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

PM-14333 Complete fix for crash caused by spannable text creation #4479

Merged
merged 5 commits into from
Dec 20, 2024

Conversation

dseverns-livefront
Copy link
Collaborator

🎟️ Tracking

https://bitwarden.atlassian.net/browse/PM-14333

📔 Objective

  • This completes the work started in https://bitwarden.atlassian.net/browse/PM-15976 fix, with that change we are avoiding the crash, but not trying to apply a span style on a non existing index. This change updates our string resources and how we are applying the spans to better support the case where there is translation for the high lighted string but not for the full string where its to be added.

⏰ Reminders before review

  • Contributor guidelines followed
  • All formatters and local linters executed and passed
  • Written new unit and / or integration tests where applicable
  • Used internationalization (i18n) for all UI strings
  • CI builds passed
  • Communicated to DevOps any deployment requirements
  • Updated any necessary documentation or informed the documentation team

🦮 Reviewer guidelines

  • 👍 (:+1:) or similar for great changes
  • 📝 (:memo:) or ℹ️ (:information_source:) for notes or general info
  • ❓ (:question:) for questions
  • 🤔 (:thinking:) or 💭 (:thought_balloon:) for more open inquiry that's not quite a confirmed
    issue and could potentially benefit from discussion
  • 🎨 (:art:) for suggestions / improvements
  • ❌ (:x:) or ⚠️ (:warning:) for more significant problems or concerns needing attention
  • 🌱 (:seedling:) or ♻️ (:recycle:) for future improvements or indications of technical debt
  • ⛏ (:pick:) for minor or nitpick changes

it.getLinkAnnotations(expectedStart, expectedEnd)
.forEach { annotationRange ->
val linkAnnotations = it.getLinkAnnotations(expectedStart, expectedEnd)
if (linkAnnotations.isEmpty()) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@phil-livefront this not existing is why that one test was passing no matter what.

Copy link
Contributor

github-actions bot commented Dec 15, 2024

Logo
Checkmarx One – Scan Summary & Detailsda95a8ce-b36c-4596-97cc-49cd18734746

No New Or Fixed Issues Found

phil-livefront
phil-livefront previously approved these changes Dec 17, 2024
highlights = listOf(email),
highlightStyle = SpanStyle(
val descriptionAnnotatedString = R.string.we_sent_an_email_to.toAnnotatedString(
email,
Copy link
Collaborator

Choose a reason for hiding this comment

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

🔨 do we need internal param names here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

weird vararg thing. if I put args = I need to pass in as arrayOf(email)

val start = spannableBuilder.getSpanStart(annotation)
val end = spannableBuilder.getSpanEnd(annotation)
when (annotation.key) {
"emphasis" -> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

🔨 should this be a enum?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I had them, but it basically served no other purpose than doing something like:

when (val enum = EnumType.valueOf(annotation.key.uppercase())) {
     OPTION1 -> { ... }

and if annotation.key was not an enum value it would crash. I guess maybe that would be a good thing as that type of error is something that should be caught while testing so would be useful to the developer to be like hey you used an annotation we weren't ready for...and now I am thinking we should add as an enum :)

this.replace(
this.getSpanStart(annotation),
this.getSpanEnd(annotation),
args[argIndex],
Copy link
Collaborator

Choose a reason for hiding this comment

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

can we add a condition to make sure the index exists here?

val annotations = getSpans<Annotation>()
annotations
.filter {
it.key == "arg"
Copy link
Collaborator

Choose a reason for hiding this comment

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

not sure how ya'll do this stuff yet, but thoughts on adding a string constants model for the hardcoded strings? not sure these would ever change though so might be a silly ask haha. my first instinct when i see hardcoded strings tho is to ask about them haha

Copy link

codecov bot commented Dec 19, 2024

Codecov Report

Attention: Patch coverage is 89.90826% with 11 lines in your changes missing coverage. Please review.

Project coverage is 88.89%. Comparing base (f32eecc) to head (4c9423f).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...arden/ui/platform/base/util/StringResExtensions.kt 91.66% 0 Missing and 5 partials ⚠️
...ature/startregistration/StartRegistrationScreen.kt 50.00% 4 Missing ⚠️
...rtlogins/components/ImportLoginsInstructionStep.kt 33.33% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4479      +/-   ##
==========================================
- Coverage   88.93%   88.89%   -0.05%     
==========================================
  Files         459      460       +1     
  Lines       39839    39754      -85     
  Branches     5634     5643       +9     
==========================================
- Hits        35432    35340      -92     
- Misses       2440     2443       +3     
- Partials     1967     1971       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

SaintPatrck
SaintPatrck previously approved these changes Dec 20, 2024
@dseverns-livefront dseverns-livefront added this pull request to the merge queue Dec 20, 2024
Merged via the queue into main with commit 1148e48 Dec 20, 2024
8 checks passed
@dseverns-livefront dseverns-livefront deleted the PM-14333-add-back-functionalitity branch December 20, 2024 22:10
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.

3 participants