summaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main')
-rw-r--r--app/src/main/java/dev/msfjarvis/aps/injection/crypto/CryptoHandlerModule.kt15
-rw-r--r--app/src/main/java/dev/msfjarvis/aps/injection/crypto/KeyManagerModule.kt5
-rw-r--r--app/src/main/java/dev/msfjarvis/aps/ui/pgp/PGPKeyImportActivity.kt4
3 files changed, 6 insertions, 18 deletions
diff --git a/app/src/main/java/dev/msfjarvis/aps/injection/crypto/CryptoHandlerModule.kt b/app/src/main/java/dev/msfjarvis/aps/injection/crypto/CryptoHandlerModule.kt
index 63a860d1..ef6a11ce 100644
--- a/app/src/main/java/dev/msfjarvis/aps/injection/crypto/CryptoHandlerModule.kt
+++ b/app/src/main/java/dev/msfjarvis/aps/injection/crypto/CryptoHandlerModule.kt
@@ -9,23 +9,10 @@ import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
-import dagger.multibindings.IntoSet
-import dev.msfjarvis.aps.crypto.CryptoHandler
import dev.msfjarvis.aps.crypto.PGPainlessCryptoHandler
-/**
- * This module adds all [CryptoHandler] implementations into a Set which makes it easier to build
- * generic UIs which are not tied to a specific implementation because of injection.
- */
@Module
@InstallIn(SingletonComponent::class)
object CryptoHandlerModule {
- @Provides
- @IntoSet
- fun providePgpCryptoHandler(): CryptoHandler {
- return PGPainlessCryptoHandler()
- }
+ @Provides fun providePgpCryptoHandler() = PGPainlessCryptoHandler()
}
-
-/** Typealias for a [Set] of [CryptoHandler] instances injected by Dagger. */
-typealias CryptoSet = Set<@JvmSuppressWildcards CryptoHandler>
diff --git a/app/src/main/java/dev/msfjarvis/aps/injection/crypto/KeyManagerModule.kt b/app/src/main/java/dev/msfjarvis/aps/injection/crypto/KeyManagerModule.kt
index 0bc1c43d..a1119a1c 100644
--- a/app/src/main/java/dev/msfjarvis/aps/injection/crypto/KeyManagerModule.kt
+++ b/app/src/main/java/dev/msfjarvis/aps/injection/crypto/KeyManagerModule.kt
@@ -12,8 +12,8 @@ import dagger.hilt.InstallIn
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent
import dev.msfjarvis.aps.crypto.PGPKeyManager
+import dev.msfjarvis.aps.util.coroutines.DispatcherProvider
import javax.inject.Qualifier
-import kotlinx.coroutines.Dispatchers
@Module
@InstallIn(SingletonComponent::class)
@@ -21,10 +21,11 @@ object KeyManagerModule {
@Provides
fun providePGPKeyManager(
@PGPKeyDir keyDir: String,
+ dispatcherProvider: DispatcherProvider,
): PGPKeyManager {
return PGPKeyManager(
keyDir,
- Dispatchers.IO,
+ dispatcherProvider.io(),
)
}
diff --git a/app/src/main/java/dev/msfjarvis/aps/ui/pgp/PGPKeyImportActivity.kt b/app/src/main/java/dev/msfjarvis/aps/ui/pgp/PGPKeyImportActivity.kt
index 3cd6930c..b97de5e0 100644
--- a/app/src/main/java/dev/msfjarvis/aps/ui/pgp/PGPKeyImportActivity.kt
+++ b/app/src/main/java/dev/msfjarvis/aps/ui/pgp/PGPKeyImportActivity.kt
@@ -14,8 +14,8 @@ import com.github.michaelbull.result.runCatching
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import dagger.hilt.android.AndroidEntryPoint
import dev.msfjarvis.aps.R
-import dev.msfjarvis.aps.crypto.Key
import dev.msfjarvis.aps.crypto.KeyUtils.tryGetId
+import dev.msfjarvis.aps.crypto.PGPKey
import dev.msfjarvis.aps.crypto.PGPKeyManager
import javax.inject.Inject
import kotlinx.coroutines.runBlocking
@@ -35,7 +35,7 @@ class PGPKeyImportActivity : AppCompatActivity() {
contentResolver.openInputStream(uri)
?: throw IllegalStateException("Failed to open selected file")
val bytes = keyInputStream.readBytes()
- val (key, error) = runBlocking { keyManager.addKey(Key(bytes)) }
+ val (key, error) = runBlocking { keyManager.addKey(PGPKey(bytes)) }
if (error != null) throw error
key
}