From 004ea5b87a82dc920a37565d83ad0135ecef3d0b Mon Sep 17 00:00:00 2001 From: Niels Andriesse Date: Fri, 9 Jul 2021 09:24:43 +1000 Subject: [PATCH] Fix various crashes --- .../securesms/conversation/v2/ConversationActivityV2.kt | 2 +- .../securesms/conversation/v2/messages/VisibleMessageView.kt | 2 +- .../java/org/thoughtcrime/securesms/database/MmsDatabase.java | 1 + .../securesms/loki/activities/CreatePrivateChatActivity.kt | 1 + 4 files changed, 4 insertions(+), 2 deletions(-) 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 eeb9deacab..85ac3e4807 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 @@ -1260,7 +1260,7 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe } private fun saveDraft() { - val text = inputBar.text.trim() + val text = inputBar?.text?.trim() ?: return if (text.isEmpty()) { return } val drafts = Drafts() drafts.add(DraftDatabase.Draft(DraftDatabase.Draft.TEXT, text)) diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/VisibleMessageView.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/VisibleMessageView.kt index ad90bd5328..0cd7831add 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/VisibleMessageView.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/VisibleMessageView.kt @@ -82,7 +82,7 @@ class VisibleMessageView : LinearLayout { val senderSessionID = sender.address.serialize() val threadID = message.threadId val threadDB = DatabaseFactory.getThreadDatabase(context) - val thread = threadDB.getRecipientForThreadId(threadID)!! + val thread = threadDB.getRecipientForThreadId(threadID) ?: return val contactDB = DatabaseFactory.getSessionContactDatabase(context) val isGroupThread = thread.isGroupRecipient val isStartOfMessageCluster = isStartOfMessageCluster(message, previous, isGroupThread) diff --git a/app/src/main/java/org/thoughtcrime/securesms/database/MmsDatabase.java b/app/src/main/java/org/thoughtcrime/securesms/database/MmsDatabase.java index 87b59132d4..ef68a39cea 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/database/MmsDatabase.java +++ b/app/src/main/java/org/thoughtcrime/securesms/database/MmsDatabase.java @@ -883,6 +883,7 @@ public class MmsDatabase extends MessagingDatabase { } public void deleteQuotedFromMessages(MessageRecord toDeleteRecord) { + if (toDeleteRecord == null) { return; } String query = THREAD_ID + " = ?"; Cursor threadMmsCursor = rawQuery(query, new String[]{String.valueOf(toDeleteRecord.getThreadId())}); Reader reader = readerFor(threadMmsCursor); diff --git a/app/src/main/java/org/thoughtcrime/securesms/loki/activities/CreatePrivateChatActivity.kt b/app/src/main/java/org/thoughtcrime/securesms/loki/activities/CreatePrivateChatActivity.kt index 6eedd97013..eeb9ae833b 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/loki/activities/CreatePrivateChatActivity.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/loki/activities/CreatePrivateChatActivity.kt @@ -191,6 +191,7 @@ class EnterPublicKeyFragment : Fragment() { } private fun handleIsKeyboardShowingChanged() { + val optionalContentContainer = optionalContentContainer ?: return optionalContentContainer.isVisible = !isKeyboardShowing }