use of com.fsck.k9.helper.FileBrowserHelper.FileBrowserFailOverCallback in project k-9 by k9mail.
the class MessageViewFragment method onSaveAttachmentToUserProvidedDirectory.
@Override
public void onSaveAttachmentToUserProvidedDirectory(final AttachmentViewInfo attachment) {
//TODO: check if we have to download the attachment first
currentAttachmentViewInfo = attachment;
FileBrowserHelper.getInstance().showFileBrowserActivity(MessageViewFragment.this, null, ACTIVITY_CHOOSE_DIRECTORY, new FileBrowserFailOverCallback() {
@Override
public void onPathEntered(String path) {
getAttachmentController(attachment).saveAttachmentTo(path);
}
@Override
public void onCancel() {
// Do nothing
}
});
}
use of com.fsck.k9.helper.FileBrowserHelper.FileBrowserFailOverCallback in project k-9 by k9mail.
the class Prefs method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.global_preferences);
mTheme = setupListPreference(PREFERENCE_THEME, themeIdToName(K9.getK9Theme()));
mFixedMessageTheme = (CheckBoxPreference) findPreference(PREFERENCE_FIXED_MESSAGE_THEME);
mFixedMessageTheme.setChecked(K9.useFixedMessageViewTheme());
mMessageTheme = setupListPreference(PREFERENCE_MESSAGE_VIEW_THEME, themeIdToName(K9.getK9MessageViewThemeSetting()));
mComposerTheme = setupListPreference(PREFERENCE_COMPOSER_THEME, themeIdToName(K9.getK9ComposerThemeSetting()));
findPreference(PREFERENCE_FONT_SIZE).setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
public boolean onPreferenceClick(Preference preference) {
onFontSizeSettings();
return true;
}
});
mAnimations = (CheckBoxPreference) findPreference(PREFERENCE_ANIMATIONS);
mAnimations.setChecked(K9.showAnimations());
mGestures = (CheckBoxPreference) findPreference(PREFERENCE_GESTURES);
mGestures.setChecked(K9.gesturesEnabled());
mVolumeNavigation = (CheckBoxListPreference) findPreference(PREFERENCE_VOLUME_NAVIGATION);
mVolumeNavigation.setItems(new CharSequence[] { getString(R.string.volume_navigation_message), getString(R.string.volume_navigation_list) });
mVolumeNavigation.setCheckedItems(new boolean[] { K9.useVolumeKeysForNavigationEnabled(), K9.useVolumeKeysForListNavigationEnabled() });
mStartIntegratedInbox = (CheckBoxPreference) findPreference(PREFERENCE_START_INTEGRATED_INBOX);
mStartIntegratedInbox.setChecked(K9.startIntegratedInbox());
mConfirmActions = (CheckBoxListPreference) findPreference(PREFERENCE_CONFIRM_ACTIONS);
boolean canDeleteFromNotification = NotificationController.platformSupportsExtendedNotifications();
CharSequence[] confirmActionEntries = new CharSequence[canDeleteFromNotification ? 6 : 5];
boolean[] confirmActionValues = new boolean[confirmActionEntries.length];
int index = 0;
confirmActionEntries[index] = getString(R.string.global_settings_confirm_action_delete);
confirmActionValues[index++] = K9.confirmDelete();
confirmActionEntries[index] = getString(R.string.global_settings_confirm_action_delete_starred);
confirmActionValues[index++] = K9.confirmDeleteStarred();
if (canDeleteFromNotification) {
confirmActionEntries[index] = getString(R.string.global_settings_confirm_action_delete_notif);
confirmActionValues[index++] = K9.confirmDeleteFromNotification();
}
confirmActionEntries[index] = getString(R.string.global_settings_confirm_action_spam);
confirmActionValues[index++] = K9.confirmSpam();
confirmActionEntries[index] = getString(R.string.global_settings_confirm_menu_discard);
confirmActionValues[index++] = K9.confirmDiscardMessage();
confirmActionEntries[index] = getString(R.string.global_settings_confirm_menu_mark_all_read);
confirmActionValues[index++] = K9.confirmMarkAllRead();
mConfirmActions.setItems(confirmActionEntries);
mConfirmActions.setCheckedItems(confirmActionValues);
mNotificationHideSubject = setupListPreference(PREFERENCE_NOTIFICATION_HIDE_SUBJECT, K9.getNotificationHideSubject().toString());
mMeasureAccounts = (CheckBoxPreference) findPreference(PREFERENCE_MEASURE_ACCOUNTS);
mMeasureAccounts.setChecked(K9.measureAccounts());
mCountSearch = (CheckBoxPreference) findPreference(PREFERENCE_COUNT_SEARCH);
mCountSearch.setChecked(K9.countSearchMessages());
mHideSpecialAccounts = (CheckBoxPreference) findPreference(PREFERENCE_HIDE_SPECIAL_ACCOUNTS);
mHideSpecialAccounts.setChecked(K9.isHideSpecialAccounts());
mPreviewLines = setupListPreference(PREFERENCE_MESSAGELIST_PREVIEW_LINES, Integer.toString(K9.messageListPreviewLines()));
mSenderAboveSubject = (CheckBoxPreference) findPreference(PREFERENCE_MESSAGELIST_SENDER_ABOVE_SUBJECT);
mSenderAboveSubject.setChecked(K9.messageListSenderAboveSubject());
mCheckboxes = (CheckBoxPreference) findPreference(PREFERENCE_MESSAGELIST_CHECKBOXES);
mCheckboxes.setChecked(K9.messageListCheckboxes());
mStars = (CheckBoxPreference) findPreference(PREFERENCE_MESSAGELIST_STARS);
mStars.setChecked(K9.messageListStars());
mShowCorrespondentNames = (CheckBoxPreference) findPreference(PREFERENCE_MESSAGELIST_SHOW_CORRESPONDENT_NAMES);
mShowCorrespondentNames.setChecked(K9.showCorrespondentNames());
mShowContactName = (CheckBoxPreference) findPreference(PREFERENCE_MESSAGELIST_SHOW_CONTACT_NAME);
mShowContactName.setChecked(K9.showContactName());
mShowContactPicture = (CheckBoxPreference) findPreference(PREFERENCE_MESSAGELIST_SHOW_CONTACT_PICTURE);
mShowContactPicture.setChecked(K9.showContactPicture());
mColorizeMissingContactPictures = (CheckBoxPreference) findPreference(PREFERENCE_MESSAGELIST_COLORIZE_MISSING_CONTACT_PICTURES);
mColorizeMissingContactPictures.setChecked(K9.isColorizeMissingContactPictures());
mBackgroundAsUnreadIndicator = (CheckBoxPreference) findPreference(PREFERENCE_BACKGROUND_AS_UNREAD_INDICATOR);
mBackgroundAsUnreadIndicator.setChecked(K9.useBackgroundAsUnreadIndicator());
mChangeContactNameColor = (CheckBoxPreference) findPreference(PREFERENCE_MESSAGELIST_CONTACT_NAME_COLOR);
mChangeContactNameColor.setChecked(K9.changeContactNameColor());
mThreadedView = (CheckBoxPreference) findPreference(PREFERENCE_THREADED_VIEW);
mThreadedView.setChecked(K9.isThreadedViewEnabled());
if (K9.changeContactNameColor()) {
mChangeContactNameColor.setSummary(R.string.global_settings_registered_name_color_changed);
} else {
mChangeContactNameColor.setSummary(R.string.global_settings_registered_name_color_default);
}
mChangeContactNameColor.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
public boolean onPreferenceChange(Preference preference, Object newValue) {
final Boolean checked = (Boolean) newValue;
if (checked) {
onChooseContactNameColor();
mChangeContactNameColor.setSummary(R.string.global_settings_registered_name_color_changed);
} else {
mChangeContactNameColor.setSummary(R.string.global_settings_registered_name_color_default);
}
mChangeContactNameColor.setChecked(checked);
return false;
}
});
mFixedWidth = (CheckBoxPreference) findPreference(PREFERENCE_MESSAGEVIEW_FIXEDWIDTH);
mFixedWidth.setChecked(K9.messageViewFixedWidthFont());
mReturnToList = (CheckBoxPreference) findPreference(PREFERENCE_MESSAGEVIEW_RETURN_TO_LIST);
mReturnToList.setChecked(K9.messageViewReturnToList());
mShowNext = (CheckBoxPreference) findPreference(PREFERENCE_MESSAGEVIEW_SHOW_NEXT);
mShowNext.setChecked(K9.messageViewShowNext());
mAutofitWidth = (CheckBoxPreference) findPreference(PREFERENCE_AUTOFIT_WIDTH);
mAutofitWidth.setChecked(K9.autofitWidth());
mQuietTimeEnabled = (CheckBoxPreference) findPreference(PREFERENCE_QUIET_TIME_ENABLED);
mQuietTimeEnabled.setChecked(K9.getQuietTimeEnabled());
mDisableNotificationDuringQuietTime = (CheckBoxPreference) findPreference(PREFERENCE_DISABLE_NOTIFICATION_DURING_QUIET_TIME);
mDisableNotificationDuringQuietTime.setChecked(!K9.isNotificationDuringQuietTimeEnabled());
mQuietTimeStarts = (TimePickerPreference) findPreference(PREFERENCE_QUIET_TIME_STARTS);
mQuietTimeStarts.setDefaultValue(K9.getQuietTimeStarts());
mQuietTimeStarts.setSummary(K9.getQuietTimeStarts());
mQuietTimeStarts.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
public boolean onPreferenceChange(Preference preference, Object newValue) {
final String time = (String) newValue;
mQuietTimeStarts.setSummary(time);
return false;
}
});
mQuietTimeEnds = (TimePickerPreference) findPreference(PREFERENCE_QUIET_TIME_ENDS);
mQuietTimeEnds.setSummary(K9.getQuietTimeEnds());
mQuietTimeEnds.setDefaultValue(K9.getQuietTimeEnds());
mQuietTimeEnds.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
public boolean onPreferenceChange(Preference preference, Object newValue) {
final String time = (String) newValue;
mQuietTimeEnds.setSummary(time);
return false;
}
});
mNotificationQuickDelete = setupListPreference(PREFERENCE_NOTIF_QUICK_DELETE, K9.getNotificationQuickDeleteBehaviour().toString());
if (!NotificationController.platformSupportsExtendedNotifications()) {
PreferenceScreen prefs = (PreferenceScreen) findPreference("notification_preferences");
prefs.removePreference(mNotificationQuickDelete);
mNotificationQuickDelete = null;
}
mLockScreenNotificationVisibility = setupListPreference(PREFERENCE_LOCK_SCREEN_NOTIFICATION_VISIBILITY, K9.getLockScreenNotificationVisibility().toString());
if (!NotificationController.platformSupportsLockScreenNotifications()) {
((PreferenceScreen) findPreference("notification_preferences")).removePreference(mLockScreenNotificationVisibility);
mLockScreenNotificationVisibility = null;
}
mBackgroundOps = setupListPreference(PREFERENCE_BACKGROUND_OPS, K9.getBackgroundOps().name());
mDebugLogging = (CheckBoxPreference) findPreference(PREFERENCE_DEBUG_LOGGING);
mSensitiveLogging = (CheckBoxPreference) findPreference(PREFERENCE_SENSITIVE_LOGGING);
mHideUserAgent = (CheckBoxPreference) findPreference(PREFERENCE_HIDE_USERAGENT);
mHideTimeZone = (CheckBoxPreference) findPreference(PREFERENCE_HIDE_TIMEZONE);
mDebugLogging.setChecked(K9.isDebug());
mSensitiveLogging.setChecked(K9.DEBUG_SENSITIVE);
mHideUserAgent.setChecked(K9.hideUserAgent());
mHideTimeZone.setChecked(K9.hideTimeZone());
mOpenPgpProvider = (OpenPgpAppPreference) findPreference(PREFERENCE_OPENPGP_PROVIDER);
mOpenPgpProvider.setValue(K9.getOpenPgpProvider());
if (OpenPgpAppPreference.isApgInstalled(getApplicationContext())) {
mOpenPgpProvider.addLegacyProvider(APG_PROVIDER_PLACEHOLDER, getString(R.string.apg), R.drawable.ic_apg_small);
}
mOpenPgpProvider.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
public boolean onPreferenceChange(Preference preference, Object newValue) {
String value = newValue.toString();
if (APG_PROVIDER_PLACEHOLDER.equals(value)) {
mOpenPgpProvider.setValue("");
showDialog(DIALOG_APG_DEPRECATION_WARNING);
} else {
mOpenPgpProvider.setValue(value);
}
return false;
}
});
mOpenPgpSupportSignOnly = (CheckBoxPreference) findPreference(PREFERENCE_OPENPGP_SUPPORT_SIGN_ONLY);
mOpenPgpSupportSignOnly.setChecked(K9.getOpenPgpSupportSignOnly());
mAttachmentPathPreference = findPreference(PREFERENCE_ATTACHMENT_DEF_PATH);
mAttachmentPathPreference.setSummary(K9.getAttachmentDefaultPath());
mAttachmentPathPreference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
FileBrowserHelper.getInstance().showFileBrowserActivity(Prefs.this, new File(K9.getAttachmentDefaultPath()), ACTIVITY_CHOOSE_FOLDER, callback);
return true;
}
FileBrowserFailOverCallback callback = new FileBrowserFailOverCallback() {
@Override
public void onPathEntered(String path) {
mAttachmentPathPreference.setSummary(path);
K9.setAttachmentDefaultPath(path);
}
@Override
public void onCancel() {
// canceled, do nothing
}
};
});
mWrapFolderNames = (CheckBoxPreference) findPreference(PREFERENCE_FOLDERLIST_WRAP_NAME);
mWrapFolderNames.setChecked(K9.wrapFolderNames());
mVisibleRefileActions = (CheckBoxListPreference) findPreference(PREFERENCE_MESSAGEVIEW_VISIBLE_REFILE_ACTIONS);
CharSequence[] visibleRefileActionsEntries = new CharSequence[5];
visibleRefileActionsEntries[VISIBLE_REFILE_ACTIONS_DELETE] = getString(R.string.delete_action);
visibleRefileActionsEntries[VISIBLE_REFILE_ACTIONS_ARCHIVE] = getString(R.string.archive_action);
visibleRefileActionsEntries[VISIBLE_REFILE_ACTIONS_MOVE] = getString(R.string.move_action);
visibleRefileActionsEntries[VISIBLE_REFILE_ACTIONS_COPY] = getString(R.string.copy_action);
visibleRefileActionsEntries[VISIBLE_REFILE_ACTIONS_SPAM] = getString(R.string.spam_action);
boolean[] visibleRefileActionsValues = new boolean[5];
visibleRefileActionsValues[VISIBLE_REFILE_ACTIONS_DELETE] = K9.isMessageViewDeleteActionVisible();
visibleRefileActionsValues[VISIBLE_REFILE_ACTIONS_ARCHIVE] = K9.isMessageViewArchiveActionVisible();
visibleRefileActionsValues[VISIBLE_REFILE_ACTIONS_MOVE] = K9.isMessageViewMoveActionVisible();
visibleRefileActionsValues[VISIBLE_REFILE_ACTIONS_COPY] = K9.isMessageViewCopyActionVisible();
visibleRefileActionsValues[VISIBLE_REFILE_ACTIONS_SPAM] = K9.isMessageViewSpamActionVisible();
mVisibleRefileActions.setItems(visibleRefileActionsEntries);
mVisibleRefileActions.setCheckedItems(visibleRefileActionsValues);
mSplitViewMode = (ListPreference) findPreference(PREFERENCE_SPLITVIEW_MODE);
initListPreference(mSplitViewMode, K9.getSplitViewMode().name(), mSplitViewMode.getEntries(), mSplitViewMode.getEntryValues());
}
Aggregations