Browse Source

Added message about no IDLE support

main
M66B 6 years ago
parent
commit
9515d30d0d
3 changed files with 40 additions and 8 deletions
  1. +26
    -7
      app/src/main/java/eu/faircode/email/FragmentAccount.java
  2. +13
    -1
      app/src/main/res/layout/fragment_account.xml
  3. +1
    -0
      app/src/main/res/values/strings.xml

+ 26
- 7
app/src/main/java/eu/faircode/email/FragmentAccount.java View File

@ -117,6 +117,8 @@ public class FragmentAccount extends FragmentEx {
private ProgressBar pbCheck; private ProgressBar pbCheck;
private TextView tvIdle;
private ArrayAdapter<EntityFolder> adapter; private ArrayAdapter<EntityFolder> adapter;
private Spinner spDrafts; private Spinner spDrafts;
private Spinner spSent; private Spinner spSent;
@ -183,6 +185,8 @@ public class FragmentAccount extends FragmentEx {
btnCheck = view.findViewById(R.id.btnCheck); btnCheck = view.findViewById(R.id.btnCheck);
pbCheck = view.findViewById(R.id.pbCheck); pbCheck = view.findViewById(R.id.pbCheck);
tvIdle = view.findViewById(R.id.tvIdle);
spDrafts = view.findViewById(R.id.spDrafts); spDrafts = view.findViewById(R.id.spDrafts);
spSent = view.findViewById(R.id.spSent); spSent = view.findViewById(R.id.spSent);
spAll = view.findViewById(R.id.spAll); spAll = view.findViewById(R.id.spAll);
@ -217,6 +221,7 @@ public class FragmentAccount extends FragmentEx {
grpAdvanced.setVisibility(View.GONE); grpAdvanced.setVisibility(View.GONE);
btnCheck.setVisibility(position > 0 ? View.VISIBLE : View.GONE); btnCheck.setVisibility(position > 0 ? View.VISIBLE : View.GONE);
tvIdle.setVisibility(View.GONE);
grpFolders.setVisibility(View.GONE); grpFolders.setVisibility(View.GONE);
btnSave.setVisibility(View.GONE); btnSave.setVisibility(View.GONE);
@ -385,6 +390,7 @@ public class FragmentAccount extends FragmentEx {
btnAuthorize.setEnabled(false); btnAuthorize.setEnabled(false);
btnCheck.setEnabled(false); btnCheck.setEnabled(false);
pbCheck.setVisibility(View.VISIBLE); pbCheck.setVisibility(View.VISIBLE);
tvIdle.setVisibility(View.GONE);
grpFolders.setVisibility(View.GONE); grpFolders.setVisibility(View.GONE);
btnSave.setVisibility(View.GONE); btnSave.setVisibility(View.GONE);
@ -398,9 +404,9 @@ public class FragmentAccount extends FragmentEx {
args.putString("password", tilPassword.getEditText().getText().toString()); args.putString("password", tilPassword.getEditText().getText().toString());
args.putInt("auth_type", authorized == null ? Helper.AUTH_TYPE_PASSWORD : provider.getAuthType()); args.putInt("auth_type", authorized == null ? Helper.AUTH_TYPE_PASSWORD : provider.getAuthType());
new SimpleTask<List<EntityFolder>>() {
new SimpleTask<CheckResult>() {
@Override @Override
protected List<EntityFolder> onLoad(Context context, Bundle args) throws Throwable {
protected CheckResult onLoad(Context context, Bundle args) throws Throwable {
long id = args.getLong("id"); long id = args.getLong("id");
String host = args.getString("host"); String host = args.getString("host");
String port = args.getString("port"); String port = args.getString("port");
@ -417,8 +423,10 @@ public class FragmentAccount extends FragmentEx {
if (TextUtils.isEmpty(password)) if (TextUtils.isEmpty(password))
throw new Throwable(getContext().getString(R.string.title_no_password)); throw new Throwable(getContext().getString(R.string.title_no_password));
CheckResult result = new CheckResult();
result.folders = new ArrayList<>();
// Check IMAP server / get folders // Check IMAP server / get folders
List<EntityFolder> folders = new ArrayList<>();
Properties props = MessageHelper.getSessionProperties(auth_type); Properties props = MessageHelper.getSessionProperties(auth_type);
Session isession = Session.getInstance(props, null); Session isession = Session.getInstance(props, null);
isession.setDebug(true); isession.setDebug(true);
@ -438,6 +446,8 @@ public class FragmentAccount extends FragmentEx {
if (!istore.hasCapability("UIDPLUS")) if (!istore.hasCapability("UIDPLUS"))
throw new MessagingException(getContext().getString(R.string.title_no_uidplus)); throw new MessagingException(getContext().getString(R.string.title_no_uidplus));
result.idle = istore.hasCapability("IDLE");
for (Folder ifolder : istore.getDefaultFolder().list("*")) { for (Folder ifolder : istore.getDefaultFolder().list("*")) {
String type = null; String type = null;
@ -478,7 +488,7 @@ public class FragmentAccount extends FragmentEx {
folder.synchronize = (type != null && EntityFolder.SYSTEM_FOLDER_SYNC.contains(type)); folder.synchronize = (type != null && EntityFolder.SYSTEM_FOLDER_SYNC.contains(type));
folder.after = (type == null ? EntityFolder.DEFAULT_USER_SYNC : EntityFolder.DEFAULT_SYSTEM_SYNC); 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 + Log.i(Helper.TAG, folder.name + " id=" + folder.id +
" type=" + folder.type + " attr=" + TextUtils.join(",", attrs)); " type=" + folder.type + " attr=" + TextUtils.join(",", attrs));
@ -490,17 +500,19 @@ public class FragmentAccount extends FragmentEx {
istore.close(); istore.close();
} }
return folders;
return result;
} }
@Override @Override
protected void onLoaded(Bundle args, List<EntityFolder> folders) {
protected void onLoaded(Bundle args, CheckResult result) {
Helper.setViewsEnabled(view, true); Helper.setViewsEnabled(view, true);
btnAuthorize.setEnabled(true); btnAuthorize.setEnabled(true);
btnCheck.setEnabled(true); btnCheck.setEnabled(true);
pbCheck.setVisibility(View.GONE); pbCheck.setVisibility(View.GONE);
setFolders(folders);
tvIdle.setVisibility(result.idle ? View.GONE : View.VISIBLE);
setFolders(result.folders);
new Handler().post(new Runnable() { new Handler().post(new Runnable() {
@Override @Override
@ -809,6 +821,8 @@ public class FragmentAccount extends FragmentEx {
btnAdvanced.setVisibility(View.GONE); btnAdvanced.setVisibility(View.GONE);
tvIdle.setVisibility(View.GONE);
btnCheck.setVisibility(View.GONE); btnCheck.setVisibility(View.GONE);
pbCheck.setVisibility(View.GONE); pbCheck.setVisibility(View.GONE);
@ -1076,4 +1090,9 @@ public class FragmentAccount extends FragmentEx {
grpFolders.setVisibility(View.VISIBLE); grpFolders.setVisibility(View.VISIBLE);
btnSave.setVisibility(View.VISIBLE); btnSave.setVisibility(View.VISIBLE);
} }
private class CheckResult {
List<EntityFolder> folders;
boolean idle;
}
} }

+ 13
- 1
app/src/main/res/layout/fragment_account.xml View File

@ -371,6 +371,18 @@
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/etInterval" /> app:layout_constraintTop_toBottomOf="@id/etInterval" />
<TextView
android:id="@+id/tvIdle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:minWidth="100dp"
android:text="@string/title_no_idle"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textStyle="bold"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/btnCheck" />
<TextView <TextView
android:id="@+id/tvDrafts" android:id="@+id/tvDrafts"
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -389,7 +401,7 @@
android:layout_marginTop="12dp" android:layout_marginTop="12dp"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/tvDrafts" app:layout_constraintStart_toEndOf="@id/tvDrafts"
app:layout_constraintTop_toBottomOf="@id/btnCheck" />
app:layout_constraintTop_toBottomOf="@id/tvIdle" />
<TextView <TextView
android:id="@+id/tvSent" android:id="@+id/tvSent"


+ 1
- 0
app/src/main/res/values/strings.xml View File

@ -121,6 +121,7 @@
<string name="title_no_user">User name missing</string> <string name="title_no_user">User name missing</string>
<string name="title_no_password">Password missing</string> <string name="title_no_password">Password missing</string>
<string name="title_no_drafts">Drafts folder missing</string> <string name="title_no_drafts">Drafts folder missing</string>
<string name="title_no_idle">This provider does not support push messages. Reception of new messages can be delayed.</string>
<string name="title_no_uidplus">IMAP UIDPLUS not supported, see the FAQ</string> <string name="title_no_uidplus">IMAP UIDPLUS not supported, see the FAQ</string>
<string name="title_account_delete">Delete this account permanently?</string> <string name="title_account_delete">Delete this account permanently?</string>
<string name="title_identity_delete">Delete this identity permanently?</string> <string name="title_identity_delete">Delete this identity permanently?</string>


Loading…
Cancel
Save