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.
This commit is contained in:
Sylvia van Os
2022-06-29 21:28:52 +02:00
parent 1c2e810319
commit c35fe166ed
3 changed files with 7 additions and 9 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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