-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(android): Add Statusbar.setOverlaysWebView method #2597
feat(android): Add Statusbar.setOverlaysWebView method #2597
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have not tested yet, but I find the enabled
name confusing, maybe just call it overlay.
Also, getInfo method should return if it's overlaid or not.
And there is a typo on Display content unter
(should be under)
As I've not tested, I'm not 100% sure, but since you set the color to transparent, if you disable it, it might lose the previous color, right? I think the previous color should be restored.
@jcesarmobile Those are good points that I also thought about. 👍 About the color: I also was not really satisfied with the way it is, but the cordova plugin actually does the same. I suspect that this is because it would be unusual to actually switch the overlaying behavior of the status bar back and forth during runtime? But I share your opinion that this isn't very clean that way. I'll look at restoring it! (and i'm obviously fixing the typo ;D) Thanks for your time! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested and works fine.
Requested a few minor changes.
On iOS you also have to add the method here
https://github.com/ionic-team/capacitor/blob/master/ios/Capacitor/Capacitor/Plugins/DefaultPlugins.m#L138
core/src/core-plugin-definitions.ts
Outdated
@@ -1633,6 +1638,11 @@ export interface StatusBarInfoResult { | |||
visible: boolean; | |||
style: StatusBarStyle; | |||
color?: string; | |||
overlaysWebview: boolean; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change the name to overlaid or overlays, and make it optional because iOS doesn't return it
overlaysWebview: boolean; | |
overlaid?: boolean; |
|
||
// Display content under transparent status bar (Android only) | ||
Statusbar.setOverlaysWebView({ | ||
enabled: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
forgot to change the new name here
enabled: true | |
overlay: true |
// Display content under transparent status bar (Android only) | ||
Statusbar.setOverlaysWebView({ | ||
enabled: true | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing ; at the end
}) | |
}); |
@@ -114,6 +124,38 @@ public void getInfo(final PluginCall call) { | |||
data.put("visible", (decorView.getSystemUiVisibility() & View.SYSTEM_UI_FLAG_FULLSCREEN) != View.SYSTEM_UI_FLAG_FULLSCREEN); | |||
data.put("style", style); | |||
data.put("color", String.format("#%06X", (0xFFFFFF & window.getStatusBarColor()))); | |||
data.put("overlaysWebview", (decorView.getSystemUiVisibility() & View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN) == View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change the name to overlaid or overlays
data.put("overlaysWebview", (decorView.getSystemUiVisibility() & View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN) == View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); | |
data.put("overlaid", (decorView.getSystemUiVisibility() & View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN) == View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); |
Hopefully all done now 🙂 Thank you for your time and help! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good, thanks for making all the requested changes so fast!
Addition of a new method in the core Statusbar plugin, similar to the
overlaysWebView
method/preference of the cordova statusbar plugin. Updated example in the docs for the Statusbar plugin.Works only for android (as discussed in #1876) since on iOS it already handles it correctly on devices with notches.
I'm not confident in my android knowledge these days, so I might have overlooked something. But in my tests everything worked as expected, similar to the cordova plugin.
What I'm not sure about is the correct way to handle that the iOS version of the plugin doesn't implement this feature. I added it with a
"not implemented"
response in theStatusbar.swift
file but I'm not sure if that is all that's needed here.