-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* misc: Renamed `app` to `sample` * misc: Renamed crashhandler to library * fix: Missing required view
- Loading branch information
1 parent
7dfb454
commit ef361a4
Showing
33 changed files
with
233 additions
and
21 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 8 additions & 1 deletion
9
...com/dzeio/crashhandlertest/Application.kt → ...com/dzeio/crashhandlertest/Application.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,21 @@ | ||
package com.dzeio.crashhandlertest | ||
|
||
import com.dzeio.crashhandler.CrashHandler | ||
import com.dzeio.crashhandlertest.ui.ErrorActivity | ||
|
||
class Application : android.app.Application() { | ||
override fun onCreate() { | ||
super.onCreate() | ||
|
||
CrashHandler.Builder() | ||
.withActivity(ErrorActivity::class.java) | ||
.withContext(this) | ||
.withPrefix("Pouet :D") | ||
.withSuffix("WHYYYYY") | ||
.build().setup(this) | ||
.build().setup() | ||
} | ||
|
||
companion object { | ||
const val TAG = "CrashHandlerTest" | ||
} | ||
} |
86 changes: 86 additions & 0 deletions
86
sample/src/main/java/com/dzeio/crashhandlertest/ui/ErrorActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
package com.dzeio.crashhandlertest.ui | ||
|
||
import android.content.ActivityNotFoundException | ||
import android.content.Intent | ||
import android.net.Uri | ||
import android.os.Build | ||
import android.os.Bundle | ||
import android.os.Process | ||
import android.widget.Toast | ||
import androidx.appcompat.app.AppCompatActivity | ||
import androidx.core.view.WindowCompat | ||
import com.dzeio.crashhandlertest.Application | ||
import com.dzeio.crashhandlertest.databinding.ActivityErrorBinding | ||
import kotlin.system.exitProcess | ||
|
||
class ErrorActivity : AppCompatActivity() { | ||
|
||
companion object { | ||
const val TAG = "${Application.TAG}/ErrorActivity" | ||
} | ||
|
||
private lateinit var binding: ActivityErrorBinding | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
WindowCompat.setDecorFitsSystemWindows(window, false) | ||
super.onCreate(savedInstanceState) | ||
|
||
binding = ActivityErrorBinding.inflate(layoutInflater) | ||
setContentView(binding.root) | ||
|
||
val data = intent.getStringExtra("error") | ||
|
||
// Get Application datas | ||
val deviceToReport = if (Build.DEVICE.contains(Build.MANUFACTURER)) Build.DEVICE else "${Build.MANUFACTURER} ${Build.DEVICE}" | ||
|
||
val reportText = """ | ||
Crash Report (Thread: ${intent?.getLongExtra("threadId", -1) ?: "unknown"}) | ||
on $deviceToReport (${Build.MODEL}) running Android ${Build.VERSION.RELEASE} (${Build.VERSION.SDK_INT}) | ||
backtrace: | ||
""".trimIndent() + data | ||
|
||
// put it in the textView | ||
binding.errorText.text = reportText | ||
|
||
// Handle the Quit button | ||
binding.errorQuit.setOnClickListener { | ||
Process.killProcess(Process.myPid()) | ||
exitProcess(10) | ||
} | ||
|
||
// Handle the Email Button | ||
binding.errorSubmitEmail.setOnClickListener { | ||
|
||
// Create Intent | ||
val intent = Intent(Intent.ACTION_SEND) | ||
intent.data = Uri.parse("mailto:") | ||
intent.type = "text/plain" | ||
intent.putExtra(Intent.EXTRA_EMAIL, arrayOf("report.openhealth@dzeio.com")) | ||
intent.putExtra(Intent.EXTRA_SUBJECT, "Error report for application crash") | ||
intent.putExtra(Intent.EXTRA_TEXT, "Send Report Email\n$reportText") | ||
|
||
try { | ||
startActivity(Intent.createChooser(intent, "Send Report Email...")) | ||
} catch (e: ActivityNotFoundException) { | ||
Toast.makeText(this, "Not Email client found :(", Toast.LENGTH_LONG).show() | ||
} | ||
} | ||
|
||
// Handle the GitHub Button | ||
binding.errorSubmitGithub.setOnClickListener { | ||
|
||
// Build URL | ||
val url = "https://github.com/dzeiocom/OpenHealth/issues/new?title=Application Error&body=$reportText" | ||
|
||
try { | ||
startActivity( | ||
Intent(Intent.ACTION_VIEW, Uri.parse(url)) | ||
) | ||
} catch (e: ActivityNotFoundException) { | ||
Toast.makeText(this, "No Web Browser found :(", Toast.LENGTH_LONG).show() | ||
} | ||
} | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<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:fitsSystemWindows="true" | ||
android:id="@+id/linearLayout2" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent"> | ||
|
||
<TextView | ||
android:id="@+id/textView3" | ||
style="?textAppearanceHeadline5" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:text="blablabla" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" /> | ||
|
||
<TextView | ||
android:id="@+id/textView4" | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="16dp" | ||
android:text="blablabla2" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toBottomOf="@+id/textView3" /> | ||
|
||
<ScrollView | ||
android:id="@+id/scrollView2" | ||
android:layout_width="0dp" | ||
android:layout_height="0dp" | ||
android:layout_marginTop="16dp" | ||
android:layout_marginBottom="16dp" | ||
app:layout_constraintBottom_toTopOf="@+id/error_submit_email" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toBottomOf="@+id/textView4"> | ||
|
||
<TextView | ||
android:id="@+id/error_text" | ||
android:layout_width="match_parent" | ||
style="?textAppearanceCaption" | ||
android:layout_height="wrap_content" /> | ||
|
||
</ScrollView> | ||
|
||
|
||
|
||
<Button | ||
android:id="@+id/error_submit_github" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:text="Github" | ||
android:layout_marginStart="16dp" | ||
app:layout_constraintBaseline_toBaselineOf="@+id/error_submit_email" | ||
app:layout_constraintStart_toStartOf="parent" /> | ||
|
||
<Button | ||
android:id="@+id/error_submit_email" | ||
android:layout_marginBottom="16dp" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginEnd="16dp" | ||
android:text="E-Mail" | ||
app:layout_constraintBottom_toTopOf="@+id/error_quit" | ||
app:layout_constraintEnd_toEndOf="parent" /> | ||
|
||
|
||
<Button | ||
android:id="@+id/error_quit" | ||
android:layout_width="wrap_content" | ||
android:layout_height="0dp" | ||
android:text="Quit" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" /> | ||
|
||
</androidx.constraintlayout.widget.ConstraintLayout> |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters