From 0a10db3bba49ac6d6bf111023e4c442fcf44e5a6 Mon Sep 17 00:00:00 2001 From: Torsten Grote Date: Fri, 2 Aug 2024 13:54:44 -0300 Subject: [PATCH] split out FilesItem class into own file --- .../ui/restore/FileSelectionManager.kt | 38 --------------- .../backup/storage/ui/restore/FilesItem.kt | 46 +++++++++++++++++++ 2 files changed, 46 insertions(+), 38 deletions(-) create mode 100644 storage/lib/src/main/java/org/calyxos/backup/storage/ui/restore/FilesItem.kt diff --git a/storage/lib/src/main/java/org/calyxos/backup/storage/ui/restore/FileSelectionManager.kt b/storage/lib/src/main/java/org/calyxos/backup/storage/ui/restore/FileSelectionManager.kt index 64b03728..6fdf7769 100644 --- a/storage/lib/src/main/java/org/calyxos/backup/storage/ui/restore/FileSelectionManager.kt +++ b/storage/lib/src/main/java/org/calyxos/backup/storage/ui/restore/FileSelectionManager.kt @@ -12,44 +12,6 @@ import kotlinx.coroutines.flow.asStateFlow import org.calyxos.backup.storage.backup.BackupSnapshot import org.calyxos.backup.storage.restore.RestorableFile -public sealed interface FilesItem { - public val name: String - public val dir: String - public val level: Int - public val selected: Boolean - public val size: Long - public val lastModified: Long? -} - -public data class FileItem internal constructor( - internal val file: RestorableFile, - override val level: Int, - override val selected: Boolean, -) : FilesItem { - override val name: String get() = file.name - override val dir: String get() = file.dir - override val size: Long get() = file.size - override val lastModified: Long? get() = file.lastModified -} - -public data class FolderItem( - override val dir: String, - override val name: String, - override val level: Int, - val numFiles: Int, - override val size: Long, - override val lastModified: Long?, - override val selected: Boolean, - val partiallySelected: Boolean, - val expanded: Boolean, -) : FilesItem { - init { - check(selected || !partiallySelected) { - "$dir was not selected, but partially selected" - } - } -} - public class FileSelectionManager { private val allFolders = HashMap() diff --git a/storage/lib/src/main/java/org/calyxos/backup/storage/ui/restore/FilesItem.kt b/storage/lib/src/main/java/org/calyxos/backup/storage/ui/restore/FilesItem.kt new file mode 100644 index 00000000..b584c381 --- /dev/null +++ b/storage/lib/src/main/java/org/calyxos/backup/storage/ui/restore/FilesItem.kt @@ -0,0 +1,46 @@ +/* + * SPDX-FileCopyrightText: 2024 The Calyx Institute + * SPDX-License-Identifier: Apache-2.0 + */ + +package org.calyxos.backup.storage.ui.restore + +import org.calyxos.backup.storage.restore.RestorableFile + +public sealed interface FilesItem { + public val name: String + public val dir: String + public val level: Int + public val selected: Boolean + public val size: Long + public val lastModified: Long? +} + +public data class FileItem internal constructor( + internal val file: RestorableFile, + override val level: Int, + override val selected: Boolean, +) : FilesItem { + override val name: String get() = file.name + override val dir: String get() = file.dir + override val size: Long get() = file.size + override val lastModified: Long? get() = file.lastModified +} + +public data class FolderItem( + override val dir: String, + override val name: String, + override val level: Int, + val numFiles: Int, + override val size: Long, + override val lastModified: Long?, + override val selected: Boolean, + val partiallySelected: Boolean, + val expanded: Boolean, +) : FilesItem { + init { + check(selected || !partiallySelected) { + "$dir was not selected, but partially selected" + } + } +}