Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f7c021b0 authored by yyalan's avatar yyalan
Browse files

[Three Finger Tap] Hide Preference when flag is off

Bug: 414552525
Flag: com.android.settings.flags.three_finger_tap_app_launch
Test: With Flag Flipper
Change-Id: I94b31e9d2ac5633835688c6af2731cff7a4d825e
parent 6e0c26f1
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -46,6 +46,6 @@
        android:title="@string/three_finger_tap_launch_app_title"
        android:summary="@string/three_finger_tap_launch_app_summary"
        android:fragment="com.android.settings.inputmethod.TouchpadThreeFingerTapAppSelectionFragment"
        android:featureFlag="com.android.settings.flags.three_finger_tap_app_launch"/>
        settings:controller="com.android.settings.inputmethod.TouchpadThreeFingerTapAppLaunchPreferenceController"/>

</PreferenceScreen>
+1 −1
Original line number Diff line number Diff line
@@ -20,4 +20,4 @@
    android:key="input_touchpad_three_finger_tap"
    android:persistent="false"
    android:title="@string/three_finger_tap_launch_app_title"
    settings:controller="com.android.settings.inputmethod.TouchpadThreeFingerTapAppSelectionPreferenceController"/>
    settings:controller="com.android.settings.inputmethod.TouchpadThreeFingerTapAppListController"/>
+45 −0
Original line number Diff line number Diff line
/*
 * Copyright 2025 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.android.settings.flags.Flags.threeFingerTapAppLaunch;

import android.content.Context;
import android.hardware.input.InputSettings;

import androidx.annotation.NonNull;

import com.android.settings.core.BasePreferenceController;

/**
 * Controller that handles three finger tap app launching Preference's visibility based on the flag
 */
public class TouchpadThreeFingerTapAppLaunchPreferenceController extends BasePreferenceController {

    public TouchpadThreeFingerTapAppLaunchPreferenceController(@NonNull Context context,
            @NonNull String key) {
        super(context, key);
    }

    @Override
    public int getAvailabilityStatus() {
        boolean isTouchpad = InputPeripheralsSettingsUtils.isTouchpad();
        return (InputSettings.isTouchpadThreeFingerTapShortcutFeatureFlagEnabled()
                && threeFingerTapAppLaunch() && isTouchpad)
                ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
    }
}
+4 −4
Original line number Diff line number Diff line
@@ -53,11 +53,11 @@ import java.util.Comparator;
import java.util.List;

/**
 * Preference controller that updates a list of installed app Preferences.
 * Controller that updates a list of installed app Preferences.
 * This screen is a sub-page of {@link TouchpadThreeFingerTapPreferenceController}) allowing three
 * finger tap gesture to open the selected app.
 */
public class TouchpadThreeFingerTapAppSelectionPreferenceController extends BasePreferenceController
public class TouchpadThreeFingerTapAppListController extends BasePreferenceController
        implements LifecycleEventObserver, SelectorWithWidgetPreference.OnClickListener {

    private final ContentResolver mContentResolver;
@@ -113,7 +113,7 @@ public class TouchpadThreeFingerTapAppSelectionPreferenceController extends Base
        }
    };

    public TouchpadThreeFingerTapAppSelectionPreferenceController(@NonNull Context context,
    public TouchpadThreeFingerTapAppListController(@NonNull Context context,
            @NonNull String key) {
        super(context, key);
        mLauncherApps = context.getSystemService(LauncherApps.class);
@@ -123,7 +123,7 @@ public class TouchpadThreeFingerTapAppSelectionPreferenceController extends Base
    }

    @VisibleForTesting
    TouchpadThreeFingerTapAppSelectionPreferenceController(@NonNull Context context,
    TouchpadThreeFingerTapAppListController(@NonNull Context context,
            @NonNull String key,
            @NonNull LauncherApps launcherApps,
            @NonNull InputManager inputManager,
+3 −3
Original line number Diff line number Diff line
@@ -71,7 +71,7 @@ import java.util.List;
@Config(shadows = {
        ShadowSystemSettings.class,
})
public class TouchpadThreeFingerTapAppSelectionPreferenceControllerTest {
public class TouchpadThreeFingerTapAppListControllerTest {

    private static final String PREF_KEY = "testScreen";
    private static final String TEST_TITLE_PREFIX = "testTitle";
@@ -103,14 +103,14 @@ public class TouchpadThreeFingerTapAppSelectionPreferenceControllerTest {

    private final Context mContext = RuntimeEnvironment.application;
    private ContentResolver mContentResolver;
    private TouchpadThreeFingerTapAppSelectionPreferenceController mController;
    private TouchpadThreeFingerTapAppListController mController;
    private InputGestureData mCustomInputGesture;
    private LauncherApps.Callback mLauncherAppsCallback;

    @Before
    public void setup() {
        mContentResolver = mContext.getContentResolver();
        mController = new TouchpadThreeFingerTapAppSelectionPreferenceController(
        mController = new TouchpadThreeFingerTapAppListController(
                mContext, PREF_KEY, mMockLauncherApps, mMockInputManager, mMockContentObserver);
        setupMockLauncherApps();
        setupMockInputManager();