Skip to content
This repository has been archived by the owner on Jan 12, 2023. It is now read-only.

Commit

Permalink
For #6755 - Exit PiP when launched externally with Intents
Browse files Browse the repository at this point in the history
  • Loading branch information
Ionut Cristian Bedregeanu authored and mergify[bot] committed Apr 20, 2022
1 parent e8c576d commit a2824df
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions app/src/main/java/org/mozilla/focus/activity/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ open class MainActivity : LocaleAwareAppCompatActivity() {
updateSecureWindowFlags()
super.onCreate(savedInstanceState)

// Checks if Activity is currently in PiP mode if launched from external intents, then exits it
checkAndExitPiP()

if (!isTaskRoot) {
if (intent.hasCategory(Intent.CATEGORY_LAUNCHER) && Intent.ACTION_MAIN == intent.action) {
finish()
Expand Down Expand Up @@ -112,6 +115,14 @@ open class MainActivity : LocaleAwareAppCompatActivity() {
AppReviewUtils.showAppReview(this)
}

private fun checkAndExitPiP() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && isInPictureInPictureMode && intent != null) {
// Exit PiP mode
moveTaskToBack(false)
startActivity(Intent(this, this::class.java).setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT))
}
}

final override fun onUserLeaveHint() {
val browserFragment =
supportFragmentManager.findFragmentByTag(BrowserFragment.FRAGMENT_TAG) as BrowserFragment?
Expand Down

0 comments on commit a2824df

Please sign in to comment.