Add accessibility actions to the drag-and-drop locale list

Dragging is not supported neither by TalkBack or the accessibility
framework at the moment. So we need custom actions to be able
to change the order of the locales.

Also, the remove functionality is difficult to discover and use
with TalkBack only, so we are also adding a "remove" action.

It only removes one locale at the time, but most users don't
really add many locales "by mistake", so there is no real need
to delete a lot of locales at once.

Bug: 28173358
Change-Id: I3566304e3d2de87cf9243d7e87631b12d72fc929
This commit is contained in:
Mihai Nita
2016-04-21 14:56:59 -07:00
parent b1cdea67a5
commit 8e7c75986e
6 changed files with 197 additions and 10 deletions

View File

@@ -38,7 +38,6 @@ import com.android.settings.R;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
@@ -184,12 +183,14 @@ class LocaleDragAndDropAdapter
return itemCount;
}
private void onItemMove(int fromPosition, int toPosition) {
void onItemMove(int fromPosition, int toPosition) {
if (fromPosition >= 0 && toPosition >= 0) {
Collections.swap(mFeedItemList, fromPosition, toPosition);
final LocaleStore.LocaleInfo saved = mFeedItemList.get(fromPosition);
mFeedItemList.remove(fromPosition);
mFeedItemList.add(toPosition, saved);
} else {
// TODO: It looks like sometimes the RecycleView tries to swap item -1
// Investigate and file a bug.
// I did not see it in a while, but if it happens, investigate and file a bug.
Log.e(TAG, String.format(Locale.US,
"Negative position in onItemMove %d -> %d", fromPosition, toPosition));
}
@@ -207,6 +208,23 @@ class LocaleDragAndDropAdapter
}
}
boolean isRemoveMode() {
return mRemoveMode;
}
void removeItem(int position) {
int itemCount = mFeedItemList.size();
if (itemCount <= 1) {
return;
}
if (position < 0 || position >= itemCount) {
return;
}
mFeedItemList.remove(position);
notifyDataSetChanged();
doTheUpdate();
}
void removeChecked() {
int itemCount = mFeedItemList.size();
for (int i = itemCount - 1; i >= 0; i--) {