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;
}
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;
}
});
}
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;
}
}
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;
}
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);
}
Aggregations