mirror of
https://github.com/apache/cordova-plugin-statusbar.git
synced 2025-01-19 01:12:49 +08:00
fix(android)!: styleDefault not working on new devices (#238)
This commit is contained in:
parent
b7b6c66cbe
commit
49b94aed6a
@ -26,6 +26,9 @@ import android.view.View;
|
|||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
|
|
||||||
|
import androidx.core.view.WindowCompat;
|
||||||
|
import androidx.core.view.WindowInsetsControllerCompat;
|
||||||
|
|
||||||
import org.apache.cordova.CallbackContext;
|
import org.apache.cordova.CallbackContext;
|
||||||
import org.apache.cordova.CordovaArgs;
|
import org.apache.cordova.CordovaArgs;
|
||||||
import org.apache.cordova.CordovaInterface;
|
import org.apache.cordova.CordovaInterface;
|
||||||
@ -253,8 +256,9 @@ public class StatusBar extends CordovaPlugin {
|
|||||||
private void setStatusBarStyle(final String style) {
|
private void setStatusBarStyle(final String style) {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
if (style != null && !style.isEmpty()) {
|
if (style != null && !style.isEmpty()) {
|
||||||
View decorView = cordova.getActivity().getWindow().getDecorView();
|
Window window = cordova.getActivity().getWindow();
|
||||||
int uiOptions = decorView.getSystemUiVisibility();
|
View decorView = window.getDecorView();
|
||||||
|
WindowInsetsControllerCompat windowInsetsControllerCompat = WindowCompat.getInsetsController(window, decorView);
|
||||||
|
|
||||||
String[] darkContentStyles = {
|
String[] darkContentStyles = {
|
||||||
"default",
|
"default",
|
||||||
@ -267,12 +271,12 @@ public class StatusBar extends CordovaPlugin {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (Arrays.asList(darkContentStyles).contains(style.toLowerCase())) {
|
if (Arrays.asList(darkContentStyles).contains(style.toLowerCase())) {
|
||||||
decorView.setSystemUiVisibility(uiOptions | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
|
windowInsetsControllerCompat.setAppearanceLightStatusBars(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Arrays.asList(lightContentStyles).contains(style.toLowerCase())) {
|
if (Arrays.asList(lightContentStyles).contains(style.toLowerCase())) {
|
||||||
decorView.setSystemUiVisibility(uiOptions & ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
|
windowInsetsControllerCompat.setAppearanceLightStatusBars(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user