app: configure Hilt and desugaring

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
This commit is contained in:
Harsh Shandilya 2021-04-18 03:52:41 +05:30
parent 77abe7ee2c
commit a0fdd6ddc3
No known key found for this signature in database
GPG key ID: 366D7BBAD1031E80
5 changed files with 44 additions and 1 deletions

View file

@ -7,6 +7,8 @@ import com.android.build.gradle.internal.api.BaseVariantOutputImpl
plugins {
id("com.android.application")
kotlin("android")
kotlin("kapt")
id("dagger.hilt.android.plugin")
`versioning-plugin`
`aps-plugin`
`crowdin-plugin`
@ -22,6 +24,7 @@ android {
}
}
}
compileOptions { isCoreLibraryDesugaringEnabled = true }
defaultConfig {
applicationId = "dev.msfjarvis.aps"
@ -42,7 +45,9 @@ android {
}
dependencies {
kapt(libs.dagger.hilt.compiler)
compileOnly(libs.androidx.annotation)
coreLibraryDesugaring(libs.android.desugarJdkLibs)
implementation(projects.autofillParser)
implementation(projects.openpgpKtx)
implementation(libs.androidx.activityKtx)
@ -60,6 +65,7 @@ dependencies {
implementation(libs.androidx.recyclerviewSelection)
implementation(libs.androidx.security)
implementation(libs.androidx.swiperefreshlayout)
implementation(libs.dagger.hilt.android)
implementation(libs.kotlin.coroutines.android)
implementation(libs.kotlin.coroutines.core)

View file

@ -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 }

View file

@ -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
}

View file

@ -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
}

View file

@ -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 ->