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