[Physical Keybaord] Add keyboard touchpad/Mouse page - part1

1. rename TrackpadSetting to TouchpadAndMouseSetting
to match more about usage.

2. Add separated pages for touchpad and mouse.
Gather options from current page and put it accordingly.
Please note that this change only add isolate files for pages
and didn't reference from anywhere, it will be done in next change.

This is part of feature for keyboard setting update.
document: go/new-a11y-touchpad-mouse-page

Bug: 377602364
Test: atest SettingsRoboTests
Flag: com.android.settings.keyboard.keyboard_and_touchpad_a11y_new_page_enabled
Change-Id: I9e18ce3fbc3617bfb6cef3c272f3cfcfd2ff8a37
This commit is contained in:
shaoweishen
2024-11-12 03:47:47 +00:00
committed by Shaowei Shen
parent 50bbcbbcb7
commit 2be5ef9426
15 changed files with 575 additions and 14 deletions

View File

@@ -0,0 +1,83 @@
/*
* 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.InputManager;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.preference.Preference;
import com.android.settings.core.BasePreferenceController;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.core.lifecycle.LifecycleObserver;
import com.android.settingslib.core.lifecycle.events.OnStart;
import com.android.settingslib.core.lifecycle.events.OnStop;
public abstract class InputDeviceSettingsController extends BasePreferenceController
implements PreferenceControllerMixin, LifecycleObserver, OnStart, OnStop,
InputManager.InputDeviceListener {
private final InputManager mIm;
@Nullable
private Preference mPreference;
public InputDeviceSettingsController(@NonNull Context context, @NonNull String key) {
super(context, key);
mIm = context.getSystemService(InputManager.class);
}
@Override
public void onInputDeviceAdded(int deviceId) {
updateEntry();
}
@Override
public void onInputDeviceRemoved(int deviceId) {
updateEntry();
}
@Override
public void onInputDeviceChanged(int deviceId) {
updateEntry();
}
@Override
public void onStart() {
mIm.registerInputDeviceListener(this, null);
}
@Override
public void onStop() {
mIm.unregisterInputDeviceListener(this);
}
@Override
public void updateState(Preference preference) {
mPreference = preference;
updateEntry();
}
private void updateEntry() {
if (mPreference == null) {
return;
}
mPreference.setVisible(isAvailable());
}
}

View File

@@ -0,0 +1,55 @@
/*
* 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.app.settings.SettingsEnums;
import android.content.Context;
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;
@SearchIndexable
public class MouseSettingFragment extends DashboardFragment {
private static final String TAG = MouseSettingFragment.class.getSimpleName();
@Override
protected int getPreferenceScreenResId() {
return R.xml.mouse_settings;
}
@Override
protected String getLogTag() {
return TAG;
}
@Override
public int getMetricsCategory() {
return SettingsEnums.SETTINGS_KEYBOARD_MOUSE;
}
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
new BaseSearchIndexProvider(R.xml.mouse_settings) {
@Override
protected boolean isPageSearchEnabled(Context context) {
return Flags.keyboardAndTouchpadA11yNewPageEnabled()
&& InputPeripheralsSettingsUtils.isMouse();
}
};
}

View File

@@ -0,0 +1,40 @@
/*
* 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 androidx.annotation.NonNull;
import com.android.settings.keyboard.Flags;
public class MouseSettingsController extends InputDeviceSettingsController {
public MouseSettingsController(@NonNull Context context, @NonNull String key) {
super(context, key);
}
@Override
public int getAvailabilityStatus() {
boolean isFeatureOn = Flags.keyboardAndTouchpadA11yNewPageEnabled();
boolean isPointerCustomizationEnabled =
android.view.flags.Flags.enableVectorCursorA11ySettings();
boolean isMouse = InputPeripheralsSettingsUtils.isMouse();
return (isFeatureOn && isPointerCustomizationEnabled && isMouse) ? AVAILABLE
: CONDITIONALLY_UNAVAILABLE;
}
}

View File

@@ -29,9 +29,9 @@ import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settingslib.search.SearchIndexable;
@SearchIndexable
public class TrackpadSettings extends DashboardFragment {
public class TouchpadAndMouseSettings extends DashboardFragment {
private static final String TAG = "TrackpadSettings";
private static final String TAG = TouchpadAndMouseSettings.class.getSimpleName();
@Override
public void onAttach(@NonNull Context context) {
@@ -58,11 +58,11 @@ public class TrackpadSettings extends DashboardFragment {
@Override
protected int getPreferenceScreenResId() {
return R.xml.trackpad_settings;
return R.xml.touchpad_and_mouse_settings;
}
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
new BaseSearchIndexProvider(R.xml.trackpad_settings) {
new BaseSearchIndexProvider(R.xml.touchpad_and_mouse_settings) {
@Override
protected boolean isPageSearchEnabled(Context context) {
return FeatureFlagUtils

View File

@@ -20,6 +20,8 @@ import android.content.Context;
import android.hardware.input.InputManager;
import android.util.FeatureFlagUtils;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.preference.Preference;
import com.android.settings.core.BasePreferenceController;
@@ -28,15 +30,16 @@ import com.android.settingslib.core.lifecycle.LifecycleObserver;
import com.android.settingslib.core.lifecycle.events.OnStart;
import com.android.settingslib.core.lifecycle.events.OnStop;
public class TrackpadSettingsController extends BasePreferenceController
public class TouchpadAndMouseSettingsController extends BasePreferenceController
implements PreferenceControllerMixin, LifecycleObserver, OnStart, OnStop,
InputManager.InputDeviceListener {
private final InputManager mIm;
@Nullable
private Preference mPreference;
public TrackpadSettingsController(Context context, String key) {
public TouchpadAndMouseSettingsController(@NonNull Context context, @NonNull String key) {
super(context, key);
mIm = context.getSystemService(InputManager.class);
}

View File

@@ -0,0 +1,55 @@
/*
* 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.app.settings.SettingsEnums;
import android.content.Context;
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;
@SearchIndexable
public class TouchpadSettingFragment extends DashboardFragment {
private static final String TAG = TouchpadSettingFragment.class.getSimpleName();
@Override
protected int getPreferenceScreenResId() {
return R.xml.touchpad_settings;
}
@Override
protected String getLogTag() {
return TAG;
}
@Override
public int getMetricsCategory() {
return SettingsEnums.SETTINGS_KEYBOARDS_TOUCHPAD;
}
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
new BaseSearchIndexProvider(R.xml.touchpad_settings) {
@Override
protected boolean isPageSearchEnabled(Context context) {
return Flags.keyboardAndTouchpadA11yNewPageEnabled()
&& InputPeripheralsSettingsUtils.isTouchpad();
}
};
}

View File

@@ -0,0 +1,37 @@
/*
* 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 androidx.annotation.NonNull;
import com.android.settings.keyboard.Flags;
public class TouchpadSettingsController extends InputDeviceSettingsController {
public TouchpadSettingsController(@NonNull Context context, @NonNull String key) {
super(context, key);
}
@Override
public int getAvailabilityStatus() {
boolean isFeatureOn = Flags.keyboardAndTouchpadA11yNewPageEnabled();
boolean isTouchpad = InputPeripheralsSettingsUtils.isTouchpad();
return (isFeatureOn && isTouchpad) ? AVAILABLE
: CONDITIONALLY_UNAVAILABLE;
}
}