mirror of
https://github.com/dzeiocom/OpenHealth.git
synced 2025-06-13 09:29:19 +00:00
feat: Support for minified/optimized builds
This commit is contained in:
@ -16,7 +16,6 @@ class Application : Application() {
|
||||
}
|
||||
|
||||
override fun onCreate() {
|
||||
|
||||
val prefs = PreferenceManager.getDefaultSharedPreferences(this)
|
||||
|
||||
// setup the CrashHandler
|
||||
@ -25,7 +24,16 @@ class Application : Application() {
|
||||
.withPrefs(prefs)
|
||||
.witheErrorReporterCrashKey(R.string.error_reporter_crash)
|
||||
.withPrefsKey(Settings.CRASH_LAST_TIME)
|
||||
.withPrefix("${BuildConfig.APPLICATION_ID} v${BuildConfig.VERSION_NAME} (${BuildConfig.VERSION_CODE})")
|
||||
.withPrefix(
|
||||
"""
|
||||
${BuildConfig.APPLICATION_ID} v${BuildConfig.VERSION_NAME} (${BuildConfig.VERSION_CODE})
|
||||
|
||||
Build informations:
|
||||
Commit: ${BuildConfig.COMMIT}
|
||||
Branch: ${BuildConfig.BRANCH}
|
||||
Tag: ${BuildConfig.TAG}
|
||||
""".trimIndent()
|
||||
)
|
||||
.build()
|
||||
.setup(this)
|
||||
|
||||
|
@ -3,13 +3,11 @@ package com.dzeio.openhealth.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.view.LayoutInflater
|
||||
import android.widget.Toast
|
||||
import com.dzeio.openhealth.Application
|
||||
import com.dzeio.openhealth.BuildConfig
|
||||
import com.dzeio.openhealth.core.BaseActivity
|
||||
import com.dzeio.openhealth.databinding.ActivityErrorBinding
|
||||
import kotlin.system.exitProcess
|
||||
@ -28,20 +26,8 @@ class ErrorActivity : BaseActivity<ActivityErrorBinding>() {
|
||||
|
||||
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"})
|
||||
${BuildConfig.APPLICATION_ID} v${BuildConfig.VERSION_NAME} (${BuildConfig.VERSION_CODE})
|
||||
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
|
||||
binding.errorText.text = data
|
||||
|
||||
// Handle the Quit button
|
||||
binding.errorQuit.setOnClickListener {
|
||||
@ -51,14 +37,15 @@ class ErrorActivity : BaseActivity<ActivityErrorBinding>() {
|
||||
|
||||
// Handle the Email Button
|
||||
binding.errorSubmitEmail.setOnClickListener {
|
||||
|
||||
// Create Intent
|
||||
val intent = Intent(Intent.ACTION_SEND)
|
||||
intent.data = Uri.parse("mailto:")
|
||||
intent.type = "text/plain"
|
||||
val intent = Intent(Intent.ACTION_VIEW)
|
||||
intent.setDataAndType(
|
||||
Uri.parse("mailto:"),
|
||||
"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")
|
||||
intent.putExtra(Intent.EXTRA_TEXT, "Send Report Email\n$data")
|
||||
|
||||
try {
|
||||
startActivity(Intent.createChooser(intent, "Send Report Email..."))
|
||||
@ -69,14 +56,17 @@ class ErrorActivity : BaseActivity<ActivityErrorBinding>() {
|
||||
|
||||
// Handle the GitHub Button
|
||||
binding.errorSubmitGithub.setOnClickListener {
|
||||
|
||||
// Build URL
|
||||
val url = "https://github.com/dzeiocom/OpenHealth/issues/new?title=Application Error&body=$reportText"
|
||||
val url =
|
||||
"https://github.com/dzeiocom/OpenHealth/issues/new?" +
|
||||
"title=Application Error&" +
|
||||
"body=${data?.replace("\n", "\\n")}"
|
||||
|
||||
try {
|
||||
startActivity(
|
||||
Intent(Intent.ACTION_VIEW, Uri.parse(url))
|
||||
)
|
||||
val intent = Intent(Intent.ACTION_VIEW).apply {
|
||||
setData(Uri.parse(url))
|
||||
}
|
||||
startActivity(intent)
|
||||
} catch (e: ActivityNotFoundException) {
|
||||
Toast.makeText(this, "No Web Browser found :(", Toast.LENGTH_LONG).show()
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ class FoodDialogViewModel @Inject internal constructor(
|
||||
val res = foodRepository.getById(productId)
|
||||
val food = res.first()
|
||||
if (food != null) {
|
||||
items.postValue(food)
|
||||
items.postValue(food!!)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
<?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:id="@+id/linearLayout2"
|
||||
android:padding="16dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
@ -11,6 +11,7 @@
|
||||
android:id="@+id/textView3"
|
||||
style="?textAppearanceHeadline5"
|
||||
android:layout_width="wrap_content"
|
||||
android:textAlignment="center"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/error_app_crash"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
@ -20,6 +21,7 @@
|
||||
<TextView
|
||||
android:id="@+id/textView4"
|
||||
android:layout_width="0dp"
|
||||
android:textAlignment="center"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:text="@string/error_app_report"
|
||||
@ -42,6 +44,7 @@
|
||||
android:id="@+id/error_text"
|
||||
android:layout_width="match_parent"
|
||||
style="?textAppearanceCaption"
|
||||
android:textIsSelectable="true"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
</ScrollView>
|
||||
@ -53,7 +56,6 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/report_github"
|
||||
android:layout_marginStart="16dp"
|
||||
app:layout_constraintBaseline_toBaselineOf="@+id/error_submit_email"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
@ -62,7 +64,6 @@
|
||||
android:layout_marginBottom="16dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:text="@string/report_email"
|
||||
app:layout_constraintBottom_toTopOf="@+id/error_quit"
|
||||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
|
Reference in New Issue
Block a user