Exemple #1
0
  private void configureMenu(Menu menu) {
    // first run displayMessage() gets called before onCreateOptionMenu()
    if (menu == null) {
      return;
    }

    // enable them all
    menu.findItem(R.id.copy).setVisible(true);
    menu.findItem(R.id.move).setVisible(true);
    menu.findItem(R.id.archive).setVisible(true);
    menu.findItem(R.id.spam).setVisible(true);

    mToggleMessageViewMenu = menu.findItem(R.id.toggle_message_view_theme);
    if (K9.getK9MessageViewTheme() == K9.THEME_DARK) {
      mToggleMessageViewMenu.setTitle(R.string.message_view_theme_action_light);
    } else {
      mToggleMessageViewMenu.setTitle(R.string.message_view_theme_action_dark);
    }

    toggleActionsState(menu, true);

    updateUnreadToggleTitle();

    // comply with the setting
    if (!mAccount.getEnableMoveButtons()) {
      menu.findItem(R.id.move).setVisible(false);
      menu.findItem(R.id.archive).setVisible(false);
      menu.findItem(R.id.spam).setVisible(false);
    } else {
      // check message, folder capability
      if (!mController.isCopyCapable(mAccount)) {
        menu.findItem(R.id.copy).setVisible(false);
      }

      if (mController.isMoveCapable(mAccount)) {
        menu.findItem(R.id.move).setVisible(true);

        menu.findItem(R.id.archive)
            .setVisible(
                !mMessageReference.folderName.equals(mAccount.getArchiveFolderName())
                    && mAccount.hasArchiveFolder());

        menu.findItem(R.id.spam)
            .setVisible(
                !mMessageReference.folderName.equals(mAccount.getSpamFolderName())
                    && mAccount.hasSpamFolder());
      } else {
        menu.findItem(R.id.copy).setVisible(false);
        menu.findItem(R.id.move).setVisible(false);
        menu.findItem(R.id.archive).setVisible(false);
        menu.findItem(R.id.spam).setVisible(false);
      }
    }
  }
Exemple #2
0
  public void onCopy() {
    if ((!mController.isCopyCapable(mAccount)) || (mMessage == null)) {
      return;
    }
    if (!mController.isCopyCapable(mMessage)) {
      Toast toast =
          Toast.makeText(
              getActivity(), R.string.move_copy_cannot_copy_unsynced_message, Toast.LENGTH_LONG);
      toast.show();
      return;
    }

    startRefileActivity(ACTIVITY_CHOOSE_FOLDER_COPY);
  }
Exemple #3
0
    /**
     * @param projection Projection to use. If <code>null</code>, use the default projection.
     * @return Never <code>null</code>.
     * @throws InterruptedException
     */
    protected MatrixCursor getMessages(final String[] projection) throws InterruptedException {
      final BlockingQueue<List<MessageInfoHolder>> queue =
          new SynchronousQueue<List<MessageInfoHolder>>();

      // new code for integrated inbox, only execute this once as it will be processed afterwards
      // via the listener
      final SearchAccount integratedInboxAccount =
          SearchAccount.createUnifiedInboxAccount(getContext());
      final MessagingController msgController = MessagingController.getInstance(K9.app);

      msgController.searchLocalMessages(
          integratedInboxAccount, null, new MesssageInfoHolderRetrieverListener(queue));

      final List<MessageInfoHolder> holders = queue.take();

      // TODO add sort order parameter
      Collections.sort(
          holders,
          new MessageList.ReverseComparator<MessageInfoHolder>(new MessageList.DateComparator()));

      final String[] projectionToUse;
      if (projection == null) {
        projectionToUse = DEFAULT_MESSAGE_PROJECTION;
      } else {
        projectionToUse = projection;
      }

      final LinkedHashMap<String, FieldExtractor<MessageInfoHolder, ?>> extractors =
          resolveMessageExtractors(projectionToUse, holders.size());
      final int fieldCount = extractors.size();

      final String[] actualProjection = extractors.keySet().toArray(new String[fieldCount]);
      final MatrixCursor cursor = new MatrixCursor(actualProjection);

      for (final MessageInfoHolder holder : holders) {
        final Object[] o = new Object[fieldCount];

        int i = 0;
        for (final FieldExtractor<MessageInfoHolder, ?> extractor : extractors.values()) {
          o[i] = extractor.getField(holder);
          i += 1;
        }

        cursor.addRow(o);
      }

      return cursor;
    }
