@Override public void run() { StorageEditor editor = preferences.createStorageEditor(); K9.save(editor); editor.commit(); } }).start();
public static void save(StorageEditor editor) { editor.putBoolean("enableDebugLogging", K9.DEBUG); editor.putBoolean("enableSensitiveLogging", K9.DEBUG_SENSITIVE); editor.putString("backgroundOperations", K9.backgroundOps.name()); editor.putBoolean("animations", animations); editor.putBoolean("gesturesEnabled", gesturesEnabled); editor.putBoolean("useVolumeKeysForNavigation", useVolumeKeysForNavigation); editor.putBoolean("useVolumeKeysForListNavigation", useVolumeKeysForListNavigation); editor.putBoolean("autofitWidth", autofitWidth); editor.putBoolean("quietTimeEnabled", quietTimeEnabled); editor.putBoolean("notificationDuringQuietTimeEnabled", notificationDuringQuietTimeEnabled); editor.putString("quietTimeStarts", quietTimeStarts); editor.putString("quietTimeEnds", quietTimeEnds); editor.putBoolean("startIntegratedInbox", startIntegratedInbox); editor.putBoolean("measureAccounts", measureAccounts); editor.putBoolean("countSearchMessages", countSearchMessages); editor.putBoolean("messageListSenderAboveSubject", messageListSenderAboveSubject); editor.putBoolean("hideSpecialAccounts", hideSpecialAccounts); editor.putBoolean("messageListStars", messageListStars); editor.putInt("messageListPreviewLines", messageListPreviewLines); editor.putBoolean("messageListCheckboxes", messageListCheckboxes); editor.putBoolean("showCorrespondentNames", showCorrespondentNames); editor.putBoolean("showContactName", showContactName); editor.putBoolean("showContactPicture", showContactPicture); editor.putBoolean("changeRegisteredNameColor", changeContactNameColor); editor.putInt("registeredNameColor", contactNameColor); editor.putBoolean("messageViewFixedWidthFont", messageViewFixedWidthFont); editor.putBoolean("messageViewReturnToList", messageViewReturnToList); editor.putBoolean("messageViewShowNext", messageViewShowNext);
private void deleteSettings() throws MessagingException { String id = getPrefId(); StorageEditor editor = localStore.getPreferences().createStorageEditor(); editor.remove(id + ".displayMode"); editor.remove(id + ".syncMode"); editor.remove(id + ".pushMode"); editor.remove(id + ".inTopGroup"); editor.remove(id + ".integrate"); editor.commit(); }
private Preferences(Context context, CoreResourceProvider resourceProvider, StoragePersister storagePersister, LocalStoreProvider localStoreProvider, LocalKeyStoreManager localKeyStoreManager, AccountPreferenceSerializer accountPreferenceSerializer) { this.storage = new Storage(); this.storagePersister = storagePersister; this.context = context; this.resourceProvider = resourceProvider; this.localStoreProvider = localStoreProvider; this.localKeyStoreManager = localKeyStoreManager; this.accountPreferenceSerializer = accountPreferenceSerializer; Map<String, String> persistedStorageValues = storagePersister.loadValues(); storage.replaceAll(persistedStorageValues); if (storage.isEmpty()) { Timber.i("Preferences storage is zero-size, importing from Android-style preferences"); StorageEditor editor = createStorageEditor(); editor.copy(context.getSharedPreferences("AndroidMail.Main", Context.MODE_PRIVATE)); editor.commit(); } }
public void save(StorageEditor editor) throws MessagingException { String id = getPrefId(); // there can be a lot of folders. For the defaults, let's not save prefs, saving space, except for INBOX if (displayClass == FolderClass.NO_CLASS && !getServerId().equals(getAccount().getInboxFolder())) { editor.remove(id + ".displayMode"); } else { editor.putString(id + ".displayMode", displayClass.name()); } if (syncClass == FolderClass.INHERITED && !getServerId().equals(getAccount().getInboxFolder())) { editor.remove(id + ".syncMode"); } else { editor.putString(id + ".syncMode", syncClass.name()); } if (notifyClass == FolderClass.INHERITED && !getServerId().equals(getAccount().getInboxFolder())) { editor.remove(id + ".notifyMode"); } else { editor.putString(id + ".notifyMode", notifyClass.name()); } if (pushClass == FolderClass.SECOND_CLASS && !getServerId().equals(getAccount().getInboxFolder())) { editor.remove(id + ".pushMode"); } else { editor.putString(id + ".pushMode", pushClass.name()); } editor.putBoolean(id + ".inTopGroup", isInTopGroup); editor.putBoolean(id + ".integrate", isIntegrate); }
public void save(StorageEditor editor) { editor.putInt(ACCOUNT_NAME, accountName); editor.putInt(ACCOUNT_DESCRIPTION, accountDescription); editor.putInt(FOLDER_NAME, folderName); editor.putInt(FOLDER_STATUS, folderStatus); editor.putInt(MESSAGE_LIST_SUBJECT, messageListSubject); editor.putInt(MESSAGE_LIST_SENDER, messageListSender); editor.putInt(MESSAGE_LIST_DATE, messageListDate); editor.putInt(MESSAGE_LIST_PREVIEW, messageListPreview); editor.putInt(MESSAGE_VIEW_SENDER, messageViewSender); editor.putInt(MESSAGE_VIEW_TO, messageViewTo); editor.putInt(MESSAGE_VIEW_CC, messageViewCC); editor.putInt(MESSAGE_VIEW_BCC, messageViewBCC); editor.putInt(MESSAGE_VIEW_ADDITIONAL_HEADERS, messageViewAdditionalHeaders); editor.putInt(MESSAGE_VIEW_SUBJECT, messageViewSubject); editor.putInt(MESSAGE_VIEW_DATE, messageViewDate); editor.putInt(MESSAGE_VIEW_CONTENT_PERCENT, getMessageViewContentAsPercent()); editor.putInt(MESSAGE_COMPOSE_INPUT, messageComposeInput); }
/** * Write to an {@link SharedPreferences.Editor} while logging what is written if debug logging * is enabled. * * @param editor * The {@code Editor} to write to. * @param key * The name of the preference to modify. * @param value * The new value for the preference. */ private static void putString(StorageEditor editor, String key, String value) { if (K9.isDebug()) { String outputValue = value; if (!K9.DEBUG_SENSITIVE && (key.endsWith(".transportUri") || key.endsWith(".storeUri"))) { outputValue = "*sensitive*"; } Timber.v("Setting %s=%s", key, outputValue); } editor.putString(key, value); }
editor.putBoolean(accountKeyPrefix + "enabled", false);
public void save() throws MessagingException { StorageEditor editor = localStore.getPreferences().createStorageEditor(); save(editor); editor.commit(); }
private static void migrateOpenPgpGlobalToAccountSettings() { Preferences preferences = DI.get(Preferences.class); Storage storage = preferences.getStorage(); String openPgpProvider = storage.getString("openPgpProvider", null); boolean openPgpSupportSignOnly = storage.getBoolean("openPgpSupportSignOnly", false); for (Account account : preferences.getAccounts()) { account.setOpenPgpProvider(openPgpProvider); account.setOpenPgpHideSignOnly(!openPgpSupportSignOnly); preferences.saveAccount(account); } preferences.createStorageEditor() .remove("openPgpProvider") .remove("openPgpSupportSignOnly") .commit(); }
public void move(Account account, boolean mUp) { synchronized (accountLock) { StorageEditor storageEditor = createStorageEditor(); accountPreferenceSerializer.move(storageEditor, account, storage, mUp); storageEditor.commit(); loadAccounts(); } notifyListeners(); }
public static void from41MoveFolderPreferences(MigrationsHelper migrationsHelper) { try { LocalStore localStore = migrationsHelper.getLocalStore(); long startTime = SystemClock.elapsedRealtime(); StorageEditor editor = migrationsHelper.getPreferences().createStorageEditor(); List<? extends Folder > folders = localStore.getPersonalNamespaces(true); for (Folder folder : folders) { if (folder instanceof LocalFolder) { LocalFolder lFolder = (LocalFolder)folder; lFolder.save(editor); } } editor.commit(); long endTime = SystemClock.elapsedRealtime(); Timber.i("Putting folder preferences for %d folders back into Preferences took %d ms", folders.size(), endTime - startTime); } catch (Exception e) { Timber.e(e, "Could not replace Preferences in upgrade from DB_VERSION 41"); } } }
public void saveAccount(Account account) { ensureAssignedAccountNumber(account); processChangedValues(account); StorageEditor editor = createStorageEditor(); accountPreferenceSerializer.save(editor, storage, account); editor.commit(); notifyListeners(); }
editor.commit();
public void deleteAccount(Account account) { synchronized (accountLock) { if (accounts != null) { accounts.remove(account.getUuid()); } if (accountsInOrder != null) { accountsInOrder.remove(account); } try { getBackendManager().removeBackend(account); } catch (Exception e) { Timber.e(e, "Failed to reset remote store for account %s", account.getUuid()); } LocalStore.removeAccount(account); StorageEditor storageEditor = createStorageEditor(); accountPreferenceSerializer.delete(storageEditor, storage, account); storageEditor.commit(); localKeyStoreManager.deleteCertificates(account); if (newAccount == account) { newAccount = null; } } notifyListeners(); }
/** * Update the global FontSize object and permanently store the (possibly * changed) font size settings. */ private void saveSettings() { FontSizes fontSizes = K9.getFontSizes(); fontSizes.setAccountName(Integer.parseInt(mAccountName.getValue())); fontSizes.setAccountDescription(Integer.parseInt(mAccountDescription.getValue())); fontSizes.setFolderName(Integer.parseInt(mFolderName.getValue())); fontSizes.setFolderStatus(Integer.parseInt(mFolderStatus.getValue())); fontSizes.setMessageListSubject(Integer.parseInt(mMessageListSubject.getValue())); fontSizes.setMessageListSender(Integer.parseInt(mMessageListSender.getValue())); fontSizes.setMessageListDate(Integer.parseInt(mMessageListDate.getValue())); fontSizes.setMessageListPreview(Integer.parseInt(mMessageListPreview.getValue())); fontSizes.setMessageViewSender(Integer.parseInt(mMessageViewSender.getValue())); fontSizes.setMessageViewTo(Integer.parseInt(mMessageViewTo.getValue())); fontSizes.setMessageViewCC(Integer.parseInt(mMessageViewCC.getValue())); fontSizes.setMessageViewBCC(Integer.parseInt(mMessageViewBCC.getValue())); fontSizes.setMessageViewAdditionalHeaders(Integer.parseInt(mMessageViewAdditionalHeaders.getValue())); fontSizes.setMessageViewSubject(Integer.parseInt(mMessageViewSubject.getValue())); fontSizes.setMessageViewDate(Integer.parseInt(mMessageViewDate.getValue())); fontSizes.setMessageViewContentAsPercent(scaleToInt(mMessageViewContentSlider.getValue())); fontSizes.setMessageComposeInput(Integer.parseInt(mMessageComposeInput.getValue())); StorageEditor editor = Preferences.getPreferences(this).createStorageEditor(); fontSizes.save(editor); editor.commit(); }
Timber.w("Was asked to import global settings but none found."); if (editor.commit()) { Timber.v("Committed global settings to the preference storage."); globalSettingsImported = true; imported.contentVersion, account, overwrite); if (editor.commit()) { Timber.v("Committed settings for account \"%s\" to the settings database.", importResult.imported.name); if (!editor.commit()) { throw new SettingsImportExportException("Failed to set account UUID list"); if (!editor.commit()) { throw new SettingsImportExportException("Failed to set default account");
editor.commit();