fix black theme on Android 12

This commit is contained in:
Konrad Pozniak 2022-04-08 20:16:06 +02:00
parent f570aba492
commit 2286706fdb
3 changed files with 30 additions and 7 deletions

View File

@ -66,13 +66,15 @@ public abstract class BaseActivity extends AppCompatActivity implements Injectab
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
/* There isn't presently a way to globally change the theme of a whole application at
* runtime, just individual activities. So, each activity has to set its theme before any
* views are created. */
String theme = preferences.getString("appTheme", ThemeUtils.APP_THEME_DEFAULT);
Log.d("activeTheme", theme);
if (theme.equals("black")) {
setTheme(R.style.TuskyBlackTheme);
if (!setsTheme()) {
/* There isn't presently a way to globally change the theme of a whole application at
* runtime, just individual activities. So, each activity has to set its theme before any
* views are created. */
String theme = preferences.getString("appTheme", ThemeUtils.APP_THEME_DEFAULT);
Log.d("activeTheme", theme);
if (theme.equals("black")) {
setTheme(R.style.TuskyBlackTheme);
}
}
/* set the taskdescription programmatically, the theme would turn it blue */
@ -101,6 +103,12 @@ public abstract class BaseActivity extends AppCompatActivity implements Injectab
return true;
}
/* override this in your activity if it does set it's own theme
and BaseActivity should not handle it*/
protected boolean setsTheme() {
return false;
}
private static int textStyle(String name) {
int style;
switch (name) {

View File

@ -81,6 +81,7 @@ import com.keylesspalace.tusky.settings.PrefKeys
import com.keylesspalace.tusky.util.ThemeUtils
import com.keylesspalace.tusky.util.deleteStaleCachedMedia
import com.keylesspalace.tusky.util.emojify
import com.keylesspalace.tusky.util.getNonNullString
import com.keylesspalace.tusky.util.hide
import com.keylesspalace.tusky.util.removeShortcut
import com.keylesspalace.tusky.util.updateShortcut
@ -160,7 +161,13 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje
}
override fun onCreate(savedInstanceState: Bundle?) {
val theme = preferences.getNonNullString("appTheme", ThemeUtils.APP_THEME_DEFAULT)
if (theme == "black") {
setTheme(R.style.BlackSplashTheme)
}
installSplashScreen()
super.onCreate(savedInstanceState)
// delete old notification channels
@ -278,6 +285,8 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje
}
}
override fun setsTheme() = true
override fun onResume() {
super.onResume()
NotificationHelper.clearNotificationsForActiveAccount(this, accountManager)

View File

@ -36,6 +36,12 @@
<item name="postSplashScreenTheme">@style/TuskyTheme</item>
</style>
<style name="BlackSplashTheme" parent="Theme.SplashScreen">
<item name="windowSplashScreenAnimatedIcon">@drawable/ic_splash</item>
<item name="windowSplashScreenBackground">@color/black</item>
<item name="postSplashScreenTheme">@style/TuskyBlackTheme</item>
</style>
<style name="TuskyTheme" parent="TuskyBaseTheme" />
<style name="TuskyDialogActivityTheme" parent="@style/TuskyTheme" />