-
Notifications
You must be signed in to change notification settings - Fork 1.3k
For #5295 [A11y] Unable to tap snackbar #6513
For #5295 [A11y] Unable to tap snackbar #6513
Conversation
Codecov Report
@@ Coverage Diff @@
## master #6513 +/- ##
=========================================
Coverage ? 16.75%
Complexity ? 349
=========================================
Files ? 271
Lines ? 10667
Branches ? 1484
=========================================
Hits ? 1787
Misses ? 8733
Partials ? 147
Continue to review full report at Codecov.
|
.setAction(undoActionTitle) { | ||
requestedUndo.set(true) | ||
if (isAccessibilityEnabled) { | ||
// CONFIRMATION DIALOG: TO-D0 CHECK IF THERE IS TALK BACK VIA ACCESSIBILITY THEN DO THIS |
There was a problem hiding this comment.
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()
}
3591a9a
to
4203614
Compare
There was a problem hiding this 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() |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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
2ccd1f6
to
0b53107
Compare
5d4ce61
to
5b31dd8
Compare
3d5be32
to
e038e0c
Compare
@lime124 See attached GIF above |
@AmyYLee can you check this out tomorrow? thanks! |
This looks good to me @kglazko Thanks! |
bors r+ |
Build succeeded
|
Pull Request checklist
After merge
To download an APK when reviewing a PR: