From 3c3ae0a0335f908a43efbfca7ac18e5bbee3ea7c Mon Sep 17 00:00:00 2001 From: Damyan Ivanov Date: Sun, 17 Feb 2019 22:12:53 +0200 Subject: [PATCH] handle theme change --- .../mobileledger/ui/activity/MainActivity.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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 a96a0b97..ad5da965 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 @@ -106,6 +106,14 @@ public class MainActivity extends CrashReportingActivity { toolbar.setSubtitle(R.string.profile_subitlte_read_only); fab.hide(); } + + int newProfileTheme = profile.getThemeId(); + if (newProfileTheme != Colors.profileThemeId) { + Log.d("profiles", String.format("profile theme %d → %d", Colors.profileThemeId, + newProfileTheme)); + profileThemeChanged(); + Colors.profileThemeId = newProfileTheme; + } }); }); @@ -181,6 +189,14 @@ public class MainActivity extends CrashReportingActivity { findViewById(R.id.btn_add_transaction).setOnClickListener(this::fabNewTransactionClicked); } + private void profileThemeChanged() { + setupProfileColors(); + + // restart activity to reflect theme change + finish(); + Intent intent = new Intent(this, this.getClass()); + startActivity(intent); + } @Override protected void onResume() { super.onResume(); -- 2.39.2