Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 53b60ed1 authored by Alexandr Shabalin's avatar Alexandr Shabalin Committed by Android (Google) Code Review
Browse files

Merge "Fix UI glitches in the refreshed design." into main

parents a08e295f 66384da3
Loading
Loading
Loading
Loading
+19 −2
Original line number Diff line number Diff line
@@ -124,7 +124,7 @@ class MediaOutputAdapterTest : SysuiTestCase() {
    }

    @Test
    fun getItemId_forDifferentItemsTypes_returnCorrespondingHashCode() {
    fun getItemId_forDevice_returnsIdHashCode() {
        updateAdapterWithDevices(listOf(mMediaDevice1, mMediaDevice2))

        assertThat(mMediaOutputAdapter.getItemId(0))
@@ -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

+1 −0
Original line number Diff line number Diff line
@@ -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"
+9 −1
Original line number Diff line number Diff line
@@ -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
        }
    }
@@ -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)
@@ -267,6 +268,7 @@ class MediaOutputAdapter(controller: MediaSwitchingController) :
        override fun renderDeviceGroupItem() {
            mTitleIcon.visibility = GONE
            val colorTheme = ColorTheme()
            updateItemBackground()
            updateTitle(
                title = mController.sessionName ?: "",
                connectionState = CONNECTED,
@@ -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())
        }
@@ -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
@@ -614,6 +621,7 @@ class MediaOutputAdapter(controller: MediaSwitchingController) :
            } else {
                mTopSeparator.visibility = GONE
            }
            mItemLayout.setBackgroundColor(mController.colorScheme.getSurfaceContainer())
            updateExpandButton(isExpandableDivider)
        }