Add isLocalOnly property to Folder

This commit is contained in:
cketti 2020-05-15 19:45:15 +02:00
parent 118450e31d
commit 981e12965a
4 changed files with 21 additions and 10 deletions

View file

@ -25,7 +25,7 @@ class FolderRepository(
return folders
.filterNot { it.isLocalOnly }
.map { Folder(it.databaseId, it.serverId, it.name, it.type.toFolderType()) }
.map { Folder(it.databaseId, it.serverId, it.name, it.type.toFolderType(), isLocalOnly = false) }
}
fun getDisplayFolders(displayMode: FolderMode?): List<DisplayFolder> {
@ -111,7 +111,8 @@ class FolderRepository(
"poll_class",
"display_class",
"notify_class",
"push_class"
"push_class",
"local_only"
),
selection,
selectionArgs,
@ -126,7 +127,8 @@ class FolderRepository(
id = id,
serverId = cursor.getString(1),
name = cursor.getString(2),
type = folderTypeOf(id)
type = folderTypeOf(id),
isLocalOnly = cursor.getInt(9) == 1
),
isInTopGroup = cursor.getInt(3) == 1,
isIntegrate = cursor.getInt(4) == 1,
@ -157,7 +159,7 @@ class FolderRepository(
private fun getDisplayFolders(db: SQLiteDatabase, displayMode: FolderMode): List<DisplayFolder> {
val queryBuilder = StringBuilder("""
SELECT f.id, f.server_id, f.name, f.top_group, (
SELECT f.id, f.server_id, f.name, f.top_group, f.local_only, (
SELECT COUNT(m.id)
FROM messages m
WHERE m.folder_id = f.id AND m.empty = 0 AND m.deleted = 0 AND m.read = 0
@ -178,9 +180,10 @@ class FolderRepository(
val name = cursor.getString(2)
val type = folderTypeOf(id)
val isInTopGroup = cursor.getInt(3) == 1
val unreadCount = cursor.getInt(4)
val isLocalOnly = cursor.getInt(4) == 1
val unreadCount = cursor.getInt(5)
val folder = Folder(id, serverId, name, type)
val folder = Folder(id, serverId, name, type, isLocalOnly)
displayFolders.add(DisplayFolder(folder, isInTopGroup, unreadCount))
}
@ -263,7 +266,7 @@ class FolderRepository(
}
}
data class Folder(val id: Long, val serverId: String, val name: String, val type: FolderType)
data class Folder(val id: Long, val serverId: String, val name: String, val type: FolderType, val isLocalOnly: Boolean)
data class FolderDetails(
val folder: Folder,

View file

@ -140,6 +140,12 @@ class UnreadWidgetDataProviderTest : AppRobolectricTest() {
const val ACCOUNT_UNREAD_COUNT = 2
const val FOLDER_UNREAD_COUNT = 3
const val LOCALIZED_FOLDER_NAME = "Posteingang"
val FOLDER = Folder(id = FOLDER_ID, serverId = "irrelevant", name = "INBOX", type = FolderType.INBOX)
val FOLDER = Folder(
id = FOLDER_ID,
serverId = "irrelevant",
name = "INBOX",
type = FolderType.INBOX,
isLocalOnly = false
)
}
}

View file

@ -22,7 +22,8 @@ class FolderInfoHolder(
id = folderId,
serverId = localFolder.serverId,
name = localFolder.name,
type = getFolderType(account, folderId)
type = getFolderType(account, folderId),
isLocalOnly = localFolder.isLocalOnly
)
return folderNameFormatter.displayName(folder)
}

View file

@ -82,7 +82,8 @@ class FolderSettingsViewModel(
id = folder.id,
serverId = folder.serverId,
name = folder.name,
type = folderType
type = folderType,
isLocalOnly = folder.isLocalOnly
)
}