Improve long press menu readability
When media cannot be dismissed, hide the "Hide" button completely and make the "Cancel" button solid. Also update the top text to be medium weight so it is more readable on busy backgrounds. Fixes: 231397561 Test: manual - video in bug Test: atest com.android.systemui.media Change-Id: I1f9341d84102aaf6634745c42cf23ce572136954
This commit is contained in:
@@ -26,7 +26,7 @@
|
||||
android:layout_marginStart="@dimen/qs_media_padding"
|
||||
android:layout_marginEnd="@dimen/qs_media_padding"
|
||||
android:id="@+id/remove_text"
|
||||
android:fontFamily="@*android:string/config_headlineFontFamily"
|
||||
android:fontFamily="@*android:string/config_headlineFontFamilyMedium"
|
||||
android:singleLine="true"
|
||||
android:ellipsize="marquee"
|
||||
android:marqueeRepeatLimit="marquee_forever"
|
||||
@@ -62,7 +62,6 @@
|
||||
android:layout_marginEnd="@dimen/qs_media_action_spacing"
|
||||
android:layout_marginBottom="@dimen/qs_media_padding"
|
||||
app:layout_constrainedWidth="true"
|
||||
app:layout_constraintWidth_min="@dimen/min_clickable_item_size"
|
||||
app:layout_constraintHeight_min="@dimen/min_clickable_item_size"
|
||||
app:layout_constraintHorizontal_chainStyle="packed"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
@@ -73,6 +72,7 @@
|
||||
android:id="@+id/dismiss_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintWidth_min="@dimen/min_clickable_item_size"
|
||||
android:layout_gravity="center|top"
|
||||
style="@style/MediaPlayer.SolidButton"
|
||||
android:background="@drawable/qs_media_solid_button"
|
||||
|
||||
@@ -238,5 +238,6 @@ class ColorSchemeTransition internal constructor(
|
||||
fun updateColorScheme(colorScheme: ColorScheme?, enableGradient: Boolean) {
|
||||
isGradientEnabled = enableGradient
|
||||
colorTransitions.forEach { it.updateColorScheme(colorScheme) }
|
||||
colorScheme?.let { mediaViewHolder.gutsViewHolder.colorScheme = colorScheme }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,6 +40,9 @@ class GutsViewHolder constructor(itemView: View) {
|
||||
val dismissText: TextView = itemView.requireViewById(R.id.dismiss_text)
|
||||
val settings: ImageButton = itemView.requireViewById(R.id.settings)
|
||||
|
||||
private var isDismissible: Boolean = true
|
||||
var colorScheme: ColorScheme? = null
|
||||
|
||||
/** Marquees the main text of the guts menu. */
|
||||
fun marquee(start: Boolean, delay: Long, tag: String) {
|
||||
val gutsTextHandler = gutsText.handler
|
||||
@@ -47,19 +50,31 @@ class GutsViewHolder constructor(itemView: View) {
|
||||
Log.d(tag, "marquee while longPressText.getHandler() is null", Exception())
|
||||
return
|
||||
}
|
||||
gutsTextHandler.postDelayed( { gutsText.isSelected = start }, delay)
|
||||
gutsTextHandler.postDelayed({ gutsText.isSelected = start }, delay)
|
||||
}
|
||||
|
||||
/** Set whether this control can be dismissed, and update appearance to match */
|
||||
fun setDismissible(dismissible: Boolean) {
|
||||
if (isDismissible == dismissible) return
|
||||
|
||||
isDismissible = dismissible
|
||||
colorScheme?.let { setColors(it) }
|
||||
}
|
||||
|
||||
/** Sets the right colors on all the guts views based on the given [ColorScheme]. */
|
||||
fun setColors(colorScheme: ColorScheme) {
|
||||
setSurfaceColor(surfaceFromScheme(colorScheme))
|
||||
setTextPrimaryColor(textPrimaryFromScheme(colorScheme))
|
||||
setAccentPrimaryColor(accentPrimaryFromScheme(colorScheme))
|
||||
fun setColors(scheme: ColorScheme) {
|
||||
colorScheme = scheme
|
||||
setSurfaceColor(surfaceFromScheme(scheme))
|
||||
setTextPrimaryColor(textPrimaryFromScheme(scheme))
|
||||
setAccentPrimaryColor(accentPrimaryFromScheme(scheme))
|
||||
}
|
||||
|
||||
/** Sets the surface color on all guts views that use it. */
|
||||
fun setSurfaceColor(surfaceColor: Int) {
|
||||
dismissText.setTextColor(surfaceColor)
|
||||
if (!isDismissible) {
|
||||
cancelText.setTextColor(surfaceColor)
|
||||
}
|
||||
}
|
||||
|
||||
/** Sets the primary accent color on all guts views that use it. */
|
||||
@@ -74,7 +89,9 @@ class GutsViewHolder constructor(itemView: View) {
|
||||
fun setTextPrimaryColor(textPrimary: Int) {
|
||||
val textColorList = ColorStateList.valueOf(textPrimary)
|
||||
gutsText.setTextColor(textColorList)
|
||||
cancelText.setTextColor(textColorList)
|
||||
if (isDismissible) {
|
||||
cancelText.setTextColor(textColorList)
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
@@ -1183,7 +1183,7 @@ public class MediaControlPanel {
|
||||
gutsViewHolder.getGutsText().setText(text);
|
||||
|
||||
// Dismiss button
|
||||
gutsViewHolder.getDismissText().setAlpha(isDismissible ? 1 : DISABLED_ALPHA);
|
||||
gutsViewHolder.getDismissText().setVisibility(isDismissible ? View.VISIBLE : View.GONE);
|
||||
gutsViewHolder.getDismiss().setEnabled(isDismissible);
|
||||
gutsViewHolder.getDismiss().setOnClickListener(v -> {
|
||||
if (mFalsingManager.isFalseTap(FalsingManager.LOW_PENALTY)) return;
|
||||
@@ -1194,11 +1194,18 @@ public class MediaControlPanel {
|
||||
});
|
||||
|
||||
// Cancel button
|
||||
TextView cancelText = gutsViewHolder.getCancelText();
|
||||
if (isDismissible) {
|
||||
cancelText.setBackground(mContext.getDrawable(R.drawable.qs_media_outline_button));
|
||||
} else {
|
||||
cancelText.setBackground(mContext.getDrawable(R.drawable.qs_media_solid_button));
|
||||
}
|
||||
gutsViewHolder.getCancel().setOnClickListener(v -> {
|
||||
if (!mFalsingManager.isFalseTap(FalsingManager.LOW_PENALTY)) {
|
||||
closeGuts();
|
||||
}
|
||||
});
|
||||
gutsViewHolder.setDismissible(isDismissible);
|
||||
|
||||
// Settings button
|
||||
gutsViewHolder.getSettings().setOnClickListener(v -> {
|
||||
|
||||
@@ -270,8 +270,11 @@ class MediaViewController @Inject constructor(
|
||||
}
|
||||
}
|
||||
gutsIds.forEach { id ->
|
||||
viewState.widgetStates.get(id)?.alpha = if (isGutsVisible) 1f else 0f
|
||||
viewState.widgetStates.get(id)?.gone = !isGutsVisible
|
||||
viewState.widgetStates.get(id)?.let { state ->
|
||||
// Make sure to use the unmodified state if guts are visible
|
||||
state.alpha = if (isGutsVisible) state.alpha else 0f
|
||||
state.gone = if (isGutsVisible) state.gone else true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -57,11 +57,13 @@ class ColorSchemeTransitionTest : SysuiTestCase() {
|
||||
|
||||
private lateinit var animatingColorTransitionFactory: AnimatingColorTransitionFactory
|
||||
@Mock private lateinit var mediaViewHolder: MediaViewHolder
|
||||
@Mock private lateinit var gutsViewHolder: GutsViewHolder
|
||||
|
||||
@JvmField @Rule val mockitoRule = MockitoJUnit.rule()
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
whenever(mediaViewHolder.gutsViewHolder).thenReturn(gutsViewHolder)
|
||||
animatingColorTransitionFactory = { _, _, _ -> mockAnimatingTransition }
|
||||
whenever(extractColor.invoke(colorScheme)).thenReturn(TARGET_COLOR)
|
||||
|
||||
@@ -147,5 +149,6 @@ class ColorSchemeTransitionTest : SysuiTestCase() {
|
||||
fun testColorSchemeTransition_update() {
|
||||
colorSchemeTransition.updateColorScheme(colorScheme, true)
|
||||
verify(mockAnimatingTransition, times(10)).updateColorScheme(colorScheme)
|
||||
verify(gutsViewHolder).colorScheme = colorScheme
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user