示例#1
0
文件: K9.java 项目: klonikar/k-9
  /**
   * Load preferences into our statics.
   *
   * <p>If you're adding a preference here, odds are you'll need to add it to {@link
   * com.fsck.k9.preferences.GlobalSettings}, too.
   *
   * @param prefs Preferences to load
   */
  public static void loadPrefs(Preferences prefs) {
    SharedPreferences sprefs = prefs.getPreferences();
    DEBUG = sprefs.getBoolean("enableDebugLogging", false);
    if (!DEBUG && sIsDebuggable && Debug.isDebuggerConnected()) {
      // If the debugger is attached, we're probably (surprise surprise) debugging something.
      DEBUG = true;
      Log.i(K9.LOG_TAG, "Debugger attached; enabling debug logging.");
    }
    DEBUG_SENSITIVE = sprefs.getBoolean("enableSensitiveLogging", false);
    mAnimations = sprefs.getBoolean("animations", true);
    mGesturesEnabled = sprefs.getBoolean("gesturesEnabled", false);
    mUseVolumeKeysForNavigation = sprefs.getBoolean("useVolumeKeysForNavigation", false);
    mUseVolumeKeysForListNavigation = sprefs.getBoolean("useVolumeKeysForListNavigation", false);
    mStartIntegratedInbox = sprefs.getBoolean("startIntegratedInbox", false);
    mMeasureAccounts = sprefs.getBoolean("measureAccounts", true);
    mCountSearchMessages = sprefs.getBoolean("countSearchMessages", true);
    mHideSpecialAccounts = sprefs.getBoolean("hideSpecialAccounts", false);
    mMessageListSenderAboveSubject = sprefs.getBoolean("messageListSenderAboveSubject", false);
    mMessageListCheckboxes = sprefs.getBoolean("messageListCheckboxes", false);
    mMessageListStars = sprefs.getBoolean("messageListStars", true);
    mMessageListPreviewLines = sprefs.getInt("messageListPreviewLines", 2);

    mAutofitWidth = sprefs.getBoolean("autofitWidth", true);

    mQuietTimeEnabled = sprefs.getBoolean("quietTimeEnabled", false);
    mQuietTimeStarts = sprefs.getString("quietTimeStarts", "21:00");
    mQuietTimeEnds = sprefs.getString("quietTimeEnds", "7:00");

    mShowCorrespondentNames = sprefs.getBoolean("showCorrespondentNames", true);
    mShowContactName = sprefs.getBoolean("showContactName", false);
    sShowContactPicture = sprefs.getBoolean("showContactPicture", true);
    mChangeContactNameColor = sprefs.getBoolean("changeRegisteredNameColor", false);
    mContactNameColor = sprefs.getInt("registeredNameColor", 0xff00008f);
    mMessageViewFixedWidthFont = sprefs.getBoolean("messageViewFixedWidthFont", false);
    mMessageViewReturnToList = sprefs.getBoolean("messageViewReturnToList", false);
    mMessageViewShowNext = sprefs.getBoolean("messageViewShowNext", false);
    mWrapFolderNames = sprefs.getBoolean("wrapFolderNames", false);
    mHideUserAgent = sprefs.getBoolean("hideUserAgent", false);
    mHideTimeZone = sprefs.getBoolean("hideTimeZone", false);

    mConfirmDelete = sprefs.getBoolean("confirmDelete", false);
    mConfirmDeleteStarred = sprefs.getBoolean("confirmDeleteStarred", false);
    mConfirmSpam = sprefs.getBoolean("confirmSpam", false);
    mConfirmDeleteFromNotification = sprefs.getBoolean("confirmDeleteFromNotification", true);

    try {
      String value = sprefs.getString("sortTypeEnum", Account.DEFAULT_SORT_TYPE.name());
      mSortType = SortType.valueOf(value);
    } catch (Exception e) {
      mSortType = Account.DEFAULT_SORT_TYPE;
    }

    boolean sortAscending = sprefs.getBoolean("sortAscending", Account.DEFAULT_SORT_ASCENDING);
    mSortAscending.put(mSortType, sortAscending);

    String notificationHideSubject = sprefs.getString("notificationHideSubject", null);
    if (notificationHideSubject == null) {
      // If the "notificationHideSubject" setting couldn't be found, the app was probably
      // updated. Look for the old "keyguardPrivacy" setting and map it to the new enum.
      sNotificationHideSubject =
          (sprefs.getBoolean("keyguardPrivacy", false))
              ? NotificationHideSubject.WHEN_LOCKED
              : NotificationHideSubject.NEVER;
    } else {
      sNotificationHideSubject = NotificationHideSubject.valueOf(notificationHideSubject);
    }

    String notificationQuickDelete = sprefs.getString("notificationQuickDelete", null);
    if (notificationQuickDelete != null) {
      sNotificationQuickDelete = NotificationQuickDelete.valueOf(notificationQuickDelete);
    }

    String lockScreenNotificationVisibility =
        sprefs.getString("lockScreenNotificationVisibility", null);
    if (lockScreenNotificationVisibility != null) {
      sLockScreenNotificationVisibility =
          LockScreenNotificationVisibility.valueOf(lockScreenNotificationVisibility);
    }

    String splitViewMode = sprefs.getString("splitViewMode", null);
    if (splitViewMode != null) {
      sSplitViewMode = SplitViewMode.valueOf(splitViewMode);
    }

    mAttachmentDefaultPath =
        sprefs.getString(
            "attachmentdefaultpath", Environment.getExternalStorageDirectory().toString());
    sUseBackgroundAsUnreadIndicator = sprefs.getBoolean("useBackgroundAsUnreadIndicator", true);
    sThreadedViewEnabled = sprefs.getBoolean("threadedView", true);
    fontSizes.load(sprefs);

    try {
      setBackgroundOps(
          BACKGROUND_OPS.valueOf(
              sprefs.getString(
                  "backgroundOperations", BACKGROUND_OPS.WHEN_CHECKED_AUTO_SYNC.name())));
    } catch (Exception e) {
      setBackgroundOps(BACKGROUND_OPS.WHEN_CHECKED_AUTO_SYNC);
    }

    sColorizeMissingContactPictures = sprefs.getBoolean("colorizeMissingContactPictures", true);

    sMessageViewArchiveActionVisible = sprefs.getBoolean("messageViewArchiveActionVisible", false);
    sMessageViewDeleteActionVisible = sprefs.getBoolean("messageViewDeleteActionVisible", true);
    sMessageViewMoveActionVisible = sprefs.getBoolean("messageViewMoveActionVisible", false);
    sMessageViewCopyActionVisible = sprefs.getBoolean("messageViewCopyActionVisible", false);
    sMessageViewSpamActionVisible = sprefs.getBoolean("messageViewSpamActionVisible", false);

    K9.setK9Language(sprefs.getString("language", ""));

    int themeValue = sprefs.getInt("theme", Theme.LIGHT.ordinal());
    // We used to save the resource ID of the theme. So convert that to the new format if
    // necessary.
    if (themeValue == Theme.DARK.ordinal() || themeValue == android.R.style.Theme) {
      K9.setK9Theme(Theme.DARK);
    } else {
      K9.setK9Theme(Theme.LIGHT);
    }

    themeValue = sprefs.getInt("messageViewTheme", Theme.USE_GLOBAL.ordinal());
    K9.setK9MessageViewThemeSetting(Theme.values()[themeValue]);
    themeValue = sprefs.getInt("messageComposeTheme", Theme.USE_GLOBAL.ordinal());
    K9.setK9ComposerThemeSetting(Theme.values()[themeValue]);
    K9.setUseFixedMessageViewTheme(sprefs.getBoolean("fixedMessageViewTheme", true));
  }
示例#2
0
文件: K9.java 项目: klonikar/k-9
  /**
   * Save settings from our statics into the app database.
   *
   * <p>If you're adding a preference here, odds are you'll need to add it to {@link
   * com.fsck.k9.preferences.GlobalSettings}, too.
   *
   * @param editor Preferences to save into
   */
  public static void save(SharedPreferences.Editor editor) {
    editor.putBoolean("enableDebugLogging", K9.DEBUG);
    editor.putBoolean("enableSensitiveLogging", K9.DEBUG_SENSITIVE);
    editor.putString("backgroundOperations", K9.backgroundOps.name());
    editor.putBoolean("animations", mAnimations);
    editor.putBoolean("gesturesEnabled", mGesturesEnabled);
    editor.putBoolean("useVolumeKeysForNavigation", mUseVolumeKeysForNavigation);
    editor.putBoolean("useVolumeKeysForListNavigation", mUseVolumeKeysForListNavigation);
    editor.putBoolean("autofitWidth", mAutofitWidth);
    editor.putBoolean("quietTimeEnabled", mQuietTimeEnabled);
    editor.putString("quietTimeStarts", mQuietTimeStarts);
    editor.putString("quietTimeEnds", mQuietTimeEnds);

    editor.putBoolean("startIntegratedInbox", mStartIntegratedInbox);
    editor.putBoolean("measureAccounts", mMeasureAccounts);
    editor.putBoolean("countSearchMessages", mCountSearchMessages);
    editor.putBoolean("messageListSenderAboveSubject", mMessageListSenderAboveSubject);
    editor.putBoolean("hideSpecialAccounts", mHideSpecialAccounts);
    editor.putBoolean("messageListStars", mMessageListStars);
    editor.putInt("messageListPreviewLines", mMessageListPreviewLines);
    editor.putBoolean("messageListCheckboxes", mMessageListCheckboxes);
    editor.putBoolean("showCorrespondentNames", mShowCorrespondentNames);
    editor.putBoolean("showContactName", mShowContactName);
    editor.putBoolean("showContactPicture", sShowContactPicture);
    editor.putBoolean("changeRegisteredNameColor", mChangeContactNameColor);
    editor.putInt("registeredNameColor", mContactNameColor);
    editor.putBoolean("messageViewFixedWidthFont", mMessageViewFixedWidthFont);
    editor.putBoolean("messageViewReturnToList", mMessageViewReturnToList);
    editor.putBoolean("messageViewShowNext", mMessageViewShowNext);
    editor.putBoolean("wrapFolderNames", mWrapFolderNames);
    editor.putBoolean("hideUserAgent", mHideUserAgent);
    editor.putBoolean("hideTimeZone", mHideTimeZone);

    editor.putString("language", language);
    editor.putInt("theme", theme.ordinal());
    editor.putInt("messageViewTheme", messageViewTheme.ordinal());
    editor.putInt("messageComposeTheme", composerTheme.ordinal());
    editor.putBoolean("fixedMessageViewTheme", useFixedMessageTheme);

    editor.putBoolean("confirmDelete", mConfirmDelete);
    editor.putBoolean("confirmDeleteStarred", mConfirmDeleteStarred);
    editor.putBoolean("confirmSpam", mConfirmSpam);
    editor.putBoolean("confirmDeleteFromNotification", mConfirmDeleteFromNotification);

    editor.putString("sortTypeEnum", mSortType.name());
    editor.putBoolean("sortAscending", mSortAscending.get(mSortType));

    editor.putString("notificationHideSubject", sNotificationHideSubject.toString());
    editor.putString("notificationQuickDelete", sNotificationQuickDelete.toString());
    editor.putString(
        "lockScreenNotificationVisibility", sLockScreenNotificationVisibility.toString());

    editor.putString("attachmentdefaultpath", mAttachmentDefaultPath);
    editor.putBoolean("useBackgroundAsUnreadIndicator", sUseBackgroundAsUnreadIndicator);
    editor.putBoolean("threadedView", sThreadedViewEnabled);
    editor.putString("splitViewMode", sSplitViewMode.name());
    editor.putBoolean("colorizeMissingContactPictures", sColorizeMissingContactPictures);

    editor.putBoolean("messageViewArchiveActionVisible", sMessageViewArchiveActionVisible);
    editor.putBoolean("messageViewDeleteActionVisible", sMessageViewDeleteActionVisible);
    editor.putBoolean("messageViewMoveActionVisible", sMessageViewMoveActionVisible);
    editor.putBoolean("messageViewCopyActionVisible", sMessageViewCopyActionVisible);
    editor.putBoolean("messageViewSpamActionVisible", sMessageViewSpamActionVisible);

    fontSizes.save(editor);
  }