feat: add history sync worker

This commit is contained in:
2026-06-07 17:16:47 +02:00
parent 3f25ee4c41
commit 3b14f2fba9
25 changed files with 807 additions and 120 deletions
@@ -0,0 +1,33 @@
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
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) // moved from MainActivity
}
}