Exemple #1
0
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) {
      case ACTIVITY_CHOOSE_FOLDER:
        if (resultCode == RESULT_OK && data != null) {
          // obtain the filename
          Uri fileUri = data.getData();
          if (fileUri != null) {
            String filePath = fileUri.getPath();
            if (filePath != null) {
              mAttachmentPathPreference.setSummary(filePath.toString());
              K9.setAttachmentDefaultPath(filePath.toString());
            }
          }
        }
        break;
    }

    super.onActivityResult(requestCode, resultCode, data);
  }
Exemple #2
0
  private void saveSettings() {
    SharedPreferences preferences = Preferences.getPreferences(this).getPreferences();

    K9.setK9Language(mLanguage.getValue());

    K9.setK9Theme(themeNameToId(mTheme.getValue()));
    K9.setUseFixedMessageViewTheme(mFixedMessageTheme.isChecked());
    K9.setK9MessageViewThemeSetting(themeNameToId(mMessageTheme.getValue()));
    K9.setK9ComposerThemeSetting(themeNameToId(mComposerTheme.getValue()));

    K9.setAnimations(mAnimations.isChecked());
    K9.setGesturesEnabled(mGestures.isChecked());
    K9.setUseVolumeKeysForNavigation(mVolumeNavigation.getCheckedItems()[0]);
    K9.setUseVolumeKeysForListNavigation(mVolumeNavigation.getCheckedItems()[1]);
    K9.setStartIntegratedInbox(
        !mHideSpecialAccounts.isChecked() && mStartIntegratedInbox.isChecked());
    K9.setNotificationHideSubject(
        NotificationHideSubject.valueOf(mNotificationHideSubject.getValue()));

    int index = 0;
    K9.setConfirmDelete(mConfirmActions.getCheckedItems()[index++]);
    K9.setConfirmDeleteStarred(mConfirmActions.getCheckedItems()[index++]);
    if (NotificationController.platformSupportsExtendedNotifications()) {
      K9.setConfirmDeleteFromNotification(mConfirmActions.getCheckedItems()[index++]);
    }
    K9.setConfirmSpam(mConfirmActions.getCheckedItems()[index++]);
    K9.setConfirmDiscardMessage(mConfirmActions.getCheckedItems()[index++]);

    K9.setMeasureAccounts(mMeasureAccounts.isChecked());
    K9.setCountSearchMessages(mCountSearch.isChecked());
    K9.setHideSpecialAccounts(mHideSpecialAccounts.isChecked());
    K9.setMessageListPreviewLines(Integer.parseInt(mPreviewLines.getValue()));
    K9.setMessageListCheckboxes(mCheckboxes.isChecked());
    K9.setMessageListStars(mStars.isChecked());
    K9.setShowCorrespondentNames(mShowCorrespondentNames.isChecked());
    K9.setMessageListSenderAboveSubject(mSenderAboveSubject.isChecked());
    K9.setShowContactName(mShowContactName.isChecked());
    K9.setShowContactPicture(mShowContactPicture.isChecked());
    K9.setColorizeMissingContactPictures(mColorizeMissingContactPictures.isChecked());
    K9.setUseBackgroundAsUnreadIndicator(mBackgroundAsUnreadIndicator.isChecked());
    K9.setThreadedViewEnabled(mThreadedView.isChecked());
    K9.setChangeContactNameColor(mChangeContactNameColor.isChecked());
    K9.setMessageViewFixedWidthFont(mFixedWidth.isChecked());
    K9.setMessageViewReturnToList(mReturnToList.isChecked());
    K9.setMessageViewShowNext(mShowNext.isChecked());
    K9.setAutofitWidth(mAutofitWidth.isChecked());
    K9.setQuietTimeEnabled(mQuietTimeEnabled.isChecked());

    boolean[] enabledRefileActions = mVisibleRefileActions.getCheckedItems();
    K9.setMessageViewDeleteActionVisible(enabledRefileActions[VISIBLE_REFILE_ACTIONS_DELETE]);
    K9.setMessageViewArchiveActionVisible(enabledRefileActions[VISIBLE_REFILE_ACTIONS_ARCHIVE]);
    K9.setMessageViewMoveActionVisible(enabledRefileActions[VISIBLE_REFILE_ACTIONS_MOVE]);
    K9.setMessageViewCopyActionVisible(enabledRefileActions[VISIBLE_REFILE_ACTIONS_COPY]);
    K9.setMessageViewSpamActionVisible(enabledRefileActions[VISIBLE_REFILE_ACTIONS_SPAM]);

    K9.setCheckMailDuringDoze(checkMailDuringDoze.isChecked());

    K9.setNotificationDuringQuietTimeEnabled(!mDisableNotificationDuringQuietTime.isChecked());
    K9.setQuietTimeStarts(mQuietTimeStarts.getTime());
    K9.setQuietTimeEnds(mQuietTimeEnds.getTime());
    K9.setWrapFolderNames(mWrapFolderNames.isChecked());

    if (mNotificationQuickDelete != null) {
      K9.setNotificationQuickDeleteBehaviour(
          NotificationQuickDelete.valueOf(mNotificationQuickDelete.getValue()));
    }

    if (mLockScreenNotificationVisibility != null) {
      K9.setLockScreenNotificationVisibility(
          K9.LockScreenNotificationVisibility.valueOf(
              mLockScreenNotificationVisibility.getValue()));
    }

    K9.setSplitViewMode(SplitViewMode.valueOf(mSplitViewMode.getValue()));
    K9.setAttachmentDefaultPath(mAttachmentPathPreference.getSummary().toString());
    boolean needsRefresh = K9.setBackgroundOps(mBackgroundOps.getValue());

    if (!K9.DEBUG && mDebugLogging.isChecked()) {
      Toast.makeText(this, R.string.debug_logging_enabled, Toast.LENGTH_LONG).show();
    }
    K9.DEBUG = mDebugLogging.isChecked();
    K9.DEBUG_SENSITIVE = mSensitiveLogging.isChecked();
    K9.setHideUserAgent(mHideUserAgent.isChecked());
    K9.setHideTimeZone(mHideTimeZone.isChecked());

    Editor editor = preferences.edit();
    K9.save(editor);
    editor.commit();

    if (needsRefresh) {
      MailService.actionReset(this, null);
    }
  }