Exemple #4
0
  @Override
  public void onNewIntent(Intent intent) {
    setIntent(intent); // onNewIntent doesn't autoset our "internal" intent

    String initialFolder;

    mUnreadMessageCount = 0;
    String accountUuid = intent.getStringExtra(EXTRA_ACCOUNT);
    mAccount = Preferences.getPreferences(this).getAccount(accountUuid);

    if (mAccount == null) {
      // This shouldn't normally happen. But apparently it does. See issue 2261.
      finish();
      return;
    }

    initialFolder = intent.getStringExtra(EXTRA_INITIAL_FOLDER);
    boolean fromNotification = intent.getBooleanExtra(EXTRA_FROM_NOTIFICATION, false);
    if (fromNotification && mAccount.goToUnreadMessageSearch()) {
      MessagingController.getInstance(getApplication()).notifyAccountCancel(this, mAccount);
      openUnreadSearch(this, mAccount);
      finish();
    } else if (initialFolder != null && !K9.FOLDER_NONE.equals(initialFolder)) {
      onOpenFolder(initialFolder);
      finish();
    } else if (intent.getBooleanExtra(EXTRA_FROM_SHORTCUT, false)
        && !K9.FOLDER_NONE.equals(mAccount.getAutoExpandFolderName())) {
      onOpenFolder(mAccount.getAutoExpandFolderName());
      finish();
    } else {

      initializeActivityView();
    }
  }
Exemple #5
0
  /**
   * This class is responsible for reloading the list of local messages for a given folder,
   * notifying the adapter that the message have been loaded and queueing up a remote update of the
   * folder.
   */
  private void checkMail(FolderInfoHolder folder) {
    TracingPowerManager pm = TracingPowerManager.getPowerManager(this);
    final TracingWakeLock wakeLock =
        pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "FolderList checkMail");
    wakeLock.setReferenceCounted(false);
    wakeLock.acquire(K9.WAKE_LOCK_TIMEOUT);
    MessagingListener listener =
        new MessagingListener() {
          @Override
          public void synchronizeMailboxFinished(
              Account account, String folder, int totalMessagesInMailbox, int numNewMessages) {
            if (!account.equals(mAccount)) {
              return;
            }
            wakeLock.release();
          }

          @Override
          public void synchronizeMailboxFailed(Account account, String folder, String message) {
            if (!account.equals(mAccount)) {
              return;
            }
            wakeLock.release();
          }
        };
    MessagingController.getInstance(getApplication())
        .synchronizeMailbox(mAccount, folder.name, listener, null);
    sendMail(mAccount);
  }
Exemple #6
0
 private void onDownloadRemainder() {
   if (mMessage.isSet(Flag.X_DOWNLOADED_FULL)) {
     return;
   }
   mMessageView.downloadRemainderButton().setEnabled(false);
   mController.loadMessageForViewRemote(
       mAccount, mMessageReference.folderName, mMessageReference.uid, mListener);
 }
Exemple #7
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // This fragments adds options to the action bar
    setHasOptionsMenu(true);

    mController = MessagingController.getInstance(getActivity().getApplication());
  }
Exemple #8
0
 private void setDisplayMode(FolderMode aMode) {
   mMode = aMode;
   // invalidate the current filter as it is working on an inval
   if (mMyFilter != null) {
     mMyFilter.invalidate();
   }
   // re-populate the list
   MessagingController.getInstance(getApplication()).listFolders(mAccount, false, mListener);
 }
