Пример #1
0
  void acctSelected(ServiceAcctInfo info) {
    Account acct = new Account();
    acct.name = info.desc;
    acct.service = info;

    DialogInterface.OnClickListener emptyClickListener =
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int which) {}
        };

    AcctTables db = new AcctTables(this);
    try {
      db.openWritable();

      try {
        db.pushAccount(acct);
      } catch (SQLiteException e) {
        AlertDialog dlg =
            Utilities.buildAlert(
                this, e, "Unable to add account", "Internal Error", emptyClickListener);
        dlg.show();
        return;
      }
    } finally {
      db.close();
    }

    Intent i = getIntent();
    i.putExtra("acct_id", acct.ID);
    setResult(RESULT_OK, i);
    finish();
  }
  /**
   * Method fired when "add" button is clicked.
   *
   * @param v add button's <tt>View</tt>
   */
  public void onAddClicked(View v) {
    Spinner accountsSpiner = (Spinner) findViewById(R.id.selectAccountSpinner);

    Account selectedAcc = (Account) accountsSpiner.getSelectedItem();
    if (selectedAcc == null) {
      logger.error("No account selected");
      return;
    }

    ProtocolProviderService pps = selectedAcc.getProtocolProvider();
    if (pps == null) {
      logger.error("No provider registered for account " + selectedAcc.getAccountName());
      return;
    }

    View content = findViewById(android.R.id.content);
    String contactAddress = ViewUtil.getTextViewValue(content, R.id.editContactName);

    String displayName = ViewUtil.getTextViewValue(content, R.id.editDisplayName);
    if (displayName != null && displayName.length() > 0) {
      addRenameListener(pps, null, contactAddress, displayName);
    }

    Spinner groupSpinner = (Spinner) findViewById(R.id.selectGroupSpinner);
    ContactListUtils.addContact(
        pps, (MetaContactGroup) groupSpinner.getSelectedItem(), contactAddress);
    finish();
  }
 @Override
 public void onActivityResult(int requestCode, int resultCode, Intent data) {
   if (resultCode == RESULT_OK) {
     if (Intent.ACTION_EDIT.equals(getIntent().getAction())) {
       boolean isPushCapable = false;
       try {
         Store store = mAccount.getRemoteStore();
         isPushCapable = store.isPushCapable();
       } catch (Exception e) {
         Log.e(VisualVoicemail.LOG_TAG, "Could not get remote store", e);
       }
       if (isPushCapable && mAccount.getFolderPushMode() != FolderMode.NONE) {
         MailService.actionRestartPushers(this, null);
       }
       mAccount.save(Preferences.getPreferences(this));
       finish();
     } else {
       // first time setup, return to AccountSetup activity to save account
       setResult(RESULT_OK);
       finish();
     }
   } else {
     if (!Intent.ACTION_EDIT.equals(
         getIntent().getAction())) { // remove account if failed initial setup
       if (mAccount != null) Preferences.getPreferences(this).deleteAccount(mAccount);
     }
   }
 }
Пример #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();
    }
  }
Пример #5
0
 private void refreshFolder(Account account, String folderName) {
   // There has to be a cheaper way to get at the localFolder object than this
   Folder localFolder = null;
   try {
     if (account != null && folderName != null) {
       if (!account.isAvailable(FolderList.this)) {
         Log.i(K9.LOG_TAG, "not refreshing folder of unavailable account");
         return;
       }
       localFolder = account.getLocalStore().getFolder(folderName);
       int unreadMessageCount = localFolder.getUnreadMessageCount();
       FolderInfoHolder folderHolder = getFolder(folderName);
       if (folderHolder != null) {
         folderHolder.populate(context, localFolder, mAccount, unreadMessageCount);
         mHandler.dataChanged();
       }
     }
   } catch (Exception e) {
     Log.e(K9.LOG_TAG, "Exception while populating folder", e);
   } finally {
     if (localFolder != null) {
       localFolder.close();
     }
   }
 }
Пример #6
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);
 }
