Add menu item to copy media link (#895)

This commit is contained in:
Levi Bard 2018-11-01 15:13:37 +01:00 committed by Konrad Pozniak
parent 4ba6b4adfe
commit 6960d725a3
2 changed files with 12 additions and 0 deletions

View File

@ -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())) {

View File

@ -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"