• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2015 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.accessibility;
18 
19 import static com.android.internal.accessibility.AccessibilityShortcutController.AUTOCLICK_COMPONENT_NAME;
20 
21 import android.app.settings.SettingsEnums;
22 import android.content.ComponentName;
23 import android.content.Context;
24 import android.os.Bundle;
25 import android.view.LayoutInflater;
26 import android.view.View;
27 import android.view.ViewGroup;
28 
29 import com.android.internal.annotations.VisibleForTesting;
30 import com.android.server.accessibility.Flags;
31 import com.android.settings.R;
32 import com.android.settings.search.BaseSearchIndexProvider;
33 import com.android.settingslib.search.SearchIndexable;
34 
35 import java.util.List;
36 
37 /**
38  * Fragment for preference screen for settings related to Automatically click after mouse stops
39  * feature.
40  */
41 @SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC)
42 public class ToggleAutoclickPreferenceFragment
43         extends AccessibilityShortcutPreferenceFragment {
44 
45     private static final String TAG = "AutoclickPrefFragment";
46 
47     @VisibleForTesting
48     static final String KEY_AUTOCLICK_SHORTCUT_PREFERENCE = "autoclick_shortcut_preference";
49 
50     /**
51      * Autoclick settings do not need to set any restriction key for pin protected.
52      */
ToggleAutoclickPreferenceFragment()53     public ToggleAutoclickPreferenceFragment() {
54         super(/* restrictionKey= */ null);
55     }
56 
57     @Override
getLabelName()58     protected CharSequence getLabelName() {
59         return getContext().getString(R.string.accessibility_autoclick_shortcut_title);
60     }
61 
62     @Override
showGeneralCategory()63     protected boolean showGeneralCategory() {
64         return false;
65     }
66 
67     @Override
getMetricsCategory()68     public int getMetricsCategory() {
69         return SettingsEnums.ACCESSIBILITY_TOGGLE_AUTOCLICK;
70     }
71 
72     @Override
getHelpResource()73     public int getHelpResource() {
74         return R.string.help_url_autoclick;
75     }
76 
77     @Override
getLogTag()78     protected String getLogTag() {
79         return TAG;
80     }
81 
82     @Override
getPreferenceScreenResId()83     protected int getPreferenceScreenResId() {
84         return R.xml.accessibility_autoclick_settings;
85     }
86 
87     @Override
getComponentName()88     protected ComponentName getComponentName() {
89         return AUTOCLICK_COMPONENT_NAME;
90     }
91 
92     @Override
getShortcutTitle()93     protected CharSequence getShortcutTitle() {
94         return getString(R.string.accessibility_autoclick_shortcut_title);
95     }
96 
97     @Override
getShortcutPreferenceKey()98     protected String getShortcutPreferenceKey() {
99         return KEY_AUTOCLICK_SHORTCUT_PREFERENCE;
100     }
101 
102     @Override
onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)103     public View onCreateView(LayoutInflater inflater, ViewGroup container,
104             Bundle savedInstanceState) {
105         View view = super.onCreateView(inflater, container, savedInstanceState);
106         if (!Flags.enableAutoclickIndicator()) {
107             getPreferenceScreen().removePreference(mShortcutPreference);
108         }
109         return view;
110     }
111 
112     public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
113             new BaseSearchIndexProvider(R.xml.accessibility_autoclick_settings) {
114                 @Override
115                 public List<String> getNonIndexableKeys(Context context) {
116                     List<String> niks = super.getNonIndexableKeys(context);
117 
118                     if (!Flags.enableAutoclickIndicator()) {
119                         niks.add(KEY_AUTOCLICK_SHORTCUT_PREFERENCE);
120                     }
121                     return niks;
122                 }
123             };
124 }
125