diff options
author | Harsh Shandilya <me@msfjarvis.dev> | 2021-04-18 03:52:41 +0530 |
---|---|---|
committer | Harsh Shandilya <me@msfjarvis.dev> | 2021-04-18 04:03:17 +0530 |
commit | a0fdd6ddc3a40ed856e1b647b644d037eb30152a (patch) | |
tree | 3ff2c6760a25f3e3624b3059b4ea22307507312f /app/src | |
parent | 77abe7ee2c906747d80813fef8d786b3e8d94c0a (diff) |
app: configure Hilt and desugaring
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
Diffstat (limited to 'app/src')
4 files changed, 38 insertions, 1 deletions
diff --git a/app/src/main/java/dev/msfjarvis/aps/Application.kt b/app/src/main/java/dev/msfjarvis/aps/Application.kt index d7d4c7a7..013b6b21 100644 --- a/app/src/main/java/dev/msfjarvis/aps/Application.kt +++ b/app/src/main/java/dev/msfjarvis/aps/Application.kt @@ -12,6 +12,7 @@ import androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_NO import androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_YES import com.github.ajalt.timberkt.Timber.DebugTree import com.github.ajalt.timberkt.Timber.plant +import dagger.hilt.android.HiltAndroidApp import dev.msfjarvis.aps.util.extensions.getString import dev.msfjarvis.aps.util.extensions.sharedPrefs import dev.msfjarvis.aps.util.git.sshj.setUpBouncyCastleForSshj @@ -20,6 +21,7 @@ import dev.msfjarvis.aps.util.settings.PreferenceKeys import dev.msfjarvis.aps.util.settings.runMigrations @Suppress("Unused") +@HiltAndroidApp class Application : android.app.Application(), SharedPreferences.OnSharedPreferenceChangeListener { private val prefs by lazy { sharedPrefs } diff --git a/app/src/main/java/dev/msfjarvis/aps/injection/password/PasswordModule.kt b/app/src/main/java/dev/msfjarvis/aps/injection/password/PasswordModule.kt new file mode 100644 index 00000000..dd795d14 --- /dev/null +++ b/app/src/main/java/dev/msfjarvis/aps/injection/password/PasswordModule.kt @@ -0,0 +1,15 @@ +/* + * Copyright © 2014-2021 The Android Password Store Authors. All Rights Reserved. + * SPDX-License-Identifier: GPL-3.0-only + */ + +package dev.msfjarvis.aps.injection.password + +import dagger.assisted.AssistedFactory +import dev.msfjarvis.aps.data.passfile.PasswordEntry +import kotlinx.coroutines.CoroutineScope + +@AssistedFactory +interface PasswordEntryFactory { + fun create(scope: CoroutineScope, bytes: ByteArray): PasswordEntry +} diff --git a/app/src/main/java/dev/msfjarvis/aps/injection/totp/TotpModule.kt b/app/src/main/java/dev/msfjarvis/aps/injection/totp/TotpModule.kt new file mode 100644 index 00000000..e02a3b86 --- /dev/null +++ b/app/src/main/java/dev/msfjarvis/aps/injection/totp/TotpModule.kt @@ -0,0 +1,19 @@ +/* + * Copyright © 2014-2021 The Android Password Store Authors. All Rights Reserved. + * SPDX-License-Identifier: GPL-3.0-only + */ + +package dev.msfjarvis.aps.injection.totp + +import dagger.Binds +import dagger.Module +import dagger.hilt.InstallIn +import dagger.hilt.android.components.ActivityComponent +import dev.msfjarvis.aps.util.totp.TotpFinder +import dev.msfjarvis.aps.util.totp.UriTotpFinder + +@Module +@InstallIn(ActivityComponent::class) +interface TotpModule { + @Binds abstract fun bindTotpFinder(totpFinder: UriTotpFinder): TotpFinder +} diff --git a/app/src/main/java/dev/msfjarvis/aps/util/totp/UriTotpFinder.kt b/app/src/main/java/dev/msfjarvis/aps/util/totp/UriTotpFinder.kt index fa3ff28a..2e954804 100644 --- a/app/src/main/java/dev/msfjarvis/aps/util/totp/UriTotpFinder.kt +++ b/app/src/main/java/dev/msfjarvis/aps/util/totp/UriTotpFinder.kt @@ -6,9 +6,10 @@ package dev.msfjarvis.aps.util.totp import android.net.Uri +import javax.inject.Inject /** [Uri] backed TOTP URL parser. */ -class UriTotpFinder : TotpFinder { +class UriTotpFinder @Inject constructor() : TotpFinder { override fun findSecret(content: String): String? { content.split("\n".toRegex()).forEach { line -> |