Loading res/values/strings.xml +6 −2 Original line number Diff line number Diff line Loading @@ -4705,9 +4705,13 @@ <!-- Summary for the button to trigger the 'Physical keyboard accessibility' page. [CHAR LIMIT=NONE] --> <string name="keyboard_a11y_settings_summary">Sticky keys, Bounce keys, Mouse keys</string> <!-- Title for the keyboard repeat key option. [CHAR LIMIT=60] --> <string name="keyboard_repeat_key_title">Repeat Keys</string> <string name="keyboard_repeat_keys_title">Repeat Keys</string> <!-- Title for the keyboard repeat key timeout option. [CHAR LIMIT=60] --> <string name="keyboard_repeat_keys_timeout_title">Delay before repeat</string> <!-- Title for the keyboard repeat key delay option. [CHAR LIMIT=60] --> <string name="keyboard_repeat_keys_delay_title">Repeat Rate</string> <!-- Summary for the keyboard repeat key option. [CHAR LIMIT=NONE] --> <string name="keyboard_repeat_key_summary">Hold down a key to repeat its character until the key is released</string> <string name="keyboard_repeat_keys_summary">Hold down a key to repeat its character until the key is released</string> <!-- Title text for per IME subtype keyboard layout. [CHAR LIMIT=35] --> <string name="ime_label_title"><xliff:g id="ime_label" example="Gboard">%s</xliff:g> layout</string> res/xml/physical_keyboard_settings.xml +5 −4 Original line number Diff line number Diff line Loading @@ -33,11 +33,12 @@ android:summary="@string/modifier_keys_settings_summary" android:fragment="com.android.settings.inputmethod.ModifierKeysSettings" /> <SwitchPreferenceCompat android:key="physical_keyboard_repeat_key" android:title="@string/keyboard_repeat_key_title" android:summary="@string/keyboard_repeat_key_summary" <com.android.settingslib.PrimarySwitchPreference android:key="physical_keyboard_repeat_keys" android:title="@string/keyboard_repeat_keys_title" android:summary="@string/keyboard_repeat_keys_summary" android:defaultValue="false" android:fragment="com.android.settings.inputmethod.KeyboardRepeatKeysMainFragment" settings:controller="com.android.settings.inputmethod.KeyboardRepeatKeysController" /> <Preference Loading res/xml/repeat_key_main_page.xml 0 → 100644 +42 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- ~ Copyright 2024 The Android Open Source Project ~ ~ Licensed under the Apache License, Version 2.0 (the "License"); ~ you may not use this file except in compliance with the License. ~ You may obtain a copy of the License at ~ ~ http://www.apache.org/licenses/LICENSE-2.0 ~ ~ Unless required by applicable law or agreed to in writing, software ~ distributed under the License is distributed on an "AS IS" BASIS, ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ~ See the License for the specific language governing permissions and ~ limitations under the License. --> <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" xmlns:settings="http://schemas.android.com/apk/res-auto" android:title="@string/keyboard_repeat_keys_title" android:key="repeat_keys_main_page"> <com.android.settingslib.widget.MainSwitchPreference android:key="repeat_keys_main_switch" android:title="@string/keyboard_repeat_keys_title" settings:controller="com.android.settings.inputmethod.KeyboardRepeatKeysController"/> <com.android.settings.widget.LabeledSeekBarPreference android:key="repeat_keys_timeout_preference" android:title="@string/keyboard_repeat_keys_timeout_title" android:min="0" android:max="6" settings:seekBarIncrement="1" settings:controller= "com.android.settings.inputmethod.KeyboardRepeatKeysTimeOutPreferenceController" /> <com.android.settings.widget.LabeledSeekBarPreference android:key="repeat_keys_delay_preference" android:title="@string/keyboard_repeat_keys_delay_title" android:min="0" android:max="8" settings:seekBarIncrement="1" settings:controller= "com.android.settings.inputmethod.KeyboardRepeatKeysDelayPreferenceController" /> </PreferenceScreen> No newline at end of file src/com/android/settings/inputmethod/KeyboardRepeatKeysController.java +17 −5 Original line number Diff line number Diff line Loading @@ -25,14 +25,20 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.lifecycle.LifecycleObserver; import androidx.preference.PreferenceScreen; import androidx.preference.SwitchPreferenceCompat; import com.android.settingslib.PrimarySwitchPreference; import com.android.settingslib.widget.MainSwitchPreference; public class KeyboardRepeatKeysController extends InputSettingPreferenceController implements LifecycleObserver { private static final String KEY_REPEAT_KEY = "physical_keyboard_repeat_keys"; private static final String KEY_REPEAT_KEY_MAIN_PAGE = "repeat_key_main_switch"; @Nullable private SwitchPreferenceCompat mSwitchPreferenceCompat; private PrimarySwitchPreference mPrimarySwitchPreference; @Nullable private MainSwitchPreference mMainSwitchPreference; public KeyboardRepeatKeysController(@NonNull Context context, @NonNull String key) { Loading @@ -42,7 +48,11 @@ public class KeyboardRepeatKeysController extends @Override public void displayPreference(@NonNull PreferenceScreen screen) { super.displayPreference(screen); mSwitchPreferenceCompat = screen.findPreference(getPreferenceKey()); if (KEY_REPEAT_KEY.equals(getPreferenceKey())) { mPrimarySwitchPreference = screen.findPreference(getPreferenceKey()); } else if (KEY_REPEAT_KEY_MAIN_PAGE.equals(getPreferenceKey())) { mMainSwitchPreference = screen.findPreference(getPreferenceKey()); } } @Override Loading @@ -63,8 +73,10 @@ public class KeyboardRepeatKeysController extends @Override protected void onInputSettingUpdated() { if (mSwitchPreferenceCompat != null) { mSwitchPreferenceCompat.setChecked(InputSettings.isRepeatKeysEnabled(mContext)); if (mPrimarySwitchPreference != null) { mPrimarySwitchPreference.setChecked(InputSettings.isRepeatKeysEnabled(mContext)); } else if (mMainSwitchPreference != null) { mMainSwitchPreference.setChecked(InputSettings.isRepeatKeysEnabled(mContext)); } } Loading src/com/android/settings/inputmethod/KeyboardRepeatKeysDelayPreferenceController.java 0 → 100644 +65 −0 Original line number Diff line number Diff line /* * Copyright 2024 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.settings.inputmethod; import android.content.Context; import android.hardware.input.InputSettings; import androidx.annotation.NonNull; import com.android.internal.annotations.VisibleForTesting; import com.android.settings.core.SliderPreferenceController; import com.google.common.collect.ImmutableList; public class KeyboardRepeatKeysDelayPreferenceController extends SliderPreferenceController { @VisibleForTesting static final ImmutableList<Integer> REPEAT_KEY_DELAY_VALUE_LIST = ImmutableList.of(2000, 1000, 500, 300, 200, 100, 50, 30, 20); public KeyboardRepeatKeysDelayPreferenceController(@NonNull Context context, @NonNull String preferenceKey) { super(context, preferenceKey); } @Override public int getSliderPosition() { return REPEAT_KEY_DELAY_VALUE_LIST.indexOf(InputSettings.getRepeatKeysDelay(mContext)); } @Override public boolean setSliderPosition(int position) { InputSettings.setRepeatKeysDelay(mContext, REPEAT_KEY_DELAY_VALUE_LIST.get(position)); return true; } @Override public int getMax() { return REPEAT_KEY_DELAY_VALUE_LIST.size() - 1; } @Override public int getMin() { return 0; } @Override public int getAvailabilityStatus() { return InputSettings.isRepeatKeysFeatureFlagEnabled() ? AVAILABLE : UNSUPPORTED_ON_DEVICE; } } Loading
res/values/strings.xml +6 −2 Original line number Diff line number Diff line Loading @@ -4705,9 +4705,13 @@ <!-- Summary for the button to trigger the 'Physical keyboard accessibility' page. [CHAR LIMIT=NONE] --> <string name="keyboard_a11y_settings_summary">Sticky keys, Bounce keys, Mouse keys</string> <!-- Title for the keyboard repeat key option. [CHAR LIMIT=60] --> <string name="keyboard_repeat_key_title">Repeat Keys</string> <string name="keyboard_repeat_keys_title">Repeat Keys</string> <!-- Title for the keyboard repeat key timeout option. [CHAR LIMIT=60] --> <string name="keyboard_repeat_keys_timeout_title">Delay before repeat</string> <!-- Title for the keyboard repeat key delay option. [CHAR LIMIT=60] --> <string name="keyboard_repeat_keys_delay_title">Repeat Rate</string> <!-- Summary for the keyboard repeat key option. [CHAR LIMIT=NONE] --> <string name="keyboard_repeat_key_summary">Hold down a key to repeat its character until the key is released</string> <string name="keyboard_repeat_keys_summary">Hold down a key to repeat its character until the key is released</string> <!-- Title text for per IME subtype keyboard layout. [CHAR LIMIT=35] --> <string name="ime_label_title"><xliff:g id="ime_label" example="Gboard">%s</xliff:g> layout</string>
res/xml/physical_keyboard_settings.xml +5 −4 Original line number Diff line number Diff line Loading @@ -33,11 +33,12 @@ android:summary="@string/modifier_keys_settings_summary" android:fragment="com.android.settings.inputmethod.ModifierKeysSettings" /> <SwitchPreferenceCompat android:key="physical_keyboard_repeat_key" android:title="@string/keyboard_repeat_key_title" android:summary="@string/keyboard_repeat_key_summary" <com.android.settingslib.PrimarySwitchPreference android:key="physical_keyboard_repeat_keys" android:title="@string/keyboard_repeat_keys_title" android:summary="@string/keyboard_repeat_keys_summary" android:defaultValue="false" android:fragment="com.android.settings.inputmethod.KeyboardRepeatKeysMainFragment" settings:controller="com.android.settings.inputmethod.KeyboardRepeatKeysController" /> <Preference Loading
res/xml/repeat_key_main_page.xml 0 → 100644 +42 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- ~ Copyright 2024 The Android Open Source Project ~ ~ Licensed under the Apache License, Version 2.0 (the "License"); ~ you may not use this file except in compliance with the License. ~ You may obtain a copy of the License at ~ ~ http://www.apache.org/licenses/LICENSE-2.0 ~ ~ Unless required by applicable law or agreed to in writing, software ~ distributed under the License is distributed on an "AS IS" BASIS, ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ~ See the License for the specific language governing permissions and ~ limitations under the License. --> <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" xmlns:settings="http://schemas.android.com/apk/res-auto" android:title="@string/keyboard_repeat_keys_title" android:key="repeat_keys_main_page"> <com.android.settingslib.widget.MainSwitchPreference android:key="repeat_keys_main_switch" android:title="@string/keyboard_repeat_keys_title" settings:controller="com.android.settings.inputmethod.KeyboardRepeatKeysController"/> <com.android.settings.widget.LabeledSeekBarPreference android:key="repeat_keys_timeout_preference" android:title="@string/keyboard_repeat_keys_timeout_title" android:min="0" android:max="6" settings:seekBarIncrement="1" settings:controller= "com.android.settings.inputmethod.KeyboardRepeatKeysTimeOutPreferenceController" /> <com.android.settings.widget.LabeledSeekBarPreference android:key="repeat_keys_delay_preference" android:title="@string/keyboard_repeat_keys_delay_title" android:min="0" android:max="8" settings:seekBarIncrement="1" settings:controller= "com.android.settings.inputmethod.KeyboardRepeatKeysDelayPreferenceController" /> </PreferenceScreen> No newline at end of file
src/com/android/settings/inputmethod/KeyboardRepeatKeysController.java +17 −5 Original line number Diff line number Diff line Loading @@ -25,14 +25,20 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.lifecycle.LifecycleObserver; import androidx.preference.PreferenceScreen; import androidx.preference.SwitchPreferenceCompat; import com.android.settingslib.PrimarySwitchPreference; import com.android.settingslib.widget.MainSwitchPreference; public class KeyboardRepeatKeysController extends InputSettingPreferenceController implements LifecycleObserver { private static final String KEY_REPEAT_KEY = "physical_keyboard_repeat_keys"; private static final String KEY_REPEAT_KEY_MAIN_PAGE = "repeat_key_main_switch"; @Nullable private SwitchPreferenceCompat mSwitchPreferenceCompat; private PrimarySwitchPreference mPrimarySwitchPreference; @Nullable private MainSwitchPreference mMainSwitchPreference; public KeyboardRepeatKeysController(@NonNull Context context, @NonNull String key) { Loading @@ -42,7 +48,11 @@ public class KeyboardRepeatKeysController extends @Override public void displayPreference(@NonNull PreferenceScreen screen) { super.displayPreference(screen); mSwitchPreferenceCompat = screen.findPreference(getPreferenceKey()); if (KEY_REPEAT_KEY.equals(getPreferenceKey())) { mPrimarySwitchPreference = screen.findPreference(getPreferenceKey()); } else if (KEY_REPEAT_KEY_MAIN_PAGE.equals(getPreferenceKey())) { mMainSwitchPreference = screen.findPreference(getPreferenceKey()); } } @Override Loading @@ -63,8 +73,10 @@ public class KeyboardRepeatKeysController extends @Override protected void onInputSettingUpdated() { if (mSwitchPreferenceCompat != null) { mSwitchPreferenceCompat.setChecked(InputSettings.isRepeatKeysEnabled(mContext)); if (mPrimarySwitchPreference != null) { mPrimarySwitchPreference.setChecked(InputSettings.isRepeatKeysEnabled(mContext)); } else if (mMainSwitchPreference != null) { mMainSwitchPreference.setChecked(InputSettings.isRepeatKeysEnabled(mContext)); } } Loading
src/com/android/settings/inputmethod/KeyboardRepeatKeysDelayPreferenceController.java 0 → 100644 +65 −0 Original line number Diff line number Diff line /* * Copyright 2024 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.settings.inputmethod; import android.content.Context; import android.hardware.input.InputSettings; import androidx.annotation.NonNull; import com.android.internal.annotations.VisibleForTesting; import com.android.settings.core.SliderPreferenceController; import com.google.common.collect.ImmutableList; public class KeyboardRepeatKeysDelayPreferenceController extends SliderPreferenceController { @VisibleForTesting static final ImmutableList<Integer> REPEAT_KEY_DELAY_VALUE_LIST = ImmutableList.of(2000, 1000, 500, 300, 200, 100, 50, 30, 20); public KeyboardRepeatKeysDelayPreferenceController(@NonNull Context context, @NonNull String preferenceKey) { super(context, preferenceKey); } @Override public int getSliderPosition() { return REPEAT_KEY_DELAY_VALUE_LIST.indexOf(InputSettings.getRepeatKeysDelay(mContext)); } @Override public boolean setSliderPosition(int position) { InputSettings.setRepeatKeysDelay(mContext, REPEAT_KEY_DELAY_VALUE_LIST.get(position)); return true; } @Override public int getMax() { return REPEAT_KEY_DELAY_VALUE_LIST.size() - 1; } @Override public int getMin() { return 0; } @Override public int getAvailabilityStatus() { return InputSettings.isRepeatKeysFeatureFlagEnabled() ? AVAILABLE : UNSUPPORTED_ON_DEVICE; } }