• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2024 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.settings.inputmethod;
18 
19 import static com.android.settings.inputmethod.InputPeripheralsSettingsUtils.isMouse;
20 import static com.android.settings.inputmethod.InputPeripheralsSettingsUtils.isTouchpad;
21 
22 import android.app.settings.SettingsEnums;
23 import android.content.Context;
24 
25 import com.android.settings.R;
26 import com.android.settings.search.BaseSearchIndexProvider;
27 import com.android.settings.widget.PreferenceCategoryController;
28 import com.android.settingslib.core.AbstractPreferenceController;
29 import com.android.settingslib.search.SearchIndexable;
30 
31 import java.util.List;
32 
33 /** Accessibility settings for pointer and touchpad. */
34 @SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC)
35 public class PointerTouchpadFragment extends InputDeviceDashboardFragment {
36 
37     private static final String TAG = "PointerTouchpadFragment";
38 
39     @Override
createPreferenceControllers(Context context)40     protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
41         return buildPreferenceControllers(context);
42     }
43 
buildPreferenceControllers(Context context)44     private static List<AbstractPreferenceController> buildPreferenceControllers(Context context) {
45         TouchpadSystemGesturesPreferenceController systemGesturesController =
46                 new TouchpadSystemGesturesPreferenceController(
47                         context, "touchpad_system_gestures_enable");
48         return List.of(
49                 systemGesturesController,
50                 new PreferenceCategoryController(context, "touchpad_category")
51                         .setChildren(List.of(systemGesturesController)));
52     }
53 
54     @Override
getMetricsCategory()55     public int getMetricsCategory() {
56         return SettingsEnums.ACCESSIBILITY_POINTER_TOUCHPAD;
57     }
58 
59     @Override
getPreferenceScreenResId()60     protected int getPreferenceScreenResId() {
61         return R.xml.accessibility_pointer_and_touchpad;
62     }
63 
64     @Override
getLogTag()65     protected String getLogTag() {
66         return TAG;
67     }
68 
69     public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
70             new BaseSearchIndexProvider(R.xml.accessibility_pointer_and_touchpad) {
71                 @Override
72                 protected boolean isPageSearchEnabled(Context context) {
73                     return isTouchpad() || isMouse();
74                 }
75 
76                 @Override
77                 public List<AbstractPreferenceController> createPreferenceControllers(
78                         Context context) {
79                     return buildPreferenceControllers(context);
80                 }
81             };
82 
83     @Override
needToFinishEarly()84     protected boolean needToFinishEarly() {
85         return isMouseDetached() && isTouchpadDetached();
86     }
87 }
88