X-Git-Url: https://git.ktnx.net/?p=mobile-ledger.git;a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fnet%2Fktnx%2Fmobileledger%2Fui%2Factivity%2FMainActivity.java;h=9cb045d7a00ec44d69c6617d2730ba0f400fbef6;hp=a96a0b976d6939a7fbfb8ab5898176afe720729c;hb=889caa76c8e742031ad6cf7b8757fedfc06b52fe;hpb=254ccdbeec488fb1309513a3ff9be28f9b06855c 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..9cb045d7 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 @@ -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(); - } }