Loading packages/SystemUI/res/values/dimens.xml +1 −0 Original line number Diff line number Diff line Loading @@ -2259,6 +2259,7 @@ <dimen name="tile_details_button_size">20dp</dimen> <dimen name="tile_details_entry_gap">2dp</dimen> <dimen name="tile_details_bottom_padding">14dp</dimen> <dimen name="tile_details_horizontal_padding">14dp</dimen> <!-- Tile Details end --> </resources> packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/CastDetailsContent.kt +70 −1 Original line number Diff line number Diff line Loading @@ -16,9 +16,12 @@ package com.android.systemui.qs.tiles.dialog import android.content.Context import android.database.DataSetObserver import android.view.LayoutInflater import android.view.ViewGroup import android.widget.LinearLayout import android.widget.ListAdapter import android.widget.ListView import androidx.compose.foundation.Image import androidx.compose.foundation.layout.Arrangement Loading @@ -38,6 +41,7 @@ import com.android.compose.ui.graphics.painter.rememberDrawablePainter import com.android.internal.R import com.android.internal.app.MediaRouteChooserContentManager import com.android.internal.app.MediaRouteControllerContentManager import com.android.systemui.res.R as SystemUiR private val MAX_CAST_LIST_HEIGHT = 5000.dp Loading Loading @@ -71,6 +75,9 @@ fun CastDetailsContent(castDetailsViewModel: CastDetailsViewModel) { @Composable fun CastChooserView(contentManager: MediaRouteChooserContentManager) { var dataObserver: DataSetObserver? = null var adapter: ListAdapter? = null AndroidView( // Use heightIn on this AndroidView to ensure it measures to a non-zero height that works // within the scrollable area in the `TileDetails`. Loading @@ -92,9 +99,25 @@ fun CastChooserView(contentManager: MediaRouteChooserContentManager) { listView.layoutParams = this } customizeView(listView) // Listen to the adapter data change and `customizeView` when changes occur. adapter = listView.adapter dataObserver = object : DataSetObserver() { override fun onChanged() { super.onChanged() customizeView(listView) } } adapter?.registerDataSetObserver(dataObserver) view }, onRelease = { contentManager.onDetachedFromWindow() }, onRelease = { contentManager.onDetachedFromWindow() adapter?.unregisterDataSetObserver(dataObserver) }, ) } Loading Loading @@ -125,3 +148,49 @@ fun CastControllerDisconnectButton(contentManager: MediaRouteControllerContentMa Text(text = "Disconnect") } } private fun customizeView(listView: ListView) { val context = listView.context val entryBackgroundStart = context.getDrawable(SystemUiR.drawable.settingslib_entry_bg_off_start) val entryBackgroundEnd = context.getDrawable(SystemUiR.drawable.settingslib_entry_bg_off_end) val entryBackgroundMiddle = context.getDrawable(SystemUiR.drawable.settingslib_entry_bg_off_middle) // This code will run after the ListView has had a chance to complete its layout. listView.post { val visibleChildCount = listView.childCount val adapter = listView.adapter val totalItemCount = adapter?.count ?: 0 if (adapter == null || totalItemCount == 0) { return@post } for (i in 0 until visibleChildCount) { val child = listView.getChildAt(i) as LinearLayout val adapterPosition = listView.getPositionForView(child) if (adapterPosition != ListView.INVALID_POSITION) { val entry = child.getChildAt(0) as LinearLayout entry.background = when (adapterPosition) { 0 -> entryBackgroundStart totalItemCount - 1 -> entryBackgroundEnd else -> entryBackgroundMiddle } setPadding(context, child) } } } } private fun setPadding(context: Context, targetBackgroundView: LinearLayout) { val horizontalPadding = context.resources.getDimensionPixelSize(SystemUiR.dimen.tile_details_horizontal_padding) targetBackgroundView.setPadding( horizontalPadding, targetBackgroundView.paddingTop, horizontalPadding, targetBackgroundView.paddingBottom, ) } Loading
packages/SystemUI/res/values/dimens.xml +1 −0 Original line number Diff line number Diff line Loading @@ -2259,6 +2259,7 @@ <dimen name="tile_details_button_size">20dp</dimen> <dimen name="tile_details_entry_gap">2dp</dimen> <dimen name="tile_details_bottom_padding">14dp</dimen> <dimen name="tile_details_horizontal_padding">14dp</dimen> <!-- Tile Details end --> </resources>
packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/CastDetailsContent.kt +70 −1 Original line number Diff line number Diff line Loading @@ -16,9 +16,12 @@ package com.android.systemui.qs.tiles.dialog import android.content.Context import android.database.DataSetObserver import android.view.LayoutInflater import android.view.ViewGroup import android.widget.LinearLayout import android.widget.ListAdapter import android.widget.ListView import androidx.compose.foundation.Image import androidx.compose.foundation.layout.Arrangement Loading @@ -38,6 +41,7 @@ import com.android.compose.ui.graphics.painter.rememberDrawablePainter import com.android.internal.R import com.android.internal.app.MediaRouteChooserContentManager import com.android.internal.app.MediaRouteControllerContentManager import com.android.systemui.res.R as SystemUiR private val MAX_CAST_LIST_HEIGHT = 5000.dp Loading Loading @@ -71,6 +75,9 @@ fun CastDetailsContent(castDetailsViewModel: CastDetailsViewModel) { @Composable fun CastChooserView(contentManager: MediaRouteChooserContentManager) { var dataObserver: DataSetObserver? = null var adapter: ListAdapter? = null AndroidView( // Use heightIn on this AndroidView to ensure it measures to a non-zero height that works // within the scrollable area in the `TileDetails`. Loading @@ -92,9 +99,25 @@ fun CastChooserView(contentManager: MediaRouteChooserContentManager) { listView.layoutParams = this } customizeView(listView) // Listen to the adapter data change and `customizeView` when changes occur. adapter = listView.adapter dataObserver = object : DataSetObserver() { override fun onChanged() { super.onChanged() customizeView(listView) } } adapter?.registerDataSetObserver(dataObserver) view }, onRelease = { contentManager.onDetachedFromWindow() }, onRelease = { contentManager.onDetachedFromWindow() adapter?.unregisterDataSetObserver(dataObserver) }, ) } Loading Loading @@ -125,3 +148,49 @@ fun CastControllerDisconnectButton(contentManager: MediaRouteControllerContentMa Text(text = "Disconnect") } } private fun customizeView(listView: ListView) { val context = listView.context val entryBackgroundStart = context.getDrawable(SystemUiR.drawable.settingslib_entry_bg_off_start) val entryBackgroundEnd = context.getDrawable(SystemUiR.drawable.settingslib_entry_bg_off_end) val entryBackgroundMiddle = context.getDrawable(SystemUiR.drawable.settingslib_entry_bg_off_middle) // This code will run after the ListView has had a chance to complete its layout. listView.post { val visibleChildCount = listView.childCount val adapter = listView.adapter val totalItemCount = adapter?.count ?: 0 if (adapter == null || totalItemCount == 0) { return@post } for (i in 0 until visibleChildCount) { val child = listView.getChildAt(i) as LinearLayout val adapterPosition = listView.getPositionForView(child) if (adapterPosition != ListView.INVALID_POSITION) { val entry = child.getChildAt(0) as LinearLayout entry.background = when (adapterPosition) { 0 -> entryBackgroundStart totalItemCount - 1 -> entryBackgroundEnd else -> entryBackgroundMiddle } setPadding(context, child) } } } } private fun setPadding(context: Context, targetBackgroundView: LinearLayout) { val horizontalPadding = context.resources.getDimensionPixelSize(SystemUiR.dimen.tile_details_horizontal_padding) targetBackgroundView.setPadding( horizontalPadding, targetBackgroundView.paddingTop, horizontalPadding, targetBackgroundView.paddingBottom, ) }