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

Commit 77db42db authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Dim down controls when slider is active" into rvc-dev am: 56cd4dca...

Merge "Dim down controls when slider is active" into rvc-dev am: 56cd4dca am: 4e3c5c07 am: 1a31bc1b

Change-Id: I4d0725c6a6d72223bdb3037168461dafa6b8e4d6
parents d3b28e0a 1a31bc1b
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -1253,6 +1253,7 @@
    <dimen name="control_base_item_margin">2dp</dimen>
    <dimen name="control_status_padding">3dp</dimen>
    <fraction name="controls_toggle_bg_intensity">5%</fraction>
    <fraction name="controls_dimmed_alpha">40%</fraction>

    <!-- Home Controls activity view detail panel-->
    <dimen name="controls_activity_view_top_padding">25dp</dimen>
+8 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import android.service.controls.actions.ControlAction
import com.android.systemui.controls.ControlStatus
import com.android.systemui.controls.UserAwareController
import com.android.systemui.controls.management.ControlsFavoritingActivity
import com.android.systemui.controls.ui.ControlWithState
import com.android.systemui.controls.ui.ControlsUiController
import java.util.function.Consumer

@@ -111,6 +112,13 @@ interface ControlsController : UserAwareController {
        @ControlAction.ResponseResult response: Int
    )

    /**
     * When a control should be highlighted, dimming down what's around it.
     *
     * @param cws focused control, or {@code null} if nothing should be highlighted.
     */
    fun onFocusChanged(cws: ControlWithState?)

    // FAVORITE MANAGEMENT

    /**
+5 −0
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@ import com.android.systemui.broadcast.BroadcastDispatcher
import com.android.systemui.controls.ControlStatus
import com.android.systemui.controls.ControlsServiceInfo
import com.android.systemui.controls.management.ControlsListingController
import com.android.systemui.controls.ui.ControlWithState
import com.android.systemui.controls.ui.ControlsUiController
import com.android.systemui.dagger.qualifiers.Background
import com.android.systemui.dump.DumpManager
@@ -504,6 +505,10 @@ class ControlsControllerImpl @Inject constructor (
        }
    }

    override fun onFocusChanged(cws: ControlWithState?) {
        uiController.onFocusChanged(cws)
    }

    override fun refreshStatus(componentName: ComponentName, control: Control) {
        if (!confirmAvailability()) {
            Log.d(TAG, "Controls not available")
+5 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import android.service.controls.actions.CommandAction
import android.util.Log
import android.view.HapticFeedbackConstants
import com.android.systemui.R
import com.android.systemui.controls.controller.ControlsController

object ControlActionCoordinator {
    const val MIN_LEVEL = 0
@@ -76,4 +77,8 @@ object ControlActionCoordinator {
            it.show()
        }
    }

    fun setFocusedElement(cvh: ControlViewHolder?, controlsController: ControlsController) {
        controlsController.onFocusChanged(cvh?.cws)
    }
}
+13 −1
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ import android.service.controls.templates.StatelessTemplate
import android.service.controls.templates.TemperatureControlTemplate
import android.service.controls.templates.ToggleRangeTemplate
import android.service.controls.templates.ToggleTemplate
import android.util.MathUtils
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
@@ -68,6 +69,8 @@ class ControlViewHolder(

    private val toggleBackgroundIntensity: Float = layout.context.resources
            .getFraction(R.fraction.controls_toggle_bg_intensity, 1, 1)
    private val dimmedAlpha: Float = layout.context.resources
            .getFraction(R.fraction.controls_dimmed_alpha, 1, 1)
    private var stateAnimator: ValueAnimator? = null
    private val baseLayer: GradientDrawable
    val icon: ImageView = layout.requireViewById(R.id.icon)
@@ -82,6 +85,11 @@ class ControlViewHolder(
    var lastAction: ControlAction? = null
    val deviceType: Int
        get() = cws.control?.let { it.getDeviceType() } ?: cws.ci.deviceType
    var dimmed: Boolean = false
        set(value) {
            field = value
            bindData(cws)
        }

    init {
        val ld = layout.getBackground() as LayerDrawable
@@ -177,7 +185,8 @@ class ControlViewHolder(

        val fg = context.resources.getColorStateList(ri.foreground, context.theme)
        val bg = context.resources.getColor(R.color.control_default_background, context.theme)
        val (clip, newAlpha) = if (enabled) {
        val dimAlpha = if (dimmed) dimmedAlpha else 1f
        var (clip, newAlpha) = if (enabled) {
            listOf(ri.enabledBackground, ALPHA_ENABLED)
        } else {
            listOf(R.color.control_default_background, ALPHA_DISABLED)
@@ -202,12 +211,14 @@ class ControlViewHolder(
            if (animated) {
                val oldColor = color?.defaultColor ?: newClipColor
                val oldBaseColor = baseLayer.color?.defaultColor ?: newBaseColor
                val oldAlpha = layout.alpha
                stateAnimator = ValueAnimator.ofInt(clipLayer.alpha, newAlpha).apply {
                    addUpdateListener {
                        alpha = it.animatedValue as Int
                        setColor(ColorUtils.blendARGB(oldColor, newClipColor, it.animatedFraction))
                        baseLayer.setColor(ColorUtils.blendARGB(oldBaseColor,
                                newBaseColor, it.animatedFraction))
                        layout.alpha = MathUtils.lerp(oldAlpha, dimAlpha, it.animatedFraction)
                    }
                    addListener(object : AnimatorListenerAdapter() {
                        override fun onAnimationEnd(animation: Animator?) {
@@ -222,6 +233,7 @@ class ControlViewHolder(
                alpha = newAlpha
                setColor(newClipColor)
                baseLayer.setColor(newBaseColor)
                layout.alpha = dimAlpha
            }
        }
    }
Loading