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

Commit

Permalink
For #3074 - Add name to fatal crash dialog.
Browse files Browse the repository at this point in the history
  • Loading branch information
boek committed Nov 9, 2018
1 parent c6f5b92 commit 6171b89
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
3 changes: 2 additions & 1 deletion app/src/main/java/org/mozilla/focus/activity/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,8 @@ open class MainActivity : LocaleAwareAppCompatActivity() {

override fun onNewIntent(unsafeIntent: Intent) {
if (Crash.isCrashIntent(unsafeIntent)) {
val browserFragment = supportFragmentManager.findFragmentByTag(BrowserFragment.FRAGMENT_TAG) as BrowserFragment?
val browserFragment = supportFragmentManager
.findFragmentByTag(BrowserFragment.FRAGMENT_TAG) as BrowserFragment?
val crash = Crash.fromIntent(unsafeIntent)

browserFragment?.handleTabCrash(crash)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,7 @@ class BrowserFragment : WebFragment(), LifecycleObserver, View.OnClickListener,
}
}

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

Log.e("crash:", crash.toString())
Expand Down Expand Up @@ -707,7 +707,7 @@ class BrowserFragment : WebFragment(), LifecycleObserver, View.OnClickListener,
urlView?.text = requireContext().getString(R.string.tab_crash_report_title)
}

internal fun hideCrashReporter() {
private fun hideCrashReporter() {
val fragmentManager = requireActivity().supportFragmentManager
val fragment = fragmentManager.findFragmentByTag(CrashReporterFragment.FRAGMENT_TAG)
?: return
Expand All @@ -727,7 +727,7 @@ class BrowserFragment : WebFragment(), LifecycleObserver, View.OnClickListener,
}
}

internal fun crashReporterIsVisible(): Boolean = requireActivity().supportFragmentManager.let {
private fun crashReporterIsVisible(): Boolean = requireActivity().supportFragmentManager.let {
it.findFragmentByTag(CrashReporterFragment.FRAGMENT_TAG)?.isVisible ?: false
}

Expand Down Expand Up @@ -1429,9 +1429,7 @@ 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
Expand Up @@ -12,15 +12,13 @@ import android.view.ViewGroup
import kotlinx.android.synthetic.main.fragment_crash_reporter.*
import org.mozilla.focus.R


class CrashReporterFragment: Fragment() {

class CrashReporterFragment : Fragment() {
var onCloseTabPressed: ((sendCrashReport: Boolean) -> Unit)? = null

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

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
Expand All @@ -37,4 +35,4 @@ class CrashReporterFragment: Fragment() {

fun create() = CrashReporterFragment()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import mozilla.components.lib.crash.CrashReporter
import mozilla.components.lib.crash.service.MozillaSocorroService
import mozilla.components.lib.crash.service.SentryService
import org.mozilla.focus.BuildConfig
import org.mozilla.focus.R
import org.mozilla.focus.activity.MainActivity
import org.mozilla.focus.locale.LocaleManager
import java.util.Locale
Expand All @@ -37,7 +38,7 @@ object CrashReporterWrapper {
val supportedBuild = Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP
if (!supportedBuild || BuildConfig.SENTRY_TOKEN.isEmpty()) return

val sentryDsn= BuildConfig.SENTRY_TOKEN
val sentryDsn = BuildConfig.SENTRY_TOKEN

val intent = Intent(context, MainActivity::class.java).apply {
flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP
Expand All @@ -49,7 +50,6 @@ object CrashReporterWrapper {
intent,
0)


crashReporter = CrashReporter(
services = listOf(
SentryService(
Expand All @@ -59,6 +59,9 @@ object CrashReporterWrapper {
sendEventForNativeCrashes = true),
MozillaSocorroService(context, "Firefox Focus")
),
promptConfiguration = CrashReporter.PromptConfiguration(
appName = context.resources.getString(R.string.app_name)
),
shouldPrompt = CrashReporter.Prompt.ALWAYS,
nonFatalCrashIntent = pendingIntent).install(context)

Expand Down

0 comments on commit 6171b89

Please sign in to comment.