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

Commit

Permalink
Closes #1062 & Closes #1121: Restyles crash reporter fragment (#1122)
Browse files Browse the repository at this point in the history
  • Loading branch information
sblatz authored Mar 22, 2019
1 parent 8f11ab6 commit c44e378
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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)
}

Expand Down
8 changes: 3 additions & 5 deletions app/src/main/java/org/mozilla/fenix/utils/Settings.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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
)
}
10 changes: 10 additions & 0 deletions app/src/main/res/drawable/crash_reporter_button.xml
Original file line number Diff line number Diff line change
@@ -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 added app/src/main/res/drawable/fenix_error_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
63 changes: 19 additions & 44 deletions app/src/main/res/layout/fragment_crash_reporter.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,94 +5,69 @@
<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">

<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"/>

<TextView
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" />

<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" />
Expand Down
3 changes: 0 additions & 3 deletions app/src/main/res/navigation/nav_graph.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@
app:destination="@id/libraryFragment" />
</fragment>


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



<fragment
android:id="@+id/historyFragment"
android:name="org.mozilla.fenix.library.history.HistoryFragment"
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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 -->
Expand Down

0 comments on commit c44e378

Please sign in to comment.