Merge "Controls UI - Remove focused control" into rvc-dev
This commit is contained in:
@@ -23,7 +23,6 @@ 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
|
||||
|
||||
@@ -110,13 +109,6 @@ 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
|
||||
|
||||
/**
|
||||
|
||||
@@ -41,7 +41,6 @@ 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
|
||||
@@ -500,10 +499,6 @@ 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")
|
||||
|
||||
@@ -59,9 +59,4 @@ interface ControlActionCoordinator {
|
||||
* retain context with their favorited controls in the power menu.
|
||||
*/
|
||||
fun longPress(cvh: ControlViewHolder)
|
||||
|
||||
/**
|
||||
* Event to inform the UI that the user has has focused on a single control.
|
||||
*/
|
||||
fun setFocusedElement(cvh: ControlViewHolder?)
|
||||
}
|
||||
|
||||
@@ -26,14 +26,11 @@ import android.service.controls.actions.BooleanAction
|
||||
import android.service.controls.actions.CommandAction
|
||||
import android.util.Log
|
||||
import android.view.HapticFeedbackConstants
|
||||
import com.android.systemui.controls.controller.ControlsController
|
||||
import com.android.systemui.globalactions.GlobalActionsComponent
|
||||
import com.android.systemui.plugins.ActivityStarter
|
||||
import com.android.systemui.statusbar.policy.KeyguardStateController
|
||||
import com.android.systemui.util.concurrency.DelayableExecutor
|
||||
|
||||
import dagger.Lazy
|
||||
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
||||
@@ -41,7 +38,6 @@ import javax.inject.Singleton
|
||||
class ControlActionCoordinatorImpl @Inject constructor(
|
||||
private val context: Context,
|
||||
private val bgExecutor: DelayableExecutor,
|
||||
private val controlsController: Lazy<ControlsController>,
|
||||
private val activityStarter: ActivityStarter,
|
||||
private val keyguardStateController: KeyguardStateController,
|
||||
private val globalActionsComponent: GlobalActionsComponent
|
||||
@@ -95,10 +91,6 @@ class ControlActionCoordinatorImpl @Inject constructor(
|
||||
}
|
||||
}
|
||||
|
||||
override fun setFocusedElement(cvh: ControlViewHolder?) {
|
||||
controlsController.get().onFocusChanged(cvh?.cws)
|
||||
}
|
||||
|
||||
private fun bouncerOrRun(f: () -> Unit) {
|
||||
if (!keyguardStateController.isUnlocked()) {
|
||||
context.sendBroadcast(Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS))
|
||||
|
||||
@@ -73,8 +73,6 @@ 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)
|
||||
@@ -91,11 +89,6 @@ class ControlViewHolder(
|
||||
|
||||
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
|
||||
@@ -222,7 +215,6 @@ class ControlViewHolder(
|
||||
|
||||
val fg = context.resources.getColorStateList(ri.foreground, context.theme)
|
||||
val bg = context.resources.getColor(R.color.control_default_background, context.theme)
|
||||
val dimAlpha = if (dimmed) dimmedAlpha else 1f
|
||||
var (newClipColor, newAlpha) = if (enabled) {
|
||||
// allow color overrides for the enabled state only
|
||||
val color = cws.control?.getCustomColor()?.let {
|
||||
@@ -269,7 +261,7 @@ class ControlViewHolder(
|
||||
setColor(ColorUtils.blendARGB(oldColor, newClipColor, it.animatedFraction))
|
||||
baseLayer.setColor(ColorUtils.blendARGB(oldBaseColor,
|
||||
newBaseColor, it.animatedFraction))
|
||||
layout.alpha = MathUtils.lerp(oldAlpha, dimAlpha, it.animatedFraction)
|
||||
layout.alpha = MathUtils.lerp(oldAlpha, 1f, it.animatedFraction)
|
||||
}
|
||||
addListener(object : AnimatorListenerAdapter() {
|
||||
override fun onAnimationEnd(animation: Animator?) {
|
||||
@@ -284,7 +276,7 @@ class ControlViewHolder(
|
||||
alpha = newAlpha
|
||||
setColor(newClipColor)
|
||||
baseLayer.setColor(newBaseColor)
|
||||
layout.alpha = dimAlpha
|
||||
layout.alpha = 1f
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,5 +37,4 @@ interface ControlsUiController {
|
||||
controlId: String,
|
||||
@ControlAction.ResponseResult response: Int
|
||||
)
|
||||
fun onFocusChanged(controlWithState: ControlWithState?)
|
||||
}
|
||||
|
||||
@@ -217,20 +217,6 @@ class ControlsUiControllerImpl @Inject constructor (
|
||||
}
|
||||
}
|
||||
|
||||
override fun onFocusChanged(focusedControl: ControlWithState?) {
|
||||
controlViewsById.forEach { key: ControlKey, viewHolder: ControlViewHolder ->
|
||||
val state = controlsById.get(key) ?: return@forEach
|
||||
val shouldBeDimmed = focusedControl != null && state != focusedControl
|
||||
if (viewHolder.dimmed == shouldBeDimmed) {
|
||||
return@forEach
|
||||
}
|
||||
|
||||
uiExecutor.execute {
|
||||
viewHolder.dimmed = shouldBeDimmed
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun startFavoritingActivity(context: Context, si: StructureInfo) {
|
||||
startTargetedActivity(context, si, ControlsFavoritingActivity::class.java)
|
||||
}
|
||||
|
||||
@@ -175,7 +175,6 @@ class ToggleRangeBehavior : Behavior {
|
||||
fun beginUpdateRange() {
|
||||
status.setTextSize(TypedValue.COMPLEX_UNIT_PX, context.getResources()
|
||||
.getDimensionPixelSize(R.dimen.control_status_expanded).toFloat())
|
||||
cvh.controlActionCoordinator.setFocusedElement(cvh)
|
||||
}
|
||||
|
||||
fun updateRange(level: Int, checked: Boolean, isDragging: Boolean) {
|
||||
@@ -248,7 +247,6 @@ class ToggleRangeBehavior : Behavior {
|
||||
status.setText("$currentStatusText $currentRangeValue")
|
||||
cvh.action(FloatAction(rangeTemplate.getTemplateId(),
|
||||
findNearestStep(levelToRangeValue(clipLayer.getLevel()))))
|
||||
cvh.controlActionCoordinator.setFocusedElement(null)
|
||||
}
|
||||
|
||||
fun findNearestStep(value: Float): Float {
|
||||
|
||||
Reference in New Issue
Block a user