Fix ErrorActivity report bug

This commit is contained in:
PhilKes 2025-01-31 17:03:48 +01:00
parent ceaf4cc3a3
commit c749ff1018
4 changed files with 25 additions and 47 deletions

View file

@ -22,7 +22,7 @@ body:
- type: input
id: android-version
attributes:
label: Android Version
label: Android Version (API Level)
description: What Android version are you using?
- type: textarea
id: logs

View file

@ -261,7 +261,7 @@ fun Context.createReportBugIntent(
return Intent(
Intent.ACTION_VIEW,
Uri.parse(
"https://github.com/PhilKes/NotallyX/issues/new?labels=bug&projects=&template=bug_report.yml${title?.let { "&title=$it" }}${body?.let { "&what-happened=$it" }}&version=${BuildConfig.VERSION_NAME}&android-version=${Build.VERSION.SDK_INT}${stackTrace?.let { "&logs=$stackTrace" } ?: ""}"
"https://github.com/PhilKes/NotallyX/issues/new?labels=bug&projects=&template=bug_report.yml${title?.let { "&title=$it" } ?: ""}${body?.let { "&what-happened=$it" } ?: ""}&version=${BuildConfig.VERSION_NAME}&android-version=${Build.VERSION.SDK_INT}${stackTrace?.let { "&logs=$stackTrace" } ?: ""}"
.take(2000)
),
)

View file

@ -1,57 +1,34 @@
package com.philkes.notallyx.utils
import android.os.Bundle
import android.widget.Button
import android.widget.ImageView
import androidx.appcompat.app.AppCompatActivity
import cat.ereza.customactivityoncrash.CustomActivityOnCrash
import com.philkes.notallyx.R
import com.philkes.notallyx.presentation.dp
import com.philkes.notallyx.databinding.ActivityErrorBinding
/**
* Activity used when the app is about to crash. Implicitly used by cat.ereza:customactivityoncrash.
* Activity used when the app is about to crash. Implicitly used by
* `cat.ereza:customactivityoncrash`.
*/
class ErrorActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_error)
findViewById<ImageView>(
cat.ereza.customactivityoncrash.R.id.customactivityoncrash_error_activity_image
)
.apply {
minimumWidth = 100.dp(this@ErrorActivity)
minimumHeight = 100.dp(this@ErrorActivity)
setImageResource(R.drawable.error)
}
findViewById<Button>(
cat.ereza.customactivityoncrash.R.id
.customactivityoncrash_error_activity_restart_button
)
.apply {
setText(
cat.ereza.customactivityoncrash.R.string
.customactivityoncrash_error_activity_restart_app
val binding = ActivityErrorBinding.inflate(layoutInflater)
setContentView(binding.root)
binding.apply {
RestartButton.setOnClickListener {
CustomActivityOnCrash.restartApplication(
this@ErrorActivity,
CustomActivityOnCrash.getConfigFromIntent(intent)!!,
)
setOnClickListener {
CustomActivityOnCrash.restartApplication(
this@ErrorActivity,
CustomActivityOnCrash.getConfigFromIntent(intent)!!,
)
}
}
val stackTrace = CustomActivityOnCrash.getStackTraceFromIntent(intent)
stackTrace?.let { application.log(TAG, stackTrace = it) }
findViewById<Button>(
cat.ereza.customactivityoncrash.R.id
.customactivityoncrash_error_activity_more_info_button
)
.apply {
setText(R.string.report_crash)
setOnClickListener {
reportBug(CustomActivityOnCrash.getStackTraceFromIntent(intent))
}
val stackTrace = CustomActivityOnCrash.getStackTraceFromIntent(intent)
stackTrace?.let { application.log(TAG, stackTrace = it) }
ReportButton.setOnClickListener {
reportBug(CustomActivityOnCrash.getStackTraceFromIntent(intent))
}
}
}
companion object {

View file

@ -22,11 +22,12 @@
android:paddingTop="@dimen/customactivityoncrash_activity_vertical_margin">
<ImageView
android:id="@+id/customactivityoncrash_error_activity_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@null"
android:src="@drawable/customactivityoncrash_error_image" />
android:minWidth="100dp"
android:minHeight="100dp"
android:src="@drawable/error" />
<TextView
android:layout_width="wrap_content"
@ -38,19 +39,19 @@
android:textStyle="bold" />
<Button
android:id="@+id/customactivityoncrash_error_activity_restart_button"
android:id="@+id/RestartButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/customactivityoncrash_activity_vertical_margin"
android:text="@string/customactivityoncrash_error_activity_close_app" />
android:text="@string/customactivityoncrash_error_activity_restart_app" />
<com.google.android.material.button.MaterialButton
android:id="@+id/customactivityoncrash_error_activity_more_info_button"
android:id="@+id/ReportButton"
style="@style/Widget.Material3.Button.OutlinedButton"
app:strokeColor="?attr/colorPrimary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/customactivityoncrash_error_activity_error_details"
android:text="@string/report_crash"
android:textColor="?colorPrimary" />
</LinearLayout>
</ScrollView>