Пример #7
0
 @Override
 public void listFoldersStarted(Account account) {
   if (account.equals(mAccount)) {
     mHandler.progress(true);
   }
   super.listFoldersStarted(account);
 }
 @Override
 public void onSaveInstanceState(Bundle outState) {
   super.onSaveInstanceState(outState);
   outState.putString(EXTRA_ACCOUNT, mAccount.getUuid());
   outState.putInt(STATE_SECURITY_TYPE_POSITION, mCurrentSecurityTypeViewPosition);
   outState.putInt(STATE_AUTH_TYPE_POSITION, mCurrentAuthTypeViewPosition);
 }
 public static void actionIncomingSettings(
     Activity context, Account account, boolean makeDefault) {
   Intent i = new Intent(context, AccountSetupIncoming.class);
   i.putExtra(EXTRA_ACCOUNT, account.getUuid());
   i.putExtra(EXTRA_MAKE_DEFAULT, makeDefault);
   context.startActivity(i);
 }
Пример #10
0
 @Override
 public void sendPendingMessagesFailed(Account account) {
   super.sendPendingMessagesFailed(account);
   if (account.equals(mAccount)) {
     refreshFolder(account, mAccount.getOutboxFolderName());
   }
 }
Пример #11
0
 @Override
 public void folderStatusChanged(
     Account account, String folderName, int unreadMessageCount) {
   if (account.equals(mAccount)) {
     refreshFolder(account, folderName);
   }
 }
Пример #12
0
          @Override
          public void sendPendingMessagesStarted(Account account) {
            super.sendPendingMessagesStarted(account);

            if (account.equals(mAccount)) {
              mHandler.dataChanged();
            }
          }
Пример #13
0
  private void initializeActivityView() {
    mAdapter = new FolderListAdapter();
    restorePreviousData();

    setListAdapter(mAdapter);

    setTitle(mAccount.getDescription());
  }
Пример #14
0
  public static Intent actionHandleNotification(
      Context context, Account account, String initialFolder) {
    Intent intent =
        new Intent(
            Intent.ACTION_VIEW,
            Uri.parse("email://accounts/" + account.getAccountNumber()),
            context,
            FolderList.class);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.putExtra(EXTRA_ACCOUNT, account.getUuid());
    intent.putExtra(EXTRA_FROM_NOTIFICATION, true);

    if (initialFolder != null) {
      intent.putExtra(EXTRA_INITIAL_FOLDER, initialFolder);
    }
    return intent;
  }
Пример #15
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);
          }
Пример #16
0
 private void onClearFolder(Account account, String folderName) {
   // There has to be a cheaper way to get at the localFolder object than this
   LocalFolder localFolder = null;
   try {
     if (account == null || folderName == null || !account.isAvailable(FolderList.this)) {
       Log.i(K9.LOG_TAG, "not clear folder of unavailable account");
       return;
     }
     localFolder = account.getLocalStore().getFolder(folderName);
     localFolder.open(Folder.OpenMode.READ_WRITE);
     localFolder.clearAllMessages();
   } catch (Exception e) {
     Log.e(K9.LOG_TAG, "Exception while clearing folder", e);
   } finally {
     if (localFolder != null) {
       localFolder.close();
     }
   }
 }
Пример #17
0
          @Override
          public void synchronizeMailboxStarted(Account account, String folder) {
            super.synchronizeMailboxStarted(account, folder);
            if (account.equals(mAccount)) {

              mHandler.progress(true);
              mHandler.folderLoading(folder, true);
              mHandler.dataChanged();
            }
          }
Пример #18
0
          @Override
          public void listFoldersFailed(Account account, String message) {
            if (account.equals(mAccount)) {

              mHandler.progress(false);

              if (Config.LOGV) {
                Log.v(K9.LOG_TAG, "listFoldersFailed " + message);
              }
            }
            super.listFoldersFailed(account, message);
          }
Пример #19
0
          @Override
          public void synchronizeMailboxFinished(
              Account account, String folder, int totalMessagesInMailbox, int numNewMessages) {
            super.synchronizeMailboxFinished(
                account, folder, totalMessagesInMailbox, numNewMessages);
            if (account.equals(mAccount)) {
              mHandler.progress(false);
              mHandler.folderLoading(folder, false);

              refreshFolder(account, folder);
            }
          }
