]> git.ktnx.net Git - mobile-ledger.git/commitdiff
handle theme change
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Sun, 17 Feb 2019 20:12:53 +0000 (22:12 +0200)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Sun, 17 Feb 2019 20:12:53 +0000 (22:12 +0200)
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();