From 727d0a7a8b4cc0b4d473bcb355585e2608371ff9 Mon Sep 17 00:00:00 2001 From: alperozturk Date: Thu, 12 Oct 2023 15:02:19 +0200 Subject: [PATCH] Check system uiMode Signed-off-by: alperozturk --- .../client/preferences/AppPreferencesImpl.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/nextcloud/client/preferences/AppPreferencesImpl.java b/app/src/main/java/com/nextcloud/client/preferences/AppPreferencesImpl.java index 0449a103b3..3e0ea437fb 100644 --- a/app/src/main/java/com/nextcloud/client/preferences/AppPreferencesImpl.java +++ b/app/src/main/java/com/nextcloud/client/preferences/AppPreferencesImpl.java @@ -26,6 +26,7 @@ package com.nextcloud.client.preferences; import android.annotation.SuppressLint; import android.content.Context; import android.content.SharedPreferences; +import android.content.res.Configuration; import com.google.gson.Gson; import com.nextcloud.appReview.AppReviewShownModel; @@ -437,7 +438,14 @@ public final class AppPreferencesImpl implements AppPreferences { @Override public boolean isDarkModeEnabled() { - return getDarkThemeMode() == DarkMode.DARK; + DarkMode mode = getDarkThemeMode(); + + if (mode == DarkMode.SYSTEM) { + int currentNightMode = context.getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK; + return currentNightMode == Configuration.UI_MODE_NIGHT_YES; + } + + return mode == DarkMode.DARK; } @Override