1 /* 2 * Copyright (C) 2022 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.screenrecord 17 18 import android.content.Context 19 import android.os.Bundle 20 import com.android.systemui.R 21 22 /** Dialog to select screen recording options */ 23 class MediaProjectionPermissionDialog( 24 context: Context?, 25 private val onStartRecordingClicked: Runnable, 26 private val appName: String? 27 ) : BaseScreenSharePermissionDialog(context, createOptionList(appName), appName) { onCreatenull28 override fun onCreate(savedInstanceState: Bundle?) { 29 super.onCreate(savedInstanceState) 30 if (appName == null) { 31 setDialogTitle(R.string.media_projection_permission_dialog_system_service_title) 32 } else { 33 setDialogTitle(R.string.media_projection_permission_dialog_title) 34 } 35 setStartButtonText(R.string.media_projection_permission_dialog_continue) 36 setStartButtonOnClickListener { 37 // Note that it is important to run this callback before dismissing, so that the 38 // callback can disable the dialog exit animation if it wants to. 39 onStartRecordingClicked.run() 40 dismiss() 41 } 42 } 43 44 companion object { createOptionListnull45 private fun createOptionList(appName: String?): List<ScreenShareOption> { 46 val singleAppWarningText = 47 if (appName == null) { 48 R.string.media_projection_permission_dialog_system_service_warning_single_app 49 } else { 50 R.string.media_projection_permission_dialog_warning_single_app 51 } 52 val entireScreenWarningText = 53 if (appName == null) { 54 R.string.media_projection_permission_dialog_system_service_warning_entire_screen 55 } else { 56 R.string.media_projection_permission_dialog_warning_entire_screen 57 } 58 59 return listOf( 60 ScreenShareOption( 61 mode = ENTIRE_SCREEN, 62 spinnerText = R.string.media_projection_permission_dialog_option_entire_screen, 63 warningText = entireScreenWarningText 64 ), 65 ScreenShareOption( 66 mode = SINGLE_APP, 67 spinnerText = R.string.media_projection_permission_dialog_option_single_app, 68 warningText = singleAppWarningText 69 ) 70 ) 71 } 72 } 73 } 74