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 package com.android.permissioncontroller.incident.wear
18 
19 import androidx.lifecycle.MutableLiveData
20 import androidx.lifecycle.ViewModel
21 import androidx.lifecycle.ViewModelProvider
22 
23 class WearConfirmationActivityViewModel : ViewModel() {
24     /** A livedata which stores whether the incident/bug report dialog is visible. */
25     val showDialogLiveData = MutableLiveData<Boolean>()
26 
27     /** A livedata which stores to whether to show the screen for deny report */
28     val showDenyReportLiveData = MutableLiveData<Boolean>()
29 
30     /** A livedata which stores arguments for a confirmation section. */
31     var contentArgsLiveData = MutableLiveData<ContentArgs>()
32 
33     data class ContentArgs(
34         // stores the incident/bug report title
35         val title: String,
36         // stores the incident/bug report message body
37         val message: String,
38         // this is a button shows only in a denied incident/bug report dialog
39         val onDenyClick: () -> Unit,
40         val onOkClick: () -> Unit,
41         val onCancelClick: () -> Unit,
42     )
43 
44     init {
45         showDialogLiveData.value = false
46         showDenyReportLiveData.value = false
47         contentArgsLiveData.value = null
48     }
49 }
50 
51 /** Factory for a WearConfirmationActivityViewModel */
52 class WearConfirmationActivityViewModelFactory : ViewModelProvider.Factory {
createnull53     override fun <T : ViewModel> create(modelClass: Class<T>): T {
54         @Suppress("UNCHECKED_CAST") return WearConfirmationActivityViewModel() as T
55     }
56 }
57