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

Reversed the previous changes. To fix the crash, verified whether the fragment is added to the activity in pipModeChanged function. Fullscreen media clean up is done in onstop() method of BaseBrowserFragment

Co-Authored-By: Mugurell <[email protected]>
  • Loading branch information
indurs and Mugurell committed May 8, 2022
1 parent 7a3af99 commit 74a20a8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .experimenter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ messaging:
type: string
description: What should be displayed when a control message is selected.
enum:
- show-none
- show-next-message
- show-none
styles:
type: json
description: "A map of styles to configure message appearance.\n"
Expand Down
4 changes: 1 addition & 3 deletions app/src/main/java/org/mozilla/fenix/HomeActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,7 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity {
listOf(
HomeDeepLinkIntentProcessor(this),
SpeechProcessingIntentProcessor(this, components.core.store),
StartSearchIntentProcessor(
unlockOrientationIfInPiPMode = { unlockOrientationIfInPiPMode() },
components.core.store),
StartSearchIntentProcessor(),
OpenBrowserIntentProcessor(this, ::getIntentSessionId),
OpenSpecificTabIntentProcessor(this),
DefaultBrowserIntentProcessor(this)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ package org.mozilla.fenix.home.intent
import android.content.Intent
import androidx.navigation.NavController
import androidx.navigation.navOptions
import mozilla.components.browser.state.store.BrowserStore
import mozilla.components.feature.media.ext.findActiveMediaTab
import mozilla.components.service.glean.private.NoExtras
import org.mozilla.fenix.GleanMetrics.SearchWidget
import org.mozilla.fenix.HomeActivity
Expand All @@ -22,27 +20,19 @@ import org.mozilla.fenix.ext.nav
* Tapping the private browsing mode launcher icon should also open to the search fragment.
*/

class StartSearchIntentProcessor(
val unlockOrientationIfInPiPMode: ()->Unit,
val store: BrowserStore,

) : HomeIntentProcessor {
class StartSearchIntentProcessor() : HomeIntentProcessor {

override fun process(intent: Intent, navController: NavController, out: Intent): Boolean {
val event = intent.extras?.getString(HomeActivity.OPEN_TO_SEARCH)

return if (event != null) {
openSearch(event,navController,out)
if(store.state.findActiveMediaTab()?.id !=null){
unlockOrientationIfInPiPMode()
}
return true
return openSearch(event,navController,out)
} else {
false
}
}

private fun openSearch(event: String,navController: NavController,out: Intent){
private fun openSearch(event: String,navController: NavController,out: Intent):Boolean{
val source = when (event) {
SEARCH_WIDGET -> {
SearchWidget.newTabButton.record(NoExtras())
Expand Down Expand Up @@ -70,6 +60,7 @@ class StartSearchIntentProcessor(
}
navController.nav(null, it, options)
}
return true
}

companion object {
Expand Down

0 comments on commit 74a20a8

Please sign in to comment.