Merge "Reduce device fallback to just icon" into rvc-dev am: 1d53e823fd
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11936396 Change-Id: I02141e8a72175a5995c93f951bdf9b73d9a48eb8
This commit is contained in:
@@ -1,24 +0,0 @@
|
||||
<!--
|
||||
Copyright (C) 2020 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="18dp"
|
||||
android:height="18dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:pathData="M17,2L7,2c-1.1,0 -2,0.9 -2,2v16c0,1.1 0.9,1.99 2,1.99L17,22c1.1,0 2,-0.9 2,-2L19,4c0,-1.1 -0.9,-2 -2,-2zM7,20L7,4h10v16L7,20zM12,9c1.1,0 2,-0.9 2,-2s-0.9,-2 -2,-2c-1.11,0 -2,0.9 -2,2s0.89,2 2,2zM12,11c-2.21,0 -4,1.79 -4,4s1.79,4 4,4 4,-1.79 4,-4 -1.79,-4 -4,-4zM12,17c-1.1,0 -2,-0.9 -2,-2s0.9,-2 2,-2 2,0.9 2,2 -0.9,2 -2,2z"
|
||||
android:fillColor="#000000"/>
|
||||
</vector>
|
||||
@@ -122,6 +122,23 @@
|
||||
android:textSize="14sp" />
|
||||
</LinearLayout>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/media_seamless_fallback"
|
||||
android:layout_width="@dimen/qs_seamless_icon_size"
|
||||
android:layout_height="@dimen/qs_seamless_icon_size"
|
||||
android:tint="@color/media_primary_text"
|
||||
android:src="@drawable/ic_cast_connected"
|
||||
android:forceHasOverlappingRendering="false" />
|
||||
|
||||
<androidx.constraintlayout.widget.Barrier
|
||||
android:id="@+id/media_seamless_barrier"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:barrierDirection="start"
|
||||
app:constraint_referenced_ids="media_seamless,media_seamless_fallback"
|
||||
app:barrierAllowsGoneWidgets="false"
|
||||
/>
|
||||
|
||||
<!-- Seek Bar -->
|
||||
<SeekBar
|
||||
android:id="@+id/media_progress_bar"
|
||||
|
||||
@@ -1269,6 +1269,9 @@
|
||||
<dimen name="qs_media_panel_outer_padding">16dp</dimen>
|
||||
<dimen name="qs_media_album_size">52dp</dimen>
|
||||
<dimen name="qs_seamless_icon_size">20dp</dimen>
|
||||
<dimen name="qs_seamless_fallback_icon_size">20dp</dimen>
|
||||
<dimen name="qs_seamless_fallback_top_margin">18dp</dimen>
|
||||
<dimen name="qs_seamless_fallback_end_margin">16dp</dimen>
|
||||
<dimen name="qqs_media_spacing">16dp</dimen>
|
||||
<dimen name="qs_footer_horizontal_margin">22dp</dimen>
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
android:layout_marginTop="20dp"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/icon"
|
||||
app:layout_constraintEnd_toStartOf="@id/media_seamless"
|
||||
app:layout_constraintEnd_toStartOf="@id/media_seamless_barrier"
|
||||
app:layout_constraintHorizontal_bias="0"
|
||||
/>
|
||||
|
||||
@@ -51,6 +51,18 @@
|
||||
android:layout_marginEnd="@dimen/qs_media_panel_outer_padding"
|
||||
/>
|
||||
|
||||
<Constraint
|
||||
android:id="@+id/media_seamless_fallback"
|
||||
android:layout_width="@dimen/qs_seamless_fallback_icon_size"
|
||||
android:layout_height="@dimen/qs_seamless_fallback_icon_size"
|
||||
android:layout_marginTop="@dimen/qs_seamless_fallback_top_margin"
|
||||
android:layout_marginEnd="@dimen/qs_seamless_fallback_end_margin"
|
||||
android:alpha="0.5"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
/>
|
||||
|
||||
<Constraint
|
||||
android:id="@+id/album_art"
|
||||
android:layout_width="@dimen/qs_media_album_size"
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
android:layout_marginTop="20dp"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/icon"
|
||||
app:layout_constraintEnd_toStartOf="@id/media_seamless"
|
||||
app:layout_constraintEnd_toStartOf="@id/media_seamless_barrier"
|
||||
app:layout_constraintHorizontal_bias="0"
|
||||
/>
|
||||
|
||||
@@ -51,6 +51,18 @@
|
||||
android:layout_marginEnd="@dimen/qs_media_panel_outer_padding"
|
||||
/>
|
||||
|
||||
<Constraint
|
||||
android:id="@+id/media_seamless_fallback"
|
||||
android:layout_width="@dimen/qs_seamless_fallback_icon_size"
|
||||
android:layout_height="@dimen/qs_seamless_fallback_icon_size"
|
||||
android:layout_marginTop="@dimen/qs_seamless_fallback_top_margin"
|
||||
android:layout_marginEnd="@dimen/qs_seamless_fallback_end_margin"
|
||||
android:alpha="0.5"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
/>
|
||||
|
||||
<Constraint
|
||||
android:id="@+id/album_art"
|
||||
android:layout_width="@dimen/qs_media_album_size"
|
||||
|
||||
@@ -265,21 +265,23 @@ public class MediaControlPanel {
|
||||
rect.setColor(Color.TRANSPARENT);
|
||||
|
||||
final MediaDeviceData device = data.getDevice();
|
||||
int seamlessId = mViewHolder.getSeamless().getId();
|
||||
if (device != null && !device.getEnabled()) {
|
||||
mViewHolder.getSeamless().setEnabled(false);
|
||||
expandedSet.setAlpha(seamlessId, 0.38f);
|
||||
collapsedSet.setAlpha(seamlessId, 0.38f);
|
||||
iconView.setImageResource(R.drawable.ic_hardware_speaker);
|
||||
iconView.setVisibility(View.VISIBLE);
|
||||
deviceName.setText(R.string.media_seamless_remote_device);
|
||||
final int seamlessId = mViewHolder.getSeamless().getId();
|
||||
final int seamlessFallbackId = mViewHolder.getSeamlessFallback().getId();
|
||||
final boolean showFallback = device != null && !device.getEnabled();
|
||||
final int seamlessFallbackVisibility = showFallback ? View.VISIBLE : View.GONE;
|
||||
mViewHolder.getSeamlessFallback().setVisibility(seamlessFallbackVisibility);
|
||||
expandedSet.setVisibility(seamlessFallbackId, seamlessFallbackVisibility);
|
||||
collapsedSet.setVisibility(seamlessFallbackId, seamlessFallbackVisibility);
|
||||
final int seamlessVisibility = showFallback ? View.GONE : View.VISIBLE;
|
||||
mViewHolder.getSeamless().setVisibility(seamlessVisibility);
|
||||
expandedSet.setVisibility(seamlessId, seamlessVisibility);
|
||||
collapsedSet.setVisibility(seamlessId, seamlessVisibility);
|
||||
if (showFallback) {
|
||||
iconView.setImageDrawable(null);
|
||||
deviceName.setText(null);
|
||||
} else if (device != null) {
|
||||
mViewHolder.getSeamless().setEnabled(true);
|
||||
expandedSet.setAlpha(seamlessId, 1.0f);
|
||||
collapsedSet.setAlpha(seamlessId, 1.0f);
|
||||
Drawable icon = device.getIcon();
|
||||
iconView.setVisibility(View.VISIBLE);
|
||||
|
||||
if (icon instanceof AdaptiveIcon) {
|
||||
AdaptiveIcon aIcon = (AdaptiveIcon) icon;
|
||||
aIcon.setBackgroundColor(mBackgroundColor);
|
||||
@@ -291,9 +293,6 @@ public class MediaControlPanel {
|
||||
} else {
|
||||
// Reset to default
|
||||
Log.w(TAG, "device is null. Not binding output chip.");
|
||||
mViewHolder.getSeamless().setEnabled(true);
|
||||
expandedSet.setAlpha(seamlessId, 1.0f);
|
||||
collapsedSet.setAlpha(seamlessId, 1.0f);
|
||||
iconView.setVisibility(View.GONE);
|
||||
deviceName.setText(com.android.internal.R.string.ext_media_seamless_action);
|
||||
}
|
||||
|
||||
@@ -44,6 +44,7 @@ class PlayerViewHolder private constructor(itemView: View) {
|
||||
val seamless = itemView.requireViewById<ViewGroup>(R.id.media_seamless)
|
||||
val seamlessIcon = itemView.requireViewById<ImageView>(R.id.media_seamless_image)
|
||||
val seamlessText = itemView.requireViewById<TextView>(R.id.media_seamless_text)
|
||||
val seamlessFallback = itemView.requireViewById<ImageView>(R.id.media_seamless_fallback)
|
||||
|
||||
// Seek bar
|
||||
val seekBar = itemView.requireViewById<SeekBar>(R.id.media_progress_bar)
|
||||
|
||||
@@ -25,6 +25,7 @@ import android.media.session.MediaSession
|
||||
import android.media.session.PlaybackState
|
||||
import android.testing.AndroidTestingRunner
|
||||
import android.testing.TestableLooper
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.FrameLayout
|
||||
import android.widget.ImageButton
|
||||
@@ -79,6 +80,8 @@ public class MediaControlPanelTest : SysuiTestCase() {
|
||||
@Mock private lateinit var seekBarViewModel: SeekBarViewModel
|
||||
@Mock private lateinit var seekBarData: LiveData<SeekBarViewModel.Progress>
|
||||
@Mock private lateinit var mediaViewController: MediaViewController
|
||||
@Mock private lateinit var expandedSet: ConstraintSet
|
||||
@Mock private lateinit var collapsedSet: ConstraintSet
|
||||
private lateinit var appIcon: ImageView
|
||||
private lateinit var appName: TextView
|
||||
private lateinit var albumView: ImageView
|
||||
@@ -87,6 +90,7 @@ public class MediaControlPanelTest : SysuiTestCase() {
|
||||
private lateinit var seamless: ViewGroup
|
||||
private lateinit var seamlessIcon: ImageView
|
||||
private lateinit var seamlessText: TextView
|
||||
private lateinit var seamlessFallback: ImageView
|
||||
private lateinit var seekBar: SeekBar
|
||||
private lateinit var elapsedTimeView: TextView
|
||||
private lateinit var totalTimeView: TextView
|
||||
@@ -105,8 +109,8 @@ public class MediaControlPanelTest : SysuiTestCase() {
|
||||
@Before
|
||||
fun setUp() {
|
||||
bgExecutor = FakeExecutor(FakeSystemClock())
|
||||
whenever(mediaViewController.expandedLayout).thenReturn(mock(ConstraintSet::class.java))
|
||||
whenever(mediaViewController.collapsedLayout).thenReturn(mock(ConstraintSet::class.java))
|
||||
whenever(mediaViewController.expandedLayout).thenReturn(expandedSet)
|
||||
whenever(mediaViewController.collapsedLayout).thenReturn(collapsedSet)
|
||||
|
||||
player = MediaControlPanel(context, bgExecutor, activityStarter, mediaViewController,
|
||||
seekBarViewModel)
|
||||
@@ -133,6 +137,8 @@ public class MediaControlPanelTest : SysuiTestCase() {
|
||||
whenever(holder.seamlessIcon).thenReturn(seamlessIcon)
|
||||
seamlessText = TextView(context)
|
||||
whenever(holder.seamlessText).thenReturn(seamlessText)
|
||||
seamlessFallback = ImageView(context)
|
||||
whenever(holder.seamlessFallback).thenReturn(seamlessFallback)
|
||||
seekBar = SeekBar(context)
|
||||
whenever(holder.seekBar).thenReturn(seekBar)
|
||||
elapsedTimeView = TextView(context)
|
||||
@@ -214,13 +220,16 @@ public class MediaControlPanelTest : SysuiTestCase() {
|
||||
|
||||
@Test
|
||||
fun bindDisabledDevice() {
|
||||
seamless.id = 1
|
||||
seamlessFallback.id = 2
|
||||
player.attach(holder)
|
||||
val state = MediaData(true, BG_COLOR, APP, null, ARTIST, TITLE, null, emptyList(),
|
||||
emptyList(), PACKAGE, session.getSessionToken(), null, disabledDevice, true, null)
|
||||
player.bind(state)
|
||||
assertThat(seamless.isEnabled()).isFalse()
|
||||
assertThat(seamlessText.getText()).isEqualTo(context.getResources().getString(
|
||||
R.string.media_seamless_remote_device))
|
||||
verify(expandedSet).setVisibility(seamless.id, View.GONE)
|
||||
verify(expandedSet).setVisibility(seamlessFallback.id, View.VISIBLE)
|
||||
verify(collapsedSet).setVisibility(seamless.id, View.GONE)
|
||||
verify(collapsedSet).setVisibility(seamlessFallback.id, View.VISIBLE)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user