Store folder is subscribed

pull/155/head
M66B 5 years ago
parent c36e8c5438
commit a1750c4cac

File diff suppressed because it is too large Load Diff

@ -704,6 +704,7 @@ class Core {
Map<String, List<EntityFolder>> parentFolders = new HashMap<>();
for (Folder ifolder : ifolders) {
String fullName = ifolder.getFullName();
boolean subscribed = ifolder.isSubscribed();
String[] attr = attrs.get(ifolder);
String type = EntityFolder.getType(attr, fullName);
@ -725,6 +726,7 @@ class Core {
folder.display = display;
folder.type = (EntityFolder.SYSTEM.equals(type) ? type : EntityFolder.USER);
folder.synchronize = false;
folder.subscribed = subscribed;
folder.poll = ("imap.gmail.com".equals(account.host));
folder.sync_days = EntityFolder.DEFAULT_SYNC;
folder.keep_days = EntityFolder.DEFAULT_KEEP;
@ -733,6 +735,9 @@ class Core {
} else {
Log.i(folder.name + " exists type=" + folder.type);
if (folder.subscribed == null || !folder.subscribed.equals(subscribed))
db.folder().setFolderSubscribed(folder.id, subscribed);
if (folder.display == null) {
if (display != null) {
db.folder().setFolderDisplay(folder.id, display);

@ -51,7 +51,7 @@ import io.requery.android.database.sqlite.RequerySQLiteOpenHelperFactory;
// https://developer.android.com/topic/libraries/architecture/room.html
@Database(
version = 73,
version = 74,
entities = {
EntityIdentity.class,
EntityAccount.class,
@ -759,6 +759,13 @@ public abstract class DB extends RoomDatabase {
db.execSQL("ALTER TABLE `account` ADD COLUMN `order` INTEGER");
}
})
.addMigrations(new Migration(73, 74) {
@Override
public void migrate(SupportSQLiteDatabase db) {
Log.i("DB migration from version " + startVersion + " to " + endVersion);
db.execSQL("ALTER TABLE `folder` ADD COLUMN `subscribed` INTEGER");
}
})
.build();
}

@ -155,6 +155,9 @@ public interface DaoFolder {
@Query("UPDATE folder SET error = :error WHERE id = :id")
int setFolderError(long id, String error);
@Query("UPDATE folder SET subscribed = :subscribed WHERE id = :id")
int setFolderSubscribed(long id, Boolean subscribed);
@Query("UPDATE folder SET type = :type WHERE id = :id")
int setFolderType(long id, String type);

@ -76,6 +76,7 @@ public class EntityFolder implements Serializable {
public Boolean poll = false;
@NonNull
public Boolean download = true;
public Boolean subscribed;
@NonNull
public Integer sync_days;
@NonNull
@ -259,6 +260,7 @@ public class EntityFolder implements Serializable {
this.synchronize.equals(other.synchronize) &&
this.poll.equals(other.poll) &&
this.download.equals(other.download) &&
Objects.equals(this.subscribed, other.subscribed) &&
this.sync_days.equals(other.sync_days) &&
this.keep_days.equals(other.keep_days) &&
Objects.equals(this.display, other.display) &&

Loading…
Cancel
Save