From b2b2c36ecbd54648f5bd52a8a5a845402dd848c5 Mon Sep 17 00:00:00 2001 From: nielsandriesse Date: Thu, 24 Sep 2020 09:43:18 +1000 Subject: [PATCH] Hopefully fix crash --- src/org/thoughtcrime/securesms/ApplicationContext.java | 4 +++- .../thoughtcrime/securesms/loki/activities/HomeActivity.kt | 1 + .../thoughtcrime/securesms/loki/activities/PNModeActivity.kt | 1 - 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/org/thoughtcrime/securesms/ApplicationContext.java b/src/org/thoughtcrime/securesms/ApplicationContext.java index 11d4dc48d4..29a668776d 100644 --- a/src/org/thoughtcrime/securesms/ApplicationContext.java +++ b/src/org/thoughtcrime/securesms/ApplicationContext.java @@ -216,7 +216,9 @@ public class ApplicationContext extends MultiDexApplication implements Dependenc resubmitProfilePictureIfNeeded(); publicChatManager = new PublicChatManager(this); updateOpenGroupProfilePicturesIfNeeded(); - registerForFCMIfNeeded(false); + if (userPublicKey != null) { + registerForFCMIfNeeded(false); + } // Set application UI mode (day/night theme) to the user selected one. UiModeUtilities.setupUiModeToUserSelected(this); // ======== diff --git a/src/org/thoughtcrime/securesms/loki/activities/HomeActivity.kt b/src/org/thoughtcrime/securesms/loki/activities/HomeActivity.kt index e0bba59ccf..5c81027f7d 100644 --- a/src/org/thoughtcrime/securesms/loki/activities/HomeActivity.kt +++ b/src/org/thoughtcrime/securesms/loki/activities/HomeActivity.kt @@ -172,6 +172,7 @@ class HomeActivity : PassphraseRequiredActionBarActivity, ConversationClickListe SessionManagementProtocol.configureIfNeeded(sessionResetImpl, sskDatabase, application) MultiDeviceProtocol.configureIfNeeded(apiDB) IP2Country.configureIfNeeded(this) + application.registerForFCMIfNeeded(false) // Preload device links to make message sending quicker val publicKeys = ContactUtilities.getAllContacts(this).filter { contact -> !contact.recipient.isGroupRecipient && !contact.isOurDevice && !contact.isSlave diff --git a/src/org/thoughtcrime/securesms/loki/activities/PNModeActivity.kt b/src/org/thoughtcrime/securesms/loki/activities/PNModeActivity.kt index 75102938b9..03e0dec356 100644 --- a/src/org/thoughtcrime/securesms/loki/activities/PNModeActivity.kt +++ b/src/org/thoughtcrime/securesms/loki/activities/PNModeActivity.kt @@ -158,7 +158,6 @@ class PNModeActivity : BaseActionBarActivity() { val application = ApplicationContext.getInstance(this) application.setUpStorageAPIIfNeeded() application.setUpP2PAPIIfNeeded() - application.registerForFCMIfNeeded(true) val intent = Intent(this, HomeActivity::class.java) intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK show(intent)