Loading packages/SystemUI/animation/src/com/android/systemui/animation/GhostedViewTransitionAnimatorController.kt +10 −4 Original line number Original line Diff line number Diff line Loading @@ -191,14 +191,20 @@ constructor( // so we have to take the optical insets into account. // so we have to take the optical insets into account. ghostedView.getLocationOnScreen(ghostedViewLocation) ghostedView.getLocationOnScreen(ghostedViewLocation) val insets = backgroundInsets val insets = backgroundInsets state.top = ghostedViewLocation[1] + insets.top val boundCorrections: Rect = if (ghostedView is LaunchableView) { ghostedView.getPaddingForLaunchAnimation() } else { Rect() } state.top = ghostedViewLocation[1] + insets.top + boundCorrections.top state.bottom = state.bottom = ghostedViewLocation[1] + (ghostedView.height * ghostedView.scaleY).roundToInt() - ghostedViewLocation[1] + (ghostedView.height * ghostedView.scaleY).roundToInt() - insets.bottom insets.bottom + boundCorrections.bottom state.left = ghostedViewLocation[0] + insets.left state.left = ghostedViewLocation[0] + insets.left + boundCorrections.left state.right = state.right = ghostedViewLocation[0] + (ghostedView.width * ghostedView.scaleX).roundToInt() - ghostedViewLocation[0] + (ghostedView.width * ghostedView.scaleX).roundToInt() - insets.right insets.right + boundCorrections.right } } override fun onTransitionAnimationStart(isExpandingFullyAbove: Boolean) { override fun onTransitionAnimationStart(isExpandingFullyAbove: Boolean) { Loading packages/SystemUI/animation/src/com/android/systemui/animation/LaunchableView.kt +4 −0 Original line number Original line Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.systemui.animation package com.android.systemui.animation import android.graphics.Rect import android.view.View import android.view.View /** A view that can expand/launch into an app or a dialog. */ /** A view that can expand/launch into an app or a dialog. */ Loading @@ -41,6 +42,9 @@ interface LaunchableView { /** Perform an action when the activity launch animation ends */ /** Perform an action when the activity launch animation ends */ fun onActivityLaunchAnimationEnd() {} fun onActivityLaunchAnimationEnd() {} /** Provide an optional correction applied to the visible area during a launch animation */ fun getPaddingForLaunchAnimation(): Rect = Rect() } } /** A delegate that can be used by views to make the implementation of [LaunchableView] easier. */ /** A delegate that can be used by views to make the implementation of [LaunchableView] easier. */ Loading packages/SystemUI/src/com/android/systemui/haptics/qs/QSLongPressEffectViewBinder.kt +1 −0 Original line number Original line Diff line number Diff line Loading @@ -57,6 +57,7 @@ object QSLongPressEffectViewBinder { qsLongPressEffect.clearActionType() qsLongPressEffect.clearActionType() } } QSLongPressEffect.ActionType.LONG_PRESS -> { QSLongPressEffect.ActionType.LONG_PRESS -> { tile.prepareForLaunch() tile.performLongClick() tile.performLongClick() qsLongPressEffect.clearActionType() qsLongPressEffect.clearActionType() } } Loading packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSLongPressProperties.kt +2 −2 Original line number Original line Diff line number Diff line Loading @@ -22,8 +22,8 @@ package com.android.systemui.qs.tileimpl * These properties are used during animation if a tile supports a long-press action. * These properties are used during animation if a tile supports a long-press action. */ */ data class QSLongPressProperties( data class QSLongPressProperties( var xScale: Float, var height: Float, var yScale: Float, var width: Float, var cornerRadius: Float, var cornerRadius: Float, var backgroundColor: Int, var backgroundColor: Int, var labelColor: Int, var labelColor: Int, Loading packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileViewImpl.kt +75 −40 Original line number Original line Diff line number Diff line Loading @@ -25,6 +25,7 @@ import android.content.res.Configuration import android.content.res.Resources.ID_NULL import android.content.res.Resources.ID_NULL import android.graphics.Color import android.graphics.Color import android.graphics.PorterDuff import android.graphics.PorterDuff import android.graphics.Rect import android.graphics.drawable.Drawable import android.graphics.drawable.Drawable import android.graphics.drawable.GradientDrawable import android.graphics.drawable.GradientDrawable import android.graphics.drawable.LayerDrawable import android.graphics.drawable.LayerDrawable Loading @@ -46,6 +47,7 @@ import android.widget.LinearLayout import android.widget.Switch import android.widget.Switch import android.widget.TextView import android.widget.TextView import androidx.annotation.VisibleForTesting import androidx.annotation.VisibleForTesting import androidx.core.graphics.drawable.updateBounds import com.android.app.tracing.traceSection import com.android.app.tracing.traceSection import com.android.settingslib.Utils import com.android.settingslib.Utils import com.android.systemui.Flags import com.android.systemui.Flags Loading @@ -62,7 +64,6 @@ import com.android.systemui.plugins.qs.QSTileView import com.android.systemui.qs.logging.QSLogger import com.android.systemui.qs.logging.QSLogger import com.android.systemui.qs.tileimpl.QSIconViewImpl.QS_ANIM_LENGTH import com.android.systemui.qs.tileimpl.QSIconViewImpl.QS_ANIM_LENGTH import com.android.systemui.res.R import com.android.systemui.res.R import com.android.systemui.util.children import kotlinx.coroutines.DisposableHandle import kotlinx.coroutines.DisposableHandle import java.util.Objects import java.util.Objects Loading @@ -83,6 +84,10 @@ open class QSTileViewImpl @JvmOverloads constructor( const val UNAVAILABLE_ALPHA = 0.3f const val UNAVAILABLE_ALPHA = 0.3f @VisibleForTesting @VisibleForTesting internal const val TILE_STATE_RES_PREFIX = "tile_states_" internal const val TILE_STATE_RES_PREFIX = "tile_states_" @VisibleForTesting internal const val LONG_PRESS_EFFECT_WIDTH_SCALE = 1.1f @VisibleForTesting internal const val LONG_PRESS_EFFECT_HEIGHT_SCALE = 1.2f } } private val icon: QSIconViewImpl = QSIconViewImpl(context) private val icon: QSIconViewImpl = QSIconViewImpl(context) Loading Loading @@ -180,6 +185,8 @@ open class QSTileViewImpl @JvmOverloads constructor( private val locInScreen = IntArray(2) private val locInScreen = IntArray(2) /** Visuo-haptic long-press effects */ /** Visuo-haptic long-press effects */ private var haveLongPressPropertiesBeenReset = true private var paddingForLaunch = Rect() private var initialLongPressProperties: QSLongPressProperties? = null private var initialLongPressProperties: QSLongPressProperties? = null private var finalLongPressProperties: QSLongPressProperties? = null private var finalLongPressProperties: QSLongPressProperties? = null private val colorEvaluator = ArgbEvaluator.getInstance() private val colorEvaluator = ArgbEvaluator.getInstance() Loading Loading @@ -326,7 +333,7 @@ open class QSTileViewImpl @JvmOverloads constructor( private fun updateHeight() { private fun updateHeight() { // TODO(b/332900989): Find a more robust way of resetting the tile if not reset by the // TODO(b/332900989): Find a more robust way of resetting the tile if not reset by the // launch animation. // launch animation. if (scaleX != 1f || scaleY != 1f) { if (!haveLongPressPropertiesBeenReset && longPressEffect != null) { // The launch animation of a long-press effect did not reset the long-press effect so // The launch animation of a long-press effect did not reset the long-press effect so // we must do it here // we must do it here resetLongPressEffectProperties() resetLongPressEffectProperties() Loading Loading @@ -632,7 +639,7 @@ open class QSTileViewImpl @JvmOverloads constructor( ) ) } } showRippleEffect = false showRippleEffect = false initializeLongPressProperties() initializeLongPressProperties(measuredHeight, measuredWidth) } else { } else { // Long-press effects might have been enabled before but the new state does not // Long-press effects might have been enabled before but the new state does not // handle a long-press. In this case, we go back to the behaviour of a regular tile // handle a long-press. In this case, we go back to the behaviour of a regular tile Loading Loading @@ -765,8 +772,60 @@ open class QSTileViewImpl @JvmOverloads constructor( override fun onActivityLaunchAnimationEnd() = resetLongPressEffectProperties() override fun onActivityLaunchAnimationEnd() = resetLongPressEffectProperties() fun prepareForLaunch() { val startingHeight = initialLongPressProperties?.height?.toInt() ?: 0 val startingWidth = initialLongPressProperties?.width?.toInt() ?: 0 val deltaH = finalLongPressProperties?.height?.minus(startingHeight)?.toInt() ?: 0 val deltaW = finalLongPressProperties?.width?.minus(startingWidth)?.toInt() ?: 0 paddingForLaunch.left = -deltaW / 2 paddingForLaunch.top = -deltaH / 2 paddingForLaunch.right = deltaW / 2 paddingForLaunch.bottom = deltaH / 2 } override fun getPaddingForLaunchAnimation(): Rect = paddingForLaunch fun updateLongPressEffectProperties(effectProgress: Float) { fun updateLongPressEffectProperties(effectProgress: Float) { if (!isLongClickable || longPressEffect == null) return if (!isLongClickable || longPressEffect == null) return if (haveLongPressPropertiesBeenReset) haveLongPressPropertiesBeenReset = false // Dimensions change val newHeight = interpolateFloat( effectProgress, initialLongPressProperties?.height ?: 0f, finalLongPressProperties?.height ?: 0f, ).toInt() val newWidth = interpolateFloat( effectProgress, initialLongPressProperties?.width ?: 0f, finalLongPressProperties?.width ?: 0f, ).toInt() val startingHeight = initialLongPressProperties?.height?.toInt() ?: 0 val startingWidth = initialLongPressProperties?.width?.toInt() ?: 0 val deltaH = (newHeight - startingHeight) / 2 val deltaW = (newWidth - startingWidth) / 2 background.updateBounds( left = -deltaW, top = -deltaH, right = newWidth - deltaW, bottom = newHeight - deltaH, ) // Radius change val newRadius = interpolateFloat( effectProgress, initialLongPressProperties?.cornerRadius ?: 0f, finalLongPressProperties?.cornerRadius ?: 0f, ) changeCornerRadius(newRadius) // Color change setAllColors( setAllColors( colorEvaluator.evaluate( colorEvaluator.evaluate( effectProgress, effectProgress, Loading Loading @@ -802,32 +861,6 @@ open class QSTileViewImpl @JvmOverloads constructor( finalLongPressProperties?.iconColor ?: 0, finalLongPressProperties?.iconColor ?: 0, ) as Int, ) as Int, ) ) val newScaleX = interpolateFloat( effectProgress, initialLongPressProperties?.xScale ?: 1f, finalLongPressProperties?.xScale ?: 1f, ) val newScaleY = interpolateFloat( effectProgress, initialLongPressProperties?.xScale ?: 1f, finalLongPressProperties?.xScale ?: 1f, ) val newRadius = interpolateFloat( effectProgress, initialLongPressProperties?.cornerRadius ?: 0f, finalLongPressProperties?.cornerRadius ?: 0f, ) scaleX = newScaleX scaleY = newScaleY for (child in children) { child.scaleX = 1f / newScaleX child.scaleY = 1f / newScaleY } changeCornerRadius(newRadius) } } private fun unbindLongPressEffect() { private fun unbindLongPressEffect() { Loading @@ -839,12 +872,12 @@ open class QSTileViewImpl @JvmOverloads constructor( start + fraction * (end - start) start + fraction * (end - start) fun resetLongPressEffectProperties() { fun resetLongPressEffectProperties() { scaleY = 1f background.updateBounds( scaleX = 1f left = 0, for (child in children) { top = 0, child.scaleY = 1f right = initialLongPressProperties?.width?.toInt() ?: 0, child.scaleX = 1f bottom = initialLongPressProperties?.height?.toInt() ?: 0, } ) changeCornerRadius(resources.getDimensionPixelSize(R.dimen.qs_corner_radius).toFloat()) changeCornerRadius(resources.getDimensionPixelSize(R.dimen.qs_corner_radius).toFloat()) setAllColors( setAllColors( getBackgroundColorForState(lastState, lastDisabledByPolicy), getBackgroundColorForState(lastState, lastDisabledByPolicy), Loading @@ -854,13 +887,15 @@ open class QSTileViewImpl @JvmOverloads constructor( getOverlayColorForState(lastState), getOverlayColorForState(lastState), ) ) icon.setTint(icon.mIcon as ImageView, lastIconTint) icon.setTint(icon.mIcon as ImageView, lastIconTint) haveLongPressPropertiesBeenReset = true } } private fun initializeLongPressProperties() { @VisibleForTesting fun initializeLongPressProperties(startingHeight: Int, startingWidth: Int) { initialLongPressProperties = initialLongPressProperties = QSLongPressProperties( QSLongPressProperties( /* xScale= */1f, height = startingHeight.toFloat(), /* yScale= */1f, width = startingWidth.toFloat(), resources.getDimensionPixelSize(R.dimen.qs_corner_radius).toFloat(), resources.getDimensionPixelSize(R.dimen.qs_corner_radius).toFloat(), getBackgroundColorForState(lastState), getBackgroundColorForState(lastState), getLabelColorForState(lastState), getLabelColorForState(lastState), Loading @@ -872,8 +907,8 @@ open class QSTileViewImpl @JvmOverloads constructor( finalLongPressProperties = finalLongPressProperties = QSLongPressProperties( QSLongPressProperties( /* xScale= */1.1f, height = LONG_PRESS_EFFECT_HEIGHT_SCALE * startingHeight, /* yScale= */1.2f, width = LONG_PRESS_EFFECT_WIDTH_SCALE * startingWidth, resources.getDimensionPixelSize(R.dimen.qs_corner_radius).toFloat() - 20, resources.getDimensionPixelSize(R.dimen.qs_corner_radius).toFloat() - 20, getBackgroundColorForState(Tile.STATE_ACTIVE), getBackgroundColorForState(Tile.STATE_ACTIVE), getLabelColorForState(Tile.STATE_ACTIVE), getLabelColorForState(Tile.STATE_ACTIVE), Loading Loading
packages/SystemUI/animation/src/com/android/systemui/animation/GhostedViewTransitionAnimatorController.kt +10 −4 Original line number Original line Diff line number Diff line Loading @@ -191,14 +191,20 @@ constructor( // so we have to take the optical insets into account. // so we have to take the optical insets into account. ghostedView.getLocationOnScreen(ghostedViewLocation) ghostedView.getLocationOnScreen(ghostedViewLocation) val insets = backgroundInsets val insets = backgroundInsets state.top = ghostedViewLocation[1] + insets.top val boundCorrections: Rect = if (ghostedView is LaunchableView) { ghostedView.getPaddingForLaunchAnimation() } else { Rect() } state.top = ghostedViewLocation[1] + insets.top + boundCorrections.top state.bottom = state.bottom = ghostedViewLocation[1] + (ghostedView.height * ghostedView.scaleY).roundToInt() - ghostedViewLocation[1] + (ghostedView.height * ghostedView.scaleY).roundToInt() - insets.bottom insets.bottom + boundCorrections.bottom state.left = ghostedViewLocation[0] + insets.left state.left = ghostedViewLocation[0] + insets.left + boundCorrections.left state.right = state.right = ghostedViewLocation[0] + (ghostedView.width * ghostedView.scaleX).roundToInt() - ghostedViewLocation[0] + (ghostedView.width * ghostedView.scaleX).roundToInt() - insets.right insets.right + boundCorrections.right } } override fun onTransitionAnimationStart(isExpandingFullyAbove: Boolean) { override fun onTransitionAnimationStart(isExpandingFullyAbove: Boolean) { Loading
packages/SystemUI/animation/src/com/android/systemui/animation/LaunchableView.kt +4 −0 Original line number Original line Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.systemui.animation package com.android.systemui.animation import android.graphics.Rect import android.view.View import android.view.View /** A view that can expand/launch into an app or a dialog. */ /** A view that can expand/launch into an app or a dialog. */ Loading @@ -41,6 +42,9 @@ interface LaunchableView { /** Perform an action when the activity launch animation ends */ /** Perform an action when the activity launch animation ends */ fun onActivityLaunchAnimationEnd() {} fun onActivityLaunchAnimationEnd() {} /** Provide an optional correction applied to the visible area during a launch animation */ fun getPaddingForLaunchAnimation(): Rect = Rect() } } /** A delegate that can be used by views to make the implementation of [LaunchableView] easier. */ /** A delegate that can be used by views to make the implementation of [LaunchableView] easier. */ Loading
packages/SystemUI/src/com/android/systemui/haptics/qs/QSLongPressEffectViewBinder.kt +1 −0 Original line number Original line Diff line number Diff line Loading @@ -57,6 +57,7 @@ object QSLongPressEffectViewBinder { qsLongPressEffect.clearActionType() qsLongPressEffect.clearActionType() } } QSLongPressEffect.ActionType.LONG_PRESS -> { QSLongPressEffect.ActionType.LONG_PRESS -> { tile.prepareForLaunch() tile.performLongClick() tile.performLongClick() qsLongPressEffect.clearActionType() qsLongPressEffect.clearActionType() } } Loading
packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSLongPressProperties.kt +2 −2 Original line number Original line Diff line number Diff line Loading @@ -22,8 +22,8 @@ package com.android.systemui.qs.tileimpl * These properties are used during animation if a tile supports a long-press action. * These properties are used during animation if a tile supports a long-press action. */ */ data class QSLongPressProperties( data class QSLongPressProperties( var xScale: Float, var height: Float, var yScale: Float, var width: Float, var cornerRadius: Float, var cornerRadius: Float, var backgroundColor: Int, var backgroundColor: Int, var labelColor: Int, var labelColor: Int, Loading
packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileViewImpl.kt +75 −40 Original line number Original line Diff line number Diff line Loading @@ -25,6 +25,7 @@ import android.content.res.Configuration import android.content.res.Resources.ID_NULL import android.content.res.Resources.ID_NULL import android.graphics.Color import android.graphics.Color import android.graphics.PorterDuff import android.graphics.PorterDuff import android.graphics.Rect import android.graphics.drawable.Drawable import android.graphics.drawable.Drawable import android.graphics.drawable.GradientDrawable import android.graphics.drawable.GradientDrawable import android.graphics.drawable.LayerDrawable import android.graphics.drawable.LayerDrawable Loading @@ -46,6 +47,7 @@ import android.widget.LinearLayout import android.widget.Switch import android.widget.Switch import android.widget.TextView import android.widget.TextView import androidx.annotation.VisibleForTesting import androidx.annotation.VisibleForTesting import androidx.core.graphics.drawable.updateBounds import com.android.app.tracing.traceSection import com.android.app.tracing.traceSection import com.android.settingslib.Utils import com.android.settingslib.Utils import com.android.systemui.Flags import com.android.systemui.Flags Loading @@ -62,7 +64,6 @@ import com.android.systemui.plugins.qs.QSTileView import com.android.systemui.qs.logging.QSLogger import com.android.systemui.qs.logging.QSLogger import com.android.systemui.qs.tileimpl.QSIconViewImpl.QS_ANIM_LENGTH import com.android.systemui.qs.tileimpl.QSIconViewImpl.QS_ANIM_LENGTH import com.android.systemui.res.R import com.android.systemui.res.R import com.android.systemui.util.children import kotlinx.coroutines.DisposableHandle import kotlinx.coroutines.DisposableHandle import java.util.Objects import java.util.Objects Loading @@ -83,6 +84,10 @@ open class QSTileViewImpl @JvmOverloads constructor( const val UNAVAILABLE_ALPHA = 0.3f const val UNAVAILABLE_ALPHA = 0.3f @VisibleForTesting @VisibleForTesting internal const val TILE_STATE_RES_PREFIX = "tile_states_" internal const val TILE_STATE_RES_PREFIX = "tile_states_" @VisibleForTesting internal const val LONG_PRESS_EFFECT_WIDTH_SCALE = 1.1f @VisibleForTesting internal const val LONG_PRESS_EFFECT_HEIGHT_SCALE = 1.2f } } private val icon: QSIconViewImpl = QSIconViewImpl(context) private val icon: QSIconViewImpl = QSIconViewImpl(context) Loading Loading @@ -180,6 +185,8 @@ open class QSTileViewImpl @JvmOverloads constructor( private val locInScreen = IntArray(2) private val locInScreen = IntArray(2) /** Visuo-haptic long-press effects */ /** Visuo-haptic long-press effects */ private var haveLongPressPropertiesBeenReset = true private var paddingForLaunch = Rect() private var initialLongPressProperties: QSLongPressProperties? = null private var initialLongPressProperties: QSLongPressProperties? = null private var finalLongPressProperties: QSLongPressProperties? = null private var finalLongPressProperties: QSLongPressProperties? = null private val colorEvaluator = ArgbEvaluator.getInstance() private val colorEvaluator = ArgbEvaluator.getInstance() Loading Loading @@ -326,7 +333,7 @@ open class QSTileViewImpl @JvmOverloads constructor( private fun updateHeight() { private fun updateHeight() { // TODO(b/332900989): Find a more robust way of resetting the tile if not reset by the // TODO(b/332900989): Find a more robust way of resetting the tile if not reset by the // launch animation. // launch animation. if (scaleX != 1f || scaleY != 1f) { if (!haveLongPressPropertiesBeenReset && longPressEffect != null) { // The launch animation of a long-press effect did not reset the long-press effect so // The launch animation of a long-press effect did not reset the long-press effect so // we must do it here // we must do it here resetLongPressEffectProperties() resetLongPressEffectProperties() Loading Loading @@ -632,7 +639,7 @@ open class QSTileViewImpl @JvmOverloads constructor( ) ) } } showRippleEffect = false showRippleEffect = false initializeLongPressProperties() initializeLongPressProperties(measuredHeight, measuredWidth) } else { } else { // Long-press effects might have been enabled before but the new state does not // Long-press effects might have been enabled before but the new state does not // handle a long-press. In this case, we go back to the behaviour of a regular tile // handle a long-press. In this case, we go back to the behaviour of a regular tile Loading Loading @@ -765,8 +772,60 @@ open class QSTileViewImpl @JvmOverloads constructor( override fun onActivityLaunchAnimationEnd() = resetLongPressEffectProperties() override fun onActivityLaunchAnimationEnd() = resetLongPressEffectProperties() fun prepareForLaunch() { val startingHeight = initialLongPressProperties?.height?.toInt() ?: 0 val startingWidth = initialLongPressProperties?.width?.toInt() ?: 0 val deltaH = finalLongPressProperties?.height?.minus(startingHeight)?.toInt() ?: 0 val deltaW = finalLongPressProperties?.width?.minus(startingWidth)?.toInt() ?: 0 paddingForLaunch.left = -deltaW / 2 paddingForLaunch.top = -deltaH / 2 paddingForLaunch.right = deltaW / 2 paddingForLaunch.bottom = deltaH / 2 } override fun getPaddingForLaunchAnimation(): Rect = paddingForLaunch fun updateLongPressEffectProperties(effectProgress: Float) { fun updateLongPressEffectProperties(effectProgress: Float) { if (!isLongClickable || longPressEffect == null) return if (!isLongClickable || longPressEffect == null) return if (haveLongPressPropertiesBeenReset) haveLongPressPropertiesBeenReset = false // Dimensions change val newHeight = interpolateFloat( effectProgress, initialLongPressProperties?.height ?: 0f, finalLongPressProperties?.height ?: 0f, ).toInt() val newWidth = interpolateFloat( effectProgress, initialLongPressProperties?.width ?: 0f, finalLongPressProperties?.width ?: 0f, ).toInt() val startingHeight = initialLongPressProperties?.height?.toInt() ?: 0 val startingWidth = initialLongPressProperties?.width?.toInt() ?: 0 val deltaH = (newHeight - startingHeight) / 2 val deltaW = (newWidth - startingWidth) / 2 background.updateBounds( left = -deltaW, top = -deltaH, right = newWidth - deltaW, bottom = newHeight - deltaH, ) // Radius change val newRadius = interpolateFloat( effectProgress, initialLongPressProperties?.cornerRadius ?: 0f, finalLongPressProperties?.cornerRadius ?: 0f, ) changeCornerRadius(newRadius) // Color change setAllColors( setAllColors( colorEvaluator.evaluate( colorEvaluator.evaluate( effectProgress, effectProgress, Loading Loading @@ -802,32 +861,6 @@ open class QSTileViewImpl @JvmOverloads constructor( finalLongPressProperties?.iconColor ?: 0, finalLongPressProperties?.iconColor ?: 0, ) as Int, ) as Int, ) ) val newScaleX = interpolateFloat( effectProgress, initialLongPressProperties?.xScale ?: 1f, finalLongPressProperties?.xScale ?: 1f, ) val newScaleY = interpolateFloat( effectProgress, initialLongPressProperties?.xScale ?: 1f, finalLongPressProperties?.xScale ?: 1f, ) val newRadius = interpolateFloat( effectProgress, initialLongPressProperties?.cornerRadius ?: 0f, finalLongPressProperties?.cornerRadius ?: 0f, ) scaleX = newScaleX scaleY = newScaleY for (child in children) { child.scaleX = 1f / newScaleX child.scaleY = 1f / newScaleY } changeCornerRadius(newRadius) } } private fun unbindLongPressEffect() { private fun unbindLongPressEffect() { Loading @@ -839,12 +872,12 @@ open class QSTileViewImpl @JvmOverloads constructor( start + fraction * (end - start) start + fraction * (end - start) fun resetLongPressEffectProperties() { fun resetLongPressEffectProperties() { scaleY = 1f background.updateBounds( scaleX = 1f left = 0, for (child in children) { top = 0, child.scaleY = 1f right = initialLongPressProperties?.width?.toInt() ?: 0, child.scaleX = 1f bottom = initialLongPressProperties?.height?.toInt() ?: 0, } ) changeCornerRadius(resources.getDimensionPixelSize(R.dimen.qs_corner_radius).toFloat()) changeCornerRadius(resources.getDimensionPixelSize(R.dimen.qs_corner_radius).toFloat()) setAllColors( setAllColors( getBackgroundColorForState(lastState, lastDisabledByPolicy), getBackgroundColorForState(lastState, lastDisabledByPolicy), Loading @@ -854,13 +887,15 @@ open class QSTileViewImpl @JvmOverloads constructor( getOverlayColorForState(lastState), getOverlayColorForState(lastState), ) ) icon.setTint(icon.mIcon as ImageView, lastIconTint) icon.setTint(icon.mIcon as ImageView, lastIconTint) haveLongPressPropertiesBeenReset = true } } private fun initializeLongPressProperties() { @VisibleForTesting fun initializeLongPressProperties(startingHeight: Int, startingWidth: Int) { initialLongPressProperties = initialLongPressProperties = QSLongPressProperties( QSLongPressProperties( /* xScale= */1f, height = startingHeight.toFloat(), /* yScale= */1f, width = startingWidth.toFloat(), resources.getDimensionPixelSize(R.dimen.qs_corner_radius).toFloat(), resources.getDimensionPixelSize(R.dimen.qs_corner_radius).toFloat(), getBackgroundColorForState(lastState), getBackgroundColorForState(lastState), getLabelColorForState(lastState), getLabelColorForState(lastState), Loading @@ -872,8 +907,8 @@ open class QSTileViewImpl @JvmOverloads constructor( finalLongPressProperties = finalLongPressProperties = QSLongPressProperties( QSLongPressProperties( /* xScale= */1.1f, height = LONG_PRESS_EFFECT_HEIGHT_SCALE * startingHeight, /* yScale= */1.2f, width = LONG_PRESS_EFFECT_WIDTH_SCALE * startingWidth, resources.getDimensionPixelSize(R.dimen.qs_corner_radius).toFloat() - 20, resources.getDimensionPixelSize(R.dimen.qs_corner_radius).toFloat() - 20, getBackgroundColorForState(Tile.STATE_ACTIVE), getBackgroundColorForState(Tile.STATE_ACTIVE), getLabelColorForState(Tile.STATE_ACTIVE), getLabelColorForState(Tile.STATE_ACTIVE), Loading