Search in sources :

Example 61 with Account

use of com.fsck.k9.Account in project k-9 by k9mail.

the class IdentityAdapter method getView.

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    Object item = mItems.get(position);
    View view = null;
    if (item instanceof Account) {
        if (convertView != null && convertView.getTag() instanceof AccountHolder) {
            view = convertView;
        } else {
            view = mLayoutInflater.inflate(R.layout.choose_account_item, parent, false);
            AccountHolder holder = new AccountHolder();
            holder.name = (TextView) view.findViewById(R.id.name);
            holder.chip = view.findViewById(R.id.chip);
            view.setTag(holder);
        }
        Account account = (Account) item;
        AccountHolder holder = (AccountHolder) view.getTag();
        holder.name.setText(account.getDescription());
        holder.chip.setBackgroundColor(account.getChipColor());
    } else if (item instanceof IdentityContainer) {
        if (convertView != null && convertView.getTag() instanceof IdentityHolder) {
            view = convertView;
        } else {
            view = mLayoutInflater.inflate(R.layout.choose_identity_item, parent, false);
            IdentityHolder holder = new IdentityHolder();
            holder.name = (TextView) view.findViewById(R.id.name);
            holder.description = (TextView) view.findViewById(R.id.description);
            view.setTag(holder);
        }
        IdentityContainer identityContainer = (IdentityContainer) item;
        Identity identity = identityContainer.identity;
        IdentityHolder holder = (IdentityHolder) view.getTag();
        holder.name.setText(identity.getDescription());
        holder.description.setText(getIdentityDescription(identity));
    }
    return view;
}
Also used : Account(com.fsck.k9.Account) TextView(android.widget.TextView) Identity(com.fsck.k9.Identity) TextView(android.widget.TextView) View(android.view.View)

Example 62 with Account

use of com.fsck.k9.Account in project k-9 by k9mail.

the class FolderSettings method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    String folderName = (String) getIntent().getSerializableExtra(EXTRA_FOLDER_NAME);
    String accountUuid = getIntent().getStringExtra(EXTRA_ACCOUNT);
    Account mAccount = Preferences.getPreferences(this).getAccount(accountUuid);
    try {
        LocalStore localStore = mAccount.getLocalStore();
        mFolder = localStore.getFolder(folderName);
        mFolder.open(Folder.OPEN_MODE_RW);
    } catch (MessagingException me) {
        Timber.e(me, "Unable to edit folder %s preferences", folderName);
        return;
    }
    boolean isPushCapable = false;
    try {
        Store store = mAccount.getRemoteStore();
        isPushCapable = store.isPushCapable();
    } catch (Exception e) {
        Timber.e(e, "Could not get remote store");
    }
    addPreferencesFromResource(R.xml.folder_settings_preferences);
    String displayName = FolderInfoHolder.getDisplayName(this, mAccount, mFolder.getName());
    Preference category = findPreference(PREFERENCE_TOP_CATERGORY);
    category.setTitle(displayName);
    mInTopGroup = (CheckBoxPreference) findPreference(PREFERENCE_IN_TOP_GROUP);
    mInTopGroup.setChecked(mFolder.isInTopGroup());
    mIntegrate = (CheckBoxPreference) findPreference(PREFERENCE_INTEGRATE);
    mIntegrate.setChecked(mFolder.isIntegrate());
    mDisplayClass = (ListPreference) findPreference(PREFERENCE_DISPLAY_CLASS);
    mDisplayClass.setValue(mFolder.getDisplayClass().name());
    mDisplayClass.setSummary(mDisplayClass.getEntry());
    mDisplayClass.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {

        public boolean onPreferenceChange(Preference preference, Object newValue) {
            final String summary = newValue.toString();
            int index = mDisplayClass.findIndexOfValue(summary);
            mDisplayClass.setSummary(mDisplayClass.getEntries()[index]);
            mDisplayClass.setValue(summary);
            return false;
        }
    });
    mSyncClass = (ListPreference) findPreference(PREFERENCE_SYNC_CLASS);
    mSyncClass.setValue(mFolder.getRawSyncClass().name());
    mSyncClass.setSummary(mSyncClass.getEntry());
    mSyncClass.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {

        public boolean onPreferenceChange(Preference preference, Object newValue) {
            final String summary = newValue.toString();
            int index = mSyncClass.findIndexOfValue(summary);
            mSyncClass.setSummary(mSyncClass.getEntries()[index]);
            mSyncClass.setValue(summary);
            return false;
        }
    });
    mPushClass = (ListPreference) findPreference(PREFERENCE_PUSH_CLASS);
    mPushClass.setEnabled(isPushCapable);
    mPushClass.setValue(mFolder.getRawPushClass().name());
    mPushClass.setSummary(mPushClass.getEntry());
    mPushClass.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {

        public boolean onPreferenceChange(Preference preference, Object newValue) {
            final String summary = newValue.toString();
            int index = mPushClass.findIndexOfValue(summary);
            mPushClass.setSummary(mPushClass.getEntries()[index]);
            mPushClass.setValue(summary);
            return false;
        }
    });
    mNotifyClass = (ListPreference) findPreference(PREFERENCE_NOTIFY_CLASS);
    mNotifyClass.setValue(mFolder.getRawNotifyClass().name());
    mNotifyClass.setSummary(mNotifyClass.getEntry());
    mNotifyClass.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {

        public boolean onPreferenceChange(Preference preference, Object newValue) {
            final String summary = newValue.toString();
            int index = mNotifyClass.findIndexOfValue(summary);
            mNotifyClass.setSummary(mNotifyClass.getEntries()[index]);
            mNotifyClass.setValue(summary);
            return false;
        }
    });
}
Also used : MessagingException(com.fsck.k9.mail.MessagingException) CheckBoxPreference(android.preference.CheckBoxPreference) ListPreference(android.preference.ListPreference) Preference(android.preference.Preference) Store(com.fsck.k9.mail.Store) LocalStore(com.fsck.k9.mailstore.LocalStore) LocalStore(com.fsck.k9.mailstore.LocalStore) MessagingException(com.fsck.k9.mail.MessagingException)

