[Physical Keyboard] Add slow keys dialog
demo: https://screenshot.googleplex.com/7CPpfHvAixe9Awr.png Add dialog for Slow keys, which have same set up with Bounce keys. Move dialog logic to InputSettingPreferenceController, to reuse it from slow keys controller. Bug: 346949547 Test: atest SettingsRoboTests Flag: com.android.settings.keyboard.keyboard_and_touchpad_a11y_new_page_enabled Change-Id: Ia4d74fcf3f20ed68cb252503e88d99ea79eae291
This commit is contained in:
committed by
Shaowei Shen
parent
9936dae2be
commit
7aefcf71b6
@@ -20,27 +20,34 @@ import android.content.Context;
|
||||
import android.hardware.input.InputSettings;
|
||||
import android.net.Uri;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.lifecycle.LifecycleObserver;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
import androidx.preference.TwoStatePreference;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settingslib.PrimarySwitchPreference;
|
||||
|
||||
public class KeyboardAccessibilitySlowKeysController extends
|
||||
InputSettingPreferenceController implements
|
||||
LifecycleObserver {
|
||||
public static final int SLOW_KEYS_THRESHOLD = 500;
|
||||
|
||||
private TwoStatePreference mTwoStatePreference;
|
||||
@Nullable
|
||||
private PrimarySwitchPreference mPrimarySwitchPreference;
|
||||
|
||||
public KeyboardAccessibilitySlowKeysController(@NonNull Context context, @NonNull String key) {
|
||||
super(context, key);
|
||||
constructDialog(context, R.string.slow_keys, R.string.slow_keys_summary);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void displayPreference(@NonNull PreferenceScreen screen) {
|
||||
super.displayPreference(screen);
|
||||
mTwoStatePreference = screen.findPreference(getPreferenceKey());
|
||||
mPrimarySwitchPreference = screen.findPreference(getPreferenceKey());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -50,8 +57,7 @@ public class KeyboardAccessibilitySlowKeysController extends
|
||||
|
||||
@Override
|
||||
public boolean setChecked(boolean isChecked) {
|
||||
InputSettings.setAccessibilitySlowKeysThreshold(mContext,
|
||||
isChecked ? SLOW_KEYS_THRESHOLD : 0);
|
||||
updateInputSettingKeysValue(isChecked ? SLOW_KEYS_THRESHOLD : 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -64,8 +70,8 @@ public class KeyboardAccessibilitySlowKeysController extends
|
||||
|
||||
@Override
|
||||
protected void onInputSettingUpdated() {
|
||||
if (mTwoStatePreference != null) {
|
||||
mTwoStatePreference.setChecked(
|
||||
if (mPrimarySwitchPreference != null) {
|
||||
mPrimarySwitchPreference.setChecked(
|
||||
InputSettings.isAccessibilitySlowKeysEnabled(mContext));
|
||||
}
|
||||
}
|
||||
@@ -75,4 +81,25 @@ public class KeyboardAccessibilitySlowKeysController extends
|
||||
return Settings.Secure.getUriFor(
|
||||
Settings.Secure.ACCESSIBILITY_SLOW_KEYS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handlePreferenceTreeClick(@NonNull Preference preference) {
|
||||
if (!TextUtils.equals(preference.getKey(), getPreferenceKey())) {
|
||||
return false;
|
||||
}
|
||||
if (mAlertDialog != null) {
|
||||
mAlertDialog.show();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateInputSettingKeysValue(int thresholdTimeMillis) {
|
||||
InputSettings.setAccessibilitySlowKeysThreshold(mContext, thresholdTimeMillis);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getInputSettingKeysValue() {
|
||||
return InputSettings.getAccessibilitySlowKeysThreshold(mContext);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user