예제 #1
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);
 }
예제 #2
0
파일: K9.java 프로젝트: klonikar/k-9
  private static void setServicesEnabled(Context context, boolean enabled, Integer wakeLockId) {

    PackageManager pm = context.getPackageManager();

    if (!enabled
        && pm.getComponentEnabledSetting(new ComponentName(context, MailService.class))
            == PackageManager.COMPONENT_ENABLED_STATE_ENABLED) {
      /*
       * If no accounts now exist but the service is still enabled we're about to disable it
       * so we'll reschedule to kill off any existing alarms.
       */
      MailService.actionReset(context, wakeLockId);
    }
    Class<?>[] classes = {MessageCompose.class, BootReceiver.class, MailService.class};

    for (Class<?> clazz : classes) {

      boolean alreadyEnabled =
          pm.getComponentEnabledSetting(new ComponentName(context, clazz))
              == PackageManager.COMPONENT_ENABLED_STATE_ENABLED;

      if (enabled != alreadyEnabled) {
        pm.setComponentEnabledSetting(
            new ComponentName(context, clazz),
            enabled
                ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED
                : PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
            PackageManager.DONT_KILL_APP);
      }
    }

    if (enabled
        && pm.getComponentEnabledSetting(new ComponentName(context, MailService.class))
            == PackageManager.COMPONENT_ENABLED_STATE_ENABLED) {
      /*
       * And now if accounts do exist then we've just enabled the service and we want to
       * schedule alarms for the new accounts.
       */
      MailService.actionReset(context, wakeLockId);
    }
  }
예제 #3
0
  private void saveSettings() throws MessagingException {
    mFolder.setInTopGroup(mInTopGroup.isChecked());
    mFolder.setIntegrate(mIntegrate.isChecked());
    // We call getPushClass() because display class changes can affect push class when push class is
    // set to inherit
    FolderClass oldPushClass = mFolder.getPushClass();
    FolderClass oldDisplayClass = mFolder.getDisplayClass();
    mFolder.setDisplayClass(FolderClass.valueOf(mDisplayClass.getValue()));
    mFolder.setSyncClass(FolderClass.valueOf(mSyncClass.getValue()));
    mFolder.setPushClass(FolderClass.valueOf(mPushClass.getValue()));

    mFolder.save();

    FolderClass newPushClass = mFolder.getPushClass();
    FolderClass newDisplayClass = mFolder.getDisplayClass();

    if (oldPushClass != newPushClass
        || (newPushClass != FolderClass.NO_CLASS && oldDisplayClass != newDisplayClass)) {
      MailService.actionRestartPushers(getApplication(), null);
    }
  }
예제 #4
0
파일: Prefs.java 프로젝트: sidamos/k-9
  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);
    }
  }