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

Commit 91aff5cf authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Fix hold volume keys don't trigger the one handed mode in One-handed...

Merge "Fix hold volume keys don't trigger the one handed mode in One-handed mode settings page" into sc-v2-dev am: f761f2e1 am: 0c77283d

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/15297649

Change-Id: Ife7742eddb4fc4beab1b2cac33d9d6def442ec12
parents 26dbd9eb 0c77283d
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -93,7 +93,8 @@ public class OneHandedActionPullDownPrefController extends BasePreferenceControl
            return;
        }
        if (uri.equals(OneHandedSettingsUtils.ONE_HANDED_MODE_ENABLED_URI)
                || uri.equals(OneHandedSettingsUtils.SHORTCUT_ENABLED_URI)) {
                || uri.equals(OneHandedSettingsUtils.SOFTWARE_SHORTCUT_ENABLED_URI)
                || uri.equals(OneHandedSettingsUtils.HARDWARE_SHORTCUT_ENABLED_URI)) {
            mPreference.setEnabled(OneHandedSettingsUtils.canEnableController(mContext));
        } else if (uri.equals(OneHandedSettingsUtils.SHOW_NOTIFICATION_ENABLED_URI)) {
            updateState(mPreference);
+2 −1
Original line number Diff line number Diff line
@@ -93,7 +93,8 @@ public class OneHandedActionShowNotificationPrefController extends BasePreferenc
            return;
        }
        if (uri.equals(OneHandedSettingsUtils.ONE_HANDED_MODE_ENABLED_URI)
                || uri.equals(OneHandedSettingsUtils.SHORTCUT_ENABLED_URI)) {
                || uri.equals(OneHandedSettingsUtils.SOFTWARE_SHORTCUT_ENABLED_URI)
                || uri.equals(OneHandedSettingsUtils.HARDWARE_SHORTCUT_ENABLED_URI)) {
            mPreference.setEnabled(OneHandedSettingsUtils.canEnableController(mContext));
        } else if (uri.equals(OneHandedSettingsUtils.SHOW_NOTIFICATION_ENABLED_URI)) {
            updateState(mPreference);
+19 −4
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import android.os.Looper;
import android.os.SystemProperties;
import android.os.UserHandle;
import android.provider.Settings;
import android.text.TextUtils;

import androidx.annotation.VisibleForTesting;

@@ -45,8 +46,10 @@ public class OneHandedSettingsUtils {
            Settings.Secure.getUriFor(Settings.Secure.ONE_HANDED_MODE_ENABLED);
    static final Uri SHOW_NOTIFICATION_ENABLED_URI =
            Settings.Secure.getUriFor(Settings.Secure.SWIPE_BOTTOM_TO_NOTIFICATION_ENABLED);
    static final Uri SHORTCUT_ENABLED_URI =
    static final Uri SOFTWARE_SHORTCUT_ENABLED_URI =
            Settings.Secure.getUriFor(Settings.Secure.ACCESSIBILITY_BUTTON_TARGETS);
    static final Uri HARDWARE_SHORTCUT_ENABLED_URI =
            Settings.Secure.getUriFor(Settings.Secure.ACCESSIBILITY_SHORTCUT_TARGET_SERVICE);

    public enum OneHandedTimeout {
        NEVER(0), SHORT(4), MEDIUM(8), LONG(12);
@@ -238,9 +241,20 @@ public class OneHandedSettingsUtils {
     * @return true if user enabled one-handed shortcut in settings, false otherwise.
     */
    public static boolean getShortcutEnabled(Context context) {
        final String targets = Settings.Secure.getStringForUser(context.getContentResolver(),
        // Checks SOFTWARE_SHORTCUT_KEY
        final String targetsSW = Settings.Secure.getStringForUser(context.getContentResolver(),
                Settings.Secure.ACCESSIBILITY_BUTTON_TARGETS, sCurrentUserId);
        return targets != null ? targets.contains(ONE_HANDED_MODE_TARGET_NAME) : false;
        if (!TextUtils.isEmpty(targetsSW) && targetsSW.contains(ONE_HANDED_MODE_TARGET_NAME)) {
            return true;
        }

        // Checks HARDWARE_SHORTCUT_KEY
        final String targetsHW = Settings.Secure.getStringForUser(context.getContentResolver(),
                Settings.Secure.ACCESSIBILITY_SHORTCUT_TARGET_SERVICE, sCurrentUserId);
        if (!TextUtils.isEmpty(targetsHW) && targetsHW.contains(ONE_HANDED_MODE_TARGET_NAME)) {
            return true;
        }
        return false;
    }

    /**
@@ -285,7 +299,8 @@ public class OneHandedSettingsUtils {
            final ContentResolver resolver = mContext.getContentResolver();
            resolver.registerContentObserver(ONE_HANDED_MODE_ENABLED_URI, true, this);
            resolver.registerContentObserver(SHOW_NOTIFICATION_ENABLED_URI, true, this);
            resolver.registerContentObserver(SHORTCUT_ENABLED_URI, true, this);
            resolver.registerContentObserver(SOFTWARE_SHORTCUT_ENABLED_URI, true, this);
            resolver.registerContentObserver(HARDWARE_SHORTCUT_ENABLED_URI, true, this);
        }

        @Override