Merge "[Fixed] UI issues after rotation" into udc-dev am: 28aa2964fb
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/23109896 Change-Id: Icbc09be2306b0a5a6bcc2d55aa7777acd1d8cfb9 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -169,9 +169,11 @@ public class NewKeyboardLayoutEnabledLocalesFragment extends DashboardFragment
|
|||||||
|
|
||||||
private void mapLanguageWithLayout(InputMethodInfo info, InputMethodSubtype subtype) {
|
private void mapLanguageWithLayout(InputMethodInfo info, InputMethodSubtype subtype) {
|
||||||
CharSequence subtypeLabel = getSubtypeLabel(mContext, info, subtype);
|
CharSequence subtypeLabel = getSubtypeLabel(mContext, info, subtype);
|
||||||
KeyboardLayout[] keyboardLayouts = getKeyboardLayouts(info, subtype);
|
KeyboardLayout[] keyboardLayouts =
|
||||||
String layout = getKeyboardLayout(info, subtype);
|
NewKeyboardSettingsUtils.getKeyboardLayouts(
|
||||||
|
mIm, mUserId, mInputDeviceIdentifier, info, subtype);
|
||||||
|
String layout = NewKeyboardSettingsUtils.getKeyboardLayout(
|
||||||
|
mIm, mUserId, mInputDeviceIdentifier, info, subtype);
|
||||||
if (layout != null) {
|
if (layout != null) {
|
||||||
for (int i = 0; i < keyboardLayouts.length; i++) {
|
for (int i = 0; i < keyboardLayouts.length; i++) {
|
||||||
if (keyboardLayouts[i].getDescriptor().equals(layout)) {
|
if (keyboardLayouts[i].getDescriptor().equals(layout)) {
|
||||||
@@ -220,7 +222,6 @@ public class NewKeyboardLayoutEnabledLocalesFragment extends DashboardFragment
|
|||||||
preference -> {
|
preference -> {
|
||||||
showKeyboardLayoutPicker(
|
showKeyboardLayoutPicker(
|
||||||
keyboardInfo.getSubtypeLabel(),
|
keyboardInfo.getSubtypeLabel(),
|
||||||
keyboardInfo.getLayout(),
|
|
||||||
mInputDeviceIdentifier,
|
mInputDeviceIdentifier,
|
||||||
mUserId,
|
mUserId,
|
||||||
keyboardInfo.getInputMethodInfo(),
|
keyboardInfo.getInputMethodInfo(),
|
||||||
@@ -267,7 +268,6 @@ public class NewKeyboardLayoutEnabledLocalesFragment extends DashboardFragment
|
|||||||
|
|
||||||
private void showKeyboardLayoutPicker(
|
private void showKeyboardLayoutPicker(
|
||||||
CharSequence subtypeLabel,
|
CharSequence subtypeLabel,
|
||||||
String layout,
|
|
||||||
InputDeviceIdentifier inputDeviceIdentifier,
|
InputDeviceIdentifier inputDeviceIdentifier,
|
||||||
int userId,
|
int userId,
|
||||||
InputMethodInfo inputMethodInfo,
|
InputMethodInfo inputMethodInfo,
|
||||||
@@ -281,7 +281,6 @@ public class NewKeyboardLayoutEnabledLocalesFragment extends DashboardFragment
|
|||||||
NewKeyboardSettingsUtils.EXTRA_INPUT_METHOD_SUBTYPE, inputMethodSubtype);
|
NewKeyboardSettingsUtils.EXTRA_INPUT_METHOD_SUBTYPE, inputMethodSubtype);
|
||||||
arguments.putInt(NewKeyboardSettingsUtils.EXTRA_USER_ID, userId);
|
arguments.putInt(NewKeyboardSettingsUtils.EXTRA_USER_ID, userId);
|
||||||
arguments.putCharSequence(NewKeyboardSettingsUtils.EXTRA_TITLE, subtypeLabel);
|
arguments.putCharSequence(NewKeyboardSettingsUtils.EXTRA_TITLE, subtypeLabel);
|
||||||
arguments.putString(NewKeyboardSettingsUtils.EXTRA_KEYBOARD_LAYOUT, layout);
|
|
||||||
new SubSettingLauncher(mContext)
|
new SubSettingLauncher(mContext)
|
||||||
.setSourceMetricsCategory(getMetricsCategory())
|
.setSourceMetricsCategory(getMetricsCategory())
|
||||||
.setDestination(NewKeyboardLayoutPickerFragment.class.getName())
|
.setDestination(NewKeyboardLayoutPickerFragment.class.getName())
|
||||||
@@ -289,16 +288,6 @@ public class NewKeyboardLayoutEnabledLocalesFragment extends DashboardFragment
|
|||||||
.launch();
|
.launch();
|
||||||
}
|
}
|
||||||
|
|
||||||
private KeyboardLayout[] getKeyboardLayouts(InputMethodInfo info, InputMethodSubtype subtype) {
|
|
||||||
return mIm.getKeyboardLayoutListForInputDevice(
|
|
||||||
mInputDeviceIdentifier, mUserId, info, subtype);
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getKeyboardLayout(InputMethodInfo info, InputMethodSubtype subtype) {
|
|
||||||
return mIm.getKeyboardLayoutForInputDevice(
|
|
||||||
mInputDeviceIdentifier, mUserId, info, subtype);
|
|
||||||
}
|
|
||||||
|
|
||||||
private CharSequence getSubtypeLabel(
|
private CharSequence getSubtypeLabel(
|
||||||
Context context, InputMethodInfo info, InputMethodSubtype subtype) {
|
Context context, InputMethodInfo info, InputMethodSubtype subtype) {
|
||||||
return subtype.getDisplayName(
|
return subtype.getDisplayName(
|
||||||
|
@@ -20,6 +20,7 @@ import android.app.settings.SettingsEnums;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.hardware.input.InputDeviceIdentifier;
|
import android.hardware.input.InputDeviceIdentifier;
|
||||||
import android.hardware.input.InputManager;
|
import android.hardware.input.InputManager;
|
||||||
|
import android.hardware.input.KeyboardLayout;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.inputmethod.InputMethodInfo;
|
import android.view.inputmethod.InputMethodInfo;
|
||||||
import android.view.inputmethod.InputMethodSubtype;
|
import android.view.inputmethod.InputMethodSubtype;
|
||||||
@@ -31,28 +32,50 @@ public class NewKeyboardLayoutPickerContent extends DashboardFragment {
|
|||||||
|
|
||||||
private static final String TAG = "KeyboardLayoutPicker";
|
private static final String TAG = "KeyboardLayoutPicker";
|
||||||
|
|
||||||
|
private InputManager mIm;
|
||||||
|
private int mUserId;
|
||||||
|
private InputDeviceIdentifier mIdentifier;
|
||||||
|
private InputMethodInfo mInputMethodInfo;
|
||||||
|
private InputMethodSubtype mInputMethodSubtype;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAttach(Context context) {
|
public void onAttach(Context context) {
|
||||||
super.onAttach(context);
|
super.onAttach(context);
|
||||||
InputManager inputManager = getContext().getSystemService(InputManager.class);
|
mIm = getContext().getSystemService(InputManager.class);
|
||||||
Bundle arguments = getArguments();
|
Bundle arguments = getArguments();
|
||||||
final CharSequence title = arguments.getCharSequence(NewKeyboardSettingsUtils.EXTRA_TITLE);
|
final CharSequence title = arguments.getCharSequence(NewKeyboardSettingsUtils.EXTRA_TITLE);
|
||||||
final String layout = arguments.getString(NewKeyboardSettingsUtils.EXTRA_KEYBOARD_LAYOUT);
|
mUserId = arguments.getInt(NewKeyboardSettingsUtils.EXTRA_USER_ID);
|
||||||
final int userId = arguments.getInt(NewKeyboardSettingsUtils.EXTRA_USER_ID);
|
mIdentifier =
|
||||||
final InputDeviceIdentifier identifier =
|
|
||||||
arguments.getParcelable(NewKeyboardSettingsUtils.EXTRA_INPUT_DEVICE_IDENTIFIER);
|
arguments.getParcelable(NewKeyboardSettingsUtils.EXTRA_INPUT_DEVICE_IDENTIFIER);
|
||||||
final InputMethodInfo inputMethodInfo =
|
mInputMethodInfo =
|
||||||
arguments.getParcelable(NewKeyboardSettingsUtils.EXTRA_INPUT_METHOD_INFO);
|
arguments.getParcelable(NewKeyboardSettingsUtils.EXTRA_INPUT_METHOD_INFO);
|
||||||
final InputMethodSubtype inputMethodSubtype =
|
mInputMethodSubtype =
|
||||||
arguments.getParcelable(NewKeyboardSettingsUtils.EXTRA_INPUT_METHOD_SUBTYPE);
|
arguments.getParcelable(NewKeyboardSettingsUtils.EXTRA_INPUT_METHOD_SUBTYPE);
|
||||||
if (identifier == null
|
if (mIdentifier == null
|
||||||
|| NewKeyboardSettingsUtils.getInputDevice(inputManager, identifier) == null) {
|
|| NewKeyboardSettingsUtils.getInputDevice(mIm, mIdentifier) == null) {
|
||||||
getActivity().finish();
|
getActivity().finish();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
getActivity().setTitle(title);
|
getActivity().setTitle(title);
|
||||||
use(NewKeyboardLayoutPickerController.class).initialize(this /*parent*/, userId,
|
use(NewKeyboardLayoutPickerController.class).initialize(this /*parent*/, mUserId,
|
||||||
identifier, inputMethodInfo, inputMethodSubtype, layout);
|
mIdentifier, mInputMethodInfo, mInputMethodSubtype, getSelectedLayoutLabel());
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getSelectedLayoutLabel() {
|
||||||
|
String label = getContext().getString(R.string.keyboard_default_layout);
|
||||||
|
String layout = NewKeyboardSettingsUtils.getKeyboardLayout(
|
||||||
|
mIm, mUserId, mIdentifier, mInputMethodInfo, mInputMethodSubtype);
|
||||||
|
KeyboardLayout[] keyboardLayouts = NewKeyboardSettingsUtils.getKeyboardLayouts(
|
||||||
|
mIm, mUserId, mIdentifier, mInputMethodInfo, mInputMethodSubtype);
|
||||||
|
if (layout != null) {
|
||||||
|
for (int i = 0; i < keyboardLayouts.length; i++) {
|
||||||
|
if (keyboardLayouts[i].getDescriptor().equals(layout)) {
|
||||||
|
label = keyboardLayouts[i].getLabel();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return label;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -19,6 +19,7 @@ package com.android.settings.inputmethod;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.hardware.input.InputDeviceIdentifier;
|
import android.hardware.input.InputDeviceIdentifier;
|
||||||
import android.hardware.input.InputManager;
|
import android.hardware.input.InputManager;
|
||||||
|
import android.hardware.input.KeyboardLayout;
|
||||||
import android.view.InputDevice;
|
import android.view.InputDevice;
|
||||||
import android.view.inputmethod.InputMethodInfo;
|
import android.view.inputmethod.InputMethodInfo;
|
||||||
import android.view.inputmethod.InputMethodManager;
|
import android.view.inputmethod.InputMethodManager;
|
||||||
@@ -39,7 +40,6 @@ public class NewKeyboardSettingsUtils {
|
|||||||
"com.android.settings.inputmethod.EXTRA_INTENT_FROM";
|
"com.android.settings.inputmethod.EXTRA_INTENT_FROM";
|
||||||
|
|
||||||
static final String EXTRA_TITLE = "keyboard_layout_picker_title";
|
static final String EXTRA_TITLE = "keyboard_layout_picker_title";
|
||||||
static final String EXTRA_KEYBOARD_LAYOUT = "keyboard_layout";
|
|
||||||
static final String EXTRA_USER_ID = "user_id";
|
static final String EXTRA_USER_ID = "user_id";
|
||||||
static final String EXTRA_INPUT_DEVICE_IDENTIFIER = "input_device_identifier";
|
static final String EXTRA_INPUT_DEVICE_IDENTIFIER = "input_device_identifier";
|
||||||
static final String EXTRA_INPUT_METHOD_INFO = "input_method_info";
|
static final String EXTRA_INPUT_METHOD_INFO = "input_method_info";
|
||||||
@@ -117,4 +117,14 @@ public class NewKeyboardSettingsUtils {
|
|||||||
static InputDevice getInputDevice(InputManager im, InputDeviceIdentifier identifier) {
|
static InputDevice getInputDevice(InputManager im, InputDeviceIdentifier identifier) {
|
||||||
return im.getInputDeviceByDescriptor(identifier.getDescriptor());
|
return im.getInputDeviceByDescriptor(identifier.getDescriptor());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static KeyboardLayout[] getKeyboardLayouts(InputManager inputManager, int userId,
|
||||||
|
InputDeviceIdentifier identifier, InputMethodInfo info, InputMethodSubtype subtype) {
|
||||||
|
return inputManager.getKeyboardLayoutListForInputDevice(identifier, userId, info, subtype);
|
||||||
|
}
|
||||||
|
|
||||||
|
static String getKeyboardLayout(InputManager inputManager, int userId,
|
||||||
|
InputDeviceIdentifier identifier, InputMethodInfo info, InputMethodSubtype subtype) {
|
||||||
|
return inputManager.getKeyboardLayoutForInputDevice(identifier, userId, info, subtype);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -67,12 +67,14 @@ public final class PhysicalKeyboardFragment extends SettingsPreferenceFragment
|
|||||||
private static final String SHOW_VIRTUAL_KEYBOARD_SWITCH = "show_virtual_keyboard_switch";
|
private static final String SHOW_VIRTUAL_KEYBOARD_SWITCH = "show_virtual_keyboard_switch";
|
||||||
private static final String KEYBOARD_SHORTCUTS_HELPER = "keyboard_shortcuts_helper";
|
private static final String KEYBOARD_SHORTCUTS_HELPER = "keyboard_shortcuts_helper";
|
||||||
private static final String MODIFIER_KEYS_SETTINGS = "modifier_keys_settings";
|
private static final String MODIFIER_KEYS_SETTINGS = "modifier_keys_settings";
|
||||||
|
private static final String EXTRA_AUTO_SELECTION = "auto_selection";
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
private final ArrayList<HardKeyboardDeviceInfo> mLastHardKeyboards = new ArrayList<>();
|
private final ArrayList<HardKeyboardDeviceInfo> mLastHardKeyboards = new ArrayList<>();
|
||||||
|
|
||||||
private InputManager mIm;
|
private InputManager mIm;
|
||||||
private InputMethodManager mImm;
|
private InputMethodManager mImm;
|
||||||
|
private InputDeviceIdentifier mAutoInputDeviceIdentifier;
|
||||||
@NonNull
|
@NonNull
|
||||||
private PreferenceCategory mKeyboardAssistanceCategory;
|
private PreferenceCategory mKeyboardAssistanceCategory;
|
||||||
@NonNull
|
@NonNull
|
||||||
@@ -84,6 +86,12 @@ public final class PhysicalKeyboardFragment extends SettingsPreferenceFragment
|
|||||||
static final String EXTRA_BT_ADDRESS = "extra_bt_address";
|
static final String EXTRA_BT_ADDRESS = "extra_bt_address";
|
||||||
private String mBluetoothAddress;
|
private String mBluetoothAddress;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSaveInstanceState(Bundle outState) {
|
||||||
|
outState.putParcelable(EXTRA_AUTO_SELECTION, mAutoInputDeviceIdentifier);
|
||||||
|
super.onSaveInstanceState(outState);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreatePreferences(Bundle bundle, String s) {
|
public void onCreatePreferences(Bundle bundle, String s) {
|
||||||
Activity activity = Preconditions.checkNotNull(getActivity());
|
Activity activity = Preconditions.checkNotNull(getActivity());
|
||||||
@@ -107,15 +115,19 @@ public final class PhysicalKeyboardFragment extends SettingsPreferenceFragment
|
|||||||
KeyboardLayoutPickerFragment.EXTRA_INPUT_DEVICE_IDENTIFIER);
|
KeyboardLayoutPickerFragment.EXTRA_INPUT_DEVICE_IDENTIFIER);
|
||||||
// TODO (b/271391879): The EXTRA_INTENT_FROM is used for the future metrics.
|
// TODO (b/271391879): The EXTRA_INTENT_FROM is used for the future metrics.
|
||||||
if (inputDeviceIdentifier != null) {
|
if (inputDeviceIdentifier != null) {
|
||||||
Bundle arguments = new Bundle();
|
mAutoInputDeviceIdentifier = inputDeviceIdentifier;
|
||||||
arguments.putParcelable(NewKeyboardSettingsUtils.EXTRA_INPUT_DEVICE_IDENTIFIER,
|
|
||||||
inputDeviceIdentifier);
|
|
||||||
new SubSettingLauncher(getContext())
|
|
||||||
.setSourceMetricsCategory(getMetricsCategory())
|
|
||||||
.setDestination(NewKeyboardLayoutEnabledLocalesFragment.class.getName())
|
|
||||||
.setArguments(arguments)
|
|
||||||
.launch();
|
|
||||||
}
|
}
|
||||||
|
// Don't repeat the autoselection.
|
||||||
|
if (isAutoSelection(bundle, inputDeviceIdentifier)) {
|
||||||
|
showEnabledLocalesKeyboardLayoutList(inputDeviceIdentifier);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean isAutoSelection(Bundle bundle, InputDeviceIdentifier identifier) {
|
||||||
|
if (bundle != null && bundle.getParcelable(EXTRA_AUTO_SELECTION) != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return identifier != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -220,7 +232,6 @@ public final class PhysicalKeyboardFragment extends SettingsPreferenceFragment
|
|||||||
pref.setOnPreferenceClickListener(
|
pref.setOnPreferenceClickListener(
|
||||||
preference -> {
|
preference -> {
|
||||||
showEnabledLocalesKeyboardLayoutList(
|
showEnabledLocalesKeyboardLayoutList(
|
||||||
hardKeyboardDeviceInfo.mDeviceName,
|
|
||||||
hardKeyboardDeviceInfo.mDeviceIdentifier);
|
hardKeyboardDeviceInfo.mDeviceIdentifier);
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
@@ -246,8 +257,7 @@ public final class PhysicalKeyboardFragment extends SettingsPreferenceFragment
|
|||||||
fragment.show(getActivity().getSupportFragmentManager(), "keyboardLayout");
|
fragment.show(getActivity().getSupportFragmentManager(), "keyboardLayout");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showEnabledLocalesKeyboardLayoutList(String keyboardName,
|
private void showEnabledLocalesKeyboardLayoutList(InputDeviceIdentifier inputDeviceIdentifier) {
|
||||||
InputDeviceIdentifier inputDeviceIdentifier) {
|
|
||||||
Bundle arguments = new Bundle();
|
Bundle arguments = new Bundle();
|
||||||
arguments.putParcelable(NewKeyboardSettingsUtils.EXTRA_INPUT_DEVICE_IDENTIFIER,
|
arguments.putParcelable(NewKeyboardSettingsUtils.EXTRA_INPUT_DEVICE_IDENTIFIER,
|
||||||
inputDeviceIdentifier);
|
inputDeviceIdentifier);
|
||||||
|
Reference in New Issue
Block a user