diff --git a/feature/smart-config/src/main/java/com/buzbuz/smartautoclicker/feature/smart/config/ui/common/starters/RestartMediaProjectionActivity.kt b/feature/smart-config/src/main/java/com/buzbuz/smartautoclicker/feature/smart/config/ui/common/starters/RestartMediaProjectionActivity.kt index 82681575..68909fec 100644 --- a/feature/smart-config/src/main/java/com/buzbuz/smartautoclicker/feature/smart/config/ui/common/starters/RestartMediaProjectionActivity.kt +++ b/feature/smart-config/src/main/java/com/buzbuz/smartautoclicker/feature/smart/config/ui/common/starters/RestartMediaProjectionActivity.kt @@ -64,11 +64,12 @@ class RestartMediaProjectionActivity : AppCompatActivity() { registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result -> val data = result.data if (data == null || result.resultCode != RESULT_OK) { + Log.i(TAG, "Media projection permission rejected") finishActivity() return@registerForActivityResult } - Log.i(TAG, "Media projection us running, start scenario") + Log.i(TAG, "Media projection permission granted, restart recording") viewModel.restartScreenRecord(this, result.resultCode, data) finishActivity() @@ -82,13 +83,25 @@ class RestartMediaProjectionActivity : AppCompatActivity() { .setTitle(R.string.dialog_overlay_title_warning) .setMessage(R.string.message_error_media_projection_lost) .setPositiveButton(R.string.yes) { _, _ -> + dialog = null projectionActivityResult.showMediaProjectionWarning(this) { finishActivity() } } .setNegativeButton(R.string.no) { _, _ -> finishActivity() } - .create().also { it.showAsOverlay() } + .setOnDismissListener { + if (dialog != null) { + dialog = null + finishActivity() + } + } + .create().also { + it.setOnKeyListener { _, _ ,_ -> true } + it.showAsOverlay() + } private fun finishActivity() { dialog?.dismiss() + dialog = null + overlayManager.restoreVisibility() overlayManager.navigateUp(this) finish() diff --git a/feature/smart-config/src/main/java/com/buzbuz/smartautoclicker/feature/smart/config/ui/common/starters/StartersOverlays.kt b/feature/smart-config/src/main/java/com/buzbuz/smartautoclicker/feature/smart/config/ui/common/starters/StartersOverlays.kt index c3bf505e..bbac1182 100644 --- a/feature/smart-config/src/main/java/com/buzbuz/smartautoclicker/feature/smart/config/ui/common/starters/StartersOverlays.kt +++ b/feature/smart-config/src/main/java/com/buzbuz/smartautoclicker/feature/smart/config/ui/common/starters/StartersOverlays.kt @@ -33,7 +33,7 @@ internal fun newWebBrowserStarterOverlay(uri: Uri) = ActivityStarterOverlayMenu( ) internal fun newRestartMediaProjectionStarterOverlay(context: Context) = ActivityStarterOverlayMenu( - intent = RestartMediaProjectionActivity.getStartIntent(context) + intent = RestartMediaProjectionActivity.getStartIntent(context), ) internal fun newNotificationPermissionStarterOverlay(context: Context) = ActivityStarterOverlayMenu(