• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2023 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 
18 package com.android.systemui.keyguard.ui.viewmodel
19 
20 import com.android.systemui.common.shared.model.Icon
21 import com.android.systemui.common.shared.model.Text
22 import com.android.systemui.common.ui.domain.interactor.ConfigurationInteractor
23 import com.android.systemui.keyguard.domain.interactor.KeyguardTouchHandlingInteractor
24 import com.android.systemui.res.R
25 import javax.inject.Inject
26 import kotlinx.coroutines.flow.Flow
27 
28 /** Models the UI state of a keyguard settings popup menu. */
29 class KeyguardSettingsMenuViewModel
30 @Inject
31 constructor(
32     private val interactor: KeyguardTouchHandlingInteractor,
33     configurationInteractor: ConfigurationInteractor,
34 ) {
35     val isVisible: Flow<Boolean> = interactor.isMenuVisible
36     val shouldOpenSettings: Flow<Boolean> = interactor.shouldOpenSettings
37 
38     val icon: Icon = Icon.Resource(res = R.drawable.ic_palette, contentDescription = null)
39 
40     val text: Text = Text.Resource(res = R.string.lock_screen_settings)
41 
42     val textSize =
43         configurationInteractor.dimensionPixelSize(
44             com.android.internal.R.dimen.text_size_small_material
45         )
46 
onTouchGestureStartednull47     fun onTouchGestureStarted() {
48         interactor.onMenuTouchGestureStarted()
49     }
50 
onTouchGestureEndednull51     fun onTouchGestureEnded(isClick: Boolean) {
52         interactor.onMenuTouchGestureEnded(isClick = isClick)
53     }
54 
onSettingsShownnull55     fun onSettingsShown() {
56         interactor.onSettingsShown()
57     }
58 }
59