Fix appearance

This commit is contained in:
MrLetsplay 2023-09-26 18:25:09 +02:00
parent 095dffd80a
commit 41cf364438
Signed by: mr
SSH Key Fingerprint: SHA256:92jBH80vpXyaZHjaIl47pjRq+Yt7XGTArqQg1V7hSqg

View File

@ -1,6 +1,7 @@
package com.cringe_studios.cringe_authenticator.util;
import android.annotation.SuppressLint;
import android.content.res.Configuration;
import android.util.Log;
import android.view.View;
@ -26,11 +27,22 @@ public class ThemeUtil {
if(!SettingsUtil.isThemedBackgroundEnabled(activity)) return;
Theme theme = SettingsUtil.getTheme(activity);
Appearance appearance = SettingsUtil.getAppearance(activity);
int nightMode = activity.getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
boolean isNightMode;
switch(nightMode) {
case Configuration.UI_MODE_NIGHT_NO:
default:
isNightMode = false;
break;
case Configuration.UI_MODE_NIGHT_YES:
isNightMode = true;
break;
}
View v = activity.findViewById(R.id.app_background);
if(v != null) {
v.setBackgroundResource(appearance == Appearance.LIGHT ? theme.getLightBackground() : theme.getDarkBackground());
v.setBackgroundResource(!isNightMode ? theme.getLightBackground() : theme.getDarkBackground());
}
}