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

Commit 7e0f34b2 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 d9dd94f3
Loading
Loading
Loading
Loading
+18 −2
Original line number Diff line number Diff line
@@ -537,6 +537,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {

    boolean mVolumeAnswerCall;

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

    private boolean mPendingKeyguardOccluded;
    private boolean mKeyguardOccludedChanged;

@@ -926,6 +929,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();
        }
@@ -1578,9 +1584,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);
@@ -2416,6 +2424,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,
@@ -4270,6 +4281,11 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                        mScreenshotChordVolumeDownKeyTriggered = false;
                        cancelPendingScreenshotChordAction();
                        cancelPendingAccessibilityShortcutAction();

                        if (mClickPartialScreenshot && mScreenshotChordVolumeDownKeyConsumed) {
                            mScreenshotRunnable.setScreenshotType(TAKE_SCREENSHOT_SELECTED_REGION);
                            mHandler.post(mScreenshotRunnable);
                        }
                    }
                } else if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) {
                    if (down) {