Add an in-out boolean color-scheme property to Palette (#4701)

This allows applications to force dark/light mode, as well as determine
which mode is active.
This commit is contained in:
Simon Hausmann 2024-03-26 15:44:22 +01:00 committed by GitHub
parent ccc92e6143
commit 68083243b2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
48 changed files with 234 additions and 139 deletions

View file

@ -211,14 +211,7 @@ class SlintInputView extends View {
protected void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
int currentNightMode = newConfig.uiMode & Configuration.UI_MODE_NIGHT_MASK;
switch (currentNightMode) {
case Configuration.UI_MODE_NIGHT_NO:
SlintAndroidJavaHelper.setDarkMode(false);
break;
case Configuration.UI_MODE_NIGHT_YES:
SlintAndroidJavaHelper.setDarkMode(true);
break;
}
SlintAndroidJavaHelper.setNightMode(currentNightMode);
}
private InputHandle mCursorHandle;
@ -423,7 +416,7 @@ public class SlintAndroidJavaHelper {
static public native void updateText(String text, int cursorPosition, int anchorPosition, int preeditStart,
int preeditOffset);
static public native void setDarkMode(boolean dark);
static public native void setNightMode(int nightMode);
static public native void moveCursorHandle(int id, int pos_x, int pos_y);
@ -462,9 +455,9 @@ public class SlintAndroidJavaHelper {
});
}
public boolean dark_color_scheme() {
public int color_scheme() {
int nightModeFlags = mActivity.getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
return nightModeFlags == Configuration.UI_MODE_NIGHT_YES;
return nightModeFlags;
}
// Get the geometry of the view minus the system bars and the keyboard