diff --git a/app/src/main/java/com/infomaniak/drive/data/cache/FileMigration.kt b/app/src/main/java/com/infomaniak/drive/data/cache/FileMigration.kt index 2393ef3b36..c138a298d5 100644 --- a/app/src/main/java/com/infomaniak/drive/data/cache/FileMigration.kt +++ b/app/src/main/java/com/infomaniak/drive/data/cache/FileMigration.kt @@ -349,6 +349,15 @@ class FileMigration : RealmMigration { oldVersionTemp++ } + + // Migrated to version 8 + if (oldVersionTemp == 7L) { + schema.get("Rights")?.apply { + addField("colorable", Boolean::class.java, FieldAttribute.REQUIRED) + } + + oldVersionTemp++ + } } override fun equals(other: Any?): Boolean { @@ -376,7 +385,7 @@ class FileMigration : RealmMigration { } companion object { - const val dbVersion = 7L // Must be bumped when the schema changes + const val dbVersion = 8L // Must be bumped when the schema changes const val LOGOUT_CURRENT_USER_TAG = "logout_current_user_tag" } } diff --git a/app/src/main/java/com/infomaniak/drive/data/models/File.kt b/app/src/main/java/com/infomaniak/drive/data/models/File.kt index 2b07fd2a20..588eae9be1 100644 --- a/app/src/main/java/com/infomaniak/drive/data/models/File.kt +++ b/app/src/main/java/com/infomaniak/drive/data/models/File.kt @@ -373,12 +373,7 @@ open class File( } } - fun isAllowedToBeColored(): Boolean { - return !isDisabled() - && isFolder() - && getVisibilityType() != VisibilityType.IS_SHARED_SPACE - && getVisibilityType() != VisibilityType.IS_TEAM_SPACE - } + fun isAllowedToBeColored() = rights?.colorable ?: false fun hasCreationRight() = isFolder() && rights?.canCreateFile == true diff --git a/app/src/main/java/com/infomaniak/drive/data/models/Rights.kt b/app/src/main/java/com/infomaniak/drive/data/models/Rights.kt index e74d3ade9a..1d49fbb715 100644 --- a/app/src/main/java/com/infomaniak/drive/data/models/Rights.kt +++ b/app/src/main/java/com/infomaniak/drive/data/models/Rights.kt @@ -58,6 +58,7 @@ open class Rights( var canUseTeam: Boolean = false, @SerializedName("can_write") var canWrite: Boolean = false, + var colorable: Boolean = false, var right: String = "", ) : RealmObject(), Parcelable {