package com.bitcointxoko.gudariwallet import android.app.Application import androidx.work.Configuration import com.bitcointxoko.gudariwallet.api.LNbitsClient import com.bitcointxoko.gudariwallet.data.HistoricalSyncStore import com.bitcointxoko.gudariwallet.data.LNbitsWalletRepository import com.bitcointxoko.gudariwallet.data.PaymentCacheRepository import com.bitcointxoko.gudariwallet.security.EncryptedSecretStore import com.bitcointxoko.gudariwallet.sync.HistoricalSyncWorkerFactory import com.bitcointxoko.gudariwallet.util.NotificationHelper import timber.log.Timber class GudariWalletApplication : Application(), Configuration.Provider { // Evaluated lazily on first WorkManager access — EncryptedSecretStore is // safe to construct here since the Application context is fully ready. override val workManagerConfiguration: Configuration get() { val secrets = EncryptedSecretStore(this) val api = LNbitsClient.create(secrets) val repo = LNbitsWalletRepository(api = api, secrets = secrets) val paymentCache = PaymentCacheRepository(this) val syncStore = HistoricalSyncStore(this) return Configuration.Builder() .setWorkerFactory(HistoricalSyncWorkerFactory(repo, paymentCache, syncStore)) .build() } override fun onCreate() { super.onCreate() NotificationHelper.createChannels(this) if (BuildConfig.DEBUG) { Timber.plant(Timber.DebugTree()) } } }