mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-24 16:57:50 +00:00
improve delete option ui
This commit is contained in:
parent
4ce1bd6875
commit
e8551a3545
@ -1170,6 +1170,7 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
|
||||
}
|
||||
|
||||
override fun deleteMessages(messages: Set<MessageRecord>) {
|
||||
val allSentByCurrentUser = messages.all { it.isOutgoing }
|
||||
if (thread.isOpenGroupRecipient) {
|
||||
val messageCount = messages.size
|
||||
val builder = AlertDialog.Builder(this)
|
||||
@ -1187,7 +1188,7 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
|
||||
endActionMode()
|
||||
}
|
||||
builder.show()
|
||||
} else {
|
||||
} else if (allSentByCurrentUser) {
|
||||
val bottomSheet = DeleteOptionsBottomSheet()
|
||||
bottomSheet.recipient = thread
|
||||
bottomSheet.onDeleteForMeTapped = {
|
||||
@ -1209,6 +1210,23 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
|
||||
endActionMode()
|
||||
}
|
||||
bottomSheet.show(supportFragmentManager, bottomSheet.tag)
|
||||
} else {
|
||||
val messageCount = messages.size
|
||||
val builder = AlertDialog.Builder(this)
|
||||
builder.setTitle(resources.getQuantityString(R.plurals.ConversationFragment_delete_selected_messages, messageCount, messageCount))
|
||||
builder.setMessage(resources.getQuantityString(R.plurals.ConversationFragment_this_will_permanently_delete_all_n_selected_messages, messageCount, messageCount))
|
||||
builder.setCancelable(true)
|
||||
builder.setPositiveButton(R.string.delete) { _, _ ->
|
||||
for (message in messages) {
|
||||
this.deleteLocally(message)
|
||||
}
|
||||
endActionMode()
|
||||
}
|
||||
builder.setNegativeButton(android.R.string.cancel) { dialog, _ ->
|
||||
dialog.dismiss()
|
||||
endActionMode()
|
||||
}
|
||||
builder.show()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -34,8 +34,9 @@ class ConversationActionModeCallback(private val adapter: ConversationAdapter, p
|
||||
val thread = DatabaseFactory.getThreadDatabase(context).getRecipientForThreadId(threadID)!!
|
||||
val userPublicKey = TextSecurePreferences.getLocalNumber(context)!!
|
||||
fun userCanDeleteSelectedItems(): Boolean {
|
||||
if (openGroup == null) { return true }
|
||||
val allSentByCurrentUser = selectedItems.all { it.isOutgoing }
|
||||
val allReceivedByByCurrentUser = selectedItems.all { !it.isOutgoing }
|
||||
if (openGroup == null) { return allSentByCurrentUser || allReceivedByByCurrentUser }
|
||||
if (allSentByCurrentUser) { return true }
|
||||
return OpenGroupAPIV2.isUserModerator(userPublicKey, openGroup.room, openGroup.server)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user