mirror of
				https://github.com/PabloMK7/citra.git
				synced 2025-10-30 21:30:04 +00:00 
			
		
		
		
	citra_android: Night mode fixes (#6416)
This commit is contained in:
		
							parent
							
								
									e283de9b6d
								
							
						
					
					
						commit
						cdb157f58a
					
				
					 3 changed files with 16 additions and 6 deletions
				
			
		|  | @ -169,6 +169,8 @@ public final class MainActivity extends AppCompatActivity implements MainView { | ||||||
|     protected void onResume() { |     protected void onResume() { | ||||||
|         super.onResume(); |         super.onResume(); | ||||||
|         mPresenter.addDirIfNeeded(new AddDirectoryHelper(this)); |         mPresenter.addDirIfNeeded(new AddDirectoryHelper(this)); | ||||||
|  | 
 | ||||||
|  |         ThemeUtil.setSystemBarMode(this, ThemeUtil.getIsLightMode(getResources())); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     // TODO: Replace with a ButterKnife injection. |     // TODO: Replace with a ButterKnife injection. | ||||||
|  |  | ||||||
|  | @ -3,6 +3,7 @@ package org.citra.citra_emu.utils; | ||||||
| import android.app.Activity; | import android.app.Activity; | ||||||
| import android.content.SharedPreferences; | import android.content.SharedPreferences; | ||||||
| import android.content.res.Configuration; | import android.content.res.Configuration; | ||||||
|  | import android.content.res.Resources; | ||||||
| import android.graphics.Color; | import android.graphics.Color; | ||||||
| import android.os.Build; | import android.os.Build; | ||||||
| import android.preference.PreferenceManager; | import android.preference.PreferenceManager; | ||||||
|  | @ -41,11 +42,7 @@ public class ThemeUtil { | ||||||
|                 break; |                 break; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         int systemReportedThemeMode = activity.getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK; |         setSystemBarMode(activity, getIsLightMode(activity.getResources())); | ||||||
|         WindowInsetsControllerCompat windowController = WindowCompat.getInsetsController(activity.getWindow(), activity.getWindow().getDecorView()); |  | ||||||
|         windowController.setAppearanceLightStatusBars(systemReportedThemeMode == Configuration.UI_MODE_NIGHT_NO); |  | ||||||
|         windowController.setAppearanceLightNavigationBars(systemReportedThemeMode == Configuration.UI_MODE_NIGHT_NO); |  | ||||||
| 
 |  | ||||||
|         setNavigationBarColor(activity, MaterialColors.getColor(activity.getWindow().getDecorView(), R.attr.colorSurface)); |         setNavigationBarColor(activity, MaterialColors.getColor(activity.getWindow().getDecorView(), R.attr.colorSurface)); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | @ -53,6 +50,12 @@ public class ThemeUtil { | ||||||
|         applyTheme(mPreferences.getInt(SettingsFile.KEY_DESIGN, 0), activity); |         applyTheme(mPreferences.getInt(SettingsFile.KEY_DESIGN, 0), activity); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     public static void setSystemBarMode(AppCompatActivity activity, boolean isLightMode) { | ||||||
|  |         WindowInsetsControllerCompat windowController = WindowCompat.getInsetsController(activity.getWindow(), activity.getWindow().getDecorView()); | ||||||
|  |         windowController.setAppearanceLightStatusBars(isLightMode); | ||||||
|  |         windowController.setAppearanceLightNavigationBars(isLightMode); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     public static void setNavigationBarColor(@NonNull Activity activity, @ColorInt int color) { |     public static void setNavigationBarColor(@NonNull Activity activity, @ColorInt int color) { | ||||||
|         int gestureType = InsetsHelper.getSystemGestureType(activity.getApplicationContext()); |         int gestureType = InsetsHelper.getSystemGestureType(activity.getApplicationContext()); | ||||||
|         int orientation = activity.getResources().getConfiguration().orientation; |         int orientation = activity.getResources().getConfiguration().orientation; | ||||||
|  | @ -80,4 +83,8 @@ public class ThemeUtil { | ||||||
|         return Color.argb(Math.round(alphaFactor * Color.alpha(color)), Color.red(color), |         return Color.argb(Math.round(alphaFactor * Color.alpha(color)), Color.red(color), | ||||||
|                 Color.green(color), Color.blue(color)); |                 Color.green(color), Color.blue(color)); | ||||||
|     } |     } | ||||||
|  | 
 | ||||||
|  |     public static boolean getIsLightMode(Resources resources) { | ||||||
|  |         return (resources.getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_NO; | ||||||
|  |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -2,7 +2,8 @@ | ||||||
| <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" | <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||||||
|     xmlns:tools="http://schemas.android.com/tools" |     xmlns:tools="http://schemas.android.com/tools" | ||||||
|     android:layout_width="match_parent" |     android:layout_width="match_parent" | ||||||
|     android:layout_height="match_parent"> |     android:layout_height="match_parent" | ||||||
|  |     android:background="?attr/colorSurface"> | ||||||
| 
 | 
 | ||||||
|     <androidx.swiperefreshlayout.widget.SwipeRefreshLayout |     <androidx.swiperefreshlayout.widget.SwipeRefreshLayout | ||||||
|         android:id="@+id/refresh_grid_games" |         android:id="@+id/refresh_grid_games" | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue