1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-11 20:15:03 -05:00

Directly go to message when clicking on a single-message notification.

This commit is contained in:
Danny Baumann 2013-01-05 14:10:07 +01:00
parent d9cc0446b6
commit ef93f0af6c
3 changed files with 30 additions and 17 deletions

View File

@ -586,7 +586,8 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme
Log.i(K9.LOG_TAG, "MessageList sending message " + messageReference);
MessageView.actionView(this, messageReference, messageRefs, getIntent().getExtras());
Intent i = MessageView.actionView(this, messageReference, messageRefs);
startActivity(i);
}
/*

View File

@ -41,7 +41,6 @@ public class MessageView extends K9FragmentActivity implements MessageViewFragme
private static final String EXTRA_MESSAGE_REFERENCE = "com.fsck.k9.MessageView_messageReference";
private static final String EXTRA_MESSAGE_REFERENCES = "com.fsck.k9.MessageView_messageReferences";
private static final String EXTRA_MESSAGE_LIST_EXTRAS = "com.fsck.k9.MessageView_messageListExtras";
/**
* @see #mLastDirection
@ -50,14 +49,13 @@ public class MessageView extends K9FragmentActivity implements MessageViewFragme
private static final int NEXT = 2;
public static void actionView(Context context, MessageReference messRef,
ArrayList<MessageReference> messReferences, Bundle messageListExtras) {
public static Intent actionView(Context context, MessageReference messRef,
ArrayList<MessageReference> messReferences) {
Intent i = new Intent(context, MessageView.class);
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
i.putExtra(EXTRA_MESSAGE_LIST_EXTRAS, messageListExtras);
i.putExtra(EXTRA_MESSAGE_REFERENCE, messRef);
i.putParcelableArrayListExtra(EXTRA_MESSAGE_REFERENCES, messReferences);
context.startActivity(i);
return i;
}
@ -438,7 +436,9 @@ public class MessageView extends K9FragmentActivity implements MessageViewFragme
private void showNextMessage() {
findSurroundingMessagesUid();
if (mMessageReferences == null) {
mMessageReferences.remove(mMessageReference);
}
if (mLastDirection == NEXT && mNextMessage != null) {
onNext();
} else if (mLastDirection == PREVIOUS && mPreviousMessage != null) {
@ -491,6 +491,10 @@ public class MessageView extends K9FragmentActivity implements MessageViewFragme
private void findSurroundingMessagesUid() {
mNextMessage = mPreviousMessage = null;
if (mMessageReferences == null) {
return;
}
int i = mMessageReferences.indexOf(mMessageReference);
if (i < 0) {
return;

View File

@ -50,6 +50,7 @@ import com.fsck.k9.R;
import com.fsck.k9.activity.FolderList;
import com.fsck.k9.activity.MessageList;
import com.fsck.k9.activity.MessageReference;
import com.fsck.k9.activity.MessageView;
import com.fsck.k9.activity.NotificationDeleteConfirmation;
import com.fsck.k9.helper.Contacts;
import com.fsck.k9.helper.HtmlConverter;
@ -4692,6 +4693,18 @@ public class MessagingController implements Runnable {
builder.setContentText(summary);
}
for (Message m : data.messages) {
if (m.isSet(Flag.FLAGGED)) {
builder.setPriority(NotificationCompat.PRIORITY_HIGH);
break;
}
}
Intent targetIntent;
if (unreadCount == 1) {
targetIntent = MessageView.actionView(context, message.makeMessageReference(), null);
} else {
String initialFolder = message.getFolder().getName();
/* only go to folder if all messages are in the same folder, else go to folder list */
for (MessageReference ref : allRefs) {
@ -4700,15 +4713,10 @@ public class MessagingController implements Runnable {
break;
}
}
for (Message m : data.messages) {
if (m.isSet(Flag.FLAGGED)) {
builder.setPriority(NotificationCompat.PRIORITY_HIGH);
break;
}
}
Intent i = FolderList.actionHandleNotification(context, account, initialFolder);
PendingIntent pi = PendingIntent.getActivity(context, 0, i, PendingIntent.FLAG_UPDATE_CURRENT);
targetIntent = FolderList.actionHandleNotification(context, account, initialFolder);
}
PendingIntent pi = PendingIntent.getActivity(context, 0, targetIntent, PendingIntent.FLAG_UPDATE_CURRENT);
builder.setContentIntent(pi);
// Only ring or vibrate if we have not done so already on this account and fetch