1 /* 2 * Copyright (C) 2024 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.systemui.volume.panel.component.mediaoutput.domain.interactor 18 19 import com.android.internal.jank.InteractionJankMonitor 20 import com.android.systemui.animation.DialogCuj 21 import com.android.systemui.animation.DialogTransitionAnimator 22 import com.android.systemui.animation.Expandable 23 import com.android.systemui.media.dialog.MediaOutputDialogManager 24 import com.android.systemui.volume.panel.component.mediaoutput.domain.model.MediaOutputComponentModel 25 import com.android.systemui.volume.panel.dagger.scope.VolumePanelScope 26 import javax.inject.Inject 27 28 /** User actions interactor for Media Output Volume Panel component. */ 29 @VolumePanelScope 30 class MediaOutputActionsInteractor 31 @Inject 32 constructor(private val mediaOutputDialogManager: MediaOutputDialogManager) { 33 onBarClicknull34 fun onBarClick(model: MediaOutputComponentModel?, expandable: Expandable?) { 35 if (model is MediaOutputComponentModel.MediaSession) { 36 mediaOutputDialogManager.createAndShowWithController( 37 model.session.packageName, 38 false, 39 expandable?.dialogController() 40 ) 41 } else { 42 mediaOutputDialogManager.createAndShowForSystemRouting(expandable?.dialogController()) 43 } 44 } 45 dialogControllernull46 private fun Expandable.dialogController(): DialogTransitionAnimator.Controller? { 47 return dialogTransitionController( 48 cuj = 49 DialogCuj( 50 InteractionJankMonitor.CUJ_SHADE_DIALOG_OPEN, 51 MediaOutputDialogManager.INTERACTION_JANK_TAG 52 ) 53 ) 54 } 55 } 56