Locale list: format the numbers using the UI locale

The digits used for numbering the drag-and-drop locale list should
use a locale-aware formatter.
We will not see decimal or thousand separators, but the visible
difference is in the use of native digits. Example: Arabic.

Change-Id: I3f8cd5a3adea1cb88ae63f09711c728f4588020c
This commit is contained in:
Mihai Nita
2016-02-02 08:15:03 -08:00
parent 0eb0d9bfe3
commit e7f40be0ef

View File

@@ -32,6 +32,7 @@ import com.android.settings.R;
import com.android.internal.app.LocalePicker;
import com.android.internal.app.LocaleStore;
import java.text.NumberFormat;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
@@ -45,6 +46,7 @@ class LocaleDragAndDropAdapter
private final ItemTouchHelper mItemTouchHelper;
private boolean mRemoveMode = false;
private boolean mDragEnabled = true;
private NumberFormat mNumberFormatter = NumberFormat.getNumberInstance();
class CustomViewHolder extends RecyclerView.ViewHolder implements View.OnTouchListener {
private final LocaleDragCell mLocaleDragCell;
@@ -113,7 +115,7 @@ class LocaleDragAndDropAdapter
String label = feedItem.getFullNameNative();
dragCell.setLabel(label);
dragCell.setLocalized(feedItem.isTranslated());
dragCell.setMiniLabel(Integer.toString(i + 1));
dragCell.setMiniLabel(mNumberFormatter.format(i + 1));
dragCell.setShowCheckbox(mRemoveMode);
dragCell.setShowMiniLabel(!mRemoveMode);
dragCell.setShowHandle(!mRemoveMode);
@@ -195,6 +197,8 @@ class LocaleDragAndDropAdapter
LocaleList ll = new LocaleList(newList);
LocalePicker.updateLocales(ll);
mNumberFormatter = NumberFormat.getNumberInstance(Locale.getDefault());
}
private void setDragEnabled(boolean enabled) {