1
0
Fork 0

Closes #1062 & Closes #1121: Restyles crash reporter fragment (#1122)

master
Sawyer Blatz 2019-03-22 10:05:16 -07:00 committed by GitHub
parent 8f11ab6fcf
commit c44e378385
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 42 additions and 59 deletions

View File

@ -8,12 +8,14 @@ import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.fragment.app.Fragment
import androidx.navigation.Navigation
import kotlinx.android.synthetic.main.fragment_crash_reporter.*
import mozilla.components.lib.crash.Crash
import org.mozilla.fenix.R
import org.mozilla.fenix.ext.requireComponents
import org.mozilla.fenix.utils.Settings
class CrashReporterFragment : Fragment() {
override fun onCreateView(
@ -24,20 +26,21 @@ class CrashReporterFragment : Fragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
val crashIntent = CrashReporterFragmentArgs.fromBundle(arguments!!).crashIntent
val crash = Crash.fromIntent(CrashReporterFragmentArgs.fromBundle(arguments!!).crashIntent)
view.findViewById<TextView>(R.id.title).text =
getString(R.string.tab_crash_title, context!!.getString(R.string.app_name))
// TODO TelemetryWrapper.crashReporterOpened()
closeTabButton.setOnClickListener {
val wantsToSubmitCrashReport = sendCrashCheckbox.isChecked
val selectedSession = requireComponents.core.sessionManager.selectedSession
selectedSession?.let { session -> requireComponents.useCases.tabsUseCases.removeTab.invoke(session) }
// TODO TelemetryWrapper.crashReporterClosed(wantsSubmitCrashReport)
if (wantsToSubmitCrashReport) {
if (Settings.getInstance(context!!).isCrashReportingEnabled) {
requireComponents.analytics.crashReporter.submitReport(crash)
}

View File

@ -38,6 +38,9 @@ class Settings private constructor(context: Context) {
val defaultSearchEngineName: String
get() = preferences.getString(appContext.getPreferenceKey(R.string.pref_key_search_engine), "") ?: ""
val isCrashReportingEnabled: Boolean
get() = preferences.getBoolean(appContext.getPreferenceKey(R.string.pref_key_crash_reporter), true)
val isTelemetryEnabled: Boolean
get() = preferences.getBoolean(appContext.getPreferenceKey(R.string.pref_key_telemetry), true)
@ -61,9 +64,4 @@ class Settings private constructor(context: Context) {
appContext.getPreferenceKey(R.string.pref_key_show_search_suggestions),
true
)
fun crashReportingEnabled(): Boolean = preferences.getBoolean(
appContext.getPreferenceKey(R.string.pref_key_crash_reporter),
true
)
}

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- 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/. -->
<shape android:shape="rectangle" xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="4dp" />
<size android:height="36dp" android:width="158dp" />
<solid android:color="#FF312A65" />
</shape>

Binary file not shown.

After

Width:  |  Height:  |  Size: 123 KiB

View File

@ -5,7 +5,6 @@
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/photonGrey10">
@ -13,12 +12,11 @@
<ImageView
android:id="@+id/crash_tab_image"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginTop="8dp"
android:src="@drawable/ic_error_session_crashed"
android:layout_height="120dp"
android:layout_marginTop="40dp"
android:src="@drawable/fenix_error_1"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintDimensionRatio="1:1"
app:layout_constraintWidth_percent="0.6"
app:layout_constraintWidth_percent="0.8"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
@ -26,58 +24,31 @@
android:id="@+id/title"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:layout_marginTop="6dp"
android:lineSpacingExtra="8sp"
android:singleLine="false"
android:text="@string/tab_crash_title"
android:textAlignment="center"
android:textColor="@color/search_text"
android:textSize="20sp"
android:textColor="@color/light_mode_text_color"
android:textSize="24sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/crash_tab_image" />
<TextView
android:id="@+id/description"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:lineSpacingExtra="7sp"
android:singleLine="false"
android:text="@string/tab_crash_description"
android:textColor="@color/search_text"
android:textSize="15sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/title" />
<CheckBox
android:id="@+id/sendCrashCheckbox"
android:layout_width="0dp"
android:layout_height="32dp"
android:layout_marginBottom="@dimen/crash_reporter_close_tab_button_bottom_margin"
android:buttonTint="@color/crash_page_accent"
android:checked="true"
android:text="@string/tab_crash_send_report"
android:textColor="@color/search_text"
android:textSize="15sp"
app:layout_constraintBottom_toTopOf="@id/restoreTabButton"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintWidth_percent="0.8"
tools:text="@string/tab_crash_send_report" />
<Button
android:id="@+id/restoreTabButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_height="36dp"
android:layout_marginStart="@dimen/crash_reporter_close_tab_button_horizontal_margin"
android:layout_marginEnd="@dimen/crash_reporter_close_tab_button_horizontal_margin"
android:layout_marginBottom="@dimen/crash_reporter_close_tab_button_bottom_margin"
android:backgroundTint="@color/crash_page_accent"
android:text="@string/tab_crash_restore"
android:fontFamily="Sharp Sans"
android:textColor="@color/off_white"
android:textStyle="bold"
android:textAllCaps="false"
android:textSize="14sp"
android:background="@drawable/crash_reporter_button"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintWidth_percent="0.4" />
@ -85,14 +56,18 @@
<Button
android:id="@+id/closeTabButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_height="36dp"
android:layout_marginStart="@dimen/crash_reporter_close_tab_button_horizontal_margin"
android:layout_marginEnd="@dimen/crash_reporter_close_tab_button_horizontal_margin"
android:layout_marginBottom="@dimen/crash_reporter_close_tab_button_bottom_margin"
android:backgroundTint="@color/crash_page_off_accent"
android:text="@string/tab_crash_close"
android:textColor="@color/search_text"
android:fontFamily="Sharp Sans"
android:textColor="@color/light_mode_text_color"
android:textStyle="bold"
android:textAllCaps="false"
android:textSize="14sp"
android:background="@drawable/crash_reporter_button"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintWidth_percent="0.4" />

View File

@ -70,7 +70,6 @@
app:destination="@id/libraryFragment" />
</fragment>
<fragment
android:id="@+id/libraryFragment"
android:name="org.mozilla.fenix.library.LibraryFragment"
@ -81,8 +80,6 @@
app:destination="@+id/historyFragment" />
</fragment>
<fragment
android:id="@+id/historyFragment"
android:name="org.mozilla.fenix.library.history.HistoryFragment"

View File

@ -77,8 +77,8 @@
<color name="history_title_private_theme">@color/off_white</color>
<color name="history_url_private_theme">@color/photonGrey40</color>
<color name="crash_page_accent">#45a1ff</color>
<color name="crash_page_off_accent">@color/photonGrey30</color>
<color name="crash_page_accent">#312a65</color>
<color name="crash_page_off_accent">#efeff2</color>
<color name="quick_action_share_icon">#174291</color>
<color name="quick_action_share_icon_background">#b9f0fd</color>

View File

@ -250,7 +250,7 @@
<!-- Crashes -->
<!-- Title text displayed on the tab crash page -->
<string name="tab_crash_title">Sorry. We\'re having a problem with this tab.</string>
<string name="tab_crash_title">Sorry. %1$s can\'t get that tab back</string>
<!-- Description text displayed on the tab crash page -->
<string name="tab_crash_description">You can attempt to restore or close this tab below.</string>
<!-- Send crash report checkbox text on the tab crash page -->