2019-03-20 18:47:22 +01:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
package org.mozilla.fenix.crashes
|
|
|
|
|
|
|
|
import android.os.Bundle
|
|
|
|
import android.view.View
|
|
|
|
import androidx.fragment.app.Fragment
|
2019-08-19 21:53:24 +02:00
|
|
|
import androidx.navigation.fragment.findNavController
|
2019-09-13 19:06:03 +02:00
|
|
|
import androidx.navigation.fragment.navArgs
|
2019-03-20 18:47:22 +01:00
|
|
|
import kotlinx.android.synthetic.main.fragment_crash_reporter.*
|
|
|
|
import mozilla.components.lib.crash.Crash
|
|
|
|
import org.mozilla.fenix.R
|
2019-11-25 21:36:47 +01:00
|
|
|
import org.mozilla.fenix.ext.hideToolbar
|
2020-02-07 18:41:17 +01:00
|
|
|
import org.mozilla.fenix.ext.increaseTapArea
|
2019-03-20 18:47:22 +01:00
|
|
|
import org.mozilla.fenix.ext.requireComponents
|
2019-09-10 19:11:58 +02:00
|
|
|
import org.mozilla.fenix.ext.settings
|
2019-03-20 18:47:22 +01:00
|
|
|
|
2019-09-13 19:06:03 +02:00
|
|
|
/**
|
|
|
|
* Fragment shown when a tab crashes.
|
|
|
|
*/
|
2019-10-06 19:57:41 +02:00
|
|
|
class CrashReporterFragment : Fragment(R.layout.fragment_crash_reporter) {
|
2019-03-20 18:47:22 +01:00
|
|
|
|
|
|
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
|
|
|
super.onViewCreated(view, savedInstanceState)
|
2019-03-22 18:05:16 +01:00
|
|
|
|
2019-09-13 19:06:03 +02:00
|
|
|
val args: CrashReporterFragmentArgs by navArgs()
|
|
|
|
val crash = Crash.fromIntent(args.crashIntent)
|
2019-03-22 18:05:16 +01:00
|
|
|
|
2019-09-13 19:06:03 +02:00
|
|
|
title.text = getString(R.string.tab_crash_title_2, getString(R.string.app_name))
|
2019-03-20 18:47:22 +01:00
|
|
|
|
2019-09-13 19:06:03 +02:00
|
|
|
val controller = CrashReporterController(
|
|
|
|
crash,
|
|
|
|
session = requireComponents.core.sessionManager.selectedSession,
|
|
|
|
navController = findNavController(),
|
|
|
|
components = requireComponents,
|
2019-09-24 19:33:46 +02:00
|
|
|
settings = requireContext().settings()
|
2019-09-13 19:06:03 +02:00
|
|
|
)
|
2019-03-20 18:47:22 +01:00
|
|
|
|
2020-02-07 18:41:17 +01:00
|
|
|
restoreTabButton.apply {
|
|
|
|
increaseTapArea(TAP_INCREASE_DP)
|
|
|
|
setOnClickListener {
|
|
|
|
controller.handleCloseAndRestore(sendCrashCheckbox.isChecked)
|
|
|
|
}
|
2019-04-08 17:04:22 +02:00
|
|
|
}
|
2020-02-07 18:41:17 +01:00
|
|
|
|
|
|
|
closeTabButton.apply {
|
|
|
|
increaseTapArea(TAP_INCREASE_DP)
|
|
|
|
setOnClickListener {
|
|
|
|
controller.handleCloseAndRemove(sendCrashCheckbox.isChecked)
|
|
|
|
}
|
2019-03-20 18:47:22 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-28 22:21:21 +01:00
|
|
|
override fun onResume() {
|
|
|
|
super.onResume()
|
2019-11-25 21:36:47 +01:00
|
|
|
hideToolbar()
|
2019-03-28 22:21:21 +01:00
|
|
|
}
|
2020-02-07 18:41:17 +01:00
|
|
|
|
|
|
|
companion object {
|
|
|
|
private const val TAP_INCREASE_DP = 12
|
|
|
|
}
|
2019-03-20 18:47:22 +01:00
|
|
|
}
|