From 638ab4b190ee1e5d447f73dea0aca91848459b00 Mon Sep 17 00:00:00 2001 From: RohitKushvaha01 Date: Tue, 24 Mar 2026 14:06:35 +0530 Subject: [PATCH 1/4] fix: system bar colors --- .../android/com/foxdebug/system/System.java | 3 + src/plugins/system/www/plugin.js | 84 ++++++++++--------- 2 files changed, 47 insertions(+), 40 deletions(-) diff --git a/src/plugins/system/android/com/foxdebug/system/System.java b/src/plugins/system/android/com/foxdebug/system/System.java index 3ebea6297..9d78bd1af 100644 --- a/src/plugins/system/android/com/foxdebug/system/System.java +++ b/src/plugins/system/android/com/foxdebug/system/System.java @@ -1691,9 +1691,11 @@ private void setUiTheme( final CallbackContext callback ) { this.systemBarColor = Color.parseColor(systemBarColor); + preferences.set("BackgroundColor", String.format("0x%08X", this.systemBarColor)); this.theme = new Theme(scheme); final Window window = activity.getWindow(); + // Method and constants not available on all SDKs but we want to be able to compile this code with any SDK window.clearFlags(0x04000000); // SDK 19: WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); window.addFlags(0x80000000); // SDK 21: WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); @@ -1728,6 +1730,7 @@ private void setUiTheme( controller.setSystemBarsAppearance(0, appearance); } } + callback.success("OK"); } catch (IllegalArgumentException error) { callback.error(error.toString()); diff --git a/src/plugins/system/www/plugin.js b/src/plugins/system/www/plugin.js index 01d77ecb3..5d9be4a7d 100644 --- a/src/plugins/system/www/plugin.js +++ b/src/plugins/system/www/plugin.js @@ -33,19 +33,19 @@ module.exports = { cordova.exec(success, error, 'System', 'getNativeLibraryPath', []); }, - getFilesDir: function (success, error) { - cordova.exec(success, error, 'System', 'getFilesDir', []); - }, - getRewardStatus: function (success, error) { - cordova.exec(success, error, 'System', 'getRewardStatus', []); - }, - redeemReward: function (offerId, success, error) { - cordova.exec(success, error, 'System', 'redeemReward', [offerId]); - }, - - getParentPath: function (path, success, error) { - cordova.exec(success, error, 'System', 'getParentPath', [path]); - }, + getFilesDir: function (success, error) { + cordova.exec(success, error, 'System', 'getFilesDir', []); + }, + getRewardStatus: function (success, error) { + cordova.exec(success, error, 'System', 'getRewardStatus', []); + }, + redeemReward: function (offerId, success, error) { + cordova.exec(success, error, 'System', 'redeemReward', [offerId]); + }, + + getParentPath: function (path, success, error) { + cordova.exec(success, error, 'System', 'getParentPath', [path]); + }, listChildren: function (path, success, error) { cordova.exec(success, error, 'System', 'listChildren', [path]); @@ -135,36 +135,40 @@ module.exports = { onError: null, }; - cordova.exec(function (data) { - if (typeof data !== 'string') { - console.warn('System.inAppBrowser: invalid callback payload', data); - return; - } - var separatorIndex = data.indexOf(':'); - if (separatorIndex < 0) { - console.warn('System.inAppBrowser: malformed callback payload', data); - return; - } - var dataTag = data.slice(0, separatorIndex); - var dataUrl = data.slice(separatorIndex + 1); - if (dataTag === 'onOpenExternalBrowser') { - if (typeof myInAppBrowser.onOpenExternalBrowser === 'function') { - myInAppBrowser.onOpenExternalBrowser(dataUrl); - } else { - console.warn('System.inAppBrowser: onOpenExternalBrowser handler is not set'); - } - } - }, function (err) { - if (typeof myInAppBrowser.onError === 'function') { - myInAppBrowser.onError(err); - return; - } - console.warn('System.inAppBrowser error callback not handled', err); - }, 'System', 'in-app-browser', [url, title, !!showButtons, disableCache]); + cordova.exec(function (data) { + if (typeof data !== 'string') { + console.warn('System.inAppBrowser: invalid callback payload', data); + return; + } + var separatorIndex = data.indexOf(':'); + if (separatorIndex < 0) { + console.warn('System.inAppBrowser: malformed callback payload', data); + return; + } + var dataTag = data.slice(0, separatorIndex); + var dataUrl = data.slice(separatorIndex + 1); + if (dataTag === 'onOpenExternalBrowser') { + if (typeof myInAppBrowser.onOpenExternalBrowser === 'function') { + myInAppBrowser.onOpenExternalBrowser(dataUrl); + } else { + console.warn('System.inAppBrowser: onOpenExternalBrowser handler is not set'); + } + } + }, function (err) { + if (typeof myInAppBrowser.onError === 'function') { + myInAppBrowser.onError(err); + return; + } + console.warn('System.inAppBrowser error callback not handled', err); + }, 'System', 'in-app-browser', [url, title, !!showButtons, disableCache]); return myInAppBrowser; }, setUiTheme: function (systemBarColor, theme, onSuccess, onFail) { - cordova.exec(onSuccess, onFail, 'System', 'set-ui-theme', [systemBarColor, theme]); + cordova.exec((out)=>{ + cordova.exec(null, null, "SystemBarPlugin", "updateSystemBars", []); + window.statusbar.setBackgroundColor(systemBarColor); + onSuccess(out) + }, onFail, 'System', 'set-ui-theme', [systemBarColor, theme]); }, setIntentHandler: function (handler, onerror) { cordova.exec(handler, onerror, 'System', 'set-intent-handler', []); From 31ddebf47654b71cfa4c8cf75ff2c254efdcac5c Mon Sep 17 00:00:00 2001 From: RohitKushvaha01 Date: Tue, 24 Mar 2026 15:06:32 +0530 Subject: [PATCH 2/4] feat: improvements --- .../android/com/foxdebug/system/System.java | 57 ++++--------------- src/plugins/system/www/plugin.js | 3 +- 2 files changed, 12 insertions(+), 48 deletions(-) diff --git a/src/plugins/system/android/com/foxdebug/system/System.java b/src/plugins/system/android/com/foxdebug/system/System.java index 9d78bd1af..b95a52c63 100644 --- a/src/plugins/system/android/com/foxdebug/system/System.java +++ b/src/plugins/system/android/com/foxdebug/system/System.java @@ -1686,56 +1686,21 @@ private void removeShortcut(String id, CallbackContext callback) { } private void setUiTheme( - final String systemBarColor, - final JSONObject scheme, - final CallbackContext callback + final String systemBarColor, + final JSONObject scheme, + final CallbackContext callback ) { - this.systemBarColor = Color.parseColor(systemBarColor); - preferences.set("BackgroundColor", String.format("0x%08X", this.systemBarColor)); - this.theme = new Theme(scheme); - - final Window window = activity.getWindow(); - - // Method and constants not available on all SDKs but we want to be able to compile this code with any SDK - window.clearFlags(0x04000000); // SDK 19: WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); - window.addFlags(0x80000000); // SDK 21: WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); try { - // Using reflection makes sure any 5.0+ device will work without having to compile with SDK level 21 - - window - .getClass() - .getMethod("setNavigationBarColor", int.class) - .invoke(window, this.systemBarColor); - - window - .getClass() - .getMethod("setStatusBarColor", int.class) - .invoke(window, this.systemBarColor); + this.systemBarColor = Color.parseColor(systemBarColor); + this.theme = new Theme(scheme); + + preferences.set("BackgroundColor", String.format("0x%08X", this.systemBarColor)); - window.getDecorView().setBackgroundColor(this.systemBarColor); + webView.getPluginManager().postMessage("updateSystemBars", null); - if (Build.VERSION.SDK_INT < 30) { - setStatusBarStyle(window); - setNavigationBarStyle(window); - } else { - String themeType = theme.getType(); - WindowInsetsController controller = window.getInsetsController(); - int appearance = - WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS | - WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS; - - if (themeType.equals("light")) { - controller.setSystemBarsAppearance(appearance, appearance); - } else { - controller.setSystemBarsAppearance(0, appearance); - } - } - - callback.success("OK"); - } catch (IllegalArgumentException error) { - callback.error(error.toString()); - } catch (Exception error) { - callback.error(error.toString()); + callback.success(); + } catch (IllegalArgumentException e) { + callback.error("Invalid color: " + systemBarColor); } } diff --git a/src/plugins/system/www/plugin.js b/src/plugins/system/www/plugin.js index 5d9be4a7d..fb1148359 100644 --- a/src/plugins/system/www/plugin.js +++ b/src/plugins/system/www/plugin.js @@ -165,9 +165,8 @@ module.exports = { }, setUiTheme: function (systemBarColor, theme, onSuccess, onFail) { cordova.exec((out)=>{ - cordova.exec(null, null, "SystemBarPlugin", "updateSystemBars", []); window.statusbar.setBackgroundColor(systemBarColor); - onSuccess(out) + onSuccess(out); }, onFail, 'System', 'set-ui-theme', [systemBarColor, theme]); }, setIntentHandler: function (handler, onerror) { From 7799c5a5b0ca0982da199d7ba687b137d643a86c Mon Sep 17 00:00:00 2001 From: RohitKushvaha01 Date: Tue, 24 Mar 2026 18:00:52 +0530 Subject: [PATCH 3/4] fix: white themes not working --- src/plugins/system/android/com/foxdebug/system/System.java | 2 +- src/plugins/system/www/plugin.js | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/plugins/system/android/com/foxdebug/system/System.java b/src/plugins/system/android/com/foxdebug/system/System.java index b95a52c63..1509a9f44 100644 --- a/src/plugins/system/android/com/foxdebug/system/System.java +++ b/src/plugins/system/android/com/foxdebug/system/System.java @@ -1694,7 +1694,7 @@ private void setUiTheme( this.systemBarColor = Color.parseColor(systemBarColor); this.theme = new Theme(scheme); - preferences.set("BackgroundColor", String.format("0x%08X", this.systemBarColor)); + preferences.set("BackgroundColor", this.systemBarColor); webView.getPluginManager().postMessage("updateSystemBars", null); diff --git a/src/plugins/system/www/plugin.js b/src/plugins/system/www/plugin.js index fb1148359..f2b4337f1 100644 --- a/src/plugins/system/www/plugin.js +++ b/src/plugins/system/www/plugin.js @@ -164,6 +164,13 @@ module.exports = { return myInAppBrowser; }, setUiTheme: function (systemBarColor, theme, onSuccess, onFail) { + const color = systemBarColor.toLowerCase(); + + if (color === '#ffffff' || color === '#ffffffff') { + systemBarColor = '#fffffe'; + } + + cordova.exec((out)=>{ window.statusbar.setBackgroundColor(systemBarColor); onSuccess(out); From 16074eb77be84a426fe6eec48a7466875d6cbd92 Mon Sep 17 00:00:00 2001 From: RohitKushvaha01 Date: Tue, 24 Mar 2026 18:08:54 +0530 Subject: [PATCH 4/4] fix: error --- src/plugins/system/www/plugin.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/plugins/system/www/plugin.js b/src/plugins/system/www/plugin.js index f2b4337f1..939c130c7 100644 --- a/src/plugins/system/www/plugin.js +++ b/src/plugins/system/www/plugin.js @@ -164,16 +164,19 @@ module.exports = { return myInAppBrowser; }, setUiTheme: function (systemBarColor, theme, onSuccess, onFail) { - const color = systemBarColor.toLowerCase(); + const color = systemBarColor.toLowerCase(); if (color === '#ffffff' || color === '#ffffffff') { systemBarColor = '#fffffe'; } - - cordova.exec((out)=>{ + cordova.exec((out) => { window.statusbar.setBackgroundColor(systemBarColor); - onSuccess(out); + + if (typeof onSuccess === "function") { + onSuccess(out); + } + }, onFail, 'System', 'set-ui-theme', [systemBarColor, theme]); }, setIntentHandler: function (handler, onerror) {