use of com.fsck.k9.Account in project k-9 by k9mail.
the class MigrationTo43 method fixOutboxFolders.
public static void fixOutboxFolders(SQLiteDatabase db, MigrationsHelper migrationsHelper) {
try {
LocalStore localStore = migrationsHelper.getLocalStore();
Account account = migrationsHelper.getAccount();
Context context = migrationsHelper.getContext();
// If folder "OUTBOX" (old, v3.800 - v3.802) exists, rename it to
// "K9MAIL_INTERNAL_OUTBOX" (new)
LocalFolder oldOutbox = new LocalFolder(localStore, "OUTBOX");
if (oldOutbox.exists()) {
ContentValues cv = new ContentValues();
cv.put("name", Account.OUTBOX);
db.update("folders", cv, "name = ?", new String[] { "OUTBOX" });
Timber.i("Renamed folder OUTBOX to %s", OUTBOX);
}
// Check if old (pre v3.800) localized outbox folder exists
String localizedOutbox = context.getString(R.string.special_mailbox_name_outbox);
LocalFolder obsoleteOutbox = new LocalFolder(localStore, localizedOutbox);
if (obsoleteOutbox.exists()) {
// Get all messages from the localized outbox ...
List<? extends Message> messages = obsoleteOutbox.getMessages(null, false);
if (messages.size() > 0) {
// ... and move them to the drafts folder (we don't want to
// surprise the user by sending potentially very old messages)
LocalFolder drafts = new LocalFolder(localStore, account.getDraftsFolderName());
obsoleteOutbox.moveMessages(messages, drafts);
}
// Now get rid of the localized outbox
obsoleteOutbox.delete();
obsoleteOutbox.delete(true);
}
} catch (Exception e) {
Timber.e(e, "Error trying to fix the outbox folders");
}
}
use of com.fsck.k9.Account in project k-9 by k9mail.
the class DeviceNotifications method createInboxStyleSummaryNotification.
private NotificationCompat.Builder createInboxStyleSummaryNotification(Account account, NotificationData notificationData, int unreadMessageCount) {
NotificationHolder latestNotification = notificationData.getHolderForLatestNotification();
int newMessagesCount = notificationData.getNewMessagesCount();
String accountName = controller.getAccountName(account);
String title = context.getResources().getQuantityString(R.plurals.notification_new_messages_title, newMessagesCount, newMessagesCount);
String summary = (notificationData.hasSummaryOverflowMessages()) ? context.getString(R.string.notification_additional_messages, notificationData.getSummaryOverflowMessagesCount(), accountName) : accountName;
String groupKey = NotificationGroupKeys.getGroupKey(account);
NotificationCompat.Builder builder = createAndInitializeNotificationBuilder(account).setNumber(unreadMessageCount).setTicker(latestNotification.content.summary).setGroup(groupKey).setGroupSummary(true).setContentTitle(title).setSubText(accountName);
NotificationCompat.InboxStyle style = createInboxStyle(builder).setBigContentTitle(title).setSummaryText(summary);
for (NotificationContent content : notificationData.getContentForSummaryNotification()) {
style.addLine(content.summary);
}
builder.setStyle(style);
addMarkAllAsReadAction(builder, notificationData);
addDeleteAllAction(builder, notificationData);
wearNotifications.addSummaryActions(builder, notificationData);
int notificationId = NotificationIds.getNewMailSummaryNotificationId(account);
List<MessageReference> messageReferences = notificationData.getAllMessageReferences();
PendingIntent contentIntent = actionCreator.createViewMessagesPendingIntent(account, messageReferences, notificationId);
builder.setContentIntent(contentIntent);
return builder;
}
use of com.fsck.k9.Account in project k-9 by k9mail.
the class DeviceNotifications method addDeleteAllAction.
private void addDeleteAllAction(Builder builder, NotificationData notificationData) {
if (K9.getNotificationQuickDeleteBehaviour() != NotificationQuickDelete.ALWAYS) {
return;
}
int icon = getDeleteActionIcon();
String title = context.getString(R.string.notification_action_delete);
Account account = notificationData.getAccount();
int notificationId = NotificationIds.getNewMailSummaryNotificationId(account);
ArrayList<MessageReference> messageReferences = notificationData.getAllMessageReferences();
PendingIntent action = actionCreator.createDeleteAllPendingIntent(account, messageReferences, notificationId);
builder.addAction(icon, title, action);
}
use of com.fsck.k9.Account in project k-9 by k9mail.
the class DeviceNotifications method addMarkAllAsReadAction.
private void addMarkAllAsReadAction(Builder builder, NotificationData notificationData) {
int icon = getMarkAsReadActionIcon();
String title = context.getString(R.string.notification_action_mark_as_read);
Account account = notificationData.getAccount();
ArrayList<MessageReference> messageReferences = notificationData.getAllMessageReferences();
int notificationId = NotificationIds.getNewMailSummaryNotificationId(account);
PendingIntent markAllAsReadPendingIntent = actionCreator.createMarkAllAsReadPendingIntent(account, messageReferences, notificationId);
builder.addAction(icon, title, markAllAsReadPendingIntent);
}
use of com.fsck.k9.Account in project k-9 by k9mail.
the class NotificationActionCreator method buildMessageViewBackStack.
private TaskStackBuilder buildMessageViewBackStack(MessageReference message) {
Account account = Preferences.getPreferences(context).getAccount(message.getAccountUuid());
String folderName = message.getFolderName();
TaskStackBuilder stack = buildMessageListBackStack(account, folderName);
Intent intent = MessageList.actionDisplayMessageIntent(context, message);
stack.addNextIntent(intent);
return stack;
}
Aggregations