Add menu item to copy media link (#895)

main
Levi Bard 6 years ago committed by Konrad Pozniak
parent c05eaae317
commit e03482d759
  1. 8
      app/src/main/java/com/keylesspalace/tusky/ViewMediaActivity.kt
  2. 4
      app/src/main/res/menu/view_media_toolbar.xml

@ -19,6 +19,8 @@ import android.Manifest
import android.animation.Animator import android.animation.Animator
import android.animation.AnimatorListenerAdapter import android.animation.AnimatorListenerAdapter
import android.app.DownloadManager import android.app.DownloadManager
import android.content.ClipData
import android.content.ClipboardManager
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import android.content.pm.PackageManager import android.content.pm.PackageManager
@ -143,6 +145,7 @@ class ViewMediaActivity : BaseActivity(), ViewImageFragment.PhotoActionsListener
R.id.action_download -> downloadMedia() R.id.action_download -> downloadMedia()
R.id.action_open_status -> onOpenStatus() R.id.action_open_status -> onOpenStatus()
R.id.action_share_media -> shareMedia() R.id.action_share_media -> shareMedia()
R.id.action_copy_media_link -> copyLink()
} }
true true
} }
@ -224,6 +227,11 @@ class ViewMediaActivity : BaseActivity(), ViewImageFragment.PhotoActionsListener
startActivityWithSlideInAnimation(ViewThreadActivity.startIntent(this, attach.statusId, attach.statusUrl)) startActivityWithSlideInAnimation(ViewThreadActivity.startIntent(this, attach.statusId, attach.statusUrl))
} }
private fun copyLink() {
val clipboard = getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
clipboard.primaryClip = ClipData.newPlainText(null, attachments!![viewPager.currentItem].attachment.url)
}
private fun shareMedia() { private fun shareMedia() {
val directory = applicationContext.getExternalFilesDir("Tusky") val directory = applicationContext.getExternalFilesDir("Tusky")
if (directory == null || !(directory.exists())) { if (directory == null || !(directory.exists())) {

@ -11,6 +11,10 @@
android:icon="@drawable/ic_menu_share_24dp" android:icon="@drawable/ic_menu_share_24dp"
android:title="@string/action_share" android:title="@string/action_share"
app:showAsAction="ifRoom" /> app:showAsAction="ifRoom" />
<item
android:id="@+id/action_copy_media_link"
android:title="@string/action_copy_link"
app:showAsAction="never" />
<item <item
android:id="@+id/action_open_status" android:id="@+id/action_open_status"
android:title="@string/action_open_toot" android:title="@string/action_open_toot"

Loading…
Cancel
Save