]> git.ktnx.net Git - mobile-ledger.git/blobdiff - app/src/main/java/net/ktnx/mobileledger/ui/activity/MainActivity.java
handle theme change
[mobile-ledger.git] / app / src / main / java / net / ktnx / mobileledger / ui / activity / MainActivity.java
index a96a0b976d6939a7fbfb8ab5898176afe720729c..ad5da965d49ed5f11f059eb6eddd309f8c7c9c28 100644 (file)
@@ -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();