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.bottombar.ui.viewmodel
18 
19 import android.content.Intent
20 import android.provider.Settings
21 import com.android.internal.logging.UiEventLogger
22 import com.android.systemui.plugins.ActivityStarter
23 import com.android.systemui.volume.panel.dagger.scope.VolumePanelScope
24 import com.android.systemui.volume.panel.ui.VolumePanelUiEvent
25 import com.android.systemui.volume.panel.ui.viewmodel.VolumePanelViewModel
26 import javax.inject.Inject
27 
28 @VolumePanelScope
29 class BottomBarViewModel
30 @Inject
31 constructor(
32     private val activityStarter: ActivityStarter,
33     private val volumePanelViewModel: VolumePanelViewModel,
34     private val uiEventLogger: UiEventLogger,
35 ) {
36 
onDoneClickednull37     fun onDoneClicked() {
38         volumePanelViewModel.dismissPanel()
39     }
40 
onSettingsClickednull41     fun onSettingsClicked() {
42         uiEventLogger.log(VolumePanelUiEvent.VOLUME_PANEL_SOUND_SETTINGS_CLICKED)
43         activityStarter.startActivityDismissingKeyguard(
44             /* intent = */ Intent(Settings.ACTION_SOUND_SETTINGS),
45             /* onlyProvisioned = */ false,
46             /* dismissShade = */ true,
47             /* disallowEnterPictureInPictureWhileLaunching = */ false,
48             /* callback = */ { volumePanelViewModel.dismissPanel() },
49             /* flags = */ Intent.FLAG_ACTIVITY_REORDER_TO_FRONT,
50             /* animationController = */ null,
51             /* userHandle = */ null,
52         )
53     }
54 }
55