1 /*
<lambda>null2  * 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.controls.ui
19 
20 import android.app.Dialog
21 import android.content.Context
22 import android.content.DialogInterface
23 import com.android.systemui.res.R
24 import com.android.systemui.statusbar.phone.SystemUIDialog
25 import java.util.function.Consumer
26 import javax.inject.Inject
27 
28 class ControlsDialogsFactory @Inject constructor(
29         private val dialogFactory: SystemUIDialog.Factory
30 ) {
31 
32 
33     fun createRemoveAppDialog(
34             context: Context,
35             appName: CharSequence,
36             response: Consumer<Boolean>
37     ): Dialog {
38         val listener =
39             DialogInterface.OnClickListener { _, which ->
40                 response.accept(which == DialogInterface.BUTTON_POSITIVE)
41             }
42         return dialogFactory.create(context).apply {
43             setTitle(context.getString(R.string.controls_panel_remove_app_authorization, appName))
44             setCanceledOnTouchOutside(true)
45             setOnCancelListener { response.accept(false) }
46             setPositiveButton(R.string.controls_dialog_remove, listener)
47             setNeutralButton(R.string.cancel, listener)
48         }
49     }
50 }
51