Refactoring

pull/168/head
M66B 5 years ago
parent e7d3716084
commit 92429f8c5e

@ -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");

@ -195,7 +195,7 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
lbm.sendBroadcast(
new Intent(settings ? ActivitySetup.ACTION_EDIT_ACCOUNT : ActivityView.ACTION_VIEW_FOLDERS)
.putExtra("id", account.id)
.putExtra("pop", account.pop));
.putExtra("protocol", account.protocol));
}
}
@ -216,7 +216,8 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
popupMenu.getMenu().add(Menu.NONE, R.string.title_enabled, 1, R.string.title_enabled)
.setCheckable(true).setChecked(account.synchronize);
if (!account.pop && account.notify && Build.VERSION.SDK_INT >= 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<AdapterAccount.ViewHold
popupMenu.getMenu().add(Menu.NONE, R.string.title_edit_channel, 2, R.string.title_edit_channel);
}
if (!account.pop && settings)
if (account.protocol == EntityAccount.TYPE_IMAP && settings)
popupMenu.getMenu().add(Menu.NONE, R.string.title_copy, 3, R.string.title_copy);
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@ -294,6 +295,7 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
lbm.sendBroadcast(
new Intent(ActivitySetup.ACTION_EDIT_ACCOUNT)
.putExtra("id", account.id)
.putExtra("protocol", account.protocol)
.putExtra("copy", true));
}
});

