From 9515d30d0d491523d45172c5cb750b29424c1b8a Mon Sep 17 00:00:00 2001 From: M66B Date: Sat, 22 Sep 2018 10:29:35 +0000 Subject: [PATCH] Added message about no IDLE support --- .../eu/faircode/email/FragmentAccount.java | 33 +++++++++++++++---- app/src/main/res/layout/fragment_account.xml | 14 +++++++- app/src/main/res/values/strings.xml | 1 + 3 files changed, 40 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentAccount.java b/app/src/main/java/eu/faircode/email/FragmentAccount.java index 1ed9a2d7..767ba483 100644 --- a/app/src/main/java/eu/faircode/email/FragmentAccount.java +++ b/app/src/main/java/eu/faircode/email/FragmentAccount.java @@ -117,6 +117,8 @@ public class FragmentAccount extends FragmentEx { private ProgressBar pbCheck; + private TextView tvIdle; + private ArrayAdapter adapter; private Spinner spDrafts; private Spinner spSent; @@ -183,6 +185,8 @@ public class FragmentAccount extends FragmentEx { btnCheck = view.findViewById(R.id.btnCheck); pbCheck = view.findViewById(R.id.pbCheck); + tvIdle = view.findViewById(R.id.tvIdle); + spDrafts = view.findViewById(R.id.spDrafts); spSent = view.findViewById(R.id.spSent); spAll = view.findViewById(R.id.spAll); @@ -217,6 +221,7 @@ public class FragmentAccount extends FragmentEx { grpAdvanced.setVisibility(View.GONE); btnCheck.setVisibility(position > 0 ? View.VISIBLE : View.GONE); + tvIdle.setVisibility(View.GONE); grpFolders.setVisibility(View.GONE); btnSave.setVisibility(View.GONE); @@ -385,6 +390,7 @@ public class FragmentAccount extends FragmentEx { btnAuthorize.setEnabled(false); btnCheck.setEnabled(false); pbCheck.setVisibility(View.VISIBLE); + tvIdle.setVisibility(View.GONE); grpFolders.setVisibility(View.GONE); btnSave.setVisibility(View.GONE); @@ -398,9 +404,9 @@ public class FragmentAccount extends FragmentEx { args.putString("password", tilPassword.getEditText().getText().toString()); args.putInt("auth_type", authorized == null ? Helper.AUTH_TYPE_PASSWORD : provider.getAuthType()); - new SimpleTask>() { + new SimpleTask() { @Override - protected List onLoad(Context context, Bundle args) throws Throwable { + protected CheckResult onLoad(Context context, Bundle args) throws Throwable { long id = args.getLong("id"); String host = args.getString("host"); String port = args.getString("port"); @@ -417,8 +423,10 @@ public class FragmentAccount extends FragmentEx { if (TextUtils.isEmpty(password)) throw new Throwable(getContext().getString(R.string.title_no_password)); + CheckResult result = new CheckResult(); + result.folders = new ArrayList<>(); + // Check IMAP server / get folders - List folders = new ArrayList<>(); Properties props = MessageHelper.getSessionProperties(auth_type); Session isession = Session.getInstance(props, null); isession.setDebug(true); @@ -438,6 +446,8 @@ public class FragmentAccount extends FragmentEx { if (!istore.hasCapability("UIDPLUS")) throw new MessagingException(getContext().getString(R.string.title_no_uidplus)); + result.idle = istore.hasCapability("IDLE"); + for (Folder ifolder : istore.getDefaultFolder().list("*")) { String type = null; @@ -478,7 +488,7 @@ public class FragmentAccount extends FragmentEx { folder.synchronize = (type != null && EntityFolder.SYSTEM_FOLDER_SYNC.contains(type)); folder.after = (type == null ? EntityFolder.DEFAULT_USER_SYNC : EntityFolder.DEFAULT_SYSTEM_SYNC); } - folders.add(folder); + result.folders.add(folder); Log.i(Helper.TAG, folder.name + " id=" + folder.id + " type=" + folder.type + " attr=" + TextUtils.join(",", attrs)); @@ -490,17 +500,19 @@ public class FragmentAccount extends FragmentEx { istore.close(); } - return folders; + return result; } @Override - protected void onLoaded(Bundle args, List folders) { + protected void onLoaded(Bundle args, CheckResult result) { Helper.setViewsEnabled(view, true); btnAuthorize.setEnabled(true); btnCheck.setEnabled(true); pbCheck.setVisibility(View.GONE); - setFolders(folders); + tvIdle.setVisibility(result.idle ? View.GONE : View.VISIBLE); + + setFolders(result.folders); new Handler().post(new Runnable() { @Override @@ -809,6 +821,8 @@ public class FragmentAccount extends FragmentEx { btnAdvanced.setVisibility(View.GONE); + tvIdle.setVisibility(View.GONE); + btnCheck.setVisibility(View.GONE); pbCheck.setVisibility(View.GONE); @@ -1076,4 +1090,9 @@ public class FragmentAccount extends FragmentEx { grpFolders.setVisibility(View.VISIBLE); btnSave.setVisibility(View.VISIBLE); } + + private class CheckResult { + List folders; + boolean idle; + } } diff --git a/app/src/main/res/layout/fragment_account.xml b/app/src/main/res/layout/fragment_account.xml index 0af1037d..63544fa6 100644 --- a/app/src/main/res/layout/fragment_account.xml +++ b/app/src/main/res/layout/fragment_account.xml @@ -371,6 +371,18 @@ app:layout_constraintEnd_toEndOf="parent" app:layout_constraintTop_toBottomOf="@id/etInterval" /> + + + app:layout_constraintTop_toBottomOf="@id/tvIdle" /> User name missing Password missing Drafts folder missing + This provider does not support push messages. Reception of new messages can be delayed. IMAP UIDPLUS not supported, see the FAQ Delete this account permanently? Delete this identity permanently?