From b03ba5bfa7ac3c122ac399f59b276a20e59b23c6 Mon Sep 17 00:00:00 2001 From: ryanzhao Date: Tue, 17 Aug 2021 16:16:17 +1000 Subject: [PATCH] clean --- .../attachments/DatabaseAttachmentProvider.kt | 2 +- .../conversation/v2/ConversationActivityV2.kt | 10 +++++----- .../v2/menus/ConversationActionModeCallback.kt | 6 +++--- .../layout/fragment_delete_message_bottom_sheet.xml | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/attachments/DatabaseAttachmentProvider.kt b/app/src/main/java/org/thoughtcrime/securesms/attachments/DatabaseAttachmentProvider.kt index 2ed700cb3d..e2f78eecc7 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/attachments/DatabaseAttachmentProvider.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/attachments/DatabaseAttachmentProvider.kt @@ -178,7 +178,7 @@ class DatabaseAttachmentProvider(context: Context, helper: SQLCipherOpenHelper) override fun updateMessageAsDeleted(timestamp: Long, author: String) { val database = DatabaseFactory.getMmsSmsDatabase(context) val address = Address.fromSerialized(author) - val message = database.getMessageFor(timestamp, address)!! + val message = database.getMessageFor(timestamp, address) ?: return val messagingDatabase: MessagingDatabase = if (message.isMms) DatabaseFactory.getMmsDatabase(context) else DatabaseFactory.getSmsDatabase(context) messagingDatabase.markAsDeleted(message.id, message.isRead) diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt index f8772bff45..b5aa6a1ae3 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt @@ -211,7 +211,7 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe const val INVITE_CONTACTS = 124 //flag - val isUnsendRequestsEnabled = false + const val IS_UNSEND_REQUESTS_ENABLED = false } // endregion @@ -1121,7 +1121,7 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe stopAudioHandler.removeCallbacks(stopVoiceMessageRecordingTask) } - private fun buildUsendRequest(message: MessageRecord): UnsendRequest? { + private fun buildUnsendRequest(message: MessageRecord): UnsendRequest? { if (this.thread.isOpenGroupRecipient) return null val messageDataProvider = MessagingModuleConfiguration.shared.messageDataProvider messageDataProvider.getServerHashForMessage(message.id) ?: return null @@ -1137,7 +1137,7 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe } private fun deleteLocally(message: MessageRecord) { - buildUsendRequest(message)?.let { unsendRequest -> + buildUnsendRequest(message)?.let { unsendRequest -> TextSecurePreferences.getLocalNumber(this@ConversationActivityV2)?.let { MessageSender.send(unsendRequest, Address.fromSerialized(it)) } @@ -1146,7 +1146,7 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe } private fun deleteForEveryone(message: MessageRecord) { - buildUsendRequest(message)?.let { unsendRequest -> + buildUnsendRequest(message)?.let { unsendRequest -> MessageSender.send(unsendRequest, thread.address) } val messageDataProvider = MessagingModuleConfiguration.shared.messageDataProvider @@ -1218,7 +1218,7 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe } override fun deleteMessages(messages: Set) { - if (!isUnsendRequestsEnabled) { + if (!IS_UNSEND_REQUESTS_ENABLED) { deleteMessagesWithoutUnsendRequest(messages) return } diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/menus/ConversationActionModeCallback.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/menus/ConversationActionModeCallback.kt index f9603f935f..48772f8adf 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/menus/ConversationActionModeCallback.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/menus/ConversationActionModeCallback.kt @@ -38,14 +38,14 @@ class ConversationActionModeCallback(private val adapter: ConversationAdapter, p val allSentByCurrentUser = selectedItems.all { it.isOutgoing } // Remove this after the unsend request is enabled - if (!ConversationActivityV2.isUnsendRequestsEnabled) { + if (!ConversationActivityV2.IS_UNSEND_REQUESTS_ENABLED) { if (openGroup == null) { return true } if (allSentByCurrentUser) { return true } return OpenGroupAPIV2.isUserModerator(userPublicKey, openGroup.room, openGroup.server) } - val allReceivedByByCurrentUser = selectedItems.all { !it.isOutgoing } - if (openGroup == null) { return allSentByCurrentUser || allReceivedByByCurrentUser } + val allReceivedByCurrentUser = selectedItems.all { !it.isOutgoing } + if (openGroup == null) { return allSentByCurrentUser || allReceivedByCurrentUser } if (allSentByCurrentUser) { return true } return OpenGroupAPIV2.isUserModerator(userPublicKey, openGroup.room, openGroup.server) } diff --git a/app/src/main/res/layout/fragment_delete_message_bottom_sheet.xml b/app/src/main/res/layout/fragment_delete_message_bottom_sheet.xml index 592701ae08..031813a7c5 100644 --- a/app/src/main/res/layout/fragment_delete_message_bottom_sheet.xml +++ b/app/src/main/res/layout/fragment_delete_message_bottom_sheet.xml @@ -13,13 +13,13 @@ android:id="@+id/deleteForMeTextView" style="@style/BottomSheetActionItem" android:text="@string/delete_message_for_me" - android:textColor="@color/core_red"/> + android:textColor="@color/destructive"/> + android:textColor="@color/destructive"/>