From 6d2a0b6424600b6105367bab93ea33a2a5f1e2bf Mon Sep 17 00:00:00 2001 From: Abodunrinwa Toki Date: Thu, 30 Jun 2016 15:01:59 +0100 Subject: [PATCH] Fix order of items in language menu. Bug: 29571417 Change-Id: I682925afe7fe07f6300197e0b4064525f0799b4f --- .../InputMethodSubtypePreference.java | 39 +++++++++---------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/src/com/android/settings/inputmethod/InputMethodSubtypePreference.java b/src/com/android/settings/inputmethod/InputMethodSubtypePreference.java index 600542a6cb5..678b2d96aa5 100644 --- a/src/com/android/settings/inputmethod/InputMethodSubtypePreference.java +++ b/src/com/android/settings/inputmethod/InputMethodSubtypePreference.java @@ -62,31 +62,28 @@ class InputMethodSubtypePreference extends SwitchWithNoTextPreference { return 0; } if (rhs instanceof InputMethodSubtypePreference) { - final InputMethodSubtypePreference pref = (InputMethodSubtypePreference) rhs; + final InputMethodSubtypePreference rhsPref = (InputMethodSubtypePreference) rhs; + if (mIsSystemLocale && !rhsPref.mIsSystemLocale) { + return -1; + } + if (!mIsSystemLocale && rhsPref.mIsSystemLocale) { + return 1; + } + if (mIsSystemLanguage && !rhsPref.mIsSystemLanguage) { + return -1; + } + if (!mIsSystemLanguage && rhsPref.mIsSystemLanguage) { + return 1; + } final CharSequence t0 = getTitle(); final CharSequence t1 = rhs.getTitle(); - if (TextUtils.equals(t0, t1)) { - return 0; + if (t0 == null && t1 == null) { + return Integer.compare(hashCode(), rhs.hashCode()); } - if (mIsSystemLocale) { - return -1; + if (t0 != null && t1 != null) { + return collator.compare(t0.toString(), t1.toString()); } - if (pref.mIsSystemLocale) { - return 1; - } - if (mIsSystemLanguage) { - return -1; - } - if (pref.mIsSystemLanguage) { - return 1; - } - if (TextUtils.isEmpty(t0)) { - return 1; - } - if (TextUtils.isEmpty(t1)) { - return -1; - } - return collator.compare(t0.toString(), t1.toString()); + return t0 == null ? -1 : 1; } return super.compareTo(rhs); }