citra_android: Night mode fixes (#6416)
This commit is contained in:
parent
e283de9b6d
commit
cdb157f58a
|
@ -169,6 +169,8 @@ public final class MainActivity extends AppCompatActivity implements MainView {
|
|||
protected void onResume() {
|
||||
super.onResume();
|
||||
mPresenter.addDirIfNeeded(new AddDirectoryHelper(this));
|
||||
|
||||
ThemeUtil.setSystemBarMode(this, ThemeUtil.getIsLightMode(getResources()));
|
||||
}
|
||||
|
||||
// TODO: Replace with a ButterKnife injection.
|
||||
|
|
|
@ -3,6 +3,7 @@ package org.citra.citra_emu.utils;
|
|||
import android.app.Activity;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Color;
|
||||
import android.os.Build;
|
||||
import android.preference.PreferenceManager;
|
||||
|
@ -41,11 +42,7 @@ public class ThemeUtil {
|
|||
break;
|
||||
}
|
||||
|
||||
int systemReportedThemeMode = activity.getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
|
||||
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);
|
||||
|
||||
setSystemBarMode(activity, getIsLightMode(activity.getResources()));
|
||||
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);
|
||||
}
|
||||
|
||||
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) {
|
||||
int gestureType = InsetsHelper.getSystemGestureType(activity.getApplicationContext());
|
||||
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),
|
||||
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"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/colorSurface">
|
||||
|
||||
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
android:id="@+id/refresh_grid_games"
|
||||
|
|
Reference in New Issue