Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6061af11 authored by Kenny Root's avatar Kenny Root Committed by Android Code Review
Browse files

Merge "Sort the IME list before showing to user"

parents 0f0dd448 cf06e2cf
Loading
Loading
Loading
Loading
+13 −9
Original line number Diff line number Diff line
@@ -78,9 +78,12 @@ import android.view.inputmethod.EditorInfo;
import java.io.FileDescriptor;
import java.io.IOException;
import java.io.PrintWriter;
import java.text.Collator;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;

/**
 * This class provides a system service that manages input methods.
@@ -1514,20 +1517,21 @@ public class InputMethodManagerService extends IInputMethodManager.Stub

            int N = immis.size();

            mItems = new CharSequence[N];
            mIms = new InputMethodInfo[N];
            final Map<CharSequence, InputMethodInfo> imMap =
                new TreeMap<CharSequence, InputMethodInfo>(Collator.getInstance());

            int j = 0;
            for (int i = 0; i < N; ++i) {
                InputMethodInfo property = immis.get(i);
                if (property == null) {
                    continue;
                }
                mItems[j] = property.loadLabel(pm);
                mIms[j] = property;
                j++;
                imMap.put(property.loadLabel(pm), property);
            }

            N = imMap.size();
            mItems = imMap.keySet().toArray(new CharSequence[N]);
            mIms = imMap.values().toArray(new InputMethodInfo[N]);

            int checkedItem = 0;
            for (int i = 0; i < N; ++i) {
                if (mIms[i].getId().equals(lastInputMethodId)) {