Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#27: Handle absence of the folder #29

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@ name: Build the app

on: [push]

env:
ACRA_LOGIN: ${{ secrets.ACRARIUM_BASIC_AUTH_LOGIN }}
ACRA_PASS: ${{ secrets.ACRARIUM_BASIC_AUTH_PASSWORD }}
ACRA_URI: ${{ secrets.ACRARIUM_URI }}

jobs:
build:
runs-on: ubuntu-latest
environment: Development
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
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,32 @@ package space.taran.arkshelf.data
import android.content.Context
import android.os.Environment
import space.taran.arkshelf.domain.UserPreferences
import timber.log.Timber
import java.nio.file.Path
import javax.inject.Inject
import kotlin.io.path.Path
import kotlin.io.path.exists

class UserPreferencesImpl @Inject constructor(
private val context: Context
) : UserPreferences {
private val prefs = context.getSharedPreferences("prefs", Context.MODE_PRIVATE)

override fun getLinkFolder() =
prefs.getString(SAVE_PATH_KEY, null)?.let { Path(it) }
prefs.getString(SAVE_PATH_KEY, null)
?.let {
val linkFolder = Path(it)
// Permission to access files may have been revoked
try {
if (linkFolder.exists())
linkFolder
else
null
} catch (e: Throwable) {
Timber.e(e)
null
}
}


override fun setLinkFolder(path: Path) = with(prefs.edit()) {
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() {
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