Пример #20
0
          @Override
          public void setPushActive(Account account, String folderName, boolean enabled) {
            if (!account.equals(mAccount)) {
              return;
            }
            FolderInfoHolder holder = getFolder(folderName);

            if (holder != null) {
              holder.pushActive = enabled;

              mHandler.dataChanged();
            }
          }
Пример #21
0
  public static Intent actionHandleAccountIntent(
      Context context, Account account, String initialFolder, boolean fromShortcut) {
    Intent intent = new Intent(context, FolderList.class);
    intent.putExtra(EXTRA_ACCOUNT, account.getUuid());

    if (initialFolder != null) {
      intent.putExtra(EXTRA_INITIAL_FOLDER, initialFolder);
    }

    if (fromShortcut) {
      intent.putExtra(EXTRA_FROM_SHORTCUT, true);
    }

    return intent;
  }
Пример #22
0
  @Override
  public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
    getMenuInflater().inflate(R.menu.folder_context, menu);

    FolderInfoHolder folder = (FolderInfoHolder) mAdapter.getItem(info.position);

    menu.setHeaderTitle(folder.displayName);

    if (!folder.name.equals(mAccount.getTrashFolderName()))
      menu.findItem(R.id.empty_trash).setVisible(false);

    if (folder.name.equals(mAccount.getOutboxFolderName())) {
      menu.findItem(R.id.check_mail).setVisible(false);
    } else {
      menu.findItem(R.id.send_messages).setVisible(false);
    }
    if (K9.ERROR_FOLDER_NAME.equals(folder.name)) {
      menu.findItem(R.id.expunge).setVisible(false);
    }

    menu.setHeaderTitle(folder.displayName);
  }
Пример #23
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);
  }
Пример #24
0
  private void openUnreadSearch(Context context, final Account account) {
    String description =
        getString(
            R.string.search_title, mAccount.getDescription(), getString(R.string.unread_modifier));

    SearchSpecification searchSpec =
        new SearchSpecification() {
          // interface has no override            @Override
          public String[] getAccountUuids() {
            return new String[] {account.getUuid()};
          }

          // interface has no override            @Override
          public Flag[] getForbiddenFlags() {
            return UNREAD_FLAG_ARRAY;
          }

          // interface has no override            @Override
          public String getQuery() {
            return "";
          }

          @Override
          public Flag[] getRequiredFlags() {
            return null;
          }

          @Override
          public boolean isIntegrate() {
            return false;
          }

          @Override
          public String[] getFolderNames() {
            return null;
          }
        };
    MessageList.actionHandle(context, description, searchSpec);
  }
