Files
SyncFlow/app/src/main/kotlin/com/syncflow/di/AppModule.kt
T
amir 5f45a344b7 fix: epoch-millis DB converter + biometric from onResume
Sync change detection:
- DbConverters was using epochSecond but comparisons used epochMilli —
  every file appeared modified on every scan, causing full re-sync each time
- DB migration 2→3 clears sync_file_states (all stored timestamps wrong)
- First sync after upgrade re-learns state; subsequent syncs skip unchanged files

Biometric:
- Move prompt trigger from LaunchedEffect to onResume() — guarantees
  the activity is in RESUMED state when authenticate() is called
- Add bestAuthenticators(): tries BIOMETRIC_STRONG|DEVICE_CREDENTIAL first,
  falls back to BIOMETRIC_WEAK|DEVICE_CREDENTIAL for side-sensor phones
- canAuthenticate() now accepts either strong or weak+credential
- onAuthenticationError always shows Unlock button (no infinite retry loop)
- isLocked/showRetry are Activity-level state, no need for Compose remember

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-22 23:59:20 +00:00

52 lines
1.9 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)
.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)
}