Loading packages/SystemUI/multivalentTests/src/com/android/systemui/media/dialog/MediaOutputAdapterTest.kt +19 −2 Original line number Diff line number Diff line Loading @@ -124,7 +124,7 @@ class MediaOutputAdapterTest : SysuiTestCase() { } @Test fun getItemId_forDifferentItemsTypes_returnCorrespondingHashCode() { fun getItemId_forDevice_returnsIdHashCode() { updateAdapterWithDevices(listOf(mMediaDevice1, mMediaDevice2)) assertThat(mMediaOutputAdapter.getItemId(0)) Loading @@ -132,7 +132,24 @@ class MediaOutputAdapterTest : SysuiTestCase() { } @Test fun getItemId_invalidPosition_returnPosition() { fun getItemId_forGroupSeparator_returnsTitleHashCode() { mMediaItems.add(MediaItem.createGroupDividerMediaItem("Suggested Devices")) mMediaOutputAdapter.updateItems() assertThat(mMediaOutputAdapter.getItemId(0)).isEqualTo("Suggested Devices".hashCode()) } @Test fun getItemId_forDeviceGroup_returnsItemType() { mMediaSwitchingController.stub { on { isGroupListCollapsed } doReturn true } initializeSession() assertThat(mMediaOutputAdapter.getItemId(1)) .isEqualTo(MediaItemType.TYPE_DEVICE_GROUP.toLong()) } @Test fun getItemId_invalidPosition_returnsNoId() { updateAdapterWithDevices(listOf(mMediaDevice1, mMediaDevice2)) val invalidPosition = mMediaItems.size + 1 Loading packages/SystemUI/res/layout/media_output_list_item_group_divider.xml +1 −0 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ ~ limitations under the License. --> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/item_layout" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginHorizontal="@dimen/media_output_dialog_margin_horizontal" Loading packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputAdapter.kt +9 −1 Original line number Diff line number Diff line Loading @@ -111,7 +111,7 @@ class MediaOutputAdapter(controller: MediaSwitchingController) : currentMediaItem.mediaDevice.getOrNull()?.id?.hashCode()?.toLong() ?: RecyclerView.NO_ID TYPE_GROUP_DIVIDER -> currentMediaItem.title.hashCode().toLong() TYPE_DEVICE_GROUP -> currentMediaItem.hashCode().toLong() TYPE_DEVICE_GROUP -> currentMediaItem.mediaItemType.toLong() else -> RecyclerView.NO_ID } } Loading Loading @@ -253,6 +253,7 @@ class MediaOutputAdapter(controller: MediaSwitchingController) : val fixedVolumeConnected = connectionState == CONNECTED && restrictVolumeAdjustment val colorTheme = ColorTheme(fixedVolumeConnected, deviceDisabled) updateItemBackground() updateTitle(device.name, connectionState, colorTheme) updateTitleIcon(device, connectionState, restrictVolumeAdjustment, colorTheme) updateSubtitle(subtitle, colorTheme) Loading @@ -267,6 +268,7 @@ class MediaOutputAdapter(controller: MediaSwitchingController) : override fun renderDeviceGroupItem() { mTitleIcon.visibility = GONE val colorTheme = ColorTheme() updateItemBackground() updateTitle( title = mController.sessionName ?: "", connectionState = CONNECTED, Loading Loading @@ -299,6 +301,10 @@ class MediaOutputAdapter(controller: MediaSwitchingController) : } } private fun updateItemBackground() { mItemLayout.setBackgroundColor(mController.colorScheme.getSurfaceContainer()) } private fun updateContentPadding(verticalPadding: Float) { mMainContent.setPadding(0, verticalPadding.toInt(), 0, verticalPadding.toInt()) } Loading Loading @@ -595,6 +601,7 @@ class MediaOutputAdapter(controller: MediaSwitchingController) : inner class MediaGroupDividerViewHolder(itemView: View, val mContext: Context) : RecyclerView.ViewHolder(itemView) { private val mItemLayout: ViewGroup = itemView.requireViewById(R.id.item_layout) private val mTopSeparator: View = itemView.requireViewById(R.id.top_separator) private val mTitleText: TextView = itemView.requireViewById(R.id.title) @VisibleForTesting Loading @@ -614,6 +621,7 @@ class MediaOutputAdapter(controller: MediaSwitchingController) : } else { mTopSeparator.visibility = GONE } mItemLayout.setBackgroundColor(mController.colorScheme.getSurfaceContainer()) updateExpandButton(isExpandableDivider) } Loading Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/media/dialog/MediaOutputAdapterTest.kt +19 −2 Original line number Diff line number Diff line Loading @@ -124,7 +124,7 @@ class MediaOutputAdapterTest : SysuiTestCase() { } @Test fun getItemId_forDifferentItemsTypes_returnCorrespondingHashCode() { fun getItemId_forDevice_returnsIdHashCode() { updateAdapterWithDevices(listOf(mMediaDevice1, mMediaDevice2)) assertThat(mMediaOutputAdapter.getItemId(0)) Loading @@ -132,7 +132,24 @@ class MediaOutputAdapterTest : SysuiTestCase() { } @Test fun getItemId_invalidPosition_returnPosition() { fun getItemId_forGroupSeparator_returnsTitleHashCode() { mMediaItems.add(MediaItem.createGroupDividerMediaItem("Suggested Devices")) mMediaOutputAdapter.updateItems() assertThat(mMediaOutputAdapter.getItemId(0)).isEqualTo("Suggested Devices".hashCode()) } @Test fun getItemId_forDeviceGroup_returnsItemType() { mMediaSwitchingController.stub { on { isGroupListCollapsed } doReturn true } initializeSession() assertThat(mMediaOutputAdapter.getItemId(1)) .isEqualTo(MediaItemType.TYPE_DEVICE_GROUP.toLong()) } @Test fun getItemId_invalidPosition_returnsNoId() { updateAdapterWithDevices(listOf(mMediaDevice1, mMediaDevice2)) val invalidPosition = mMediaItems.size + 1 Loading
packages/SystemUI/res/layout/media_output_list_item_group_divider.xml +1 −0 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ ~ limitations under the License. --> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/item_layout" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginHorizontal="@dimen/media_output_dialog_margin_horizontal" Loading
packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputAdapter.kt +9 −1 Original line number Diff line number Diff line Loading @@ -111,7 +111,7 @@ class MediaOutputAdapter(controller: MediaSwitchingController) : currentMediaItem.mediaDevice.getOrNull()?.id?.hashCode()?.toLong() ?: RecyclerView.NO_ID TYPE_GROUP_DIVIDER -> currentMediaItem.title.hashCode().toLong() TYPE_DEVICE_GROUP -> currentMediaItem.hashCode().toLong() TYPE_DEVICE_GROUP -> currentMediaItem.mediaItemType.toLong() else -> RecyclerView.NO_ID } } Loading Loading @@ -253,6 +253,7 @@ class MediaOutputAdapter(controller: MediaSwitchingController) : val fixedVolumeConnected = connectionState == CONNECTED && restrictVolumeAdjustment val colorTheme = ColorTheme(fixedVolumeConnected, deviceDisabled) updateItemBackground() updateTitle(device.name, connectionState, colorTheme) updateTitleIcon(device, connectionState, restrictVolumeAdjustment, colorTheme) updateSubtitle(subtitle, colorTheme) Loading @@ -267,6 +268,7 @@ class MediaOutputAdapter(controller: MediaSwitchingController) : override fun renderDeviceGroupItem() { mTitleIcon.visibility = GONE val colorTheme = ColorTheme() updateItemBackground() updateTitle( title = mController.sessionName ?: "", connectionState = CONNECTED, Loading Loading @@ -299,6 +301,10 @@ class MediaOutputAdapter(controller: MediaSwitchingController) : } } private fun updateItemBackground() { mItemLayout.setBackgroundColor(mController.colorScheme.getSurfaceContainer()) } private fun updateContentPadding(verticalPadding: Float) { mMainContent.setPadding(0, verticalPadding.toInt(), 0, verticalPadding.toInt()) } Loading Loading @@ -595,6 +601,7 @@ class MediaOutputAdapter(controller: MediaSwitchingController) : inner class MediaGroupDividerViewHolder(itemView: View, val mContext: Context) : RecyclerView.ViewHolder(itemView) { private val mItemLayout: ViewGroup = itemView.requireViewById(R.id.item_layout) private val mTopSeparator: View = itemView.requireViewById(R.id.top_separator) private val mTitleText: TextView = itemView.requireViewById(R.id.title) @VisibleForTesting Loading @@ -614,6 +621,7 @@ class MediaOutputAdapter(controller: MediaSwitchingController) : } else { mTopSeparator.visibility = GONE } mItemLayout.setBackgroundColor(mController.colorScheme.getSurfaceContainer()) updateExpandButton(isExpandableDivider) } Loading