[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:
@@ -4615,6 +4615,11 @@
|
||||
<!-- Summary for the modifier key picker dialog page [CHAR LIMIT=35] -->
|
||||
<string name="modifier_keys_picker_summary">Choose a new key for <xliff:g id="modifier_key_default_name">%1$s</xliff:g>:</string>
|
||||
|
||||
<!-- Title for the button to trigger the 'Physical keyboard accessibility' page. [CHAR LIMIT=60] -->
|
||||
<string name="keyboard_a11y_settings">Physical keyboard accessibility</string>
|
||||
<!-- 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 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>
|
||||
<!-- Summary text for keyboards when no layout has been selected. [CHAR LIMIT=35] -->
|
||||
|
57
res/xml/physical_keyboard_a11y_settings.xml
Normal file
57
res/xml/physical_keyboard_a11y_settings.xml
Normal file
@@ -0,0 +1,57 @@
|
||||
<?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_a11y_settings"
|
||||
android:key="physical_keyboard_a11y">
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="keyboard_a11y_category"
|
||||
android:title="@string/keyboard_a11y_category">
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:key="accessibility_sticky_keys"
|
||||
android:title="@string/sticky_keys"
|
||||
android:summary="@string/sticky_keys_summary"
|
||||
android:defaultValue="false"
|
||||
settings:controller="com.android.settings.inputmethod.KeyboardAccessibilityStickyKeysController"/>
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:key="accessibility_bounce_keys"
|
||||
android:title="@string/bounce_keys"
|
||||
android:defaultValue="false"
|
||||
settings:controller="com.android.settings.inputmethod.KeyboardAccessibilityBounceKeysController"/>
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:key="accessibility_slow_keys"
|
||||
android:title="@string/slow_keys"
|
||||
android:defaultValue="false"
|
||||
settings:controller="com.android.settings.inputmethod.KeyboardAccessibilitySlowKeysController" />
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:key="accessibility_mouse_keys"
|
||||
android:title="@string/mouse_keys"
|
||||
android:summary="@string/mouse_keys_summary"
|
||||
android:defaultValue="false"
|
||||
settings:controller="com.android.settings.inputmethod.KeyboardAccessibilityMouseKeysController" />
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
|
||||
</PreferenceScreen>
|
@@ -31,6 +31,11 @@
|
||||
android:title="@string/modifier_keys_settings"
|
||||
android:summary="@string/modifier_keys_settings_summary"
|
||||
android:fragment="com.android.settings.inputmethod.ModifierKeysSettings" />
|
||||
<Preference
|
||||
android:key="physical_keyboard_a11y"
|
||||
android:title="@string/keyboard_a11y_settings"
|
||||
android:summary="@string/keyboard_a11y_settings_summary"
|
||||
android:fragment="com.android.settings.inputmethod.PhysicalKeyboardA11yFragment" />
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
* 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 static androidx.lifecycle.Lifecycle.Event.ON_PAUSE;
|
||||
import static androidx.lifecycle.Lifecycle.Event.ON_RESUME;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.database.ContentObserver;
|
||||
import android.net.Uri;
|
||||
import android.os.Handler;
|
||||
import android.os.UserHandle;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.LifecycleObserver;
|
||||
import androidx.lifecycle.OnLifecycleEvent;
|
||||
import androidx.preference.Preference;
|
||||
|
||||
import com.android.settings.core.TogglePreferenceController;
|
||||
import com.android.settings.keyboard.Flags;
|
||||
|
||||
/**
|
||||
* Abstract class for toggle controllers of Keyboard accessibility related function.
|
||||
*/
|
||||
public abstract class KeyboardAccessibilityController extends TogglePreferenceController implements
|
||||
LifecycleObserver {
|
||||
private final ContentResolver mContentResolver;
|
||||
private final ContentObserver mContentObserver = new ContentObserver(new Handler(true)) {
|
||||
@Override
|
||||
public void onChange(boolean selfChange, Uri uri) {
|
||||
if (getSettingUri().equals(uri)) {
|
||||
updateKeyboardAccessibilitySettings();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
protected abstract void updateKeyboardAccessibilitySettings();
|
||||
|
||||
protected abstract Uri getSettingUri();
|
||||
|
||||
public KeyboardAccessibilityController(@NonNull Context context,
|
||||
@NonNull String preferenceKey) {
|
||||
super(context, preferenceKey);
|
||||
mContentResolver = context.getContentResolver();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateState(@NonNull Preference preference) {
|
||||
super.updateState(preference);
|
||||
refreshSummary(preference);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return Flags.keyboardAndTouchpadA11yNewPageEnabled() ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSliceHighlightMenuRes() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Invoked when the panel is resumed. */
|
||||
@OnLifecycleEvent(ON_RESUME)
|
||||
public void onResume() {
|
||||
registerSettingsObserver();
|
||||
}
|
||||
|
||||
/** Invoked when the panel is paused. */
|
||||
@OnLifecycleEvent(ON_PAUSE)
|
||||
public void onPause() {
|
||||
unregisterSettingsObserver();
|
||||
}
|
||||
|
||||
private void registerSettingsObserver() {
|
||||
unregisterSettingsObserver();
|
||||
mContentResolver.registerContentObserver(
|
||||
getSettingUri(),
|
||||
false,
|
||||
mContentObserver,
|
||||
UserHandle.myUserId());
|
||||
updateKeyboardAccessibilitySettings();
|
||||
}
|
||||
|
||||
private void unregisterSettingsObserver() {
|
||||
mContentResolver.unregisterContentObserver(mContentObserver);
|
||||
}
|
||||
}
|
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
public class KeyboardAccessibilityMouseKeysController extends
|
||||
KeyboardAccessibilityController implements
|
||||
LifecycleObserver {
|
||||
public KeyboardAccessibilityMouseKeysController(@NonNull Context context, @NonNull String key) {
|
||||
super(context, key);
|
||||
}
|
||||
|
||||
@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 updateKeyboardAccessibilitySettings() {
|
||||
setChecked(
|
||||
InputSettings.isAccessibilityMouseKeysEnabled(mContext));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Uri getSettingUri() {
|
||||
return Settings.Secure.getUriFor(
|
||||
Settings.Secure.ACCESSIBILITY_MOUSE_KEYS_ENABLED);
|
||||
}
|
||||
}
|
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* 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 KeyboardAccessibilitySlowKeysController extends
|
||||
KeyboardAccessibilityController implements
|
||||
LifecycleObserver {
|
||||
public static final int SLOW_KEYS_THRESHOLD = 500;
|
||||
|
||||
public KeyboardAccessibilitySlowKeysController(@NonNull Context context, @NonNull String key) {
|
||||
super(context, key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChecked() {
|
||||
return InputSettings.isAccessibilitySlowKeysEnabled(mContext);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setChecked(boolean isChecked) {
|
||||
InputSettings.setAccessibilitySlowKeysThreshold(mContext,
|
||||
isChecked ? SLOW_KEYS_THRESHOLD : 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return (super.getAvailabilityStatus() == AVAILABLE)
|
||||
&& InputSettings.isAccessibilitySlowKeysFeatureFlagEnabled() ? AVAILABLE
|
||||
: UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public CharSequence getSummary() {
|
||||
return mContext.getString(R.string.slow_keys_summary, SLOW_KEYS_THRESHOLD);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateKeyboardAccessibilitySettings() {
|
||||
setChecked(
|
||||
InputSettings.isAccessibilitySlowKeysEnabled(mContext));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Uri getSettingUri() {
|
||||
return Settings.Secure.getUriFor(
|
||||
Settings.Secure.ACCESSIBILITY_SLOW_KEYS);
|
||||
}
|
||||
}
|
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
public class KeyboardAccessibilityStickyKeysController extends
|
||||
KeyboardAccessibilityController implements
|
||||
LifecycleObserver {
|
||||
public KeyboardAccessibilityStickyKeysController(@NonNull Context context,
|
||||
@NonNull String key) {
|
||||
super(context, key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChecked() {
|
||||
return InputSettings.isAccessibilityStickyKeysEnabled(mContext);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setChecked(boolean isChecked) {
|
||||
InputSettings.setAccessibilityStickyKeysEnabled(mContext,
|
||||
isChecked);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return (super.getAvailabilityStatus() == AVAILABLE)
|
||||
&& InputSettings.isAccessibilitySlowKeysFeatureFlagEnabled() ? AVAILABLE
|
||||
: UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateKeyboardAccessibilitySettings() {
|
||||
setChecked(
|
||||
InputSettings.isAccessibilityStickyKeysEnabled(mContext));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Uri getSettingUri() {
|
||||
return Settings.Secure.getUriFor(
|
||||
Settings.Secure.ACCESSIBILITY_STICKY_KEYS);
|
||||
}
|
||||
}
|
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
* 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 static com.android.settings.inputmethod.PhysicalKeyboardFragment.getHardKeyboards;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
import android.hardware.input.InputManager;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.android.internal.util.Preconditions;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
import com.android.settings.keyboard.Flags;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settingslib.search.SearchIndexable;
|
||||
import com.android.settingslib.utils.ThreadUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@SearchIndexable
|
||||
public class PhysicalKeyboardA11yFragment extends DashboardFragment
|
||||
implements InputManager.InputDeviceListener {
|
||||
private static final String TAG = "KeyboardAndTouchA11yFragment";
|
||||
|
||||
private InputManager mInputManager;
|
||||
|
||||
@Override
|
||||
public int getMetricsCategory() {
|
||||
return SettingsEnums.PHYSICAL_KEYBOARD_A11Y;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(@NonNull Context context) {
|
||||
super.onAttach(context);
|
||||
mInputManager = Preconditions.checkNotNull(getActivity()
|
||||
.getSystemService(InputManager.class));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
finishEarlyIfNeeded();
|
||||
mInputManager.registerInputDeviceListener(this, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
mInputManager.unregisterInputDeviceListener(this);
|
||||
}
|
||||
|
||||
private void finishEarlyIfNeeded() {
|
||||
final Context context = getContext();
|
||||
ThreadUtils.postOnBackgroundThread(() -> {
|
||||
final List<PhysicalKeyboardFragment.HardKeyboardDeviceInfo> newHardKeyboards =
|
||||
getHardKeyboards(context);
|
||||
if (newHardKeyboards.isEmpty()) {
|
||||
getActivity().finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getLogTag() {
|
||||
return TAG;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getPreferenceScreenResId() {
|
||||
return R.xml.physical_keyboard_a11y_settings;
|
||||
}
|
||||
|
||||
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
||||
new BaseSearchIndexProvider(R.xml.physical_keyboard_a11y_settings) {
|
||||
@Override
|
||||
protected boolean isPageSearchEnabled(Context context) {
|
||||
return Flags.keyboardAndTouchpadA11yNewPageEnabled()
|
||||
&& !getHardKeyboards(context).isEmpty();
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public void onInputDeviceAdded(int deviceId) {
|
||||
finishEarlyIfNeeded();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInputDeviceRemoved(int deviceId) {
|
||||
finishEarlyIfNeeded();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInputDeviceChanged(int deviceId) {
|
||||
finishEarlyIfNeeded();
|
||||
}
|
||||
}
|
@@ -50,6 +50,7 @@ import com.android.settings.R;
|
||||
import com.android.settings.Settings;
|
||||
import com.android.settings.SettingsPreferenceFragment;
|
||||
import com.android.settings.core.SubSettingLauncher;
|
||||
import com.android.settings.keyboard.Flags;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settingslib.search.SearchIndexable;
|
||||
@@ -74,6 +75,7 @@ public final class PhysicalKeyboardFragment extends SettingsPreferenceFragment
|
||||
private static final String ACCESSIBILITY_SLOW_KEYS = "accessibility_slow_keys";
|
||||
private static final String ACCESSIBILITY_STICKY_KEYS = "accessibility_sticky_keys";
|
||||
private static final String ACCESSIBILITY_MOUSE_KEYS = "accessibility_mouse_keys";
|
||||
private static final String ACCESSIBILITY_PHYSICAL_KEYBOARD_A11Y = "physical_keyboard_a11y";
|
||||
private static final String KEYBOARD_SHORTCUTS_HELPER = "keyboard_shortcuts_helper";
|
||||
private static final String MODIFIER_KEYS_SETTINGS = "modifier_keys_settings";
|
||||
private static final String EXTRA_AUTO_SELECTION = "auto_selection";
|
||||
@@ -154,21 +156,34 @@ public final class PhysicalKeyboardFragment extends SettingsPreferenceFragment
|
||||
}
|
||||
boolean isModifierKeySettingsEnabled = FeatureFlagUtils
|
||||
.isEnabled(getContext(), FeatureFlagUtils.SETTINGS_NEW_KEYBOARD_MODIFIER_KEY);
|
||||
boolean isKeyboardAndTouchpadA11yNewPageEnabled =
|
||||
Flags.keyboardAndTouchpadA11yNewPageEnabled();
|
||||
if (!isModifierKeySettingsEnabled) {
|
||||
mKeyboardAssistanceCategory.removePreference(findPreference(MODIFIER_KEYS_SETTINGS));
|
||||
}
|
||||
if (!InputSettings.isAccessibilityBounceKeysFeatureEnabled()) {
|
||||
if (!isKeyboardAndTouchpadA11yNewPageEnabled) {
|
||||
mKeyboardAssistanceCategory.removePreference(
|
||||
findPreference(ACCESSIBILITY_PHYSICAL_KEYBOARD_A11Y));
|
||||
}
|
||||
if (!InputSettings.isAccessibilityBounceKeysFeatureEnabled()
|
||||
|| isKeyboardAndTouchpadA11yNewPageEnabled) {
|
||||
mKeyboardA11yCategory.removePreference(mAccessibilityBounceKeys);
|
||||
}
|
||||
if (!InputSettings.isAccessibilitySlowKeysFeatureFlagEnabled()) {
|
||||
if (!InputSettings.isAccessibilitySlowKeysFeatureFlagEnabled()
|
||||
|| isKeyboardAndTouchpadA11yNewPageEnabled) {
|
||||
mKeyboardA11yCategory.removePreference(mAccessibilitySlowKeys);
|
||||
}
|
||||
if (!InputSettings.isAccessibilityStickyKeysFeatureEnabled()) {
|
||||
if (!InputSettings.isAccessibilityStickyKeysFeatureEnabled()
|
||||
|| isKeyboardAndTouchpadA11yNewPageEnabled) {
|
||||
mKeyboardA11yCategory.removePreference(mAccessibilityStickyKeys);
|
||||
}
|
||||
if (!InputSettings.isAccessibilityMouseKeysFeatureFlagEnabled()) {
|
||||
if (!InputSettings.isAccessibilityMouseKeysFeatureFlagEnabled()
|
||||
|| isKeyboardAndTouchpadA11yNewPageEnabled) {
|
||||
mKeyboardA11yCategory.removePreference(mAccessibilityMouseKeys);
|
||||
}
|
||||
if (isKeyboardAndTouchpadA11yNewPageEnabled) {
|
||||
mKeyboardA11yCategory.setVisible(false);
|
||||
}
|
||||
InputDeviceIdentifier inputDeviceIdentifier = activity.getIntent().getParcelableExtra(
|
||||
KeyboardLayoutPickerFragment.EXTRA_INPUT_DEVICE_IDENTIFIER,
|
||||
InputDeviceIdentifier.class);
|
||||
|
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* 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 static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import android.content.Context;
|
||||
import android.hardware.input.InputSettings;
|
||||
import android.platform.test.annotations.DisableFlags;
|
||||
import android.platform.test.annotations.EnableFlags;
|
||||
import android.platform.test.flag.junit.SetFlagsRule;
|
||||
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settings.keyboard.Flags;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
import org.robolectric.annotation.Config;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
@Config(shadows = {
|
||||
com.android.settings.testutils.shadow.ShadowFragment.class,
|
||||
})
|
||||
public class KeyboardAccessibilityBounceKeysControllerTest {
|
||||
@Rule
|
||||
public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
|
||||
private Context mContext;
|
||||
private KeyboardAccessibilityBounceKeysController mKeyboardAccessibilityBounceKeysController;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
mContext = RuntimeEnvironment.application;
|
||||
mKeyboardAccessibilityBounceKeysController = new KeyboardAccessibilityBounceKeysController(
|
||||
mContext,
|
||||
"accessibility_bounce_keys");
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(Flags.FLAG_KEYBOARD_AND_TOUCHPAD_A11Y_NEW_PAGE_ENABLED)
|
||||
public void getAvailabilityStatus_flagIsEnabled_isAvailable() {
|
||||
assertThat(mKeyboardAccessibilityBounceKeysController.getAvailabilityStatus())
|
||||
.isEqualTo(BasePreferenceController.AVAILABLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisableFlags(Flags.FLAG_KEYBOARD_AND_TOUCHPAD_A11Y_NEW_PAGE_ENABLED)
|
||||
public void getAvailabilityStatus_flagIsDisabled_notSupport() {
|
||||
assertThat(mKeyboardAccessibilityBounceKeysController.getAvailabilityStatus())
|
||||
.isEqualTo(BasePreferenceController.UNSUPPORTED_ON_DEVICE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setChecked_true_updateBounceKeyValue() {
|
||||
mKeyboardAccessibilityBounceKeysController.setChecked(true);
|
||||
boolean isEnabled = InputSettings.isAccessibilityBounceKeysEnabled(mContext);
|
||||
|
||||
assertThat(isEnabled).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setChecked_false_updateBounceKeyValue() {
|
||||
mKeyboardAccessibilityBounceKeysController.setChecked(false);
|
||||
boolean isEnabled = InputSettings.isAccessibilityBounceKeysEnabled(mContext);
|
||||
|
||||
assertThat(isEnabled).isFalse();
|
||||
}
|
||||
}
|
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* 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 static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import android.content.Context;
|
||||
import android.hardware.input.InputSettings;
|
||||
import android.platform.test.annotations.DisableFlags;
|
||||
import android.platform.test.annotations.EnableFlags;
|
||||
import android.platform.test.flag.junit.SetFlagsRule;
|
||||
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settings.keyboard.Flags;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
import org.robolectric.annotation.Config;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
@Config(shadows = {
|
||||
com.android.settings.testutils.shadow.ShadowFragment.class,
|
||||
})
|
||||
public class KeyboardAccessibilityMouseKeysControllerTest {
|
||||
@Rule
|
||||
public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
|
||||
private Context mContext;
|
||||
private KeyboardAccessibilityMouseKeysController mKeyboardAccessibilityMouseKeysController;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
mContext = RuntimeEnvironment.application;
|
||||
mKeyboardAccessibilityMouseKeysController = new KeyboardAccessibilityMouseKeysController(
|
||||
mContext,
|
||||
"accessibility_mouse_keys");
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(Flags.FLAG_KEYBOARD_AND_TOUCHPAD_A11Y_NEW_PAGE_ENABLED)
|
||||
public void getAvailabilityStatus_flagIsEnabled_isAvailable() {
|
||||
assertThat(mKeyboardAccessibilityMouseKeysController.getAvailabilityStatus())
|
||||
.isEqualTo(BasePreferenceController.AVAILABLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisableFlags(Flags.FLAG_KEYBOARD_AND_TOUCHPAD_A11Y_NEW_PAGE_ENABLED)
|
||||
public void getAvailabilityStatus_flagIsDisabled_notSupport() {
|
||||
assertThat(mKeyboardAccessibilityMouseKeysController.getAvailabilityStatus())
|
||||
.isEqualTo(BasePreferenceController.UNSUPPORTED_ON_DEVICE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setChecked_true_updateMouseKeyValue() {
|
||||
mKeyboardAccessibilityMouseKeysController.setChecked(true);
|
||||
boolean isEnabled = InputSettings.isAccessibilityMouseKeysEnabled(mContext);
|
||||
|
||||
assertThat(isEnabled).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setChecked_false_updateMouseKeyValue() {
|
||||
mKeyboardAccessibilityMouseKeysController.setChecked(false);
|
||||
boolean isEnabled = InputSettings.isAccessibilityMouseKeysEnabled(mContext);
|
||||
|
||||
assertThat(isEnabled).isFalse();
|
||||
}
|
||||
}
|
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* 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 static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import android.content.Context;
|
||||
import android.hardware.input.InputSettings;
|
||||
import android.platform.test.annotations.DisableFlags;
|
||||
import android.platform.test.annotations.EnableFlags;
|
||||
import android.platform.test.flag.junit.SetFlagsRule;
|
||||
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settings.keyboard.Flags;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
import org.robolectric.annotation.Config;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
@Config(shadows = {
|
||||
com.android.settings.testutils.shadow.ShadowFragment.class,
|
||||
})
|
||||
public class KeyboardAccessibilitySlowKeysControllerTest {
|
||||
@Rule
|
||||
public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
|
||||
private Context mContext;
|
||||
private KeyboardAccessibilitySlowKeysController mKeyboardAccessibilitySlowKeysController;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
mContext = RuntimeEnvironment.application;
|
||||
mKeyboardAccessibilitySlowKeysController = new KeyboardAccessibilitySlowKeysController(
|
||||
mContext,
|
||||
"accessibility_slow_keys");
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(Flags.FLAG_KEYBOARD_AND_TOUCHPAD_A11Y_NEW_PAGE_ENABLED)
|
||||
public void getAvailabilityStatus_flagIsEnabled_isAvailable() {
|
||||
assertThat(mKeyboardAccessibilitySlowKeysController.getAvailabilityStatus())
|
||||
.isEqualTo(BasePreferenceController.AVAILABLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisableFlags(Flags.FLAG_KEYBOARD_AND_TOUCHPAD_A11Y_NEW_PAGE_ENABLED)
|
||||
public void getAvailabilityStatus_flagIsDisabled_notSupport() {
|
||||
assertThat(mKeyboardAccessibilitySlowKeysController.getAvailabilityStatus())
|
||||
.isEqualTo(BasePreferenceController.UNSUPPORTED_ON_DEVICE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setChecked_true_updateSlowKeyValue() {
|
||||
mKeyboardAccessibilitySlowKeysController.setChecked(true);
|
||||
boolean isEnabled = InputSettings.isAccessibilitySlowKeysEnabled(mContext);
|
||||
|
||||
assertThat(isEnabled).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setChecked_false_updateSlowKeyValue() {
|
||||
mKeyboardAccessibilitySlowKeysController.setChecked(false);
|
||||
boolean isEnabled = InputSettings.isAccessibilitySlowKeysEnabled(mContext);
|
||||
|
||||
assertThat(isEnabled).isFalse();
|
||||
}
|
||||
}
|
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* 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 static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import android.content.Context;
|
||||
import android.hardware.input.InputSettings;
|
||||
import android.platform.test.annotations.DisableFlags;
|
||||
import android.platform.test.annotations.EnableFlags;
|
||||
import android.platform.test.flag.junit.SetFlagsRule;
|
||||
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settings.keyboard.Flags;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
import org.robolectric.annotation.Config;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
@Config(shadows = {
|
||||
com.android.settings.testutils.shadow.ShadowFragment.class,
|
||||
})
|
||||
public class KeyboardAccessibilityStickyKeysControllerTest {
|
||||
@Rule
|
||||
public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
|
||||
private Context mContext;
|
||||
private KeyboardAccessibilityStickyKeysController mKeyboardAccessibilityStickyKeysController;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
mContext = RuntimeEnvironment.application;
|
||||
mKeyboardAccessibilityStickyKeysController = new KeyboardAccessibilityStickyKeysController(
|
||||
mContext,
|
||||
"accessibility_sticky_keys");
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFlags(Flags.FLAG_KEYBOARD_AND_TOUCHPAD_A11Y_NEW_PAGE_ENABLED)
|
||||
public void getAvailabilityStatus_flagIsEnabled_isAvailable() {
|
||||
assertThat(mKeyboardAccessibilityStickyKeysController.getAvailabilityStatus())
|
||||
.isEqualTo(BasePreferenceController.AVAILABLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisableFlags(Flags.FLAG_KEYBOARD_AND_TOUCHPAD_A11Y_NEW_PAGE_ENABLED)
|
||||
public void getAvailabilityStatus_flagIsDisabled_notSupport() {
|
||||
assertThat(mKeyboardAccessibilityStickyKeysController.getAvailabilityStatus())
|
||||
.isEqualTo(BasePreferenceController.UNSUPPORTED_ON_DEVICE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setChecked_true_updateStickyKeyValue() {
|
||||
mKeyboardAccessibilityStickyKeysController.setChecked(true);
|
||||
boolean isEnabled = InputSettings.isAccessibilityStickyKeysEnabled(mContext);
|
||||
|
||||
assertThat(isEnabled).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setChecked_false_updateStickyKeyValue() {
|
||||
mKeyboardAccessibilityStickyKeysController.setChecked(false);
|
||||
boolean isEnabled = InputSettings.isAccessibilityStickyKeysEnabled(mContext);
|
||||
|
||||
assertThat(isEnabled).isFalse();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user