Skip to content

Commit

Permalink
Merge pull request #18 from OutSystems/fix/RNMT-6057/styleDefault-not…
Browse files Browse the repository at this point in the history
…-working-android13

RNMT-6057 ::: StatusBar plugin not working on Android apps built with MABS 9
  • Loading branch information
andredestro authored Apr 4, 2023
2 parents aae0aa6 + fdc532c commit 09c246c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@
"cordova": ">=3.0.0"
},
"4.0.0": {
"cordova-android": ">=10.0.0",
"cordova": ">=3.0.0"
},
"5.0.0": {
"cordova": ">100"
}
}
Expand Down
1 change: 1 addition & 0 deletions plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

<engines>
<engine name="cordova" version=">=3.0.0" />
<engine name="cordova-android" version=">=10.0.0" />
</engines>

<js-module src="www/statusbar.js" name="statusbar">
Expand Down
12 changes: 8 additions & 4 deletions src/android/StatusBar.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
import android.view.Window;
import android.view.WindowManager;

import androidx.core.view.WindowCompat;
import androidx.core.view.WindowInsetsControllerCompat;

import org.apache.cordova.CallbackContext;
import org.apache.cordova.CordovaArgs;
import org.apache.cordova.CordovaInterface;
Expand Down Expand Up @@ -343,8 +346,9 @@ private void setStatusBarTransparent(final boolean transparent) {
private void setStatusBarStyle(final String style) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (style != null && !style.isEmpty()) {
View decorView = cordova.getActivity().getWindow().getDecorView();
int uiOptions = decorView.getSystemUiVisibility();
Window window = cordova.getActivity().getWindow();
View decorView = window.getDecorView();
WindowInsetsControllerCompat windowInsetsControllerCompat = WindowCompat.getInsetsController(window, decorView);

String[] darkContentStyles = {
"default",
Expand All @@ -357,12 +361,12 @@ private void setStatusBarStyle(final String style) {
};

if (Arrays.asList(darkContentStyles).contains(style.toLowerCase())) {
decorView.setSystemUiVisibility(uiOptions | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
windowInsetsControllerCompat.setAppearanceLightStatusBars(true);
return;
}

if (Arrays.asList(lightContentStyles).contains(style.toLowerCase())) {
decorView.setSystemUiVisibility(uiOptions & ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
windowInsetsControllerCompat.setAppearanceLightStatusBars(false);
return;
}

Expand Down

0 comments on commit 09c246c

Please sign in to comment.