Example 63 with Account

use of com.fsck.k9.Account in project k-9 by k9mail.

the class RecipientPresenter method initFromReplyToMessage.

public void initFromReplyToMessage(Message message, boolean isReplyAll) {
    ReplyToAddresses replyToAddresses = isReplyAll ? replyToParser.getRecipientsToReplyAllTo(message, account) : replyToParser.getRecipientsToReplyTo(message, account);
    addToAddresses(replyToAddresses.to);
    addCcAddresses(replyToAddresses.cc);
    boolean shouldSendAsPgpInline = composePgpInlineDecider.shouldReplyInline(message);
    if (shouldSendAsPgpInline) {
        cryptoEnablePgpInline = true;
    }
}
Also used : ReplyToAddresses(com.fsck.k9.helper.ReplyToParser.ReplyToAddresses)

Example 64 with Account

use of com.fsck.k9.Account in project k-9 by k9mail.

the class BaseNotificationsTest method createFakeAccount.

private Account createFakeAccount() {
    Account account = mock(Account.class);
    when(account.getAccountNumber()).thenReturn(ACCOUNT_NUMBER);
    when(account.getChipColor()).thenReturn(ACCOUNT_COLOR);
    return account;
}
Also used : Account(com.fsck.k9.Account)

Example 65 with Account

use of com.fsck.k9.Account in project k-9 by k9mail.

the class BaseNotificationsTest method testCreateBigTextStyleNotification.

@Test
public void testCreateBigTextStyleNotification() throws Exception {
    Account account = createFakeAccount();
    int notificationId = 23;
    NotificationHolder holder = createNotificationHolder(notificationId);
    Builder builder = notifications.createBigTextStyleNotification(account, holder, notificationId);
    verify(builder).setTicker(NOTIFICATION_SUMMARY);
    verify(builder).setGroup("newMailNotifications-" + ACCOUNT_NUMBER);
    verify(builder).setContentTitle(SENDER);
    verify(builder).setContentText(SUBJECT);
    verify(builder).setSubText(ACCOUNT_NAME);
    BigTextStyle bigTextStyle = notifications.bigTextStyle;
    verify(bigTextStyle).bigText(NOTIFICATION_PREVIEW);
    verify(builder).setStyle(bigTextStyle);
}
Also used : Account(com.fsck.k9.Account) BigTextStyle(android.support.v4.app.NotificationCompat.BigTextStyle) Builder(android.support.v4.app.NotificationCompat.Builder) Test(org.junit.Test)

Aggregations

Account (com.fsck.k9.Account)122 Test (org.junit.Test)81 MessagingException (com.fsck.k9.mail.MessagingException)53 LocalFolder (com.fsck.k9.mailstore.LocalFolder)44 LocalMessage (com.fsck.k9.mailstore.LocalMessage)43 LocalStore (com.fsck.k9.mailstore.LocalStore)42 ArrayList (java.util.ArrayList)34 MessageReference (com.fsck.k9.activity.MessageReference)32 Message (com.fsck.k9.mail.Message)29 Folder (com.fsck.k9.mail.Folder)27 UnavailableStorageException (com.fsck.k9.mailstore.UnavailableStorageException)25 MimeMessage (com.fsck.k9.mail.internet.MimeMessage)22 IOException (java.io.IOException)22 Cursor (android.database.Cursor)21 CertificateValidationException (com.fsck.k9.mail.CertificateValidationException)20 Store (com.fsck.k9.mail.Store)20 SearchAccount (com.fsck.k9.search.SearchAccount)20 PendingIntent (android.app.PendingIntent)19 Pop3Store (com.fsck.k9.mail.store.pop3.Pop3Store)19 AuthenticationFailedException (com.fsck.k9.mail.AuthenticationFailedException)18