Added inherited folder type

This commit is contained in:
M66B 2022-08-07 15:27:17 +02:00
parent 9fabfaf978
commit af74fe7744
11 changed files with 2833 additions and 13 deletions

File diff suppressed because it is too large Load Diff

View File

@ -364,7 +364,10 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
if (account < 0 && !primary)
tvType.setText(folder.accountName);
else
tvType.setText(EntityFolder.localizeType(context, folder.type));
tvType.setText(EntityFolder.localizeType(context, folder.type) +
(folder.inherited_type == null || !(BuildConfig.DEBUG || EntityFolder.SENT.equals(folder.inherited_type))
? ""
: "/" + EntityFolder.localizeType(context, folder.inherited_type)));
tvTotal.setText(folder.total == null ? null : NF.format(folder.total));

View File

@ -3794,7 +3794,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
}
private boolean isOutgoing(TupleMessageEx message) {
if (EntityFolder.isOutgoing(message.folderType))
if (EntityFolder.isOutgoing(message.folderType) || EntityFolder.isOutgoing(message.folderInheritedType))
return true;
else {
if (message.identityEmail == null)

View File

@ -2627,7 +2627,7 @@ class Core {
nameFolder.put(folder.name, folder);
String parentName = folder.getParentName();
if (!parentFolders.containsKey(parentName))
parentFolders.put(parentName, new ArrayList<EntityFolder>());
parentFolders.put(parentName, new ArrayList<>());
parentFolders.get(parentName).add(folder);
}
}
@ -2657,8 +2657,18 @@ class Core {
Log.i("Updating folders parents=" + parentFolders.size());
for (String parentName : parentFolders.keySet()) {
EntityFolder parent = nameFolder.get(parentName);
for (EntityFolder child : parentFolders.get(parentName))
for (EntityFolder child : parentFolders.get(parentName)) {
String rootType = null;
EntityFolder r = parent;
while (r != null) {
if (!r.selectable)
break;
rootType = r.type;
r = nameFolder.get(r.getParentName());
}
db.folder().setFolderInheritedType(child.id, rootType);
db.folder().setFolderParent(child.id, parent == null ? null : parent.id);
}
}
Log.i("Delete local count=" + local.size());

View File

@ -71,7 +71,7 @@ import io.requery.android.database.sqlite.SQLiteDatabase;
// https://developer.android.com/topic/libraries/architecture/room.html
@Database(
version = 240,
version = 241,
entities = {
EntityIdentity.class,
EntityAccount.class,
@ -1615,7 +1615,7 @@ public abstract class DB extends RoomDatabase {
logMigration(startVersion, endVersion);
//db.execSQL("CREATE VIEW IF NOT EXISTS `account_view` AS " + TupleAccountView.query);
//db.execSQL("CREATE VIEW IF NOT EXISTS `identity_view` AS " + TupleIdentityView.query);
db.execSQL("CREATE VIEW IF NOT EXISTS `folder_view` AS " + TupleFolderView.query);
//db.execSQL("CREATE VIEW IF NOT EXISTS `folder_view` AS " + TupleFolderView.query);
}
})
.addMigrations(new Migration(135, 136) {
@ -2410,6 +2410,14 @@ public abstract class DB extends RoomDatabase {
logMigration(startVersion, endVersion);
db.execSQL("ALTER TABLE `search` ADD COLUMN `order` INTEGER");
}
}).addMigrations(new Migration(240, 241) {
@Override
public void migrate(@NonNull SupportSQLiteDatabase db) {
logMigration(startVersion, endVersion);
db.execSQL("ALTER TABLE `folder` ADD COLUMN `inherited_type` TEXT");
db.execSQL("DROP VIEW `folder_view`");
db.execSQL("CREATE VIEW IF NOT EXISTS `folder_view` AS " + TupleFolderView.query);
}
}).addMigrations(new Migration(998, 999) {
@Override
public void migrate(@NonNull SupportSQLiteDatabase db) {

View File

@ -300,6 +300,9 @@ public interface DaoFolder {
@Query("UPDATE folder SET type = :type WHERE id = :id AND NOT (type IS :type)")
int setFolderType(long id, String type);
@Query("UPDATE folder SET inherited_type = :type WHERE id = :id AND NOT (inherited_type IS :type)")
int setFolderInheritedType(long id, String type);
@Query("UPDATE folder SET `order` = :order WHERE id = :id AND NOT (`order` IS :order)")
int setFolderOrder(long id, Integer order);

View File

@ -49,7 +49,7 @@ public interface DaoMessage {
@Query("SELECT message.*" +
", account.pop AS accountProtocol, account.name AS accountName, account.category AS accountCategory, COALESCE(identity.color, folder.color, account.color) AS accountColor" +
", account.notify AS accountNotify, account.leave_deleted AS accountLeaveDeleted, account.auto_seen AS accountAutoSeen" +
", folder.name AS folderName, folder.color AS folderColor, folder.display AS folderDisplay, folder.type AS folderType, folder.unified AS folderUnified, folder.read_only AS folderReadOnly" +
", folder.name AS folderName, folder.color AS folderColor, folder.display AS folderDisplay, folder.type AS folderType, folder.inherited_type AS folderInheritedType, folder.unified AS folderUnified, folder.read_only AS folderReadOnly" +
", IFNULL(identity.display, identity.name) AS identityName, identity.email AS identityEmail, identity.color AS identityColor, identity.synchronize AS identitySynchronize" +
", '[' || group_concat(message.`from`, ',') || ']' AS senders" +
", '[' || group_concat(message.`to`, ',') || ']' AS recipients" +
@ -128,7 +128,7 @@ public interface DaoMessage {
@Query("SELECT message.*" +
", account.pop AS accountProtocol, account.name AS accountName, account.category AS accountCategory, COALESCE(identity.color, folder.color, account.color) AS accountColor" +
", account.notify AS accountNotify, account.leave_deleted AS accountLeaveDeleted, account.auto_seen AS accountAutoSeen" +
", folder.name AS folderName, folder.color AS folderColor, folder.display AS folderDisplay, folder.type AS folderType, folder.unified AS folderUnified, folder.read_only AS folderReadOnly" +
", folder.name AS folderName, folder.color AS folderColor, folder.display AS folderDisplay, folder.type AS folderType, folder.inherited_type AS folderInheritedType, folder.unified AS folderUnified, folder.read_only AS folderReadOnly" +
", IFNULL(identity.display, identity.name) AS identityName, identity.email AS identityEmail, identity.color AS identityColor, identity.synchronize AS identitySynchronize" +
", '[' || group_concat(message.`from`, ',') || ']' AS senders" +
", '[' || group_concat(message.`to`, ',') || ']' AS recipients" +
@ -200,7 +200,7 @@ public interface DaoMessage {
@Query("SELECT message.*" +
", account.pop AS accountProtocol, account.name AS accountName, account.category AS accountCategory, COALESCE(identity.color, folder.color, account.color) AS accountColor" +
", account.notify AS accountNotify, account.leave_deleted AS accountLeaveDeleted, account.auto_seen AS accountAutoSeen" +
", folder.name AS folderName, folder.color AS folderColor, folder.display AS folderDisplay, folder.type AS folderType, folder.unified AS folderUnified, folder.read_only AS folderReadOnly" +
", folder.name AS folderName, folder.color AS folderColor, folder.display AS folderDisplay, folder.type AS folderType, folder.inherited_type AS folderInheritedType, folder.unified AS folderUnified, folder.read_only AS folderReadOnly" +
", IFNULL(identity.display, identity.name) AS identityName, identity.email AS identityEmail, identity.color AS identityColor, identity.synchronize AS identitySynchronize" +
", message.`from` AS senders" +
", message.`to` AS recipients" +
@ -487,7 +487,7 @@ public interface DaoMessage {
@Query("SELECT message.*" +
", account.pop AS accountProtocol, account.name AS accountName, account.category AS accountCategory, identity.color AS accountColor" +
", account.notify AS accountNotify, account.leave_deleted AS accountLeaveDeleted, account.auto_seen AS accountAutoSeen" +
", folder.name AS folderName, folder.color AS folderColor, folder.display AS folderDisplay, folder.type AS folderType, folder.unified AS folderUnified, folder.read_only AS folderReadOnly" +
", folder.name AS folderName, folder.color AS folderColor, folder.display AS folderDisplay, folder.type AS folderType, folder.inherited_type AS folderInheritedType, folder.unified AS folderUnified, folder.read_only AS folderReadOnly" +
", IFNULL(identity.display, identity.name) AS identityName, identity.email AS identityEmail, identity.color AS identityColor, identity.synchronize AS identitySynchronize" +
", message.`from` AS senders" +
", message.`to` AS recipients" +
@ -518,7 +518,7 @@ public interface DaoMessage {
@Query("SELECT message.*" +
", account.pop AS accountProtocol, account.name AS accountName, account.category AS accountCategory, COALESCE(identity.color, folder.color, account.color) AS accountColor" +
", account.notify AS accountNotify, account.leave_deleted AS accountLeaveDeleted, account.auto_seen AS accountAutoSeen" +
", folder.name AS folderName, folder.color AS folderColor, folder.display AS folderDisplay, folder.type AS folderType, folder.unified AS folderUnified, folder.read_only AS folderReadOnly" +
", folder.name AS folderName, folder.color AS folderColor, folder.display AS folderDisplay, folder.type AS folderType, folder.inherited_type AS folderInheritedType, folder.unified AS folderUnified, folder.read_only AS folderReadOnly" +
", IFNULL(identity.display, identity.name) AS identityName, identity.email AS identityEmail, identity.color AS identityColor, identity.synchronize AS identitySynchronize" +
", message.`from` AS senders" +
", message.`to` AS recipients" +

View File

@ -77,6 +77,7 @@ public class EntityFolder extends EntityOrder implements Serializable {
public String name;
@NonNull
public String type;
public String inherited_type;
@NonNull
public Integer level = 0; // obsolete
@NonNull

View File

@ -2301,7 +2301,8 @@ public class Log {
if (folder.synchronize) {
int unseen = db.message().countUnseen(folder.id);
int notifying = db.message().countNotifying(folder.id);
size += write(os, "- " + folder.name + " " + folder.type +
size += write(os, "- " + folder.name + " " +
folder.type + (folder.inherited_type == null ? "" : "/" + folder.inherited_type) +
(folder.unified ? " unified" : "") +
(folder.notify ? " notify" : "") +
" poll=" + folder.poll + "/" + folder.poll_factor +
@ -2375,6 +2376,7 @@ public class Log {
Collections.sort(folders, folders.get(0).getComparator(context));
for (EntityFolder folder : folders) {
JSONObject jfolder = folder.toJSON();
jfolder.put("inherited_type", folder.inherited_type);
jfolder.put("level", folder.level);
jfolder.put("total", folder.total);
jfolder.put("initialize", folder.initialize);

View File

@ -30,7 +30,7 @@ import java.util.Objects;
value = TupleFolderView.query
)
public class TupleFolderView {
static final String query = "SELECT id, account, name, type, display, color, unified, notify, read_only FROM folder";
static final String query = "SELECT id, account, name, type, inherited_type, display, color, unified, notify, read_only FROM folder";
@NonNull
public Long id;
@ -39,6 +39,7 @@ public class TupleFolderView {
public String name;
@NonNull
public String type;
public String inherited_type;
public String display;
public Integer color;
@NonNull
@ -56,6 +57,7 @@ public class TupleFolderView {
Objects.equals(this.account, other.account) &&
this.name.equals(other.name) &&
this.type.equals(other.type) &&
Objects.equals(this.inherited_type, other.inherited_type) &&
Objects.equals(this.display, other.display) &&
Objects.equals(this.color, other.color) &&
this.unified == other.unified &&

View File

@ -45,6 +45,7 @@ public class TupleMessageEx extends EntityMessage {
public Integer folderColor;
public String folderDisplay;
public String folderType;
public String folderInheritedType;
public boolean folderUnified;
public boolean folderReadOnly;
public String identityName;
@ -150,6 +151,7 @@ public class TupleMessageEx extends EntityMessage {
this.folderName.equals(other.folderName) &&
Objects.equals(this.folderDisplay, other.folderDisplay) &&
this.folderType.equals(other.folderType) &&
Objects.equals(this.folderInheritedType, other.folderInheritedType) &&
this.folderUnified == other.folderUnified &&
this.folderReadOnly == other.folderReadOnly &&
Objects.equals(this.identityName, other.identityName) &&