Exemple #9
0
          @Override
          public void listFoldersFinished(Account account) {
            if (account.equals(mAccount)) {

              mHandler.progress(false);
              MessagingController.getInstance(getApplication()).refreshListener(mAdapter.mListener);
              mHandler.dataChanged();
            }
            super.listFoldersFinished(account);
          }
Exemple #10
0
 private void delete() {
   if (mMessage != null) {
     // Disable the delete button after it's tapped (to try to prevent
     // accidental clicks)
     mMenu.findItem(R.id.delete).setEnabled(false);
     Message messageToDelete = mMessage;
     mFragmentListener.showNextMessageOrReturn();
     mController.deleteMessages(Collections.singletonList(messageToDelete), null);
   }
 }
Exemple #11
0
  @Override
  public int delete(Uri uri, String selection, String[] selectionArgs) {
    if (K9.app == null) {
      return 0;
    }

    if (K9.DEBUG) {
      Log.v(K9.LOG_TAG, "MessageProvider/delete: " + uri);
    }

    // Note: can only delete a message

    List<String> segments = null;
    int accountId = -1;
    String folderName = null;
    String msgUid = null;

    segments = uri.getPathSegments();
    accountId = Integer.parseInt(segments.get(1));
    folderName = segments.get(2);
    msgUid = segments.get(3);

    // get account
    Account myAccount = null;
    for (Account account : Preferences.getPreferences(getContext()).getAccounts()) {
      if (account.getAccountNumber() == accountId) {
        myAccount = account;
        if (!account.isAvailable(getContext())) {
          Log.w(K9.LOG_TAG, "not deleting messages because account is unavailable at the moment");
          return 0;
        }
      }
    }

    // get localstore parameter
    Message msg = null;
    try {
      Folder lf = LocalStore.getLocalInstance(myAccount, K9.app).getFolder(folderName);
      int msgCount = lf.getMessageCount();
      if (K9.DEBUG) {
        Log.d(K9.LOG_TAG, "folder msg count = " + msgCount);
      }
      msg = lf.getMessage(msgUid);
    } catch (MessagingException e) {
      Log.e(K9.LOG_TAG, "Unable to retrieve message", e);
    }

    // launch command to delete the message
    if ((myAccount != null) && (msg != null)) {
      MessagingController.getInstance(K9.app).deleteMessages(new Message[] {msg}, null);
    }

    // FIXME return the actual number of deleted messages
    return 0;
  }
Exemple #12
0
 public void onFlag() {
   if (mMessage != null) {
     boolean newState = !mMessage.isSet(Flag.FLAGGED);
     mController.setFlag(
         mAccount,
         mMessage.getFolder().getName(),
         new Message[] {mMessage},
         Flag.FLAGGED,
         newState);
     mMessageView.setHeaders(mMessage, mAccount);
   }
 }
Exemple #13
0
  /**
   * On resume we refresh the folder list (in the background) and we refresh the messages for any
   * folder that is currently open. This guarantees that things like unread message count and read
   * status are updated.
   */
  @Override
  public void onResume() {
    super.onResume();

    if (!mAccount.isAvailable(this)) {
      Log.i(K9.LOG_TAG, "account unavaliabale, not showing folder-list but account-list");
      startActivity(new Intent(this, Accounts.class));
      finish();
      return;
    }
    if (mAdapter == null) initializeActivityView();

    MessagingController.getInstance(getApplication()).addListener(mAdapter.mListener);
    // mAccount.refresh(Preferences.getPreferences(this));
    MessagingController.getInstance(getApplication())
        .getAccountStats(this, mAccount, mAdapter.mListener);

    onRefresh(!REFRESH_REMOTE);

    MessagingController.getInstance(getApplication()).notifyAccountCancel(this, mAccount);
  }
