From 41cf3644382489399b64ea58f7bd9cd1e8c748d0 Mon Sep 17 00:00:00 2001 From: MrLetsplay Date: Tue, 26 Sep 2023 18:25:09 +0200 Subject: [PATCH] Fix appearance --- .../cringe_authenticator/util/ThemeUtil.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/cringe_studios/cringe_authenticator/util/ThemeUtil.java b/app/src/main/java/com/cringe_studios/cringe_authenticator/util/ThemeUtil.java index 4a54c83..682dc06 100644 --- a/app/src/main/java/com/cringe_studios/cringe_authenticator/util/ThemeUtil.java +++ b/app/src/main/java/com/cringe_studios/cringe_authenticator/util/ThemeUtil.java @@ -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()); } }