Пример #25
0
          @Override
          public void synchronizeMailboxFailed(Account account, String folder, String message) {
            super.synchronizeMailboxFailed(account, folder, message);
            if (!account.equals(mAccount)) {
              return;
            }

            mHandler.progress(false);

            mHandler.folderLoading(folder, false);

            //   String mess = truncateStatus(message);

            //   mHandler.folderStatus(folder, mess);
            FolderInfoHolder holder = getFolder(folder);

            if (holder != null) {
              holder.lastChecked = 0;
            }

            mHandler.dataChanged();
          }
 public static Intent intentActionEditIncomingSettings(Context context, Account account) {
   Intent i = new Intent(context, AccountSetupIncoming.class);
   i.setAction(Intent.ACTION_EDIT);
   i.putExtra(EXTRA_ACCOUNT, account.getUuid());
   return i;
 }
 public static void actionNewAccountSetup(Activity context, Account account) {
   Intent i = new Intent(context, AccountSetupIncoming.class);
   i.putExtra(EXTRA_ACCOUNT, account.getUuid());
   i.putExtra(EXTRA_MAKE_DEFAULT, true);
   context.startActivityForResult(i, 0);
 }
  protected void onNext() {
    try {

      ConnectionSecurity connectionSecurity = getSelectedSecurity();

      String username = mUsernameView.getText().toString();
      String password = null;
      String clientCertificateAlias = null;

      AuthType authType = getSelectedAuthType();
      if (authType == AuthType.EXTERNAL) {
        clientCertificateAlias = mClientCertificateSpinner.getAlias();
      } else {
        password = mPasswordView.getText().toString();
      }
      String host = mServerView.getText().toString();
      int port = Integer.parseInt(mPortView.getText().toString());

      Map<String, String> extra = null;
      if (Type.IMAP == mStoreType) {
        extra = new HashMap<String, String>();
        extra.put(
            ImapStoreSettings.AUTODETECT_NAMESPACE_KEY,
            Boolean.toString(mImapAutoDetectNamespaceView.isChecked()));
        extra.put(ImapStoreSettings.PATH_PREFIX_KEY, mImapPathPrefixView.getText().toString());
      } else if (Type.WebDAV == mStoreType) {
        extra = new HashMap<String, String>();
        extra.put(WebDavStoreSettings.PATH_KEY, mWebdavPathPrefixView.getText().toString());
        extra.put(WebDavStoreSettings.AUTH_PATH_KEY, mWebdavAuthPathView.getText().toString());
        extra.put(
            WebDavStoreSettings.MAILBOX_PATH_KEY, mWebdavMailboxPathView.getText().toString());
      }

      mAccount.deleteCertificate(host, port, CheckDirection.INCOMING);
      ServerSettings settings =
          new ServerSettings(
              mStoreType,
              host,
              port,
              connectionSecurity,
              authType,
              username,
              password,
              clientCertificateAlias,
              extra);

      mAccount.setStoreUri(RemoteStore.createStoreUri(settings));

      mAccount.setCompression(NetworkType.MOBILE, mCompressionMobile.isChecked());
      mAccount.setCompression(NetworkType.WIFI, mCompressionWifi.isChecked());
      mAccount.setCompression(NetworkType.OTHER, mCompressionOther.isChecked());
      // mAccount.setSubscribedFoldersOnly(mSubscribedFoldersOnly.isChecked());

      // visual voicemail specific setup
      if (!Intent.ACTION_EDIT.equals(getIntent().getAction())) {
        mAccount.setRequiresCellular(mRequiresCellular.isChecked());
        mAccount.setDescription(mAccountName.getText().toString());
        mAccount.setPhoneNumber("");
        mAccount = AccountCreator.initialVisualVoicemailSetup(AccountSetupIncoming.this, mAccount);
      }

      AccountSetupCheckSettings.actionCheckSettings(this, mAccount, CheckDirection.INCOMING);
    } catch (Exception e) {
      failure(e);
    }
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.account_setup_incoming);

    mUsernameView = (EditText) findViewById(R.id.account_username);
    mPasswordView = (EditText) findViewById(R.id.account_password);
    mClientCertificateSpinner =
        (ClientCertificateSpinner) findViewById(R.id.account_client_certificate_spinner);
    mClientCertificateLabelView = (TextView) findViewById(R.id.account_client_certificate_label);
    mPasswordLabelView = (TextView) findViewById(R.id.account_password_label);
    TextView serverLabelView = (TextView) findViewById(R.id.account_server_label);
    mServerView = (EditText) findViewById(R.id.account_server);
    mPortView = (EditText) findViewById(R.id.account_port);
    mSecurityTypeView = (Spinner) findViewById(R.id.account_security_type);
    mAuthTypeView = (Spinner) findViewById(R.id.account_auth_type);
    mImapAutoDetectNamespaceView = (CheckBox) findViewById(R.id.imap_autodetect_namespace);
    mImapPathPrefixView = (EditText) findViewById(R.id.imap_path_prefix);
    mWebdavPathPrefixView = (EditText) findViewById(R.id.webdav_path_prefix);
    mWebdavAuthPathView = (EditText) findViewById(R.id.webdav_auth_path);
    mWebdavMailboxPathView = (EditText) findViewById(R.id.webdav_mailbox_path);
    mNextButton = (Button) findViewById(R.id.next);
    mCompressionMobile = (CheckBox) findViewById(R.id.compression_mobile);
    mCompressionWifi = (CheckBox) findViewById(R.id.compression_wifi);
    mCompressionOther = (CheckBox) findViewById(R.id.compression_other);
    // mSubscribedFoldersOnly = (CheckBox)findViewById(R.id.subscribed_folders_only);
    mRequiresCellular = (CheckBox) findViewById(R.id.account_requires_cellular);
    mAccountName = (EditText) findViewById(R.id.account_name);

    mNextButton.setOnClickListener(this);

    mImapAutoDetectNamespaceView.setOnCheckedChangeListener(
        new OnCheckedChangeListener() {
          @Override
          public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            mImapPathPrefixView.setEnabled(!isChecked);
            if (isChecked && mImapPathPrefixView.hasFocus()) {
              mImapPathPrefixView.focusSearch(View.FOCUS_UP).requestFocus();
            } else if (!isChecked) {
              mImapPathPrefixView.requestFocus();
            }
          }
        });

    mAuthTypeAdapter = AuthTypeAdapter.get(this);
    mAuthTypeView.setAdapter(mAuthTypeAdapter);

    /*
     * Only allow digits in the port field.
     */
    mPortView.setKeyListener(DigitsKeyListener.getInstance("0123456789"));

    String accountUuid = getIntent().getStringExtra(EXTRA_ACCOUNT);
    mAccount = Preferences.getPreferences(this).getAccount(accountUuid);
    // mMakeDefault = getIntent().getBooleanExtra(EXTRA_MAKE_DEFAULT, false);

    /*
     * If we're being reloaded we override the original account with the one
     * we saved
     */
    if (savedInstanceState != null && savedInstanceState.containsKey(EXTRA_ACCOUNT)) {
      accountUuid = savedInstanceState.getString(EXTRA_ACCOUNT);
      mAccount = Preferences.getPreferences(this).getAccount(accountUuid);
    }

    boolean editSettings = Intent.ACTION_EDIT.equals(getIntent().getAction());

    try {
      ServerSettings settings = RemoteStore.decodeStoreUri(mAccount.getStoreUri());

      if (savedInstanceState == null) {
        // The first item is selected if settings.authenticationType is null or is not in
        // mAuthTypeAdapter
        mCurrentAuthTypeViewPosition =
            mAuthTypeAdapter.getAuthPosition(settings.authenticationType);
      } else {
        mCurrentAuthTypeViewPosition = savedInstanceState.getInt(STATE_AUTH_TYPE_POSITION);
      }
      mAuthTypeView.setSelection(mCurrentAuthTypeViewPosition, false);
      updateViewFromAuthType();

      if (settings.username != null) {
        mUsernameView.setText(settings.username);
      }

      if (settings.password != null) {
        mPasswordView.setText(settings.password);
      }

      if (settings.clientCertificateAlias != null) {
        mClientCertificateSpinner.setAlias(settings.clientCertificateAlias);
      }

      mStoreType = settings.type;
      if (Type.POP3 == settings.type) {
        serverLabelView.setText(R.string.account_setup_incoming_pop_server_label);
        findViewById(R.id.imap_path_prefix_section).setVisibility(View.GONE);
        findViewById(R.id.webdav_advanced_header).setVisibility(View.GONE);
        findViewById(R.id.webdav_mailbox_alias_section).setVisibility(View.GONE);
        findViewById(R.id.webdav_owa_path_section).setVisibility(View.GONE);
        findViewById(R.id.webdav_auth_path_section).setVisibility(View.GONE);
        findViewById(R.id.compression_section).setVisibility(View.GONE);
        findViewById(R.id.compression_label).setVisibility(View.GONE);
        // mSubscribedFoldersOnly.setVisibility(View.GONE);
      } else if (Type.IMAP == settings.type) {
        serverLabelView.setText(R.string.account_setup_incoming_imap_server_label);

        ImapStoreSettings imapSettings = (ImapStoreSettings) settings;

        mImapAutoDetectNamespaceView.setChecked(imapSettings.autoDetectNamespace);
        if (imapSettings.pathPrefix != null) {
          mImapPathPrefixView.setText(imapSettings.pathPrefix);
        }

        findViewById(R.id.webdav_advanced_header).setVisibility(View.GONE);
        findViewById(R.id.webdav_mailbox_alias_section).setVisibility(View.GONE);
        findViewById(R.id.webdav_owa_path_section).setVisibility(View.GONE);
        findViewById(R.id.webdav_auth_path_section).setVisibility(View.GONE);

        /*if (!editSettings) {
            findViewById(R.id.imap_folder_setup_section).setVisibility(View.GONE);
        }*/
      } else if (Type.WebDAV == settings.type) {
        serverLabelView.setText(R.string.account_setup_incoming_webdav_server_label);
        mConnectionSecurityChoices =
            new ConnectionSecurity[] {ConnectionSecurity.NONE, ConnectionSecurity.SSL_TLS_REQUIRED};

        // Hide the unnecessary fields
        findViewById(R.id.imap_path_prefix_section).setVisibility(View.GONE);
        findViewById(R.id.account_auth_type_label).setVisibility(View.GONE);
        findViewById(R.id.account_auth_type).setVisibility(View.GONE);
        findViewById(R.id.compression_section).setVisibility(View.GONE);
        findViewById(R.id.compression_label).setVisibility(View.GONE);
        // mSubscribedFoldersOnly.setVisibility(View.GONE);

        WebDavStoreSettings webDavSettings = (WebDavStoreSettings) settings;

        if (webDavSettings.path != null) {
          mWebdavPathPrefixView.setText(webDavSettings.path);
        }

        if (webDavSettings.authPath != null) {
          mWebdavAuthPathView.setText(webDavSettings.authPath);
        }

        if (webDavSettings.mailboxPath != null) {
          mWebdavMailboxPathView.setText(webDavSettings.mailboxPath);
        }
      } else {
        throw new Exception("Unknown account type: " + mAccount.getStoreUri());
      }

      if (!editSettings) {
        mAccount.setDeletePolicy(AccountCreator.getDefaultDeletePolicy(settings.type));
      }

      // Note that mConnectionSecurityChoices is configured above based on server type
      ConnectionSecurityAdapter securityTypesAdapter =
          ConnectionSecurityAdapter.get(this, mConnectionSecurityChoices);
      mSecurityTypeView.setAdapter(securityTypesAdapter);

      // Select currently configured security type
      if (savedInstanceState == null) {
        mCurrentSecurityTypeViewPosition =
            securityTypesAdapter.getConnectionSecurityPosition(settings.connectionSecurity);
      } else {

        /*
         * Restore the spinner state now, before calling
         * setOnItemSelectedListener(), thus avoiding a call to
         * onItemSelected(). Then, when the system restores the state
         * (again) in onRestoreInstanceState(), The system will see that
         * the new state is the same as the current state (set here), so
         * once again onItemSelected() will not be called.
         */
        mCurrentSecurityTypeViewPosition = savedInstanceState.getInt(STATE_SECURITY_TYPE_POSITION);
      }
      mSecurityTypeView.setSelection(mCurrentSecurityTypeViewPosition, false);

      updateAuthPlainTextFromSecurityType(settings.connectionSecurity);

      mCompressionMobile.setChecked(mAccount.useCompression(NetworkType.MOBILE));
      mCompressionWifi.setChecked(mAccount.useCompression(NetworkType.WIFI));
      mCompressionOther.setChecked(mAccount.useCompression(NetworkType.OTHER));

      if (settings.host != null) {
        mServerView.setText(settings.host);
      }

      if (settings.port != -1) {
        mPortView.setText(Integer.toString(settings.port));
      } else {
        updatePortFromSecurityType();
      }
      mCurrentPortViewSetting = mPortView.getText().toString();

      // mSubscribedFoldersOnly.setChecked(mAccount.subscribedFoldersOnly());
    } catch (Exception e) {
      failure(e);
    }
    // show & populate setup fields
    if (!Intent.ACTION_EDIT.equals(getIntent().getAction())) {
      findViewById(R.id.account_name_label).setVisibility(View.VISIBLE);
      mAccountName.setVisibility(View.VISIBLE);
      String desc = mAccount.getDescription();
      mAccountName.setText((desc != null ? desc : ""));
      findViewById(R.id.account_requires_cellular_label).setVisibility(View.VISIBLE);
      mRequiresCellular.setVisibility(View.VISIBLE);
      mRequiresCellular.setChecked(true);
    }
  }
Пример #30
0
 @Override
 public void emptyTrashCompleted(Account account) {
   if (account.equals(mAccount)) {
     refreshFolder(account, mAccount.getTrashFolderName());
   }
 }