Files
app_Settings/src/com/android/settings/inputmethod/KeyboardAccessibilityMouseKeysController.java
shaoweishen f0a01c51dd [Physical Keyboard][A11y Page] Add Bounce keys dialog
1.Add dialog for adjust bounce key to different values.
demo video: b/346949547#comment24.
2.Update summary text.
3.When receive update from content uri, update toggle state directly.
4.Rename Controller to more suitable name.

Bug: 346949547
Test: atest SettingsRoboTests
Flag: com.android.settings.keyboard.keyboard_and_touchpad_a11y_new_page_enabled
Change-Id: I94d8d1a77528b13f59b2d67dfa30e17dd177e385
2024-10-08 03:13:40 +00:00

78 lines
2.4 KiB
Java

/*
* 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 androidx.preference.PreferenceScreen;
import androidx.preference.TwoStatePreference;
public class KeyboardAccessibilityMouseKeysController extends
InputSettingPreferenceController implements
LifecycleObserver {
private TwoStatePreference mTwoStatePreference;
public KeyboardAccessibilityMouseKeysController(@NonNull Context context, @NonNull String key) {
super(context, key);
}
@Override
public void displayPreference(@NonNull PreferenceScreen screen) {
super.displayPreference(screen);
mTwoStatePreference = screen.findPreference(getPreferenceKey());
}
@Override
public boolean isChecked() {
return InputSettings.isAccessibilityMouseKeysEnabled(mContext);
}
@Override
public boolean setChecked(boolean isChecked) {
InputSettings.setAccessibilityMouseKeysEnabled(mContext,
isChecked);
return true;
}
@Override
public int getAvailabilityStatus() {
return (super.getAvailabilityStatus() == AVAILABLE)
&& InputSettings.isAccessibilityMouseKeysFeatureFlagEnabled() ? AVAILABLE
: UNSUPPORTED_ON_DEVICE;
}
@Override
protected void onInputSettingUpdated() {
if (mTwoStatePreference != null) {
mTwoStatePreference.setChecked(
InputSettings.isAccessibilityMouseKeysEnabled(mContext));
}
}
@Override
protected Uri getSettingUri() {
return Settings.Secure.getUriFor(
Settings.Secure.ACCESSIBILITY_MOUSE_KEYS_ENABLED);
}
}