From 59184f1717ca7e6521f1a86934a152de15f86608 Mon Sep 17 00:00:00 2001 From: Christophe Beyls Date: Fri, 31 May 2024 13:23:06 +0200 Subject: [PATCH] Fix incorrect theme override outside of MainActivity (#4469) The pull request to integrate the SplashScreen library (#4413) required overriding the theme before setting the layout in `MainActivity.onCreate()`, in order to switch from `SplashTheme` to `TuskyTheme`. Since the parent `BaseActivity` already contained code to override the theme in case the user selects the "black" theme, that logic was added at the same spot in `BaseActivity`. However, since other Activities inherit from `BaseActivity` and sometimes declare a different default theme than `TuskyTheme` in the Manifest, the wrong theme was set for those Activities when not in Black theme mode. This pull request ensures that the theme will only be overridden to `TuskyTheme` in `MainActivity`, the only Activity that uses a splash screen. --- app/src/main/java/com/keylesspalace/tusky/BaseActivity.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/keylesspalace/tusky/BaseActivity.java b/app/src/main/java/com/keylesspalace/tusky/BaseActivity.java index 34c6aa9e8..2bbcf2858 100644 --- a/app/src/main/java/com/keylesspalace/tusky/BaseActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/BaseActivity.java @@ -34,7 +34,6 @@ import androidx.annotation.StringRes; import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AppCompatActivity; import androidx.lifecycle.ViewModelProvider; -import androidx.preference.PreferenceManager; import com.google.android.material.color.MaterialColors; import com.google.android.material.snackbar.Snackbar; @@ -107,7 +106,8 @@ public abstract class BaseActivity extends AppCompatActivity { Log.d("activeTheme", theme); if (ThemeUtils.isBlack(getResources().getConfiguration(), theme)) { setTheme(R.style.TuskyBlackTheme); - } else { + } else if (this instanceof MainActivity) { + // Replace the SplashTheme of MainActivity setTheme(R.style.TuskyTheme); }