Skip to content

Commit

Permalink
For mozilla-mobile#24040: App should not crash when the search widget…
Browse files Browse the repository at this point in the history
… 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 <[email protected]>
  • Loading branch information
indurs and Mugurell committed May 27, 2022
1 parent ab36146 commit 830db16
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions app/src/main/java/org/mozilla/fenix/HomeActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit 830db16

Please sign in to comment.