@@ -129,18 +129,17 @@ public void onActivityCreated(@NonNull Activity activity, @Nullable Bundle saved
129129 if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .VANILLA_ICE_CREAM ) {
130130 android .widget .FrameLayout content = activity .findViewById (android .R .id .content );
131131
132- SharedPreferences prefs = PreferenceManager .getDefaultSharedPreferences (activity );
133- boolean dark = prefs .getBoolean ("dark_theme" , false );
134-
135132 // On Android 15+, setStatusBarColor is ignored
136133 // Set window background to primary color - this shows behind the status bar
137134 int primaryColor = ContextCompat .getColor (activity , R .color .colorPrimary );
138135 activity .getWindow ().setBackgroundDrawable (new ColorDrawable (primaryColor ));
139136
137+ boolean isNight = (activity .getResources ().getConfiguration ().uiMode & android .content .res .Configuration .UI_MODE_NIGHT_MASK ) == android .content .res .Configuration .UI_MODE_NIGHT_YES ;
138+
140139 // Set status bar icons to light (white) since our background is dark
141140 View decor = activity .getWindow ().getDecorView ();
142141 WindowCompat .getInsetsController (activity .getWindow (), decor ).setAppearanceLightStatusBars (false );
143- WindowCompat .getInsetsController (activity .getWindow (), decor ).setAppearanceLightNavigationBars (!dark );
142+ WindowCompat .getInsetsController (activity .getWindow (), decor ).setAppearanceLightNavigationBars (!isNight );
144143
145144 ViewCompat .setOnApplyWindowInsetsListener (content , new OnApplyWindowInsetsListener () {
146145 @ NonNull
@@ -157,8 +156,9 @@ public WindowInsetsCompat onApplyWindowInsets(@NonNull View v, @NonNull WindowIn
157156 // Set background on the actual layout (first child), not on the content frame
158157 // This way the padding area shows the window background (primary color)
159158 if (content .getChildCount () > 0 ) {
159+ boolean isNight = (activity .getResources ().getConfiguration ().uiMode & android .content .res .Configuration .UI_MODE_NIGHT_MASK ) == android .content .res .Configuration .UI_MODE_NIGHT_YES ;
160160 View child = content .getChildAt (0 );
161- child .setBackgroundColor (dark ? Color .BLACK : Color .WHITE );
161+ child .setBackgroundColor (isNight ? Color .BLACK : Color .WHITE );
162162 }
163163
164164 return insets ;
0 commit comments