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

Commit a67e1eef authored by Miranda Kephart's avatar Miranda Kephart Committed by Matt Casey
Browse files

Add scroll chip to screenshot shelf ui

Bug: 329659738
Test: manual (same behavior as old scroll chip)
Flag: ACONFIG com.android.systemui.screenshot_shelf_ui DEVELOPMENT
Change-Id: I09a62c7bab7defbcd94dbef54d7a2526180b8b8d
Merged-In: I09a62c7bab7defbcd94dbef54d7a2526180b8b8d
parent f0a301fc
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ import dagger.assisted.AssistedInject
 * implementation.
 */
interface ScreenshotActionsProvider {
    fun onScrollChipReady(onClick: Runnable)
    fun setCompletedScreenshot(result: ScreenshotSavedResult)

    fun onAssistContentAvailable(assistContent: AssistContent) {}
@@ -145,6 +146,18 @@ constructor(
        }
    }

    override fun onScrollChipReady(onClick: Runnable) {
        viewModel.addAction(
            ActionButtonViewModel(
                AppCompatResources.getDrawable(context, R.drawable.ic_screenshot_scroll),
                context.resources.getString(R.string.screenshot_scroll_label),
                context.resources.getString(R.string.screenshot_scroll_label),
            ) {
                onClick.run()
            }
        )
    }

    override fun setCompletedScreenshot(result: ScreenshotSavedResult) {
        if (this.result != null) {
            Log.e(TAG, "Got a second completed screenshot for existing request!")
+14 −2
Original line number Diff line number Diff line
@@ -621,14 +621,26 @@ public class ScreenshotController {
                mDisplayId,
                mWindow.getDecorView().getWindowToken(),
                (response) -> {
                    mUiEventLogger.log(ScreenshotEvent.SCREENSHOT_LONG_SCREENSHOT_IMPRESSION,
                            0, response.getPackageName());
                    if (screenshotShelfUi() && mActionsProvider != null) {
                        mActionsProvider.onScrollChipReady(
                                () -> onScrollButtonClicked(owner, response));
                    } else {
                        mViewProxy.showScrollChip(response.getPackageName(),
                                () -> onScrollButtonClicked(owner, response));
                    }
                    return Unit.INSTANCE;
                }
        );
    }

    private void onScrollButtonClicked(UserHandle owner, ScrollCaptureResponse response) {
        if (DEBUG_INPUT) {
            Log.d(TAG, "scroll chip tapped");
        }
        mUiEventLogger.log(ScreenshotEvent.SCREENSHOT_LONG_SCREENSHOT_REQUESTED, 0,
                response.getPackageName());
        Bitmap newScreenshot = mImageCapture.captureDisplay(mDisplayId, getFullScreenRect());
        if (newScreenshot == null) {
            Log.e(TAG, "Failed to capture current screenshot for scroll transition!");
+1 −9
Original line number Diff line number Diff line
@@ -259,16 +259,8 @@ public class ScreenshotView extends FrameLayout implements
        if (DEBUG_SCROLL) {
            Log.d(TAG, "Showing Scroll option");
        }
        mUiEventLogger.log(ScreenshotEvent.SCREENSHOT_LONG_SCREENSHOT_IMPRESSION, 0, packageName);
        mScrollChip.setVisibility(VISIBLE);
        mScrollChip.setOnClickListener((v) -> {
            if (DEBUG_INPUT) {
                Log.d(TAG, "scroll chip tapped");
            }
            mUiEventLogger.log(ScreenshotEvent.SCREENSHOT_LONG_SCREENSHOT_REQUESTED, 0,
                    packageName);
            onClick.run();
        });
        mScrollChip.setOnClickListener((v) -> onClick.run());
    }

    @Override // ViewTreeObserver.OnComputeInternalInsetsListener