@ -393,7 +393,7 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
popupMenu.getMenu().add(Menu.NONE, 0, 0, folder.getDisplayName(context)).setEnabled(false);
popupMenu.getMenu().add(Menu.NONE, R.string.title_synchronize_now, 1, R.string.title_synchronize_now);
if (folder.account != null && !folder.accountPop) {
if (folder.account != null && folder.accountProtocol == EntityAccount.TYPE_IMAP) {
popupMenu.getMenu().add(Menu.NONE, R.string.title_synchronize_all, 2, R.string.title_synchronize_all);
popupMenu.getMenu().add(Menu.NONE, R.string.title_delete_local, 3, R.string.title_delete_local);
@ -418,7 +418,7 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
.setCheckable(true).setChecked(folder.notify);
}
if (folder.account != null && !folder.accountPop) {
if (folder.account != null && folder.accountProtocol == EntityAccount.TYPE_IMAP) {
boolean subscriptions = prefs.getBoolean("subscriptions", false);
if (folder.subscribed != null && subscriptions)
popupMenu.getMenu().add(Menu.NONE, R.string.title_subscribe, 9, R.string.title_subscribe)
@ -445,7 +445,7 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
}
}
if (folder.account != null && !folder.accountPop)
if (folder.account != null && folder.accountProtocol == EntityAccount.TYPE_IMAP)
popupMenu.getMenu().add(Menu.NONE, R.string.title_create_sub_folder, 16, R.string.title_create_sub_folder);
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {

@ -707,7 +707,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
view.setAlpha(
(EntityFolder.OUTBOX.equals(message.folderType)
? message.identitySynchronize == null || !message.identitySynchronize
: message.uid == null && !message.accountPop)
: message.uid == null && message.accountProtocol == EntityAccount.TYPE_IMAP)
? Helper.LOW_LIGHT : 1.0f);
// Duplicate
@ -1011,7 +1011,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
ibFlagged.setImageResource(flagged > 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<AdapterMessage.ViewHold
Bundle args = new Bundle();
args.putLong("id", message.id);
args.putBoolean("pop", message.accountPop);
args.putInt("protocol", message.accountProtocol);
new SimpleTask<Void>() {
@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<AdapterMessage.ViewHold
if (message == null)
return null;
if (pop)
if (protocol != EntityAccount.TYPE_IMAP)
EntityOperation.queue(context, message, EntityOperation.SEEN, !message.ui_seen);
else {
List<EntityMessage> messages = db.message().getMessagesByThread(
@ -2230,7 +2230,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
if (account == null)
return null;
if (account.pop)
if (account.protocol != EntityAccount.TYPE_IMAP)
EntityOperation.queue(context, message, EntityOperation.FLAG, flagged);
else {
List<EntityMessage> messages = db.message().getMessagesByThread(
@ -2949,25 +2949,25 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
popupMenu.getMenu().findItem(R.id.menu_unseen).setTitle(message.ui_seen ? R.string.title_unseen : R.string.title_seen);
popupMenu.getMenu().findItem(R.id.menu_unseen).setEnabled(
(message.uid != null && !message.folderReadOnly) || message.accountPop);
(message.uid != null && !message.folderReadOnly) || message.accountProtocol != EntityAccount.TYPE_IMAP);
popupMenu.getMenu().findItem(R.id.menu_hide).setTitle(message.ui_snoozed == null ? R.string.title_hide : R.string.title_unhide);
popupMenu.getMenu().findItem(R.id.menu_flag_color).setEnabled(
(message.uid != null && !message.folderReadOnly) || message.accountPop);
(message.uid != null && !message.folderReadOnly) || message.accountProtocol != EntityAccount.TYPE_IMAP);
popupMenu.getMenu().findItem(R.id.menu_copy).setEnabled(message.uid != null && !message.folderReadOnly);
popupMenu.getMenu().findItem(R.id.menu_copy).setVisible(!message.accountPop);
popupMenu.getMenu().findItem(R.id.menu_copy).setVisible(message.accountProtocol == EntityAccount.TYPE_IMAP);
popupMenu.getMenu().findItem(R.id.menu_delete).setVisible(!message.accountPop);
popupMenu.getMenu().findItem(R.id.menu_delete).setVisible(message.accountProtocol == EntityAccount.TYPE_IMAP);
popupMenu.getMenu().findItem(R.id.menu_resync).setEnabled(message.uid != null);
popupMenu.getMenu().findItem(R.id.menu_resync).setVisible(!message.accountPop);
popupMenu.getMenu().findItem(R.id.menu_resync).setVisible(message.accountProtocol == EntityAccount.TYPE_IMAP);
popupMenu.getMenu().findItem(R.id.menu_create_rule).setVisible(!message.accountPop);
popupMenu.getMenu().findItem(R.id.menu_create_rule).setVisible(message.accountProtocol == EntityAccount.TYPE_IMAP);
popupMenu.getMenu().findItem(R.id.menu_manage_keywords).setEnabled(message.uid != null && !message.folderReadOnly);
popupMenu.getMenu().findItem(R.id.menu_manage_keywords).setVisible(!message.accountPop);
popupMenu.getMenu().findItem(R.id.menu_manage_keywords).setVisible(message.accountProtocol == EntityAccount.TYPE_IMAP);
popupMenu.getMenu().findItem(R.id.menu_junk).setEnabled(message.uid != null && !message.folderReadOnly);
popupMenu.getMenu().findItem(R.id.menu_junk).setVisible(hasJunk && !EntityFolder.JUNK.equals(message.folderType));
@ -2978,7 +2978,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
popupMenu.getMenu().findItem(R.id.menu_show_headers).setChecked(show_headers);
popupMenu.getMenu().findItem(R.id.menu_show_headers).setEnabled(message.uid != null);
popupMenu.getMenu().findItem(R.id.menu_show_headers).setVisible(!message.accountPop);
popupMenu.getMenu().findItem(R.id.menu_show_headers).setVisible(message.accountProtocol == EntityAccount.TYPE_IMAP);
popupMenu.getMenu().findItem(R.id.menu_raw_download).setEnabled(
message.uid != null && (message.raw == null || !message.raw));
@ -2987,9 +2987,9 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
popupMenu.getMenu().findItem(R.id.menu_raw_send).setEnabled(
message.uid != null && (message.raw != null && message.raw));
popupMenu.getMenu().findItem(R.id.menu_raw_download).setVisible(!message.accountPop);
popupMenu.getMenu().findItem(R.id.menu_raw_save).setVisible(!message.accountPop);
popupMenu.getMenu().findItem(R.id.menu_raw_send).setVisible(!message.accountPop);
popupMenu.getMenu().findItem(R.id.menu_raw_download).setVisible(message.accountProtocol == EntityAccount.TYPE_IMAP);
popupMenu.getMenu().findItem(R.id.menu_raw_save).setVisible(message.accountProtocol == EntityAccount.TYPE_IMAP);
popupMenu.getMenu().findItem(R.id.menu_raw_send).setVisible(message.accountProtocol == EntityAccount.TYPE_IMAP);
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override

@ -35,7 +35,7 @@ public interface DaoFolder {
List<EntityFolder> 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<TupleFolderSort> 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<List<TupleFolderEx>> 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<Integer> 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" +

@ -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<EntityMessage> 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" +

@ -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 &&

@ -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();

@ -831,11 +831,11 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
if (aid < 0) {
List<EntityAccount> 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<EntityMessage> 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

@ -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;

@ -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();
}
});

@ -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)

@ -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<EntityFolder, IMAPFolder> 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 {

@ -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 &&

@ -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 &&

@ -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());

Loading…
Cancel
Save