mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-04-26 03:18:47 +02:00
Added SDL_GetSystemTheme() to return whether the system is using a dark or light color theme, and SDL_EVENT_SYSTEM_THEME_CHANGED is sent when this changes
Fixes https://github.com/libsdl-org/SDL/issues/5334 Fixes https://github.com/libsdl-org/SDL/issues/6958 Closes https://github.com/libsdl-org/SDL/pull/6440
This commit is contained in:
@@ -412,6 +412,15 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
|
||||
} catch(Exception ignored) {
|
||||
}
|
||||
|
||||
switch (getContext().getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) {
|
||||
case Configuration.UI_MODE_NIGHT_NO:
|
||||
SDLActivity.onNativeDarkModeChanged(false);
|
||||
break;
|
||||
case Configuration.UI_MODE_NIGHT_YES:
|
||||
SDLActivity.onNativeDarkModeChanged(true);
|
||||
break;
|
||||
}
|
||||
|
||||
setContentView(mLayout);
|
||||
|
||||
setWindowStyle(false);
|
||||
@@ -577,6 +586,15 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
|
||||
mCurrentLocale = newConfig.locale;
|
||||
SDLActivity.onNativeLocaleChanged();
|
||||
}
|
||||
|
||||
switch (newConfig.uiMode & Configuration.UI_MODE_NIGHT_MASK) {
|
||||
case Configuration.UI_MODE_NIGHT_NO:
|
||||
SDLActivity.onNativeDarkModeChanged(false);
|
||||
break;
|
||||
case Configuration.UI_MODE_NIGHT_YES:
|
||||
SDLActivity.onNativeDarkModeChanged(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -931,6 +949,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
|
||||
public static native void nativeAddTouch(int touchId, String name);
|
||||
public static native void nativePermissionResult(int requestCode, boolean result);
|
||||
public static native void onNativeLocaleChanged();
|
||||
public static native void onNativeDarkModeChanged(boolean enabled);
|
||||
|
||||
/**
|
||||
* This method is called by SDL using JNI.
|
||||
|
||||
Reference in New Issue
Block a user