Loading packages/SystemUI/res/layout/volume_dialog.xml +1 −1 Original line number Diff line number Diff line Loading @@ -16,7 +16,7 @@ <androidx.constraintlayout.motion.widget.MotionLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:androidprv="http://schemas.android.com/apk/prv/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/volume_dialog_root" android:id="@+id/volume_dialog" android:layout_width="match_parent" android:layout_height="match_parent" android:alpha="0" Loading packages/SystemUI/res/layout/volume_ringer_button.xml +9 −16 Original line number Diff line number Diff line Loading @@ -13,20 +13,13 @@ ~ See the License for the specific language governing permissions and ~ limitations under the License. --> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" <ImageButton xmlns:android="http://schemas.android.com/apk/res/android" xmlns:androidprv="http://schemas.android.com/apk/prv/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" > <ImageButton android:id="@+id/volume_drawer_button" android:layout_width="match_parent" android:layout_height="match_parent" android:padding="@dimen/volume_dialog_ringer_drawer_button_icon_radius" android:background="@drawable/volume_ringer_item_bg" android:contentDescription="@string/volume_ringer_mode" android:gravity="center" android:tint="@androidprv:color/materialColorOnSurface" android:padding="@dimen/volume_dialog_ringer_drawer_button_icon_radius" android:src="@drawable/volume_ringer_item_bg" android:background="@drawable/volume_ringer_item_bg"/> </FrameLayout> android:tint="@androidprv:color/materialColorOnSurface" /> packages/SystemUI/src/com/android/systemui/volume/dialog/VolumeDialog.kt +1 −1 Original line number Diff line number Diff line Loading @@ -68,7 +68,7 @@ constructor( override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.volume_dialog) requireViewById<View>(R.id.volume_dialog_root).repeatWhenAttached { requireViewById<View>(R.id.volume_dialog).repeatWhenAttached { coroutineScopeTraced("[Volume]dialog") { val component = componentFactory.create(this) with(component.volumeDialogViewBinder()) { bind(this@VolumeDialog) } Loading packages/SystemUI/src/com/android/systemui/volume/dialog/domain/interactor/VolumeDialogVisibilityInteractor.kt +15 −4 Original line number Diff line number Diff line Loading @@ -17,7 +17,9 @@ package com.android.systemui.volume.dialog.domain.interactor import android.annotation.SuppressLint import android.provider.Settings import com.android.systemui.plugins.VolumeDialogController import com.android.systemui.shared.settings.data.repository.SecureSettingsRepository import com.android.systemui.volume.Events import com.android.systemui.volume.dialog.dagger.scope.VolumeDialogPlugin import com.android.systemui.volume.dialog.dagger.scope.VolumeDialogPluginScope Loading @@ -28,8 +30,9 @@ import com.android.systemui.volume.dialog.shared.model.VolumeDialogVisibilityMod import com.android.systemui.volume.dialog.shared.model.VolumeDialogVisibilityModel.Visible import com.android.systemui.volume.dialog.utils.VolumeTracer import javax.inject.Inject import kotlin.time.Duration import kotlin.time.Duration.Companion.milliseconds import kotlin.time.Duration.Companion.seconds import kotlin.time.DurationUnit import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.delay import kotlinx.coroutines.flow.Flow Loading @@ -43,8 +46,6 @@ import kotlinx.coroutines.flow.merge import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.flow.stateIn private val MAX_DIALOG_SHOW_TIME: Duration = 3.seconds /** * Handles Volume Dialog visibility state. It might change from several sources: * - [com.android.systemui.plugins.VolumeDialogController] requests visibility change; Loading @@ -60,8 +61,11 @@ constructor( private val tracer: VolumeTracer, private val repository: VolumeDialogVisibilityRepository, private val controller: VolumeDialogController, private val secureSettingsRepository: SecureSettingsRepository, ) { private val defaultTimeout = 3.seconds @SuppressLint("SharedFlowCreation") private val mutableDismissDialogEvents = MutableSharedFlow<Unit>(extraBufferCapacity = 1) val dialogVisibility: Flow<VolumeDialogVisibilityModel> = Loading @@ -73,7 +77,14 @@ constructor( init { merge( mutableDismissDialogEvents.mapLatest { delay(MAX_DIALOG_SHOW_TIME) delay( secureSettingsRepository .getInt( Settings.Secure.VOLUME_DIALOG_DISMISS_TIMEOUT, defaultTimeout.toInt(DurationUnit.MILLISECONDS), ) .milliseconds ) VolumeDialogEventModel.DismissRequested(Events.DISMISS_REASON_TIMEOUT) }, callbacksInteractor.event, Loading packages/SystemUI/src/com/android/systemui/volume/dialog/ringer/ui/binder/VolumeDialogRingerViewBinder.kt +26 −30 Original line number Diff line number Diff line Loading @@ -246,16 +246,12 @@ constructor( uiModel.drawerState.currentMode != uiModel.drawerState.previousMode ) { val count = uiModel.availableButtons.size val selectedButton = getChildAt(count - uiModel.currentButtonIndex) .requireViewById<ImageButton>(R.id.volume_drawer_button) val selectedButton = getChildAt(count - uiModel.currentButtonIndex) as ImageButton val previousIndex = uiModel.availableButtons.indexOfFirst { it.ringerMode == uiModel.drawerState.previousMode } val unselectedButton = getChildAt(count - previousIndex) .requireViewById<ImageButton>(R.id.volume_drawer_button) val unselectedButton = getChildAt(count - previousIndex) as ImageButton // We only need to execute on roundness animation end and volume dialog background // progress update once because these changes should be applied once on volume dialog // background and ringer drawer views. Loading Loading @@ -306,7 +302,7 @@ constructor( ) { val count = uiModel.availableButtons.size uiModel.availableButtons.fastForEachIndexed { index, ringerButton -> val view = getChildAt(count - index) val view = getChildAt(count - index) as ImageButton val isOpen = uiModel.drawerState is RingerDrawerState.Open if (index == uiModel.currentButtonIndex) { view.bindDrawerButton( Loading @@ -323,15 +319,16 @@ constructor( onAnimationEnd?.run() } private fun View.bindDrawerButton( private fun ImageButton.bindDrawerButton( buttonViewModel: RingerButtonViewModel, viewModel: VolumeDialogRingerDrawerViewModel, isOpen: Boolean, isSelected: Boolean = false, isAnimated: Boolean = false, ) { // id = buttonViewModel.viewId setSelected(isSelected) val ringerContentDesc = context.getString(buttonViewModel.contentDescriptionResId) with(requireViewById<ImageButton>(R.id.volume_drawer_button)) { setImageResource(buttonViewModel.imageResId) contentDescription = if (isSelected && !isOpen) { Loading @@ -355,7 +352,6 @@ constructor( viewModel.onRingerButtonClicked(buttonViewModel.ringerMode, isSelected) } } } private fun MotionLayout.ensureChildCount(@LayoutRes viewLayoutId: Int, count: Int) { val childCountDelta = childCount - count - 1 Loading Loading
packages/SystemUI/res/layout/volume_dialog.xml +1 −1 Original line number Diff line number Diff line Loading @@ -16,7 +16,7 @@ <androidx.constraintlayout.motion.widget.MotionLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:androidprv="http://schemas.android.com/apk/prv/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/volume_dialog_root" android:id="@+id/volume_dialog" android:layout_width="match_parent" android:layout_height="match_parent" android:alpha="0" Loading
packages/SystemUI/res/layout/volume_ringer_button.xml +9 −16 Original line number Diff line number Diff line Loading @@ -13,20 +13,13 @@ ~ See the License for the specific language governing permissions and ~ limitations under the License. --> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" <ImageButton xmlns:android="http://schemas.android.com/apk/res/android" xmlns:androidprv="http://schemas.android.com/apk/prv/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" > <ImageButton android:id="@+id/volume_drawer_button" android:layout_width="match_parent" android:layout_height="match_parent" android:padding="@dimen/volume_dialog_ringer_drawer_button_icon_radius" android:background="@drawable/volume_ringer_item_bg" android:contentDescription="@string/volume_ringer_mode" android:gravity="center" android:tint="@androidprv:color/materialColorOnSurface" android:padding="@dimen/volume_dialog_ringer_drawer_button_icon_radius" android:src="@drawable/volume_ringer_item_bg" android:background="@drawable/volume_ringer_item_bg"/> </FrameLayout> android:tint="@androidprv:color/materialColorOnSurface" />
packages/SystemUI/src/com/android/systemui/volume/dialog/VolumeDialog.kt +1 −1 Original line number Diff line number Diff line Loading @@ -68,7 +68,7 @@ constructor( override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.volume_dialog) requireViewById<View>(R.id.volume_dialog_root).repeatWhenAttached { requireViewById<View>(R.id.volume_dialog).repeatWhenAttached { coroutineScopeTraced("[Volume]dialog") { val component = componentFactory.create(this) with(component.volumeDialogViewBinder()) { bind(this@VolumeDialog) } Loading
packages/SystemUI/src/com/android/systemui/volume/dialog/domain/interactor/VolumeDialogVisibilityInteractor.kt +15 −4 Original line number Diff line number Diff line Loading @@ -17,7 +17,9 @@ package com.android.systemui.volume.dialog.domain.interactor import android.annotation.SuppressLint import android.provider.Settings import com.android.systemui.plugins.VolumeDialogController import com.android.systemui.shared.settings.data.repository.SecureSettingsRepository import com.android.systemui.volume.Events import com.android.systemui.volume.dialog.dagger.scope.VolumeDialogPlugin import com.android.systemui.volume.dialog.dagger.scope.VolumeDialogPluginScope Loading @@ -28,8 +30,9 @@ import com.android.systemui.volume.dialog.shared.model.VolumeDialogVisibilityMod import com.android.systemui.volume.dialog.shared.model.VolumeDialogVisibilityModel.Visible import com.android.systemui.volume.dialog.utils.VolumeTracer import javax.inject.Inject import kotlin.time.Duration import kotlin.time.Duration.Companion.milliseconds import kotlin.time.Duration.Companion.seconds import kotlin.time.DurationUnit import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.delay import kotlinx.coroutines.flow.Flow Loading @@ -43,8 +46,6 @@ import kotlinx.coroutines.flow.merge import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.flow.stateIn private val MAX_DIALOG_SHOW_TIME: Duration = 3.seconds /** * Handles Volume Dialog visibility state. It might change from several sources: * - [com.android.systemui.plugins.VolumeDialogController] requests visibility change; Loading @@ -60,8 +61,11 @@ constructor( private val tracer: VolumeTracer, private val repository: VolumeDialogVisibilityRepository, private val controller: VolumeDialogController, private val secureSettingsRepository: SecureSettingsRepository, ) { private val defaultTimeout = 3.seconds @SuppressLint("SharedFlowCreation") private val mutableDismissDialogEvents = MutableSharedFlow<Unit>(extraBufferCapacity = 1) val dialogVisibility: Flow<VolumeDialogVisibilityModel> = Loading @@ -73,7 +77,14 @@ constructor( init { merge( mutableDismissDialogEvents.mapLatest { delay(MAX_DIALOG_SHOW_TIME) delay( secureSettingsRepository .getInt( Settings.Secure.VOLUME_DIALOG_DISMISS_TIMEOUT, defaultTimeout.toInt(DurationUnit.MILLISECONDS), ) .milliseconds ) VolumeDialogEventModel.DismissRequested(Events.DISMISS_REASON_TIMEOUT) }, callbacksInteractor.event, Loading
packages/SystemUI/src/com/android/systemui/volume/dialog/ringer/ui/binder/VolumeDialogRingerViewBinder.kt +26 −30 Original line number Diff line number Diff line Loading @@ -246,16 +246,12 @@ constructor( uiModel.drawerState.currentMode != uiModel.drawerState.previousMode ) { val count = uiModel.availableButtons.size val selectedButton = getChildAt(count - uiModel.currentButtonIndex) .requireViewById<ImageButton>(R.id.volume_drawer_button) val selectedButton = getChildAt(count - uiModel.currentButtonIndex) as ImageButton val previousIndex = uiModel.availableButtons.indexOfFirst { it.ringerMode == uiModel.drawerState.previousMode } val unselectedButton = getChildAt(count - previousIndex) .requireViewById<ImageButton>(R.id.volume_drawer_button) val unselectedButton = getChildAt(count - previousIndex) as ImageButton // We only need to execute on roundness animation end and volume dialog background // progress update once because these changes should be applied once on volume dialog // background and ringer drawer views. Loading Loading @@ -306,7 +302,7 @@ constructor( ) { val count = uiModel.availableButtons.size uiModel.availableButtons.fastForEachIndexed { index, ringerButton -> val view = getChildAt(count - index) val view = getChildAt(count - index) as ImageButton val isOpen = uiModel.drawerState is RingerDrawerState.Open if (index == uiModel.currentButtonIndex) { view.bindDrawerButton( Loading @@ -323,15 +319,16 @@ constructor( onAnimationEnd?.run() } private fun View.bindDrawerButton( private fun ImageButton.bindDrawerButton( buttonViewModel: RingerButtonViewModel, viewModel: VolumeDialogRingerDrawerViewModel, isOpen: Boolean, isSelected: Boolean = false, isAnimated: Boolean = false, ) { // id = buttonViewModel.viewId setSelected(isSelected) val ringerContentDesc = context.getString(buttonViewModel.contentDescriptionResId) with(requireViewById<ImageButton>(R.id.volume_drawer_button)) { setImageResource(buttonViewModel.imageResId) contentDescription = if (isSelected && !isOpen) { Loading @@ -355,7 +352,6 @@ constructor( viewModel.onRingerButtonClicked(buttonViewModel.ringerMode, isSelected) } } } private fun MotionLayout.ensureChildCount(@LayoutRes viewLayoutId: Int, count: Int) { val childCountDelta = childCount - count - 1 Loading