From d06a8494ff8f3b6e1742748a824b41aa61000377 Mon Sep 17 00:00:00 2001 From: Fabian Kozynski Date: Thu, 26 Sep 2019 16:06:08 -0400 Subject: Restrict accessible move when tiles cannot be removed When there were the minimum number of tiles in QSCustomize clicking on a current tile while on TB would enter ADD MODE, that allowed to move the tile out. This CL makes sure that in that case we enter MOVE MODE so the tile cannot be removed. Also, makes sure that the tile is focused when entering move mode Fixes: 140363294 Test: manual with and without TB with 6 and more tiles Change-Id: I3a27ca1bc54971f6a72b7d69abe6bdb73ca7c56a --- .../android/systemui/qs/customize/TileAdapter.java | 38 ++++++++++++++-------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/qs/customize/TileAdapter.java b/packages/SystemUI/src/com/android/systemui/qs/customize/TileAdapter.java index 2542abdbef72..bd3297b3d39c 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/customize/TileAdapter.java +++ b/packages/SystemUI/src/com/android/systemui/qs/customize/TileAdapter.java @@ -277,20 +277,7 @@ public class TileAdapter extends RecyclerView.Adapter implements TileSta selectPosition(holder.getAdapterPosition(), v); } }); - if (mNeedsFocus) { - // Wait for this to get laid out then set its focus. - // Ensure that tile gets laid out so we get the callback. - holder.mTileView.requestLayout(); - holder.mTileView.addOnLayoutChangeListener(new OnLayoutChangeListener() { - @Override - public void onLayoutChange(View v, int left, int top, int right, int bottom, - int oldLeft, int oldTop, int oldRight, int oldBottom) { - holder.mTileView.removeOnLayoutChangeListener(this); - holder.mTileView.requestFocus(); - } - }); - mNeedsFocus = false; - } + focusOnHolder(holder); return; } @@ -330,16 +317,38 @@ public class TileAdapter extends RecyclerView.Adapter implements TileSta } else { if (position < mEditIndex && canRemoveTiles()) { showAccessibilityDialog(position, v); + } else if (position < mEditIndex && !canRemoveTiles()) { + startAccessibleMove(position); } else { startAccessibleAdd(position); } } } }); + if (position == mAccessibilityFromIndex) { + focusOnHolder(holder); + } } } } + private void focusOnHolder(Holder holder) { + if (mNeedsFocus) { + // Wait for this to get laid out then set its focus. + // Ensure that tile gets laid out so we get the callback. + holder.mTileView.requestLayout(); + holder.mTileView.addOnLayoutChangeListener(new OnLayoutChangeListener() { + @Override + public void onLayoutChange(View v, int left, int top, int right, int bottom, + int oldLeft, int oldTop, int oldRight, int oldBottom) { + holder.mTileView.removeOnLayoutChangeListener(this); + holder.mTileView.requestFocus(); + } + }); + mNeedsFocus = false; + } + } + private boolean canRemoveTiles() { return mCurrentSpecs.size() > mMinNumTiles; } @@ -396,6 +405,7 @@ public class TileAdapter extends RecyclerView.Adapter implements TileSta mAccessibilityFromIndex = position; mAccessibilityFromLabel = mTiles.get(position).state.label; mAccessibilityAction = ACTION_MOVE; + mNeedsFocus = true; notifyDataSetChanged(); } -- cgit v1.2.3-59-g8ed1b