Add menu item to copy media link (#895)
This commit is contained in:
parent
4ba6b4adfe
commit
6960d725a3
2 changed files with 12 additions and 0 deletions
|
@ -19,6 +19,8 @@ import android.Manifest
|
|||
import android.animation.Animator
|
||||
import android.animation.AnimatorListenerAdapter
|
||||
import android.app.DownloadManager
|
||||
import android.content.ClipData
|
||||
import android.content.ClipboardManager
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.pm.PackageManager
|
||||
|
@ -143,6 +145,7 @@ class ViewMediaActivity : BaseActivity(), ViewImageFragment.PhotoActionsListener
|
|||
R.id.action_download -> downloadMedia()
|
||||
R.id.action_open_status -> onOpenStatus()
|
||||
R.id.action_share_media -> shareMedia()
|
||||
R.id.action_copy_media_link -> copyLink()
|
||||
}
|
||||
true
|
||||
}
|
||||
|
@ -224,6 +227,11 @@ class ViewMediaActivity : BaseActivity(), ViewImageFragment.PhotoActionsListener
|
|||
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() {
|
||||
val directory = applicationContext.getExternalFilesDir("Tusky")
|
||||
if (directory == null || !(directory.exists())) {
|
||||
|
|
|
@ -11,6 +11,10 @@
|
|||
android:icon="@drawable/ic_menu_share_24dp"
|
||||
android:title="@string/action_share"
|
||||
app:showAsAction="ifRoom" />
|
||||
<item
|
||||
android:id="@+id/action_copy_media_link"
|
||||
android:title="@string/action_copy_link"
|
||||
app:showAsAction="never" />
|
||||
<item
|
||||
android:id="@+id/action_open_status"
|
||||
android:title="@string/action_open_toot"
|
||||
|
|
Loading…
Reference in a new issue