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

Commit 113e3534 authored by Matt Casey's avatar Matt Casey Committed by Automerger Merge Worker
Browse files

Merge "Request scroll capture when the screen rotates." into sc-dev am: 894c5d3d am: fa7efbf3

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14900805

Change-Id: Idadade56b0f79d92d77ce9a89c47a57c542a940f
parents 8e61db7b fa7efbf3
Loading
Loading
Loading
Loading
+16 −7
Original line number Original line Diff line number Diff line
@@ -554,16 +554,15 @@ public class ScreenshotController {
        // Wait until this window is attached to request because it is
        // Wait until this window is attached to request because it is
        // the reference used to locate the target window (below).
        // the reference used to locate the target window (below).
        withWindowAttached(() -> {
        withWindowAttached(() -> {
            mScrollCaptureClient.setHostWindowToken(mWindow.getDecorView().getWindowToken());
            requestScrollCapture();
            if (mLastScrollCaptureRequest != null) {
                mLastScrollCaptureRequest.cancel(true);
            }
            mLastScrollCaptureRequest = mScrollCaptureClient.request(DEFAULT_DISPLAY);
            mLastScrollCaptureRequest.addListener(() ->
                    onScrollCaptureResponseReady(mLastScrollCaptureRequest), mMainExecutor);
            mWindow.peekDecorView().getViewRootImpl().setActivityConfigCallback(
            mWindow.peekDecorView().getViewRootImpl().setActivityConfigCallback(
                    (overrideConfig, newDisplayId) -> {
                    (overrideConfig, newDisplayId) -> {
                        if (mConfigChanges.applyNewConfig(mContext.getResources())) {
                        if (mConfigChanges.applyNewConfig(mContext.getResources())) {
                            // Hide the scroll chip until we know it's available in this orientation
                            mScreenshotView.hideScrollChip();
                            // Delay scroll capture eval a bit to allow the underlying activity
                            // to set up in the new orientation.
                            mScreenshotHandler.postDelayed(this::requestScrollCapture, 150);
                            updateDisplayCutout();
                            updateDisplayCutout();
                        }
                        }
                    });
                    });
@@ -593,6 +592,16 @@ public class ScreenshotController {
        cancelTimeout(); // restarted after animation
        cancelTimeout(); // restarted after animation
    }
    }


    private void requestScrollCapture() {
        mScrollCaptureClient.setHostWindowToken(mWindow.getDecorView().getWindowToken());
        if (mLastScrollCaptureRequest != null) {
            mLastScrollCaptureRequest.cancel(true);
        }
        mLastScrollCaptureRequest = mScrollCaptureClient.request(DEFAULT_DISPLAY);
        mLastScrollCaptureRequest.addListener(() ->
                onScrollCaptureResponseReady(mLastScrollCaptureRequest), mMainExecutor);
    }

    private void onScrollCaptureResponseReady(Future<ScrollCaptureResponse> responseFuture) {
    private void onScrollCaptureResponseReady(Future<ScrollCaptureResponse> responseFuture) {
        try {
        try {
            if (mLastScrollCaptureResponse != null) {
            if (mLastScrollCaptureResponse != null) {
+4 −0
Original line number Original line Diff line number Diff line
@@ -204,6 +204,10 @@ public class ScreenshotView extends FrameLayout implements
        mSwipeDismissHandler = new SwipeDismissHandler();
        mSwipeDismissHandler = new SwipeDismissHandler();
    }
    }


    public void hideScrollChip() {
        mScrollChip.setVisibility(View.GONE);
    }

    /**
    /**
     * Called to display the scroll action chip when support is detected.
     * Called to display the scroll action chip when support is detected.
     *
     *