summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsatok <satok@google.com>2011-01-25 06:34:21 -0800
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-01-25 06:34:21 -0800
commitb562792129a547bf124e71be7ca5d556c0aefb55 (patch)
tree88dc4f23b8278adf3bb244b3e32aec5ac436cfd1
parent24a0b71a67ca98fbb94ff6ff321acb155d8a1014 (diff)
parent7dc93a1df7731672b321b78316afff2104dcf239 (diff)
downloadframeworks_base-b562792129a547bf124e71be7ca5d556c0aefb55.zip
frameworks_base-b562792129a547bf124e71be7ca5d556c0aefb55.tar.gz
frameworks_base-b562792129a547bf124e71be7ca5d556c0aefb55.tar.bz2
Merge "Sort IME by id" into honeycomb
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/tablet/InputMethodsPanel.java29
1 files changed, 24 insertions, 5 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/InputMethodsPanel.java b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/InputMethodsPanel.java
index a3ccef9..06c789c 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/InputMethodsPanel.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/InputMethodsPanel.java
@@ -36,9 +36,12 @@ import android.widget.LinearLayout;
import android.widget.RadioButton;
import android.widget.TextView;
+import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import java.util.Set;
+import java.util.TreeMap;
import com.android.systemui.R;
@@ -47,9 +50,10 @@ public class InputMethodsPanel extends LinearLayout implements StatusBarPanel, O
private static final String TAG = "InputMethodsPanel";
private final InputMethodManager mImm;
- private final HashMap<InputMethodInfo, List<InputMethodSubtype>>
+ private final TreeMap<InputMethodInfo, List<InputMethodSubtype>>
mEnabledInputMethodAndSubtypesCache =
- new HashMap<InputMethodInfo, List<InputMethodSubtype>>();
+ new TreeMap<InputMethodInfo, List<InputMethodSubtype>>(
+ new InputMethodComparator());
private final HashMap<View, Pair<InputMethodInfo, InputMethodSubtype>> mRadioViewAndImiMap =
new HashMap<View, Pair<InputMethodInfo, InputMethodSubtype>>();
@@ -61,6 +65,21 @@ public class InputMethodsPanel extends LinearLayout implements StatusBarPanel, O
private String mEnabledInputMethodAndSubtypesCacheStr;
private View mConfigureImeShortcut;
+ private class InputMethodComparator implements Comparator<InputMethodInfo> {
+ public int compare(InputMethodInfo imi1, InputMethodInfo imi2) {
+ if (imi2 == null) return 0;
+ if (imi1 == null) return 1;
+ if (mPackageManager != null) {
+ CharSequence imiId1 = imi1.loadLabel(mPackageManager);
+ CharSequence imiId2 = imi2.loadLabel(mPackageManager);
+ if (imiId1 != null && imiId2 != null) {
+ return imiId1.toString().compareTo(imiId2.toString());
+ }
+ }
+ return imi1.getId().compareTo(imi2.getId());
+ }
+ }
+
public InputMethodsPanel(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
@@ -190,8 +209,8 @@ public class InputMethodsPanel extends LinearLayout implements StatusBarPanel, O
mRadioViewAndImiMap.clear();
mPackageManager = mContext.getPackageManager();
- HashMap<InputMethodInfo, List<InputMethodSubtype>> enabledIMIs
- = getEnabledInputMethodAndSubtypeList();
+ Map<InputMethodInfo, List<InputMethodSubtype>> enabledIMIs =
+ getEnabledInputMethodAndSubtypeList();
// TODO: Sort by alphabet and mode.
Set<InputMethodInfo> cachedImiSet = enabledIMIs.keySet();
for (InputMethodInfo imi: cachedImiSet) {
@@ -278,7 +297,7 @@ public class InputMethodsPanel extends LinearLayout implements StatusBarPanel, O
}
}
- private HashMap<InputMethodInfo, List<InputMethodSubtype>>
+ private TreeMap<InputMethodInfo, List<InputMethodSubtype>>
getEnabledInputMethodAndSubtypeList() {
String newEnabledIMIs = Settings.Secure.getString(
mContext.getContentResolver(), Settings.Secure.ENABLED_INPUT_METHODS);