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

Commit f1639477 authored by Caitlin Shkuratov's avatar Caitlin Shkuratov Committed by Android (Google) Code Review
Browse files

Merge changes I61bfb975,I2cb907c5,I13c60b3b into tm-qpr-dev

* changes:
  [Media TTT] Animate the sender chip out.
  [Chipbar] Define #shouldIgnoreViewRemoval as a specific API on the TemporaryViewDisplayController, instead of having subclasses just override #removeView.
  [Media TTT] Add the background back to the receiver chip.
parents 24bc2503 7d9b0e62
Loading
Loading
Loading
Loading
+29 −11
Original line number Diff line number Diff line
@@ -361,13 +361,17 @@ class ViewHierarchyAnimator {
         *
         * The end state of the animation is controlled by [destination]. This value can be any of
         * the four corners, any of the four edges, or the center of the view.
         *
         * @param onAnimationEnd an optional runnable that will be run once the animation finishes
         *    successfully. Will not be run if the animation is cancelled.
         */
        @JvmOverloads
        fun animateRemoval(
            rootView: View,
            destination: Hotspot = Hotspot.CENTER,
            interpolator: Interpolator = DEFAULT_REMOVAL_INTERPOLATOR,
            duration: Long = DEFAULT_DURATION
            duration: Long = DEFAULT_DURATION,
            onAnimationEnd: Runnable? = null,
        ): Boolean {
            if (
                !occupiesSpace(
@@ -391,13 +395,28 @@ class ViewHierarchyAnimator {
                addListener(child, listener, recursive = false)
            }

            val viewHasSiblings = parent.childCount > 1
            if (viewHasSiblings) {
                // Remove the view so that a layout update is triggered for the siblings and they
                // animate to their next position while the view's removal is also animating.
                parent.removeView(rootView)
            // By adding the view to the overlay, we can animate it while it isn't part of the view
            // hierarchy. It is correctly positioned because we have its previous bounds, and we set
            // them manually during the animation.
                // By adding the view to the overlay, we can animate it while it isn't part of the
                // view hierarchy. It is correctly positioned because we have its previous bounds,
                // and we set them manually during the animation.
                parent.overlay.add(rootView)
            }
            // If this view has no siblings, the parent view may shrink to (0,0) size and mess
            // up the animation if we immediately remove the view. So instead, we just leave the
            // view in the real hierarchy until the animation finishes.

            val endRunnable = Runnable {
                if (viewHasSiblings) {
                    parent.overlay.remove(rootView)
                } else {
                    parent.removeView(rootView)
                }
                onAnimationEnd?.run()
            }

            val startValues =
                mapOf(
@@ -430,7 +449,8 @@ class ViewHierarchyAnimator {
                endValues,
                interpolator,
                duration,
                ephemeral = true
                ephemeral = true,
                endRunnable,
            )

            if (rootView is ViewGroup) {
@@ -463,7 +483,6 @@ class ViewHierarchyAnimator {
                                .alpha(0f)
                                .setInterpolator(Interpolators.ALPHA_OUT)
                                .setDuration(duration / 2)
                                .withEndAction { parent.overlay.remove(rootView) }
                                .start()
                        }
                    }
@@ -477,7 +496,6 @@ class ViewHierarchyAnimator {
                    .setInterpolator(Interpolators.ALPHA_OUT)
                    .setDuration(duration / 2)
                    .setStartDelay(duration / 2)
                    .withEndAction { parent.overlay.remove(rootView) }
                    .start()
            }

+1 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@

    <com.android.internal.widget.CachingIconView
        android:id="@+id/app_icon"
        android:background="@drawable/media_ttt_chip_background_receiver"
        android:layout_width="@dimen/media_ttt_icon_size_receiver"
        android:layout_height="@dimen/media_ttt_icon_size_receiver"
        android:layout_gravity="center|bottom"
+2 −3
Original line number Diff line number Diff line
@@ -1056,9 +1056,8 @@
    <!-- Media tap-to-transfer chip for receiver device -->
    <dimen name="media_ttt_chip_size_receiver">100dp</dimen>
    <dimen name="media_ttt_icon_size_receiver">95dp</dimen>
    <!-- Since the generic icon isn't circular, we need to scale it down so it still fits within
         the circular chip. -->
    <dimen name="media_ttt_generic_icon_size_receiver">70dp</dimen>
    <!-- Add some padding for the generic icon so it doesn't go all the way to the border. -->
    <dimen name="media_ttt_generic_icon_padding">12dp</dimen>
    <dimen name="media_ttt_receiver_vert_translation">20dp</dimen>

    <!-- Window magnification -->
+0 −24
Original line number Diff line number Diff line
@@ -19,7 +19,6 @@ package com.android.systemui.media.taptotransfer.common
import android.content.Context
import android.content.pm.PackageManager
import android.graphics.drawable.Drawable
import com.android.internal.widget.CachingIconView
import com.android.settingslib.Utils
import com.android.systemui.R

@@ -76,29 +75,6 @@ class MediaTttUtils {
                isAppIcon = false
            )
        }

        /**
         * Sets an icon to be displayed by the given view.
         *
         * @param iconSize the size in pixels that the icon should be. If null, the size of
         * [appIconView] will not be adjusted.
         */
        fun setIcon(
            appIconView: CachingIconView,
            icon: Drawable,
            iconContentDescription: CharSequence,
            iconSize: Int? = null,
        ) {
            iconSize?.let { size ->
                val lp = appIconView.layoutParams
                lp.width = size
                lp.height = size
                appIconView.layoutParams = lp
            }

            appIconView.contentDescription = iconContentDescription
            appIconView.setImageDrawable(icon)
        }
    }
}

+8 −10
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import android.view.View
import android.view.ViewGroup
import android.view.WindowManager
import android.view.accessibility.AccessibilityManager
import com.android.internal.widget.CachingIconView
import com.android.settingslib.Utils
import com.android.systemui.R
import com.android.systemui.dagger.SysUISingleton
@@ -146,20 +147,17 @@ class MediaTttChipControllerReceiver @Inject constructor(
        )
        val iconDrawable = newInfo.appIconDrawableOverride ?: iconInfo.drawable
        val iconContentDescription = newInfo.appNameOverride ?: iconInfo.contentDescription
        val iconSize = context.resources.getDimensionPixelSize(
        val iconPadding =
            if (iconInfo.isAppIcon) {
                R.dimen.media_ttt_icon_size_receiver
                0
            } else {
                R.dimen.media_ttt_generic_icon_size_receiver
                context.resources.getDimensionPixelSize(R.dimen.media_ttt_generic_icon_padding)
            }
        )

        MediaTttUtils.setIcon(
            currentView.requireViewById(R.id.app_icon),
            iconDrawable,
            iconContentDescription,
            iconSize,
        )
        val iconView = currentView.requireViewById<CachingIconView>(R.id.app_icon)
        iconView.setPadding(iconPadding, iconPadding, iconPadding, iconPadding)
        iconView.setImageDrawable(iconDrawable)
        iconView.contentDescription = iconContentDescription
    }

    override fun animateViewIn(view: ViewGroup) {
Loading