Exemple #14
0
  public void onRefile(String dstFolder) {
    if (!mController.isMoveCapable(mAccount)) {
      return;
    }
    if (!mController.isMoveCapable(mMessage)) {
      Toast toast =
          Toast.makeText(
              getActivity(), R.string.move_copy_cannot_copy_unsynced_message, Toast.LENGTH_LONG);
      toast.show();
      return;
    }

    if (K9.FOLDER_NONE.equalsIgnoreCase(dstFolder)) {
      return;
    }

    if (mAccount.getSpamFolderName().equals(dstFolder) && K9.confirmSpam()) {
      mDstFolder = dstFolder;
      showDialog(R.id.dialog_confirm_spam);
    } else {
      refileMessage(dstFolder);
    }
  }
Exemple #15
0
 private void onToggleRead() {
   if (mMessage != null) {
     mController.setFlag(
         mAccount,
         mMessage.getFolder().getName(),
         new Message[] {mMessage},
         Flag.SEEN,
         !mMessage.isSet(Flag.SEEN));
     mMessageView.setHeaders(mMessage, mAccount);
     String subject = mMessage.getSubject();
     displayMessageSubject(subject);
     updateUnreadToggleTitle();
   }
 }
Exemple #16
0
  private void displayMessage(MessageReference ref, boolean resetPgpData) {
    mMessageReference = ref;
    if (K9.DEBUG) {
      Log.d(K9.LOG_TAG, "MessageView displaying message " + mMessageReference);
    }

    Context appContext = getActivity().getApplicationContext();
    mAccount = Preferences.getPreferences(appContext).getAccount(mMessageReference.accountUuid);

    if (resetPgpData) {
      // start with fresh, empty PGP data
      mPgpData = new PgpData();
    }

    // Clear previous message
    mMessageView.resetView();
    mMessageView.resetHeaderView();

    mController.loadMessageForView(
        mAccount, mMessageReference.folderName, mMessageReference.uid, mListener);
    configureMenu(mMenu);
  }
Exemple #17
0
 private void onRefresh() {
   MessagingController.getInstance(getApplication()).listFolders(mAccount, true, mListener);
 }
