Skip to content
This repository has been archived by the owner on Jan 12, 2023. It is now read-only.

Commit

Permalink
For #3074 - Adds Crash reporting UI
Browse files Browse the repository at this point in the history
  • Loading branch information
boek committed Nov 9, 2018
1 parent 52963c7 commit 9b7976b
Show file tree
Hide file tree
Showing 5 changed files with 506 additions and 0 deletions.
20 changes: 20 additions & 0 deletions app/src/main/java/org/mozilla/focus/fragment/BrowserFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,24 @@ class BrowserFragment : WebFragment(), LifecycleObserver, View.OnClickListener,
}
}

internal fun showCrashReporter(crash: Crash) {
val fragmentManager = requireActivity().supportFragmentManager

Log.e("crash:", crash.toString())
if (fragmentManager.findFragmentByTag(CrashReporterFragment.FRAGMENT_TAG) != null) {
// We are already displaying the crash reporter
// No need to show another one.
return
}

val crashReporterFragment = CrashReporterFragment.create()

fragmentManager
.beginTransaction()
.add(R.id.container, crashReporterFragment, CrashReporterFragment.FRAGMENT_TAG)
.commit()
}

internal fun showAddToHomescreenDialog(url: String, title: String) {
val fragmentManager = fragmentManager

Expand Down Expand Up @@ -1369,6 +1387,8 @@ class BrowserFragment : WebFragment(), LifecycleObserver, View.OnClickListener,

fun handleTabCrash(crash: Crash) {
Log.e("crashed!", crash.toString())
showCrashReporter(crash)

}

companion object {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/* 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.focus.fragment

import android.os.Bundle
import android.support.v4.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import org.mozilla.focus.R


class CrashReporterFragment: Fragment() {
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? = inflater.inflate(R.layout.fragment_crash_reporter, container, false)

companion object {
val FRAGMENT_TAG = "crash-reporter"

fun create() = CrashReporterFragment()
}
}
Loading

0 comments on commit 9b7976b

Please sign in to comment.