diff --git a/app/src/main/java/org/mozilla/focus/activity/MainActivity.kt b/app/src/main/java/org/mozilla/focus/activity/MainActivity.kt index 90a0a98a386..f64ecdfe07f 100644 --- a/app/src/main/java/org/mozilla/focus/activity/MainActivity.kt +++ b/app/src/main/java/org/mozilla/focus/activity/MainActivity.kt @@ -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) diff --git a/app/src/main/java/org/mozilla/focus/fragment/BrowserFragment.kt b/app/src/main/java/org/mozilla/focus/fragment/BrowserFragment.kt index 6e88526c242..e0394f1581a 100644 --- a/app/src/main/java/org/mozilla/focus/fragment/BrowserFragment.kt +++ b/app/src/main/java/org/mozilla/focus/fragment/BrowserFragment.kt @@ -675,7 +675,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()) @@ -706,7 +706,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 @@ -726,7 +726,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 } @@ -1419,9 +1419,7 @@ class BrowserFragment : WebFragment(), LifecycleObserver, View.OnClickListener, } fun handleTabCrash(crash: Crash) { - Log.e("crashed!", crash.toString()) showCrashReporter(crash) - } companion object { diff --git a/app/src/main/java/org/mozilla/focus/fragment/CrashReporterFragment.kt b/app/src/main/java/org/mozilla/focus/fragment/CrashReporterFragment.kt index 7eef4c52537..509e1fbbdd3 100644 --- a/app/src/main/java/org/mozilla/focus/fragment/CrashReporterFragment.kt +++ b/app/src/main/java/org/mozilla/focus/fragment/CrashReporterFragment.kt @@ -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?) { @@ -37,4 +35,4 @@ class CrashReporterFragment: Fragment() { fun create() = CrashReporterFragment() } -} \ No newline at end of file +} diff --git a/app/src/main/java/org/mozilla/focus/telemetry/CrashReporterWrapper.kt b/app/src/main/java/org/mozilla/focus/telemetry/CrashReporterWrapper.kt index 65e669184f1..dc0961b832d 100644 --- a/app/src/main/java/org/mozilla/focus/telemetry/CrashReporterWrapper.kt +++ b/app/src/main/java/org/mozilla/focus/telemetry/CrashReporterWrapper.kt @@ -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 @@ -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 @@ -49,7 +50,6 @@ object CrashReporterWrapper { intent, 0) - crashReporter = CrashReporter( services = listOf( SentryService( @@ -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)