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

Commit

Permalink
For #3074 - Polishes Crash reporter state
Browse files Browse the repository at this point in the history
  • Loading branch information
boek committed Nov 9, 2018
1 parent e772fed commit c6f5b92
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 13 deletions.
25 changes: 21 additions & 4 deletions app/src/main/java/org/mozilla/focus/fragment/BrowserFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ import org.mozilla.focus.biometrics.BiometricAuthenticationHandler
import org.mozilla.focus.biometrics.Biometrics
import org.mozilla.focus.broadcastreceiver.DownloadBroadcastReceiver
import org.mozilla.focus.exceptions.ExceptionDomains
import org.mozilla.focus.ext.isSearch
import org.mozilla.focus.ext.requireComponents
import org.mozilla.focus.ext.shouldRequestDesktopSite
import org.mozilla.focus.findinpage.FindInPageCoordinator
Expand Down Expand Up @@ -679,7 +680,7 @@ class BrowserFragment : WebFragment(), LifecycleObserver, View.OnClickListener,
val fragmentManager = requireActivity().supportFragmentManager

Log.e("crash:", crash.toString())
if (fragmentManager.findFragmentByTag(CrashReporterFragment.FRAGMENT_TAG) != null) {
if (crashReporterIsVisible()) {
// We are already displaying the crash reporter
// No need to show another one.
return
Expand All @@ -701,11 +702,15 @@ class BrowserFragment : WebFragment(), LifecycleObserver, View.OnClickListener,
crash_container.visibility = View.VISIBLE
tabs.hide()
erase.hide()
securityView?.setImageResource(R.drawable.ic_firefox)
menuView?.visibility = View.GONE
urlView?.text = requireContext().getString(R.string.tab_crash_report_title)
}

internal fun hideCrashReporter() {
val fragmentManager = requireActivity().supportFragmentManager
val fragment = fragmentManager.findFragmentByTag(CrashReporterFragment.FRAGMENT_TAG) ?: return
val fragment = fragmentManager.findFragmentByTag(CrashReporterFragment.FRAGMENT_TAG)
?: return

fragmentManager
.beginTransaction()
Expand All @@ -715,6 +720,15 @@ class BrowserFragment : WebFragment(), LifecycleObserver, View.OnClickListener,
crash_container.visibility = View.GONE
tabs.show()
erase.show()
securityView?.setImageResource(R.drawable.ic_internet)
menuView?.visibility = View.VISIBLE
urlView?.text = session.let {
if (it.isSearch) it.searchTerms else it.url
}
}

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

internal fun showAddToHomescreenDialog(url: String, title: String) {
Expand Down Expand Up @@ -967,7 +981,9 @@ class BrowserFragment : WebFragment(), LifecycleObserver, View.OnClickListener,
menuWeakReference = WeakReference(menu)
}

R.id.display_url -> if (requireComponents.sessionManager.findSessionById(session.id) != null) {
R.id.display_url -> if (
!crashReporterIsVisible() &&
requireComponents.sessionManager.findSessionById(session.id) != null) {
val urlFragment = UrlInputFragment
.createWithSession(session, urlView!!)

Expand Down Expand Up @@ -1102,7 +1118,7 @@ class BrowserFragment : WebFragment(), LifecycleObserver, View.OnClickListener,
showAddToHomescreenDialog(url, title)
}

R.id.security_info -> showSecurityPopUp()
R.id.security_info -> if (!crashReporterIsVisible()) { showSecurityPopUp() }

R.id.report_site_issue -> {
val reportUrl = String.format(SupportUtils.REPORT_SITE_ISSUE_URL, url)
Expand Down Expand Up @@ -1295,6 +1311,7 @@ class BrowserFragment : WebFragment(), LifecycleObserver, View.OnClickListener,
}

private fun updateSecurityIcon(session: Session, securityInfo: Session.SecurityInfo = session.securityInfo) {
if (crashReporterIsVisible()) return
val securityView = securityView ?: return

if (!session.loading) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ object CrashReporterWrapper {
}

fun onIsEnabledChanged(context: Context, isEnabled: Boolean = TelemetryWrapper.isTelemetryEnabled(context)) {
crashReporter?.enabled = isEnabled || true
crashReporter?.enabled = isEnabled
}

fun submitCrash(crash: Crash) {
Expand Down
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/ic_firefox.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="32dp"
android:height="32dp"
android:viewportWidth="32"
android:viewportHeight="32">
<path
android:pathData="M31.359,14.615h0c-0.044,-0.289 -0.088,-0.459 -0.088,-0.459s-0.113,0.131 -0.3,0.378A10.77,10.77 0,0 0,30.6 12.5a13.846,13.846 0,0 0,-0.937 -2.411,10.048 10.048,0 0,0 -0.856,-1.468q-0.176,-0.263 -0.359,-0.51c-0.57,-0.931 -1.224,-1.5 -1.981,-2.576a7.806,7.806 0,0 1,-0.991 -2.685A10.844,10.844 0,0 0,25 4.607c-0.777,-0.784 -1.453,-1.341 -1.861,-1.721C21.126,1.006 21.36,0.031 21.36,0.031h0S17.6,4.228 19.229,8.6a8.4,8.4 0,0 0,2.8 3.733c1.576,1.3 3.273,2.323 4.168,4.937a8.377,8.377 0,0 0,-3.144 -3.317,7.573 7.573,0 0,1 0.6,3 7.124,7.124 0,0 1,-8.711 6.94,6.561 6.561,0 0,1 -1.765,-0.6 7.183,7.183 0,0 1,-2.115 -1.955l-0.01,-0.017 0.126,0.046a6.5,6.5 0,0 0,0.9 0.241,5.628 5.628,0 0,0 3.583,-0.423c1.126,-0.625 1.808,-1.088 2.361,-0.905l0.01,0c0.54,0.172 0.966,-0.352 0.58,-0.9a2.94,2.94 0,0 0,-2.848 -1.112c-1.127,0.164 -2.16,0.965 -3.637,0.189a3.129,3.129 0,0 1,-0.277 -0.163c-0.1,-0.057 0.317,0.087 0.22,0.022a7.33,7.33 0,0 1,-0.928 -0.554c-0.022,-0.018 0.223,0.07 0.2,0.052a3.581,3.581 0,0 1,-0.968 -0.979,1.741 1.741,0 0,1 -0.066,-1.554 1.371,1.371 0,0 1,0.6 -0.564c0.191,0.094 0.309,0.165 0.309,0.165s-0.087,-0.16 -0.134,-0.244c0.017,-0.006 0.032,0 0.049,-0.011 0.167,0.072 0.537,0.26 0.732,0.375a1.016,1.016 0,0 1,0.335 0.3s0.067,-0.033 0.017,-0.173a0.9,0.9 0,0 0,-0.346 -0.424l0.016,0a2.94,2.94 0,0 1,0.426 0.265,2.079 2.079,0 0,0 0.17,-0.9 1.178,1.178 0,0 0,-0.069 -0.5c-0.053,-0.1 0.03,-0.14 0.123,-0.035a0.976,0.976 0,0 0,-0.079 -0.238v-0.008h0s0.053,-0.069 0.077,-0.094a1.43,1.43 0,0 1,0.216 -0.176,9.973 9.973,0 0,1 1.465,-0.747c0.414,-0.181 0.757,-0.319 0.827,-0.359a2.3,2.3 0,0 0,0.293 -0.225,1.968 1.968,0 0,0 0.66,-1.14 1.6,1.6 0,0 0,0.017 -0.178v-0.05l0,-0.03v0l0,-0.012v0l0,-0.013h0c-0.06,-0.225 -0.448,-0.394 -2.476,-0.584a1.773,1.773 0,0 1,-1.45 -1.36l0,0.009c-0.029,0.074 -0.055,0.149 -0.081,0.225 0.026,-0.075 0.052,-0.15 0.081,-0.225l0,-0.016a5.138,5.138 0,0 1,1.986 -2.466c0.052,-0.042 -0.208,0.011 -0.156,-0.032a5.156,5.156 0,0 1,0.53 -0.224c0.091,-0.038 -0.39,-0.222 -0.815,-0.177a2.2,2.2 0,0 0,-0.756 0.178c0.1,-0.086 0.4,-0.2 0.329,-0.2a4.865,4.865 0,0 0,-1.542 0.583,0.314 0.314,0 0,1 0.03,-0.14 2.4,2.4 0,0 0,-0.964 0.744,1.275 1.275,0 0,0 0.01,-0.174 2.876,2.876 0,0 0,-0.473 0.444l-0.009,0.007a6.285,6.285 0,0 0,-3.517 -0.3l-0.01,-0.009 0.012,0a2.943,2.943 0,0 1,-0.625 -0.7L6.1,5.852 6.081,5.83c-0.077,-0.114 -0.156,-0.243 -0.237,-0.387 -0.058,-0.1 -0.117,-0.217 -0.176,-0.338 0,-0.008 -0.009,-0.011 -0.013,-0.012 -0.024,0 -0.041,0.111 -0.061,0.082l0,-0.006a4.308,4.308 0,0 1,-0.283 -1.687l-0.016,0.008a1.884,1.884 0,0 0,-0.714 0.934c-0.061,0.137 -0.1,0.212 -0.14,0.287 0,0.006 0,-0.01 0,-0.035 0.009,-0.069 0.039,-0.211 0.032,-0.2s-0.012,0.019 -0.019,0.029a1.733,1.733 0,0 0,-0.251 0.372,2.355 2.355,0 0,0 -0.15,0.382c-0.006,0.021 0,-0.018 0,-0.064s0.009,-0.128 0,-0.111l-0.022,0.043a9.5,9.5 0,0 0,-0.8 3.035A3.022,3.022 0,0 0,3.2 8.7v0.016a6.628,6.628 0,0 0,-0.817 1.1,15.606 15.606,0 0,0 -1.727,4.23 10.351,10.351 0,0 1,0.925 -1.621,15 15,0 0,0 -1.045,5.5 14.233,14.233 0,0 1,0.45 -1.629A13.807,13.807 0,0 0,2.234 22.76a15.037,15.037 0,0 0,5.951 6.748h0a13.016,13.016 0,0 0,3.468 1.662c0.162,0.059 0.326,0.117 0.494,0.173 -0.053,-0.021 -0.1,-0.044 -0.153,-0.067a15.7,15.7 0,0 0,4.5 0.662c5.394,0 7.175,-2.054 7.339,-2.259h0a2.73,2.73 0,0 0,0.637 -0.856h0q0.156,-0.064 0.315,-0.137l0.067,-0.03 0.121,-0.057a11.312,11.312 0,0 0,2.277 -1.426,5.5 5.5,0 0,0 2.123,-3.1h0a1.938,1.938 0,0 0,0.029 -1.428q0.083,-0.131 0.171,-0.28a12.706,12.706 0,0 0,1.907 -6.181v-0.006c0,-0.059 0,-0.118 0,-0.177A7.731,7.731 0,0 0,31.359 14.615Z"
android:fillColor="#f9f9fa"/>
</vector>
20 changes: 12 additions & 8 deletions app/src/main/res/layout/fragment_crash_reporter.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@
<TextView
android:id="@+id/headline"
android:layout_width="300dp"
android:layout_height="54dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:lineSpacingExtra="8sp"
android:singleLine="false"
android:text="@string/tab_crash_report_headline"
android:textAlignment="center"
android:textColor="@android:color/black"
android:textSize="20sp"
android:layout_marginTop="12dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/background" />
Expand All @@ -37,11 +38,12 @@
android:id="@+id/description"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:lineSpacingExtra="7sp"
android:singleLine="false"
android:text="@string/tab_crash_report_description"
android:textColor="@android:color/black"
android:textSize="15sp"
android:layout_marginTop="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/headline" />
Expand All @@ -55,6 +57,7 @@
android:checked="true"
android:text="@string/crash_report_send_crash_label"
android:textColor="@android:color/black"
android:textSize="15sp"
app:layout_constraintBottom_toTopOf="@id/closeTabButton"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
Expand All @@ -63,16 +66,17 @@

<Button
android:id="@+id/closeTabButton"
android:layout_marginEnd="26dp"
android:layout_marginStart="26dp"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="26dp"
android:layout_marginEnd="26dp"
android:layout_marginBottom="24dp"
android:backgroundTint="@color/colorCrashAccent"
android:text="@string/tab_crash_report_close_tab_button_label"
android:textFontWeight="600"
android:layout_marginBottom="24dp"
app:layout_constraintWidth_percent="0.8"
android:textSize="14sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toBottomOf="parent" />
app:layout_constraintWidth_percent="0.8" />
</android.support.constraint.ConstraintLayout>

0 comments on commit c6f5b92

Please sign in to comment.