Refactor bug report template + send feedback actions

This commit is contained in:
PhilKes 2024-10-23 17:44:03 +02:00 committed by Phil
parent a0e09aeef1
commit db9bc5df98
5 changed files with 87 additions and 46 deletions

View file

@ -1,31 +0,0 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: bug
assignees: ''
---
**Describe the bug**
A clear and concise description of what the bug is.
**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Smartphone (please complete the following information):**
- Android Version: [e.g. 13]
- App Version [e.g. 6.0]
**Additional context**
Add any other context about the problem here.

36
.github/ISSUE_TEMPLATE/bug_report.yml vendored Normal file
View file

@ -0,0 +1,36 @@
name: Bug Report
description: Create a report to help us improve
labels: ["bug"]
projects: []
body:
- type: textarea
id: what-happened
attributes:
label: What happened?
description: Also tell us, what did you expect to happen?
placeholder: Tell us what you see!
value: "A bug happened!"
validations:
required: true
- type: input
id: version
attributes:
label: App Version
description: What version of the app are you running?
validations:
required: true
- type: input
id: android-version
attributes:
label: Android Version
description: What Android version are you using?
- type: textarea
id: logs
attributes:
label: (Optional) Relevant log output
description: Please copy and paste any relevant log output. This will be automatically formatted into code, so no need for backticks.
render: shell
- type: markdown
attributes:
value: |
Thanks for taking the time to fill out this bug report!

View file

@ -44,6 +44,7 @@ import com.philkes.notallyx.presentation.view.misc.SortDirection
import com.philkes.notallyx.presentation.view.misc.TextSize
import com.philkes.notallyx.presentation.view.misc.Theme
import com.philkes.notallyx.presentation.viewmodel.BaseNoteModel
import com.philkes.notallyx.utils.Operations
import com.philkes.notallyx.utils.backup.BackupProgress
import com.philkes.notallyx.utils.backup.scheduleAutoBackup
import com.philkes.notallyx.utils.canAuthenticateWithBiometrics
@ -197,16 +198,42 @@ class SettingsFragment : Fragment() {
}
private fun sendFeedback() {
val intent =
Intent(
Intent.ACTION_VIEW,
Uri.parse("https://github.com/PhilKes/NotallyX/issues/new/choose"),
)
try {
startActivity(intent)
} catch (exception: ActivityNotFoundException) {
Toast.makeText(requireContext(), R.string.install_a_browser, Toast.LENGTH_LONG).show()
}
MaterialAlertDialogBuilder(requireContext())
val options =
arrayOf(getString(R.string.report_bug), getString(R.string.make_feature_request))
MaterialAlertDialogBuilder(requireContext())
.setTitle(R.string.send_feedback)
.setItems(options) { _, which ->
val intent =
when (which) {
0 -> {
val app = requireContext().applicationContext as Application
val logs = Operations.getLastExceptionLog(app)
Intent(
Intent.ACTION_VIEW,
Uri.parse(
"https://github.com/PhilKes/NotallyX/issues/new?labels=bug&projects=&template=bug_report.yml&logs=$logs"
.take(2000)
),
)
}
else ->
Intent(
Intent.ACTION_VIEW,
Uri.parse(
"https://github.com/PhilKes/NotallyX/issues/new?labels=enhancement&template=feature_request.md"
),
)
}
try {
startActivity(intent)
} catch (exception: ActivityNotFoundException) {
Toast.makeText(requireContext(), R.string.install_a_browser, Toast.LENGTH_LONG)
.show()
}
}
.setNegativeButton(R.string.cancel, null)
.show()
}
private fun displayLibraries() {

View file

@ -24,16 +24,17 @@ import java.io.File
import java.io.FileOutputStream
import java.io.OutputStreamWriter
import java.io.PrintWriter
import java.net.URLEncoder
import java.nio.charset.StandardCharsets
import java.text.DateFormat
object Operations {
const val extraCharSequence = "com.philkes.notallyx.extra.charSequence"
fun getLog(app: Application): File {
val folder = File(app.filesDir, "logs")
folder.mkdir()
return File(folder, "Log.v1.txt")
fun getLastExceptionLog(app: Application): String {
val logContents = getLog(app).readText().substringAfterLast("[Start]")
return URLEncoder.encode(logContents, StandardCharsets.UTF_8.toString())
}
fun log(app: Application, throwable: Throwable) {
@ -117,6 +118,12 @@ object Operations {
}
}
private fun getLog(app: Application): File {
val folder = File(app.filesDir, "logs")
folder.mkdir()
return File(folder, "Log.v1.txt")
}
private fun getOutlinedDrawable(context: Context): MaterialShapeDrawable {
val model =
ShapeAppearanceModel.builder()

View file

@ -186,7 +186,9 @@
<string name="about">About</string>
<string name="libraries">Libraries</string>
<string name="rate">Rate this app</string>
<string name="send_feedback">Report an issue or make a feature request</string>
<string name="send_feedback">Send Feedback</string>
<string name="report_bug">Report an issue/bug</string>
<string name="make_feature_request">Make a feature request</string>
<string name="github" translatable="false">GitHub</string>