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 package com.android.systemui.mediaprojection.devicepolicy 17 18 import android.app.AlertDialog 19 import android.content.Context 20 import android.content.DialogInterface.BUTTON_POSITIVE 21 import android.content.res.Resources 22 import com.android.systemui.dagger.qualifiers.Main 23 import com.android.systemui.res.R 24 import com.android.systemui.statusbar.phone.SystemUIDialog 25 import javax.inject.Inject 26 27 /** Dialog that shows that screen capture is disabled on this device. */ 28 class ScreenCaptureDisabledDialogDelegate 29 @Inject 30 constructor( 31 private val context: Context, 32 @Main private val resources: Resources, 33 ) { 34 35 fun createPlainDialog(): AlertDialog { 36 return AlertDialog.Builder(context, R.style.Theme_SystemUI_Dialog).create().also { 37 initDialog(it) 38 } 39 } 40 41 fun createSysUIDialog(): AlertDialog { 42 return SystemUIDialog(context).also { initDialog(it) } 43 } 44 45 private fun initDialog(dialog: AlertDialog) { 46 dialog.setTitle( 47 resources.getString(R.string.screen_capturing_disabled_by_policy_dialog_title) 48 ) 49 dialog.setMessage( 50 resources.getString(R.string.screen_capturing_disabled_by_policy_dialog_description) 51 ) 52 dialog.setIcon(R.drawable.ic_cast) 53 dialog.setButton(BUTTON_POSITIVE, resources.getString(android.R.string.ok)) { _, _ -> 54 dialog.cancel() 55 } 56 } 57 } 58