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

Commit

Permalink
For #3074 - Show crash report view over browser
Browse files Browse the repository at this point in the history
  • Loading branch information
boek committed Nov 9, 2018
1 parent 9b7976b commit e49774a
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import android.widget.ImageView
import android.widget.TextView
import android.widget.Toast
import kotlinx.android.synthetic.main.browser_display_toolbar.*
import kotlinx.android.synthetic.main.fragment_browser.*
import mozilla.components.browser.session.Session
import mozilla.components.browser.session.SessionManager
import mozilla.components.lib.crash.Crash
Expand Down Expand Up @@ -687,8 +688,13 @@ class BrowserFragment : WebFragment(), LifecycleObserver, View.OnClickListener,

fragmentManager
.beginTransaction()
.add(R.id.container, crashReporterFragment, CrashReporterFragment.FRAGMENT_TAG)
.addToBackStack(null)
.add(R.id.crash_container, crashReporterFragment, CrashReporterFragment.FRAGMENT_TAG)
.commit()

crash_container.visibility = View.VISIBLE
tabs.hide()
erase.hide()
}

internal fun showAddToHomescreenDialog(url: String, title: String) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class GeckoWebViewProvider : IWebViewProvider {
SharedPreferences.OnSharedPreferenceChangeListener {
private var callback: IWebView.Callback? = null
private var findListener: IFindListener? = null
private var currentUrl: String = "about:blank"
private var currentUrl: String = ABOUT_BLANK
private var canGoBack: Boolean = false
private var canGoForward: Boolean = false
private var isSecure: Boolean = false
Expand Down Expand Up @@ -373,12 +373,12 @@ class GeckoWebViewProvider : IWebViewProvider {
}

override fun onCrash(session: GeckoSession) {
Log.i(TAG, "Crashed, opening new session")
geckoSession.close()
geckoSession = createGeckoSession()
applySettingsAndSetDelegates()
geckoSession.open(geckoRuntime!!)
setSession(geckoSession)
currentUrl = ABOUT_BLANK
geckoSession.loadUri(currentUrl)
}

Expand Down
7 changes: 7 additions & 0 deletions app/src/main/res/layout/fragment_browser.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@

</android.support.v4.widget.SwipeRefreshLayout>

<FrameLayout
android:id="@+id/crash_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/photonRed50"
android:visibility="gone"/>

<include
layout="@layout/browser_display_toolbar"/>

Expand Down
38 changes: 21 additions & 17 deletions app/src/main/res/layout/fragment_crash_reporter.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,65 +9,69 @@

<View
android:id="@+id/background"
android:layout_width="160dp"
android:layout_height="160dp"
android:layout_marginTop="16dp"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginTop="8dp"
android:background="@drawable/ic_error_session_crashed"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintDimensionRatio="1:1"
app:layout_constraintWidth_percent="0.6"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<EditText
<TextView
android:id="@+id/headline"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:lineHeight="28dp"
android:layout_height="54dp"
android:singleLine="false"
android:text="@string/tab_crash_report_headline"
android:textAlignment="center"
android:textColor="@android:color/black"
android:textSize="20dp"
android:textSize="20sp"
android:layout_marginTop="12dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/background" />

<EditText
<TextView
android:id="@+id/description"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:lineHeight="22dp"
android:singleLine="false"
android:text="@string/tab_crash_report_description"
android:textColor="@android:color/black"
android:textSize="15dp"
android:textSize="15sp"
android:layout_marginTop="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/headline" />

<CheckBox
android:id="@+id/sendCrashCheckbox"
android:layout_marginEnd="26dp"
android:layout_marginStart="26dp"
android:layout_width="0dp"
android:layout_height="32dp"
android:layout_marginBottom="24dp"
android:layout_width="match_parent"
android:layout_height="34dp"
android:buttonTint="@color/colorCrashAccent"
android:checked="true"
android:text="@string/crash_report_send_crash_label"
android:textColor="@android:color/black"
tools:text="@string/crash_report_send_crash_label"
app:layout_constraintBottom_toTopOf="@id/closeTabButton"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toTopOf="@id/closeTabButton" />
app:layout_constraintWidth_percent="0.8"
tools:text="@string/crash_report_send_crash_label" />

<Button
android:id="@+id/closeTabButton"
android:layout_marginEnd="26dp"
android:layout_marginStart="26dp"
android:layout_width="match_parent"
android:layout_width="0dp"
android:layout_height="wrap_content"
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"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toBottomOf="parent" />
Expand Down

0 comments on commit e49774a

Please sign in to comment.