• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 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.systemui.accessibility;
18 
19 import android.content.Context;
20 import android.provider.Settings;
21 
22 import androidx.annotation.MainThread;
23 import androidx.annotation.Nullable;
24 
25 import com.android.systemui.dagger.SysUISingleton;
26 import com.android.systemui.settings.UserTracker;
27 import com.android.systemui.util.settings.SecureSettings;
28 
29 import javax.inject.Inject;
30 
31 /**
32  * Controller for tracking the current accessibility gesture list.
33  *
34  * @see Settings.Secure#ACCESSIBILITY_GESTURE_TARGETS
35  */
36 @MainThread
37 @SysUISingleton
38 public class AccessibilityGestureTargetsObserver extends
39         SecureSettingsContentObserver<AccessibilityGestureTargetsObserver.TargetsChangedListener> {
40 
41     /** Listener for accessibility gesture targets changes. */
42     public interface TargetsChangedListener {
43 
44         /**
45          * Called when accessibility gesture targets changes.
46          *
47          * @param targets Current content of {@link Settings.Secure#ACCESSIBILITY_GESTURE_TARGETS}
48          */
onAccessibilityGestureTargetsChanged(String targets)49         void onAccessibilityGestureTargetsChanged(String targets);
50     }
51 
52     @Inject
AccessibilityGestureTargetsObserver( Context context, UserTracker userTracker, SecureSettings secureSettings)53     public AccessibilityGestureTargetsObserver(
54             Context context, UserTracker userTracker, SecureSettings secureSettings) {
55         super(context, userTracker, secureSettings, Settings.Secure.ACCESSIBILITY_GESTURE_TARGETS);
56     }
57 
58     @Override
onValueChanged(TargetsChangedListener listener, String value)59     void onValueChanged(TargetsChangedListener listener, String value) {
60         listener.onAccessibilityGestureTargetsChanged(value);
61     }
62 
63     /** Returns the current string from settings key
64      *  {@link Settings.Secure#ACCESSIBILITY_GESTURE_TARGETS}. */
65     @Nullable
getCurrentAccessibilityGestureTargets()66     public String getCurrentAccessibilityGestureTargets() {
67         return getSettingsValue();
68     }
69 }
70