From faa01b22a0f23efe6302d4787c244bb4f241b8da Mon Sep 17 00:00:00 2001 From: Damyan Ivanov Date: Mon, 26 Apr 2021 04:44:43 +0000 Subject: [PATCH] several fixes when there are no profiles after full room adoption in particular, the ProfileThemedActivity doesn't call finish() when there is no current profile, because this is exactly the case when the app has just been installed and the main activity's introductory interface needs to be shown --- .../ui/account_summary/AccountSummaryFragment.java | 3 +++ .../net/ktnx/mobileledger/ui/activity/MainActivity.java | 8 ++------ .../mobileledger/ui/activity/ProfileThemedActivity.java | 6 ++++-- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/account_summary/AccountSummaryFragment.java b/app/src/main/java/net/ktnx/mobileledger/ui/account_summary/AccountSummaryFragment.java index d5964e4b..8ad6da6f 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/account_summary/AccountSummaryFragment.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/account_summary/AccountSummaryFragment.java @@ -108,6 +108,9 @@ public class AccountSummaryFragment extends MobileLedgerListFragment { Data.observeProfile(this, this::onProfileChanged); } private void onProfileChanged(Profile profile) { + if (profile == null) + return; + DB.get() .getAccountDAO() .getAllWithAmounts(profile.getId()) diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/activity/MainActivity.java b/app/src/main/java/net/ktnx/mobileledger/ui/activity/MainActivity.java index 9f6233bc..cb7cb46c 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/activity/MainActivity.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/activity/MainActivity.java @@ -411,11 +411,7 @@ public class MainActivity extends ProfileThemedActivity implements FabManager.Fa * called when the current profile has changed */ private void onProfileChanged(@Nullable Profile newProfile) { - if (this.profile == null) { - if (newProfile == null) - return; - } - else { + if (this.profile != null) { if (this.profile.equals(newProfile)) return; } @@ -427,7 +423,7 @@ public class MainActivity extends ProfileThemedActivity implements FabManager.Fa else setTitle(R.string.app_name); - int newProfileTheme = haveProfile ? newProfile.getTheme() : -1; + int newProfileTheme = haveProfile ? newProfile.getTheme() : Colors.DEFAULT_HUE_DEG; if (newProfileTheme != Colors.profileThemeId) { Logger.debug("profiles", String.format(Locale.ENGLISH, "profile theme %d → %d", Colors.profileThemeId, diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/activity/ProfileThemedActivity.java b/app/src/main/java/net/ktnx/mobileledger/ui/activity/ProfileThemedActivity.java index a1beb94b..0b4a1fe0 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/activity/ProfileThemedActivity.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/activity/ProfileThemedActivity.java @@ -75,7 +75,6 @@ public class ProfileThemedActivity extends CrashReportingActivity { Data.observeProfile(this, profile -> { if (profile == null) { Logger.debug(TAG, "No current profile, leaving"); - finish(); return; } @@ -118,7 +117,10 @@ public class ProfileThemedActivity extends CrashReportingActivity { profile = dao.getAnySync(); } - Logger.debug(TAG, String.format(Locale.ROOT, "Profile %d loaded. posting", profileId)); + if (profile == null) + Logger.debug(TAG, "No profile could be loaded"); + else + Logger.debug(TAG, String.format(Locale.ROOT, "Profile %d loaded. posting", profileId)); Data.postCurrentProfile(profile); } } -- 2.39.2