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

Commit d8a68830 authored by Michael Mikhail's avatar Michael Mikhail
Browse files

Add logs and set visibility to gone on animation end

This CL adds logs and sets visibility of the ripple view to gone when
animation ends.

Flag: EXEMPT bugfix
Bug: 363403530
Test: build and checked UI, no crashes.
Change-Id: I869b19442c1f1e7562fa3f19b9fd297df3982287
parent 4d96988c
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.systemui.media.taptotransfer.receiver
import android.app.StatusBarManager
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.log.LogBuffer
import com.android.systemui.log.core.LogLevel
import com.android.systemui.media.taptotransfer.common.MediaTttLoggerUtils
import com.android.systemui.temporarydisplay.TemporaryViewLogger
import javax.inject.Inject
@@ -50,6 +51,15 @@ constructor(
        MediaTttLoggerUtils.logPackageNotFound(buffer, TAG, packageName)
    }

    fun logRippleAnimationEnd(id: Int) {
        buffer.log(
            tag,
            LogLevel.DEBUG,
            { int1 = id },
            { "ripple animation for view with id: $int1 is ended" }
        )
    }

    companion object {
        private const val TAG = "MediaTttReceiver"
    }
+3 −2
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ class MediaTttReceiverRippleController
constructor(
    private val context: Context,
    private val windowManager: WindowManager,
    private val mediaTttReceiverLogger: MediaTttReceiverLogger,
) {

    private var maxRippleWidth: Float = 0f
@@ -90,12 +91,12 @@ constructor(
    /** Expands the ripple to cover the screen. */
    fun expandToSuccessState(rippleView: ReceiverChipRippleView, onAnimationEnd: Runnable?) {
        layoutRipple(rippleView, isFullScreen = true)
        rippleView.expandToFull(maxRippleHeight, onAnimationEnd)
        rippleView.expandToFull(maxRippleHeight, mediaTttReceiverLogger, onAnimationEnd)
    }

    /** Collapses the ripple. */
    fun collapseRipple(rippleView: ReceiverChipRippleView, onAnimationEnd: Runnable? = null) {
        rippleView.collapseRipple(onAnimationEnd)
        rippleView.collapseRipple(mediaTttReceiverLogger, onAnimationEnd)
    }

    private fun layoutRipple(rippleView: ReceiverChipRippleView, isFullScreen: Boolean = false) {
+29 −16
Original line number Diff line number Diff line
@@ -24,9 +24,7 @@ import com.android.systemui.surfaceeffects.ripple.RippleShader
import com.android.systemui.surfaceeffects.ripple.RippleView
import kotlin.math.pow

/**
 * An expanding ripple effect for the media tap-to-transfer receiver chip.
 */
/** An expanding ripple effect for the media tap-to-transfer receiver chip. */
class ReceiverChipRippleView(context: Context?, attrs: AttributeSet?) : RippleView(context, attrs) {

    // Indicates whether the ripple started expanding.
@@ -46,24 +44,34 @@ class ReceiverChipRippleView(context: Context?, attrs: AttributeSet?) : RippleVi
    }

    /** Used to animate out the ripple. No-op if the ripple was never started via [startRipple]. */
    fun collapseRipple(onAnimationEnd: Runnable? = null) {
    fun collapseRipple(logger: MediaTttReceiverLogger, onAnimationEnd: Runnable? = null) {
        if (!isStarted) {
            return // Ignore if ripple is not started yet.
        }
        duration = DEFAULT_DURATION
        // Reset all listeners to animator.
        animator.removeAllListeners()
        animator.addListener(object : AnimatorListenerAdapter() {
        animator.addListener(
            object : AnimatorListenerAdapter() {
                override fun onAnimationEnd(animation: Animator) {
                    animation?.let {
                        visibility = GONE
                        logger.logRippleAnimationEnd(id)
                    }
                    onAnimationEnd?.run()
                    isStarted = false
                }
        })
            }
        )
        animator.reverse()
    }

    // Expands the ripple to cover full screen.
    fun expandToFull(newHeight: Float, onAnimationEnd: Runnable? = null) {
    fun expandToFull(
        newHeight: Float,
        logger: MediaTttReceiverLogger,
        onAnimationEnd: Runnable? = null
    ) {
        if (!isStarted) {
            return
        }
@@ -85,13 +93,18 @@ class ReceiverChipRippleView(context: Context?, attrs: AttributeSet?) : RippleVi
            rippleShader.time = now.toFloat()
            invalidate()
        }
        animator.addListener(object : AnimatorListenerAdapter() {
        animator.addListener(
            object : AnimatorListenerAdapter() {
                override fun onAnimationEnd(animation: Animator) {
                animation?.let { visibility = GONE }
                    animation?.let {
                        visibility = GONE
                        logger.logRippleAnimationEnd(id)
                    }
                    onAnimationEnd?.run()
                    isStarted = false
                }
        })
            }
        )
        animator.start()
    }