1
0
Fork 0
fenix/app/src/main/java/org/mozilla/fenix/crashes/CrashReporterFragment.kt

65 lines
2.0 KiB
Kotlin
Raw Normal View History

/* 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
import androidx.navigation.fragment.findNavController
2019-09-13 19:06:03 +02:00
import androidx.navigation.fragment.navArgs
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
import org.mozilla.fenix.ext.increaseTapArea
import org.mozilla.fenix.ext.requireComponents
import org.mozilla.fenix.ext.settings
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) {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
2019-09-13 19:06:03 +02:00
val args: CrashReporterFragmentArgs by navArgs()
val crash = Crash.fromIntent(args.crashIntent)
2019-09-13 19:06:03 +02:00
title.text = getString(R.string.tab_crash_title_2, getString(R.string.app_name))
2019-09-13 19:06:03 +02:00
val controller = CrashReporterController(
crash,
session = requireComponents.core.sessionManager.selectedSession,
navController = findNavController(),
components = requireComponents,
settings = requireContext().settings()
2019-09-13 19:06:03 +02:00
)
restoreTabButton.apply {
increaseTapArea(TAP_INCREASE_DP)
setOnClickListener {
controller.handleCloseAndRestore(sendCrashCheckbox.isChecked)
}
}
closeTabButton.apply {
increaseTapArea(TAP_INCREASE_DP)
setOnClickListener {
controller.handleCloseAndRemove(sendCrashCheckbox.isChecked)
}
}
}
override fun onResume() {
super.onResume()
2019-11-25 21:36:47 +01:00
hideToolbar()
}
companion object {
private const val TAP_INCREASE_DP = 12
}
}