Add toast

This commit is contained in:
Hinton 2024-10-24 15:41:44 -07:00
parent d4d980b576
commit 30531a40d3
No known key found for this signature in database
GPG key ID: 5F7295599C5D965C
2 changed files with 15 additions and 3 deletions

View file

@ -1,6 +1,8 @@
package com.x8bit.bitwarden.data.vault.manager package com.x8bit.bitwarden.data.vault.manager
import android.content.Context
import android.net.Uri import android.net.Uri
import android.widget.Toast
import androidx.core.net.toUri import androidx.core.net.toUri
import com.bitwarden.vault.AttachmentView import com.bitwarden.vault.AttachmentView
import com.bitwarden.vault.Cipher import com.bitwarden.vault.Cipher
@ -35,9 +37,6 @@ import com.x8bit.bitwarden.data.vault.repository.util.toNetworkAttachmentRequest
import com.x8bit.bitwarden.data.vault.repository.util.toOfflineCipher import com.x8bit.bitwarden.data.vault.repository.util.toOfflineCipher
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.flow.filter
import kotlinx.coroutines.flow.flatMapConcat
import kotlinx.coroutines.flow.flattenConcat import kotlinx.coroutines.flow.flattenConcat
import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.flow.flowOf
import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.map
@ -51,6 +50,7 @@ import java.time.Clock
@OptIn(ExperimentalCoroutinesApi::class) @OptIn(ExperimentalCoroutinesApi::class)
@Suppress("TooManyFunctions") @Suppress("TooManyFunctions")
class CipherManagerImpl( class CipherManagerImpl(
private val context: Context,
private val fileManager: FileManager, private val fileManager: FileManager,
private val authDiskSource: AuthDiskSource, private val authDiskSource: AuthDiskSource,
private val ciphersService: CiphersService, private val ciphersService: CiphersService,
@ -81,6 +81,7 @@ class CipherManagerImpl(
} }
val userId = activeUserId!! val userId = activeUserId!!
val hasItems = it.isNotEmpty()
it.map { c -> it.map { c ->
val cipher = c.toOfflineCipher().toCipher() val cipher = c.toOfflineCipher().toCipher()
@ -119,7 +120,16 @@ class CipherManagerImpl(
onSuccess = { it }, onSuccess = { it },
) )
} }
}
if (hasItems) {
externalScope.launch {
Toast.makeText(
context,
"Offline items uploaded",
Toast.LENGTH_SHORT
).show()
}
} }
} }
} }

View file

@ -40,6 +40,7 @@ object VaultManagerModule {
@Provides @Provides
@Singleton @Singleton
fun provideCipherManager( fun provideCipherManager(
@ApplicationContext context: Context,
ciphersService: CiphersService, ciphersService: CiphersService,
vaultDiskSource: VaultDiskSource, vaultDiskSource: VaultDiskSource,
vaultSdkSource: VaultSdkSource, vaultSdkSource: VaultSdkSource,
@ -49,6 +50,7 @@ object VaultManagerModule {
networkConnectionManager: NetworkConnectionManager, networkConnectionManager: NetworkConnectionManager,
dispatcherManager: DispatcherManager dispatcherManager: DispatcherManager
): CipherManager = CipherManagerImpl( ): CipherManager = CipherManagerImpl(
context = context,
fileManager = fileManager, fileManager = fileManager,
authDiskSource = authDiskSource, authDiskSource = authDiskSource,
ciphersService = ciphersService, ciphersService = ciphersService,