Files
SyncFlow/app/src/main/kotlin/com/syncflow/di/AppModule.kt
T
amir c60eb8d27b
Build & Release APK / build (push) Has been cancelled
v1.0.63: live sync progress counters, pause/resume, .gitignore fix
- SyncEngine: accepts onProgress callback — emits uploaded/downloaded/
  deleted/bytes counts atomically as each file completes
- SyncWorker: streams progress to WorkManager data so the UI can poll
  it live; reports per-run counters in the completion notification;
  adds pause/resume support
- HomeViewModel/PairDetailViewModel: subscribe to live WorkManager
  progress and surface it via SyncProgress state
- SyncPairEntity/SyncPairDao/SyncDatabase: persist last-run counters
  (uploaded, downloaded, deleted, bytesTransferred) in the DB with a
  Room migration (v3→v4)
- AppModule: provides WorkManager as an injectable singleton
- .gitignore: add .kotlin/ to exclude compiler session files

Security: no new issues — all logging via Timber (debug-only), DB
queries use Room parameterized API, file sharing via FileProvider.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-27 20:07:25 +00:00

52 lines
2.0 KiB
Kotlin

package com.syncflow.di
import android.content.Context
import androidx.room.Room
import androidx.work.WorkManager
import com.syncflow.data.db.*
import com.syncflow.data.preferences.AppPreferences
import com.syncflow.data.repository.AccountRepository
import com.syncflow.data.security.CredentialStore
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton
@Module
@InstallIn(SingletonComponent::class)
object AppModule {
@Provides @Singleton
fun provideDatabase(@ApplicationContext ctx: Context): SyncDatabase =
Room.databaseBuilder(ctx, SyncDatabase::class.java, "syncflow.db")
.fallbackToDestructiveMigrationFrom(1)
.addMigrations(SyncDatabase.MIGRATION_2_3, SyncDatabase.MIGRATION_3_4)
.build()
@Provides fun provideCloudAccountDao(db: SyncDatabase): CloudAccountDao = db.cloudAccountDao()
@Provides fun provideSyncPairDao(db: SyncDatabase): SyncPairDao = db.syncPairDao()
@Provides fun provideSyncFileStateDao(db: SyncDatabase): SyncFileStateDao = db.syncFileStateDao()
@Provides fun provideSyncConflictDao(db: SyncDatabase): SyncConflictDao = db.syncConflictDao()
@Provides fun provideSyncEventDao(db: SyncDatabase): SyncEventDao = db.syncEventDao()
@Provides @Singleton
fun provideCredentialStore(@ApplicationContext ctx: Context): CredentialStore =
CredentialStore(ctx)
@Provides @Singleton
fun provideAccountRepository(
accountDao: CloudAccountDao,
credentialStore: CredentialStore,
): AccountRepository = AccountRepository(accountDao, credentialStore)
@Provides @Singleton
fun provideAppPreferences(@ApplicationContext ctx: Context): AppPreferences =
AppPreferences(ctx)
@Provides @Singleton
fun provideWorkManager(@ApplicationContext ctx: Context): WorkManager =
WorkManager.getInstance(ctx)
}