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

Make status bar transparent on android #15778

Merged
merged 3 commits into from
May 25, 2023

Conversation

janicduplessis
Copy link
Contributor

@janicduplessis janicduplessis commented Mar 9, 2023

Details

Make the status bar transparent on Android.

This also fixes 2 issues that were discovered during QA and caused the initial PR (#15778) to be reverted:

  1. Splash screen moving. Instead of using StatusBar module from RN to make status bar translucent, use the same code used by RN but directly in MainActivity onCreate. This is needed because JS executes too late and causes the move to happen. See [HOLD for payment 2023-06-05] [HOLD for payment 2023-03-20] Revert splash screen logo shift regression #15770
  2. Incorrect window height from RN Dimensions module when using transparent status bar. This is visible on login screen where a bar the size of the statusbar shows at the bottom of the screen. To fix this I used frame from react-native-safe-area-context which has the proper screen size values. Shared in Slack https://expensify.slack.com/archives/C049HHMV9SM/p1678339044151379?thread_ts=1678336100.806819&cid=C049HHMV9SM.

Fixed Issues

$ #13001
$ #15770
PROPOSAL: GH_LINK_ISSUE(COMMENT)

Tests

  • Verify that no errors appear in the JS console
  • Thorough testing of navigation and status bar on Android
  • Ensure status and navigation don't move on app open
  • Test various screens and make sure layout looks fine with transparent status bar

Offline tests

N/A

QA Steps

  • Verify that no errors appear in the JS console
  • Test various screens and make sure layout looks fine with transparent status bar

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android / native
    • Android / Chrome
    • iOS / native
    • iOS / Safari
    • MacOS / Chrome / Safari
    • MacOS / Desktop
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
      • If any non-english text was added/modified, I verified the translation was requested/reviewed in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is correct English and approved by marketing by adding the Waiting for Copy label for a copy review on the original GH to get the correct copy.
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.js or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • The file is named correctly
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
  • I have checked off every checkbox in the PR author checklist, including those that don't apply to this PR.

Screenshots/Videos

Web

image

image
Mobile Web - Chrome image image
Mobile Web - Safari image image
Desktop image image
iOS image image image image image image
Android
Screen.Recording.2023-03-09.at.12.41.55.mov
image image image image image image

@janicduplessis janicduplessis force-pushed the @janic/status-bar-2 branch 2 times, most recently from 97e7bab to 5da0715 Compare March 9, 2023 17:50
@janicduplessis janicduplessis marked this pull request as ready for review March 9, 2023 17:56
@janicduplessis janicduplessis requested a review from a team as a code owner March 9, 2023 17:56
@melvin-bot melvin-bot bot requested review from Julesssss and mananjadhav and removed request for a team March 9, 2023 17:56
@MelvinBot
Copy link

@Julesssss @mananjadhav One of you needs to copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@janicduplessis
Copy link
Contributor Author

cc @Julesssss @roryabraham

@Julesssss
Copy link
Contributor

Nice! I'll test this tomorrow 👍

@janicduplessis
Copy link
Contributor Author

Added one more fix in SetPassword screen to use SafeAreaView from react-native-safe-area-context instead of react-native.

The flicker I noticed (#15778 (comment)) only seems to happen on initial app render, the SafeAreaView on SetPassword screens works fine and doesn't flicker.

src/components/withWindowDimensions.js Outdated Show resolved Hide resolved
src/pages/SetPasswordPage.js Outdated Show resolved Hide resolved
src/pages/signin/SignInPage.js Show resolved Hide resolved
@janicduplessis
Copy link
Contributor Author

janicduplessis commented Mar 11, 2023

@roryabraham Updated with your feedback.

@mananjadhav
Copy link
Collaborator

@janicduplessis @roryabraham @Julesssss Are we only focus on the status bar or also the bottom bar? For iOS it is transparent at the bottom too. This can be achieved with windowTranslucentNavigation but it has its own caveats.

Screenshot 2023-03-13 at 1 31 09 AM

@janicduplessis
Copy link
Contributor Author

@mananjadhav My plan is to start with statusbar and work on navigation bar after. Navigation bar is a bit more tricky since it prevents automatic keyboard handling that we currently rely on on Android. It requires using KeyboardAvoidingView like on iOS. Some code also kind of assume bottom insets if just rounded corners / gesture area like on iOS instead of being a solid bar like on most android devices. So i figured it would be best to address in a follow up.

@mananjadhav
Copy link
Collaborator

Makes sense, and agreed navigation has its fair set of issues to be dealt with especially as it draws the activity behind the status bar.

mananjadhav
mananjadhav previously approved these changes Mar 13, 2023
Copy link
Collaborator

@mananjadhav mananjadhav left a comment

Choose a reason for hiding this comment

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

Except for one comment on withWindowDimensions support for RNW, I think this looks good.

Other comment on bottom bar is already addressed.

Copy link
Contributor

@Julesssss Julesssss left a comment

Choose a reason for hiding this comment

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

This is looking better, but unfortunately I'm seeing a lot more jankiness with these changes. Notice the transition between signin/password and show/hide keyboard. We'll need to fix these too.

@Julesssss
Copy link
Contributor

Both of these are release builds

Current

screen-20230313-140509.mp4

With changes

screen-20230313-140234.mp4

@janicduplessis
Copy link
Contributor Author

Thanks for testing @Julesssss , I suspect this is caused by a different behaviour of frame in react-native-safe-area-context which changes value when keyboard opens vs Dimensions module which doesn’t. I will see how this could be fixed.

@janicduplessis
Copy link
Contributor Author

@Julesssss @aimane-chnaif Done!

@Julesssss
Copy link
Contributor

Thanks @janicduplessis. Please don't amend commits and force-push once the PR is in review though.

Copy link
Contributor

@Julesssss Julesssss left a comment

Choose a reason for hiding this comment

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

Kicked off a new build here

@aimane-chnaif
Copy link
Contributor

ok so expected bug (android splash logo position flickering) happening (around 5s-6s in video below):

Screen.Recording.2023-05-24.at.7.49.33.AM.mov

@Julesssss
Copy link
Contributor

Hey @aimane-chnaif, what device and OS version is that screencast from?

@aimane-chnaif
Copy link
Contributor

aimane-chnaif commented May 24, 2023

Hey @aimane-chnaif, what device and OS version is that screencast from?

happening on all my android devices

Above screenshot is from Pixel XL API 33 emulator

Copy link
Contributor

@Julesssss Julesssss left a comment

Choose a reason for hiding this comment

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

Damn, yeah I'm also seeing this again:

Android 8

Nexus5X.mp4
Nexus5XSignedIn.mp4

@janicduplessis
Copy link
Contributor Author

Probably need to make statusbar transparent on splash too, will have a look today.

@janicduplessis janicduplessis dismissed stale reviews from Julesssss and mananjadhav via 3b38058 May 24, 2023 15:10
@janicduplessis
Copy link
Contributor Author

@Julesssss @aimane-chnaif I just pushed a fix for the new flicker issue.

@aimane-chnaif
Copy link
Contributor

Please fix lint

@janicduplessis
Copy link
Contributor Author

Oups, there you go!

@aimane-chnaif
Copy link
Contributor

@Julesssss let's trigger build once again

@Julesssss
Copy link
Contributor

New CI build in progress

@OSBotify
Copy link
Contributor

🧪🧪 Use the links below to test this build in android and iOS. Happy testing! 🧪🧪

android 🤖 iOS 🍎
https://ad-hoc-expensify-cash.s3.amazonaws.com/android/15778/index.html ❌ FAILED ❌
Android The QR code can't be generated, because the iOS build failed
desktop 💻 web 🕸️
https://ad-hoc-expensify-cash.s3.amazonaws.com/desktop/15778/NewExpensify.dmg https://15778.pr-testing.expensify.com
Desktop Web

@aimane-chnaif
Copy link
Contributor

Latest version tests well.

Small concern about navigation bar (not a blocker):
navigation bar background color and theme changes while on Splash screen.
can we make them consistent on Splash?

Screen.Recording.2023-05-25.at.7.38.46.AM.mov
XRecorder_25052023_074403.mp4

Copy link
Contributor

@aimane-chnaif aimane-chnaif left a comment

Choose a reason for hiding this comment

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

Thanks for the great work!
I think all good to merge

@Julesssss
Copy link
Contributor

bar background color and theme changes while on Splash screen

Hey @aimane-chnaif, thanks for retesting. Good spot, but I think we can live with this for now

Copy link
Contributor

@Julesssss Julesssss left a comment

Choose a reason for hiding this comment

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

Excellent, thanks again @janicduplessis

@Julesssss Julesssss merged commit c53c89b into Expensify:main May 25, 2023
@OSBotify
Copy link
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@janicduplessis janicduplessis deleted the @janic/status-bar-2 branch May 25, 2023 13:12
@OSBotify
Copy link
Contributor

🚀 Deployed to staging by https://github.com/Julesssss in version: 1.3.19-0 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

@OSBotify
Copy link
Contributor

🚀 Deployed to production by https://github.com/luacmartins in version: 1.3.19-7 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

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.

7 participants