Android TalkBack keep highlighted position on Screen Rotation - android

Use case:
Enable the Google TalkBack accessibility service and navigate to an
app (e.g. Google Messenger)
In this app, assuming that you'll be presented with a list of items
to select, arbitrarily navigate to one of them using Talkback gestures (swipe right or just click once on one of them)
Rotate the screen
Expected behaviour:
The previously highlighted item should still be highlighted; the user
should be able to continue it's navigation
The Google Messenger app is a perfect example of this correct
behaviour
Messenger After rotation
My Sunshine app behaviour:
The previously highlighted item is not highlighted after Screen
Rotation
The user has to navigate again to the previously selected item
Depending on the screen, finding and having an item selected again can be a pain... not what we want to induce to our user
Sunshine After rotation
How should we implement this?
I'm thinking, as a solution, at Accessibility Events and intercepting them... but this doesn't seem to be right, doesn't seem to be "best practice" (e.g. creating a Custom View and implement the methods handling these Events)
! Note that the green highlighted list item doesn't seem to be focused (getCurrentFocused() returns null)
! Note that the list items become focused if we use D-Pad navigation, instead of TalkBack navigation (but this is another discussion...)
L.E:
I've spend a whole day on this, trying to "get the focus" of the
highlighted item, but the item is NOT focused. This is why I assume
that this feature must be tackled in some other way and I would like
to know your (!) experienced opinion before I spend another 2 days
re-creating all the used Android components (as I assume it could be done - this doesn't sound very "best practice", doesn't it ?)
This is NOT a homework, there's nothing wrong with my current code
(so, there's no code to post, unless one would like my whole project)
and, given that this is my first post, I could not attach more than 2
pictures (this is why the "before" screens are missing)
Just give me a good hint, based on experience, and I will implement it and post the finished, working code here.

It should work out of the box if you implement stable IDs in your RecyclerView.Adapter (and potentially disable the ItemAnimator on the RecyclerView (rv.setItemAnimator(null)) which you can do conditionally if TalkBack is enabled).
Here's a blog post I wrote about the item animator bug.

I ran into the same problem while working on the same project.
Hint: listView.setItemChecked(int position, boolean value);
Good luck :)

Related

How to properly design list item with actions

It probably will be an opinion based answers rather than fixed ones, but I thoughts it wouldn't be bad to ask this question and get opinions from more experienced developers.
I am implementing in my app recycler view, that each item in the recycler view should have some actions, for example
delete, reminders, spinners, change icons and some others.
Currently I implemented the delete and change icon logic with both swipe action, and contextual action mode(on click the app bar changed to "new" app bar with delete button)
I thought to continue to implement all the other actions, like reminders and spinners in the item itself but I don't know if it's a good idea.
After some research I have several approaches in my mind:
throw all the actions right in the item view itself, which mean the user see right away all the possible actions.
use popup menu(three dots on the item, and open little menu with actions)
expand the contextual action mode that will include all actions
Maybe even completely different approach and put all the actions inside the item detail screen
What do you think is a better approach?
For what it's worth, the Material Design specs (scroll down to List Controls, I can't get a link to it HOW IRONIC) recommend a primary and (optional) secondary action, with possible left and right swipe gestures (which are usually understood to be "get rid of this item" in some way, like archive and delete)
Personally I think that's a good way to go (and you don't need to follow MD but it's a good base set of principles, especially if you're not a designer or UX person yourself) - it avoids clutter, and makes it clearer to users what their main options are.
You can implement tap behaviour on the list item to bring up a dialog (fullscreen or otherwise) where you have room to add lots of other options, labels to explain them, etc. You're not limited to the size of a list item, and you can easily add to it in future if you need to, instead of being committed to trying to fit everything into a list item.
Plus there's accessibility to think about - list items are small, you don't get much space (especially on smaller devices, where the user has large fonts enabled) so where are you gonna put all that stuff? Moving some to a contextual action mode works, but there's not much space there either, and the user has to realise they need to look up there. Will it work well for blind users relying on linear navigation?
Basically you can avoid a lot of these troubles by following established patterns, where other people have done the work to make it all "just work". My own personal experience has been trying to do things in a different way, and eventually coming back to the "recommended" way and wishing I'd done that to begin with!

Can you jump out of a RecyclerView while using TalkBack gesture navigation on Android?

