Пример #1
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();
    }
  }
Пример #2
0
 private void setDisplayMode(FolderMode newMode) {
   mAccount.setFolderDisplayMode(newMode);
   mAccount.save(Preferences.getPreferences(this));
   if (mAccount.getFolderPushMode() != FolderMode.NONE) {
     MailService.actionRestartPushers(this, null);
   }
   onRefresh(false);
 }
Пример #3
0
          @Override
          public void listFolders(Account account, Folder[] folders) {
            if (account.equals(mAccount)) {

              List<FolderInfoHolder> newFolders = new LinkedList<FolderInfoHolder>();
              List<FolderInfoHolder> topFolders = new LinkedList<FolderInfoHolder>();

              Account.FolderMode aMode = account.getFolderDisplayMode();
              Preferences prefs =
                  Preferences.getPreferences(getApplication().getApplicationContext());
              for (Folder folder : folders) {
                try {
                  folder.refresh(prefs);

                  Folder.FolderClass fMode = folder.getDisplayClass();

                  if ((aMode == Account.FolderMode.FIRST_CLASS
                          && fMode != Folder.FolderClass.FIRST_CLASS)
                      || (aMode == Account.FolderMode.FIRST_AND_SECOND_CLASS
                          && fMode != Folder.FolderClass.FIRST_CLASS
                          && fMode != Folder.FolderClass.SECOND_CLASS)
                      || (aMode == Account.FolderMode.NOT_SECOND_CLASS
                          && fMode == Folder.FolderClass.SECOND_CLASS)) {
                    continue;
                  }
                } catch (MessagingException me) {
                  Log.e(
                      K9.LOG_TAG,
                      "Couldn't get prefs to check for displayability of folder "
                          + folder.getName(),
                      me);
                }

                FolderInfoHolder holder = null;

                int folderIndex = getFolderIndex(folder.getName());
                if (folderIndex >= 0) {
                  holder = (FolderInfoHolder) getItem(folderIndex);
                }
                int unreadMessageCount = 0;
                try {
                  unreadMessageCount = folder.getUnreadMessageCount();
                } catch (Exception e) {
                  Log.e(
                      K9.LOG_TAG,
                      "Unable to get unreadMessageCount for "
                          + mAccount.getDescription()
                          + ":"
                          + folder.getName());
                }

                if (holder == null) {
                  holder = new FolderInfoHolder(context, folder, mAccount, unreadMessageCount);
                } else {
                  holder.populate(context, folder, mAccount, unreadMessageCount);
                }
                if (folder.isInTopGroup()) {
                  topFolders.add(holder);
                } else {
                  newFolders.add(holder);
                }
              }
              Collections.sort(newFolders);
              Collections.sort(topFolders);
              topFolders.addAll(newFolders);
              mHandler.newFolders(topFolders);
            }
            super.listFolders(account, folders);
          }