mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-22 18:00:02 +01:00
Improve the Android 12 splash screen.
This commit is contained in:
@@ -11,16 +11,14 @@ import androidx.appcompat.app.AppCompatDelegate;
|
||||
|
||||
import org.signal.core.util.logging.Log;
|
||||
import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.keyvalue.SettingsValues;
|
||||
import org.thoughtcrime.securesms.keyvalue.SettingsValues.Theme;
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore;
|
||||
|
||||
public class DynamicTheme {
|
||||
|
||||
private static final String TAG = Log.tag(DynamicTheme.class);
|
||||
|
||||
public static final String DARK = "dark";
|
||||
public static final String LIGHT = "light";
|
||||
public static final String SYSTEM = "system";
|
||||
|
||||
private static int globalNightModeConfiguration;
|
||||
|
||||
private int onCreateNightModeConfiguration;
|
||||
@@ -55,9 +53,9 @@ public class DynamicTheme {
|
||||
}
|
||||
|
||||
public static void setDefaultDayNightMode(@NonNull Context context) {
|
||||
String theme = SignalStore.settings().getTheme();
|
||||
Theme theme = SignalStore.settings().getTheme();
|
||||
|
||||
if (theme.equals(SYSTEM)) {
|
||||
if (theme == Theme.SYSTEM) {
|
||||
Log.d(TAG, "Setting to follow system expecting: " + ConfigurationUtil.getNightModeConfiguration(context.getApplicationContext()));
|
||||
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM);
|
||||
} else if (DynamicTheme.isDarkTheme(context)) {
|
||||
@@ -75,12 +73,12 @@ public class DynamicTheme {
|
||||
* Takes the system theme into account.
|
||||
*/
|
||||
public static boolean isDarkTheme(@NonNull Context context) {
|
||||
String theme = SignalStore.settings().getTheme();
|
||||
Theme theme = SignalStore.settings().getTheme();
|
||||
|
||||
if (theme.equals(SYSTEM) && systemThemeAvailable()) {
|
||||
if (theme == Theme.SYSTEM && systemThemeAvailable()) {
|
||||
return isSystemInDarkTheme(context);
|
||||
} else {
|
||||
return theme.equals(DARK);
|
||||
return theme == Theme.DARK;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
package org.thoughtcrime.securesms.util;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Build;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.keyvalue.SettingsValues;
|
||||
|
||||
public final class SplashScreenUtil {
|
||||
private SplashScreenUtil() {}
|
||||
|
||||
/**
|
||||
* Sets the splash screen for Android 12+ devices based on the passed-in theme.
|
||||
*/
|
||||
public static void setSplashScreenThemeIfNecessary(@Nullable Activity activity, @NonNull SettingsValues.Theme theme) {
|
||||
if (Build.VERSION.SDK_INT < 31 || activity == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (theme) {
|
||||
case LIGHT:
|
||||
activity.getSplashScreen().setSplashScreenTheme(R.style.Theme_Signal_DayNight_NoActionBar_LightSplash);
|
||||
break;
|
||||
case DARK:
|
||||
activity.getSplashScreen().setSplashScreenTheme(R.style.Theme_Signal_DayNight_NoActionBar_DarkSplash);
|
||||
break;
|
||||
case SYSTEM:
|
||||
activity.getSplashScreen().setSplashScreenTheme(Resources.ID_NULL);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -774,7 +774,7 @@ public class TextSecurePreferences {
|
||||
* @deprecated Use {@link SettingsValues#getTheme()} via {@link org.thoughtcrime.securesms.keyvalue.SignalStore} instead.
|
||||
*/
|
||||
public static String getTheme(Context context) {
|
||||
return getStringPreference(context, THEME_PREF, DynamicTheme.systemThemeAvailable() ? DynamicTheme.SYSTEM : DynamicTheme.LIGHT);
|
||||
return getStringPreference(context, THEME_PREF, DynamicTheme.systemThemeAvailable() ? "system" : "light");
|
||||
}
|
||||
|
||||
public static boolean isShowInviteReminders(Context context) {
|
||||
|
||||
Reference in New Issue
Block a user