diff options
author | Tom Taylor <tomtaylor@google.com> | 2012-09-19 13:40:50 -0700 |
---|---|---|
committer | Tom Taylor <tomtaylor@google.com> | 2012-09-19 13:40:50 -0700 |
commit | c6be7e1a81769764ce0b51ce03406ad96944d8e5 (patch) | |
tree | 6c509a0baf3239ec69d6ab00fb5355e4258eb455 /src | |
parent | 99f719d1cb0c6ed68373d73427a816c4e56eb5ba (diff) | |
download | Mms-c6be7e1a81769764ce0b51ce03406ad96944d8e5.tar.gz |
Notification beep sounds every time I open a previously viewed SMS
Bug 7192246
Bug 7117451
Only beep it there are outstanding notifications. Also, there was a race
condition between receiving an sms and putting up a notification and
the conversation getting marked as read.
Change-Id: Ib3050582cbcef2986214fcb82c8c64aa9948211f
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/mms/data/Conversation.java | 7 | ||||
-rw-r--r-- | src/com/android/mms/transaction/MessagingNotification.java | 27 | ||||
-rw-r--r-- | src/com/android/mms/ui/ComposeMessageActivity.java | 19 |
3 files changed, 23 insertions, 30 deletions
diff --git a/src/com/android/mms/data/Conversation.java b/src/com/android/mms/data/Conversation.java index 4f2f3f66..e49983c2 100644 --- a/src/com/android/mms/data/Conversation.java +++ b/src/com/android/mms/data/Conversation.java @@ -349,7 +349,8 @@ public class Conversation { } setHasUnreadMessages(false); } - // Always update notifications regardless of the read state. + // Always update notifications regardless of the read state, which is usually + // canceling the notification of the thread that was just marked read. MessagingNotification.blockingUpdateAllNotifications(mContext, threadId); return null; @@ -732,7 +733,9 @@ public class Conversation { sDeletingThreads = true; String selection = deleteAll ? null : "locked=0"; - MmsApp.getApplication().getPduLoaderManager().clear(); + MmsApp app = MmsApp.getApplication(); + app.getPduLoaderManager().clear(); + app.getThumbnailManager().clear(); handler.setDeleteToken(token); handler.startDelete(token, new Long(-1), Threads.CONTENT_URI, selection, null); diff --git a/src/com/android/mms/transaction/MessagingNotification.java b/src/com/android/mms/transaction/MessagingNotification.java index 0dd7a785..687f7daa 100644 --- a/src/com/android/mms/transaction/MessagingNotification.java +++ b/src/com/android/mms/transaction/MessagingNotification.java @@ -245,17 +245,6 @@ public class MessagingNotification { */ public static void blockingUpdateNewMessageIndicator(Context context, long newMsgThreadId, boolean isStatusMessage) { - synchronized (sCurrentlyDisplayedThreadLock) { - if (newMsgThreadId > 0 && newMsgThreadId == sCurrentlyDisplayedThreadId) { - if (DEBUG) { - Log.d(TAG, "blockingUpdateNewMessageIndicator: newMsgThreadId == " + - "sCurrentlyDisplayedThreadId so NOT showing notification," + - " but playing soft sound. threadId: " + newMsgThreadId); - } - playInConversationNotificationSound(context); - return; - } - } // notificationSet is kept sorted by the incoming message delivery time, with the // most recent message first. SortedSet<NotificationInfo> notificationSet = @@ -272,8 +261,21 @@ public class MessagingNotification { Log.d(TAG, "blockingUpdateNewMessageIndicator: count=" + notificationSet.size() + ", newMsgThreadId=" + newMsgThreadId); } + synchronized (sCurrentlyDisplayedThreadLock) { + if (newMsgThreadId > 0 && newMsgThreadId == sCurrentlyDisplayedThreadId) { + if (DEBUG) { + Log.d(TAG, "blockingUpdateNewMessageIndicator: newMsgThreadId == " + + "sCurrentlyDisplayedThreadId so NOT showing notification," + + " but playing soft sound. threadId: " + newMsgThreadId); + } + playInConversationNotificationSound(context); + return; + } + } updateNotification(context, newMsgThreadId != THREAD_NONE, threads.size(), notificationSet); + } else if (DEBUG) { + Log.d(TAG, "blockingUpdateNewMessageIndicator: notificationSet is empty"); } // And deals with delivery reports (which use Toasts). It's safe to call in a worker @@ -753,6 +755,9 @@ public class MessagingNotification { NotificationManager nm = (NotificationManager) context.getSystemService( Context.NOTIFICATION_SERVICE); + if (DEBUG) { + Log.d(TAG, "cancelNotification"); + } nm.cancel(notificationId); } diff --git a/src/com/android/mms/ui/ComposeMessageActivity.java b/src/com/android/mms/ui/ComposeMessageActivity.java index 2355a605..7bbcf683 100644 --- a/src/com/android/mms/ui/ComposeMessageActivity.java +++ b/src/com/android/mms/ui/ComposeMessageActivity.java @@ -268,9 +268,6 @@ public class ComposeMessageActivity extends Activity private boolean mIsKeyboardOpen; // Whether the hardware keyboard is visible private boolean mIsLandscape; // Whether we're in landscape mode - private boolean mPossiblePendingNotification; // If the message list has changed, we may have - // a pending notification to deal with. - private boolean mToastForDraftSave; // Whether to notify the user that a draft is being saved private boolean mSentMessage; // true if the user has sent a message while in this @@ -2170,6 +2167,7 @@ public class ComposeMessageActivity extends Activity mIsRunning = true; updateThreadIdIfRunning(); + mConversation.markAsRead(); } @Override @@ -2206,6 +2204,7 @@ public class ComposeMessageActivity extends Activity Log.v(TAG, "onPause: mSavedScrollPosition=" + mSavedScrollPosition); } + mConversation.markAsRead(); mIsRunning = false; } @@ -2300,11 +2299,6 @@ public class ComposeMessageActivity extends Activity } @Override - public void onUserInteraction() { - checkPendingNotification(); - } - - @Override public boolean onKeyDown(int keyCode, KeyEvent event) { switch (keyCode) { case KeyEvent.KEYCODE_DEL: @@ -3773,8 +3767,6 @@ public class ComposeMessageActivity extends Activity mDataSetChangedListener = new MessageListAdapter.OnDataSetChangedListener() { @Override public void onDataSetChanged(MessageListAdapter adapter) { - mPossiblePendingNotification = true; - checkPendingNotification(); } @Override @@ -3783,13 +3775,6 @@ public class ComposeMessageActivity extends Activity } }; - private void checkPendingNotification() { - if (mPossiblePendingNotification && hasWindowFocus()) { - mConversation.markAsRead(); - mPossiblePendingNotification = false; - } - } - /** * smoothScrollToEnd will scroll the message list to the bottom if the list is already near * the bottom. Typically this is called to smooth scroll a newly received message into view. |