Exemple #18
0
  @Override
  public void onCreate() {
    if (K9.DEVELOPER_MODE) {
      StrictMode.enableDefaults();
    }

    PRNGFixes.apply();

    super.onCreate();
    app = this;

    sIsDebuggable = ((getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0);
    K9MailLib.setDebugStatus(
        new K9MailLib.DebugStatus() {
          @Override
          public boolean enabled() {
            return DEBUG;
          }

          @Override
          public boolean debugSensitive() {
            return DEBUG_SENSITIVE;
          }
        });

    checkCachedDatabaseVersion();

    Preferences prefs = Preferences.getPreferences(this);
    loadPrefs(prefs);

    /*
     * We have to give MimeMessage a temp directory because File.createTempFile(String, String)
     * doesn't work in Android and MimeMessage does not have access to a Context.
     */
    BinaryTempFileBody.setTempDirectory(getCacheDir());

    LocalKeyStore.setKeyStoreLocation(getDir("KeyStore", MODE_PRIVATE).toString());

    /*
     * Enable background sync of messages
     */

    setServicesEnabled(this);
    registerReceivers();

    MessagingController.getInstance(this)
        .addListener(
            new MessagingListener() {
              private void broadcastIntent(
                  String action, Account account, String folder, Message message) {
                try {
                  Uri uri =
                      Uri.parse(
                          "email://messages/"
                              + account.getAccountNumber()
                              + "/"
                              + Uri.encode(folder)
                              + "/"
                              + Uri.encode(message.getUid()));
                  Intent intent = new Intent(action, uri);
                  intent.putExtra(K9.Intents.EmailReceived.EXTRA_ACCOUNT, account.getDescription());
                  intent.putExtra(K9.Intents.EmailReceived.EXTRA_FOLDER, folder);
                  intent.putExtra(K9.Intents.EmailReceived.EXTRA_SENT_DATE, message.getSentDate());
                  intent.putExtra(
                      K9.Intents.EmailReceived.EXTRA_FROM, Address.toString(message.getFrom()));
                  intent.putExtra(
                      K9.Intents.EmailReceived.EXTRA_TO,
                      Address.toString(message.getRecipients(Message.RecipientType.TO)));
                  intent.putExtra(
                      K9.Intents.EmailReceived.EXTRA_CC,
                      Address.toString(message.getRecipients(Message.RecipientType.CC)));
                  intent.putExtra(
                      K9.Intents.EmailReceived.EXTRA_BCC,
                      Address.toString(message.getRecipients(Message.RecipientType.BCC)));
                  intent.putExtra(K9.Intents.EmailReceived.EXTRA_SUBJECT, message.getSubject());
                  intent.putExtra(
                      K9.Intents.EmailReceived.EXTRA_FROM_SELF,
                      account.isAnIdentity(message.getFrom()));
                  K9.this.sendBroadcast(intent);
                  if (K9.DEBUG)
                    Log.d(
                        K9.LOG_TAG,
                        "Broadcasted: action="
                            + action
                            + " account="
                            + account.getDescription()
                            + " folder="
                            + folder
                            + " message uid="
                            + message.getUid());

                } catch (MessagingException e) {
                  Log.w(
                      K9.LOG_TAG,
                      "Error: action="
                          + action
                          + " account="
                          + account.getDescription()
                          + " folder="
                          + folder
                          + " message uid="
                          + message.getUid());
                }
              }

              private void updateUnreadWidget() {
                try {
                  UnreadWidgetProvider.updateUnreadCount(K9.this);
                } catch (Exception e) {
                  if (K9.DEBUG) {
                    Log.e(LOG_TAG, "Error while updating unread widget(s)", e);
                  }
                }
              }

              @Override
              public void synchronizeMailboxRemovedMessage(
                  Account account, String folder, Message message) {
                broadcastIntent(
                    K9.Intents.EmailReceived.ACTION_EMAIL_DELETED, account, folder, message);
                updateUnreadWidget();
              }

              @Override
              public void messageDeleted(Account account, String folder, Message message) {
                broadcastIntent(
                    K9.Intents.EmailReceived.ACTION_EMAIL_DELETED, account, folder, message);
                updateUnreadWidget();
              }

              @Override
              public void synchronizeMailboxNewMessage(
                  Account account, String folder, Message message) {
                broadcastIntent(
                    K9.Intents.EmailReceived.ACTION_EMAIL_RECEIVED, account, folder, message);
                updateUnreadWidget();
              }

              @Override
              public void folderStatusChanged(
                  Account account, String folderName, int unreadMessageCount) {

                updateUnreadWidget();

                // let observers know a change occurred
                Intent intent = new Intent(K9.Intents.EmailReceived.ACTION_REFRESH_OBSERVER, null);
                intent.putExtra(K9.Intents.EmailReceived.EXTRA_ACCOUNT, account.getDescription());
                intent.putExtra(K9.Intents.EmailReceived.EXTRA_FOLDER, folderName);
                K9.this.sendBroadcast(intent);
              }
            });

    notifyObservers();
  }
Exemple #19
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    getListView().setFastScrollEnabled(true);
    getListView().setItemsCanFocus(false);
    getListView().setChoiceMode(ListView.CHOICE_MODE_NONE);
    Intent intent = getIntent();
    String accountUuid = intent.getStringExtra(EXTRA_ACCOUNT);
    mAccount = Preferences.getPreferences(this).getAccount(accountUuid);
    mMessageReference = intent.getParcelableExtra(EXTRA_MESSAGE);
    mFolder = intent.getStringExtra(EXTRA_CUR_FOLDER);
    mSelectFolder = intent.getStringExtra(EXTRA_SEL_FOLDER);
    if (intent.getStringExtra(EXTRA_SHOW_CURRENT) != null) {
      mHideCurrentFolder = false;
    }
    if (intent.getStringExtra(EXTRA_SHOW_FOLDER_NONE) != null) {
      mShowOptionNone = true;
    }
    if (intent.getStringExtra(EXTRA_SHOW_DISPLAYABLE_ONLY) != null) {
      mShowDisplayableOnly = true;
    }
    if (mFolder == null) mFolder = "";

    mAdapter =
        new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1) {
          private Filter myFilter = null;

          @Override
          public Filter getFilter() {
            if (myFilter == null) {
              myFilter = new FolderListFilter<String>(this);
            }
            return myFilter;
          }
        };

    setListAdapter(mAdapter);

    mMode = mAccount.getFolderTargetMode();
    MessagingController.getInstance(getApplication()).listFolders(mAccount, false, mListener);

    this.getListView()
        .setOnItemClickListener(
            new AdapterView.OnItemClickListener() {
              @Override
              public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                Intent result = new Intent();
                result.putExtra(EXTRA_ACCOUNT, mAccount.getUuid());
                result.putExtra(EXTRA_CUR_FOLDER, mFolder);
                String destFolderName = (String) ((TextView) view).getText();
                if (mHeldInbox != null
                    && getString(R.string.special_mailbox_name_inbox).equals(destFolderName)) {
                  destFolderName = mHeldInbox;
                }
                result.putExtra(EXTRA_NEW_FOLDER, destFolderName);
                result.putExtra(EXTRA_MESSAGE, mMessageReference);
                setResult(RESULT_OK, result);
                finish();
              }
            });
  }
