Вынос IStorageInfo и IVaultInfo
This commit is contained in:
@@ -8,4 +8,4 @@ class Logger: ILogger {
|
|||||||
Timber.tag(tag)
|
Timber.tag(tag)
|
||||||
Timber.d(msg)
|
Timber.d(msg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import java.util.UUID
|
|||||||
|
|
||||||
class LocalStorage(
|
class LocalStorage(
|
||||||
override val uuid: UUID,
|
override val uuid: UUID,
|
||||||
|
override val isEncrypted: Boolean,
|
||||||
absolutePath: String,
|
absolutePath: String,
|
||||||
ioDispatcher: CoroutineDispatcher
|
ioDispatcher: CoroutineDispatcher
|
||||||
) : IStorage {
|
) : IStorage {
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ class LocalVault(private val ioDispatcher: CoroutineDispatcher, context: Context
|
|||||||
if (dirs != null) {
|
if (dirs != null) {
|
||||||
_storages.value = dirs.map {
|
_storages.value = dirs.map {
|
||||||
val uuid = UUID.fromString(it.name)
|
val uuid = UUID.fromString(it.name)
|
||||||
LocalStorage(uuid, it.path, ioDispatcher)
|
LocalStorage(uuid, false, it.path, ioDispatcher)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -66,7 +66,7 @@ class LocalVault(private val ioDispatcher: CoroutineDispatcher, context: Context
|
|||||||
val uuid = UUID.randomUUID()
|
val uuid = UUID.randomUUID()
|
||||||
val next = Path(path.path, uuid.toString())
|
val next = Path(path.path, uuid.toString())
|
||||||
next.createDirectory()
|
next.createDirectory()
|
||||||
val newStorage = LocalStorage(uuid, next.pathString, ioDispatcher)
|
val newStorage = LocalStorage(uuid, false, next.pathString, ioDispatcher)
|
||||||
_storages.value = _storages.value.toMutableList().apply {
|
_storages.value = _storages.value.toMutableList().apply {
|
||||||
add(newStorage)
|
add(newStorage)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.github.nullptroma.wallenc.domain.datatypes
|
package com.github.nullptroma.wallenc.domain.datatypes
|
||||||
|
|
||||||
class DataPackage<T>(
|
open class DataPackage<T>(
|
||||||
val data: T,
|
val data: T,
|
||||||
val isLoading: Boolean? = false,
|
val isLoading: Boolean? = false,
|
||||||
val isError: Boolean? = false
|
val isError: Boolean? = false
|
||||||
|
|||||||
@@ -12,7 +12,8 @@ class EncryptedStorage(
|
|||||||
source: IStorage,
|
source: IStorage,
|
||||||
key: EncryptKey,
|
key: EncryptKey,
|
||||||
logger: ILogger,
|
logger: ILogger,
|
||||||
ioDispatcher: CoroutineDispatcher
|
ioDispatcher: CoroutineDispatcher,
|
||||||
|
override val isEncrypted: Boolean
|
||||||
) : IStorage {
|
) : IStorage {
|
||||||
override val size: StateFlow<Long?>
|
override val size: StateFlow<Long?>
|
||||||
get() = TODO("Not yet implemented")
|
get() = TODO("Not yet implemented")
|
||||||
|
|||||||
@@ -1,14 +1,6 @@
|
|||||||
package com.github.nullptroma.wallenc.domain.interfaces
|
package com.github.nullptroma.wallenc.domain.interfaces
|
||||||
|
|
||||||
import kotlinx.coroutines.flow.StateFlow
|
interface IStorage: IStorageInfo {
|
||||||
import java.util.UUID
|
|
||||||
|
|
||||||
interface IStorage {
|
|
||||||
val size: StateFlow<Long?>
|
|
||||||
val numberOfFiles: StateFlow<Int?>
|
|
||||||
val uuid: UUID
|
|
||||||
val name: StateFlow<String>
|
|
||||||
val isAvailable: StateFlow<Boolean>
|
|
||||||
val accessor: IStorageAccessor
|
val accessor: IStorageAccessor
|
||||||
|
|
||||||
suspend fun rename(newName: String)
|
suspend fun rename(newName: String)
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package com.github.nullptroma.wallenc.domain.interfaces
|
||||||
|
|
||||||
|
import kotlinx.coroutines.flow.StateFlow
|
||||||
|
import java.util.UUID
|
||||||
|
|
||||||
|
interface IStorageInfo {
|
||||||
|
val size: StateFlow<Long?>
|
||||||
|
val numberOfFiles: StateFlow<Int?>
|
||||||
|
val uuid: UUID
|
||||||
|
val isEncrypted: Boolean
|
||||||
|
val name: StateFlow<String>
|
||||||
|
val isAvailable: StateFlow<Boolean>
|
||||||
|
}
|
||||||
@@ -1,9 +1,12 @@
|
|||||||
package com.github.nullptroma.wallenc.domain.interfaces
|
package com.github.nullptroma.wallenc.domain.interfaces
|
||||||
|
|
||||||
import com.github.nullptroma.wallenc.domain.datatypes.EncryptKey
|
import com.github.nullptroma.wallenc.domain.datatypes.EncryptKey
|
||||||
|
import kotlinx.coroutines.flow.StateFlow
|
||||||
import java.util.UUID
|
import java.util.UUID
|
||||||
|
|
||||||
interface IVault : IVaultInfo {
|
interface IVault : IVaultInfo {
|
||||||
|
override val storages: StateFlow<List<IStorage>>
|
||||||
|
|
||||||
suspend fun createStorage(): IStorage
|
suspend fun createStorage(): IStorage
|
||||||
suspend fun createStorage(key: EncryptKey): IStorage
|
suspend fun createStorage(key: EncryptKey): IStorage
|
||||||
suspend fun createStorage(key: EncryptKey, uuid: UUID): IStorage
|
suspend fun createStorage(key: EncryptKey, uuid: UUID): IStorage
|
||||||
|
|||||||
@@ -4,10 +4,10 @@ import com.github.nullptroma.wallenc.domain.enums.VaultType
|
|||||||
import kotlinx.coroutines.flow.StateFlow
|
import kotlinx.coroutines.flow.StateFlow
|
||||||
import java.util.UUID
|
import java.util.UUID
|
||||||
|
|
||||||
interface IVaultInfo {
|
sealed interface IVaultInfo {
|
||||||
val type: VaultType
|
val type: VaultType
|
||||||
val uuid: UUID
|
val uuid: UUID
|
||||||
val storages: StateFlow<List<IStorage>>
|
val storages: StateFlow<List<IStorageInfo>>
|
||||||
val isAvailable: StateFlow<Boolean>
|
val isAvailable: StateFlow<Boolean>
|
||||||
val totalSpace: StateFlow<Int?>
|
val totalSpace: StateFlow<Int?>
|
||||||
val availableSpace: StateFlow<Int?>
|
val availableSpace: StateFlow<Int?>
|
||||||
|
|||||||
@@ -3,12 +3,6 @@ package com.github.nullptroma.wallenc.domain.usecases
|
|||||||
import com.github.nullptroma.wallenc.domain.interfaces.IVaultsManager
|
import com.github.nullptroma.wallenc.domain.interfaces.IVaultsManager
|
||||||
|
|
||||||
class GetAllRawStoragesUseCase(private val manager: IVaultsManager) {
|
class GetAllRawStoragesUseCase(private val manager: IVaultsManager) {
|
||||||
// fun getStoragesFlow() = manager.remoteVaults.combine(manager.localVault) { remote, local ->
|
|
||||||
// mutableListOf<IVault>().apply {
|
|
||||||
// addAll(remote)
|
|
||||||
// add(local)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
val localStorages
|
val localStorages
|
||||||
get() = manager.localVault.storages
|
get() = manager.localVault.storages
|
||||||
}
|
}
|
||||||
@@ -3,11 +3,14 @@ package com.github.nullptroma.wallenc.domain.usecases
|
|||||||
import com.github.nullptroma.wallenc.domain.interfaces.IDirectory
|
import com.github.nullptroma.wallenc.domain.interfaces.IDirectory
|
||||||
import com.github.nullptroma.wallenc.domain.interfaces.IFile
|
import com.github.nullptroma.wallenc.domain.interfaces.IFile
|
||||||
import com.github.nullptroma.wallenc.domain.interfaces.IStorage
|
import com.github.nullptroma.wallenc.domain.interfaces.IStorage
|
||||||
|
import com.github.nullptroma.wallenc.domain.interfaces.IStorageInfo
|
||||||
|
|
||||||
class StorageFileManagementUseCase {
|
class StorageFileManagementUseCase {
|
||||||
private var _storage: IStorage? = null
|
private var _storage: IStorage? = null
|
||||||
|
|
||||||
fun setStorage(storage: IStorage) {
|
fun setStorage(storage: IStorageInfo) {
|
||||||
|
if(storage !is IStorage)
|
||||||
|
throw Exception("Cannot manage storage on StorageInfo")
|
||||||
_storage = storage
|
_storage = storage
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
package com.github.nullptroma.wallenc.domain.usecases
|
|
||||||
|
|
||||||
import com.github.nullptroma.wallenc.domain.interfaces.IMetaInfo
|
|
||||||
|
|
||||||
class TestUseCase (val meta: IMetaInfo, val id: Int) {
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
package com.github.nullptroma.wallenc.presentation.screens.main.screens.local.vault
|
package com.github.nullptroma.wallenc.presentation.screens.main.screens.local.vault
|
||||||
|
|
||||||
import com.github.nullptroma.wallenc.domain.interfaces.IStorage
|
import com.github.nullptroma.wallenc.domain.interfaces.IStorageInfo
|
||||||
|
|
||||||
data class LocalVaultScreenState(val storagesList: List<IStorage>)
|
data class LocalVaultScreenState(val storagesList: List<IStorageInfo>)
|
||||||
@@ -3,8 +3,7 @@ package com.github.nullptroma.wallenc.presentation.screens.main.screens.local.va
|
|||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
import com.github.nullptroma.wallenc.domain.interfaces.IDirectory
|
import com.github.nullptroma.wallenc.domain.interfaces.IDirectory
|
||||||
import com.github.nullptroma.wallenc.domain.interfaces.IFile
|
import com.github.nullptroma.wallenc.domain.interfaces.IFile
|
||||||
import com.github.nullptroma.wallenc.domain.interfaces.ILogger
|
import com.github.nullptroma.wallenc.domain.interfaces.IStorageInfo
|
||||||
import com.github.nullptroma.wallenc.domain.interfaces.IStorage
|
|
||||||
import com.github.nullptroma.wallenc.domain.usecases.ManageLocalVaultUseCase
|
import com.github.nullptroma.wallenc.domain.usecases.ManageLocalVaultUseCase
|
||||||
import com.github.nullptroma.wallenc.domain.usecases.StorageFileManagementUseCase
|
import com.github.nullptroma.wallenc.domain.usecases.StorageFileManagementUseCase
|
||||||
import com.github.nullptroma.wallenc.presentation.viewmodel.ViewModelBase
|
import com.github.nullptroma.wallenc.presentation.viewmodel.ViewModelBase
|
||||||
@@ -31,7 +30,7 @@ class LocalVaultViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun printAllFilesToLog(storage: IStorage) {
|
fun printAllFilesToLog(storage: IStorageInfo) {
|
||||||
_storageFileManagementUseCase.setStorage(storage)
|
_storageFileManagementUseCase.setStorage(storage)
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
val files: List<IFile>
|
val files: List<IFile>
|
||||||
|
|||||||
Reference in New Issue
Block a user