@@ -89,8 +89,7 @@ public boolean execute(String action, JSONArray args, CallbackContext callbackCo
89
89
boolean visible = args .getBoolean (0 );
90
90
cordova .getActivity ().runOnUiThread (() -> setStatusBarVisible (visible ));
91
91
} else if ("setStatusBarBackgroundColor" .equals (action )) {
92
- String bgColor = args .getString (0 );
93
- cordova .getActivity ().runOnUiThread (() -> setStatusBarBackgroundColor (bgColor ));
92
+ cordova .getActivity ().runOnUiThread (() -> setStatusBarBackgroundColor (args ));
94
93
} else {
95
94
return false ;
96
95
}
@@ -120,17 +119,27 @@ private void setStatusBarVisible(final boolean visible) {
120
119
121
120
/**
122
121
* Allow the app to override the status bar background color from JS API.
123
- * If the supplied string is invalid and fails to parse, it will silently ignore
122
+ * If the supplied ARGB is invalid or fails to parse, it will silently ignore
124
123
* the change request.
125
124
*
126
- * @param colorPref hex string
125
+ * @param argbVals {A, R, G, B}
127
126
*/
128
- private void setStatusBarBackgroundColor (final String colorPref ) {
129
- int parsedColor = parseColorFromString (colorPref );
130
- if (parsedColor == INVALID_COLOR ) return ;
131
-
132
- overrideStatusBarBackgroundColor = parsedColor ;
133
- updateStatusBar (overrideStatusBarBackgroundColor );
127
+ private void setStatusBarBackgroundColor (JSONArray argbVals ) {
128
+ try {
129
+ int a = argbVals .getInt (0 );
130
+ int r = argbVals .getInt (1 );
131
+ int g = argbVals .getInt (2 );
132
+ int b = argbVals .getInt (3 );
133
+ String hexColor = String .format ("#%02X%02X%02X%02X" , a , r , g , b );
134
+
135
+ int parsedColor = parseColorFromString (hexColor );
136
+ if (parsedColor == INVALID_COLOR ) return ;
137
+
138
+ overrideStatusBarBackgroundColor = parsedColor ;
139
+ updateStatusBar (overrideStatusBarBackgroundColor );
140
+ } catch (JSONException e ) {
141
+ // Silently skip
142
+ }
134
143
}
135
144
136
145
/**
0 commit comments