Show number of incomplete emails at top of Inbox
This commit is contained in:
@@ -59,6 +59,7 @@ public class EmailListFragment extends ListFragment implements
|
|||||||
OnEmailSelectedListener mCallback;
|
OnEmailSelectedListener mCallback;
|
||||||
|
|
||||||
private PullToRefreshLayout mPullToRefreshLayout;
|
private PullToRefreshLayout mPullToRefreshLayout;
|
||||||
|
private TextView mNumIncompleteEmails;
|
||||||
|
|
||||||
private EmailListAdapter mAdapter;
|
private EmailListAdapter mAdapter;
|
||||||
private EmailFolder mFolder;
|
private EmailFolder mFolder;
|
||||||
@@ -131,6 +132,14 @@ public class EmailListFragment extends ListFragment implements
|
|||||||
.setup(mPullToRefreshLayout);
|
.setup(mPullToRefreshLayout);
|
||||||
|
|
||||||
mPullToRefreshLayout.setRefreshing(I2PBote.getInstance().isCheckingForMail());
|
mPullToRefreshLayout.setRefreshing(I2PBote.getInstance().isCheckingForMail());
|
||||||
|
|
||||||
|
int numIncompleteEmails = I2PBote.getInstance().getNumIncompleteEmails();
|
||||||
|
if (numIncompleteEmails > 0) {
|
||||||
|
mNumIncompleteEmails = new TextView(getActivity());
|
||||||
|
mNumIncompleteEmails.setText(getResources().getString(R.string.incomplete_emails,
|
||||||
|
numIncompleteEmails));
|
||||||
|
getListView().addHeaderView(mNumIncompleteEmails);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -279,11 +288,13 @@ public class EmailListFragment extends ListFragment implements
|
|||||||
@Override
|
@Override
|
||||||
public void onListItemClick(ListView parent, View view, int pos, long id) {
|
public void onListItemClick(ListView parent, View view, int pos, long id) {
|
||||||
super.onListItemClick(parent, view, pos, id);
|
super.onListItemClick(parent, view, pos, id);
|
||||||
|
int position = mNumIncompleteEmails == null ? pos : pos - 1;
|
||||||
|
if (position < 0) return;
|
||||||
if (mMode == null) {
|
if (mMode == null) {
|
||||||
mCallback.onEmailSelected(
|
mCallback.onEmailSelected(
|
||||||
mFolder.getName(), mAdapter.getItem(pos).getMessageID());
|
mFolder.getName(), mAdapter.getItem(position).getMessageID());
|
||||||
} else
|
} else
|
||||||
onListItemSelect(pos);
|
onListItemSelect(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onListItemSelect(int position) {
|
private void onListItemSelect(int position) {
|
||||||
@@ -525,6 +536,19 @@ public class EmailListFragment extends ListFragment implements
|
|||||||
protected void onPostExecute(Void result) {
|
protected void onPostExecute(Void result) {
|
||||||
super.onPostExecute(result);
|
super.onPostExecute(result);
|
||||||
|
|
||||||
|
int numIncomingEmails = I2PBote.getInstance().getNumIncompleteEmails();
|
||||||
|
if (numIncomingEmails > 0) {
|
||||||
|
if (mNumIncompleteEmails == null) {
|
||||||
|
mNumIncompleteEmails = new TextView(getActivity());
|
||||||
|
getListView().addHeaderView(mNumIncompleteEmails);
|
||||||
|
}
|
||||||
|
mNumIncompleteEmails.setText(getResources().getString(R.string.incomplete_emails,
|
||||||
|
numIncomingEmails));
|
||||||
|
} else if (mNumIncompleteEmails != null) {
|
||||||
|
getListView().removeHeaderView(mNumIncompleteEmails);
|
||||||
|
mNumIncompleteEmails = null;
|
||||||
|
}
|
||||||
|
|
||||||
// Notify PullToRefreshLayout that the refresh has finished
|
// Notify PullToRefreshLayout that the refresh has finished
|
||||||
mPullToRefreshLayout.setRefreshComplete();
|
mPullToRefreshLayout.setRefreshComplete();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,6 +40,7 @@
|
|||||||
<string name="pull_text">Pull to check email</string>
|
<string name="pull_text">Pull to check email</string>
|
||||||
<string name="refreshing_text">Checking email...</string>
|
<string name="refreshing_text">Checking email...</string>
|
||||||
<string name="release_text">Let go to check email</string>
|
<string name="release_text">Let go to check email</string>
|
||||||
|
<string name="incomplete_emails">%s incomplete emails</string>
|
||||||
<string name="items_selected">%s selected</string>
|
<string name="items_selected">%s selected</string>
|
||||||
<string name="action_delete">Delete</string>
|
<string name="action_delete">Delete</string>
|
||||||
<string name="action_mark_read">Mark read</string>
|
<string name="action_mark_read">Mark read</string>
|
||||||
|
|||||||
Reference in New Issue
Block a user