mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-28 22:34:08 +00:00
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:
parent
ccc92e6143
commit
68083243b2
48 changed files with 234 additions and 139 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue