app: configure Hilt and desugaring
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
This commit is contained in:
parent
77abe7ee2c
commit
a0fdd6ddc3
5 changed files with 44 additions and 1 deletions
|
@ -7,6 +7,8 @@ import com.android.build.gradle.internal.api.BaseVariantOutputImpl
|
||||||
plugins {
|
plugins {
|
||||||
id("com.android.application")
|
id("com.android.application")
|
||||||
kotlin("android")
|
kotlin("android")
|
||||||
|
kotlin("kapt")
|
||||||
|
id("dagger.hilt.android.plugin")
|
||||||
`versioning-plugin`
|
`versioning-plugin`
|
||||||
`aps-plugin`
|
`aps-plugin`
|
||||||
`crowdin-plugin`
|
`crowdin-plugin`
|
||||||
|
@ -22,6 +24,7 @@ android {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
compileOptions { isCoreLibraryDesugaringEnabled = true }
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId = "dev.msfjarvis.aps"
|
applicationId = "dev.msfjarvis.aps"
|
||||||
|
@ -42,7 +45,9 @@ android {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
kapt(libs.dagger.hilt.compiler)
|
||||||
compileOnly(libs.androidx.annotation)
|
compileOnly(libs.androidx.annotation)
|
||||||
|
coreLibraryDesugaring(libs.android.desugarJdkLibs)
|
||||||
implementation(projects.autofillParser)
|
implementation(projects.autofillParser)
|
||||||
implementation(projects.openpgpKtx)
|
implementation(projects.openpgpKtx)
|
||||||
implementation(libs.androidx.activityKtx)
|
implementation(libs.androidx.activityKtx)
|
||||||
|
@ -60,6 +65,7 @@ dependencies {
|
||||||
implementation(libs.androidx.recyclerviewSelection)
|
implementation(libs.androidx.recyclerviewSelection)
|
||||||
implementation(libs.androidx.security)
|
implementation(libs.androidx.security)
|
||||||
implementation(libs.androidx.swiperefreshlayout)
|
implementation(libs.androidx.swiperefreshlayout)
|
||||||
|
implementation(libs.dagger.hilt.android)
|
||||||
|
|
||||||
implementation(libs.kotlin.coroutines.android)
|
implementation(libs.kotlin.coroutines.android)
|
||||||
implementation(libs.kotlin.coroutines.core)
|
implementation(libs.kotlin.coroutines.core)
|
||||||
|
|
|
@ -12,6 +12,7 @@ import androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_NO
|
||||||
import androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_YES
|
import androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_YES
|
||||||
import com.github.ajalt.timberkt.Timber.DebugTree
|
import com.github.ajalt.timberkt.Timber.DebugTree
|
||||||
import com.github.ajalt.timberkt.Timber.plant
|
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.getString
|
||||||
import dev.msfjarvis.aps.util.extensions.sharedPrefs
|
import dev.msfjarvis.aps.util.extensions.sharedPrefs
|
||||||
import dev.msfjarvis.aps.util.git.sshj.setUpBouncyCastleForSshj
|
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
|
import dev.msfjarvis.aps.util.settings.runMigrations
|
||||||
|
|
||||||
@Suppress("Unused")
|
@Suppress("Unused")
|
||||||
|
@HiltAndroidApp
|
||||||
class Application : android.app.Application(), SharedPreferences.OnSharedPreferenceChangeListener {
|
class Application : android.app.Application(), SharedPreferences.OnSharedPreferenceChangeListener {
|
||||||
|
|
||||||
private val prefs by lazy { sharedPrefs }
|
private val prefs by lazy { sharedPrefs }
|
||||||
|
|
|
@ -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
|
||||||
|
}
|
|
@ -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
|
||||||
|
}
|
|
@ -6,9 +6,10 @@
|
||||||
package dev.msfjarvis.aps.util.totp
|
package dev.msfjarvis.aps.util.totp
|
||||||
|
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
/** [Uri] backed TOTP URL parser. */
|
/** [Uri] backed TOTP URL parser. */
|
||||||
class UriTotpFinder : TotpFinder {
|
class UriTotpFinder @Inject constructor() : TotpFinder {
|
||||||
|
|
||||||
override fun findSecret(content: String): String? {
|
override fun findSecret(content: String): String? {
|
||||||
content.split("\n".toRegex()).forEach { line ->
|
content.split("\n".toRegex()).forEach { line ->
|
||||||
|
|
Loading…
Reference in a new issue