Skip to content

Commit b88b965

Browse files
author
desperateCoder
committed
add color to card entity
1 parent 7e6df34 commit b88b965

5 files changed

Lines changed: 17 additions & 0 deletions

File tree

app/src/main/java/it/niedermann/nextcloud/deck/database/migration/Migration_34_35.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public Migration_34_35() {
1616
@Override
1717
public void migrate(@NonNull SupportSQLiteDatabase database) {
1818
database.execSQL("ALTER TABLE `Card` add column startDate INTEGER");
19+
database.execSQL("ALTER TABLE `Card` add column color INTEGER");
1920
// Reset ETags to refetch Cards
2021
database.execSQL("UPDATE `Account` SET `boardsEtag` = NULL");
2122
database.execSQL("UPDATE `Board` SET `etag` = NULL");

app/src/main/java/it/niedermann/nextcloud/deck/model/Card.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import androidx.room.Ignore;
77
import androidx.room.Index;
88

9+
import com.google.gson.annotations.JsonAdapter;
910
import com.google.gson.annotations.SerializedName;
1011

1112
import java.time.Instant;
@@ -15,6 +16,7 @@
1516

1617
import it.niedermann.nextcloud.deck.model.enums.DBStatus;
1718
import it.niedermann.nextcloud.deck.model.interfaces.AbstractRemoteEntity;
19+
import it.niedermann.nextcloud.deck.remote.api.json.JsonColorSerializer;
1820

1921
@Entity(inheritSuperIndices = true,
2022
indices = {
@@ -53,6 +55,8 @@ public TaskStatus(int taskCount, int doneCount) {
5355

5456
private String title;
5557
private String description;
58+
@JsonAdapter(JsonColorSerializer.class)
59+
private Integer color;
5660
@NonNull
5761
private Long stackId;
5862
private String type;
@@ -96,6 +100,7 @@ public Card(Card card) {
96100
this.archived = card.isArchived();
97101
this.dueDate = card.getDueDate();
98102
this.startDate = card.getStartDate();
103+
this.color = card.getColor();
99104
this.done = card.getDone();
100105
this.notified = card.isNotified();
101106
this.overdue = card.getOverdue();
@@ -229,6 +234,14 @@ public void setStartDate(Instant dateTime) {
229234
this.startDate = dateTime;
230235
}
231236

237+
public Integer getColor() {
238+
return color;
239+
}
240+
241+
public void setColor(Integer color) {
242+
this.color = color;
243+
}
244+
232245
public int getOverdue() {
233246
return overdue;
234247
}

app/src/main/java/it/niedermann/nextcloud/deck/model/propagation/CardUpdate.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public CardUpdate(FullCard card) {
2222
setArchived(card.getCard().isArchived());
2323
setDueDate(card.getCard().getDueDate());
2424
setStartDate(card.getCard().getStartDate());
25+
setColor(card.getCard().getColor());
2526
setNotified(card.getCard().isNotified());
2627
setOverdue(card.getCard().getOverdue());
2728
setCommentsUnread(card.getCard().getCommentsUnread());

app/src/main/java/it/niedermann/nextcloud/deck/model/propagation/CardUpdateOwnerString.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public CardUpdateOwnerString(CardUpdate card) {
2020
setArchived(card.isArchived());
2121
setDueDate(card.getDueDate());
2222
setStartDate(card.getStartDate());
23+
setColor(card.getColor());
2324
setNotified(card.isNotified());
2425
setOverdue(card.getOverdue());
2526
setCommentsUnread(card.getCommentsUnread());

app/src/main/java/it/niedermann/nextcloud/deck/remote/api/JsonToEntityParser.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,7 @@ protected static FullCard parseCard(JsonObject e) {
469469
card.setOverdue(getNullAsZero(e.get("overdue")));
470470
card.setDueDate(getTimestampFromString(e.get("duedate")));
471471
card.setStartDate(getTimestampFromString(e.get("startdate")));
472+
card.setColor(getColorAsInt(e, "color"));
472473
card.setCommentsUnread(e.get("commentsUnread").getAsInt());
473474
JsonElement owner = e.get("owner");
474475
if (owner != null) {

0 commit comments

Comments
 (0)