Skip to content

Convert hardware bitmap to software bitmap for Android notification avatar cropping - #13391

Merged
arosiclair merged 2 commits into
Expensify:mainfrom
StefanNemeth:bug/android_notifications_avatar
Dec 27, 2022
Merged

Convert hardware bitmap to software bitmap for Android notification avatar cropping#13391
arosiclair merged 2 commits into
Expensify:mainfrom
StefanNemeth:bug/android_notifications_avatar

Conversation

@StefanNemeth

@StefanNemeth StefanNemeth commented Dec 7, 2022

Copy link
Copy Markdown
Contributor

Details

Converts the hardware avatar bitmap to a software bitmap so that it can be cropped properly on Android for user notifications.

Fixed Issues

$ #12967
$ #12967 (comment)

Tests

  1. Run a release build (otherwise notifications don't seem to work due to Airship configuration)
  2. Sign into the Android app
  3. Sign into another account on web and upload a custom profile picture for that account
  4. Background the Android app
  5. Send a message from the account signed in on web to the account signed in on Android
  6. Verify that a push notification appears and that the notification appears a message style notification, including the avatar image of the web user.
  • Verify that no errors appear in the JS console

Offline tests

QA Steps

  1. Sign into the Android app
  2. Sign into another account on web and upload a custom profile picture for that account
  3. Background the Android app
  4. Send a message from the account signed in on web to the account signed in on Android
  5. Verify that a push notification appears and that the notification appears a message style notification, including the avatar image of the web user.
  • Verify that no errors appear in the JS console

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
    • 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.
  • I have checked off every checkbox in the PR author checklist, including those that don't apply to this PR.

Screenshots/Videos

Web image
Mobile Web - Chrome image
Mobile Web - Safari

image

Desktop image
iOS

image

Android

image

@StefanNemeth
StefanNemeth requested a review from a team as a code owner December 7, 2022 04:25
@melvin-bot
melvin-bot Bot requested review from parasharrajat and robertjchen and removed request for a team December 7, 2022 04:25
@melvin-bot

melvin-bot Bot commented Dec 7, 2022

Copy link
Copy Markdown

@robertjchen @parasharrajat 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]

@github-actions

github-actions Bot commented Dec 7, 2022

Copy link
Copy Markdown
Contributor

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

@StefanNemeth

Copy link
Copy Markdown
Contributor Author

I have read the CLA Document and I hereby sign the CLA

@parasharrajat

Copy link
Copy Markdown
Member

I am not getting any notifications on the release app as well as on PROD. Not sure how to test it.

Is this same for your @StefanNemeth?

@StefanNemeth

Copy link
Copy Markdown
Contributor Author

I am not getting any notifications on the release app as well as on PROD. Not sure how to test it.

Is this same for your @StefanNemeth?

Not anymore. Local notifications don't seem so reliable.. could be related to #13392

@parasharrajat

Copy link
Copy Markdown
Member

@robertjchen Should we hold this PR until #13392 is fixed? I can't really test it.

@robertjchen

Copy link
Copy Markdown
Contributor

Yep, looks like we'll have to wait on #13392 for now

@arosiclair arosiclair left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice find! The push notification issue should be resolved on staging. Prod should come soon.

@StefanNemeth

Copy link
Copy Markdown
Contributor Author

Great 👍 Works for me again

@parasharrajat

Copy link
Copy Markdown
Member

@StefanNemeth Sorry for the delay here. This is vacation time so I was mostly away. Please merge main into this PR.

@parasharrajat

parasharrajat commented Dec 27, 2022

Copy link
Copy Markdown
Member

Screenshots

🔲 iOS / native

Screenshot 2022-12-27 17:08:54

🔲 iOS / Safari

SignIn issue and not affected by changes.

🔲 MacOS / Desktop

Screenshot 2022-12-27 16:59:40

🔲 MacOS / Chrome

Screenshot 2022-12-27 16:48:30

🔲 Android / Chrome

Screenshot 2022-12-27 16:47:25

🔲 Android / native

Screenshot 2022-12-27 16:38:52

@parasharrajat

Copy link
Copy Markdown
Member

Can someone trigger checks?

