Merge change 1418 into donut
* changes: Show locale names in alphabetical order, in their own language.
This commit is contained in:
@@ -30,6 +30,7 @@ import android.widget.ListView;
|
|||||||
|
|
||||||
import java.io.BufferedWriter;
|
import java.io.BufferedWriter;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
|
import java.text.Collator;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
@@ -38,7 +39,9 @@ public class LocalePicker extends ListActivity {
|
|||||||
|
|
||||||
Loc[] mLocales;
|
Loc[] mLocales;
|
||||||
|
|
||||||
private static class Loc {
|
private static class Loc implements Comparable {
|
||||||
|
static Collator sCollator = Collator.getInstance();
|
||||||
|
|
||||||
String label;
|
String label;
|
||||||
Locale locale;
|
Locale locale;
|
||||||
|
|
||||||
@@ -51,6 +54,10 @@ public class LocalePicker extends ListActivity {
|
|||||||
public String toString() {
|
public String toString() {
|
||||||
return this.label;
|
return this.label;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int compareTo(Object o) {
|
||||||
|
return sCollator.compare(this.label, ((Loc) o).label);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int getContentView() {
|
int getContentView() {
|
||||||
@@ -78,9 +85,9 @@ public class LocalePicker extends ListActivity {
|
|||||||
|
|
||||||
if (finalSize == 0) {
|
if (finalSize == 0) {
|
||||||
Log.v(TAG, "adding initial "+
|
Log.v(TAG, "adding initial "+
|
||||||
toTitleCase(l.getDisplayLanguage()));
|
toTitleCase(l.getDisplayLanguage(l)));
|
||||||
preprocess[finalSize++] =
|
preprocess[finalSize++] =
|
||||||
new Loc(toTitleCase(l.getDisplayLanguage()), l);
|
new Loc(toTitleCase(l.getDisplayLanguage(l)), l);
|
||||||
} else {
|
} else {
|
||||||
// check previous entry:
|
// check previous entry:
|
||||||
// same lang and a country -> upgrade to full name and
|
// same lang and a country -> upgrade to full name and
|
||||||
@@ -91,20 +98,20 @@ public class LocalePicker extends ListActivity {
|
|||||||
Log.v(TAG, "backing up and fixing "+
|
Log.v(TAG, "backing up and fixing "+
|
||||||
preprocess[finalSize-1].label+" to "+
|
preprocess[finalSize-1].label+" to "+
|
||||||
preprocess[finalSize-1].locale.
|
preprocess[finalSize-1].locale.
|
||||||
getDisplayName());
|
getDisplayName(l));
|
||||||
preprocess[finalSize-1].label = toTitleCase(
|
preprocess[finalSize-1].label = toTitleCase(
|
||||||
preprocess[finalSize-1].
|
preprocess[finalSize-1].
|
||||||
locale.getDisplayName());
|
locale.getDisplayName(l));
|
||||||
Log.v(TAG, " and adding "+
|
Log.v(TAG, " and adding "+
|
||||||
toTitleCase(l.getDisplayName()));
|
toTitleCase(l.getDisplayName(l)));
|
||||||
preprocess[finalSize++] =
|
preprocess[finalSize++] =
|
||||||
new Loc(toTitleCase(l.getDisplayName()), l);
|
new Loc(toTitleCase(l.getDisplayName(l)), l);
|
||||||
} else {
|
} else {
|
||||||
String displayName;
|
String displayName;
|
||||||
if (s.equals("zz_ZZ")) {
|
if (s.equals("zz_ZZ")) {
|
||||||
displayName = "Pseudo...";
|
displayName = "Pseudo...";
|
||||||
} else {
|
} else {
|
||||||
displayName = toTitleCase(l.getDisplayLanguage());
|
displayName = toTitleCase(l.getDisplayLanguage(l));
|
||||||
}
|
}
|
||||||
Log.v(TAG, "adding "+displayName);
|
Log.v(TAG, "adding "+displayName);
|
||||||
preprocess[finalSize++] = new Loc(displayName, l);
|
preprocess[finalSize++] = new Loc(displayName, l);
|
||||||
@@ -116,6 +123,7 @@ public class LocalePicker extends ListActivity {
|
|||||||
for (int i = 0; i < finalSize ; i++) {
|
for (int i = 0; i < finalSize ; i++) {
|
||||||
mLocales[i] = preprocess[i];
|
mLocales[i] = preprocess[i];
|
||||||
}
|
}
|
||||||
|
Arrays.sort(mLocales);
|
||||||
int layoutId = R.layout.locale_picker_item;
|
int layoutId = R.layout.locale_picker_item;
|
||||||
int fieldId = R.id.locale;
|
int fieldId = R.id.locale;
|
||||||
ArrayAdapter<Loc> adapter =
|
ArrayAdapter<Loc> adapter =
|
||||||
|
Reference in New Issue
Block a user