[PR #1833] [MERGED] Fix for short profile Name value crashing app #3165

Closed
opened 2025-11-26 23:29:09 -06:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/bitwarden/android/pull/1833
Author: @mpbw2
Created: 3/8/2022
Status: Merged
Merged: 3/9/2022
Merged by: @mpbw2

Base: masterHead: bugfix-avatarshortname


📝 Commits (1)

  • f6f1602 Fix for short profile Name value crashing app

📊 Changes

5 files changed (+17 additions, -2 deletions)

View changed files

📝 src/App/Controls/AvatarImageSource.cs (+5 -1)
📝 src/Core/Abstractions/IStateService.cs (+1 -0)
📝 src/Core/Services/StateService.cs (+9 -0)
📝 src/Core/Services/SyncService.cs (+1 -0)
📝 src/iOS.Core/Renderers/CustomNavigationRenderer.cs (+1 -1)

📄 Description

Type of change

  • Bug fix
  • New feature development
  • Tech debt (refactoring, code cleanup, dependency upgrades, etc)
  • Build/deploy pipeline (DevOps)
  • Other

Objective

  • Using a one or two character "Name" in your account profile would result in an invisible avatar, which then caused iOS to crash when our CustomNavigationRenderer tried to apply a rendering mode to the non-existent avatar. The latter issue is now protected from crashing, and the former issue has been fixed so both platforms create the avatar properly if "Name" is 1 or 2 chars. Special thanks to "AJ" for the help tracking this down. :)
  • Discovered "Name" was never updated after account was initially added, so now it's updated on sync

Code changes

  • AvatarImageSource.cs: Make sure chars and upperData are both populated if the first two conditions fail in Draw(), and return the original value if both conditions fail in GetFirstLetters(..)
  • CustomNavigationRenderer.cs: Null check uiBarButtonItem.Image before applying rendering mode
  • SyncService.cs & StateService.cs: Added support for updating "Name" on sync (previously was only set when adding account)

Testing requirements

Before you submit

  • I have added unit tests where it makes sense to do so (encouraged but not required)
  • This change requires a documentation update (notify the documentation team)
  • This change has particular deployment requirements (notify the DevOps team)

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/bitwarden/android/pull/1833 **Author:** [@mpbw2](https://github.com/mpbw2) **Created:** 3/8/2022 **Status:** ✅ Merged **Merged:** 3/9/2022 **Merged by:** [@mpbw2](https://github.com/mpbw2) **Base:** `master` ← **Head:** `bugfix-avatarshortname` --- ### 📝 Commits (1) - [`f6f1602`](https://github.com/bitwarden/android/commit/f6f160297fca80537be22f3cf2da6bc16f97af7a) Fix for short profile Name value crashing app ### 📊 Changes **5 files changed** (+17 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `src/App/Controls/AvatarImageSource.cs` (+5 -1) 📝 `src/Core/Abstractions/IStateService.cs` (+1 -0) 📝 `src/Core/Services/StateService.cs` (+9 -0) 📝 `src/Core/Services/SyncService.cs` (+1 -0) 📝 `src/iOS.Core/Renderers/CustomNavigationRenderer.cs` (+1 -1) </details> ### 📄 Description ## Type of change - [X] Bug fix - [ ] New feature development - [ ] Tech debt (refactoring, code cleanup, dependency upgrades, etc) - [ ] Build/deploy pipeline (DevOps) - [ ] Other ## Objective <!--Describe what the purpose of this PR is. For example: what bug you're fixing or what new feature you're adding--> - Using a one or two character "Name" in your account profile would result in an invisible avatar, which then caused iOS to crash when our `CustomNavigationRenderer` tried to apply a rendering mode to the non-existent avatar. The latter issue is now protected from crashing, and the former issue has been fixed so both platforms create the avatar properly if "Name" is 1 or 2 chars. Special thanks to "AJ" for the help tracking this down. :) - Discovered "Name" was never updated after account was initially added, so now it's updated on sync ## Code changes <!--Explain the changes you've made to each file or major component. This should help the reviewer understand your changes--> <!--Also refer to any related changes or PRs in other repositories--> * **AvatarImageSource.cs:** Make sure `chars` and `upperData` are both populated if the first two conditions fail in `Draw()`, and return the original value if both conditions fail in `GetFirstLetters(..)` * **CustomNavigationRenderer.cs:** Null check `uiBarButtonItem.Image` before applying rendering mode * **SyncService.cs & StateService.cs:** Added support for updating "Name" on sync (previously was only set when adding account) ## Testing requirements <!--What functionality requires testing by QA? This includes testing new behavior and regression testing--> ## Before you submit - [ ] I have added **unit tests** where it makes sense to do so (encouraged but not required) - [ ] This change requires a **documentation update** (notify the documentation team) - [ ] This change has particular **deployment requirements** (notify the DevOps team) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2025-11-26 23:29:09 -06:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/android#3165