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

Commit 0d35b3c1 authored by Julia Tuttle's avatar Julia Tuttle
Browse files

Set AOD RON as GONE when not visible

This gets rid of the redundant bottom margin.

Bug: 396352974
Test: manual: enable flag and look at AOD without a RON
Flag: com.android.systemui.aod_ui_rich_ongoing
Change-Id: Id7a3d4ab5af4209b58236309155a39371666bd94
parent 67182615
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
    }