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 74b6a752f86..6e88526c242 100644 --- a/app/src/main/java/org/mozilla/focus/fragment/BrowserFragment.kt +++ b/app/src/main/java/org/mozilla/focus/fragment/BrowserFragment.kt @@ -51,6 +51,7 @@ import android.widget.TextView import android.widget.Toast import kotlinx.android.synthetic.main.browser_display_toolbar.* import kotlinx.android.synthetic.main.fragment_browser.* +import kotlinx.android.synthetic.main.toolbar.* import mozilla.components.browser.session.Session import mozilla.components.browser.session.SessionManager import mozilla.components.lib.crash.Crash @@ -65,6 +66,7 @@ import org.mozilla.focus.biometrics.BiometricAuthenticationDialogFragment import org.mozilla.focus.biometrics.BiometricAuthenticationHandler import org.mozilla.focus.biometrics.Biometrics import org.mozilla.focus.broadcastreceiver.DownloadBroadcastReceiver +import org.mozilla.focus.ext.isSearch import org.mozilla.focus.ext.requireComponents import org.mozilla.focus.ext.shouldRequestDesktopSite import org.mozilla.focus.findinpage.FindInPageCoordinator @@ -677,7 +679,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 @@ -699,11 +701,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() @@ -713,6 +719,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) { @@ -965,7 +980,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!!) @@ -1100,7 +1117,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) @@ -1293,6 +1310,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) { 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 35a4580ca4b..65e669184f1 100644 --- a/app/src/main/java/org/mozilla/focus/telemetry/CrashReporterWrapper.kt +++ b/app/src/main/java/org/mozilla/focus/telemetry/CrashReporterWrapper.kt @@ -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) { diff --git a/app/src/main/res/drawable/ic_firefox.xml b/app/src/main/res/drawable/ic_firefox.xml new file mode 100644 index 00000000000..4dc3f0e127a --- /dev/null +++ b/app/src/main/res/drawable/ic_firefox.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/layout/fragment_crash_reporter.xml b/app/src/main/res/layout/fragment_crash_reporter.xml index a0e4c11cc76..43f43dc767d 100644 --- a/app/src/main/res/layout/fragment_crash_reporter.xml +++ b/app/src/main/res/layout/fragment_crash_reporter.xml @@ -22,13 +22,14 @@ @@ -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" /> @@ -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" @@ -63,16 +66,17 @@