Skip to content

Commit 638ab4b

Browse files
fix: system bar colors
1 parent 8704e6e commit 638ab4b

2 files changed

Lines changed: 47 additions & 40 deletions

File tree

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1691,9 +1691,11 @@ private void setUiTheme(
16911691
final CallbackContext callback
16921692
) {
16931693
this.systemBarColor = Color.parseColor(systemBarColor);
1694+
preferences.set("BackgroundColor", String.format("0x%08X", this.systemBarColor));
16941695
this.theme = new Theme(scheme);
16951696

16961697
final Window window = activity.getWindow();
1698+
16971699
// Method and constants not available on all SDKs but we want to be able to compile this code with any SDK
16981700
window.clearFlags(0x04000000); // SDK 19: WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
16991701
window.addFlags(0x80000000); // SDK 21: WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
@@ -1728,6 +1730,7 @@ private void setUiTheme(
17281730
controller.setSystemBarsAppearance(0, appearance);
17291731
}
17301732
}
1733+
17311734
callback.success("OK");
17321735
} catch (IllegalArgumentException error) {
17331736
callback.error(error.toString());

src/plugins/system/www/plugin.js

Lines changed: 44 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,19 @@ module.exports = {
3333
cordova.exec(success, error, 'System', 'getNativeLibraryPath', []);
3434
},
3535

36-
getFilesDir: function (success, error) {
37-
cordova.exec(success, error, 'System', 'getFilesDir', []);
38-
},
39-
getRewardStatus: function (success, error) {
40-
cordova.exec(success, error, 'System', 'getRewardStatus', []);
41-
},
42-
redeemReward: function (offerId, success, error) {
43-
cordova.exec(success, error, 'System', 'redeemReward', [offerId]);
44-
},
45-
46-
getParentPath: function (path, success, error) {
47-
cordova.exec(success, error, 'System', 'getParentPath', [path]);
48-
},
36+
getFilesDir: function (success, error) {
37+
cordova.exec(success, error, 'System', 'getFilesDir', []);
38+
},
39+
getRewardStatus: function (success, error) {
40+
cordova.exec(success, error, 'System', 'getRewardStatus', []);
41+
},
42+
redeemReward: function (offerId, success, error) {
43+
cordova.exec(success, error, 'System', 'redeemReward', [offerId]);
44+
},
45+
46+
getParentPath: function (path, success, error) {
47+
cordova.exec(success, error, 'System', 'getParentPath', [path]);
48+
},
4949

5050
listChildren: function (path, success, error) {
5151
cordova.exec(success, error, 'System', 'listChildren', [path]);
@@ -135,36 +135,40 @@ module.exports = {
135135
onError: null,
136136
};
137137

138-
cordova.exec(function (data) {
139-
if (typeof data !== 'string') {
140-
console.warn('System.inAppBrowser: invalid callback payload', data);
141-
return;
142-
}
143-
var separatorIndex = data.indexOf(':');
144-
if (separatorIndex < 0) {
145-
console.warn('System.inAppBrowser: malformed callback payload', data);
146-
return;
147-
}
148-
var dataTag = data.slice(0, separatorIndex);
149-
var dataUrl = data.slice(separatorIndex + 1);
150-
if (dataTag === 'onOpenExternalBrowser') {
151-
if (typeof myInAppBrowser.onOpenExternalBrowser === 'function') {
152-
myInAppBrowser.onOpenExternalBrowser(dataUrl);
153-
} else {
154-
console.warn('System.inAppBrowser: onOpenExternalBrowser handler is not set');
155-
}
156-
}
157-
}, function (err) {
158-
if (typeof myInAppBrowser.onError === 'function') {
159-
myInAppBrowser.onError(err);
160-
return;
161-
}
162-
console.warn('System.inAppBrowser error callback not handled', err);
163-
}, 'System', 'in-app-browser', [url, title, !!showButtons, disableCache]);
138+
cordova.exec(function (data) {
139+
if (typeof data !== 'string') {
140+
console.warn('System.inAppBrowser: invalid callback payload', data);
141+
return;
142+
}
143+
var separatorIndex = data.indexOf(':');
144+
if (separatorIndex < 0) {
145+
console.warn('System.inAppBrowser: malformed callback payload', data);
146+
return;
147+
}
148+
var dataTag = data.slice(0, separatorIndex);
149+
var dataUrl = data.slice(separatorIndex + 1);
150+
if (dataTag === 'onOpenExternalBrowser') {
151+
if (typeof myInAppBrowser.onOpenExternalBrowser === 'function') {
152+
myInAppBrowser.onOpenExternalBrowser(dataUrl);
153+
} else {
154+
console.warn('System.inAppBrowser: onOpenExternalBrowser handler is not set');
155+
}
156+
}
157+
}, function (err) {
158+
if (typeof myInAppBrowser.onError === 'function') {
159+
myInAppBrowser.onError(err);
160+
return;
161+
}
162+
console.warn('System.inAppBrowser error callback not handled', err);
163+
}, 'System', 'in-app-browser', [url, title, !!showButtons, disableCache]);
164164
return myInAppBrowser;
165165
},
166166
setUiTheme: function (systemBarColor, theme, onSuccess, onFail) {
167-
cordova.exec(onSuccess, onFail, 'System', 'set-ui-theme', [systemBarColor, theme]);
167+
cordova.exec((out)=>{
168+
cordova.exec(null, null, "SystemBarPlugin", "updateSystemBars", []);
169+
window.statusbar.setBackgroundColor(systemBarColor);
170+
onSuccess(out)
171+
}, onFail, 'System', 'set-ui-theme', [systemBarColor, theme]);
168172
},
169173
setIntentHandler: function (handler, onerror) {
170174
cordova.exec(handler, onerror, 'System', 'set-intent-handler', []);

0 commit comments

Comments
 (0)