2
0
mirror of https://github.com/fork-maintainers/iceraven-browser synced 2024-11-02 03:40:16 +00:00

For #1002 and #1222: Adds ability to restore crashed tabs (#1433)

This commit is contained in:
Sawyer Blatz 2019-04-08 08:04:22 -07:00 committed by GitHub
parent 9f1ec5e2b0
commit 2f3d38b51f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 35 additions and 21 deletions

View File

@ -7,12 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Added
- #916 - Added the ability to save and delete bookmarks
- #356 - Adds the ability to delete history
- #356 - Added the ability to delete history
- #208 - Added normal browsing dark mode (advised to use attrs from now on for most referenced colors)
- #957 - Adds telemetry for the context menu
- #1036 - Adds telemetry for Find in Page
- #1049 - Add style for progress bar with gradient drawable
- #957 - Added telemetry for the context menu
- #1036 - Added telemetry for Find in Page
- #1049 - Added style for progress bar with gradient drawable
- #1165 - Added doorhanger to the toolbar
- #1002 - Added ability to restore tab after crash
- #1195 - Adds telemetry for quick action sheet
- #627 - Sets engine preferred color scheme based on light/dark theme
- #904 - Added tab counter in browser toolbar

View File

@ -13,6 +13,7 @@ import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.Fragment
import androidx.navigation.Navigation
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
@ -36,19 +37,14 @@ class CrashReporterFragment : Fragment() {
requireContext().components.analytics.metrics.track(Event.CrashReporterOpened)
val selectedSession = requireComponents.core.sessionManager.selectedSession
restore_tab_button.setOnClickListener {
selectedSession?.let { session -> closeFragment(true, session, crash) }
}
close_tab_button.setOnClickListener {
val selectedSession = requireComponents.core.sessionManager.selectedSession
selectedSession?.let { session -> requireComponents.useCases.tabsUseCases.removeTab.invoke(session) }
var wantsSubmitCrashReport = false
if (Settings.getInstance(context!!).isCrashReportingEnabled) {
requireComponents.analytics.crashReporter.submitReport(crash)
wantsSubmitCrashReport = true
}
requireContext().components.analytics.metrics.track(Event.CrashReporterClosed(wantsSubmitCrashReport))
navigateHome(view)
selectedSession?.let { session -> closeFragment(false, session, crash) }
}
}
@ -57,12 +53,29 @@ class CrashReporterFragment : Fragment() {
(activity as AppCompatActivity).supportActionBar?.hide()
}
fun navigateHome(fromView: View) {
private fun closeFragment(shouldRestore: Boolean, session: Session, crash: Crash) {
submitReportIfNecessary(crash)
if (shouldRestore) {
requireComponents.useCases.sessionUseCases.crashRecovery.invoke(session)
Navigation.findNavController(view!!).popBackStack()
} else {
requireComponents.useCases.tabsUseCases.removeTab.invoke(session)
navigateHome(view!!)
}
}
private fun submitReportIfNecessary(crash: Crash) {
var didSubmitCrashReport = false
if (Settings.getInstance(context!!).isCrashReportingEnabled) {
requireComponents.analytics.crashReporter.submitReport(crash)
didSubmitCrashReport = true
}
requireContext().components.analytics.metrics.track(Event.CrashReporterClosed(didSubmitCrashReport))
}
private fun navigateHome(fromView: View) {
val directions = CrashReporterFragmentDirections.actionCrashReporterFragmentToHomeFragment()
Navigation.findNavController(fromView).navigate(directions)
}
fun onBackPressed() {
requireContext().components.analytics.metrics.track(Event.CrashReporterClosed(false))
}
}