Merge "Reduce device fallback to just icon" into rvc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
1d53e823fd
@@ -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" />
|
android:textSize="14sp" />
|
||||||
</LinearLayout>
|
</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 -->
|
<!-- Seek Bar -->
|
||||||
<SeekBar
|
<SeekBar
|
||||||
android:id="@+id/media_progress_bar"
|
android:id="@+id/media_progress_bar"
|
||||||
|
|||||||
@@ -1269,6 +1269,9 @@
|
|||||||
<dimen name="qs_media_panel_outer_padding">16dp</dimen>
|
<dimen name="qs_media_panel_outer_padding">16dp</dimen>
|
||||||
<dimen name="qs_media_album_size">52dp</dimen>
|
<dimen name="qs_media_album_size">52dp</dimen>
|
||||||
<dimen name="qs_seamless_icon_size">20dp</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="qqs_media_spacing">16dp</dimen>
|
||||||
<dimen name="qs_footer_horizontal_margin">22dp</dimen>
|
<dimen name="qs_footer_horizontal_margin">22dp</dimen>
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,7 @@
|
|||||||
android:layout_marginTop="20dp"
|
android:layout_marginTop="20dp"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
app:layout_constraintStart_toEndOf="@id/icon"
|
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"
|
app:layout_constraintHorizontal_bias="0"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
@@ -51,6 +51,18 @@
|
|||||||
android:layout_marginEnd="@dimen/qs_media_panel_outer_padding"
|
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
|
<Constraint
|
||||||
android:id="@+id/album_art"
|
android:id="@+id/album_art"
|
||||||
android:layout_width="@dimen/qs_media_album_size"
|
android:layout_width="@dimen/qs_media_album_size"
|
||||||
|
|||||||
@@ -36,7 +36,7 @@
|
|||||||
android:layout_marginTop="20dp"
|
android:layout_marginTop="20dp"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
app:layout_constraintStart_toEndOf="@id/icon"
|
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"
|
app:layout_constraintHorizontal_bias="0"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
@@ -51,6 +51,18 @@
|
|||||||
android:layout_marginEnd="@dimen/qs_media_panel_outer_padding"
|
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
|
<Constraint
|
||||||
android:id="@+id/album_art"
|
android:id="@+id/album_art"
|
||||||
android:layout_width="@dimen/qs_media_album_size"
|
android:layout_width="@dimen/qs_media_album_size"
|
||||||
|
|||||||
@@ -265,21 +265,23 @@ public class MediaControlPanel {
|
|||||||
rect.setColor(Color.TRANSPARENT);
|
rect.setColor(Color.TRANSPARENT);
|
||||||
|
|
||||||
final MediaDeviceData device = data.getDevice();
|
final MediaDeviceData device = data.getDevice();
|
||||||
int seamlessId = mViewHolder.getSeamless().getId();
|
final int seamlessId = mViewHolder.getSeamless().getId();
|
||||||
if (device != null && !device.getEnabled()) {
|
final int seamlessFallbackId = mViewHolder.getSeamlessFallback().getId();
|
||||||
mViewHolder.getSeamless().setEnabled(false);
|
final boolean showFallback = device != null && !device.getEnabled();
|
||||||
expandedSet.setAlpha(seamlessId, 0.38f);
|
final int seamlessFallbackVisibility = showFallback ? View.VISIBLE : View.GONE;
|
||||||
collapsedSet.setAlpha(seamlessId, 0.38f);
|
mViewHolder.getSeamlessFallback().setVisibility(seamlessFallbackVisibility);
|
||||||
iconView.setImageResource(R.drawable.ic_hardware_speaker);
|
expandedSet.setVisibility(seamlessFallbackId, seamlessFallbackVisibility);
|
||||||
iconView.setVisibility(View.VISIBLE);
|
collapsedSet.setVisibility(seamlessFallbackId, seamlessFallbackVisibility);
|
||||||
deviceName.setText(R.string.media_seamless_remote_device);
|
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) {
|
} else if (device != null) {
|
||||||
mViewHolder.getSeamless().setEnabled(true);
|
|
||||||
expandedSet.setAlpha(seamlessId, 1.0f);
|
|
||||||
collapsedSet.setAlpha(seamlessId, 1.0f);
|
|
||||||
Drawable icon = device.getIcon();
|
Drawable icon = device.getIcon();
|
||||||
iconView.setVisibility(View.VISIBLE);
|
iconView.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
if (icon instanceof AdaptiveIcon) {
|
if (icon instanceof AdaptiveIcon) {
|
||||||
AdaptiveIcon aIcon = (AdaptiveIcon) icon;
|
AdaptiveIcon aIcon = (AdaptiveIcon) icon;
|
||||||
aIcon.setBackgroundColor(mBackgroundColor);
|
aIcon.setBackgroundColor(mBackgroundColor);
|
||||||
@@ -291,9 +293,6 @@ public class MediaControlPanel {
|
|||||||
} else {
|
} else {
|
||||||
// Reset to default
|
// Reset to default
|
||||||
Log.w(TAG, "device is null. Not binding output chip.");
|
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);
|
iconView.setVisibility(View.GONE);
|
||||||
deviceName.setText(com.android.internal.R.string.ext_media_seamless_action);
|
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 seamless = itemView.requireViewById<ViewGroup>(R.id.media_seamless)
|
||||||
val seamlessIcon = itemView.requireViewById<ImageView>(R.id.media_seamless_image)
|
val seamlessIcon = itemView.requireViewById<ImageView>(R.id.media_seamless_image)
|
||||||
val seamlessText = itemView.requireViewById<TextView>(R.id.media_seamless_text)
|
val seamlessText = itemView.requireViewById<TextView>(R.id.media_seamless_text)
|
||||||
|
val seamlessFallback = itemView.requireViewById<ImageView>(R.id.media_seamless_fallback)
|
||||||
|
|
||||||
// Seek bar
|
// Seek bar
|
||||||
val seekBar = itemView.requireViewById<SeekBar>(R.id.media_progress_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.media.session.PlaybackState
|
||||||
import android.testing.AndroidTestingRunner
|
import android.testing.AndroidTestingRunner
|
||||||
import android.testing.TestableLooper
|
import android.testing.TestableLooper
|
||||||
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.FrameLayout
|
import android.widget.FrameLayout
|
||||||
import android.widget.ImageButton
|
import android.widget.ImageButton
|
||||||
@@ -79,6 +80,8 @@ public class MediaControlPanelTest : SysuiTestCase() {
|
|||||||
@Mock private lateinit var seekBarViewModel: SeekBarViewModel
|
@Mock private lateinit var seekBarViewModel: SeekBarViewModel
|
||||||
@Mock private lateinit var seekBarData: LiveData<SeekBarViewModel.Progress>
|
@Mock private lateinit var seekBarData: LiveData<SeekBarViewModel.Progress>
|
||||||
@Mock private lateinit var mediaViewController: MediaViewController
|
@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 appIcon: ImageView
|
||||||
private lateinit var appName: TextView
|
private lateinit var appName: TextView
|
||||||
private lateinit var albumView: ImageView
|
private lateinit var albumView: ImageView
|
||||||
@@ -87,6 +90,7 @@ public class MediaControlPanelTest : SysuiTestCase() {
|
|||||||
private lateinit var seamless: ViewGroup
|
private lateinit var seamless: ViewGroup
|
||||||
private lateinit var seamlessIcon: ImageView
|
private lateinit var seamlessIcon: ImageView
|
||||||
private lateinit var seamlessText: TextView
|
private lateinit var seamlessText: TextView
|
||||||
|
private lateinit var seamlessFallback: ImageView
|
||||||
private lateinit var seekBar: SeekBar
|
private lateinit var seekBar: SeekBar
|
||||||
private lateinit var elapsedTimeView: TextView
|
private lateinit var elapsedTimeView: TextView
|
||||||
private lateinit var totalTimeView: TextView
|
private lateinit var totalTimeView: TextView
|
||||||
@@ -105,8 +109,8 @@ public class MediaControlPanelTest : SysuiTestCase() {
|
|||||||
@Before
|
@Before
|
||||||
fun setUp() {
|
fun setUp() {
|
||||||
bgExecutor = FakeExecutor(FakeSystemClock())
|
bgExecutor = FakeExecutor(FakeSystemClock())
|
||||||
whenever(mediaViewController.expandedLayout).thenReturn(mock(ConstraintSet::class.java))
|
whenever(mediaViewController.expandedLayout).thenReturn(expandedSet)
|
||||||
whenever(mediaViewController.collapsedLayout).thenReturn(mock(ConstraintSet::class.java))
|
whenever(mediaViewController.collapsedLayout).thenReturn(collapsedSet)
|
||||||
|
|
||||||
player = MediaControlPanel(context, bgExecutor, activityStarter, mediaViewController,
|
player = MediaControlPanel(context, bgExecutor, activityStarter, mediaViewController,
|
||||||
seekBarViewModel)
|
seekBarViewModel)
|
||||||
@@ -133,6 +137,8 @@ public class MediaControlPanelTest : SysuiTestCase() {
|
|||||||
whenever(holder.seamlessIcon).thenReturn(seamlessIcon)
|
whenever(holder.seamlessIcon).thenReturn(seamlessIcon)
|
||||||
seamlessText = TextView(context)
|
seamlessText = TextView(context)
|
||||||
whenever(holder.seamlessText).thenReturn(seamlessText)
|
whenever(holder.seamlessText).thenReturn(seamlessText)
|
||||||
|
seamlessFallback = ImageView(context)
|
||||||
|
whenever(holder.seamlessFallback).thenReturn(seamlessFallback)
|
||||||
seekBar = SeekBar(context)
|
seekBar = SeekBar(context)
|
||||||
whenever(holder.seekBar).thenReturn(seekBar)
|
whenever(holder.seekBar).thenReturn(seekBar)
|
||||||
elapsedTimeView = TextView(context)
|
elapsedTimeView = TextView(context)
|
||||||
@@ -214,13 +220,16 @@ public class MediaControlPanelTest : SysuiTestCase() {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun bindDisabledDevice() {
|
fun bindDisabledDevice() {
|
||||||
|
seamless.id = 1
|
||||||
|
seamlessFallback.id = 2
|
||||||
player.attach(holder)
|
player.attach(holder)
|
||||||
val state = MediaData(true, BG_COLOR, APP, null, ARTIST, TITLE, null, emptyList(),
|
val state = MediaData(true, BG_COLOR, APP, null, ARTIST, TITLE, null, emptyList(),
|
||||||
emptyList(), PACKAGE, session.getSessionToken(), null, disabledDevice, true, null)
|
emptyList(), PACKAGE, session.getSessionToken(), null, disabledDevice, true, null)
|
||||||
player.bind(state)
|
player.bind(state)
|
||||||
assertThat(seamless.isEnabled()).isFalse()
|
verify(expandedSet).setVisibility(seamless.id, View.GONE)
|
||||||
assertThat(seamlessText.getText()).isEqualTo(context.getResources().getString(
|
verify(expandedSet).setVisibility(seamlessFallback.id, View.VISIBLE)
|
||||||
R.string.media_seamless_remote_device))
|
verify(collapsedSet).setVisibility(seamless.id, View.GONE)
|
||||||
|
verify(collapsedSet).setVisibility(seamlessFallback.id, View.VISIBLE)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
Reference in New Issue
Block a user