• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.multiuser.widget.domain
18 
19 import android.content.Intent
20 import android.content.res.Resources
21 
22 import androidx.compose.ui.res.stringResource
23 
24 import kotlinx.coroutines.CoroutineDispatcher
25 import kotlinx.coroutines.Dispatchers
26 import kotlinx.coroutines.withContext
27 
28 import com.android.multiuser.widget.R
29 import com.android.multiuser.widget.data.getActionIntent
30 import com.android.multiuser.widget.viewmodel.DialogViewModel
31 
32 /**
33  * Load DialogViewModel from intent and resources.
34  */
35 class DialogUseCase(private val intent:Intent,
36                         private val resources: Resources) {
invokenull37     operator fun invoke() : DialogViewModel {
38         return DialogViewModel(
39             title = intent.getStringExtra("title")
40                 ?: resources.getString(R.string.widget_switch_not_allowed_dialog_message),
41             message = intent.getStringExtra("message")
42                 ?: resources.getString(R.string.widget_switch_not_allowed_dialog_message),
43             positiveButtonText =
44                 intent.getStringExtra("action_text"),
45             actionIntent = intent.getActionIntent()
46         )
47     }
48 }
49