Exemple #20
0
 public void copyMessage(MessageReference reference, String destFolderName) {
   mController.copyMessage(mAccount, mMessageReference.folderName, mMessage, destFolderName, null);
 }
Exemple #21
0
  public static void updateWidget(
      Context context, AppWidgetManager appWidgetManager, int appWidgetId, String accountUuid) {

    RemoteViews remoteViews =
        new RemoteViews(context.getPackageName(), R.layout.unread_widget_layout);

    int unreadCount = 0;
    String accountName = context.getString(R.string.app_name);
    Intent clickIntent = null;
    try {
      BaseAccount account = null;
      AccountStats stats = null;

      SearchAccount searchAccount = null;
      if (SearchAccount.UNIFIED_INBOX.equals(accountUuid)) {
        searchAccount = SearchAccount.createUnifiedInboxAccount(context);
      } else if (SearchAccount.ALL_MESSAGES.equals(accountUuid)) {
        searchAccount = SearchAccount.createAllMessagesAccount(context);
      }

      if (searchAccount != null) {
        account = searchAccount;
        MessagingController controller = MessagingController.getInstance(K9.app);
        stats = controller.getSearchAccountStatsSynchronous(searchAccount, null);
        clickIntent =
            MessageList.intentDisplaySearch(
                context, searchAccount.getRelatedSearch(), false, true, true);
      } else {
        Account realAccount = Preferences.getPreferences(context).getAccount(accountUuid);
        if (realAccount != null) {
          account = realAccount;
          stats = realAccount.getStats(context);

          if (K9.FOLDER_NONE.equals(realAccount.getAutoExpandFolderName())) {
            clickIntent = FolderList.actionHandleAccountIntent(context, realAccount, null, false);
          } else {
            LocalSearch search = new LocalSearch(realAccount.getAutoExpandFolderName());
            search.addAllowedFolder(realAccount.getAutoExpandFolderName());
            search.addAccountUuid(account.getUuid());
            clickIntent = MessageList.intentDisplaySearch(context, search, false, true, true);
          }
          clickIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
        }
      }

      if (account != null) {
        accountName = account.getDescription();
      }

      if (stats != null) {
        unreadCount = stats.unreadMessageCount;
      }
    } catch (Exception e) {
      if (K9.DEBUG) {
        Log.e(K9.LOG_TAG, "Error getting widget configuration", e);
      }
    }

    if (unreadCount <= 0) {
      // Hide TextView for unread count if there are no unread messages.
      remoteViews.setViewVisibility(R.id.unread_count, View.GONE);
    } else {
      remoteViews.setViewVisibility(R.id.unread_count, View.VISIBLE);

      String displayCount =
          (unreadCount <= MAX_COUNT)
              ? String.valueOf(unreadCount)
              : String.valueOf(MAX_COUNT) + "+";
      remoteViews.setTextViewText(R.id.unread_count, displayCount);
    }

    remoteViews.setTextViewText(R.id.account_name, accountName);

    if (clickIntent == null) {
      // If the widget configuration couldn't be loaded we open the configuration
      // activity when the user clicks the widget.
      clickIntent = new Intent(context, UnreadWidgetConfiguration.class);
      clickIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
    }
    clickIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

    PendingIntent pendingIntent = PendingIntent.getActivity(context, appWidgetId, clickIntent, 0);

    remoteViews.setOnClickPendingIntent(R.id.unread_widget_layout, pendingIntent);

    appWidgetManager.updateAppWidget(appWidgetId, remoteViews);
  }
