[Physical Keyboard][A11y Page] Add new Keyboard A11y page

Add new Keyboard A11y page, and controled with flag.
Demo video: b/345399212#comment6

Bug: 345399212
Test: atest SettingsRoboTests
Flag: com.android.settings.keyboard.keyboard_and_touchpad_a11y_new_page_enabled
Change-Id: I4bd45ff16c8abb33e1cf56c377ea86c20195fe26
This commit is contained in:
shaoweishen
2024-08-20 09:25:17 +00:00
parent 9c44e35d02
commit bf4442162d
14 changed files with 920 additions and 4 deletions

View File

@@ -0,0 +1,75 @@
/*
* 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 android.net.Uri;
import android.provider.Settings;
import androidx.annotation.NonNull;
import androidx.lifecycle.LifecycleObserver;
import com.android.settings.R;
public class KeyboardAccessibilityBounceKeysController extends
KeyboardAccessibilityController implements
LifecycleObserver {
public static final int BOUNCE_KEYS_THRESHOLD = 500;
public KeyboardAccessibilityBounceKeysController(@NonNull Context context,
@NonNull String key) {
super(context, key);
}
@Override
public int getAvailabilityStatus() {
return (super.getAvailabilityStatus() == AVAILABLE)
&& InputSettings.isAccessibilityBounceKeysFeatureEnabled() ? AVAILABLE
: UNSUPPORTED_ON_DEVICE;
}
@Override
public boolean isChecked() {
return InputSettings.isAccessibilityBounceKeysEnabled(mContext);
}
@Override
public boolean setChecked(boolean isChecked) {
InputSettings.setAccessibilityBounceKeysThreshold(mContext,
isChecked ? BOUNCE_KEYS_THRESHOLD : 0);
return true;
}
@NonNull
@Override
public CharSequence getSummary() {
return mContext.getString(R.string.bounce_keys_summary, BOUNCE_KEYS_THRESHOLD);
}
@Override
protected void updateKeyboardAccessibilitySettings() {
setChecked(
InputSettings.isAccessibilityBounceKeysEnabled(mContext));
}
@Override
protected Uri getSettingUri() {
return Settings.Secure.getUriFor(
Settings.Secure.ACCESSIBILITY_BOUNCE_KEYS);
}
}