Merge "Add tile added/removed announcements" into sc-dev
diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml
index 589a39c..abcf4e8 100644
--- a/packages/SystemUI/res/values/strings.xml
+++ b/packages/SystemUI/res/values/strings.xml
@@ -2253,6 +2253,12 @@
<!-- 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>
+ <!-- Accessibility announcement after a tile has been added [CHAR LIMIT=NONE] -->
+ <string name="accessibility_qs_edit_tile_added">Tile added</string>
+
+ <!-- Accessibility announcement after a tile has been added [CHAR LIMIT=NONE] -->
+ <string name="accessibility_qs_edit_tile_removed">Tile removed</string>
+
<!-- Accessibility label for window when QS editing is happening [CHAR LIMIT=NONE] -->
<string name="accessibility_desc_quick_settings_edit">Quick settings editor.</string>
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 507048c..21464fd 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/customize/TileAdapter.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/customize/TileAdapter.java
@@ -441,15 +441,17 @@
return position > mEditIndex;
}
- private void addFromPosition(int position) {
- if (!canAddFromPosition(position)) return;
+ private boolean addFromPosition(int position) {
+ if (!canAddFromPosition(position)) return false;
move(position, mEditIndex);
+ return true;
}
- private void removeFromPosition(int position) {
- if (!canRemoveFromPosition(position)) return;
+ private boolean removeFromPosition(int position) {
+ if (!canRemoveFromPosition(position)) return false;
TileInfo info = mTiles.get(position);
move(position, info.isSystem ? mEditIndex : mTileDividerIndex);
+ return true;
}
public SpanSizeLookup getSizeLookup() {
@@ -578,11 +580,17 @@
}
private void add() {
- addFromPosition(getLayoutPosition());
+ if (addFromPosition(getLayoutPosition())) {
+ itemView.announceForAccessibility(
+ itemView.getContext().getText(R.string.accessibility_qs_edit_tile_added));
+ }
}
private void remove() {
- removeFromPosition(getLayoutPosition());
+ if (removeFromPosition(getLayoutPosition())) {
+ itemView.announceForAccessibility(
+ itemView.getContext().getText(R.string.accessibility_qs_edit_tile_removed));
+ }
}
boolean isCurrentTile() {