+ * @param doNotUse IMPORTANT: Do not use this parameter. The ID in the list widget
+ * must be a positive value. However, we rely on negative IDs for special mailboxes. Instead,
+ * we use the ID returned by {@link MailboxesAdapter#getId(int)}.
+ */
+ @Override
+ public void onItemClick(AdapterView> parent, View view, int position, long doNotUse) {
final long id = mListAdapter.getId(position);
if (mListAdapter.isAccountRow(position)) {
mCallback.onAccountSelected(id);
diff --git a/src/com/android/email/activity/MessageListFragment.java b/src/com/android/email/activity/MessageListFragment.java
index 9fe6bbede..f8579ad42 100644
--- a/src/com/android/email/activity/MessageListFragment.java
+++ b/src/com/android/email/activity/MessageListFragment.java
@@ -18,11 +18,11 @@ package com.android.email.activity;
import com.android.email.Controller;
import com.android.email.Email;
+import com.android.email.NotificationController;
import com.android.email.R;
import com.android.email.RefreshManager;
import com.android.email.data.MailboxAccountLoader;
import com.android.email.provider.EmailProvider;
-import com.android.email.service.MailService;
import com.android.emailcommon.Logging;
import com.android.emailcommon.provider.EmailContent;
import com.android.emailcommon.provider.EmailContent.Account;
@@ -37,7 +37,6 @@ import android.app.ListFragment;
import android.app.LoaderManager;
import android.content.ClipData;
import android.content.ContentUris;
-import android.content.Context;
import android.content.Loader;
import android.content.res.Configuration;
import android.content.res.Resources;
@@ -238,6 +237,7 @@ public class MessageListFragment extends ListFragment
return instance;
}
+ @SuppressWarnings("unused")
@Override
public void onCreate(Bundle savedInstanceState) {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
@@ -261,6 +261,7 @@ public class MessageListFragment extends ListFragment
return root;
}
+ @SuppressWarnings("unused")
@Override
public void onActivityCreated(Bundle savedInstanceState) {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
@@ -292,6 +293,7 @@ public class MessageListFragment extends ListFragment
}
}
+ @SuppressWarnings("unused")
@Override
public void onStart() {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
@@ -300,6 +302,7 @@ public class MessageListFragment extends ListFragment
super.onStart();
}
+ @SuppressWarnings("unused")
@Override
public void onResume() {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
@@ -307,6 +310,7 @@ public class MessageListFragment extends ListFragment
}
super.onResume();
mResumed = true;
+ adjustMessageNotification(false);
// If we're recovering from the stopped state, we don't have to reload.
// (when mOpenRequested = false)
@@ -315,6 +319,7 @@ public class MessageListFragment extends ListFragment
}
}
+ @SuppressWarnings("unused")
@Override
public void onPause() {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
@@ -323,8 +328,10 @@ public class MessageListFragment extends ListFragment
mResumed = false;
super.onStop();
mSavedListState = getListView().onSaveInstanceState();
+ adjustMessageNotification(true);
}
+ @SuppressWarnings("unused")
@Override
public void onStop() {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
@@ -333,6 +340,7 @@ public class MessageListFragment extends ListFragment
super.onStop();
}
+ @SuppressWarnings("unused")
@Override
public void onDestroy() {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
@@ -349,6 +357,7 @@ public class MessageListFragment extends ListFragment
super.onDestroy();
}
+ @SuppressWarnings("unused")
@Override
public void onSaveInstanceState(Bundle outState) {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
@@ -360,6 +369,7 @@ public class MessageListFragment extends ListFragment
outState.putLong(BUNDLE_KEY_SELECTED_MESSAGE_ID, mSelectedMessageId);
}
+ @SuppressWarnings("unused")
@VisibleForTesting
void restoreInstanceState(Bundle savedInstanceState) {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
@@ -414,6 +424,7 @@ public class MessageListFragment extends ListFragment
* {@link Mailbox#QUERY_ALL_INBOXES}. -1 is not allowed.
*/
// STOPSHIP Make it private once phone activities are gone
+ @SuppressWarnings("unused")
void openMailbox(long mailboxId) {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
Log.d(Logging.LOG_TAG, "MessageListFragment openMailbox");
@@ -446,10 +457,15 @@ public class MessageListFragment extends ListFragment
}
/**
- * @return the account id or -1 if it's unknown yet. It's also -1 if it's a magic mailbox.
+ * Returns the account id of the currently viewed messages. May return
+ * {@link Account#PSEUDO_ACCOUNT_ID_NONE} if the mailbox is not yet known or
+ * {@link Account#ACCOUNT_ID_COMBINED_VIEW} if viewing a combined mailbox.
*/
- public long getAccountId() {
- return (mMailbox == null) ? -1 : mMailbox.mAccountKey;
+ private long getAccountId() {
+ return (mMailbox == null)
+ ? (mMailboxId < Mailbox.NO_MAILBOX)
+ ? Account.ACCOUNT_ID_COMBINED_VIEW : Account.PSEUDO_ACCOUNT_ID_NONE
+ : mMailbox.mAccountKey;
}
/**
@@ -492,6 +508,7 @@ public class MessageListFragment extends ListFragment
/**
* Called when a message is clicked.
*/
+ @Override
public void onItemClick(AdapterView> parent, View view, int position, long id) {
if (view != mListFooterView) {
MessageListItem itemView = (MessageListItem) view;
@@ -593,6 +610,7 @@ public class MessageListFragment extends ListFragment
}
}
+ @Override
public boolean onDrag(View view, DragEvent event) {
switch(event.getAction()) {
case DragEvent.ACTION_DRAG_ENDED:
@@ -614,6 +632,7 @@ public class MessageListFragment extends ListFragment
return false;
}
+ @Override
public boolean onItemLongClick(AdapterView> parent, View view, int position, long id) {
if (view != mListFooterView) {
// Start drag&drop.
@@ -732,7 +751,7 @@ public class MessageListFragment extends ListFragment
return;
}
long accountId = getAccountId();
- if (accountId != -1) {
+ if (Account.isNormalAccount(accountId)) {
mRefreshManager.refreshMessageList(accountId, mMailboxId, userRequest);
}
}
@@ -753,7 +772,7 @@ public class MessageListFragment extends ListFragment
*/
private void onLoadMoreMessages() {
long accountId = getAccountId();
- if (accountId != -1) {
+ if (Account.isNormalAccount(accountId)) {
mRefreshManager.loadMoreMessages(accountId, mMailboxId);
}
}
@@ -794,10 +813,12 @@ public class MessageListFragment extends ListFragment
private void toggleRead(Set
- *
- * TODO Instead of resetting the message count, we should just be suspending the notification
- * controller for the correct accounts. Need to ensure we resume notifications appropriately.
- */
- private static void resetNewMessageCount(
- Context context, long mailboxId, long accountId) {
- if (mailboxId == Mailbox.QUERY_ALL_INBOXES) {
- MailService.resetNewMessageCount(context, -1);
- } else if (mailboxId >= 0 && accountId != -1) {
- MailService.resetNewMessageCount(context, accountId);
- }
- }
-
/**
* Show/hide the "selection" action mode, according to the number of selected messages and
* the visibility of the fragment.
diff --git a/src/com/android/email/activity/UIControllerBase.java b/src/com/android/email/activity/UIControllerBase.java
index 2c24828d9..2d6f4aae8 100644
--- a/src/com/android/email/activity/UIControllerBase.java
+++ b/src/com/android/email/activity/UIControllerBase.java
@@ -49,7 +49,7 @@ abstract class UIControllerBase {
protected static final String BUNDLE_KEY_MESSAGE_ID = "UIController.state.message_id";
/** No account selected */
- static final long NO_ACCOUNT = -1;
+ static final long NO_ACCOUNT = Account.PSEUDO_ACCOUNT_ID_NONE;
/** No mailbox selected */
static final long NO_MAILBOX = -1;
/** No message selected */
diff --git a/src/com/android/email/service/MailService.java b/src/com/android/email/service/MailService.java
index 417c19167..47bf9b94b 100644
--- a/src/com/android/email/service/MailService.java
+++ b/src/com/android/email/service/MailService.java
@@ -143,17 +143,6 @@ public class MailService extends Service {
context.startService(i);
}
- /**
- * Reset new message counts for one or all accounts. This clears both our local copy and
- * the values (if any) stored in the account records.
- *
- * @param accountId account to clear, or -1 for all accounts
- */
- @SuppressWarnings("deprecation")
- public static void resetNewMessageCount(final Context context, final long accountId) {
- NotificationController.getInstance(context).resetMessageNotification(accountId);
- }
-
/**
* Entry point for asynchronous message services (e.g. push mode) to post notifications of new
* messages. This assumes that the push provider has already synced the messages into the
@@ -162,7 +151,7 @@ public class MailService extends Service {
* @param context a context
* @param accountId the id of the account that is reporting new messages
*/
- @SuppressWarnings("unchecked")
+ @SuppressWarnings("rawtypes")
public static void actionNotifyNewMessages(
Context context, long accountId, List messageIdList) {
Intent i = new Intent(ACTION_NOTIFY_MAIL);