Merge "[Physical Keyboard][Setting] New pk a11y entry under a11y page" into main
This commit is contained in:
@@ -30,7 +30,6 @@ import android.os.UserHandle;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
import android.util.ArrayMap;
|
||||
import android.view.InputDevice;
|
||||
import android.view.accessibility.AccessibilityManager;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
@@ -45,7 +44,6 @@ import com.android.settings.R;
|
||||
import com.android.settings.accessibility.AccessibilityUtil.AccessibilityServiceFragmentType;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
import com.android.settings.development.Enable16kUtils;
|
||||
import com.android.settings.inputmethod.PhysicalKeyboardFragment;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settingslib.RestrictedPreference;
|
||||
@@ -73,14 +71,12 @@ public class AccessibilitySettings extends DashboardFragment implements
|
||||
private static final String CATEGORY_DISPLAY = "display_category";
|
||||
@VisibleForTesting
|
||||
static final String CATEGORY_DOWNLOADED_SERVICES = "user_installed_services_category";
|
||||
private static final String CATEGORY_KEYBOARD_OPTIONS = "physical_keyboard_options_category";
|
||||
@VisibleForTesting
|
||||
static final String CATEGORY_INTERACTION_CONTROL = "interaction_control_category";
|
||||
|
||||
private static final String[] CATEGORIES = new String[]{
|
||||
CATEGORY_SCREEN_READER, CATEGORY_CAPTIONS, CATEGORY_AUDIO, CATEGORY_DISPLAY,
|
||||
CATEGORY_SPEECH, CATEGORY_INTERACTION_CONTROL,
|
||||
CATEGORY_KEYBOARD_OPTIONS, CATEGORY_DOWNLOADED_SERVICES
|
||||
CATEGORY_SPEECH, CATEGORY_INTERACTION_CONTROL, CATEGORY_DOWNLOADED_SERVICES
|
||||
};
|
||||
|
||||
// Extras passed to sub-fragments.
|
||||
@@ -275,7 +271,7 @@ public class AccessibilitySettings extends DashboardFragment implements
|
||||
* @return The service summary
|
||||
*/
|
||||
public static CharSequence getServiceSummary(Context context, AccessibilityServiceInfo info,
|
||||
boolean serviceEnabled) {
|
||||
boolean serviceEnabled) {
|
||||
if (serviceEnabled && info.crashed) {
|
||||
return context.getText(R.string.accessibility_summary_state_stopped);
|
||||
}
|
||||
@@ -461,7 +457,6 @@ public class AccessibilitySettings extends DashboardFragment implements
|
||||
// Hide category if it is empty.
|
||||
updatePreferenceCategoryVisibility(CATEGORY_SCREEN_READER);
|
||||
updatePreferenceCategoryVisibility(CATEGORY_SPEECH);
|
||||
updatePreferenceCategoryVisibility(CATEGORY_KEYBOARD_OPTIONS);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -556,9 +551,7 @@ public class AccessibilitySettings extends DashboardFragment implements
|
||||
/**
|
||||
* Updates preferences related to system configurations.
|
||||
*/
|
||||
protected void updateSystemPreferences() {
|
||||
updateKeyboardPreferencesVisibility();
|
||||
}
|
||||
protected void updateSystemPreferences() {}
|
||||
|
||||
private void updatePreferencesState() {
|
||||
final List<AbstractPreferenceController> controllers = new ArrayList<>();
|
||||
@@ -567,53 +560,6 @@ public class AccessibilitySettings extends DashboardFragment implements
|
||||
findPreference(controller.getPreferenceKey())));
|
||||
}
|
||||
|
||||
private void updateKeyboardPreferencesVisibility() {
|
||||
if (!mCategoryToPrefCategoryMap.containsKey(CATEGORY_KEYBOARD_OPTIONS)) {
|
||||
return;
|
||||
}
|
||||
boolean isVisible = isAnyHardKeyboardsExist()
|
||||
&& isAnyKeyboardPreferenceAvailable();
|
||||
mCategoryToPrefCategoryMap.get(CATEGORY_KEYBOARD_OPTIONS).setVisible(
|
||||
isVisible);
|
||||
if (isVisible) {
|
||||
//set summary here.
|
||||
findPreference(KeyboardBounceKeyPreferenceController.PREF_KEY).setSummary(
|
||||
getContext().getString(R.string.bounce_keys_summary,
|
||||
PhysicalKeyboardFragment.BOUNCE_KEYS_THRESHOLD));
|
||||
findPreference(KeyboardSlowKeyPreferenceController.PREF_KEY).setSummary(
|
||||
getContext().getString(R.string.slow_keys_summary,
|
||||
PhysicalKeyboardFragment.SLOW_KEYS_THRESHOLD));
|
||||
}
|
||||
}
|
||||
|
||||
static boolean isAnyHardKeyboardsExist() {
|
||||
for (int deviceId : InputDevice.getDeviceIds()) {
|
||||
final InputDevice device = InputDevice.getDevice(deviceId);
|
||||
if (device != null && !device.isVirtual() && device.isFullKeyboard()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isAnyKeyboardPreferenceAvailable() {
|
||||
for (List<AbstractPreferenceController> controllerList : getPreferenceControllers()) {
|
||||
for (AbstractPreferenceController controller : controllerList) {
|
||||
if (controller.getPreferenceKey().equals(
|
||||
KeyboardBounceKeyPreferenceController.PREF_KEY)
|
||||
|| controller.getPreferenceKey().equals(
|
||||
KeyboardSlowKeyPreferenceController.PREF_KEY)
|
||||
|| controller.getPreferenceKey().equals(
|
||||
KeyboardStickyKeyPreferenceController.PREF_KEY)) {
|
||||
if (controller.isAvailable()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
||||
new BaseSearchIndexProvider(R.xml.accessibility_settings) {
|
||||
@Override
|
||||
@@ -671,10 +617,12 @@ public class AccessibilitySettings extends DashboardFragment implements
|
||||
};
|
||||
|
||||
@Override
|
||||
public void onInputDeviceAdded(int deviceId) {}
|
||||
public void onInputDeviceAdded(int deviceId) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInputDeviceRemoved(int deviceId) {}
|
||||
public void onInputDeviceRemoved(int deviceId) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInputDeviceChanged(int deviceId) {
|
||||
|
||||
@@ -1,79 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 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.accessibility;
|
||||
|
||||
|
||||
import android.content.Context;
|
||||
import android.hardware.input.InputSettings;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.TogglePreferenceController;
|
||||
import com.android.settings.inputmethod.PhysicalKeyboardFragment;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* A toggle preference controller for keyboard bounce key.
|
||||
*/
|
||||
public class KeyboardBounceKeyPreferenceController extends TogglePreferenceController {
|
||||
private static final String TAG = "BounceKeyPrefController";
|
||||
static final String PREF_KEY = "toggle_keyboard_bounce_keys";
|
||||
|
||||
public KeyboardBounceKeyPreferenceController(Context context, String preferenceKey) {
|
||||
super(context, preferenceKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return InputSettings.isAccessibilityBounceKeysFeatureEnabled()
|
||||
? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChecked() {
|
||||
return InputSettings.isAccessibilityBounceKeysEnabled(mContext);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setChecked(boolean isChecked) {
|
||||
InputSettings.setAccessibilityBounceKeysThreshold(mContext,
|
||||
isChecked ? PhysicalKeyboardFragment.BOUNCE_KEYS_THRESHOLD
|
||||
: 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSliceHighlightMenuRes() {
|
||||
return R.string.menu_key_accessibility;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateNonIndexableKeys(@NonNull List<String> keys) {
|
||||
super.updateNonIndexableKeys(keys);
|
||||
|
||||
if (Flags.fixA11ySettingsSearch() && !AccessibilitySettings.isAnyHardKeyboardsExist()) {
|
||||
if (keys.contains(getPreferenceKey())) {
|
||||
Log.w(TAG, "Skipping updateNonIndexableKeys, key already in list.");
|
||||
return;
|
||||
}
|
||||
keys.add(getPreferenceKey());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 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.accessibility;
|
||||
|
||||
|
||||
import android.content.Context;
|
||||
import android.hardware.input.InputSettings;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.TogglePreferenceController;
|
||||
import com.android.settings.inputmethod.PhysicalKeyboardFragment;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* A toggle preference controller for keyboard slow key.
|
||||
*/
|
||||
public class KeyboardSlowKeyPreferenceController extends TogglePreferenceController {
|
||||
private static final String TAG = "SlowKeyPrefController";
|
||||
|
||||
static final String PREF_KEY = "toggle_keyboard_slow_keys";
|
||||
|
||||
public KeyboardSlowKeyPreferenceController(Context context, String preferenceKey) {
|
||||
super(context, preferenceKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return InputSettings.isAccessibilitySlowKeysFeatureFlagEnabled()
|
||||
? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChecked() {
|
||||
return InputSettings.isAccessibilitySlowKeysEnabled(mContext);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setChecked(boolean isChecked) {
|
||||
InputSettings.setAccessibilitySlowKeysThreshold(mContext,
|
||||
isChecked ? PhysicalKeyboardFragment.SLOW_KEYS_THRESHOLD
|
||||
: 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSliceHighlightMenuRes() {
|
||||
return R.string.menu_key_accessibility;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateNonIndexableKeys(@NonNull List<String> keys) {
|
||||
super.updateNonIndexableKeys(keys);
|
||||
|
||||
if (Flags.fixA11ySettingsSearch() && !AccessibilitySettings.isAnyHardKeyboardsExist()) {
|
||||
if (keys.contains(getPreferenceKey())) {
|
||||
Log.w(TAG, "Skipping updateNonIndexableKeys, key already in list.");
|
||||
return;
|
||||
}
|
||||
keys.add(getPreferenceKey());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 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.accessibility;
|
||||
|
||||
|
||||
import android.content.Context;
|
||||
import android.hardware.input.InputSettings;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.TogglePreferenceController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* A toggle preference controller for keyboard sticky key.
|
||||
*/
|
||||
public class KeyboardStickyKeyPreferenceController extends TogglePreferenceController {
|
||||
private static final String TAG = "StickyKeyPrefController";
|
||||
static final String PREF_KEY = "toggle_keyboard_sticky_keys";
|
||||
|
||||
public KeyboardStickyKeyPreferenceController(Context context, String preferenceKey) {
|
||||
super(context, preferenceKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return InputSettings.isAccessibilityStickyKeysFeatureEnabled()
|
||||
? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChecked() {
|
||||
return InputSettings.isAccessibilityStickyKeysEnabled(mContext);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setChecked(boolean isChecked) {
|
||||
InputSettings.setAccessibilityStickyKeysEnabled(mContext, isChecked);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSliceHighlightMenuRes() {
|
||||
return R.string.menu_key_accessibility;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateNonIndexableKeys(@NonNull List<String> keys) {
|
||||
super.updateNonIndexableKeys(keys);
|
||||
|
||||
if (Flags.fixA11ySettingsSearch() && !AccessibilitySettings.isAnyHardKeyboardsExist()) {
|
||||
if (keys.contains(getPreferenceKey())) {
|
||||
Log.w(TAG, "Skipping updateNonIndexableKeys, key already in list.");
|
||||
return;
|
||||
}
|
||||
keys.add(getPreferenceKey());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user