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

Commit 78095981 authored by Julia Tuttle's avatar Julia Tuttle Committed by Android (Google) Code Review
Browse files

Merge "Set AOD RON as GONE when not visible" into main

parents d440bbf5 0d35b3c1
Loading
Loading
Loading
Loading
+38 −5
Original line number Diff line number Diff line
@@ -26,6 +26,8 @@ import android.view.HapticFeedbackConstants
import android.view.InputDevice
import android.view.MotionEvent
import android.view.View
import android.view.View.GONE
import android.view.View.INVISIBLE
import android.view.View.OnLayoutChangeListener
import android.view.View.VISIBLE
import android.view.ViewGroup
@@ -304,8 +306,9 @@ object KeyguardRootViewBinder {
                            if (isVisible.value) {
                                blueprintViewModel.refreshBlueprint()
                            }
                            childViews[aodPromotedNotificationId]
                                ?.setAodNotifIconContainerIsVisible(isVisible)
                            childViews[aodPromotedNotificationId]?.setAodPromotedNotifIsVisible(
                                isVisible
                            )
                        }
                    }

@@ -313,7 +316,7 @@ object KeyguardRootViewBinder {
                        shadeInteractor.isAnyFullyExpanded.collect { isFullyAnyExpanded ->
                            view.visibility =
                                if (isFullyAnyExpanded) {
                                    View.INVISIBLE
                                    INVISIBLE
                                } else {
                                    View.VISIBLE
                                }
@@ -524,10 +527,10 @@ object KeyguardRootViewBinder {
                visibility =
                    if (isVisible.value) {
                        alpha = 1f
                        View.VISIBLE
                        VISIBLE
                    } else {
                        alpha = 0f
                        View.INVISIBLE
                        INVISIBLE
                    }
            }

@@ -541,6 +544,36 @@ object KeyguardRootViewBinder {
        }
    }

    private fun View.setAodPromotedNotifIsVisible(isVisible: AnimatedValue<Boolean>) {
        animate().cancel()
        val animatorListener =
            object : AnimatorListenerAdapter() {
                override fun onAnimationEnd(animation: Animator) {
                    isVisible.stopAnimating()
                }
            }

        if (isVisible.isAnimating) {
            if (isVisible.value) {
                alpha = 0f
                visibility = VISIBLE
                CrossFadeHelper.fadeIn(this, animatorListener)
            } else {
                CrossFadeHelper.fadeOut(this, animatorListener)
            }
        } else {
            if (isVisible.value) {
                alpha = 1f
                visibility = VISIBLE
            } else {
                // Hide with GONE, not INVISIBLE, so there won't be a redundant bottom
                // margin between the smart space and the shelf.
                alpha = 0f
                visibility = GONE
            }
        }
    }

    private fun MotionEvent.isTouchscreenSource(): Boolean {
        return device?.supportsSource(InputDevice.SOURCE_TOUCHSCREEN) == true
    }