automatically enable UI_MODE_NIGHT when gtk-theme-name contains "dark"

gtk-theme-name is only checked once at start up
This commit is contained in:
Julian Winkler
2024-03-10 12:05:33 +01:00
parent f49922cf1b
commit 005e2299bd
8 changed files with 87 additions and 5 deletions

View File

@@ -63,7 +63,6 @@ public class Context extends Object {
static AssetManager assets;
static DisplayMetrics dm;
static Configuration config;
static Resources r;
static ApplicationInfo application_info;
static Resources.Theme theme;
@@ -82,7 +81,8 @@ public class Context extends Object {
static {
assets = new AssetManager();
dm = new DisplayMetrics();
config = new Configuration();
Configuration config = new Configuration();
native_updateConfig(config);
r = new Resources(assets, dm, config);
theme = r.newTheme();
application_info = new ApplicationInfo();
@@ -97,6 +97,8 @@ public class Context extends Object {
}
}
protected static native void native_updateConfig(Configuration config);
static Application createApplication(long native_window) throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException, ClassNotFoundException {
Application application;
ResXmlAttribute application_name = manifest.getApplicationElement().searchAttributeByResourceId(AndroidManifestBlock.ID_name);

View File

@@ -701,11 +701,11 @@ public final class AssetManager {
* applications.
* {@hide}
*/
public /*native*/ final void setConfiguration(int mcc, int mnc, String locale,
public native final void setConfiguration(int mcc, int mnc, String locale,
int orientation, int touchscreen, int density, int keyboard,
int keyboardHidden, int navigation, int screenWidth, int screenHeight,
int smallestScreenWidthDp, int screenWidthDp, int screenHeightDp,
int screenLayout, int uiMode, int majorVersion) {}
int screenLayout, int uiMode, int majorVersion);
/**
* Retrieve the resource identifier for the given resource name.

View File

@@ -208,7 +208,7 @@ public class Resources {
mCompatibilityInfo = compatInfo;
}
mToken = new WeakReference<IBinder>(token);
// updateConfiguration(config, metrics);
updateConfiguration(config, metrics);
// assets.ensureStringBlocks();
}