Skip to content
This repository has been archived by the owner on Feb 20, 2023. It is now read-only.

For #5295 [A11y] Unable to tap snackbar #6513

Merged
merged 1 commit into from
Nov 15, 2019

Conversation

kglazko
Copy link
Contributor

@kglazko kglazko commented Nov 8, 2019


Pull Request checklist

  • Quality: This PR builds and passes detekt/ktlint checks (A pre-push hook is recommended)
  • Tests: This PR includes thorough tests or an explanation of why it does not
  • Screenshots: This PR includes screenshots or GIFs of the changes made or an explanation of why it does not
  • Accessibility: The code in this PR follows accessibility best practices or does not include any user facing features

After merge

  • Milestone: Make sure issues finished by this pull request are added to the milestone of the version currently in development.

To download an APK when reviewing a PR:

  1. click on Show All Checks,
  2. click Details next to "Taskcluster (pull_request)" after it appears and then finishes with a green checkmark,
  3. click on the "Fenix - assemble" task, then click "Run Artifacts".
  4. the APK links should be on the left side of the screen, named for each CPU architecture

@codecov-io
Copy link

codecov-io commented Nov 8, 2019

Codecov Report

❗ No coverage uploaded for pull request base (master@ee4e1c8). Click here to learn what that means.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master    #6513   +/-   ##
=========================================
  Coverage          ?   16.75%           
  Complexity        ?      349           
=========================================
  Files             ?      271           
  Lines             ?    10667           
  Branches          ?     1484           
=========================================
  Hits              ?     1787           
  Misses            ?     8733           
  Partials          ?      147
Impacted Files Coverage Δ Complexity Δ
app/src/main/java/org/mozilla/fenix/utils/Undo.kt 0% <0%> (ø) 0 <0> (?)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ee4e1c8...e038e0c. Read the comment docs.

@kglazko kglazko changed the title Issue 5295 [A11y] Unable to tap snackbar WIP For #5295 [A11y] Unable to tap snackbar Nov 8, 2019
.setAction(undoActionTitle) {
requestedUndo.set(true)
if (isAccessibilityEnabled) {
// CONFIRMATION DIALOG: TO-D0 CHECK IF THERE IS TALK BACK VIA ACCESSIBILITY THEN DO THIS
Copy link
Contributor

Choose a reason for hiding this comment

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

The code looks good, but these blocks have gotten big enough that they're getting a little tough to follow. I think this would be easier if they were broken into helper functions, so we could get:

if (isAccessibilityEnabled) {
  showUndoDialog()
else {
  showUndoSnackbar()
}

@kglazko kglazko force-pushed the Issue5295UnableToTapSnackbar branch from 3591a9a to 4203614 Compare November 12, 2019 23:31
@kglazko kglazko requested a review from severinrudie November 12, 2019 23:45
Copy link
Contributor

@severinrudie severinrudie left a comment

Choose a reason for hiding this comment

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

Code looks good to me. I have a few minor nits, but the structure is solid.

val isAccessibilityEnabled = accessibilityEnabled(view)

// Show either Snackbar or dialog based on result
if (isAccessibilityEnabled) showUndoDialog() else showUndoSnackbar()
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a small project style thing, but would you remind reformatting this into:

if (isAccessibilityEnabled) {
  showUndoDialog()
} else {
  showUndoSnackbar()
}

}
}

// Check if accessibility is enabled
val isAccessibilityEnabled = accessibilityEnabled(view)
Copy link
Contributor

Choose a reason for hiding this comment

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

This line doesn't seem to help readabbility too much. Maybe just call accessibilityEnabled(view) inside the if statement on 96?

// Check if accessibility is enabled
val isAccessibilityEnabled = accessibilityEnabled(view)

// Show either Snackbar or dialog based on result
Copy link
Contributor

Choose a reason for hiding this comment

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

There's a maxim on code comments that says they should explain how, not what. I don't think we need this comment, but it probably would be worth explaining why we're doing this in the first place. Would you mind replacing this with something like // It is difficult to use our Snackbars quickly enough with accessibility settings enabled, so in that case we show a dialog instead?

.setAnchorView(anchorView)
.setAction(undoActionTitle) {
requestedUndo.set(true)
// Launch an alert dialog for undo- for accessibility users
Copy link
Contributor

Choose a reason for hiding this comment

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

This is the kind of comment that could age poorly. If we explain the accessibility problem down where we're conditioning on accessibility mode, hopefully it will be removed if that ever goes out of date. However, it's not unreasonable to think that some other chunk of code could someday call showUndoDialog for a use case that has nothing to do with accessibility. At that point, this comment will have rotted unintentionally. I would remove this one entirely.

Commenting is really hard.


// If user engages with the snackbar, it'll get automatically dismissed.
snackbar.show()
// Launch an indefinite snackbar
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we could probably get rid of this comment


fun accessibilityEnabled(view:View): Boolean {
val am = view.context.getSystemService(Context.ACCESSIBILITY_SERVICE) as AccessibilityManager
return am.isEnabled
Copy link
Contributor

Choose a reason for hiding this comment

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

Good helper function, this really improves the clarity.

Normally I think it's good to narrow parameters as much as possible (passing Context is better than View, AccessibilityManager is better than Context). There are a lot of good reasons for doing that, but in this instance the lookup is all the function is really doing. So this is probably good as is! No changes needed.

}
}

// If user engages with the snackbar, it'll get automatically dismissed.
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we could probably get rid of this comment

@kglazko kglazko force-pushed the Issue5295UnableToTapSnackbar branch 3 times, most recently from 2ccd1f6 to 0b53107 Compare November 14, 2019 19:25
@kglazko
Copy link
Contributor Author

kglazko commented Nov 14, 2019

VideoToGif_GIF
Screenshot GIF

@kglazko kglazko force-pushed the Issue5295UnableToTapSnackbar branch 4 times, most recently from 5d4ce61 to 5b31dd8 Compare November 14, 2019 21:13
@kglazko kglazko force-pushed the Issue5295UnableToTapSnackbar branch from 3d5be32 to e038e0c Compare November 14, 2019 21:54
@kglazko kglazko requested review from brampitoyo and removed request for brampitoyo November 14, 2019 22:09
@kglazko kglazko changed the title WIP For #5295 [A11y] Unable to tap snackbar For #5295 [A11y] Unable to tap snackbar Nov 14, 2019
@kglazko
Copy link
Contributor Author

kglazko commented Nov 14, 2019

@lime124 See attached GIF above

@lime124
Copy link
Collaborator

lime124 commented Nov 15, 2019

@AmyYLee can you check this out tomorrow? thanks!

@AmyYLee
Copy link
Collaborator

AmyYLee commented Nov 15, 2019

VideoToGif_GIF
Screenshot GIF

This looks good to me @kglazko Thanks!

@kglazko
Copy link
Contributor Author

kglazko commented Nov 15, 2019

bors r+

bors bot pushed a commit that referenced this pull request Nov 15, 2019
6513: For #5295 [A11y] Unable to tap snackbar r=kglazko a=kglazko



Co-authored-by: Kate Glazko <katglazko@gmail.com>
@bors
Copy link

bors bot commented Nov 15, 2019

Build succeeded

  • build-debug
  • test-debug
  • lint-detekt
  • lint-ktlint
  • test-ui
  • lint-compare-locales
  • lint-lint

@bors bors bot merged commit e038e0c into mozilla-mobile:master Nov 15, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants