Skip to content

Commit 99989f3

Browse files
fix. allow webview to detect theme change
1 parent cb57ef0 commit 99989f3

File tree

5 files changed

+9
-37
lines changed

5 files changed

+9
-37
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,4 +113,4 @@
113113
"yargs": "^17.7.2"
114114
},
115115
"browserslist": "cover 100%,not android < 5"
116-
}
116+
}

res/android/values/themes.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
<item name="windowSplashScreenBackground">@color/ic_splash_background</item>
55
<item name="windowSplashScreenAnimatedIcon">@drawable/ic_launcher_foreground</item>
66
<item name="windowSplashScreenAnimationDuration">200</item>
7-
<item name="postSplashScreenTheme">@style/Theme.AppCompat.NoActionBar</item>
7+
<item name="postSplashScreenTheme">@style/Theme.AppCompat.DayNight.NoActionBar</item>
88
</style>
99
</resources>

src/lib/systemConfiguration.js

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -56,18 +56,8 @@ export function getSystemConfiguration() {
5656
export function isDeviceDarkTheme() {
5757
return new Promise((resolve, reject) => {
5858
try {
59-
cordova.exec(
60-
(result) => {
61-
resolve(result.isDark);
62-
},
63-
(error) => {
64-
console.warn(error);
65-
resolve(false);
66-
},
67-
"System",
68-
"getTheme",
69-
[],
70-
);
59+
var isDark = window.matchMedia("(prefers-color-scheme: dark)").matches;
60+
resolve(isDark);
7161
} catch (e) {
7262
resolve(false);
7363
}

src/plugins/system/android/com/foxdebug/system/System.java

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -104,24 +104,6 @@ public boolean execute(
104104
final String arg5 = args.optString(4);
105105
final String arg6 = args.optString(5);
106106

107-
if (action.equals("getTheme")) {
108-
JSONObject theme = new JSONObject();
109-
110-
boolean isDark = (cordova.getActivity().getResources().getConfiguration().uiMode
111-
& Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_YES;
112-
113-
try {
114-
theme.put("isDark", isDark);
115-
} catch (Exception e) {
116-
callbackContext.error("Error setting 'isDark' JSON entry.");
117-
return true;
118-
}
119-
120-
callbackContext.success(theme);
121-
122-
return true;
123-
}
124-
125107
switch (action) {
126108
case "get-webkit-info":
127109
case "file-action":

www/index.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -165,17 +165,17 @@
165165

166166
<title>Acode</title>
167167
<!--styles-->
168-
<link rel="stylesheet" href="./css/build/263.css">
169-
<link rel="stylesheet" href="./css/build/31.css">
170-
<link rel="stylesheet" href="./css/build/439.css">
171-
<link rel="stylesheet" href="./css/build/490.css">
172-
<link rel="stylesheet" href="./css/build/626.css">
173168
<link rel="stylesheet" href="./css/build/about.css">
174169
<link rel="stylesheet" href="./css/build/customTheme.css">
175170
<link rel="stylesheet" href="./css/build/donate.css">
176171
<link rel="stylesheet" href="./css/build/fileBrowser.css">
177172
<link rel="stylesheet" href="./css/build/main.css">
178173
<link rel="stylesheet" href="./css/build/plugins.css">
174+
<link rel="stylesheet" href="./css/build/src_pages_quickTools_quickTools_js.css">
175+
<link rel="stylesheet" href="./css/build/src_sidebarApps_extensions_index_js.css">
176+
<link rel="stylesheet" href="./css/build/src_sidebarApps_files_index_js.css">
177+
<link rel="stylesheet" href="./css/build/src_sidebarApps_notification_index_js.css">
178+
<link rel="stylesheet" href="./css/build/src_sidebarApps_searchInFiles_index_js.css">
179179
<link rel="stylesheet" href="./css/build/themeSetting.css">
180180
<!--styles_end-->
181181
</head>

0 commit comments

Comments
 (0)