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

Commit 09526dd5 authored by Jesse Chan's avatar Jesse Chan Committed by LuK1337
Browse files

Implement click to take partial screenshot [1/3]



Default to the old long press behaviour when the feature is enabled.

Change-Id: I5fc37f818b06db2bd2d315cffee2041a740781ed
Signed-off-by: default avatarJesse Chan <jc@lineageos.org>
parent 3028f2a3
Loading
Loading
Loading
Loading
+19 −2
Original line number Diff line number Diff line
@@ -553,6 +553,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {

    boolean mVolumeAnswerCall;

    // Click volume down + power for partial screenshot
    boolean mClickPartialScreenshot;

    private boolean mPendingKeyguardOccluded;
    private boolean mKeyguardOccludedChanged;

@@ -910,6 +913,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            resolver.registerContentObserver(LineageSettings.System.getUriFor(
                    LineageSettings.System.VOLUME_ANSWER_CALL), false, this,
                    UserHandle.USER_ALL);
            resolver.registerContentObserver(LineageSettings.System.getUriFor(
                    LineageSettings.System.CLICK_PARTIAL_SCREENSHOT), false, this,
                    UserHandle.USER_ALL);

            updateSettings();
        }
@@ -1441,9 +1447,11 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    }

    private long getScreenshotChordLongPressDelay() {
        long delayMs = DeviceConfig.getLong(
        // If click to partial screenshot is enabled, restore pre Android QPR1
        // default delay (500ms) in case SCREENSHOT_KEYCHORD_DELAY is shorter than it.
        long delayMs = Long.max(mClickPartialScreenshot ? 500 : 0, DeviceConfig.getLong(
                DeviceConfig.NAMESPACE_SYSTEMUI, SCREENSHOT_KEYCHORD_DELAY,
                ViewConfiguration.get(mContext).getScreenshotChordKeyTimeout());
                ViewConfiguration.get(mContext).getScreenshotChordKeyTimeout()));
        if (mKeyguardDelegate.isShowing()) {
            // Double the time it takes to take a screenshot from the keyguard
            return (long) (KEYGUARD_SCREENSHOT_CHORD_DELAY_MULTIPLIER * delayMs);
@@ -1457,7 +1465,13 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    }

    private void cancelPendingScreenshotChordAction() {
        boolean hadCallback = mHandler.hasCallbacks(mScreenshotRunnable);
        mHandler.removeCallbacks(mScreenshotRunnable);
        if (mClickPartialScreenshot && hadCallback) {
            mScreenshotRunnable.setScreenshotType(
                    TAKE_SCREENSHOT_SELECTED_REGION);
            mHandler.post(mScreenshotRunnable);
        }
    }

    private void cancelPendingAccessibilityShortcutAction() {
@@ -2517,6 +2531,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            mCameraLaunch = LineageSettings.System.getIntForUser(resolver,
                    LineageSettings.System.CAMERA_LAUNCH, 0,
                    UserHandle.USER_CURRENT) == 1;
            mClickPartialScreenshot = LineageSettings.System.getIntForUser(resolver,
                    LineageSettings.System.CLICK_PARTIAL_SCREENSHOT, 0,
                    UserHandle.USER_CURRENT) == 1;

            // Configure wake gesture.
            boolean wakeGestureEnabledSetting = Settings.Secure.getIntForUser(resolver,