1 /** 2 * Copyright (C) 2022 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.bluetooth; 18 19 import android.content.Context; 20 import android.view.View; 21 22 import com.android.internal.logging.UiEventLogger; 23 import com.android.systemui.animation.DialogLaunchAnimator; 24 import com.android.systemui.dagger.SysUISingleton; 25 import com.android.systemui.media.dialog.MediaOutputDialogFactory; 26 27 import javax.inject.Inject; 28 29 /** 30 * Controller to create BroadcastDialog objects. 31 */ 32 @SysUISingleton 33 public class BroadcastDialogController { 34 35 private Context mContext; 36 private UiEventLogger mUiEventLogger; 37 private DialogLaunchAnimator mDialogLaunchAnimator; 38 private MediaOutputDialogFactory mMediaOutputDialogFactory; 39 40 @Inject BroadcastDialogController(Context context, UiEventLogger uiEventLogger, DialogLaunchAnimator dialogLaunchAnimator, MediaOutputDialogFactory mediaOutputDialogFactory)41 public BroadcastDialogController(Context context, UiEventLogger uiEventLogger, 42 DialogLaunchAnimator dialogLaunchAnimator, 43 MediaOutputDialogFactory mediaOutputDialogFactory) { 44 mContext = context; 45 mUiEventLogger = uiEventLogger; 46 mDialogLaunchAnimator = dialogLaunchAnimator; 47 mMediaOutputDialogFactory = mediaOutputDialogFactory; 48 } 49 50 /** Creates a [BroadcastDialog] for the user to switch broadcast or change the output device 51 * 52 * @param currentBroadcastAppName Indicates the APP name currently broadcasting 53 * @param outputPkgName Indicates the output media package name to be switched 54 */ createBroadcastDialog(String currentBroadcastAppName, String outputPkgName, boolean aboveStatusBar, View view)55 public void createBroadcastDialog(String currentBroadcastAppName, String outputPkgName, 56 boolean aboveStatusBar, View view) { 57 BroadcastDialog broadcastDialog = new BroadcastDialog(mContext, mMediaOutputDialogFactory, 58 currentBroadcastAppName, outputPkgName, mUiEventLogger); 59 if (view != null) { 60 mDialogLaunchAnimator.showFromView(broadcastDialog, view); 61 } else { 62 broadcastDialog.show(); 63 } 64 } 65 } 66