summaryrefslogtreecommitdiff
path: root/app/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java')
-rw-r--r--app/src/main/java/dev/msfjarvis/aps/Application.kt2
-rw-r--r--app/src/main/java/dev/msfjarvis/aps/injection/password/PasswordModule.kt15
-rw-r--r--app/src/main/java/dev/msfjarvis/aps/injection/totp/TotpModule.kt19
-rw-r--r--app/src/main/java/dev/msfjarvis/aps/util/totp/UriTotpFinder.kt3
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 ->