Skip to content

Commit

Permalink
#1556 mark card as done: first impl
Browse files Browse the repository at this point in the history
  • Loading branch information
desperateCoder committed Dec 22, 2023
1 parent 07fd0c2 commit 2d62de8
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
import it.niedermann.nextcloud.deck.database.migration.Migration_29_30;
import it.niedermann.nextcloud.deck.database.migration.Migration_30_31;
import it.niedermann.nextcloud.deck.database.migration.Migration_31_32;
import it.niedermann.nextcloud.deck.database.migration.Migration_32_33;
import it.niedermann.nextcloud.deck.database.migration.Migration_8_9;
import it.niedermann.nextcloud.deck.database.migration.Migration_9_10;
import it.niedermann.nextcloud.deck.model.AccessControl;
Expand Down Expand Up @@ -135,7 +136,7 @@
FilterWidgetSort.class,
},
exportSchema = false,
version = 32
version = 33
)
@TypeConverters({DateTypeConverter.class, EnumConverter.class})
public abstract class DeckDatabase extends RoomDatabase {
Expand Down Expand Up @@ -188,6 +189,7 @@ private static DeckDatabase create(final Context context) {
.addMigrations(new Migration_29_30(context))
.addMigrations(new Migration_30_31())
.addMigrations(new Migration_31_32(context))
.addMigrations(new Migration_32_33())
.fallbackToDestructiveMigration()
.addCallback(ON_CREATE_CALLBACK)
.build();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package it.niedermann.nextcloud.deck.database.migration;

import androidx.annotation.NonNull;
import androidx.room.migration.Migration;
import androidx.sqlite.db.SupportSQLiteDatabase;

/**
* Adds support for marking a card as done: https://github.com/stefan-niedermann/nextcloud-deck/issues/1556
*/
public class Migration_32_33 extends Migration {

public Migration_32_33() {
super(32, 33);
}

@Override
public void migrate(@NonNull SupportSQLiteDatabase database) {
database.execSQL("ALTER TABLE `Card` add column done INTEGER");
}
}
13 changes: 13 additions & 0 deletions app/src/main/java/it/niedermann/nextcloud/deck/model/Card.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public TaskStatus(int taskCount, int doneCount) {
private String type;
private Instant createdAt;
private Instant deletedAt;
private Instant done;
private int attachmentCount;

private Long userId;
Expand Down Expand Up @@ -252,6 +253,14 @@ public int getOrder() {
return this.order;
}

public Instant getDone() {
return done;
}

public void setDone(Instant done) {
this.done = done;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
Expand All @@ -274,6 +283,8 @@ public boolean equals(Object o) {
return false;
if (deletedAt != null ? !deletedAt.equals(card.deletedAt) : card.deletedAt != null)
return false;
if (done != null ? !done.equals(card.done) : card.done != null)
return false;
if (userId != null ? !userId.equals(card.userId) : card.userId != null) return false;
return dueDate != null ? dueDate.equals(card.dueDate) : card.dueDate == null;
}
Expand All @@ -286,6 +297,7 @@ public int hashCode() {
result = 31 * result + (type != null ? type.hashCode() : 0);
result = 31 * result + (createdAt != null ? createdAt.hashCode() : 0);
result = 31 * result + (deletedAt != null ? deletedAt.hashCode() : 0);
result = 31 * result + (done != null ? done.hashCode() : 0);
result = 31 * result + attachmentCount;
result = 31 * result + (userId != null ? userId.hashCode() : 0);
result = 31 * result + order;
Expand All @@ -306,6 +318,7 @@ public String toString() {
", type='" + type + '\'' +
", createdAt=" + createdAt +
", deletedAt=" + deletedAt +
", done=" + done +
", attachmentCount=" + attachmentCount +
", userId=" + userId +
", order=" + order +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public CardUpdate(FullCard card) {
setAccountId(card.getAccountId());
setId(card.getId());
setLocalId(card.getLocalId());
setDone(card.getCard().getDone());
}

public User getOwner() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,7 @@ protected static FullCard parseCard(JsonObject e) {
card.setLastModified(getTimestampFromLong(e.get("lastModified")));
card.setCreatedAt(getTimestampFromLong(e.get("createdAt")));
card.setDeletedAt(getTimestampFromLong(e.get("deletedAt")));
card.setDone(getTimestampFromString(e.get("done")));
if (e.has("labels") && !e.get("labels").isJsonNull()) {
JsonArray labelsJson = e.getAsJsonArray("labels");
List<Label> labels = new ArrayList<>();
Expand Down

0 comments on commit 2d62de8

Please sign in to comment.