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.permission.ui.wear.model 18 19 import android.graphics.drawable.Drawable 20 import androidx.lifecycle.MutableLiveData 21 import androidx.lifecycle.ViewModel 22 import androidx.lifecycle.ViewModelProvider 23 import com.android.permissioncontroller.permission.ui.model.UnusedAppsViewModel.UnusedPeriod 24 25 class WearUnusedAppsViewModel : ViewModel() { 26 /** A livedata which indicates if the loading animation should be showed. */ 27 val loadingLiveData = MutableLiveData<Boolean>() 28 29 /** A livedata which stores unused period category visibilities. */ 30 val unusedPeriodCategoryVisibilitiesLiveData = MutableLiveData<List<Boolean>>() 31 32 /** A livedata which indicates if the info massage category is visible or not. */ 33 val infoMsgCategoryVisibilityLiveData = MutableLiveData<Boolean>() 34 35 /** A livedata which stores a map of unused apps group by UnusedPeriod. */ 36 val unusedAppChipsLiveData = 37 MutableLiveData<Map<UnusedPeriod, Map<String, UnusedAppChip>>>() 38 39 data class UnusedAppChip( 40 val label: String, 41 val summary: String?, 42 val icon: Drawable?, 43 val contentDescription: String?, 44 val onClick: () -> Unit, 45 ) 46 47 init { 48 loadingLiveData.value = true 49 unusedPeriodCategoryVisibilitiesLiveData.value = emptyList() 50 infoMsgCategoryVisibilityLiveData.value = false 51 unusedAppChipsLiveData.value = mutableMapOf() 52 } 53 } 54 55 /** Factory for a WearUnusedAppsViewModel */ 56 class WearUnusedAppsViewModelFactory : ViewModelProvider.Factory { createnull57 override fun <T : ViewModel> create(modelClass: Class<T>): T { 58 @Suppress("UNCHECKED_CAST") return WearUnusedAppsViewModel() as T 59 } 60 } 61