diff options
author | desperateCoder <echotodevnull@gmail.com> | 2020-12-10 18:34:39 +0300 |
---|---|---|
committer | desperateCoder <echotodevnull@gmail.com> | 2020-12-10 18:34:39 +0300 |
commit | 191e16973a362ac2b488d33e634cee7117d85635 (patch) | |
tree | 619dde41eef1d33b72ff400c2ab1226ca1e161df /app/src/main | |
parent | 200167e0fda47a683c7c926e587d593a841263ca (diff) |
#597 filter widget: refactored DB structure
Diffstat (limited to 'app/src/main')
11 files changed, 248 insertions, 43 deletions
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/model/widget/filter/FilterWidget.java b/app/src/main/java/it/niedermann/nextcloud/deck/model/widget/filter/FilterWidget.java index d31f35f66..7d93e2858 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/model/widget/filter/FilterWidget.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/model/widget/filter/FilterWidget.java @@ -1,14 +1,34 @@ package it.niedermann.nextcloud.deck.model.widget.filter; import androidx.room.Entity; +import androidx.room.Ignore; import androidx.room.PrimaryKey; +import java.util.List; + @Entity() public class FilterWidget { @PrimaryKey(autoGenerate = true) private Long id; + @Ignore + private List<FilterWidgetAccount> accounts; + + @Ignore + private List<FilterWidgetDue> dues; + + @Ignore + private List<FilterWidgetSort> sorts; + + public List<FilterWidgetAccount> getAccounts() { + return accounts; + } + + public void setAccounts(List<FilterWidgetAccount> accounts) { + this.accounts = accounts; + } + public Long getId() { return id; } @@ -17,6 +37,22 @@ public class FilterWidget { this.id = id; } + public List<FilterWidgetDue> getDues() { + return dues; + } + + public void setDues(List<FilterWidgetDue> dues) { + this.dues = dues; + } + + public List<FilterWidgetSort> getSorts() { + return sorts; + } + + public void setSorts(List<FilterWidgetSort> sorts) { + this.sorts = sorts; + } + @Override public boolean equals(Object o) { if (this == o) return true; diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/model/widget/filter/FilterWidgetAccount.java b/app/src/main/java/it/niedermann/nextcloud/deck/model/widget/filter/FilterWidgetAccount.java index 70ad17761..e8f2b99c1 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/model/widget/filter/FilterWidgetAccount.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/model/widget/filter/FilterWidgetAccount.java @@ -2,9 +2,12 @@ package it.niedermann.nextcloud.deck.model.widget.filter; import androidx.room.Entity; import androidx.room.ForeignKey; +import androidx.room.Ignore; import androidx.room.Index; import androidx.room.PrimaryKey; +import java.util.List; + import it.niedermann.nextcloud.deck.model.Account; @Entity( @@ -32,6 +35,28 @@ public class FilterWidgetAccount { private Long filterWidgetId; private Long accountId; + @Ignore + private List<FilterWidgetBoard> boards; + + @Ignore + private List<FilterWidgetUser> users; + + public void setBoards(List<FilterWidgetBoard> boards) { + this.boards = boards; + } + + public List<FilterWidgetBoard> getBoards() { + return boards; + } + + public List<FilterWidgetUser> getUsers() { + return users; + } + + public void setUsers(List<FilterWidgetUser> users) { + this.users = users; + } + public Long getId() { return id; } diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/model/widget/filter/FilterWidgetBoard.java b/app/src/main/java/it/niedermann/nextcloud/deck/model/widget/filter/FilterWidgetBoard.java index c66f9ca74..94ab14e08 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/model/widget/filter/FilterWidgetBoard.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/model/widget/filter/FilterWidgetBoard.java @@ -2,9 +2,12 @@ package it.niedermann.nextcloud.deck.model.widget.filter; import androidx.room.Entity; import androidx.room.ForeignKey; +import androidx.room.Ignore; import androidx.room.Index; import androidx.room.PrimaryKey; +import java.util.List; + import it.niedermann.nextcloud.deck.model.Board; @Entity( @@ -32,6 +35,28 @@ public class FilterWidgetBoard { private Long filterAccountId; private Long boardId; + @Ignore + private List<FilterWidgetStack> stacks; + + @Ignore + private List<FilterWidgetLabel> tags; + + public List<FilterWidgetLabel> getTags() { + return tags; + } + + public void setTags(List<FilterWidgetLabel> tags) { + this.tags = tags; + } + + public List<FilterWidgetStack> getStacks() { + return stacks; + } + + public void setStacks(List<FilterWidgetStack> stacks) { + this.stacks = stacks; + } + public Long getId() { return id; } diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/model/widget/filter/FilterWidgetDue.java b/app/src/main/java/it/niedermann/nextcloud/deck/model/widget/filter/FilterWidgetDue.java index eed279e29..64f11bfc6 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/model/widget/filter/FilterWidgetDue.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/model/widget/filter/FilterWidgetDue.java @@ -7,13 +7,13 @@ import androidx.room.PrimaryKey; @Entity( indices = { - @Index(value = "filterBoardId", name = "unique_idx_FilterWidgetDue_filterBoardId", unique = true), + @Index(value = "filterWidgetId", name = "unique_idx_FilterWidgetDue_filterWidgetId", unique = true), }, foreignKeys = { @ForeignKey( entity = FilterWidgetBoard.class, parentColumns = "id", - childColumns = "filterBoardId", onDelete = ForeignKey.CASCADE + childColumns = "filterWidgetId", onDelete = ForeignKey.CASCADE ) } ) @@ -21,7 +21,7 @@ public class FilterWidgetDue { @PrimaryKey(autoGenerate = true) private Long id; - private Long filterBoardId; + private Long filterWidgetId; private int dueType; public Long getId() { @@ -32,12 +32,12 @@ public class FilterWidgetDue { this.id = id; } - public Long getFilterBoardId() { - return filterBoardId; + public Long getFilterWidgetId() { + return filterWidgetId; } - public void setFilterBoardId(Long filterBoardId) { - this.filterBoardId = filterBoardId; + public void setFilterWidgetId(Long filterWidgetId) { + this.filterWidgetId = filterWidgetId; } public int getDueType() { @@ -57,13 +57,13 @@ public class FilterWidgetDue { if (dueType != that.dueType) return false; if (id != null ? !id.equals(that.id) : that.id != null) return false; - return filterBoardId != null ? filterBoardId.equals(that.filterBoardId) : that.filterBoardId == null; + return filterWidgetId != null ? filterWidgetId.equals(that.filterWidgetId) : that.filterWidgetId == null; } @Override public int hashCode() { int result = id != null ? id.hashCode() : 0; - result = 31 * result + (filterBoardId != null ? filterBoardId.hashCode() : 0); + result = 31 * result + (filterWidgetId != null ? filterWidgetId.hashCode() : 0); result = 31 * result + dueType; return result; } diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/model/widget/filter/FilterWidgetSort.java b/app/src/main/java/it/niedermann/nextcloud/deck/model/widget/filter/FilterWidgetSort.java index cbf3bb10f..a79ffb4a9 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/model/widget/filter/FilterWidgetSort.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/model/widget/filter/FilterWidgetSort.java @@ -7,15 +7,15 @@ import androidx.room.PrimaryKey; @Entity( indices = { - @Index(value = "filterBoardId", name = "idx_FilterWidgetSort_filterBoardId"), - @Index(value = {"filterBoardId", "criteria"}, name = "unique_idx_FilterWidgetSort_filterBoardId_criteria"), - @Index(value = {"filterBoardId", "ruleOrder"}, name = "unique_idx_FilterWidgetSort_filterBoardId_ruleOrder"), + @Index(value = "filterWidgetId", name = "idx_FilterWidgetSort_filterWidgetId"), + @Index(value = {"filterWidgetId", "criteria"}, name = "unique_idx_FilterWidgetSort_filterWidgetId_criteria"), + @Index(value = {"filterWidgetId", "ruleOrder"}, name = "unique_idx_FilterWidgetSort_filterWidgetId_ruleOrder"), }, foreignKeys = { @ForeignKey( entity = FilterWidgetBoard.class, parentColumns = "id", - childColumns = "filterBoardId", onDelete = ForeignKey.CASCADE + childColumns = "filterWidgetId", onDelete = ForeignKey.CASCADE ) } ) @@ -23,7 +23,7 @@ public class FilterWidgetSort { @PrimaryKey(autoGenerate = true) private Long id; - private Long filterBoardId; + private Long filterWidgetId; private boolean direction; private int criteria; private int ruleOrder; @@ -36,12 +36,12 @@ public class FilterWidgetSort { this.id = id; } - public Long getFilterBoardId() { - return filterBoardId; + public Long getFilterWidgetId() { + return filterWidgetId; } - public void setFilterBoardId(Long filterBoardId) { - this.filterBoardId = filterBoardId; + public void setFilterWidgetId(Long filterWidgetId) { + this.filterWidgetId = filterWidgetId; } public boolean isDirection() { @@ -79,13 +79,13 @@ public class FilterWidgetSort { if (criteria != that.criteria) return false; if (ruleOrder != that.ruleOrder) return false; if (id != null ? !id.equals(that.id) : that.id != null) return false; - return filterBoardId != null ? filterBoardId.equals(that.filterBoardId) : that.filterBoardId == null; + return filterWidgetId != null ? filterWidgetId.equals(that.filterWidgetId) : that.filterWidgetId == null; } @Override public int hashCode() { int result = id != null ? id.hashCode() : 0; - result = 31 * result + (filterBoardId != null ? filterBoardId.hashCode() : 0); + result = 31 * result + (filterWidgetId != null ? filterWidgetId.hashCode() : 0); result = 31 * result + (direction ? 1 : 0); result = 31 * result + criteria; result = 31 * result + ruleOrder; diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/model/widget/filter/FilterWidgetUser.java b/app/src/main/java/it/niedermann/nextcloud/deck/model/widget/filter/FilterWidgetUser.java index 26ce8cf13..9b233241b 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/model/widget/filter/FilterWidgetUser.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/model/widget/filter/FilterWidgetUser.java @@ -9,7 +9,7 @@ import it.niedermann.nextcloud.deck.model.User; @Entity( indices = { - @Index(value = "filterBoardId", name = "idx_FilterWidgetUser_filterBoardId"), + @Index(value = "filterAccountId", name = "idx_FilterWidgetUser_filterAccountId"), @Index(value = "userId", name = "idx_FilterWidgetUser_userId") }, foreignKeys = { @@ -21,7 +21,7 @@ import it.niedermann.nextcloud.deck.model.User; @ForeignKey( entity = FilterWidgetBoard.class, parentColumns = "id", - childColumns = "filterBoardId", onDelete = ForeignKey.CASCADE + childColumns = "filterAccountId", onDelete = ForeignKey.CASCADE ) } ) @@ -29,7 +29,7 @@ public class FilterWidgetUser { @PrimaryKey(autoGenerate = true) private Long id; - private Long filterBoardId; + private Long filterAccountId; private Long userId; public Long getId() { @@ -40,12 +40,12 @@ public class FilterWidgetUser { this.id = id; } - public Long getFilterBoardId() { - return filterBoardId; + public Long getFilterAccountId() { + return filterAccountId; } - public void setFilterBoardId(Long filterBoardId) { - this.filterBoardId = filterBoardId; + public void setFilterAccountId(Long filterAccountId) { + this.filterAccountId = filterAccountId; } public Long getUserId() { @@ -64,7 +64,7 @@ public class FilterWidgetUser { FilterWidgetUser that = (FilterWidgetUser) o; if (id != null ? !id.equals(that.id) : that.id != null) return false; - if (filterBoardId != null ? !filterBoardId.equals(that.filterBoardId) : that.filterBoardId != null) + if (filterAccountId != null ? !filterAccountId.equals(that.filterAccountId) : that.filterAccountId != null) return false; return userId != null ? userId.equals(that.userId) : that.userId == null; } @@ -72,7 +72,7 @@ public class FilterWidgetUser { @Override public int hashCode() { int result = id != null ? id.hashCode() : 0; - result = 31 * result + (filterBoardId != null ? filterBoardId.hashCode() : 0); + result = 31 * result + (filterAccountId != null ? filterAccountId.hashCode() : 0); result = 31 * result + (userId != null ? userId.hashCode() : 0); return result; } diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/model/widget/filter/dto/FilterWidgetCard.java b/app/src/main/java/it/niedermann/nextcloud/deck/model/widget/filter/dto/FilterWidgetCard.java new file mode 100644 index 000000000..24e5e6a21 --- /dev/null +++ b/app/src/main/java/it/niedermann/nextcloud/deck/model/widget/filter/dto/FilterWidgetCard.java @@ -0,0 +1,44 @@ +package it.niedermann.nextcloud.deck.model.widget.filter.dto; + +import it.niedermann.nextcloud.deck.model.Board; +import it.niedermann.nextcloud.deck.model.Stack; +import it.niedermann.nextcloud.deck.model.full.FullCard; + +public class FilterWidgetCard { + private FullCard card; + private Stack stack; + private Board board; + + public FilterWidgetCard() { + } + + public FilterWidgetCard(FullCard card, Stack stack, Board board) { + this.card = card; + this.stack = stack; + this.board = board; + } + + public FullCard getCard() { + return card; + } + + public void setCard(FullCard card) { + this.card = card; + } + + public Stack getStack() { + return stack; + } + + public void setStack(Stack stack) { + this.stack = stack; + } + + public Board getBoard() { + return board; + } + + public void setBoard(Board board) { + this.board = board; + } +} diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/SyncManager.java b/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/SyncManager.java index 19c4bd686..84779e478 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/SyncManager.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/SyncManager.java @@ -61,8 +61,10 @@ import it.niedermann.nextcloud.deck.model.ocs.comment.DeckComment; import it.niedermann.nextcloud.deck.model.ocs.comment.OcsComment; import it.niedermann.nextcloud.deck.model.ocs.comment.full.FullDeckComment; import it.niedermann.nextcloud.deck.model.ocs.projects.OcsProjectResource; +import it.niedermann.nextcloud.deck.model.widget.filter.FilterWidget; import it.niedermann.nextcloud.deck.model.widget.filter.FilterWidgetConfiguration; import it.niedermann.nextcloud.deck.model.widget.filter.FilterWidgetData; +import it.niedermann.nextcloud.deck.model.widget.filter.dto.FilterWidgetCard; import it.niedermann.nextcloud.deck.persistence.sync.adapters.ServerAdapter; import it.niedermann.nextcloud.deck.persistence.sync.adapters.db.DataBaseAdapter; import it.niedermann.nextcloud.deck.persistence.sync.adapters.db.util.LiveDataHelper; @@ -1934,6 +1936,57 @@ public class SyncManager { // Widgets // ------------------- + // # filter widget + + @AnyThread + public void createFilterWidget(@NonNull FilterWidget filterWidget, @NonNull IResponseCallback<Long> callback) { + doAsync(() -> { + try { + Long filterWidgetId = dataBaseAdapter.createFilterWidget(filterWidget); + callback.onResponse(filterWidgetId); + } catch (Throwable t) { + callback.onError(t); + } + }); + } + + @AnyThread + public void updateFilterWidget(@NonNull FilterWidget filterWidget, @NonNull IResponseCallback<Boolean> callback) { + doAsync(() -> { + try { + dataBaseAdapter.updateFilterWidget(filterWidget); + callback.onResponse(Boolean.TRUE); + } catch (Throwable t) { + callback.onError(t); + } + }); + } + + @AnyThread + public void deleteFilterWidget(@NonNull Long filterWidgetId, @NonNull IResponseCallback<Boolean> callback) { + doAsync(() -> { + try { + dataBaseAdapter.deleteFilterWidget(filterWidgetId); + callback.onResponse(Boolean.TRUE); + } catch (Throwable t) { + callback.onError(t); + } + }); + } + + @AnyThread + public void getCardsForFilterWidget(@NonNull Long filterWidgetId, @NonNull IResponseCallback<List<FilterWidgetCard>> callback) { + doAsync(() -> { + try { + callback.onResponse(dataBaseAdapter.getCardsForFilterWidget(filterWidgetId)); + } catch (Throwable t) { + callback.onError(t); + } + }); + } + + // # single card widget + /** * Can be called from a configuration screen or a picker. * Creates a new entry in the database, if row with given widgetId does not yet exist. @@ -1982,10 +2035,6 @@ public class SyncManager { throw new UnsupportedOperationException("Not yet implemented"); } - public void deleteFilterWidget(int appWidgetId) { - doAsync(() -> dataBaseAdapter.deleteFilterWidget(appWidgetId)); - } - /** * Returns the payload of the give {@param appWidgetId}. */ diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/adapters/db/DataBaseAdapter.java b/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/adapters/db/DataBaseAdapter.java index e02ce7aab..eecce4d05 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/adapters/db/DataBaseAdapter.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/adapters/db/DataBaseAdapter.java @@ -45,6 +45,9 @@ import it.niedermann.nextcloud.deck.model.ocs.projects.OcsProject; import it.niedermann.nextcloud.deck.model.ocs.projects.OcsProjectResource; import it.niedermann.nextcloud.deck.model.relations.UserInBoard; import it.niedermann.nextcloud.deck.model.relations.UserInGroup; +import it.niedermann.nextcloud.deck.model.widget.filter.FilterWidget; +import it.niedermann.nextcloud.deck.model.widget.filter.FilterWidgetAccount; +import it.niedermann.nextcloud.deck.model.widget.filter.dto.FilterWidgetCard; import it.niedermann.nextcloud.deck.model.widget.singlecard.SingleCardWidgetModel; import it.niedermann.nextcloud.deck.persistence.sync.adapters.db.util.LiveDataHelper; import it.niedermann.nextcloud.deck.persistence.sync.adapters.db.util.WrappedLiveData; @@ -1052,7 +1055,24 @@ public class DataBaseAdapter { return db.getStackWidgetModelDao().getStackWidgetByAppWidgetIdDirectly(appWidgetId); } - public void deleteFilterWidget(int appWidgetId) { + public Long createFilterWidget(FilterWidget filterWidget) { + long widgetId = db.getFilterWidgetDao().insert(filterWidget); + for (FilterWidgetAccount account : filterWidget.getAccounts()) { + } + return widgetId; + } + + public void deleteFilterWidget(Long filterWidgetId) { + // TODO + throw new UnsupportedOperationException("Not yet implemented"); + } + + public void updateFilterWidget(FilterWidget filterWidget) { + // TODO + throw new UnsupportedOperationException("Not yet implemented"); + } + + public List<FilterWidgetCard> getCardsForFilterWidget(Long filterWidgetId) { // TODO throw new UnsupportedOperationException("Not yet implemented"); } diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/adapters/db/DeckDatabase.java b/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/adapters/db/DeckDatabase.java index 69b2abd1d..1fbcf42af 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/adapters/db/DeckDatabase.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/adapters/db/DeckDatabase.java @@ -425,25 +425,25 @@ public abstract class DeckDatabase extends RoomDatabase { database.execSQL("CREATE TABLE `FilterWidget` (`id` INTEGER PRIMARY KEY AUTOINCREMENT)"); database.execSQL("CREATE TABLE `FilterWidgetAccount` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `filterWidgetId` INTEGER, `accountId` INTEGER, FOREIGN KEY(`accountId`) REFERENCES `Account`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`filterWidgetId`) REFERENCES `FilterWidget`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )"); database.execSQL("CREATE TABLE `FilterWidgetBoard` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `filterAccountId` INTEGER, `boardId` INTEGER, FOREIGN KEY(`boardId`) REFERENCES `Board`(`localId`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`filterAccountId`) REFERENCES `FilterWidgetAccount`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )"); - database.execSQL("CREATE TABLE `FilterWidgetDue` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `filterBoardId` INTEGER, `dueType` INTEGER NOT NULL, FOREIGN KEY(`filterBoardId`) REFERENCES `FilterWidgetBoard`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )"); + database.execSQL("CREATE TABLE `FilterWidgetDue` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `filterWidgetId` INTEGER, `dueType` INTEGER NOT NULL, FOREIGN KEY(`filterWidgetId`) REFERENCES `FilterWidget`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )"); database.execSQL("CREATE TABLE `FilterWidgetLabel` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `filterBoardId` INTEGER, `labelId` INTEGER, FOREIGN KEY(`labelId`) REFERENCES `Label`(`localId`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`filterBoardId`) REFERENCES `FilterWidgetBoard`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )"); - database.execSQL("CREATE TABLE `FilterWidgetSort` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `filterBoardId` INTEGER, `direction` INTEGER NOT NULL, `criteria` INTEGER NOT NULL, `ruleOrder` INTEGER NOT NULL, FOREIGN KEY(`filterBoardId`) REFERENCES `FilterWidgetBoard`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )"); + database.execSQL("CREATE TABLE `FilterWidgetSort` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `filterBoardId` INTEGER, `direction` INTEGER NOT NULL, `criteria` INTEGER NOT NULL, `ruleOrder` INTEGER NOT NULL, FOREIGN KEY(`filterWidgetId`) REFERENCES `FilterWidget`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )"); database.execSQL("CREATE TABLE `FilterWidgetStack` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `filterBoardId` INTEGER, `stackId` INTEGER, FOREIGN KEY(`stackId`) REFERENCES `Stack`(`localId`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`filterBoardId`) REFERENCES `FilterWidgetBoard`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )"); - database.execSQL("CREATE TABLE `FilterWidgetUser` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `filterBoardId` INTEGER, `userId` INTEGER, FOREIGN KEY(`userId`) REFERENCES `User`(`localId`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`filterBoardId`) REFERENCES `FilterWidgetBoard`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )"); + database.execSQL("CREATE TABLE `FilterWidgetUser` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `filterAccountId` INTEGER, `userId` INTEGER, FOREIGN KEY(`userId`) REFERENCES `User`(`localId`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`filterAccountId`) REFERENCES `FilterWidgetAccount`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )"); database.execSQL("CREATE INDEX `index_FilterWidgetAccount_filterWidgetId` ON `FilterWidgetAccount` (`filterWidgetId`)"); database.execSQL("CREATE INDEX `idx_FilterWidgetAccount_accountId` ON `FilterWidgetAccount` (`accountId`)"); database.execSQL("CREATE INDEX `idx_FilterWidgetBoard_boardId` ON `FilterWidgetBoard` (`boardId`)"); database.execSQL("CREATE INDEX `idx_FilterWidgetBoard_filterAccountId` ON `FilterWidgetBoard` (`filterAccountId`)"); database.execSQL("CREATE INDEX `idx_FilterWidgetLabel_filterBoardId` ON `FilterWidgetLabel` (`filterBoardId`)"); database.execSQL("CREATE INDEX `idx_FilterWidgetLabel_labelId` ON `FilterWidgetLabel` (`labelId`)"); - database.execSQL("CREATE INDEX `idx_FilterWidgetSort_filterBoardId` ON `FilterWidgetSort` (`filterBoardId`)"); + database.execSQL("CREATE INDEX `idx_FilterWidgetSort_filterWidgetId` ON `FilterWidgetSort` (`filterWidgetId`)"); database.execSQL("CREATE INDEX `idx_FilterWidgetStack_filterBoardId` ON `FilterWidgetStack` (`filterBoardId`)"); database.execSQL("CREATE INDEX `idx_FilterWidgetStack_stackId` ON `FilterWidgetStack` (`stackId`)"); - database.execSQL("CREATE INDEX `idx_FilterWidgetUser_filterBoardId` ON `FilterWidgetUser` (`filterBoardId`)"); + database.execSQL("CREATE INDEX `idx_FilterWidgetUser_filterAccountId` ON `FilterWidgetUser` (`filterAccountId`)"); database.execSQL("CREATE INDEX `idx_FilterWidgetUser_userId` ON `FilterWidgetUser` (`userId`)"); - database.execSQL("CREATE UNIQUE INDEX `unique_idx_FilterWidgetDue_filterBoardId` ON `FilterWidgetDue` (`filterBoardId`)"); - database.execSQL("CREATE INDEX `unique_idx_FilterWidgetSort_filterBoardId_criteria` ON `FilterWidgetSort` (`filterBoardId`, `criteria`)"); - database.execSQL("CREATE INDEX `unique_idx_FilterWidgetSort_filterBoardId_ruleOrder` ON `FilterWidgetSort` (`filterBoardId`, `ruleOrder`)"); + database.execSQL("CREATE UNIQUE INDEX `unique_idx_FilterWidgetDue_filterWidgetId` ON `FilterWidgetDue` (`filterWidgetId`)"); + database.execSQL("CREATE INDEX `unique_idx_FilterWidgetSort_filterWidgetId_criteria` ON `FilterWidgetSort` (`filterWidgetId`, `criteria`)"); + database.execSQL("CREATE INDEX `unique_idx_FilterWidgetSort_filterWidgetId_ruleOrder` ON `FilterWidgetSort` (`filterWidgetId`, `ruleOrder`)"); } }; diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/widget/filter/FilterWidget.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/widget/filter/FilterWidget.java index 263ac363e..5fbd1ac33 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/widget/filter/FilterWidget.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/widget/filter/FilterWidget.java @@ -9,6 +9,7 @@ import android.os.Bundle; import java.util.NoSuchElementException; +import it.niedermann.nextcloud.deck.api.IResponseCallback; import it.niedermann.nextcloud.deck.model.Account; import it.niedermann.nextcloud.deck.persistence.sync.SyncManager; @@ -71,7 +72,12 @@ public class FilterWidget extends AppWidgetProvider { final SyncManager syncManager = new SyncManager(context); for (int appWidgetId : appWidgetIds) { - syncManager.deleteFilterWidget(appWidgetId); + syncManager.deleteFilterWidget((long)appWidgetId, new IResponseCallback<Boolean>(null) { + @Override + public void onResponse(Boolean response) { + + } + }); } } |