Merge "Add compact version of new layout for phone landscape"
This commit is contained in:
committed by
Android (Google) Code Review
commit
33416cd8bc
@@ -29,14 +29,14 @@
|
||||
android:theme="@style/MediaPlayer">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/album_art"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="184dp"
|
||||
android:layout_height="@dimen/qs_media_session_height_expanded"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
android:translationZ="0dp"
|
||||
android:id="@+id/album_art"
|
||||
android:scaleType="centerCrop"
|
||||
android:adjustViewBounds="true"
|
||||
android:clipToOutline="true"
|
||||
@@ -154,10 +154,7 @@
|
||||
android:layout_marginStart="@dimen/qs_media_padding"
|
||||
android:layout_marginEnd="@dimen/qs_media_padding"
|
||||
android:layout_marginTop="0dp"
|
||||
android:layout_marginBottom="0dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/media_seamless"
|
||||
app:layout_constraintBottom_toTopOf="@id/actionEnd" />
|
||||
android:layout_marginBottom="0dp" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/actionPrev"
|
||||
@@ -168,11 +165,8 @@
|
||||
android:layout_marginEnd="0dp"
|
||||
android:layout_marginBottom="0dp"
|
||||
android:layout_marginTop="0dp"
|
||||
app:layout_constraintHorizontal_chainStyle="packed"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@id/media_progress_bar"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/actionPlayPause" />
|
||||
app:layout_constraintHorizontal_bias="1"
|
||||
app:layout_constraintHorizontal_chainStyle="packed" />
|
||||
|
||||
<!-- Seek Bar -->
|
||||
<!-- As per Material Design on Bidirectionality, this is forced to LTR in code -->
|
||||
@@ -188,11 +182,7 @@
|
||||
android:layout_marginBottom="0dp"
|
||||
android:layout_marginTop="0dp"
|
||||
android:layout_marginStart="0dp"
|
||||
android:layout_marginEnd="0dp"
|
||||
app:layout_constraintStart_toEndOf="@id/actionPrev"
|
||||
app:layout_constraintEnd_toStartOf="@id/actionNext"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/actionPlayPause" />
|
||||
android:layout_marginEnd="0dp" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/actionNext"
|
||||
@@ -202,11 +192,7 @@
|
||||
android:layout_marginStart="0dp"
|
||||
android:layout_marginEnd="@dimen/qs_media_action_spacing"
|
||||
android:layout_marginBottom="0dp"
|
||||
android:layout_marginTop="0dp"
|
||||
app:layout_constraintStart_toEndOf="@id/media_progress_bar"
|
||||
app:layout_constraintEnd_toStartOf="@id/actionStart"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/actionPlayPause" />
|
||||
android:layout_marginTop="0dp" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/actionStart"
|
||||
@@ -216,11 +202,7 @@
|
||||
android:layout_marginStart="@dimen/qs_media_action_spacing"
|
||||
android:layout_marginEnd="@dimen/qs_media_action_spacing"
|
||||
android:layout_marginBottom="0dp"
|
||||
android:layout_marginTop="0dp"
|
||||
app:layout_constraintStart_toEndOf="@id/actionNext"
|
||||
app:layout_constraintEnd_toStartOf="@id/actionEnd"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/actionPlayPause" />
|
||||
android:layout_marginTop="0dp" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/actionEnd"
|
||||
@@ -231,11 +213,7 @@
|
||||
android:layout_marginEnd="4dp"
|
||||
android:layout_marginBottom="0dp"
|
||||
android:layout_marginTop="0dp"
|
||||
app:layout_constraintHorizontal_chainStyle="packed"
|
||||
app:layout_constraintStart_toEndOf="@id/actionStart"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/actionPlayPause" />
|
||||
app:layout_constraintHorizontal_chainStyle="packed" />
|
||||
|
||||
<!-- Long press menu -->
|
||||
<TextView
|
||||
|
||||
@@ -23,6 +23,9 @@
|
||||
<!-- The maximum number of rows in the QuickSettings -->
|
||||
<integer name="quick_settings_max_rows">4</integer>
|
||||
|
||||
<!-- Use collapsed layout for media player in landscape QQS -->
|
||||
<bool name="config_quickSettingsMediaLandscapeCollapsed">false</bool>
|
||||
|
||||
<!-- Nav bar button default ordering/layout -->
|
||||
<string name="config_navBarLayout" translatable="false">left;back,home,recent;right</string>
|
||||
|
||||
|
||||
@@ -102,6 +102,9 @@
|
||||
<item>one_handed_mode_enabled:onehanded</item>
|
||||
</string-array>
|
||||
|
||||
<!-- Use collapsed layout for media player in landscape QQS -->
|
||||
<bool name="config_quickSettingsMediaLandscapeCollapsed">true</bool>
|
||||
|
||||
<!-- Show indicator for Wifi on but not connected. -->
|
||||
<bool name="config_showWifiIndicatorWhenEnabled">false</bool>
|
||||
|
||||
|
||||
@@ -990,6 +990,8 @@
|
||||
<!-- Sizes for alternate session-based layout -->
|
||||
<dimen name="qs_media_session_enabled_seekbar_vertical_padding">15dp</dimen>
|
||||
<dimen name="qs_media_session_disabled_seekbar_vertical_padding">16dp</dimen>
|
||||
<dimen name="qs_media_session_height_expanded">184dp</dimen>
|
||||
<dimen name="qs_media_session_height_collapsed">128dp</dimen>
|
||||
|
||||
<!-- Size of Smartspace media recommendations cards in the QSPanel carousel -->
|
||||
<dimen name="qs_aa_media_rec_album_size_collapsed">72dp</dimen>
|
||||
|
||||
90
packages/SystemUI/res/xml/media_session_collapsed.xml
Normal file
90
packages/SystemUI/res/xml/media_session_collapsed.xml
Normal file
@@ -0,0 +1,90 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ Copyright (C) 2022 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
|
||||
-->
|
||||
<ConstraintSet
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<Constraint
|
||||
android:id="@+id/album_art"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/qs_media_session_height_collapsed"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent" />
|
||||
|
||||
<Constraint
|
||||
android:id="@+id/actionPlayPause"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:layout_marginEnd="@dimen/qs_media_padding"
|
||||
app:layout_constraintStart_toEndOf="@id/actionEnd"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/media_seamless"
|
||||
app:layout_constraintBottom_toBottomOf="parent" />
|
||||
|
||||
<Constraint
|
||||
android:id="@+id/actionPrev"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
app:layout_constraintHorizontal_bias="1"
|
||||
app:layout_constraintHorizontal_chainStyle="packed"
|
||||
app:layout_constraintStart_toEndOf="@id/header_artist"
|
||||
app:layout_constraintEnd_toStartOf="@id/media_progress_bar"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/media_seamless" />
|
||||
|
||||
<Constraint
|
||||
android:id="@+id/media_progress_bar"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintStart_toEndOf="@id/actionPrev"
|
||||
app:layout_constraintEnd_toStartOf="@id/actionNext"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/media_seamless" />
|
||||
|
||||
<Constraint
|
||||
android:id="@+id/actionNext"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
app:layout_constraintStart_toEndOf="@id/media_progress_bar"
|
||||
app:layout_constraintEnd_toStartOf="@id/actionStart"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/media_seamless" />
|
||||
|
||||
<Constraint
|
||||
android:id="@+id/actionStart"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintStart_toEndOf="@id/actionNext"
|
||||
app:layout_constraintEnd_toStartOf="@id/actionEnd"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/media_seamless" />
|
||||
|
||||
<Constraint
|
||||
android:id="@+id/actionEnd"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintStart_toEndOf="@id/actionStart"
|
||||
app:layout_constraintEnd_toStartOf="@id/actionPlayPause"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/media_seamless" />
|
||||
|
||||
</ConstraintSet>
|
||||
84
packages/SystemUI/res/xml/media_session_expanded.xml
Normal file
84
packages/SystemUI/res/xml/media_session_expanded.xml
Normal file
@@ -0,0 +1,84 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ Copyright (C) 2022 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
|
||||
-->
|
||||
<ConstraintSet
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<Constraint
|
||||
android:id="@+id/album_art"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/qs_media_session_height_expanded"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent" />
|
||||
|
||||
<Constraint
|
||||
android:id="@+id/actionPlayPause"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:layout_marginEnd="@dimen/qs_media_padding"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/media_seamless"
|
||||
app:layout_constraintBottom_toTopOf="@id/actionEnd" />
|
||||
|
||||
<Constraint
|
||||
android:id="@+id/actionPrev"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@id/media_progress_bar"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/actionPlayPause" />
|
||||
|
||||
<Constraint
|
||||
android:id="@+id/media_progress_bar"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintStart_toEndOf="@id/actionPrev"
|
||||
app:layout_constraintEnd_toStartOf="@id/actionNext"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/actionPlayPause" />
|
||||
|
||||
<Constraint
|
||||
android:id="@+id/actionNext"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
app:layout_constraintStart_toEndOf="@id/media_progress_bar"
|
||||
app:layout_constraintEnd_toStartOf="@id/actionStart"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/actionPlayPause" />
|
||||
|
||||
<Constraint
|
||||
android:id="@+id/actionStart"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
app:layout_constraintStart_toEndOf="@id/actionNext"
|
||||
app:layout_constraintEnd_toStartOf="@id/actionEnd"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/actionPlayPause" />
|
||||
|
||||
<Constraint
|
||||
android:id="@+id/actionEnd"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
app:layout_constraintStart_toEndOf="@id/actionStart"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/actionPlayPause" />
|
||||
|
||||
</ConstraintSet>
|
||||
@@ -45,7 +45,8 @@ class KeyguardMediaController @Inject constructor(
|
||||
private val statusBarStateController: SysuiStatusBarStateController,
|
||||
private val notifLockscreenUserManager: NotificationLockscreenUserManager,
|
||||
private val context: Context,
|
||||
configurationController: ConfigurationController
|
||||
configurationController: ConfigurationController,
|
||||
private val mediaFlags: MediaFlags
|
||||
) {
|
||||
|
||||
init {
|
||||
@@ -61,7 +62,11 @@ class KeyguardMediaController @Inject constructor(
|
||||
})
|
||||
|
||||
// First let's set the desired state that we want for this host
|
||||
mediaHost.expansion = MediaHostState.COLLAPSED
|
||||
mediaHost.expansion = if (mediaFlags.useMediaSessionLayout()) {
|
||||
MediaHostState.EXPANDED
|
||||
} else {
|
||||
MediaHostState.COLLAPSED
|
||||
}
|
||||
mediaHost.showsOnlyActiveMedia = true
|
||||
mediaHost.falsingProtectionNeeded = true
|
||||
|
||||
|
||||
@@ -471,14 +471,16 @@ class MediaViewController @Inject constructor(
|
||||
|
||||
private fun updateMediaViewControllerType(type: TYPE) {
|
||||
this.type = type
|
||||
|
||||
// These XML resources contain ConstraintSets that will apply to this player type's layout
|
||||
when (type) {
|
||||
TYPE.PLAYER -> {
|
||||
collapsedLayout.load(context, R.xml.media_collapsed)
|
||||
expandedLayout.load(context, R.xml.media_expanded)
|
||||
}
|
||||
TYPE.PLAYER_SESSION -> {
|
||||
collapsedLayout.clone(context, R.layout.media_session_view)
|
||||
expandedLayout.clone(context, R.layout.media_session_view)
|
||||
collapsedLayout.load(context, R.xml.media_session_collapsed)
|
||||
expandedLayout.load(context, R.xml.media_session_expanded)
|
||||
}
|
||||
TYPE.RECOMMENDATION -> {
|
||||
collapsedLayout.load(context, R.xml.media_recommendation_collapsed)
|
||||
|
||||
@@ -17,12 +17,16 @@
|
||||
package com.android.systemui.qs;
|
||||
|
||||
import static com.android.systemui.media.dagger.MediaModule.QUICK_QS_PANEL;
|
||||
import static com.android.systemui.qs.dagger.QSFragmentModule.QS_USING_COLLAPSED_LANDSCAPE_MEDIA;
|
||||
import static com.android.systemui.qs.dagger.QSFragmentModule.QS_USING_MEDIA_PLAYER;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
|
||||
import com.android.internal.logging.MetricsLogger;
|
||||
import com.android.internal.logging.UiEventLogger;
|
||||
import com.android.systemui.R;
|
||||
import com.android.systemui.dump.DumpManager;
|
||||
import com.android.systemui.media.MediaFlags;
|
||||
import com.android.systemui.media.MediaHierarchyManager;
|
||||
import com.android.systemui.media.MediaHost;
|
||||
import com.android.systemui.plugins.qs.QSTile;
|
||||
@@ -31,6 +35,7 @@ import com.android.systemui.qs.dagger.QSScope;
|
||||
import com.android.systemui.qs.logging.QSLogger;
|
||||
import com.android.systemui.settings.brightness.BrightnessMirrorHandler;
|
||||
import com.android.systemui.statusbar.policy.BrightnessMirrorController;
|
||||
import com.android.systemui.util.leak.RotationUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -54,11 +59,16 @@ public class QuickQSPanelController extends QSPanelControllerBase<QuickQSPanel>
|
||||
private final QuickQSBrightnessController mBrightnessController;
|
||||
private final BrightnessMirrorHandler mBrightnessMirrorHandler;
|
||||
|
||||
private final MediaFlags mMediaFlags;
|
||||
private final boolean mUsingCollapsedLandscapeMedia;
|
||||
|
||||
@Inject
|
||||
QuickQSPanelController(QuickQSPanel view, QSTileHost qsTileHost,
|
||||
QSCustomizerController qsCustomizerController,
|
||||
@Named(QS_USING_MEDIA_PLAYER) boolean usingMediaPlayer,
|
||||
@Named(QUICK_QS_PANEL) MediaHost mediaHost,
|
||||
@Named(QS_USING_COLLAPSED_LANDSCAPE_MEDIA) boolean usingCollapsedLandscapeMedia,
|
||||
MediaFlags mediaFlags,
|
||||
MetricsLogger metricsLogger, UiEventLogger uiEventLogger, QSLogger qsLogger,
|
||||
DumpManager dumpManager,
|
||||
QuickQSBrightnessController quickQSBrightnessController
|
||||
@@ -67,17 +77,36 @@ public class QuickQSPanelController extends QSPanelControllerBase<QuickQSPanel>
|
||||
uiEventLogger, qsLogger, dumpManager);
|
||||
mBrightnessController = quickQSBrightnessController;
|
||||
mBrightnessMirrorHandler = new BrightnessMirrorHandler(mBrightnessController);
|
||||
mUsingCollapsedLandscapeMedia = usingCollapsedLandscapeMedia;
|
||||
mMediaFlags = mediaFlags;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onInit() {
|
||||
super.onInit();
|
||||
mMediaHost.setExpansion(0.0f);
|
||||
updateMediaExpansion();
|
||||
mMediaHost.setShowsOnlyActiveMedia(true);
|
||||
mMediaHost.init(MediaHierarchyManager.LOCATION_QQS);
|
||||
mBrightnessController.init(mShouldUseSplitNotificationShade);
|
||||
}
|
||||
|
||||
private void updateMediaExpansion() {
|
||||
int rotation = getRotation();
|
||||
boolean isLandscape = rotation == RotationUtils.ROTATION_LANDSCAPE
|
||||
|| rotation == RotationUtils.ROTATION_SEASCAPE;
|
||||
if (mMediaFlags.useMediaSessionLayout()
|
||||
&& (!mUsingCollapsedLandscapeMedia || !isLandscape)) {
|
||||
mMediaHost.setExpansion(MediaHost.EXPANDED);
|
||||
} else {
|
||||
mMediaHost.setExpansion(MediaHost.COLLAPSED);
|
||||
}
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
protected int getRotation() {
|
||||
return RotationUtils.getRotation(getContext());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onViewAttached() {
|
||||
super.onViewAttached();
|
||||
@@ -116,6 +145,7 @@ public class QuickQSPanelController extends QSPanelControllerBase<QuickQSPanel>
|
||||
@Override
|
||||
protected void onConfigurationChanged() {
|
||||
mBrightnessController.refreshVisibility(mShouldUseSplitNotificationShade);
|
||||
updateMediaExpansion();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.android.systemui.qs.dagger;
|
||||
|
||||
import static com.android.systemui.util.Utils.useCollapsedMediaInLandscape;
|
||||
import static com.android.systemui.util.Utils.useQsMediaPlayer;
|
||||
|
||||
import android.content.Context;
|
||||
@@ -56,6 +57,7 @@ public interface QSFragmentModule {
|
||||
String QS_FGS_MANAGER_FOOTER_VIEW = "qs_fgs_manager_footer";
|
||||
String QS_SECURITY_FOOTER_VIEW = "qs_security_footer";
|
||||
String QS_USING_MEDIA_PLAYER = "qs_using_media_player";
|
||||
String QS_USING_COLLAPSED_LANDSCAPE_MEDIA = "qs_using_collapsed_landscape_media";
|
||||
|
||||
/**
|
||||
* Provide a context themed using the QS theme
|
||||
@@ -171,6 +173,13 @@ public interface QSFragmentModule {
|
||||
return useQsMediaPlayer(context);
|
||||
}
|
||||
|
||||
/** */
|
||||
@Provides
|
||||
@Named(QS_USING_COLLAPSED_LANDSCAPE_MEDIA)
|
||||
static boolean providesQSUsingCollapsedLandscapeMedia(Context context) {
|
||||
return useCollapsedMediaInLandscape(context.getResources());
|
||||
}
|
||||
|
||||
/** */
|
||||
@Provides
|
||||
@QSScope
|
||||
|
||||
@@ -161,6 +161,14 @@ public class Utils {
|
||||
return useQsMediaPlayer(context) && flag > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the device should use the collapsed layout for the media player when in
|
||||
* landscape (or seascape) orientation
|
||||
*/
|
||||
public static boolean useCollapsedMediaInLandscape(Resources resources) {
|
||||
return resources.getBoolean(R.bool.config_quickSettingsMediaLandscapeCollapsed);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the device should use the split notification shade, based on orientation and
|
||||
* screen width.
|
||||
|
||||
@@ -36,6 +36,7 @@ import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mockito.Mock
|
||||
import org.mockito.Mockito.verify
|
||||
import org.mockito.junit.MockitoJUnit
|
||||
import org.mockito.Mockito.`when` as whenever
|
||||
|
||||
@@ -51,6 +52,8 @@ class KeyguardMediaControllerTest : SysuiTestCase() {
|
||||
private lateinit var statusBarStateController: SysuiStatusBarStateController
|
||||
@Mock
|
||||
private lateinit var configurationController: ConfigurationController
|
||||
@Mock
|
||||
private lateinit var mediaFlags: MediaFlags
|
||||
|
||||
@Mock
|
||||
private lateinit var notificationLockscreenUserManager: NotificationLockscreenUserManager
|
||||
@@ -70,13 +73,15 @@ class KeyguardMediaControllerTest : SysuiTestCase() {
|
||||
.thenReturn(true)
|
||||
whenever(mediaHost.hostView).thenReturn(hostView)
|
||||
hostView.layoutParams = FrameLayout.LayoutParams(100, 100)
|
||||
whenever(mediaFlags.useMediaSessionLayout()).thenReturn(false)
|
||||
keyguardMediaController = KeyguardMediaController(
|
||||
mediaHost,
|
||||
bypassController,
|
||||
statusBarStateController,
|
||||
notificationLockscreenUserManager,
|
||||
context,
|
||||
configurationController
|
||||
configurationController,
|
||||
mediaFlags
|
||||
)
|
||||
keyguardMediaController.attachSinglePaneContainer(mediaContainerView)
|
||||
keyguardMediaController.useSplitShade = false
|
||||
@@ -150,4 +155,24 @@ class KeyguardMediaControllerTest : SysuiTestCase() {
|
||||
assertTrue("HostView wasn't attached to the single pane container",
|
||||
mediaContainerView.childCount == 1)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testNotificationLayout_collapsedPlayer() {
|
||||
verify(mediaHost).expansion = MediaHostState.COLLAPSED
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testSessionLayout_expandedPlayer() {
|
||||
whenever(mediaFlags.useMediaSessionLayout()).thenReturn(true)
|
||||
keyguardMediaController = KeyguardMediaController(
|
||||
mediaHost,
|
||||
bypassController,
|
||||
statusBarStateController,
|
||||
notificationLockscreenUserManager,
|
||||
context,
|
||||
configurationController,
|
||||
mediaFlags
|
||||
)
|
||||
verify(mediaHost).expansion = MediaHostState.EXPANDED
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,11 +23,14 @@ import com.android.internal.logging.MetricsLogger
|
||||
import com.android.internal.logging.testing.UiEventLoggerFake
|
||||
import com.android.systemui.SysuiTestCase
|
||||
import com.android.systemui.dump.DumpManager
|
||||
import com.android.systemui.media.MediaFlags
|
||||
import com.android.systemui.media.MediaHost
|
||||
import com.android.systemui.media.MediaHostState
|
||||
import com.android.systemui.plugins.qs.QSTile
|
||||
import com.android.systemui.plugins.qs.QSTileView
|
||||
import com.android.systemui.qs.customize.QSCustomizerController
|
||||
import com.android.systemui.qs.logging.QSLogger
|
||||
import com.android.systemui.util.leak.RotationUtils
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
@@ -55,6 +58,8 @@ class QuickQSPanelControllerTest : SysuiTestCase() {
|
||||
@Mock
|
||||
private lateinit var mediaHost: MediaHost
|
||||
@Mock
|
||||
private lateinit var mediaFlags: MediaFlags
|
||||
@Mock
|
||||
private lateinit var metricsLogger: MetricsLogger
|
||||
private val uiEventLogger = UiEventLoggerFake()
|
||||
@Mock
|
||||
@@ -71,7 +76,7 @@ class QuickQSPanelControllerTest : SysuiTestCase() {
|
||||
@Captor
|
||||
private lateinit var captor: ArgumentCaptor<QSPanel.OnConfigurationChangedListener>
|
||||
|
||||
private lateinit var controller: QuickQSPanelController
|
||||
private lateinit var controller: TestQuickQSPanelController
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
@@ -82,13 +87,16 @@ class QuickQSPanelControllerTest : SysuiTestCase() {
|
||||
`when`(quickQSPanel.dumpableTag).thenReturn("")
|
||||
`when`(quickQSPanel.resources).thenReturn(mContext.resources)
|
||||
`when`(qsTileHost.createTileView(any(), any(), anyBoolean())).thenReturn(tileView)
|
||||
`when`(mediaFlags.useMediaSessionLayout()).thenReturn(false)
|
||||
|
||||
controller = QuickQSPanelController(
|
||||
controller = TestQuickQSPanelController(
|
||||
quickQSPanel,
|
||||
qsTileHost,
|
||||
qsCustomizerController,
|
||||
false,
|
||||
mediaHost,
|
||||
true,
|
||||
mediaFlags,
|
||||
metricsLogger,
|
||||
uiEventLogger,
|
||||
qsLogger,
|
||||
@@ -133,4 +141,49 @@ class QuickQSPanelControllerTest : SysuiTestCase() {
|
||||
|
||||
verify(quickQsBrightnessController).refreshVisibility(anyBoolean())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testMediaExpansionUpdatedWhenConfigurationChanged() {
|
||||
`when`(mediaFlags.useMediaSessionLayout()).thenReturn(true)
|
||||
|
||||
// times(2) because both controller and base controller are registering their listeners
|
||||
verify(quickQSPanel, times(2)).addOnConfigurationChangedListener(captor.capture())
|
||||
|
||||
captor.allValues.forEach { it.onConfigurationChange(Configuration.EMPTY) }
|
||||
verify(mediaHost).expansion = MediaHostState.EXPANDED
|
||||
|
||||
// Rotate device, verify media size updated
|
||||
controller.setRotation(RotationUtils.ROTATION_LANDSCAPE)
|
||||
captor.allValues.forEach { it.onConfigurationChange(Configuration.EMPTY) }
|
||||
|
||||
// times(2) because init will have set to collapsed because the flag was off
|
||||
verify(mediaHost, times(2)).expansion = MediaHostState.COLLAPSED
|
||||
}
|
||||
|
||||
class TestQuickQSPanelController(
|
||||
view: QuickQSPanel,
|
||||
qsTileHost: QSTileHost,
|
||||
qsCustomizerController: QSCustomizerController,
|
||||
usingMediaPlayer: Boolean,
|
||||
mediaHost: MediaHost,
|
||||
usingCollapsedLandscapeMedia: Boolean,
|
||||
mediaFlags: MediaFlags,
|
||||
metricsLogger: MetricsLogger,
|
||||
uiEventLogger: UiEventLoggerFake,
|
||||
qsLogger: QSLogger,
|
||||
dumpManager: DumpManager,
|
||||
quickQSBrightnessController: QuickQSBrightnessController
|
||||
) : QuickQSPanelController(view, qsTileHost, qsCustomizerController, usingMediaPlayer,
|
||||
mediaHost, usingCollapsedLandscapeMedia, mediaFlags, metricsLogger, uiEventLogger, qsLogger,
|
||||
dumpManager, quickQSBrightnessController) {
|
||||
|
||||
private var rotation = RotationUtils.ROTATION_NONE
|
||||
|
||||
@Override
|
||||
override fun getRotation(): Int = rotation
|
||||
|
||||
fun setRotation(newRotation: Int) {
|
||||
rotation = newRotation
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user