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

Commit b2188616 authored by Matt Casey's avatar Matt Casey Committed by Android (Google) Code Review
Browse files

Merge "Add ThumbnailObserver" into 24D1-dev

parents 61f945b2 e31cd2c6
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -35,4 +35,10 @@ public interface ReferenceScreenshotModule {
    @Binds
    ScreenshotActionsProvider.Factory bindScreenshotActionsProviderFactory(
            DefaultScreenshotActionsProvider.Factory defaultScreenshotActionsProviderFactory);

    /** */
    @Provides
    static ThumbnailObserver providesThumbnailObserver() {
        return new ThumbnailObserver();
    };
}
+12 −2
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import android.view.WindowManager
import android.window.OnBackInvokedCallback
import android.window.OnBackInvokedDispatcher
import androidx.core.animation.doOnEnd
import androidx.core.animation.doOnStart
import com.android.internal.logging.UiEventLogger
import com.android.systemui.log.DebugLogger.debugLog
import com.android.systemui.res.R
@@ -56,6 +57,7 @@ constructor(
    private val logger: UiEventLogger,
    private val viewModel: ScreenshotViewModel,
    private val windowManager: WindowManager,
    private val thumbnailObserver: ThumbnailObserver,
    @Assisted private val context: Context,
    @Assisted private val displayId: Int
) : ScreenshotViewProxy {
@@ -99,6 +101,10 @@ constructor(
            info.touchableRegion.set(touchableRegion)
        }
        screenshotPreview = view.screenshotPreview
        thumbnailObserver.setViews(
            view.screenshotPreview,
            view.requireViewById(R.id.screenshot_preview_border)
        )
    }

    override fun reset() {
@@ -111,8 +117,12 @@ constructor(

    override fun createScreenshotDropInAnimation(screenRect: Rect, showFlash: Boolean): Animator {
        val entrance = animationController.getEntranceAnimation(screenRect, showFlash)
        entrance.doOnStart { thumbnailObserver.onEntranceStarted() }
        entrance.doOnEnd {
            // reset the timeout when animation finishes
        entrance.doOnEnd { callbacks?.onUserInteraction() }
            callbacks?.onUserInteraction()
            thumbnailObserver.onEntranceComplete()
        }
        return entrance
    }

+32 −0
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.view.View
import android.widget.ImageView

/** An observer of thumbnail UI and entrance state that can be overridden if needed. */
open class ThumbnailObserver {
    /** Thumbnail image and border views. */
    open fun setViews(image: ImageView, border: View) {}

    /** Entrance animation has begun. */
    open fun onEntranceStarted() {}

    /** Entrance animation has completed/stopped. */
    open fun onEntranceComplete() {}
}