mirror of https://github.com/M66B/FairEmail.git
Added folder subtype flagged
This commit is contained in:
parent
41e9935c88
commit
cbebeb29d2
File diff suppressed because it is too large
Load Diff
|
@ -377,7 +377,8 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
|
||||||
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))
|
(folder.inherited_type == null || !(BuildConfig.DEBUG || EntityFolder.SENT.equals(folder.inherited_type))
|
||||||
? ""
|
? ""
|
||||||
: "/" + EntityFolder.localizeType(context, folder.inherited_type)));
|
: "/" + EntityFolder.localizeType(context, folder.inherited_type)) +
|
||||||
|
(EntityFolder.FLAGGED.equals(folder.subtype) ? "*" : ""));
|
||||||
|
|
||||||
tvTotal.setText(folder.total == null ? null : NF.format(folder.total));
|
tvTotal.setText(folder.total == null ? null : NF.format(folder.total));
|
||||||
|
|
||||||
|
|
|
@ -750,7 +750,8 @@ class Core {
|
||||||
if (MessageHelper.isRemoved(ex)) {
|
if (MessageHelper.isRemoved(ex)) {
|
||||||
if (message != null &&
|
if (message != null &&
|
||||||
!EntityOperation.SEEN.equals(op.name) &&
|
!EntityOperation.SEEN.equals(op.name) &&
|
||||||
!EntityOperation.FLAG.equals(op.name))
|
(!EntityOperation.FLAG.equals(op.name) ||
|
||||||
|
EntityFolder.FLAGGED.equals(folder.subtype)))
|
||||||
db.message().deleteMessage(message.id);
|
db.message().deleteMessage(message.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2742,6 +2743,7 @@ class Core {
|
||||||
|
|
||||||
String[] attrs = ((IMAPFolder) ifolder.second).getAttributes();
|
String[] attrs = ((IMAPFolder) ifolder.second).getAttributes();
|
||||||
String type = EntityFolder.getType(attrs, fullName, false);
|
String type = EntityFolder.getType(attrs, fullName, false);
|
||||||
|
String subtype = EntityFolder.getSubtype(attrs, fullName);
|
||||||
boolean subscribed = subscription.contains(fullName);
|
boolean subscribed = subscription.contains(fullName);
|
||||||
|
|
||||||
boolean selectable = true;
|
boolean selectable = true;
|
||||||
|
@ -2758,7 +2760,7 @@ class Core {
|
||||||
if (EntityFolder.INBOX.equals(type))
|
if (EntityFolder.INBOX.equals(type))
|
||||||
selectable = true;
|
selectable = true;
|
||||||
|
|
||||||
Log.i(account.name + ":" + fullName + " type=" + type +
|
Log.i(account.name + ":" + fullName + " type=" + type + ":" + subtype +
|
||||||
" subscribed=" + subscribed +
|
" subscribed=" + subscribed +
|
||||||
" selectable=" + selectable +
|
" selectable=" + selectable +
|
||||||
" inferiors=" + inferiors +
|
" inferiors=" + inferiors +
|
||||||
|
@ -2791,6 +2793,7 @@ class Core {
|
||||||
folder.separator = separator;
|
folder.separator = separator;
|
||||||
folder.name = fullName;
|
folder.name = fullName;
|
||||||
folder.type = type;
|
folder.type = type;
|
||||||
|
folder.subtype = type;
|
||||||
folder.subscribed = subscribed;
|
folder.subscribed = subscribed;
|
||||||
folder.selectable = selectable;
|
folder.selectable = selectable;
|
||||||
folder.inferiors = inferiors;
|
folder.inferiors = inferiors;
|
||||||
|
@ -2829,6 +2832,7 @@ class Core {
|
||||||
if (db.folder().getFolderByType(folder.account, EntityFolder.INBOX) == null)
|
if (db.folder().getFolderByType(folder.account, EntityFolder.INBOX) == null)
|
||||||
db.folder().setFolderType(folder.id, type);
|
db.folder().setFolderType(folder.id, type);
|
||||||
}
|
}
|
||||||
|
db.folder().setFolderSubtype(folder.id, subtype);
|
||||||
}
|
}
|
||||||
|
|
||||||
db.setTransactionSuccessful();
|
db.setTransactionSuccessful();
|
||||||
|
|
|
@ -68,7 +68,7 @@ import javax.mail.internet.InternetAddress;
|
||||||
// https://developer.android.com/topic/libraries/architecture/room.html
|
// https://developer.android.com/topic/libraries/architecture/room.html
|
||||||
|
|
||||||
@Database(
|
@Database(
|
||||||
version = 261,
|
version = 262,
|
||||||
entities = {
|
entities = {
|
||||||
EntityIdentity.class,
|
EntityIdentity.class,
|
||||||
EntityAccount.class,
|
EntityAccount.class,
|
||||||
|
@ -2649,6 +2649,12 @@ public abstract class DB extends RoomDatabase {
|
||||||
public void migrate(@NonNull SupportSQLiteDatabase db) {
|
public void migrate(@NonNull SupportSQLiteDatabase db) {
|
||||||
logMigration(startVersion, endVersion);
|
logMigration(startVersion, endVersion);
|
||||||
}
|
}
|
||||||
|
}).addMigrations(new Migration(261, 262) {
|
||||||
|
@Override
|
||||||
|
public void migrate(@NonNull SupportSQLiteDatabase db) {
|
||||||
|
logMigration(startVersion, endVersion);
|
||||||
|
db.execSQL("ALTER TABLE `folder` ADD COLUMN `subtype` TEXT");
|
||||||
|
}
|
||||||
}).addMigrations(new Migration(998, 999) {
|
}).addMigrations(new Migration(998, 999) {
|
||||||
@Override
|
@Override
|
||||||
public void migrate(@NonNull SupportSQLiteDatabase db) {
|
public void migrate(@NonNull SupportSQLiteDatabase db) {
|
||||||
|
|
|
@ -304,6 +304,9 @@ public interface DaoFolder {
|
||||||
@Query("UPDATE folder SET inherited_type = :type WHERE id = :id AND NOT (inherited_type IS :type)")
|
@Query("UPDATE folder SET inherited_type = :type WHERE id = :id AND NOT (inherited_type IS :type)")
|
||||||
int setFolderInheritedType(long id, String type);
|
int setFolderInheritedType(long id, String type);
|
||||||
|
|
||||||
|
@Query("UPDATE folder SET subtype = :subtype WHERE id = :id AND NOT (subtype IS :subtype)")
|
||||||
|
int setFolderSubtype(long id, String subtype);
|
||||||
|
|
||||||
@Query("UPDATE folder SET `order` = :order WHERE id = :id AND NOT (`order` IS :order)")
|
@Query("UPDATE folder SET `order` = :order WHERE id = :id AND NOT (`order` IS :order)")
|
||||||
int setFolderOrder(long id, Integer order);
|
int setFolderOrder(long id, Integer order);
|
||||||
|
|
||||||
|
|
|
@ -78,6 +78,7 @@ public class EntityFolder extends EntityOrder implements Serializable {
|
||||||
@NonNull
|
@NonNull
|
||||||
public String type;
|
public String type;
|
||||||
public String inherited_type;
|
public String inherited_type;
|
||||||
|
public String subtype;
|
||||||
@NonNull
|
@NonNull
|
||||||
public Integer level = 0; // obsolete
|
public Integer level = 0; // obsolete
|
||||||
@NonNull
|
@NonNull
|
||||||
|
@ -157,6 +158,8 @@ public class EntityFolder extends EntityOrder implements Serializable {
|
||||||
static final String SYSTEM = "System";
|
static final String SYSTEM = "System";
|
||||||
static final String USER = "User";
|
static final String USER = "User";
|
||||||
|
|
||||||
|
static final String FLAGGED = "flagged";
|
||||||
|
|
||||||
// https://tools.ietf.org/html/rfc6154
|
// https://tools.ietf.org/html/rfc6154
|
||||||
// https://www.iana.org/assignments/imap-mailbox-name-attributes/imap-mailbox-name-attributes.xhtml
|
// https://www.iana.org/assignments/imap-mailbox-name-attributes/imap-mailbox-name-attributes.xhtml
|
||||||
private static final List<String> SYSTEM_FOLDER_ATTR = Collections.unmodifiableList(Arrays.asList(
|
private static final List<String> SYSTEM_FOLDER_ATTR = Collections.unmodifiableList(Arrays.asList(
|
||||||
|
@ -507,6 +510,13 @@ public class EntityFolder extends EntityOrder implements Serializable {
|
||||||
return USER;
|
return USER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static String getSubtype(String[] attrs, String fullname) {
|
||||||
|
for (String attr : attrs)
|
||||||
|
if ("\\Flagged".equals(attr)) // Gmail
|
||||||
|
return FLAGGED;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
private static class TypeScore {
|
private static class TypeScore {
|
||||||
@NonNull
|
@NonNull
|
||||||
private String type;
|
private String type;
|
||||||
|
|
Loading…
Reference in New Issue