Skip to content

Commit 30dc8df

Browse files
authored
Merge pull request #15 from shivam21/master
Add ability to restart the app from the error screen #14
2 parents e020111 + 02807da commit 30dc8df

File tree

4 files changed

+37
-3
lines changed

4 files changed

+37
-3
lines changed

what-the-stack/src/main/java/com/haroldadmin/whatthestack/WhatTheStackActivity.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,15 @@ class WhatTheStackActivity : AppCompatActivity() {
8080
startActivity(shareIntent)
8181
}
8282
}
83+
84+
findViewById<MaterialButton>(R.id.launchApplication).apply {
85+
setOnClickListener {
86+
context.packageManager.getLaunchIntentForPackage(applicationContext.packageName)?.let {
87+
it.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
88+
startActivity(it)
89+
}
90+
}
91+
}
8392
}
8493

8594
private inline fun snackbar(messageProvider: () -> Int) {
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="24dp"
3+
android:height="24dp"
4+
android:viewportWidth="24"
5+
android:viewportHeight="24"
6+
android:tint="?attr/colorControlNormal">
7+
<path
8+
android:fillColor="@android:color/white"
9+
android:pathData="M17.65,6.35C16.2,4.9 14.21,4 12,4c-4.42,0 -7.99,3.58 -7.99,8s3.57,8 7.99,8c3.73,0 6.84,-2.55 7.73,-6h-2.08c-0.82,2.33 -3.04,4 -5.65,4 -3.31,0 -6,-2.69 -6,-6s2.69,-6 6,-6c1.66,0 3.14,0.69 4.22,1.78L13,11h7V4l-2.35,2.35z"/>
10+
</vector>

what-the-stack/src/main/res/layout/activity_what_the_stack.xml

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
3-
xmlns:tools="http://schemas.android.com/tools"
43
xmlns:app="http://schemas.android.com/apk/res-auto"
4+
xmlns:tools="http://schemas.android.com/tools"
55
android:id="@+id/nestedScrollRoot"
66
android:layout_width="match_parent"
77
android:layout_height="match_parent"
@@ -91,11 +91,25 @@
9191
android:layout_marginStart="16dp"
9292
android:layout_marginTop="2dp"
9393
android:layout_marginEnd="16dp"
94-
android:layout_marginBottom="8dp"
94+
android:layout_marginBottom="2dp"
9595
android:text="@string/share_stacktrace"
9696
android:textColor="?attr/colorOnSurface"
9797
app:icon="@drawable/ic_outline_share_24"
98-
app:iconTint="?attr/colorSecondary"/>
98+
app:iconTint="?attr/colorSecondary" />
99+
100+
<com.google.android.material.button.MaterialButton
101+
android:id="@+id/launchApplication"
102+
style="@style/Widget.MaterialComponents.Button.OutlinedButton.Icon"
103+
android:layout_width="match_parent"
104+
android:layout_height="wrap_content"
105+
android:layout_marginStart="16dp"
106+
android:layout_marginTop="2dp"
107+
android:layout_marginEnd="16dp"
108+
android:layout_marginBottom="8dp"
109+
android:text="@string/restart_application"
110+
android:textColor="?attr/colorOnSurface"
111+
app:icon="@drawable/ic_baseline_refresh_24"
112+
app:iconTint="?attr/colorSecondary" />
99113

100114
<TextView
101115
android:id="@+id/stacktraceHeader"

what-the-stack/src/main/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
<string name="exception_message">Message: %1$s</string>
3333
<string name="copy_stacktrace">Copy stacktrace</string>
3434
<string name="share_stacktrace">Share stacktrace</string>
35+
<string name="restart_application">Restart Application</string>
3536
<string name="relaunch_app">Relaunch App</string>
3637
<string name="copied_message">Stacktrace copied!</string>
3738
</resources>

0 commit comments

Comments
 (0)