short version: navigating into a RecyclerView with TalkBack gestures forces you to swipe through every item before you can move on, is that normal? Is there a standard way to navigate out and onto the next element?
I'm trying to get accessibility features working smoothly in an app I'm working on, but I've run into a problem with part of the UI. I'm using RecyclerViews sized so you can only see one item at a time, snapping to the centre, so you can swipe to change the current value from a range. It's basically the NumberPicker approach but directly in the UI, instead of a separate dialog.
The issue is by doing swipe gestures (Default linear navigation) through the UI, as soon as it lands on the RecyclerView, it starts on the current item and then navigates through every single item in the list. It won't exit the RecyclerView until it's hit the last item and has nowhere else to go.
My question is, is this normal? I'm new to TalkBack and I can't find much info on what's expected in every situation. I know my situation is a little unusual (since navigating the RecyclerView implicitly means changing the current item) but just being trapped inside the list until you go through every item seems a really strange way to navigate in general.
I know there are solutions like adding navigation headings etc (which is how the Play Store seems to handle this with their "infinite" horizontally scrolling app selections) but I just wanted to check I wasn't missing something. TalkBack announces "in list" and "out of list" when you tap on/outside of the RecyclerView, so it seems like there should be a way to explicitly navigate in and out with a gesture too...? Would users be used to switching to Controls or Headings navigations to do this?
Thanks! I really want to make this work for everyone but it's hard to know if I've done something wrong, or if I'm just bumping into limitations with the standard components

Customise Android talk-back/accessibility Gestures

I am working on some online shopping application. In this, we have Update Remove quantity buttons to manipulate cart quantity.
This works fine in normal flow. but when accessibility is enabled, It got quite complicated as user needs to go back and forth on plus and minus buttons to adjust the quantity after that user needs to remember to hit Update and Remove buttons.
I was thinking of a solution if we can override "SWPE_UP" and "SWIPE_DOWN" gestures after some view clicked so that the accessibility user can easily manipulate quantity by swiping up or down and once the quantity is set, respective buttons can be clicked programmatically on double tap.
I have gone through some articles and searched behavior in similar apps, but couldn't find enough reference material. They won't have similar problems as most apps don't have Update or Remove buttons.
If anyone can help me to find a solution or provide some reference material then it would be a great help!!

How can I suggest a swipe-to-right gesture in a list on a mobile device?

I have done live user testing for a list in my app, and have come to an interesting puzzle.
A list, specifically a single-column table in iOS, may often have a swipe right gesture for more actions, like the twitter app and mail app, and a million other apps. But when important functionality is embedded in the UI beyond that action, and a user cannot figure it out, the only thing that comes to mind to alleviate that is something like the accessory button, ie. a right-pointing triangle or chevron button.
There is probably another way but it's not coming to me. Maybe making the rows taller than normal?
This was meant as a comment but was rejected as too-long.
So after thinking more about this, the ideal solution is a visual clue, rather than painfully obvious text saying "swipe a row for more options". Perhaps when a list (UITableView, etc) is shown and rows (UITableViewCell, etc) are created and added, then as they appear an animation begins of the main visible content sliding into place in the OPPOSITE direction of the desired swipe animation, with a minimal visual indicator afterward, reminding the user that the content is moveable!
Sound good? Optionally, immediately before the animation begins, any underlying content may be shown for a split second (if its supposed to appear underneath). Sweet!

How to implement Android 4.0 like swipe to dismiss functionality in ListView?

I'm working on an app in which I would like to implement swipe-to-dismiss functionality in the ListView - similar to what we see in Android 4.0's notification bar, recent apps list or browser tabs. I want to run the app on the devices running Android 2.2+. See the following image. I also want to change the transparency of the item being swiped-away - just like in ICS.
I checked the source of the ICS web browser on http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android-apps/4.0.1_r1/com/android/browser/TabScrollView.java?av=f but couldn't figure out which class is particularly responsible for implementing this functionality.
Can anyone point me in the right direction here? Can we do this using Android Compatibility Library? Please let me know. Many thanks.
I've thought about implementing such a feature as well, but I haven't done it yet. So the only thing I can provide are some ideas on how I would approach that problem. If I've eventually written some code I will post it here.
The main class needed is a custom Adapter which extends a ListAdapter (ArrayAdapter, SimpleCursorAdapter etc.).
The adapter applies a View.OnTouchListener to all of its Views.
Whenever that listener detects a horizontal scroll dx, it calls concernedView.offsetLeftAndRight(dx) (which will make the view draggable). Of course the adapter has to save the current horizontal offset for the view. If the user was dragging a view and removes his/her finger from the screen, the touchListener will detect this as well and start a slide back animation. Using the current offset we can also calculate an alpha value, so the view will fade out when it approaches the screen borders.
If one list entry is eventually dismissed by the user, it becomes a bit tricky, and I'm still not sure how I would implement the following action: The list content has to be updated (or the adapter has to ignore the dismissed entries) and the views that were below the one that was dismissed must hover upwards in order to fill the gap. I think it might work to let the ListView load the new content, but that would fill the gap instantly. In order to avoid that, I would then start an animation that lets all the concerned views hover from their old position (where we still had the gap) back to their current position (where the gap is filled).
These are just some of my thoughts on the issue that might help some people getting started on working on the problem. Like I said, I'm probably going to implement that sometime in the future and of course I will post the code here.
I would appreciate any feedback in the comments, but I don't want to thorougly explain every single aspect of my idea, that would take me too much time ;)
I know this is quite an old question, but for anyone still searching for this, you can have a look at Roman Nurik's library here: https://github.com/romannurik/Android-SwipeToDismiss
This shows how to create the required behavior for list-view as well as for normal views.

Categories

Resources