mirror of
https://github.com/oxen-io/session-android.git
synced 2025-01-12 00:23:40 +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>) {
|
override fun deleteMessages(messages: Set<MessageRecord>) {
|
||||||
|
val allSentByCurrentUser = messages.all { it.isOutgoing }
|
||||||
if (thread.isOpenGroupRecipient) {
|
if (thread.isOpenGroupRecipient) {
|
||||||
val messageCount = messages.size
|
val messageCount = messages.size
|
||||||
val builder = AlertDialog.Builder(this)
|
val builder = AlertDialog.Builder(this)
|
||||||
@ -1187,7 +1188,7 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
|
|||||||
endActionMode()
|
endActionMode()
|
||||||
}
|
}
|
||||||
builder.show()
|
builder.show()
|
||||||
} else {
|
} else if (allSentByCurrentUser) {
|
||||||
val bottomSheet = DeleteOptionsBottomSheet()
|
val bottomSheet = DeleteOptionsBottomSheet()
|
||||||
bottomSheet.recipient = thread
|
bottomSheet.recipient = thread
|
||||||
bottomSheet.onDeleteForMeTapped = {
|
bottomSheet.onDeleteForMeTapped = {
|
||||||
@ -1209,6 +1210,23 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
|
|||||||
endActionMode()
|
endActionMode()
|
||||||
}
|
}
|
||||||
bottomSheet.show(supportFragmentManager, bottomSheet.tag)
|
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 thread = DatabaseFactory.getThreadDatabase(context).getRecipientForThreadId(threadID)!!
|
||||||
val userPublicKey = TextSecurePreferences.getLocalNumber(context)!!
|
val userPublicKey = TextSecurePreferences.getLocalNumber(context)!!
|
||||||
fun userCanDeleteSelectedItems(): Boolean {
|
fun userCanDeleteSelectedItems(): Boolean {
|
||||||
if (openGroup == null) { return true }
|
|
||||||
val allSentByCurrentUser = selectedItems.all { it.isOutgoing }
|
val allSentByCurrentUser = selectedItems.all { it.isOutgoing }
|
||||||
|
val allReceivedByByCurrentUser = selectedItems.all { !it.isOutgoing }
|
||||||
|
if (openGroup == null) { return allSentByCurrentUser || allReceivedByByCurrentUser }
|
||||||
if (allSentByCurrentUser) { return true }
|
if (allSentByCurrentUser) { return true }
|
||||||
return OpenGroupAPIV2.isUserModerator(userPublicKey, openGroup.room, openGroup.server)
|
return OpenGroupAPIV2.isUserModerator(userPublicKey, openGroup.room, openGroup.server)
|
||||||
}
|
}
|
||||||
|
@ -128,7 +128,7 @@ public class MmsSmsDatabase extends Database {
|
|||||||
public Cursor getConversationSnippet(long threadId) {
|
public Cursor getConversationSnippet(long threadId) {
|
||||||
String order = MmsSmsColumns.NORMALIZED_DATE_RECEIVED + " DESC";
|
String order = MmsSmsColumns.NORMALIZED_DATE_RECEIVED + " DESC";
|
||||||
String selection = MmsSmsColumns.THREAD_ID + " = " + threadId;
|
String selection = MmsSmsColumns.THREAD_ID + " = " + threadId;
|
||||||
|
|
||||||
return queryTables(PROJECTION, selection, order, null);
|
return queryTables(PROJECTION, selection, order, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user