@parasharrajat parasharrajat left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible 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 checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified tests pass on all platforms & I tested again on:
    • Android / native
    • Android / Chrome
    • iOS / native
    • iOS / Safari
    • MacOS / Chrome / Safari
    • MacOS / Desktop
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified proper code patterns were followed (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
    • 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 verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • 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
  • 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.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

LGTM.

cc: @robertjchen

🎀 👀 🎀 C+ reviewed

@arosiclair
arosiclair merged commit 780dd7e into Expensify:main Dec 27, 2022
@OSBotify

Copy link
Copy Markdown
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.

@github-actions

Copy link
Copy Markdown
Contributor

Performance Comparison Report 📊

Significant Changes To Duration

There are no entries

Meaningless Changes To Duration

Show entries
Name Duration
TTI 808.889 ms → 820.626 ms (+11.737 ms, +1.5%)
runJsBundle 184.226 ms → 195.000 ms (+10.774 ms, +5.8%)
regularAppStart 0.014 ms → 0.014 ms (-0.000 ms, -1.1%)
nativeLaunch 10.125 ms → 10.000 ms (-0.125 ms, -1.2%)
Show details
Name Duration
TTI Baseline
Mean: 808.889 ms
Stdev: 33.573 ms (4.2%)
Runs: 741.3588269995525 754.0549510000274 754.2417329996824 765.4604240003973 769.740996000357 771.796043000184 777.4818249996752 790.3409320004284 794.2365819998085 794.387485999614 800.0160330003127 802.492041000165 802.5335529996082 805.4958849996328 806.8925959998742 810.593692000024 811.8314060000703 813.4878610000014 814.7728000003844 817.1638240003958 821.8282059999183 822.469087000005 826.8188359998167 827.4138970002532 841.3256200002506 843.0915149999782 844.1035479996353 847.0947580002248 852.4563600001857 854.3800529995933 896.1891949996352

Current
Mean: 820.626 ms
Stdev: 44.731 ms (5.5%)
Runs: 740.1105380002409 756.8544770004228 760.2815239997581 770.1548750000075 777.5254939999431 778.1473089996725 782.3120200000703 792.1339880004525 794.4222480002791 801.3150079995394 802.9222740000114 803.2039949996397 805.4151630001143 808.1871079998091 809.9585560001433 813.2322570001706 813.8873829999939 815.6641720002517 817.879684000276 827.7697409996763 830.6873099999502 834.3020729999989 840.8193150004372 855.2872959999368 858.4863860001788 858.5730259995908 873.2313000001013 876.2480060001835 899.7858990002424 909.8992039998993 930.7068490004167
runJsBundle Baseline
Mean: 184.226 ms
Stdev: 18.463 ms (10.0%)
Runs: 153 156 157 164 164 165 166 166 166 171 171 176 177 181 182 187 191 191 192 193 194 196 197 199 199 200 201 207 210 212 227

Current
Mean: 195.000 ms
Stdev: 22.003 ms (11.3%)
Runs: 162 166 166 169 171 174 175 177 177 180 183 187 189 190 190 191 192 198 198 200 205 206 207 209 209 211 213 224 236 240 250
regularAppStart Baseline
Mean: 0.014 ms
Stdev: 0.001 ms (5.4%)
Runs: 0.012613999657332897 0.012736000120639801 0.01285799965262413 0.012939000502228737 0.013264999724924564 0.013590999878942966 0.013631000183522701 0.013632000423967838 0.013712000101804733 0.013834000565111637 0.013915999792516232 0.013915999792516232 0.013957000337541103 0.014078999869525433 0.014240999706089497 0.014283000491559505 0.014364000409841537 0.014404000714421272 0.014444999396800995 0.014566999860107899 0.014607999473810196 0.01464799977838993 0.01464799977838993 0.014810999855399132 0.014852000400424004 0.014973999932408333 0.015178000554442406 0.015217999927699566 0.015625

Current
Mean: 0.014 ms
Stdev: 0.001 ms (6.0%)
Runs: 0.012369000352919102 0.012655000202357769 0.012695000506937504 0.013020999729633331 0.013224000111222267 0.013306000269949436 0.013346999883651733 0.013347000814974308 0.013387000188231468 0.013387000188231468 0.013509000651538372 0.013631000183522701 0.01371300034224987 0.01375299971550703 0.013916000723838806 0.013997000642120838 0.014078999869525433 0.01411999948322773 0.01416000071913004 0.014161000028252602 0.014201000332832336 0.014322999864816666 0.014405000023543835 0.0147299999371171 0.014811000786721706 0.01501499954611063 0.015137000009417534 0.015258999541401863 0.015625 0.015625
nativeLaunch Baseline
Mean: 10.125 ms
Stdev: 1.654 ms (16.3%)
Runs: 8 8 8 8 8 8 9 9 9 9 9 9 9 10 10 10 10 10 10 10 11 11 11 11 11 12 12 12 12 12 14 14

Current
Mean: 10.000 ms
Stdev: 1.666 ms (16.7%)
Runs: 8 8 8 8 8 8 8 9 9 9 9 9 9 9 10 10 10 10 10 10 11 11 11 11 11 12 12 12 13 13 14

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by @arosiclair in version: 1.2.45-0 🚀

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

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by @chiragsalian in version: 1.2.45-0 🚀

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants