2
0
mirror of https://github.com/fork-maintainers/iceraven-browser synced 2024-11-15 18:12:54 +00:00

[fenix] For https://github.com/mozilla-mobile/fenix/issues/4804: Resolves issue with crash reporter stack

This commit is contained in:
Sawyer Blatz 2019-08-19 12:53:24 -07:00 committed by Emily Kager
parent aa9bf1aa6e
commit ea193a5472
3 changed files with 16 additions and 17 deletions

View File

@ -122,8 +122,14 @@ open class HomeActivity : AppCompatActivity(), ShareFragment.TabsSharedCallback
override fun onNewIntent(intent: Intent?) {
super.onNewIntent(intent)
handleCrashIfNecessary(intent)
handleOpenedFromExternalSourceIfNecessary(intent)
intent?.let {
if (Crash.isCrashIntent(it)) {
openToCrashReporter(it)
} else {
handleOpenedFromExternalSourceIfNecessary(it)
}
}
}
override fun onResume() {
@ -164,17 +170,6 @@ open class HomeActivity : AppCompatActivity(), ShareFragment.TabsSharedCallback
super.onBackPressed()
}
private fun handleCrashIfNecessary(intent: Intent?) {
if (intent == null) {
return
}
if (!Crash.isCrashIntent(intent)) {
return
}
openToCrashReporter(intent)
}
private fun openToCrashReporter(intent: Intent) {
val directions = NavGraphDirections.actionGlobalCrashReporter(intent)
navHost.navController.navigate(directions)

View File

@ -11,12 +11,14 @@ import android.view.ViewGroup
import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.Fragment
import androidx.navigation.Navigation
import androidx.navigation.fragment.findNavController
import kotlinx.android.synthetic.main.fragment_crash_reporter.*
import mozilla.components.browser.session.Session
import mozilla.components.lib.crash.Crash
import org.mozilla.fenix.R
import org.mozilla.fenix.components.metrics.Event
import org.mozilla.fenix.ext.components
import org.mozilla.fenix.ext.nav
import org.mozilla.fenix.ext.requireComponents
import org.mozilla.fenix.utils.Settings
@ -61,7 +63,7 @@ class CrashReporterFragment : Fragment() {
} else {
requireComponents.useCases.tabsUseCases.removeTab.invoke(session)
requireComponents.useCases.sessionUseCases.crashRecovery.invoke()
navigateHome(view!!)
navigateHome()
}
}
@ -74,7 +76,8 @@ class CrashReporterFragment : Fragment() {
requireContext().components.analytics.metrics.track(Event.CrashReporterClosed(didSubmitCrashReport))
}
private fun navigateHome(fromView: View) {
Navigation.findNavController(fromView).popBackStack(R.id.browserFragment, true)
private fun navigateHome() {
val directions = CrashReporterFragmentDirections.actionCrashReporterFragmentToHomeFragment()
findNavController().nav(R.id.crashReporterFragment, directions)
}
}

View File

@ -369,7 +369,8 @@
android:label="CrashReporterFragment">
<action
android:id="@+id/action_crashReporterFragment_to_homeFragment"
app:destination="@id/homeFragment" />
app:destination="@id/homeFragment"
app:popUpTo="@id/nav_graph"/>
<argument
android:name="crashIntent"
app:argType="android.content.Intent" />