Skip to content

Commit

Permalink
Ensure overlays visiblity correctness during permissions requests
Browse files Browse the repository at this point in the history
  • Loading branch information
Nain57 committed Nov 17, 2024
1 parent 36c116b commit 8164f9b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 8164f9b

Please sign in to comment.