Skip to content
Commit fbc5547e authored by Yohei Yukawa's avatar Yohei Yukawa
Browse files

Remove dependency on TreeMap from getSortedInputMethodAndSubtypeList()

InputMethodAndSubtypeList#getSortedInputMethodAndSubtypeList()
currently sorts ImeSubtypeListItem as follows:

 1. Create a sorted list of IMEs by TreeMap with the sorting key
      imi.loadLabel(mPm) + "/" + imi.getId()
 2. Generate list of ImeSubtypeListItem objects.
 3. Do stable sort ImeSubtypeListItem lists with the following order
      mImeName
      mIsSystemLocale
      mIsSystemLanguage
      mSubtypeName
 4. Return the sorted ImeSubtypeListItem list.

Since in the step 2 everything is done sequentially and the result for
each IME will not be affected by other IMEs, we can in theory unify
the step 1 into the step 3 so that we can perform sorting only once.

In order to avoid unnecessary behavior change in this CL, with this CL
the step 1 will be removed and the sorting order in the step 3 will be
updated as follows:
      mImeName
      mIsSystemLocale
      mIsSystemLanguage
      mSubtypeName
      mImi.getId()

This should be sufficient to preserve the current behavior because:
  a) if two ImeSubtypeListItem items were not classified as the same
     in the step 3, the step 1 basically did not matter and,
  b) if two ImeSubtypeListItem items were classified as the same in
     the step 3, those two items would have preserved the sort order
     in the step 1.  Here mImeName == imi.loadLabel(mPm) so if this
     is the case only mImi.getId() matters in this scenario.

Therefore this CL should not have any user-visible behavior change.

Fix: 64612471
Test: atest InputMethodSubtypeSwitchingControllerTest
Change-Id: I4204275f1fc2040d98b9c55a38ab8b8d50e65126
parent 7e06f2be
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment