From 92429f8c5ed54c457cf43198e25459c0519c78ff Mon Sep 17 00:00:00 2001 From: M66B Date: Sat, 23 Nov 2019 13:48:59 +0100 Subject: [PATCH] Refactoring --- .../java/eu/faircode/email/ActivitySetup.java | 14 ++++++-- .../eu/faircode/email/AdapterAccount.java | 8 +++-- .../java/eu/faircode/email/AdapterFolder.java | 6 ++-- .../eu/faircode/email/AdapterMessage.java | 34 +++++++++---------- .../java/eu/faircode/email/DaoFolder.java | 10 +++--- .../java/eu/faircode/email/DaoMessage.java | 12 +++---- .../java/eu/faircode/email/EntityAccount.java | 26 ++++++++++---- .../eu/faircode/email/FragmentFolders.java | 2 +- .../eu/faircode/email/FragmentMessages.java | 27 ++++++++------- .../java/eu/faircode/email/FragmentPop.java | 2 +- .../eu/faircode/email/FragmentReview.java | 2 +- .../email/SelectionPredicateMessage.java | 4 +-- .../eu/faircode/email/ServiceSynchronize.java | 6 ++-- .../java/eu/faircode/email/TupleFolderEx.java | 4 +-- .../eu/faircode/email/TupleMessageEx.java | 4 +-- .../eu/faircode/email/ViewModelMessages.java | 3 +- 16 files changed, 96 insertions(+), 68 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/ActivitySetup.java b/app/src/main/java/eu/faircode/email/ActivitySetup.java index 148915cc73..f547b0cef1 100644 --- a/app/src/main/java/eu/faircode/email/ActivitySetup.java +++ b/app/src/main/java/eu/faircode/email/ActivitySetup.java @@ -1269,8 +1269,18 @@ public class ActivitySetup extends ActivityBase implements FragmentManager.OnBac } private void onEditAccount(Intent intent) { - boolean pop = intent.getBooleanExtra("pop", false); - FragmentBase fragment = pop ? new FragmentPop() : new FragmentAccount(); + int protocol = intent.getIntExtra("protocol", EntityAccount.TYPE_IMAP); + FragmentBase fragment; + switch (protocol) { + case EntityAccount.TYPE_IMAP: + fragment = new FragmentAccount(); + break; + case EntityAccount.TYPE_POP: + fragment = new FragmentPop(); + break; + default: + throw new IllegalArgumentException("Unknown protocol=" + protocol); + } fragment.setArguments(intent.getExtras()); FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction(); fragmentTransaction.replace(R.id.content_frame, fragment).addToBackStack("account"); diff --git a/app/src/main/java/eu/faircode/email/AdapterAccount.java b/app/src/main/java/eu/faircode/email/AdapterAccount.java index a19fd95d53..e24225c5e9 100644 --- a/app/src/main/java/eu/faircode/email/AdapterAccount.java +++ b/app/src/main/java/eu/faircode/email/AdapterAccount.java @@ -195,7 +195,7 @@ public class AdapterAccount extends RecyclerView.Adapter= Build.VERSION_CODES.O) { + if (account.protocol == EntityAccount.TYPE_IMAP && account.notify && + Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { String channelId = EntityAccount.getNotificationChannelId(account.id); NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); NotificationChannel channel = nm.getNotificationChannel(channelId); @@ -224,7 +225,7 @@ public class AdapterAccount extends RecyclerView.Adapter 0 ? R.drawable.baseline_star_24 : R.drawable.baseline_star_border_24); ibFlagged.setImageTintList(ColorStateList.valueOf(flagged > 0 ? color : textColorSecondary)); - ibFlagged.setEnabled(message.uid != null || message.accountPop); + ibFlagged.setEnabled(message.uid != null || message.accountProtocol != EntityAccount.TYPE_IMAP); card.setCardBackgroundColor( flags_background && flagged > 0 && !expanded @@ -2051,13 +2051,13 @@ public class AdapterMessage extends RecyclerView.Adapter() { @Override protected Void onExecute(Context context, Bundle args) { long id = args.getLong("id"); - boolean pop = args.getBoolean("pop"); + int protocol = args.getInt("protocol"); DB db = DB.getInstance(context); try { @@ -2067,7 +2067,7 @@ public class AdapterMessage extends RecyclerView.Adapter messages = db.message().getMessagesByThread( @@ -2230,7 +2230,7 @@ public class AdapterMessage extends RecyclerView.Adapter messages = db.message().getMessagesByThread( @@ -2949,25 +2949,25 @@ public class AdapterMessage extends RecyclerView.Adapter getFolders(long account, boolean writable, boolean selectable); @Query("SELECT folder.*" + - ", account.id AS accountId, account.pop AS accountPop, account.`order` AS accountOrder" + + ", account.id AS accountId, account.pop AS accountProtocol, account.`order` AS accountOrder" + ", account.name AS accountName, account.state AS accountState" + ", COUNT(DISTINCT CASE WHEN rule.enabled THEN rule.id ELSE NULL END) rules" + ", COUNT(DISTINCT CASE WHEN message.ui_hide THEN NULL ELSE message.id END) AS messages" + @@ -61,7 +61,7 @@ public interface DaoFolder { @Query("SELECT folder.* FROM folder" + " JOIN account ON account.id = folder.account" + " WHERE folder.id = :folder" + - " AND (:search OR (account.synchronize AND account.browse AND NOT account.pop))") + " AND (:search OR (account.synchronize AND account.browse AND account.pop = " + EntityAccount.TYPE_IMAP + "))") EntityFolder getBrowsableFolder(long folder, boolean search); @Query("SELECT folder.*" + @@ -72,7 +72,7 @@ public interface DaoFolder { List getSortedFolders(); @Query("SELECT folder.*" + - ", account.id AS accountId, account.pop AS accountPop, account.`order` AS accountOrder" + + ", account.id AS accountId, account.pop AS accountProtocol, account.`order` AS accountOrder" + ", account.name AS accountName, account.state AS accountState" + ", COUNT(DISTINCT CASE WHEN rule.enabled THEN rule.id ELSE NULL END) rules" + ", COUNT(DISTINCT CASE WHEN message.ui_hide THEN NULL ELSE message.id END) AS messages" + @@ -92,7 +92,7 @@ public interface DaoFolder { LiveData> liveFolders(Long account); @Query("SELECT folder.*" + - ", account.id AS accountId, account.pop AS accountPop, account.`order` AS accountOrder" + + ", account.id AS accountId, account.pop AS accountProtocol, account.`order` AS accountOrder" + ", account.name AS accountName, account.state AS accountState" + ", COUNT(DISTINCT CASE WHEN rule.enabled THEN rule.id ELSE NULL END) rules" + ", COUNT(DISTINCT CASE WHEN message.ui_hide THEN NULL ELSE message.id END) AS messages" + @@ -130,7 +130,7 @@ public interface DaoFolder { LiveData liveSynchronizing(); @Query("SELECT folder.*" + - ", account.id AS accountId, account.pop AS accountPop, account.`order` AS accountOrder" + + ", account.id AS accountId, account.pop AS accountProtocol, account.`order` AS accountOrder" + ", account.name AS accountName, account.state AS accountState" + ", COUNT(DISTINCT CASE WHEN rule.enabled THEN rule.id ELSE NULL END) rules" + ", COUNT(DISTINCT CASE WHEN message.ui_hide THEN NULL ELSE message.id END) AS messages" + diff --git a/app/src/main/java/eu/faircode/email/DaoMessage.java b/app/src/main/java/eu/faircode/email/DaoMessage.java index 886f6028fd..dd69bdf7b3 100644 --- a/app/src/main/java/eu/faircode/email/DaoMessage.java +++ b/app/src/main/java/eu/faircode/email/DaoMessage.java @@ -42,7 +42,7 @@ public interface DaoMessage { String is_outbox = "folder.type = '" + EntityFolder.OUTBOX + "'"; @Query("SELECT message.*" + - ", account.pop AS accountPop, account.name AS accountName, COALESCE(identity.color, folder.color, account.color) AS accountColor" + + ", account.pop AS accountProtocol, account.name AS accountName, COALESCE(identity.color, folder.color, account.color) AS accountColor" + ", account.notify AS accountNotify, account.auto_seen AS accountAutoSeen" + ", folder.name AS folderName, folder.display AS folderDisplay, folder.type AS folderType, folder.read_only AS folderReadOnly" + ", identity.name AS identityName, identity.email AS identityEmail, identity.synchronize AS identitySynchronize" + @@ -92,7 +92,7 @@ public interface DaoMessage { boolean debug); @Query("SELECT message.*" + - ", account.pop AS accountPop, account.name AS accountName, COALESCE(identity.color, folder.color, account.color) AS accountColor" + + ", account.pop AS accountProtocol, account.name AS accountName, COALESCE(identity.color, folder.color, account.color) AS accountColor" + ", account.notify AS accountNotify, account.auto_seen AS accountAutoSeen" + ", folder.name AS folderName, folder.display AS folderDisplay, folder.type AS folderType, folder.read_only AS folderReadOnly" + ", identity.name AS identityName, identity.email AS identityEmail, identity.synchronize AS identitySynchronize" + @@ -136,7 +136,7 @@ public interface DaoMessage { boolean debug); @Query("SELECT message.*" + - ", account.pop AS accountPop, account.name AS accountName, COALESCE(identity.color, folder.color, account.color) AS accountColor" + + ", account.pop AS accountProtocol, account.name AS accountName, COALESCE(identity.color, folder.color, account.color) AS accountColor" + ", account.notify AS accountNotify, account.auto_seen AS accountAutoSeen" + ", folder.name AS folderName, folder.display AS folderDisplay, folder.type AS folderType, folder.read_only AS folderReadOnly" + ", identity.name AS identityName, identity.email AS identityEmail, identity.synchronize AS identitySynchronize" + @@ -255,7 +255,7 @@ public interface DaoMessage { " AND thread = :thread" + " AND (:id IS NULL OR message.id = :id)" + " AND (:folder IS NULL OR message.folder = :folder)" + - " AND (NOT uid IS NULL OR account.pop)" + + " AND (NOT uid IS NULL OR account.pop <> " + EntityAccount.TYPE_IMAP + ")" + " AND NOT ui_hide") List getMessagesByThread(long account, String thread, Long id, Long folder); @@ -275,7 +275,7 @@ public interface DaoMessage { int countMessageByMsgId(long folder, String msgid); @Query("SELECT message.*" + - ", account.pop AS accountPop, account.name AS accountName, identity.color AS accountColor" + + ", account.pop AS accountProtocol, account.name AS accountName, identity.color AS accountColor" + ", account.notify AS accountNotify, account.auto_seen AS accountAutoSeen" + ", folder.name AS folderName, folder.display AS folderDisplay, folder.type AS folderType, folder.read_only AS folderReadOnly" + ", identity.name AS identityName, identity.email AS identityEmail, identity.synchronize AS identitySynchronize" + @@ -309,7 +309,7 @@ public interface DaoMessage { TupleMessageStats getUnseenWidget(); @Query("SELECT message.*" + - ", account.pop AS accountPop, account.name AS accountName, COALESCE(identity.color, folder.color, account.color) AS accountColor" + + ", account.pop AS accountProtocol, account.name AS accountName, COALESCE(identity.color, folder.color, account.color) AS accountColor" + ", account.notify AS accountNotify, account.auto_seen AS accountAutoSeen" + ", folder.name AS folderName, folder.display AS folderDisplay, folder.type AS folderType, folder.read_only AS folderReadOnly" + ", identity.name AS identityName, identity.email AS identityEmail, identity.synchronize AS identitySynchronize" + diff --git a/app/src/main/java/eu/faircode/email/EntityAccount.java b/app/src/main/java/eu/faircode/email/EntityAccount.java index 6a0190f429..3f37c13238 100644 --- a/app/src/main/java/eu/faircode/email/EntityAccount.java +++ b/app/src/main/java/eu/faircode/email/EntityAccount.java @@ -28,6 +28,7 @@ import android.os.Build; import androidx.annotation.NonNull; import androidx.annotation.RequiresApi; +import androidx.room.ColumnInfo; import androidx.room.Entity; import androidx.room.PrimaryKey; @@ -52,11 +53,15 @@ public class EntityAccount extends EntityOrder implements Serializable { static final int DEFAULT_KEEP_ALIVE_INTERVAL = 24; // minutes static final int DEFAULT_POLL_INTERVAL = 12; // minutes + static final int TYPE_IMAP = 0; + static final int TYPE_POP = 1; + @PrimaryKey(autoGenerate = true) public Long id; @NonNull - public Boolean pop = false; + @ColumnInfo(name = "pop") + public Integer protocol = TYPE_IMAP; @NonNull public String host; // POP3/IMAP @NonNull @@ -109,7 +114,14 @@ public class EntityAccount extends EntityOrder implements Serializable { public Long last_connected; String getProtocol() { - return (pop ? "pop3" : "imap") + (starttls ? "" : "s"); + switch (protocol) { + case TYPE_IMAP: + return "imap" + (starttls ? "" : "s"); + case TYPE_POP: + return "pop3" + (starttls ? "" : "s"); + default: + throw new IllegalArgumentException("Unknown protocol=" + protocol); + } } static String getNotificationChannelId(long id) { @@ -157,7 +169,7 @@ public class EntityAccount extends EntityOrder implements Serializable { JSONObject json = new JSONObject(); json.put("id", id); json.put("order", order); - json.put("pop", pop); + json.put("protocol", protocol); json.put("host", host); json.put("starttls", starttls); json.put("insecure", insecure); @@ -203,8 +215,10 @@ public class EntityAccount extends EntityOrder implements Serializable { if (json.has("order")) account.order = json.getInt("order"); - if (json.has("pop")) - account.pop = json.getBoolean("pop"); + if (json.has("protocol")) + account.protocol = json.getInt("protocol"); + else if (json.has("pop")) + account.protocol = (json.getBoolean("pop") ? TYPE_POP : TYPE_IMAP); account.host = json.getString("host"); account.starttls = (json.has("starttls") && json.getBoolean("starttls")); @@ -251,7 +265,7 @@ public class EntityAccount extends EntityOrder implements Serializable { if (obj instanceof EntityAccount) { EntityAccount other = (EntityAccount) obj; return (Objects.equals(this.order, other.order) && - this.pop == other.pop && + this.protocol.equals(other.protocol) && this.host.equals(other.host) && this.starttls == other.starttls && this.insecure == other.insecure && diff --git a/app/src/main/java/eu/faircode/email/FragmentFolders.java b/app/src/main/java/eu/faircode/email/FragmentFolders.java index a3a5c3faa2..9ff494f75d 100644 --- a/app/src/main/java/eu/faircode/email/FragmentFolders.java +++ b/app/src/main/java/eu/faircode/email/FragmentFolders.java @@ -279,7 +279,7 @@ public class FragmentFolders extends FragmentBase { else fabError.hide(); - if (account == null || account.pop) + if (account == null || account.protocol != EntityAccount.TYPE_IMAP) fab.hide(); else fab.show(); diff --git a/app/src/main/java/eu/faircode/email/FragmentMessages.java b/app/src/main/java/eu/faircode/email/FragmentMessages.java index 89b7741954..34cee8cd33 100644 --- a/app/src/main/java/eu/faircode/email/FragmentMessages.java +++ b/app/src/main/java/eu/faircode/email/FragmentMessages.java @@ -831,11 +831,11 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. if (aid < 0) { List accounts = db.account().getSynchronizingAccounts(); for (EntityAccount account : accounts) - if (!account.pop) + if (account.protocol == EntityAccount.TYPE_IMAP) result.add(account); } else { EntityAccount account = db.account().getAccount(aid); - if (account != null && !account.pop) + if (account != null && account.protocol == EntityAccount.TYPE_IMAP) result.add(account); } @@ -1381,7 +1381,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. if (EntityFolder.OUTBOX.equals(message.folderType)) return 0; - if (message.accountPop) + if (message.accountProtocol != EntityAccount.TYPE_IMAP) return makeMovementFlags(0, ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT); TupleAccountSwipes swipes = accountSwipes.get(message.account); @@ -1434,7 +1434,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. return; TupleAccountSwipes swipes; - if (message.accountPop) { + if (message.accountProtocol != EntityAccount.TYPE_IMAP) { swipes = new TupleAccountSwipes(); swipes.swipe_right = FragmentAccount.SWIPE_ACTION_SEEN; swipes.swipe_left = 0L; @@ -1517,7 +1517,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. return; } - if (message.accountPop) + if (message.accountProtocol != EntityAccount.TYPE_IMAP) if (direction == ItemTouchHelper.LEFT) { adapter.notifyItemChanged(pos); onSwipeDelete(message); @@ -1568,7 +1568,8 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. return null; TupleMessageEx message = list.get(pos); - if (message == null || (message.uid == null && !message.accountPop)) + if (message == null || + (message.uid == null && message.accountProtocol == EntityAccount.TYPE_IMAP)) return null; if (iProperties.getValue("expanded", message.id)) @@ -1791,7 +1792,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. EntityAccount account = db.account().getAccount(message.account); if (account == null) continue; - if (account.pop) + if (account.protocol != EntityAccount.TYPE_IMAP) pop = true; if (!result.folders.contains(message.folder)) @@ -1820,7 +1821,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. EntityFolder folder = db.folder().getFolder(message.folder); boolean isArchive = EntityFolder.ARCHIVE.equals(folder.type); - boolean isTrash = (EntityFolder.TRASH.equals(folder.type) || account.pop); + boolean isTrash = (EntityFolder.TRASH.equals(folder.type) || account.protocol != EntityAccount.TYPE_IMAP); boolean isJunk = EntityFolder.JUNK.equals(folder.type); boolean isDrafts = EntityFolder.DRAFTS.equals(folder.type); @@ -1850,7 +1851,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. result.accounts = new ArrayList<>(); if (!pop) for (EntityAccount account : db.account().getSynchronizingAccounts()) - if (!account.pop) + if (account.protocol == EntityAccount.TYPE_IMAP) result.accounts.add(account); return result; @@ -2186,7 +2187,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. List messages = db.message().getMessagesByThread( message.account, message.thread, threading ? null : id, message.folder); for (EntityMessage threaded : messages) - if (message.uid != null || account.pop) + if (message.uid != null || account.protocol != EntityAccount.TYPE_IMAP) ids.add(threaded.id); } @@ -3306,7 +3307,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. if (expand != null && (expand.content || unmetered || (expand.size != null && expand.size < download))) { // Prevent flicker - if (expand.accountPop || + if (expand.accountProtocol != EntityAccount.TYPE_IMAP || (expand.accountAutoSeen && !expand.ui_seen && !expand.folderReadOnly)) { expand.unseen = 0; expand.ui_seen = true; @@ -3461,7 +3462,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. if (account == null) return null; - if (account.pop) { + if (account.protocol != EntityAccount.TYPE_IMAP) { if (!message.ui_seen) EntityOperation.queue(context, message, EntityOperation.SEEN, true); } else { @@ -4315,7 +4316,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); nm.cancel("send:" + message.identity, 1); } - } else if (message.uid == null && !account.pop) { + } else if (message.uid == null && account.protocol == EntityAccount.TYPE_IMAP) { db.message().deleteMessage(id); db.folder().setFolderError(message.folder, null); } else diff --git a/app/src/main/java/eu/faircode/email/FragmentPop.java b/app/src/main/java/eu/faircode/email/FragmentPop.java index 4d6e4b82f7..b3b75829ea 100644 --- a/app/src/main/java/eu/faircode/email/FragmentPop.java +++ b/app/src/main/java/eu/faircode/email/FragmentPop.java @@ -290,7 +290,7 @@ public class FragmentPop extends FragmentBase { if (account == null) account = new EntityAccount(); - account.pop = true; + account.protocol = EntityAccount.TYPE_POP; account.host = host; account.starttls = starttls; account.insecure = insecure; diff --git a/app/src/main/java/eu/faircode/email/FragmentReview.java b/app/src/main/java/eu/faircode/email/FragmentReview.java index e4759d1e3d..db63c7bc02 100644 --- a/app/src/main/java/eu/faircode/email/FragmentReview.java +++ b/app/src/main/java/eu/faircode/email/FragmentReview.java @@ -41,7 +41,7 @@ public class FragmentReview extends FragmentDialogBase { lbm.sendBroadcast( new Intent(ActivitySetup.ACTION_EDIT_ACCOUNT) .putExtra("id", account) - .putExtra("pop", false)); + .putExtra("protocol", EntityAccount.TYPE_IMAP)); dismiss(); } }); diff --git a/app/src/main/java/eu/faircode/email/SelectionPredicateMessage.java b/app/src/main/java/eu/faircode/email/SelectionPredicateMessage.java index e4402cdf72..923be1285b 100644 --- a/app/src/main/java/eu/faircode/email/SelectionPredicateMessage.java +++ b/app/src/main/java/eu/faircode/email/SelectionPredicateMessage.java @@ -46,7 +46,7 @@ public class SelectionPredicateMessage extends SelectionTracker.SelectionPredica if (message == null) // happens when restoring state return true; - if (message.accountPop) + if (message.accountProtocol != EntityAccount.TYPE_IMAP) return true; if (message.uid != null && !message.folderReadOnly) @@ -65,7 +65,7 @@ public class SelectionPredicateMessage extends SelectionTracker.SelectionPredica if (message == null) // happens when restoring state return true; - if (message.accountPop) + if (message.accountProtocol != EntityAccount.TYPE_IMAP) return true; if (message.uid != null && !message.folderReadOnly) diff --git a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java index 62cdac8976..56aa715fee 100644 --- a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java +++ b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java @@ -705,7 +705,7 @@ public class ServiceSynchronize extends ServiceBase { this, account.getProtocol(), account.realm, account.insecure, false, debug); iservice.setPartialFetch(account.partial_fetch); iservice.setIgnoreBodyStructureSize(account.ignore_size); - if (account.pop) + if (account.protocol != EntityAccount.TYPE_IMAP) iservice.setLeaveOnServer(account.browse); final Map mapFolders = new HashMap<>(); @@ -840,7 +840,7 @@ public class ServiceSynchronize extends ServiceBase { }); // Update folder list - if (!account.pop) + if (account.protocol == EntityAccount.TYPE_IMAP) Core.onSynchronizeFolders(this, account, iservice.getStore(), state); // Open synchronizing folders @@ -1047,7 +1047,7 @@ public class ServiceSynchronize extends ServiceBase { // Get folder Folder ifolder = mapFolders.get(folder); // null when polling - boolean canOpen = (!account.pop || EntityFolder.INBOX.equals(folder.type)); + boolean canOpen = (account.protocol == EntityAccount.TYPE_IMAP || EntityFolder.INBOX.equals(folder.type)); final boolean shouldClose = (ifolder == null && canOpen); try { diff --git a/app/src/main/java/eu/faircode/email/TupleFolderEx.java b/app/src/main/java/eu/faircode/email/TupleFolderEx.java index 48fb8fbeba..616afc8b46 100644 --- a/app/src/main/java/eu/faircode/email/TupleFolderEx.java +++ b/app/src/main/java/eu/faircode/email/TupleFolderEx.java @@ -38,7 +38,7 @@ import java.util.Objects; public class TupleFolderEx extends EntityFolder implements Serializable { public Long accountId; - public Boolean accountPop; + public Integer accountProtocol; public Integer accountOrder; public String accountName; public String accountState; @@ -66,7 +66,7 @@ public class TupleFolderEx extends EntityFolder implements Serializable { TupleFolderEx other = (TupleFolderEx) obj; return (super.equals(obj) && Objects.equals(this.accountId, other.accountId) && - Objects.equals(this.accountPop, other.accountPop) && + Objects.equals(this.accountProtocol, other.accountProtocol) && Objects.equals(this.accountName, other.accountName) && Objects.equals(this.accountState, other.accountState) && this.rules == other.rules && diff --git a/app/src/main/java/eu/faircode/email/TupleMessageEx.java b/app/src/main/java/eu/faircode/email/TupleMessageEx.java index 9cc82697b3..64498472d4 100644 --- a/app/src/main/java/eu/faircode/email/TupleMessageEx.java +++ b/app/src/main/java/eu/faircode/email/TupleMessageEx.java @@ -28,7 +28,7 @@ import java.util.Objects; import javax.mail.Address; public class TupleMessageEx extends EntityMessage { - public boolean accountPop; + public Integer accountProtocol; public String accountName; public Integer accountColor; public boolean accountNotify; @@ -63,7 +63,7 @@ public class TupleMessageEx extends EntityMessage { if (obj instanceof TupleMessageEx) { TupleMessageEx other = (TupleMessageEx) obj; return (super.equals(obj) && - this.accountPop == other.accountPop && + this.accountProtocol.equals(other.accountProtocol) && Objects.equals(this.accountName, other.accountName) && Objects.equals(this.accountColor, other.accountColor) && this.accountNotify == other.accountNotify && diff --git a/app/src/main/java/eu/faircode/email/ViewModelMessages.java b/app/src/main/java/eu/faircode/email/ViewModelMessages.java index 2fba693453..0a5cb5f21e 100644 --- a/app/src/main/java/eu/faircode/email/ViewModelMessages.java +++ b/app/src/main/java/eu/faircode/email/ViewModelMessages.java @@ -277,7 +277,8 @@ public class ViewModelMessages extends ViewModel { int count = ds.countItems(); for (int i = 0; i < count; i += 100) for (TupleMessageEx message : ds.loadRange(i, Math.min(100, count - i))) - if ((message.uid != null && !message.folderReadOnly) || message.accountPop) + if ((message.uid != null && !message.folderReadOnly) || + message.accountProtocol != EntityAccount.TYPE_IMAP) ids.add(message.id); Log.i("Loaded messages #" + ids.size());