]> git.ktnx.net Git - mobile-ledger.git/blobdiff - app/src/main/java/net/ktnx/mobileledger/ui/activity/MainActivity.java
whitespace
[mobile-ledger.git] / app / src / main / java / net / ktnx / mobileledger / ui / activity / MainActivity.java
index a96a0b976d6939a7fbfb8ab5898176afe720729c..9cb045d7a00ec44d69c6617d2730ba0f400fbef6 100644 (file)
@@ -87,6 +87,7 @@ public class MainActivity extends CrashReportingActivity {
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
+
         setContentView(R.layout.activity_main);
         Toolbar toolbar = findViewById(R.id.toolbar);
         setSupportActionBar(toolbar);
@@ -106,6 +107,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 +190,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();
@@ -365,6 +382,11 @@ public class MainActivity extends CrashReportingActivity {
         Intent intent = new Intent(this, ProfileListActivity.class);
         startActivity(intent);
     }
+    public void fabShouldShow() {
+        MobileLedgerProfile profile = Data.profile.get();
+        if ((profile != null) && profile.isPostingPermitted()) fab.show();
+    }
+
     public class SectionsPagerAdapter extends FragmentPagerAdapter {
 
         public SectionsPagerAdapter(FragmentManager fm) {
@@ -390,8 +412,4 @@ public class MainActivity extends CrashReportingActivity {
             return 2;
         }
     }
-    public void fabShouldShow() {
-        MobileLedgerProfile profile = Data.profile.get();
-        if ((profile != null) && profile.isPostingPermitted()) fab.show();
-    }
 }