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

Commit 8f5c95bc authored by Edward Savage-Jones's avatar Edward Savage-Jones Committed by Alison Cichowlas
Browse files

Add a longpress timeout config for screenshot chord

The global actions longpress timeout is currently used for the
screenshot chord. This means that increasing the globalactions
longpress timeout would also increase the time for triggering
a screenshot.

This adds a configuration item specifically for the screenshot
chord.

Bug: 119989329
Test: manual - increase the globalactions timeout and check that
               the screenshot chord is not affected.
Change-Id: I6bd8416f7546aa1d2da43f37f3e76edac3ed543b
parent dd07ae57
Loading
Loading
Loading
Loading
+23 −0
Original line number Diff line number Diff line
@@ -85,6 +85,12 @@ public class ViewConfiguration {
     */
    private static final int GLOBAL_ACTIONS_KEY_TIMEOUT = 500;

    /**
     * Defines the duration in milliseconds a user needs to hold down the
     * appropriate buttons (power + volume down) to trigger the screenshot chord.
     */
    private static final int SCREENSHOT_CHORD_KEY_TIMEOUT = 500;

    /**
     * Defines the duration in milliseconds a user needs to hold down the
     * appropriate button to bring up the accessibility shortcut for the first time
@@ -316,6 +322,7 @@ public class ViewConfiguration {
    private final float mVerticalScrollFactor;
    private final float mHorizontalScrollFactor;
    private final boolean mShowMenuShortcutsWhenKeyboardPresent;
    private final long mScreenshotChordKeyTimeout;

    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 123768915)
    private boolean sHasPermanentMenuKey;
@@ -353,6 +360,7 @@ public class ViewConfiguration {
        mHorizontalScrollFactor = HORIZONTAL_SCROLL_FACTOR;
        mVerticalScrollFactor = VERTICAL_SCROLL_FACTOR;
        mShowMenuShortcutsWhenKeyboardPresent = false;
        mScreenshotChordKeyTimeout = SCREENSHOT_CHORD_KEY_TIMEOUT;

        // Getter throws if mConstructedWithContext is false so doesn't matter what
        // this value is.
@@ -457,6 +465,9 @@ public class ViewConfiguration {

        mMinScalingSpan = res.getDimensionPixelSize(
                com.android.internal.R.dimen.config_minScalingSpan);

        mScreenshotChordKeyTimeout = res.getInteger(
                com.android.internal.R.integer.config_screenshotChordKeyTimeout);
    }

    /**
@@ -889,6 +900,18 @@ public class ViewConfiguration {
        return mGlobalActionsKeyTimeout;
    }

    /**
     * The amount of time a user needs to press the relevant keys to trigger
     * the screenshot chord.
     *
     * @return how long a user needs to press the relevant keys to trigger
     *   the screenshot chord.
     * @hide
     */
    public long getScreenshotChordKeyTimeout() {
        return mScreenshotChordKeyTimeout;
    }

    /**
     * The amount of time a user needs to press the relevant keys to activate the accessibility
     * shortcut.
+6 −1
Original line number Diff line number Diff line
@@ -2394,9 +2394,14 @@
    <!-- Maximum velocity to initiate a fling, as measured in dips per second. -->
    <dimen name="config_viewMaxFlingVelocity">8000dp</dimen>

    <!-- Amount of time in ms the user needs to press the relevant key to bring up the global actions dialog -->
    <!-- Amount of time in ms the user needs to press the relevant key to bring up the
         global actions dialog -->
    <integer name="config_globalActionsKeyTimeout">500</integer>

    <!-- Amount of time in ms the user needs to press the relevant keys to trigger the
         screenshot chord -->
    <integer name="config_screenshotChordKeyTimeout">500</integer>

    <!-- Default width of a vertical scrollbar and height of a horizontal scrollbar.
         Takes effect only if the scrollbar drawables have no intrinsic size. -->
    <dimen name="config_scrollbarSize">4dp</dimen>
+1 −0
Original line number Diff line number Diff line
@@ -2227,6 +2227,7 @@
  <java-symbol type="id" name="button_always" />
  <java-symbol type="id" name="button_app_settings" />
  <java-symbol type="integer" name="config_globalActionsKeyTimeout" />
  <java-symbol type="integer" name="config_screenshotChordKeyTimeout" />
  <java-symbol type="integer" name="config_maxResolverActivityColumns" />
  <java-symbol type="array" name="config_notificationSignalExtractors" />

+2 −2
Original line number Diff line number Diff line
@@ -1361,9 +1361,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        if (mKeyguardDelegate.isShowing()) {
            // Double the time it takes to take a screenshot from the keyguard
            return (long) (KEYGUARD_SCREENSHOT_CHORD_DELAY_MULTIPLIER *
                    ViewConfiguration.get(mContext).getDeviceGlobalActionKeyTimeout());
                    ViewConfiguration.get(mContext).getScreenshotChordKeyTimeout());
        }
        return ViewConfiguration.get(mContext).getDeviceGlobalActionKeyTimeout();
        return ViewConfiguration.get(mContext).getScreenshotChordKeyTimeout();
    }

    private long getRingerToggleChordDelay() {