diff options
| author | 2019-09-30 18:09:12 +0000 | |
|---|---|---|
| committer | 2019-09-30 18:09:12 +0000 | |
| commit | 8fb63e67a0753ba983504ded6761aff439f05832 (patch) | |
| tree | f22d1884455cd801b35627fe4627c8a96244697c | |
| parent | e4e9cae66ec3d231f6f84ecc25f4086f972fb185 (diff) | |
| parent | d06a8494ff8f3b6e1742748a824b41aa61000377 (diff) | |
Merge "Restrict accessible move when tiles cannot be removed"
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/qs/customize/TileAdapter.java | 38 |
1 files 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<Holder> 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<Holder> 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<Holder> implements TileSta mAccessibilityFromIndex = position; mAccessibilityFromLabel = mTiles.get(position).state.label; mAccessibilityAction = ACTION_MOVE; + mNeedsFocus = true; notifyDataSetChanged(); } |