From: Damyan Ivanov Date: Sun, 17 Feb 2019 20:12:53 +0000 (+0200) Subject: handle theme change X-Git-Tag: v0.7~69 X-Git-Url: https://git.ktnx.net/?p=mobile-ledger.git;a=commitdiff_plain;h=3c3ae0a0335f908a43efbfca7ac18e5bbee3ea7c handle theme change --- 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();