From 830db16173e31977e0f3049c83e98e6f752e812f Mon Sep 17 00:00:00 2001 From: indu Date: Fri, 27 May 2022 11:55:30 +0530 Subject: [PATCH] For #24040: App should not crash when the search widget is clicked while PIP mode is active When the search event is from the search widget while PIP is active, the search fragment opens after the screen is unlocked. This avoids the issue of the search page opening in landscape mode and also the app doesn't crash. Co-Authored-By: Mugurell --- app/src/main/java/org/mozilla/fenix/HomeActivity.kt | 6 ++++++ .../java/org/mozilla/fenix/browser/BaseBrowserFragment.kt | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/mozilla/fenix/HomeActivity.kt b/app/src/main/java/org/mozilla/fenix/HomeActivity.kt index 4dee68475d3c..2f20bd9d35ae 100644 --- a/app/src/main/java/org/mozilla/fenix/HomeActivity.kt +++ b/app/src/main/java/org/mozilla/fenix/HomeActivity.kt @@ -52,6 +52,7 @@ import mozilla.components.concept.storage.BookmarkNode import mozilla.components.concept.storage.BookmarkNodeType import mozilla.components.concept.storage.HistoryMetadataKey import mozilla.components.feature.contextmenu.DefaultSelectionActionDelegate +import mozilla.components.feature.media.ext.findActiveMediaTab import mozilla.components.feature.privatemode.notification.PrivateNotificationFeature import mozilla.components.feature.search.BrowserStoreSearchAdapter import mozilla.components.service.fxa.sync.SyncReason @@ -511,6 +512,11 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity { ) ) + val tab = components.core.store.state.findActiveMediaTab() + if (tab != null) { + components.useCases.sessionUseCases.exitFullscreen(tab.id) + } + val intentProcessors = listOf( CrashReporterIntentProcessor(components.appStore) diff --git a/app/src/main/java/org/mozilla/fenix/browser/BaseBrowserFragment.kt b/app/src/main/java/org/mozilla/fenix/browser/BaseBrowserFragment.kt index 9b84ad11e587..9f037fa23414 100644 --- a/app/src/main/java/org/mozilla/fenix/browser/BaseBrowserFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/browser/BaseBrowserFragment.kt @@ -1321,7 +1321,7 @@ abstract class BaseBrowserFragment : * Exit fullscreen mode when exiting PIP mode */ private fun pipModeChanged(session: SessionState) { - if (!session.content.pictureInPictureEnabled && session.content.fullScreen) { + if (!session.content.pictureInPictureEnabled && session.content.fullScreen && isAdded) { onBackPressed() fullScreenChanged(false) }