• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2025 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 android.view.accessibility.AccessibilityManager.AUTOCLICK_REVERT_TO_LEFT_CLICK_DEFAULT;
20 
21 import static com.android.settings.accessibility.AccessibilityUtil.State.OFF;
22 import static com.android.settings.accessibility.AccessibilityUtil.State.ON;
23 
24 import android.content.ContentResolver;
25 import android.content.Context;
26 import android.provider.Settings;
27 
28 import androidx.annotation.NonNull;
29 
30 import com.android.server.accessibility.Flags;
31 import com.android.settings.R;
32 import com.android.settings.core.TogglePreferenceController;
33 
34 public class ToggleAutoclickRevertToLeftClickController extends TogglePreferenceController {
35 
36     private static final String TAG =
37             ToggleAutoclickRevertToLeftClickController.class.getSimpleName();
38 
39     private final ContentResolver mContentResolver;
40 
ToggleAutoclickRevertToLeftClickController( @onNull Context context, @NonNull String key)41     public ToggleAutoclickRevertToLeftClickController(
42             @NonNull Context context, @NonNull String key) {
43         super(context, key);
44 
45         mContentResolver = context.getContentResolver();
46     }
47 
48     @Override
getAvailabilityStatus()49     public int getAvailabilityStatus() {
50         return Flags.enableAutoclickIndicator() ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
51     }
52 
53     @Override
isChecked()54     public boolean isChecked() {
55         return Settings.Secure.getInt(
56                         mContentResolver,
57                         Settings.Secure.ACCESSIBILITY_AUTOCLICK_REVERT_TO_LEFT_CLICK,
58                         AUTOCLICK_REVERT_TO_LEFT_CLICK_DEFAULT ? ON : OFF)
59                 == ON;
60     }
61 
62     @Override
setChecked(boolean isChecked)63     public boolean setChecked(boolean isChecked) {
64         Settings.Secure.putInt(
65                 mContentResolver,
66                 Settings.Secure.ACCESSIBILITY_AUTOCLICK_REVERT_TO_LEFT_CLICK,
67                 isChecked ? ON : OFF);
68         return true;
69     }
70 
71     @Override
getSliceHighlightMenuRes()72     public int getSliceHighlightMenuRes() {
73         return R.string.menu_key_accessibility;
74     }
75 }
76