More robust email checking
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
0.3.1
|
||||
* Fixed crash when clicking "Create new contact" button
|
||||
* Fixed occasional crashes when Bote connects to / disconnects from the network
|
||||
* Improved robustness and user feedback for email checking
|
||||
* Added "Copy to clipboard" button to identities and contacts
|
||||
* Added labels to the address book actions menu
|
||||
* Updated translations
|
||||
|
||||
@@ -58,6 +58,7 @@ public class EmailListFragment extends AuthenticatedListFragment implements
|
||||
OnEmailSelectedListener mCallback;
|
||||
|
||||
private MultiSwipeRefreshLayout mSwipeRefreshLayout;
|
||||
private AsyncTask<Void, Void, Void> mCheckingTask;
|
||||
private TextView mEmptyText;
|
||||
private TextView mNumIncompleteEmails;
|
||||
|
||||
@@ -135,7 +136,6 @@ public class EmailListFragment extends AuthenticatedListFragment implements
|
||||
R.color.primary, R.color.accent, R.color.primary, R.color.accent);
|
||||
mSwipeRefreshLayout.setSwipeableChildren(android.R.id.list, android.R.id.empty);
|
||||
mSwipeRefreshLayout.setOnRefreshListener(this);
|
||||
mSwipeRefreshLayout.setRefreshing(I2PBote.getInstance().isCheckingForMail());
|
||||
}
|
||||
|
||||
return v;
|
||||
@@ -177,6 +177,29 @@ public class EmailListFragment extends AuthenticatedListFragment implements
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
|
||||
if (mSwipeRefreshLayout != null) {
|
||||
boolean isChecking = I2PBote.getInstance().isCheckingForMail();
|
||||
mSwipeRefreshLayout.setRefreshing(isChecking);
|
||||
if (isChecking)
|
||||
onRefresh();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
super.onStop();
|
||||
|
||||
if (mCheckingTask != null) {
|
||||
mCheckingTask.cancel(true);
|
||||
mCheckingTask = null;
|
||||
mSwipeRefreshLayout.setRefreshing(false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Start loading the list of emails from this folder.
|
||||
* Only called when we have a password cached, or no
|
||||
@@ -237,8 +260,16 @@ public class EmailListFragment extends AuthenticatedListFragment implements
|
||||
boolean passwordRequired = I2PBote.getInstance().isPasswordRequired();
|
||||
mNewEmail.setVisibility(passwordRequired ? View.GONE : View.VISIBLE);
|
||||
mCheckEmail.setVisible(mSwipeRefreshLayout != null && !passwordRequired);
|
||||
if (mSwipeRefreshLayout != null)
|
||||
if (mSwipeRefreshLayout != null) {
|
||||
mSwipeRefreshLayout.setEnabled(!passwordRequired);
|
||||
if (mSwipeRefreshLayout.isRefreshing()) {
|
||||
mCheckEmail.setTitle(R.string.checking_email);
|
||||
mCheckEmail.setEnabled(false);
|
||||
} else {
|
||||
mCheckEmail.setTitle(R.string.check_email);
|
||||
mCheckEmail.setEnabled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -248,6 +279,7 @@ public class EmailListFragment extends AuthenticatedListFragment implements
|
||||
if (!mSwipeRefreshLayout.isRefreshing()) {
|
||||
mSwipeRefreshLayout.setRefreshing(true);
|
||||
onRefresh();
|
||||
getActivity().supportInvalidateOptionsMenu();
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -496,13 +528,17 @@ public class EmailListFragment extends AuthenticatedListFragment implements
|
||||
// SwipeRefreshLayout.OnRefreshListener
|
||||
|
||||
public void onRefresh() {
|
||||
// If we are already checking, do nothing else
|
||||
if (mCheckingTask != null)
|
||||
return;
|
||||
|
||||
I2PBote bote = I2PBote.getInstance();
|
||||
if (bote.isConnected()) {
|
||||
try {
|
||||
if (!bote.isCheckingForMail())
|
||||
bote.checkForMail();
|
||||
|
||||
new AsyncTask<Void, Void, Void>() {
|
||||
mCheckingTask = new AsyncTask<Void, Void, Void>() {
|
||||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
while (I2PBote.getInstance().isCheckingForMail()) {
|
||||
@@ -510,6 +546,9 @@ public class EmailListFragment extends AuthenticatedListFragment implements
|
||||
Thread.sleep(100);
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
if (isCancelled()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -534,8 +573,10 @@ public class EmailListFragment extends AuthenticatedListFragment implements
|
||||
|
||||
// Notify PullToRefreshLayout that the refresh has finished
|
||||
mSwipeRefreshLayout.setRefreshing(false);
|
||||
getActivity().supportInvalidateOptionsMenu();
|
||||
}
|
||||
}.execute();
|
||||
};
|
||||
mCheckingTask.execute();
|
||||
} catch (PasswordException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
<string name="action_stop_bote">Disconnect from network</string>
|
||||
<string name="action_settings">Settings</string>
|
||||
<string name="check_email">Check email</string>
|
||||
<string name="checking_email">Checking email…</string>
|
||||
<!-- Argument is a number -->
|
||||
<plurals name="incomplete_emails">
|
||||
<item quantity="one">One incomplete email</item>
|
||||
|
||||
Reference in New Issue
Block a user