Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e4705400 authored by Fabián Kozynski's avatar Fabián Kozynski
Browse files

Change a11y behavior of non-current tiles on edit

When editing tiles, when moving a tile using the accessibility action,
we would mark the invalid positions as not important for accessibility.
This would cause the recyclerView to scroll to show these views, moving
the valid views out of reach for the a11y service, but not leaving the
user in a good context.

Instead, have the views report to the a11y service, but set their
content description to indicate that they are in an invalid position.
Apply this also to the "Add tile" action that allows the user to add a
tile to a particular position (as opposed to the end).

Test: manual, using Talkback
Fixes: 319585400
Flag: none

Change-Id: I0abaa2a3dafcb6e99108378a1d6e0ef2267b2660
parent f0694c53
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -2261,6 +2261,9 @@
    <!-- Accessibility description when QS tile is to be added, indicating the destination position [CHAR LIMIT=NONE] -->
    <string name="accessibility_qs_edit_tile_add_to_position">Add to position <xliff:g id="position" example="5">%1$d</xliff:g></string>

    <!-- Accessibility description when QS tile would be added or moved, but the current position is not valid for adding or moving to [CHAR LIMIT=NONE] -->
    <string name="accessibilit_qs_edit_tile_add_move_invalid_position">Position invalid.</string>

    <!-- Accessibility description indicating the currently selected tile's position. Only used for tiles that are currently in use [CHAR LIMIT=NONE] -->
    <string name="accessibility_qs_edit_position">Position <xliff:g id="position" example="5">%1$d</xliff:g></string>

+17 −3
Original line number Diff line number Diff line
@@ -332,6 +332,14 @@ public class TileAdapter extends RecyclerView.Adapter<Holder> implements TileSta
        return mTiles.size();
    }

    public int getItemCountForAccessibility() {
        if (mAccessibilityAction == ACTION_MOVE) {
            return mEditIndex;
        } else {
            return getItemCount();
        }
    }

    @Override
    public boolean onFailedToRecycleView(Holder holder) {
        holder.stopDrag();
@@ -406,6 +414,10 @@ public class TileAdapter extends RecyclerView.Adapter<Holder> implements TileSta
        } else if (selectable && mAccessibilityAction == ACTION_MOVE) {
            info.state.contentDescription = mContext.getString(
                    R.string.accessibility_qs_edit_tile_move_to_position, position);
        } else if (!selectable && (mAccessibilityAction == ACTION_MOVE
                || mAccessibilityAction == ACTION_ADD)) {
            info.state.contentDescription = mContext.getString(
                    R.string.accessibilit_qs_edit_tile_add_move_invalid_position);
        } else {
            info.state.contentDescription = info.state.label;
        }
@@ -424,14 +436,15 @@ public class TileAdapter extends RecyclerView.Adapter<Holder> implements TileSta
        holder.mTileView.setOnClickListener(null);
        holder.mTileView.setFocusable(true);
        holder.mTileView.setFocusableInTouchMode(true);
        holder.mTileView.setAccessibilityTraversalBefore(View.NO_ID);

        if (mAccessibilityAction != ACTION_NONE) {
            holder.mTileView.setClickable(selectable);
            holder.mTileView.setFocusable(selectable);
            holder.mTileView.setFocusableInTouchMode(selectable);
            holder.mTileView.setImportantForAccessibility(selectable
                    ? View.IMPORTANT_FOR_ACCESSIBILITY_YES
                    : View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS);
//            holder.mTileView.setImportantForAccessibility(selectable
//                    ? View.IMPORTANT_FOR_ACCESSIBILITY_YES
//                    : View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS);
            if (selectable) {
                holder.mTileView.setOnClickListener(new OnClickListener() {
                    @Override
@@ -911,4 +924,5 @@ public class TileAdapter extends RecyclerView.Adapter<Holder> implements TileSta
        int estimatedTileViewHeight = mTempTextView.getMeasuredHeight() * 2 + padding * 2;
        mMinTileViewHeight = Math.max(minHeight, estimatedTileViewHeight);
    }

}