Add menu item to copy media link (#895)
This commit is contained in:
parent
4ba6b4adfe
commit
6960d725a3
|
@ -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…
Reference in New Issue