Skip to content
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

CB-14238: Make transparency of statusbar persistent when hiding and showing statusbar #99

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

aszmyd
Copy link

@aszmyd aszmyd commented Jul 18, 2018

Platforms affected

Android

What does this PR do?

  1. It makes statusbar transparency persisten. Earlier when you call methods in this order: overlaysWebView(true) , hide() , show() the status bar gets shown without transparency and pushes webview to bottom. And because we wanted to have statusbar transparent (overlaysWebView) from this point the show/hide should toggle the statusbar visibility and it should always show transparent.
  2. Support for StatusBarOverlaysWebView in Android when its pre-defined in project config.xml

What testing has been done on this change?

Manual testing on Android device

Checklist

  • Reported an issue in the JIRA database
  • Commit message follows the format: "CB-3232: (android) Fix bug with resolving file paths", where CB-xxxx is the JIRA ID & "android" is the platform affected.
  • Added automated test coverage as appropriate for this change.

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);

if (Build.VERSION.SDK_INT >= 21) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did this SDK version check get moved inside here?
Does the other stuff also work on earlier versions?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as i've checked setSystemUiVisibility has been added in API 11 https://developer.android.com/reference/android/view/View.html#setSystemUiVisibility(int) so it seems it should work everywhere

@@ -227,20 +236,22 @@ private void setStatusBarBackgroundColor(final String colorPref) {
}

private void setStatusBarTransparent(final boolean transparent) {
if (Build.VERSION.SDK_INT >= 21) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code indentation of the code inside this removed if should be adapted to match the added this.transparent = transparent;, right?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right. Fixes

@@ -96,7 +101,11 @@ public void run() {
// use KitKat here to be aligned with "Fullscreen" preference
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
int uiOptions = window.getDecorView().getSystemUiVisibility();
uiOptions &= ~View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
if (transparent) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be this.transparent?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Fixes

@aszmyd
Copy link
Author

aszmyd commented Jul 23, 2018

@janpio whats needed to get this merged? I've pushed fixes to the way i accessed transparent from another thread as this.transparent did not work during build.

@janpio
Copy link
Member

janpio commented Jul 23, 2018

Someone of the committers/maintainers with enough Android experience has to be convinced enough that he hits the merge button. I am not, as I have only superficial knowledge of Android. Enough to leave some comments on code, but not enough to actually be sure the code will be ok in production.

@aszmyd
Copy link
Author

aszmyd commented Jul 31, 2018

@janpio do you have anyone specific in mind? Maybe @infil00p can jump in here? I see he merged other Android codes in this repo.

@janpio
Copy link
Member

janpio commented Jul 31, 2018

Unfortunately not. You could try emailing the Dev mailing list, see https://cordova.apache.org/contact/.

@janpio
Copy link
Member

janpio commented Jul 31, 2018

@aszmyd Some feedback from other commiters I got when asking for a review of this:

doesn't have JIRA issue 👎
just saying we have hundreds of unattended PRs and I won't give priority to the ones that don't follow the rules

Could you please create said issue and add it to the PR? Open a new one to get the "usual" template for a PR. Thanks.

(If changing the commit message is to involved for you, we can fix that when/if merging)

@aszmyd aszmyd changed the title Make transparency of statusbar persistent when hiding and showing sta… Make transparency of statusbar persistent when hiding and showing statusbar Aug 1, 2018
@aszmyd aszmyd changed the title Make transparency of statusbar persistent when hiding and showing statusbar CB-14238: Make transparency of statusbar persistent when hiding and showing statusbar Aug 1, 2018
@aszmyd
Copy link
Author

aszmyd commented Aug 1, 2018

@janpio I've created JIRA issue: https://issues.apache.org/jira/browse/CB-14238 and renamed PR name and description. Not sure if i should also rename commit name and force git push? It could confuse others that already pulled this branch.

@brodycj
Copy link

brodycj commented Aug 1, 2018

@aszmyd it should be fine to update by force push (we do this kind of thing all the time). Alternative solution which I think is not necessary is to simply open a new PR. Even fancier is to open a new PR with text like "resolves #99" or "closes #99" in the description (https://help.github.com/articles/closing-issues-using-keywords/).

As an aside you may want to maintain your own special fork version until we get a chance to deal with this one. Maybe something like "cordova-plugin-statusbar-transparent" or "cordova-plugin-persistent-statusbar"?

@aszmyd aszmyd force-pushed the android-persistent-transparency branch from 138b0ed to 65a8631 Compare August 1, 2018 04:06
@aszmyd
Copy link
Author

aszmyd commented Aug 1, 2018

@brodybits thanks. I've pushed clean one commit with name changed.

@brodycj
Copy link

brodycj commented Aug 1, 2018

A couple minor points FYI:

  • First line should generally be within 50 characters. If you need more then you should add a blank line then keep remaining lines within 70 characters. This is very well documented, for example: https://chris.beams.io/posts/git-commit/. AFAICT we generally take care of this formatting issue if needed.
  • Unless there is good reason to keep multiple original commits we will very likely do a "squash merge", which means that the master branch would actually diverge from your proposed android-persistent-transparency branch.

Thanks for the contribution, I am sure it will help others in the future.

@aszmyd aszmyd force-pushed the android-persistent-transparency branch from 65a8631 to 515d683 Compare August 1, 2018 04:24
@aszmyd
Copy link
Author

aszmyd commented Aug 1, 2018

I do not know why travis build failed for safari browser.

@janpio
Copy link
Member

janpio commented Aug 1, 2018

I restarted the failed Travis jobs manually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants