Merge "Touchpad: remove individual gesture settings" into main

This commit is contained in:
Treehugger Robot
2025-01-06 09:05:06 -08:00
committed by Android (Google) Code Review
23 changed files with 1 additions and 1264 deletions

View File

@@ -1,26 +0,0 @@
<!--
Copyright (C) 2019 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:autoMirrored="true"
android:tint="?android:attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M20,11H7.83l5.59-5.59L12,4l-8,8l8,8l1.41-1.41L7.83,13H20V11z" />
</vector>

View File

@@ -1,25 +0,0 @@
<!--
Copyright (C) 2022 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="48"
android:viewportHeight="48"
android:tint="?android:attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M11,39H18.5V26.5H29.5V39H37V19.5L24,9.75L11,19.5ZM8,42V18L24,6L40,18V42H26.5V29.5H21.5V42ZM24,24.35Z"/>
</vector>

View File

@@ -1,26 +0,0 @@
<!--
Copyright (C) 2017 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0"
android:tint="?android:attr/colorControlNormal">
<path
android:pathData="M18,17V11C18,7.93 16.37,5.36 13.5,4.68V4C13.5,3.17 12.83,2.5 12,2.5C11.17,2.5 10.5,3.17 10.5,4V4.68C7.64,5.36 6,7.92 6,11V17H4V19H14H14.38H20V17H18ZM16,17H8V11C8,8.52 9.51,6.5 12,6.5C14.49,6.5 16,8.52 16,11V17ZM14,20C14,21.1 13.1,22 12,22C10.9,22 10,21.1 10,20H14Z"
android:fillType="evenOdd"
android:fillColor="?android:attr/colorPrimary"/>
</vector>

View File

@@ -1,26 +0,0 @@
<!--
Copyright (C) 2017 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0"
android:tint="?android:attr/colorControlNormal">
<path
android:pathData="M16,6C16,7.1 16.9,8 18,8C19.1,8 20,7.1 20,6C20,4.9 19.1,4 18,4C16.9,4 16,4.9 16,6ZM6,8C7.1,8 8,7.1 8,6C8,4.9 7.1,4 6,4C4.9,4 4,4.9 4,6C4,7.1 4.9,8 6,8ZM12.001,20C13.101,20 14.001,19.1 14.001,18C14.001,16.9 13.101,16 12.001,16C10.901,16 10.001,16.9 10.001,18C10.001,19.1 10.901,20 12.001,20ZM8.001,18C8.001,19.1 7.101,20 6.001,20C4.901,20 4.001,19.1 4.001,18C4.001,16.9 4.901,16 6.001,16C7.101,16 8.001,16.9 8.001,18ZM6.001,14C7.101,14 8.001,13.1 8.001,12C8.001,10.9 7.101,10 6.001,10C4.901,10 4.001,10.9 4.001,12C4.001,13.1 4.901,14 6.001,14ZM14.001,12C14.001,13.1 13.101,14 12.001,14C10.901,14 10.001,13.1 10.001,12C10.001,10.9 10.901,10 12.001,10C13.101,10 14.001,10.9 14.001,12ZM14.001,6C14.001,7.1 13.101,8 12.001,8C10.901,8 10.001,7.1 10.001,6C10.001,4.9 10.901,4 12.001,4C13.101,4 14.001,4.9 14.001,6ZM18,14C19.1,14 20,13.1 20,12C20,10.9 19.1,10 18,10C16.9,10 16,10.9 16,12C16,13.1 16.9,14 18,14ZM20,18C20,19.1 19.1,20 18,20C16.9,20 16,19.1 16,18C16,16.9 16.9,16 18,16C19.1,16 20,16.9 20,18Z"
android:fillType="evenOdd"
android:fillColor="?android:attr/colorPrimary"/>
</vector>

View File

@@ -1,26 +0,0 @@
<!--
Copyright (C) 2022 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="48"
android:viewportHeight="48"
android:tint="?android:attr/colorControlNormal"
android:autoMirrored="true">
<path
android:fillColor="@android:color/white"
android:pathData="M15.85,40 L13.75,37.9 19.8,31.85H4V28.85H19.8L13.75,22.8L15.85,20.7L25.5,30.35ZM32.15,27.3 L22.5,17.65 32.15,8 34.25,10.1 28.2,16.15H44V19.15H28.2L34.25,25.2Z"/>
</vector>

View File

@@ -1,25 +0,0 @@
<!--
Copyright (C) 2022 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="48"
android:viewportHeight="48"
android:tint="?android:attr/textColorPrimaryInverse">
<path
android:fillColor="@android:color/white"
android:pathData="M40.15,47 L38.2,43.1 34.3,41.15 38.2,39.3 40.15,35.3 42,39.3 46,41.15 42,43.1ZM28.5,31.4Q28.5,31.4 28.5,31.4Q28.5,31.4 28.5,31.4Q28.5,31.4 28.5,31.4Q28.5,31.4 28.5,31.4Q28.5,31.4 28.5,31.4Q28.5,31.4 28.5,31.4Q28.5,31.4 28.5,31.4Q28.5,31.4 28.5,31.4Q28.5,31.4 28.5,31.4Q28.5,31.4 28.5,31.4Q28.5,31.4 28.5,31.4Q28.5,31.4 28.5,31.4Q28.5,31.4 28.5,31.4Q28.5,31.4 28.5,31.4Q28.5,31.4 28.5,31.4Q28.5,31.4 28.5,31.4Q28.5,31.4 28.5,31.4Q28.5,31.4 28.5,31.4Q28.5,31.4 28.5,31.4Q28.5,31.4 28.5,31.4Q28.5,31.4 28.5,31.4Q28.5,31.4 28.5,31.4Q28.5,31.4 28.5,31.4Q28.5,31.4 28.5,31.4Q28.5,31.4 28.5,31.4Q28.5,31.4 28.5,31.4ZM23.05,48H30.4L29.75,45H23.05Q22,45 20.975,44.8Q19.95,44.6 19.25,43.9L6.5,30.65L7.85,29.4L19.75,35.85V9.15Q19.75,8.6 20.1,8.25Q20.45,7.9 21,7.9Q21.55,7.9 21.9,8.25Q22.25,8.6 22.25,9.15V24H26V4.25Q26,3.7 26.35,3.35Q26.7,3 27.25,3Q27.8,3 28.15,3.35Q28.5,3.7 28.5,4.25V24H32.25V6.1Q32.25,5.55 32.6,5.2Q32.95,4.85 33.5,4.85Q34.05,4.85 34.4,5.2Q34.75,5.55 34.75,6.1V24H38.5V12.45Q38.5,11.9 38.85,11.55Q39.2,11.2 39.75,11.2Q40.3,11.2 40.65,11.55Q41,11.9 41,12.45V31.4H44V12.45Q44,10.7 42.75,9.45Q41.5,8.2 39.75,8.2Q39.2,8.2 38.675,8.3Q38.15,8.4 37.75,8.75V6.45Q37.75,4.55 36.525,3.2Q35.3,1.85 33.5,1.85Q32.85,1.85 32.25,2.025Q31.65,2.2 31.1,2.6Q30.65,1.4 29.625,0.7Q28.6,0 27.3,0Q25.55,0 24.275,1.25Q23,2.5 23,4.25V5.55Q22.6,5.2 22.075,5.05Q21.55,4.9 21,4.9Q19.25,4.9 18,6.15Q16.75,7.4 16.75,9.15V30.95L8.85,26.5Q8,26.05 7.1,26.325Q6.2,26.6 5.5,27.25L2,30.3L16.85,45.7Q18.05,46.95 19.675,47.475Q21.3,48 23.05,48ZM6.85,14.8 L5.15,11.15 1.5,9.45 5.15,7.75 6.85,4.1 8.55,7.7 12.2,9.6 8.6,11.15Z"/>
</vector>

View File

@@ -4726,10 +4726,6 @@
<string name="trackpad_tap_dragging_title">Tap dragging</string>
<!-- Summary text for 'Tap dragging', a touchpad setting which allows dragging of UI elements by tapping the touchpad with a single finger and then moving it. [CHAR LIMIT=60] -->
<string name="trackpad_tap_dragging_summary">Tap and drag your finger on the touchpad to move objects</string>
<!-- Title text for 'Touchpad gestures' [CHAR LIMIT=35] -->
<string name="trackpad_touchpad_gesture_title">Touchpad gestures</string>
<!-- Summary text for 'Touchpad gestures' [CHAR LIMIT=60] -->
<string name="trackpad_touchpad_gesture_summary">Customize individual touchpad navigation gestures</string>
<!-- Title text for 'Reverse scrolling' [CHAR LIMIT=35] -->
<string name="trackpad_reverse_scrolling_title">Reverse scrolling</string>
<!-- Summary text for 'Reverse scrolling' [CHAR LIMIT=60] -->
@@ -4814,27 +4810,6 @@
<!-- Text for 'Done' button in gesture education [CHAR LIMIT=10] -->
<string name="gesture_button_done">Done</string>
<!-- Title text for 'Go back' [CHAR LIMIT=35] -->
<string name="trackpad_go_back_title">Go back</string>
<!-- Summary text for 'Go back' [CHAR LIMIT=60] -->
<string name="trackpad_go_back_summary">Swipe left or right with three fingers</string>
<!-- Title text for 'Go home' [CHAR LIMIT=35] -->
<string name="trackpad_go_home_title">Go home</string>
<!-- Summary text for 'Go home' [CHAR LIMIT=60] -->
<string name="trackpad_go_home_summary">Swipe up with three fingers</string>
<!-- Title text for 'Recent apps' [CHAR LIMIT=35] -->
<string name="trackpad_recent_apps_title">Recent apps</string>
<!-- Summary text for 'Recent apps' [CHAR LIMIT=60] -->
<string name="trackpad_recent_apps_summary">Swipe up with three fingers, then hold</string>
<!-- Title text for 'Notifications' [CHAR LIMIT=35] -->
<string name="trackpad_notifications_title">Notifications</string>
<!-- Summary text for 'Notifications' [CHAR LIMIT=60] -->
<string name="trackpad_notifications_summary">Swipe down with three fingers</string>
<!-- Title text for 'Switch apps' [CHAR LIMIT=35] -->
<string name="trackpad_switch_apps_title">Switch apps</string>
<!-- Summary text for 'Switch apps' [CHAR LIMIT=60] -->
<string name="trackpad_switch_apps_summary">Swipe left or right with four fingers</string>
<!-- Title for the button to trigger the 'modifier keys settings' page. [CHAR LIMIT=35] -->
<string name="modifier_keys_settings">Modifier keys</string>
<!-- Summary text for the 'modifier_keys_settings' page. [CHAR LIMIT=100] -->

View File

@@ -19,14 +19,6 @@
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
android:title="@string/trackpad_mouse_settings">
<Preference
android:key="trackpad_gesture_settings"
android:title="@string/trackpad_touchpad_gesture_title"
android:summary="@string/trackpad_touchpad_gesture_summary"
android:order="-10"
android:fragment="com.android.settings.inputmethod.TrackpadTouchGestureSettings"
settings:controller="com.android.settings.inputmethod.TrackpadTouchGestureSettingsController"/>
<SwitchPreferenceCompat
android:key="trackpad_tap_to_click"
android:title="@string/trackpad_tap_to_click"

View File

@@ -19,14 +19,6 @@
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
android:title="@string/trackpad_settings">
<Preference
android:key="trackpad_gesture_settings"
android:title="@string/trackpad_touchpad_gesture_title"
android:summary="@string/trackpad_touchpad_gesture_summary"
android:order="-10"
android:fragment="com.android.settings.inputmethod.TrackpadTouchGestureSettings"
settings:controller="com.android.settings.inputmethod.TrackpadTouchGestureSettingsController"/>
<SwitchPreferenceCompat
android:key="trackpad_tap_to_click"
android:title="@string/trackpad_tap_to_click"

View File

@@ -1,68 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2022 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
android:title="@string/trackpad_touchpad_gesture_title">
<SwitchPreferenceCompat
android:key="gesture_go_back"
android:title="@string/trackpad_go_back_title"
android:summary="@string/trackpad_go_back_summary"
android:icon="@drawable/ic_trackpad_gesture_back"
android:order="10"
settings:controller="com.android.settings.inputmethod.TrackpadGoBackPreferenceController"/>
<SwitchPreferenceCompat
android:key="gesture_go_home"
android:title="@string/trackpad_go_home_title"
android:summary="@string/trackpad_go_home_summary"
android:icon="@drawable/ic_trackpad_gesture_home"
android:order="20"
settings:controller="com.android.settings.inputmethod.TrackpadGoHomePreferenceController"/>
<SwitchPreferenceCompat
android:key="gesture_recent_apps"
android:title="@string/trackpad_recent_apps_title"
android:summary="@string/trackpad_recent_apps_summary"
android:icon="@drawable/ic_trackpad_gesture_recent_apps"
android:order="30"
settings:controller="com.android.settings.inputmethod.TrackpadRecentAppsPreferenceController"/>
<SwitchPreferenceCompat
android:key="gesture_notifications"
android:title="@string/trackpad_notifications_title"
android:summary="@string/trackpad_notifications_summary"
android:icon="@drawable/ic_trackpad_gesture_notifications"
android:order="40"
settings:controller="com.android.settings.inputmethod.TrackpadNotificationsPreferenceController"/>
<SwitchPreferenceCompat
android:key="gesture_switch_apps"
android:title="@string/trackpad_switch_apps_title"
android:summary="@string/trackpad_switch_apps_summary"
android:icon="@drawable/ic_trackpad_gesture_switch_apps"
android:order="50"
settings:controller="com.android.settings.inputmethod.TrackpadSwitchAppsPreferenceController"/>
<com.android.settingslib.widget.ButtonPreference
android:key="trackpad_touch_gesture_developer_mode"
android:title="@string/trackpad_touch_gesture"
android:icon="@drawable/ic_trackpad_touch_gestures_inverse"
android:order="100"
settings:controller="com.android.settings.inputmethod.TouchGesturesButtonPreferenceController"/>
</PreferenceScreen>

View File

@@ -23,7 +23,6 @@ import android.content.Context;
import android.content.Intent;
import android.hardware.input.InputSettings;
import android.os.UserHandle;
import android.util.FeatureFlagUtils;
import androidx.fragment.app.Fragment;
import androidx.preference.PreferenceScreen;
@@ -36,7 +35,6 @@ import com.android.settingslib.widget.ButtonPreference;
public class TouchGesturesButtonPreferenceController extends BasePreferenceController {
private static final int ORDER_TOP = 0;
private static final int ORDER_BOTTOM = 100;
private static final String PREFERENCE_KEY = "trackpad_touch_gesture";
private static final String GESTURE_DIALOG_TAG = "GESTURE_DIALOG_TAG";
@@ -59,14 +57,8 @@ public class TouchGesturesButtonPreferenceController extends BasePreferenceContr
super.displayPreference(screen);
ButtonPreference buttonPreference =
(ButtonPreference) screen.findPreference(getPreferenceKey());
boolean touchGestureDeveloperMode = FeatureFlagUtils
.isEnabled(mContext, FeatureFlagUtils.SETTINGS_NEW_KEYBOARD_TRACKPAD_GESTURE);
if (getPreferenceKey().equals(PREFERENCE_KEY)) {
if (touchGestureDeveloperMode) {
buttonPreference.setOrder(ORDER_TOP);
} else {
buttonPreference.setOrder(ORDER_BOTTOM);
}
buttonPreference.setOrder(ORDER_BOTTOM);
}
buttonPreference.setOnClickListener(v -> {
showTouchpadGestureEducation();

View File

@@ -1,61 +0,0 @@
/*
* Copyright (C) 2023 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings.inputmethod;
import android.app.settings.SettingsEnums;
import android.content.Context;
import android.provider.Settings;
import com.android.settings.R;
import com.android.settings.core.TogglePreferenceController;
import com.android.settings.overlay.FeatureFactory;
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
public class TrackpadGoBackPreferenceController extends TogglePreferenceController {
private static final String SETTING_KEY = Settings.Secure.TRACKPAD_GESTURE_BACK_ENABLED;
private MetricsFeatureProvider mMetricsFeatureProvider;
public TrackpadGoBackPreferenceController(Context context, String key) {
super(context, key);
mMetricsFeatureProvider = FeatureFactory.getFeatureFactory().getMetricsFeatureProvider();
}
@Override
public boolean isChecked() {
return Settings.Secure.getInt(mContext.getContentResolver(), SETTING_KEY, 1) != 0;
}
@Override
public boolean setChecked(boolean isChecked) {
Settings.Secure.putInt(mContext.getContentResolver(), SETTING_KEY, isChecked ? 1 : 0);
mMetricsFeatureProvider.action(
mContext, SettingsEnums.ACTION_GESTURE_GO_BACK_CHANGED, isChecked);
return true;
}
@Override
public int getAvailabilityStatus() {
return AVAILABLE;
}
@Override
public int getSliceHighlightMenuRes() {
return R.string.menu_key_system;
}
}

View File

@@ -1,61 +0,0 @@
/*
* Copyright (C) 2023 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings.inputmethod;
import android.app.settings.SettingsEnums;
import android.content.Context;
import android.provider.Settings;
import com.android.settings.R;
import com.android.settings.core.TogglePreferenceController;
import com.android.settings.overlay.FeatureFactory;
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
public class TrackpadGoHomePreferenceController extends TogglePreferenceController {
private static final String SETTING_KEY = Settings.Secure.TRACKPAD_GESTURE_HOME_ENABLED;
private MetricsFeatureProvider mMetricsFeatureProvider;
public TrackpadGoHomePreferenceController(Context context, String key) {
super(context, key);
mMetricsFeatureProvider = FeatureFactory.getFeatureFactory().getMetricsFeatureProvider();
}
@Override
public boolean isChecked() {
return Settings.Secure.getInt(mContext.getContentResolver(), SETTING_KEY, 1) != 0;
}
@Override
public boolean setChecked(boolean isChecked) {
Settings.Secure.putInt(mContext.getContentResolver(), SETTING_KEY, isChecked ? 1 : 0);
mMetricsFeatureProvider.action(
mContext, SettingsEnums.ACTION_GESTURE_GO_HOME_CHANGED, isChecked);
return true;
}
@Override
public int getAvailabilityStatus() {
return AVAILABLE;
}
@Override
public int getSliceHighlightMenuRes() {
return R.string.menu_key_system;
}
}

View File

@@ -1,61 +0,0 @@
/*
* Copyright (C) 2023 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings.inputmethod;
import android.app.settings.SettingsEnums;
import android.content.Context;
import android.provider.Settings;
import com.android.settings.R;
import com.android.settings.core.TogglePreferenceController;
import com.android.settings.overlay.FeatureFactory;
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
public class TrackpadNotificationsPreferenceController extends TogglePreferenceController {
private static final String SETTING_KEY = Settings.Secure.TRACKPAD_GESTURE_NOTIFICATION_ENABLED;
private MetricsFeatureProvider mMetricsFeatureProvider;
public TrackpadNotificationsPreferenceController(Context context, String key) {
super(context, key);
mMetricsFeatureProvider = FeatureFactory.getFeatureFactory().getMetricsFeatureProvider();
}
@Override
public boolean isChecked() {
return Settings.Secure.getInt(mContext.getContentResolver(), SETTING_KEY, 1) != 0;
}
@Override
public boolean setChecked(boolean isChecked) {
Settings.Secure.putInt(mContext.getContentResolver(), SETTING_KEY, isChecked ? 1 : 0);
mMetricsFeatureProvider.action(
mContext, SettingsEnums.ACTION_GESTURE_NOTIFICATION_CHANGED, isChecked);
return true;
}
@Override
public int getAvailabilityStatus() {
return AVAILABLE;
}
@Override
public int getSliceHighlightMenuRes() {
return R.string.menu_key_system;
}
}

View File

@@ -1,61 +0,0 @@
/*
* Copyright (C) 2023 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings.inputmethod;
import android.app.settings.SettingsEnums;
import android.content.Context;
import android.provider.Settings;
import com.android.settings.R;
import com.android.settings.core.TogglePreferenceController;
import com.android.settings.overlay.FeatureFactory;
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
public class TrackpadRecentAppsPreferenceController extends TogglePreferenceController {
private static final String SETTING_KEY = Settings.Secure.TRACKPAD_GESTURE_OVERVIEW_ENABLED;
private MetricsFeatureProvider mMetricsFeatureProvider;
public TrackpadRecentAppsPreferenceController(Context context, String key) {
super(context, key);
mMetricsFeatureProvider = FeatureFactory.getFeatureFactory().getMetricsFeatureProvider();
}
@Override
public boolean isChecked() {
return Settings.Secure.getInt(mContext.getContentResolver(), SETTING_KEY, 1) != 0;
}
@Override
public boolean setChecked(boolean isChecked) {
Settings.Secure.putInt(mContext.getContentResolver(), SETTING_KEY, isChecked ? 1 : 0);
mMetricsFeatureProvider.action(
mContext, SettingsEnums.ACTION_GESTURE_RECENT_APPS_CHANGED, isChecked);
return true;
}
@Override
public int getAvailabilityStatus() {
return AVAILABLE;
}
@Override
public int getSliceHighlightMenuRes() {
return R.string.menu_key_system;
}
}

View File

@@ -1,61 +0,0 @@
/*
* Copyright (C) 2023 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings.inputmethod;
import android.app.settings.SettingsEnums;
import android.content.Context;
import android.provider.Settings;
import com.android.settings.R;
import com.android.settings.core.TogglePreferenceController;
import com.android.settings.overlay.FeatureFactory;
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
public class TrackpadSwitchAppsPreferenceController extends TogglePreferenceController {
private static final String SETTING_KEY = Settings.Secure.TRACKPAD_GESTURE_QUICK_SWITCH_ENABLED;
private MetricsFeatureProvider mMetricsFeatureProvider;
public TrackpadSwitchAppsPreferenceController(Context context, String key) {
super(context, key);
mMetricsFeatureProvider = FeatureFactory.getFeatureFactory().getMetricsFeatureProvider();
}
@Override
public boolean isChecked() {
return Settings.Secure.getInt(mContext.getContentResolver(), SETTING_KEY, 1) != 0;
}
@Override
public boolean setChecked(boolean isChecked) {
Settings.Secure.putInt(mContext.getContentResolver(), SETTING_KEY, isChecked ? 1 : 0);
mMetricsFeatureProvider.action(
mContext, SettingsEnums.ACTION_GESTURE_SWITCH_APPS_CHANGED, isChecked);
return true;
}
@Override
public int getAvailabilityStatus() {
return AVAILABLE;
}
@Override
public int getSliceHighlightMenuRes() {
return R.string.menu_key_system;
}
}

View File

@@ -1,65 +0,0 @@
/*
* Copyright (C) 2022 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings.inputmethod;
import android.app.settings.SettingsEnums;
import android.content.Context;
import android.util.FeatureFlagUtils;
import com.android.settings.R;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settingslib.search.SearchIndexable;
@SearchIndexable
public class TrackpadTouchGestureSettings extends DashboardFragment {
private static final String TAG = "TrackpadTouchGestureSettings";
@Override
public void onAttach(Context context) {
super.onAttach(context);
use(TouchGesturesButtonPreferenceController.class).setFragment(this /*parent*/);
}
@Override
public int getMetricsCategory() {
return SettingsEnums.SETTINGS_KEYBOARDS_TOUCHPAD_GESTURE;
}
@Override
protected String getLogTag() {
return TAG;
}
@Override
protected int getPreferenceScreenResId() {
return R.xml.trackpad_gesture_settings;
}
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
new BaseSearchIndexProvider(R.xml.trackpad_gesture_settings) {
@Override
protected boolean isPageSearchEnabled(Context context) {
return FeatureFlagUtils
.isEnabled(
context,
FeatureFlagUtils.SETTINGS_NEW_KEYBOARD_TRACKPAD_GESTURE)
&& InputPeripheralsSettingsUtils.isTouchpad();
}
};
}

View File

@@ -1,37 +0,0 @@
/*
* Copyright (C) 2022 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings.inputmethod;
import android.content.Context;
import android.util.FeatureFlagUtils;
import com.android.settings.core.BasePreferenceController;
public class TrackpadTouchGestureSettingsController extends BasePreferenceController {
public TrackpadTouchGestureSettingsController(Context context, String key) {
super(context, key);
}
@Override
public int getAvailabilityStatus() {
boolean isFeatureOn = FeatureFlagUtils
.isEnabled(mContext, FeatureFlagUtils.SETTINGS_NEW_KEYBOARD_TRACKPAD_GESTURE);
boolean isTouchpad = InputPeripheralsSettingsUtils.isTouchpad();
return (isFeatureOn && isTouchpad) ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
}
}

View File

@@ -1,117 +0,0 @@
/*
* Copyright (C) 2023 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings.inputmethod;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.verify;
import android.app.settings.SettingsEnums;
import android.content.Context;
import android.provider.Settings;
import androidx.test.core.app.ApplicationProvider;
import com.android.settings.R;
import com.android.settings.core.BasePreferenceController;
import com.android.settings.testutils.FakeFeatureFactory;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.junit.MockitoJUnit;
import org.mockito.junit.MockitoRule;
import org.robolectric.RobolectricTestRunner;
/** Tests for {@link TrackpadGoBackPreferenceController} */
@RunWith(RobolectricTestRunner.class)
public class TrackpadGoBackPreferenceControllerTest {
@Rule
public MockitoRule rule = MockitoJUnit.rule();
private static final String PREFERENCE_KEY = "gesture_go_back";
private static final String SETTING_KEY = Settings.Secure.TRACKPAD_GESTURE_BACK_ENABLED;
private Context mContext;
private TrackpadGoBackPreferenceController mController;
private FakeFeatureFactory mFeatureFactory;
@Before
public void setUp() {
mContext = ApplicationProvider.getApplicationContext();
mFeatureFactory = FakeFeatureFactory.setupForTest();
mController = new TrackpadGoBackPreferenceController(mContext, PREFERENCE_KEY);
}
@Test
public void getAvailabilityStatus_expected() {
assertThat(mController.getAvailabilityStatus())
.isEqualTo(BasePreferenceController.AVAILABLE);
}
@Test
public void getSliceHighlightMenuRes_expected() {
assertThat(mController.getSliceHighlightMenuRes()).isEqualTo(R.string.menu_key_system);
}
@Test
public void setChecked_true_shouldReturn1() {
mController.setChecked(true);
int result = Settings.Secure.getInt(mContext.getContentResolver(), SETTING_KEY, 1);
assertThat(result).isEqualTo(1);
verify(mFeatureFactory.metricsFeatureProvider).action(
any(),
eq(SettingsEnums.ACTION_GESTURE_GO_BACK_CHANGED),
eq(true));
}
@Test
public void setChecked_false_shouldReturn0() {
mController.setChecked(false);
int result = Settings.Secure.getInt(mContext.getContentResolver(), SETTING_KEY, 1);
assertThat(result).isEqualTo(0);
verify(mFeatureFactory.metricsFeatureProvider).action(
any(),
eq(SettingsEnums.ACTION_GESTURE_GO_BACK_CHANGED),
eq(false));
}
@Test
public void isChecked_providerPutInt1_returnTrue() {
Settings.Secure.putInt(mContext.getContentResolver(), SETTING_KEY, 1);
boolean result = mController.isChecked();
assertThat(result).isTrue();
}
@Test
public void isChecked_providerPutInt0_returnFalse() {
Settings.Secure.putInt(mContext.getContentResolver(), SETTING_KEY, 0);
boolean result = mController.isChecked();
assertThat(result).isFalse();
}
}

View File

@@ -1,117 +0,0 @@
/*
* Copyright (C) 2023 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings.inputmethod;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.verify;
import android.app.settings.SettingsEnums;
import android.content.Context;
import android.provider.Settings;
import androidx.test.core.app.ApplicationProvider;
import com.android.settings.R;
import com.android.settings.core.BasePreferenceController;
import com.android.settings.testutils.FakeFeatureFactory;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.junit.MockitoJUnit;
import org.mockito.junit.MockitoRule;
import org.robolectric.RobolectricTestRunner;
/** Tests for {@link TrackpadGoHomePreferenceController} */
@RunWith(RobolectricTestRunner.class)
public class TrackpadGoHomePreferenceControllerTest {
@Rule
public MockitoRule rule = MockitoJUnit.rule();
private static final String PREFERENCE_KEY = "gesture_go_home";
private static final String SETTING_KEY = Settings.Secure.TRACKPAD_GESTURE_HOME_ENABLED;
private Context mContext;
private TrackpadGoHomePreferenceController mController;
private FakeFeatureFactory mFeatureFactory;
@Before
public void setUp() {
mContext = ApplicationProvider.getApplicationContext();
mFeatureFactory = FakeFeatureFactory.setupForTest();
mController = new TrackpadGoHomePreferenceController(mContext, PREFERENCE_KEY);
}
@Test
public void getAvailabilityStatus_expected() {
assertThat(mController.getAvailabilityStatus())
.isEqualTo(BasePreferenceController.AVAILABLE);
}
@Test
public void getSliceHighlightMenuRes_expected() {
assertThat(mController.getSliceHighlightMenuRes()).isEqualTo(R.string.menu_key_system);
}
@Test
public void setChecked_true_shouldReturn1() {
mController.setChecked(true);
int result = Settings.Secure.getInt(mContext.getContentResolver(), SETTING_KEY, 1);
assertThat(result).isEqualTo(1);
verify(mFeatureFactory.metricsFeatureProvider).action(
any(),
eq(SettingsEnums.ACTION_GESTURE_GO_HOME_CHANGED),
eq(true));
}
@Test
public void setChecked_false_shouldReturn0() {
mController.setChecked(false);
int result = Settings.Secure.getInt(mContext.getContentResolver(), SETTING_KEY, 1);
assertThat(result).isEqualTo(0);
verify(mFeatureFactory.metricsFeatureProvider).action(
any(),
eq(SettingsEnums.ACTION_GESTURE_GO_HOME_CHANGED),
eq(false));
}
@Test
public void isChecked_providerPutInt1_returnTrue() {
Settings.Secure.putInt(mContext.getContentResolver(), SETTING_KEY, 1);
boolean result = mController.isChecked();
assertThat(result).isTrue();
}
@Test
public void isChecked_providerPutInt0_returnFalse() {
Settings.Secure.putInt(mContext.getContentResolver(), SETTING_KEY, 0);
boolean result = mController.isChecked();
assertThat(result).isFalse();
}
}

View File

@@ -1,117 +0,0 @@
/*
* Copyright (C) 2023 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings.inputmethod;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.verify;
import android.app.settings.SettingsEnums;
import android.content.Context;
import android.provider.Settings;
import androidx.test.core.app.ApplicationProvider;
import com.android.settings.R;
import com.android.settings.core.BasePreferenceController;
import com.android.settings.testutils.FakeFeatureFactory;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.junit.MockitoJUnit;
import org.mockito.junit.MockitoRule;
import org.robolectric.RobolectricTestRunner;
/** Tests for {@link TrackpadNotificationsPreferenceController} */
@RunWith(RobolectricTestRunner.class)
public class TrackpadNotificationsPreferenceControllerTest {
@Rule
public MockitoRule rule = MockitoJUnit.rule();
private static final String PREFERENCE_KEY = "gesture_notifications";
private static final String SETTING_KEY = Settings.Secure.TRACKPAD_GESTURE_NOTIFICATION_ENABLED;
private Context mContext;
private TrackpadNotificationsPreferenceController mController;
private FakeFeatureFactory mFeatureFactory;
@Before
public void setUp() {
mContext = ApplicationProvider.getApplicationContext();
mFeatureFactory = FakeFeatureFactory.setupForTest();
mController = new TrackpadNotificationsPreferenceController(mContext, PREFERENCE_KEY);
}
@Test
public void getAvailabilityStatus_expected() {
assertThat(mController.getAvailabilityStatus())
.isEqualTo(BasePreferenceController.AVAILABLE);
}
@Test
public void getSliceHighlightMenuRes_expected() {
assertThat(mController.getSliceHighlightMenuRes()).isEqualTo(R.string.menu_key_system);
}
@Test
public void setChecked_true_shouldReturn1() {
mController.setChecked(true);
int result = Settings.Secure.getInt(mContext.getContentResolver(), SETTING_KEY, 1);
assertThat(result).isEqualTo(1);
verify(mFeatureFactory.metricsFeatureProvider).action(
any(),
eq(SettingsEnums.ACTION_GESTURE_NOTIFICATION_CHANGED),
eq(true));
}
@Test
public void setChecked_false_shouldReturn0() {
mController.setChecked(false);
int result = Settings.Secure.getInt(mContext.getContentResolver(), SETTING_KEY, 1);
assertThat(result).isEqualTo(0);
verify(mFeatureFactory.metricsFeatureProvider).action(
any(),
eq(SettingsEnums.ACTION_GESTURE_NOTIFICATION_CHANGED),
eq(false));
}
@Test
public void isChecked_providerPutInt1_returnTrue() {
Settings.Secure.putInt(mContext.getContentResolver(), SETTING_KEY, 1);
boolean result = mController.isChecked();
assertThat(result).isTrue();
}
@Test
public void isChecked_providerPutInt0_returnFalse() {
Settings.Secure.putInt(mContext.getContentResolver(), SETTING_KEY, 0);
boolean result = mController.isChecked();
assertThat(result).isFalse();
}
}

View File

@@ -1,117 +0,0 @@
/*
* Copyright (C) 2023 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings.inputmethod;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.verify;
import android.app.settings.SettingsEnums;
import android.content.Context;
import android.provider.Settings;
import androidx.test.core.app.ApplicationProvider;
import com.android.settings.R;
import com.android.settings.core.BasePreferenceController;
import com.android.settings.testutils.FakeFeatureFactory;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.junit.MockitoJUnit;
import org.mockito.junit.MockitoRule;
import org.robolectric.RobolectricTestRunner;
/** Tests for {@link TrackpadRecentAppsPreferenceController} */
@RunWith(RobolectricTestRunner.class)
public class TrackpadRecentAppsPreferenceControllerTest {
@Rule
public MockitoRule rule = MockitoJUnit.rule();
private static final String PREFERENCE_KEY = "gesture_recent_apps";
private static final String SETTING_KEY = Settings.Secure.TRACKPAD_GESTURE_OVERVIEW_ENABLED;
private Context mContext;
private TrackpadRecentAppsPreferenceController mController;
private FakeFeatureFactory mFeatureFactory;
@Before
public void setUp() {
mContext = ApplicationProvider.getApplicationContext();
mFeatureFactory = FakeFeatureFactory.setupForTest();
mController = new TrackpadRecentAppsPreferenceController(mContext, PREFERENCE_KEY);
}
@Test
public void getAvailabilityStatus_expected() {
assertThat(mController.getAvailabilityStatus())
.isEqualTo(BasePreferenceController.AVAILABLE);
}
@Test
public void getSliceHighlightMenuRes_expected() {
assertThat(mController.getSliceHighlightMenuRes()).isEqualTo(R.string.menu_key_system);
}
@Test
public void setChecked_true_shouldReturn1() {
mController.setChecked(true);
int result = Settings.Secure.getInt(mContext.getContentResolver(), SETTING_KEY, 1);
assertThat(result).isEqualTo(1);
verify(mFeatureFactory.metricsFeatureProvider).action(
any(),
eq(SettingsEnums.ACTION_GESTURE_RECENT_APPS_CHANGED),
eq(true));
}
@Test
public void setChecked_false_shouldReturn0() {
mController.setChecked(false);
int result = Settings.Secure.getInt(mContext.getContentResolver(), SETTING_KEY, 1);
assertThat(result).isEqualTo(0);
verify(mFeatureFactory.metricsFeatureProvider).action(
any(),
eq(SettingsEnums.ACTION_GESTURE_RECENT_APPS_CHANGED),
eq(false));
}
@Test
public void isChecked_providerPutInt1_returnTrue() {
Settings.Secure.putInt(mContext.getContentResolver(), SETTING_KEY, 1);
boolean result = mController.isChecked();
assertThat(result).isTrue();
}
@Test
public void isChecked_providerPutInt0_returnFalse() {
Settings.Secure.putInt(mContext.getContentResolver(), SETTING_KEY, 0);
boolean result = mController.isChecked();
assertThat(result).isFalse();
}
}

View File

@@ -1,117 +0,0 @@
/*
* Copyright (C) 2023 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings.inputmethod;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.verify;
import android.app.settings.SettingsEnums;
import android.content.Context;
import android.provider.Settings;
import androidx.test.core.app.ApplicationProvider;
import com.android.settings.R;
import com.android.settings.core.BasePreferenceController;
import com.android.settings.testutils.FakeFeatureFactory;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.junit.MockitoJUnit;
import org.mockito.junit.MockitoRule;
import org.robolectric.RobolectricTestRunner;
/** Tests for {@link TrackpadSwitchAppsPreferenceController} */
@RunWith(RobolectricTestRunner.class)
public class TrackpadSwitchAppsPreferenceControllerTest {
@Rule
public MockitoRule rule = MockitoJUnit.rule();
private static final String PREFERENCE_KEY = "gesture_switch_apps";
private static final String SETTING_KEY = Settings.Secure.TRACKPAD_GESTURE_QUICK_SWITCH_ENABLED;
private Context mContext;
private TrackpadSwitchAppsPreferenceController mController;
private FakeFeatureFactory mFeatureFactory;
@Before
public void setUp() {
mContext = ApplicationProvider.getApplicationContext();
mFeatureFactory = FakeFeatureFactory.setupForTest();
mController = new TrackpadSwitchAppsPreferenceController(mContext, PREFERENCE_KEY);
}
@Test
public void getAvailabilityStatus_expected() {
assertThat(mController.getAvailabilityStatus())
.isEqualTo(BasePreferenceController.AVAILABLE);
}
@Test
public void getSliceHighlightMenuRes_expected() {
assertThat(mController.getSliceHighlightMenuRes()).isEqualTo(R.string.menu_key_system);
}
@Test
public void setChecked_true_shouldReturn1() {
mController.setChecked(true);
int result = Settings.Secure.getInt(mContext.getContentResolver(), SETTING_KEY, 1);
assertThat(result).isEqualTo(1);
verify(mFeatureFactory.metricsFeatureProvider).action(
any(),
eq(SettingsEnums.ACTION_GESTURE_SWITCH_APPS_CHANGED),
eq(true));
}
@Test
public void setChecked_false_shouldReturn0() {
mController.setChecked(false);
int result = Settings.Secure.getInt(mContext.getContentResolver(), SETTING_KEY, 1);
assertThat(result).isEqualTo(0);
verify(mFeatureFactory.metricsFeatureProvider).action(
any(),
eq(SettingsEnums.ACTION_GESTURE_SWITCH_APPS_CHANGED),
eq(false));
}
@Test
public void isChecked_providerPutInt1_returnTrue() {
Settings.Secure.putInt(mContext.getContentResolver(), SETTING_KEY, 1);
boolean result = mController.isChecked();
assertThat(result).isTrue();
}
@Test
public void isChecked_providerPutInt0_returnFalse() {
Settings.Secure.putInt(mContext.getContentResolver(), SETTING_KEY, 0);
boolean result = mController.isChecked();
assertThat(result).isFalse();
}
}