Skip to content

Commit

Permalink
Crashes reporting implemented (ACRA)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdrlzy committed Jul 30, 2023
1 parent 02c20c2 commit 1d9218e
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ on: [push]
jobs:
build:
runs-on: ubuntu-latest
environment: Development
env:
ACRA_LOGIN: ${{ secrets.ACRARIUM_BASIC_AUTH_LOGIN }}
ACRA_PASS: ${{ secrets.ACRARIUM_BASIC_AUTH_PASSWORD }}
ACRA_URI: ${{ secrets.ACRARIUM_URI }}
steps:
- uses: actions/checkout@v3

Expand Down
9 changes: 9 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ android {
versionCode 1
versionName "1.0"
setProperty("archivesBaseName", "ark-shelf")
def login = System.getenv("ACRA_LOGIN") ?: ""
def password = System.getenv("ACRA_PASS") ?: ""
def uri = System.getenv("ACRA_URI") ?: ""
buildConfigField "String", "ACRA_LOGIN", "\"$login\""
buildConfigField "String", "ACRA_PASS", "\"$password\""
buildConfigField "String", "ACRA_URI", "\"$uri\""

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down Expand Up @@ -90,6 +96,9 @@ dependencies {
implementation "org.orbit-mvi:orbit-viewmodel:4.3.2"
implementation "com.ericktijerou.koleton:koleton:1.0.0-beta01"

implementation "ch.acra:acra-http:5.9.3"
implementation "ch.acra:acra-dialog:5.9.3"

implementation 'com.github.ARK-Builders:ark-filepicker:c6d66141c1'

testImplementation 'junit:junit:4.+'
Expand Down
26 changes: 26 additions & 0 deletions app/src/main/java/space/taran/arkshelf/presentation/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,16 @@ import android.app.Application
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import org.acra.config.dialog
import org.acra.config.httpSender
import org.acra.data.StringFormat
import org.acra.ktx.initAcra
import org.acra.sender.HttpSender
import space.taran.arkfilepicker.folders.FoldersRepo
import space.taran.arklib.initArkLib
import space.taran.arklib.initRustLogger
import space.taran.arkshelf.BuildConfig
import space.taran.arkshelf.R
import space.taran.arkshelf.di.DIManager
import timber.log.Timber

Expand All @@ -25,9 +32,28 @@ class App : Application() {
initArkLib()
initRustLogger()
Timber.plant(Timber.DebugTree())
initAcra()

instance = this

DIManager.init(this)
}

private fun initAcra() = CoroutineScope(Dispatchers.IO).launch {
initAcra {
buildConfigClass = BuildConfig::class.java
reportFormat = StringFormat.JSON
dialog {
text = getString(R.string.crash_dialog_description)
title = getString(R.string.crash_dialog_title)
commentPrompt = getString(R.string.crash_dialog_comment)
}
httpSender {
uri = BuildConfig.ACRA_URI
basicAuthLogin = BuildConfig.ACRA_LOGIN
basicAuthPassword = BuildConfig.ACRA_PASS
httpMethod = HttpSender.Method.POST
}
}
}
}
3 changes: 3 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
<string name="pick">Pick</string>
<string name="pick_link_folder">Pick link folder</string>
<string name="link_copied">Link copied</string>
<string name="crash_dialog_description">Sorry, the application crashed. Please send a report to the developers.</string>
<string name="crash_dialog_title">Crash</string>
<string name="crash_dialog_comment">You can add a comment here:</string>
<plurals name="items">
<item quantity="one">%d item</item>
<item quantity="other">%d items</item>
Expand Down

0 comments on commit 1d9218e

Please sign in to comment.