Merge "Sort keyboard layouts" into main

This commit is contained in:
Josep del Río
2023-12-05 12:53:20 +00:00
committed by Android (Google) Code Review
2 changed files with 10 additions and 0 deletions

View File

@@ -83,6 +83,7 @@ public class NewKeyboardLayoutPickerController extends BasePreferenceController
mFinalSelectedLayout = mLayout; mFinalSelectedLayout = mLayout;
mKeyboardLayouts = mIm.getKeyboardLayoutListForInputDevice( mKeyboardLayouts = mIm.getKeyboardLayoutListForInputDevice(
mInputDeviceIdentifier, mUserId, mInputMethodInfo, mInputMethodSubtype); mInputDeviceIdentifier, mUserId, mInputMethodInfo, mInputMethodSubtype);
NewKeyboardSettingsUtils.sortKeyboardLayoutsByLabel(mKeyboardLayouts);
parent.getActivity().setTitle(mTitle); parent.getActivity().setTitle(mTitle);
} }

View File

@@ -27,6 +27,8 @@ import android.view.inputmethod.InputMethodManager;
import android.view.inputmethod.InputMethodSubtype; import android.view.inputmethod.InputMethodSubtype;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List; import java.util.List;
/** /**
@@ -123,4 +125,11 @@ public class NewKeyboardSettingsUtils {
InputDeviceIdentifier identifier, InputMethodInfo info, InputMethodSubtype subtype) { InputDeviceIdentifier identifier, InputMethodInfo info, InputMethodSubtype subtype) {
return inputManager.getKeyboardLayoutForInputDevice(identifier, userId, info, subtype); return inputManager.getKeyboardLayoutForInputDevice(identifier, userId, info, subtype);
} }
static void sortKeyboardLayoutsByLabel(KeyboardLayout[] keyboardLayouts) {
Arrays.sort(
keyboardLayouts,
Comparator.comparing(KeyboardLayout::getLabel)
);
}
} }