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

Commit b4e61125 authored by Miranda Kephart's avatar Miranda Kephart
Browse files

Remove ScreenshotViewProxy

Now that the shelf view proxy is the only implementation, remove the
interface.

Bug: 329659738
Test: manual, atest
Flag: EXEMPT removing unused code

Change-Id: I38ac42fcff50e015986610de2720c9b23befaf8b
parent e8863258
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -40,7 +40,7 @@ constructor(
    private val intentExecutor: ActionIntentExecutor,
    @Application private val applicationScope: CoroutineScope,
    @Assisted val window: Window,
    @Assisted val viewProxy: ScreenshotViewProxy,
    @Assisted val viewProxy: ScreenshotShelfViewProxy,
    @Assisted val finishDismiss: () -> Unit,
) {

@@ -109,7 +109,7 @@ constructor(
    interface Factory {
        fun create(
            window: Window,
            viewProxy: ScreenshotViewProxy,
            viewProxy: ScreenshotShelfViewProxy,
            finishDismiss: (() -> Unit)
        ): ActionExecutor
    }
+2 −2
Original line number Diff line number Diff line
@@ -191,7 +191,7 @@ public class ScreenshotController implements ScreenshotHandler {

    private final WindowContext mContext;
    private final FeatureFlags mFlags;
    private final ScreenshotViewProxy mViewProxy;
    private final ScreenshotShelfViewProxy mViewProxy;
    private final ScreenshotNotificationsController mNotificationsController;
    private final ScreenshotSmartActions mScreenshotSmartActions;
    private final UiEventLogger mUiEventLogger;
@@ -246,7 +246,7 @@ public class ScreenshotController implements ScreenshotHandler {
            Context context,
            WindowManager windowManager,
            FeatureFlags flags,
            ScreenshotViewProxy.Factory viewProxyFactory,
            ScreenshotShelfViewProxy.Factory viewProxyFactory,
            ScreenshotSmartActions screenshotSmartActions,
            ScreenshotNotificationsController.Factory screenshotNotificationsControllerFactory,
            UiEventLogger uiEventLogger,
+23 −23
Original line number Diff line number Diff line
@@ -68,7 +68,7 @@ constructor(
    private val thumbnailObserver: ThumbnailObserver,
    @Assisted private val context: Context,
    @Assisted private val displayId: Int
) : ScreenshotViewProxy {
) {

    interface ScreenshotViewCallback {
        fun onUserInteraction()
@@ -79,12 +79,12 @@ constructor(
        fun onTouchOutside()
    }

    override val view: ScreenshotShelfView =
    val view: ScreenshotShelfView =
        LayoutInflater.from(context).inflate(R.layout.screenshot_shelf, null) as ScreenshotShelfView
    override val screenshotPreview: View
    override var packageName: String = ""
    override var callbacks: ScreenshotViewCallback? = null
    override var screenshot: ScreenshotData? = null
    val screenshotPreview: View
    var packageName: String = ""
    var callbacks: ScreenshotViewCallback? = null
    var screenshot: ScreenshotData? = null
        set(value) {
            value?.let {
                viewModel.setScreenshotBitmap(it.bitmap)
@@ -100,11 +100,11 @@ constructor(
            field = value
        }

    override val isAttachedToWindow
    val isAttachedToWindow
        get() = view.isAttachedToWindow

    override var isDismissing = false
    override var isPendingSharedTransition = false
    var isDismissing = false
    var isPendingSharedTransition = false

    private val animationController = ScreenshotAnimationController(view, viewModel)
    private var inputMonitor: InputMonitorCompat? = null
@@ -145,17 +145,17 @@ constructor(
        )
    }

    override fun reset() {
    fun reset() {
        animationController.cancel()
        isPendingSharedTransition = false
        viewModel.reset()
    }

    override fun updateInsets(insets: WindowInsets) {
    fun updateInsets(insets: WindowInsets) {
        view.updateInsets(insets)
    }

    override fun createScreenshotDropInAnimation(screenRect: Rect, showFlash: Boolean): Animator {
    fun createScreenshotDropInAnimation(screenRect: Rect, showFlash: Boolean): Animator {
        val entrance =
            animationController.getEntranceAnimation(screenRect, showFlash) {
                viewModel.setAnimationState(AnimationState.ENTRANCE_REVEAL)
@@ -173,7 +173,7 @@ constructor(
        return entrance
    }

    override fun requestDismissal(event: ScreenshotEvent?) {
    fun requestDismissal(event: ScreenshotEvent?) {
        requestDismissal(event, null)
    }

@@ -202,7 +202,7 @@ constructor(
        animator.start()
    }

    override fun prepareScrollingTransition(
    fun prepareScrollingTransition(
        response: ScrollCaptureResponse,
        screenBitmap: Bitmap, // unused
        newScreenshot: Bitmap,
@@ -230,7 +230,7 @@ constructor(
        return r
    }

    override fun startLongScreenshotTransition(
    fun startLongScreenshotTransition(
        transitionDestination: Rect,
        onTransitionEnd: Runnable,
        longScreenshot: ScrollCaptureController.LongScreenshot,
@@ -245,27 +245,27 @@ constructor(
        transitionAnimation.start()
    }

    override fun restoreNonScrollingUi() {
    fun restoreNonScrollingUi() {
        viewModel.setScrollableRect(null)
        viewModel.setScrollingScrimBitmap(null)
        animationController.restoreUI()
        callbacks?.onUserInteraction() // reset the timeout
    }

    override fun stopInputListening() {
    fun stopInputListening() {
        inputMonitor?.dispose()
        inputMonitor = null
        inputEventReceiver?.dispose()
        inputEventReceiver = null
    }

    override fun requestFocus() {
    fun requestFocus() {
        view.requestFocus()
    }

    override fun announceForAccessibility(string: String) = view.announceForAccessibility(string)
    fun announceForAccessibility(string: String) = view.announceForAccessibility(string)

    override fun prepareEntranceAnimation(runnable: Runnable) {
    fun prepareEntranceAnimation(runnable: Runnable) {
        view.viewTreeObserver.addOnPreDrawListener(
            object : ViewTreeObserver.OnPreDrawListener {
                override fun onPreDraw(): Boolean {
@@ -278,7 +278,7 @@ constructor(
        )
    }

    override fun fadeForSharedTransition() {
    fun fadeForSharedTransition() {
        animationController.fadeForSharedTransition()
    }

@@ -351,7 +351,7 @@ constructor(
    }

    @AssistedFactory
    interface Factory : ScreenshotViewProxy.Factory {
        override fun getProxy(context: Context, displayId: Int): ScreenshotShelfViewProxy
    interface Factory {
        fun getProxy(context: Context, displayId: Int): ScreenshotShelfViewProxy
    }
}
+0 −79
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.systemui.screenshot

import android.animation.Animator
import android.content.Context
import android.graphics.Bitmap
import android.graphics.Rect
import android.view.ScrollCaptureResponse
import android.view.View
import android.view.ViewGroup
import android.view.WindowInsets
import com.android.systemui.screenshot.scroll.ScrollCaptureController

/** Abstraction of the surface between ScreenshotController and ScreenshotView */
interface ScreenshotViewProxy {
    val view: ViewGroup
    val screenshotPreview: View

    var packageName: String
    var callbacks: ScreenshotShelfViewProxy.ScreenshotViewCallback?
    var screenshot: ScreenshotData?

    val isAttachedToWindow: Boolean
    val isDismissing: Boolean
    val isPendingSharedTransition: Boolean

    fun reset()

    fun updateInsets(insets: WindowInsets)

    fun createScreenshotDropInAnimation(screenRect: Rect, showFlash: Boolean): Animator

    fun requestDismissal(event: ScreenshotEvent?)

    fun prepareScrollingTransition(
        response: ScrollCaptureResponse,
        screenBitmap: Bitmap,
        newScreenshot: Bitmap,
        screenshotTakenInPortrait: Boolean,
        onTransitionPrepared: Runnable,
    )

    fun startLongScreenshotTransition(
        transitionDestination: Rect,
        onTransitionEnd: Runnable,
        longScreenshot: ScrollCaptureController.LongScreenshot
    )

    fun restoreNonScrollingUi()

    fun fadeForSharedTransition()

    fun stopInputListening()

    fun requestFocus()

    fun announceForAccessibility(string: String)

    fun prepareEntranceAnimation(runnable: Runnable)

    interface Factory {
        fun getProxy(context: Context, displayId: Int): ScreenshotViewProxy
    }
}
+0 −6
Original line number Diff line number Diff line
@@ -24,12 +24,10 @@ import com.android.systemui.screenshot.ImageCapture;
import com.android.systemui.screenshot.ImageCaptureImpl;
import com.android.systemui.screenshot.ScreenshotPolicy;
import com.android.systemui.screenshot.ScreenshotPolicyImpl;
import com.android.systemui.screenshot.ScreenshotShelfViewProxy;
import com.android.systemui.screenshot.ScreenshotSoundController;
import com.android.systemui.screenshot.ScreenshotSoundControllerImpl;
import com.android.systemui.screenshot.ScreenshotSoundProvider;
import com.android.systemui.screenshot.ScreenshotSoundProviderImpl;
import com.android.systemui.screenshot.ScreenshotViewProxy;
import com.android.systemui.screenshot.TakeScreenshotExecutor;
import com.android.systemui.screenshot.TakeScreenshotExecutorImpl;
import com.android.systemui.screenshot.TakeScreenshotService;
@@ -92,8 +90,4 @@ public abstract class ScreenshotModule {
            AccessibilityManager accessibilityManager) {
        return new ScreenshotViewModel(accessibilityManager);
    }

    @Binds
    abstract ScreenshotViewProxy.Factory bindScreenshotViewProxyFactory(
            ScreenshotShelfViewProxy.Factory shelfScreenshotViewProxyFactory);
}