Dark theme for EULA

pull/194/head
M66B 4 years ago
parent d6a231ee36
commit 2fc2ec48c9

@ -100,10 +100,8 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc
if (!this.getClass().equals(ActivityMain.class)) {
String theme = prefs.getString("theme", "blue_orange_system");
// https://developer.android.com/guide/topics/ui/look-and-feel/darktheme#configuration_changes
int uiMode = getResources().getConfiguration().uiMode;
boolean night = ((uiMode & Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_YES);
EntityLog.log(this, "Activity theme=" + theme + " UI mode=" + uiMode + " night=" + night);
boolean night = Helper.isNight(this);
EntityLog.log(this, "Activity theme=" + theme + " night=" + night);
switch (theme) {
// Light

@ -181,7 +181,10 @@ public class ActivityMain extends ActivityBase implements FragmentManager.OnBack
else
prefs.edit().putBoolean("compact", true).apply();
setTheme(R.style.AppThemeBlueOrangeLight);
if (Helper.isNight(this))
setTheme(R.style.AppThemeBlueOrangeDark);
else
setTheme(R.style.AppThemeBlueOrangeLight);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

@ -861,6 +861,13 @@ public class Helper {
view.setLayoutParams(lparam);
}
static boolean isNight(Context context) {
// https://developer.android.com/guide/topics/ui/look-and-feel/darktheme#configuration_changes
int uiMode = context.getResources().getConfiguration().uiMode;
Log.i("UI mode=" + uiMode);
return ((uiMode & Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_YES);
}
static boolean isDarkTheme(Context context) {
TypedValue tv = new TypedValue();
context.getTheme().resolveAttribute(R.attr.themeName, tv, true);

Loading…
Cancel
Save