Merge "[Physical Keyboard] Add intent support for PK layout setting page" into main
This commit is contained in:
@@ -135,6 +135,7 @@ android_library {
|
||||
"android.app.flags-aconfig",
|
||||
"android.provider.flags-aconfig",
|
||||
"android.security.flags-aconfig",
|
||||
"keyboard_flags",
|
||||
],
|
||||
}
|
||||
|
||||
|
@@ -1230,6 +1230,21 @@
|
||||
android:value="@string/menu_key_system"/>
|
||||
</activity>
|
||||
|
||||
<activity android:name="Settings$PhysicalKeyboardLayoutPickerActivity"
|
||||
android:label="@string/physical_keyboard_layout_picker_title"
|
||||
android:exported="true"
|
||||
android:clearTaskOnLaunch="true"
|
||||
android:featureFlag="com.android.settings.keyboard.keyboard_and_touchpad_a11y_new_page_enabled">
|
||||
<intent-filter android:priority="1">
|
||||
<action android:name="android.settings.HARD_KEYBOARD_LAYOUT_PICKER_SETTINGS" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
|
||||
android:value="com.android.settings.inputmethod.NewKeyboardLayoutEnabledLocalesFragment" />
|
||||
<meta-data android:name="com.android.settings.HIGHLIGHT_MENU_KEY"
|
||||
android:value="@string/menu_key_system"/>
|
||||
</activity>
|
||||
|
||||
<!-- Keep compatibility with old shortcuts. -->
|
||||
<activity-alias android:name="LanguageSettings"
|
||||
android:label="@string/language_input_gesture_title"
|
||||
|
@@ -4561,6 +4561,8 @@
|
||||
<string name="keyboard_a11y_category">Accessibility</string>
|
||||
<!-- Title for the 'physical keyboard' settings screen. [CHAR LIMIT=35] -->
|
||||
<string name="physical_keyboard_title">Physical keyboard</string>
|
||||
<!-- Title for the 'physical keyboard' settings screen. [CHAR LIMIT=35] -->
|
||||
<string name="physical_keyboard_layout_picker_title">Physical keyboard layout picker</string>
|
||||
<!-- Title for the 'Bounce keys' preference switch. [CHAR LIMIT=35] -->
|
||||
<string name="bounce_keys">Bounce keys</string>
|
||||
<!-- Summary text for the 'Bounce keys' preference sub-screen. [CHAR LIMIT=300] -->
|
||||
|
@@ -92,6 +92,9 @@ public class Settings extends SettingsActivity {
|
||||
public static class AvailableVirtualKeyboardActivity extends SettingsActivity { /* empty */ }
|
||||
public static class KeyboardLayoutPickerActivity extends SettingsActivity { /* empty */ }
|
||||
public static class PhysicalKeyboardActivity extends SettingsActivity { /* empty */ }
|
||||
public static class PhysicalKeyboardLayoutPickerActivity extends SettingsActivity {
|
||||
/* empty */
|
||||
}
|
||||
public static class InputMethodAndSubtypeEnablerActivity extends SettingsActivity { /* empty */ }
|
||||
public static class SpellCheckersSettingsActivity extends SettingsActivity { /* empty */ }
|
||||
public static class LocalePickerActivity extends SettingsActivity { /* empty */ }
|
||||
|
@@ -51,6 +51,7 @@ public class InputPeripheralsSettingsUtils {
|
||||
static final String EXTRA_TITLE = "keyboard_layout_picker_title";
|
||||
static final String EXTRA_USER_ID = "user_id";
|
||||
static final String EXTRA_INPUT_DEVICE_IDENTIFIER = "input_device_identifier";
|
||||
static final String EXTRA_INPUT_DEVICE = "input_device";
|
||||
static final String EXTRA_INPUT_METHOD_INFO = "input_method_info";
|
||||
static final String EXTRA_INPUT_METHOD_SUBTYPE = "input_method_subtype";
|
||||
|
||||
|
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.android.settings.inputmethod;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
import android.hardware.input.InputDeviceIdentifier;
|
||||
@@ -35,6 +36,7 @@ import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceCategory;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.internal.util.Preconditions;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.core.SubSettingLauncher;
|
||||
@@ -106,6 +108,16 @@ public class NewKeyboardLayoutEnabledLocalesFragment extends DashboardFragment
|
||||
mIm = mContext.getSystemService(InputManager.class);
|
||||
mImm = mContext.getSystemService(InputMethodManager.class);
|
||||
mInputDeviceId = -1;
|
||||
|
||||
Activity activity = Preconditions.checkNotNull(getActivity());
|
||||
InputDevice inputDeviceFromIntent =
|
||||
activity.getIntent().getParcelableExtra(
|
||||
InputPeripheralsSettingsUtils.EXTRA_INPUT_DEVICE,
|
||||
InputDevice.class);
|
||||
|
||||
if (inputDeviceFromIntent != null) {
|
||||
launchLayoutPickerWithIdentifier(inputDeviceFromIntent.getIdentifier());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -161,6 +173,23 @@ public class NewKeyboardLayoutEnabledLocalesFragment extends DashboardFragment
|
||||
mInputDeviceId = -1;
|
||||
}
|
||||
|
||||
private void launchLayoutPickerWithIdentifier(
|
||||
InputDeviceIdentifier inputDeviceIdentifier) {
|
||||
if (InputPeripheralsSettingsUtils.getInputDevice(mIm, inputDeviceIdentifier) == null) {
|
||||
return;
|
||||
}
|
||||
InputMethodInfo info = mImm.getCurrentInputMethodInfoAsUser(UserHandle.of(mUserId));
|
||||
InputMethodSubtype subtype = mImm.getCurrentInputMethodSubtype();
|
||||
CharSequence subtypeLabel = getSubtypeLabel(mContext, info, subtype);
|
||||
|
||||
showKeyboardLayoutPicker(
|
||||
subtypeLabel,
|
||||
inputDeviceIdentifier,
|
||||
mUserId,
|
||||
info,
|
||||
subtype);
|
||||
}
|
||||
|
||||
private void updateCheckedState() {
|
||||
if (InputPeripheralsSettingsUtils.getInputDevice(mIm, mInputDeviceIdentifier) == null) {
|
||||
return;
|
||||
|
Reference in New Issue
Block a user