Exemple #22
0
  private void onRefresh(final boolean forceRemote) {

    MessagingController.getInstance(getApplication())
        .listFolders(mAccount, forceRemote, mAdapter.mListener);
  }
Exemple #23
0
 @Override
 public void onPause() {
   super.onPause();
   MessagingController.getInstance(getApplication()).removeListener(mAdapter.mListener);
 }
Exemple #24
0
 private void onSendAlternate() {
   if (mMessage != null) {
     mController.sendAlternate(getActivity(), mAccount, mMessage);
   }
 }
Exemple #25
0
  private void onEmptyTrash(final Account account) {
    mHandler.dataChanged();

    MessagingController.getInstance(getApplication()).emptyTrash(account, null);
  }
Exemple #26
0
 private void onExpunge(final Account account, String folderName) {
   MessagingController.getInstance(getApplication()).expunge(account, folderName, null);
 }
Exemple #27
0
 private void sendMail(Account account) {
   MessagingController.getInstance(getApplication())
       .sendPendingMessages(account, mAdapter.mListener);
 }
Exemple #28
0
 private void refileMessage(String dstFolder) {
   String srcFolder = mMessageReference.folderName;
   Message messageToMove = mMessage;
   mFragmentListener.showNextMessageOrReturn();
   mController.moveMessage(mAccount, srcFolder, messageToMove, dstFolder, null);
 }
Exemple #29
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
      case R.id.compose:
        MessageCompose.actionCompose(this, mAccount);

        return true;

      case R.id.check_mail:
        MessagingController.getInstance(getApplication())
            .checkMail(this, mAccount, true, true, mAdapter.mListener);

        return true;

      case R.id.send_messages:
        MessagingController.getInstance(getApplication()).sendPendingMessages(mAccount, null);
        return true;
      case R.id.accounts:
        onAccounts();

        return true;

      case R.id.list_folders:
        onRefresh(REFRESH_REMOTE);

        return true;

      case R.id.account_settings:
        onEditAccount();

        return true;

      case R.id.app_settings:
        onEditPrefs();

        return true;

      case R.id.empty_trash:
        onEmptyTrash(mAccount);

        return true;

      case R.id.compact:
        onCompact(mAccount);

        return true;

      case R.id.export:
        onExport(mAccount);
        return true;

      case R.id.export_all:
        onExport(null);
        return true;

      case R.id.display_1st_class:
        {
          setDisplayMode(FolderMode.FIRST_CLASS);
          return true;
        }
      case R.id.display_1st_and_2nd_class:
        {
          setDisplayMode(FolderMode.FIRST_AND_SECOND_CLASS);
          return true;
        }
      case R.id.display_not_second_class:
        {
          setDisplayMode(FolderMode.NOT_SECOND_CLASS);
          return true;
        }
      case R.id.display_all:
        {
          setDisplayMode(FolderMode.ALL);
          return true;
        }
      default:
        return super.onOptionsItemSelected(item);
    }
  }
Exemple #30
0
 private void onCompact(Account account) {
   mHandler.workingAccount(R.string.compacting_account);
   MessagingController.getInstance(getApplication()).compact(account, null);
 }