mirror of
https://github.com/apache/cordova-plugin-statusbar.git
synced 2025-02-26 21:02:50 +08:00
CB-10879: Enable overlaysWebView on Android API 21+
This closes #77 This patch enables devices running Android API 21+ to have the status bar overlaying the WebView, i.e. `StatusBar.overlaysWebView(true)`. It lets any Android version call `StatusBar.overlaysWebView(false)` to disable the overlay, which is actually the default behavior on that platform.
This commit is contained in:
parent
d980145c98
commit
3f552ed734
@ -142,6 +142,23 @@ public class StatusBar extends CordovaPlugin {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ("overlaysWebView".equals(action)) {
|
||||||
|
if (Build.VERSION.SDK_INT >= 21) {
|
||||||
|
this.cordova.getActivity().runOnUiThread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
setStatusBarTransparent(args.getBoolean(0));
|
||||||
|
} catch (JSONException ignore) {
|
||||||
|
LOG.e(TAG, "Invalid boolean argument");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else return args.getBoolean(0) == false;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -164,4 +181,21 @@ public class StatusBar extends CordovaPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setStatusBarTransparent(final boolean transparent) {
|
||||||
|
if (Build.VERSION.SDK_INT >= 21) {
|
||||||
|
final Window window = cordova.getActivity().getWindow();
|
||||||
|
if (transparent) {
|
||||||
|
window.getDecorView().setSystemUiVisibility(
|
||||||
|
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
|
||||||
|
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
|
||||||
|
window.setStatusBarColor(Color.TRANSPARENT);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
window.getDecorView().setSystemUiVisibility(
|
||||||
|
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
|
||||||
|
| View.SYSTEM_UI_FLAG_VISIBLE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user