From c35fe166edffe369576f713898f4b6b2658dfa8a Mon Sep 17 00:00:00 2001 From: Sylvia van Os Date: Wed, 29 Jun 2022 21:28:52 +0200 Subject: [PATCH] Fix custom theme not applying to main screen correctly We were using the SplashScreen incorrectly. While it isn't consistently documented, I managed to find a small note on https://developer.android.com/reference/kotlin/androidx/core/splashscreen/SplashScreen#usage-of-the-core-splashscreen-library: which states that installSplashScreen has to be called BEFORE onCreate. Doing this fixing some theming bugs and allows deleting a hacky and buggy workaround. --- CHANGELOG.md | 4 ++++ .../java/protect/card_locker/CatimaAppCompatActivity.java | 5 +---- app/src/main/java/protect/card_locker/MainActivity.java | 7 ++----- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0c946f9fb..a0453b888 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## Unreleased - 110 + +- Fix custom theme not applying to main screen correctly + ## v2.17.1 - 109 - Fix incorrect text colour on "No barcode" button diff --git a/app/src/main/java/protect/card_locker/CatimaAppCompatActivity.java b/app/src/main/java/protect/card_locker/CatimaAppCompatActivity.java index be07668de..8fc5d9409 100644 --- a/app/src/main/java/protect/card_locker/CatimaAppCompatActivity.java +++ b/app/src/main/java/protect/card_locker/CatimaAppCompatActivity.java @@ -19,10 +19,7 @@ public class CatimaAppCompatActivity extends AppCompatActivity { @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); - // XXX splash screen activity has to do this after installing splash screen before view inflate - if (!this.getClass().getSimpleName().equals(MainActivity.class.getSimpleName())) { - Utils.patchColors(this); - } + Utils.patchColors(this); } @Override diff --git a/app/src/main/java/protect/card_locker/MainActivity.java b/app/src/main/java/protect/card_locker/MainActivity.java index 113932adb..9af259fdc 100644 --- a/app/src/main/java/protect/card_locker/MainActivity.java +++ b/app/src/main/java/protect/card_locker/MainActivity.java @@ -218,8 +218,8 @@ public class MainActivity extends CatimaAppCompatActivity implements LoyaltyCard @Override protected void onCreate(Bundle inputSavedInstanceState) { extractIntentFields(getIntent()); - super.onCreate(inputSavedInstanceState); SplashScreen.installSplashScreen(this); + super.onCreate(inputSavedInstanceState); if(!mArchiveMode) { setTitle(R.string.app_name); setContentView(R.layout.main_activity); @@ -228,8 +228,7 @@ public class MainActivity extends CatimaAppCompatActivity implements LoyaltyCard setTitle(R.string.archiveList); setContentView(R.layout.archive_activity); } - // XXX color patching has to be done again after setting splash screen - Utils.patchColors(this); + Toolbar toolbar = findViewById(R.id.toolbar); setSupportActionBar(toolbar); @@ -242,8 +241,6 @@ public class MainActivity extends CatimaAppCompatActivity implements LoyaltyCard mDatabase = new DBHelper(this).getWritableDatabase(); - - TabLayout groupsTabLayout = findViewById(R.id.groups); groupsTabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() { @Override