allow sharing message text directly
This commit is contained in:
parent
bed6ef764f
commit
931f977c65
|
@ -36,7 +36,7 @@ android {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'com.simplemobiletools:commons:5.24.16'
|
||||
implementation 'com.simplemobiletools:commons:5.24.17'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta4'
|
||||
implementation 'org.greenrobot:eventbus:3.2.0'
|
||||
}
|
||||
|
|
|
@ -34,8 +34,10 @@ class ThreadAdapter(
|
|||
override fun getActionMenuId() = R.menu.cab_thread
|
||||
|
||||
override fun prepareActionMode(menu: Menu) {
|
||||
val isOneItemSelected = isOneItemSelected()
|
||||
menu.apply {
|
||||
findItem(R.id.cab_copy_to_clipboard).isVisible = isOneItemSelected()
|
||||
findItem(R.id.cab_copy_to_clipboard).isVisible = isOneItemSelected
|
||||
findItem(R.id.cab_share).isVisible = isOneItemSelected
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -46,6 +48,7 @@ class ThreadAdapter(
|
|||
|
||||
when (id) {
|
||||
R.id.cab_copy_to_clipboard -> copyToClipboard()
|
||||
R.id.cab_share -> shareText()
|
||||
R.id.cab_select_all -> selectAll()
|
||||
R.id.cab_delete -> askConfirmDelete()
|
||||
}
|
||||
|
@ -102,6 +105,11 @@ class ThreadAdapter(
|
|||
activity.copyToClipboard(firstItem.body)
|
||||
}
|
||||
|
||||
private fun shareText() {
|
||||
val firstItem = getSelectedItems().first() as? Message ?: return
|
||||
activity.shareTextIntent(firstItem.body)
|
||||
}
|
||||
|
||||
private fun askConfirmDelete() {
|
||||
val itemsCnt = selectedKeys.size
|
||||
val items = resources.getQuantityString(R.plurals.delete_messages, itemsCnt, itemsCnt)
|
||||
|
|
|
@ -6,6 +6,11 @@
|
|||
android:icon="@drawable/ic_copy"
|
||||
android:title="@string/copy_to_clipboard"
|
||||
app:showAsAction="ifRoom" />
|
||||
<item
|
||||
android:id="@+id/cab_share"
|
||||
android:icon="@drawable/ic_share_vector"
|
||||
android:title="@string/share"
|
||||
app:showAsAction="ifRoom" />
|
||||
<item
|
||||
android:id="@+id/cab_select_all"
|
||||
android:icon="@drawable/ic_select_all_vector"
|
||||
|
|
Loading…
Reference in New Issue