1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-27 11:42:16 -05:00

Cancel notification when viewing message by clicking on notification.

This commit is contained in:
Danny Baumann 2013-01-06 12:13:36 +01:00
parent ef93f0af6c
commit e17e9b9344
3 changed files with 15 additions and 3 deletions

View File

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

View File

@ -14,6 +14,7 @@ import com.fsck.k9.Preferences;
import com.fsck.k9.R;
import com.fsck.k9.activity.misc.SwipeGestureDetector;
import com.fsck.k9.activity.misc.SwipeGestureDetector.OnSwipeGestureListener;
import com.fsck.k9.controller.MessagingController;
import com.fsck.k9.crypto.PgpData;
import com.fsck.k9.fragment.MessageViewFragment;
import com.fsck.k9.fragment.MessageViewFragment.MessageViewFragmentListener;
@ -41,6 +42,7 @@ 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_FROM_NOTIFICATION ="com.fsck.k9.MessageView_fromNotification";
/**
* @see #mLastDirection
@ -49,7 +51,7 @@ public class MessageView extends K9FragmentActivity implements MessageViewFragme
private static final int NEXT = 2;
public static Intent actionView(Context context, MessageReference messRef,
public static Intent actionViewIntent(Context context, MessageReference messRef,
ArrayList<MessageReference> messReferences) {
Intent i = new Intent(context, MessageView.class);
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
@ -58,6 +60,12 @@ public class MessageView extends K9FragmentActivity implements MessageViewFragme
return i;
}
public static Intent actionHandleNotificationIntent(Context context, MessageReference ref) {
Intent i = actionViewIntent(context, ref, null);
i.setFlags(i.getFlags() | Intent.FLAG_ACTIVITY_NEW_TASK);
i.putExtra(EXTRA_FROM_NOTIFICATION, true);
return i;
}
private StorageManager.StorageListener mStorageListener = new StorageListenerImplementation();
private Account mAccount;
@ -163,6 +171,9 @@ public class MessageView extends K9FragmentActivity implements MessageViewFragme
onAccountUnavailable();
return;
}
if (getIntent().getBooleanExtra(EXTRA_FROM_NOTIFICATION, false)) {
MessagingController.getInstance(getApplication()).notifyAccountCancel(this, mAccount);
}
StorageManager.getInstance(getApplication()).addListener(mStorageListener);
}

View File

@ -4703,7 +4703,8 @@ public class MessagingController implements Runnable {
Intent targetIntent;
if (unreadCount == 1) {
targetIntent = MessageView.actionView(context, message.makeMessageReference(), null);
targetIntent = MessageView.actionHandleNotificationIntent(
context, message.makeMessageReference());
} else {
String initialFolder = message.getFolder().getName();
/* only go to folder if all messages are in the same folder, else go to folder list */