Skip to content

Commit

Permalink
Dagger removal (#347)
Browse files Browse the repository at this point in the history
* dagger removal

* analytics removal
  • Loading branch information
gasstan committed Oct 31, 2022
1 parent f397260 commit d146370
Show file tree
Hide file tree
Showing 59 changed files with 687 additions and 1,137 deletions.
9 changes: 0 additions & 9 deletions app/build.gradle
Expand Up @@ -160,11 +160,6 @@ dependencies {
implementation Deps.Google.GUAVA
implementation Deps.Google.MATERIAL

// Dagger
implementation Deps.Dagger.ANDROID_SUPPORT
kapt Deps.Dagger.ANDROID_PROCESSOR
kapt Deps.Dagger.COMPILER

// grpc-java
implementation Deps.Grpc.ANDROID
implementation Deps.Grpc.OKHTTP
Expand All @@ -173,10 +168,6 @@ dependencies {
implementation 'com.squareup.okio:okio:2.8.0'
implementation Deps.JavaX.JAVA_ANNOTATION

// Analytics (for dogfooding/crash-reporting/feedback only on internal team builds)
implementation Deps.Analytics.MIXPANEL
implementation Deps.Analytics.BUGSNAG

// Misc.
implementation Deps.Misc.LOTTIE
implementation Deps.Misc.CHIPS
Expand Down
Expand Up @@ -10,7 +10,7 @@ import cash.z.ecc.kotlin.mnemonic.Mnemonics
import kotlinx.coroutines.test.runTest
import okio.Buffer
import okio.GzipSink
import okio.Okio
import okio.buffer
import org.junit.Assert.assertEquals
import org.junit.Assert.assertTrue
import org.junit.Before
Expand Down Expand Up @@ -106,7 +106,7 @@ class IntegrationTest {

fun String.gzip(): ByteArray {
val result = Buffer()
val sink = Okio.buffer(GzipSink(result))
val sink = GzipSink(result).buffer()
sink.use {
sink.write(toByteArray())
}
Expand Down
19 changes: 4 additions & 15 deletions app/src/main/java/cash/z/ecc/android/ZcashWalletApp.kt
Expand Up @@ -4,26 +4,18 @@ import android.app.Application
import android.content.Context
import androidx.camera.camera2.Camera2Config
import androidx.camera.core.CameraXConfig
import cash.z.ecc.android.di.component.AppComponent
import cash.z.ecc.android.di.component.DaggerAppComponent
import cash.z.ecc.android.di.DependenciesHolder
import cash.z.ecc.android.ext.tryWithWarning
import cash.z.ecc.android.feedback.FeedbackCoordinator
import cash.z.ecc.android.sdk.ext.ZcashSdk
import cash.z.ecc.android.sdk.internal.Twig
import cash.z.ecc.android.sdk.model.Zatoshi
import cash.z.ecc.android.sdk.model.ZcashNetwork
import cash.z.ecc.android.util.twig
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import javax.inject.Inject
import kotlinx.coroutines.*

class ZcashWalletApp : Application(), CameraXConfig.Provider {

@Inject
lateinit var coordinator: FeedbackCoordinator
private val coordinator: FeedbackCoordinator
get() = DependenciesHolder.feedbackCoordinator

lateinit var defaultNetwork: ZcashNetwork

Expand Down Expand Up @@ -74,8 +66,6 @@ class ZcashWalletApp : Application(), CameraXConfig.Provider {
creationTime = System.currentTimeMillis()

defaultNetwork = ZcashNetwork.from(resources.getInteger(R.integer.zcash_network_id))
component = DaggerAppComponent.factory().create(this)
component.inject(this)
feedbackScope.launch {
coordinator.feedback.start()
}
Expand All @@ -87,7 +77,6 @@ class ZcashWalletApp : Application(), CameraXConfig.Provider {

companion object {
lateinit var instance: ZcashWalletApp
lateinit var component: AppComponent
}

/**
Expand Down
44 changes: 44 additions & 0 deletions app/src/main/java/cash/z/ecc/android/di/DependenciesHolder.kt
@@ -0,0 +1,44 @@
package cash.z.ecc.android.di

import android.content.ClipboardManager
import android.content.Context
import cash.z.ecc.android.ZcashWalletApp
import cash.z.ecc.android.ext.Const
import cash.z.ecc.android.feedback.*
import cash.z.ecc.android.lockbox.LockBox
import cash.z.ecc.android.sdk.Synchronizer
import cash.z.ecc.android.ui.util.DebugFileTwig
import cash.z.ecc.android.util.SilentTwig
import cash.z.ecc.android.util.Twig
import cash.z.ecc.kotlin.mnemonic.Mnemonics

object DependenciesHolder {

fun provideAppContext(): Context = ZcashWalletApp.instance

val initializerComponent by lazy { InitializerComponent() }

val synchronizer by lazy { Synchronizer.newBlocking(initializerComponent.initializer) }

val clipboardManager by lazy { provideAppContext().getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager }

val lockBox by lazy { LockBox(provideAppContext()) }

val prefs by lazy { LockBox(provideAppContext()) }

val feedback by lazy { Feedback() }

val feedbackCoordinator by lazy {
lockBox.getBoolean(Const.Pref.FEEDBACK_ENABLED).let { isEnabled ->
// observe nothing unless feedback is enabled
Twig.plant(if (isEnabled) DebugFileTwig() else SilentTwig())
FeedbackCoordinator(feedback)
}
}

val feedbackFile by lazy { FeedbackFile() }

val feedbackConsole by lazy { FeedbackConsole() }

val mnemonics by lazy { Mnemonics() }
}
14 changes: 14 additions & 0 deletions app/src/main/java/cash/z/ecc/android/di/InitializerComponent.kt
@@ -0,0 +1,14 @@
package cash.z.ecc.android.di

import cash.z.ecc.android.sdk.Initializer

class InitializerComponent {

lateinit var initializer: Initializer
private set

fun createInitializer(config: Initializer.Config) {
initializer = Initializer.newBlocking(DependenciesHolder.provideAppContext(), config)
}

}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

14 changes: 0 additions & 14 deletions app/src/main/java/cash/z/ecc/android/di/annotation/ViewModelKey.kt

This file was deleted.

23 changes: 0 additions & 23 deletions app/src/main/java/cash/z/ecc/android/di/component/AppComponent.kt

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

87 changes: 0 additions & 87 deletions app/src/main/java/cash/z/ecc/android/di/module/AppModule.kt

This file was deleted.

This file was deleted.

0 comments on commit d146370

Please sign in to comment.