1 /*
2  * Copyright (C) 2023 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 android.app.settings.SettingsEnums;
20 import android.content.Context;
21 import android.hardware.input.InputSettings;
22 
23 import com.android.settings.R;
24 import com.android.settings.core.TogglePreferenceController;
25 import com.android.settings.overlay.FeatureFactory;
26 import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
27 
28 public class TrackpadTapToClickPreferenceController extends TogglePreferenceController {
29 
30     private MetricsFeatureProvider mMetricsFeatureProvider;
31 
TrackpadTapToClickPreferenceController(Context context, String key)32     public TrackpadTapToClickPreferenceController(Context context, String key) {
33         super(context, key);
34         mMetricsFeatureProvider = FeatureFactory.getFeatureFactory().getMetricsFeatureProvider();
35     }
36 
37     @Override
isChecked()38     public boolean isChecked() {
39         return InputSettings.useTouchpadTapToClick(mContext);
40     }
41 
42     @Override
setChecked(boolean isChecked)43     public boolean setChecked(boolean isChecked) {
44         InputSettings.setTouchpadTapToClick(mContext, isChecked);
45         mMetricsFeatureProvider.action(
46                 mContext, SettingsEnums.ACTION_GESTURE_TAP_TO_CLICK_CHANGED, isChecked);
47         return true;
48     }
49 
50     @Override
getAvailabilityStatus()51     public int getAvailabilityStatus() {
52         return AVAILABLE;
53     }
54 
55     @Override
getSliceHighlightMenuRes()56     public int getSliceHighlightMenuRes() {
57         return R.string.menu_key_system;
58     }
59 }
60