@Override public void beforePersistTransaction(Map<String, String> workingStorage) { workingStorage.putAll(storage.getAll()); }
static Map<String, String> getFolderSettings(Storage storage, String uuid, String folderName) { Map<String, String> result = new HashMap<>(); String prefix = uuid + "." + folderName + "."; for (String key : SETTINGS.keySet()) { String value = storage.getString(prefix + key, null); if (value != null) { result.put(key, value); } } return result; } }
@Override public void onPersistTransactionSuccess(Map<String, String> workingStorage) { storage.replaceAll(workingStorage); } };
private void loadMessageViewContentPercent(Storage storage) { int fallbackValue = 100; if (!storage.contains(MESSAGE_VIEW_CONTENT_PERCENT)) { int oldValue = storage.getInt(MESSAGE_VIEW_CONTENT, 3); fallbackValue = GlobalSettings.SettingsUpgraderV31.convertFromOldSize(oldValue); } setMessageViewContentAsPercent(storage.getInt(MESSAGE_VIEW_CONTENT_PERCENT, fallbackValue)); }
displayClass = Folder.FolderClass.valueOf(storage.getString(accountUuid + "." + name + ".displayMode", displayClass.name())); syncClass = Folder.FolderClass.valueOf(storage.getString(accountUuid + "." + name + ".syncMode", syncClass.name())); pushClass = Folder.FolderClass.valueOf(storage.getString(accountUuid + "." + name + ".pushMode", pushClass.name())); inTopGroup = storage.getBoolean(accountUuid + "." + name + ".inTopGroup", inTopGroup); integrate = storage.getBoolean(accountUuid + "." + name + ".integrate", integrate); } catch (Exception e) { Timber.e(e, " Throwing away an error while trying to upgrade folder metadata");
setDebug(storage.getBoolean("enableDebugLogging", DEVELOPER_MODE)); DEBUG_SENSITIVE = storage.getBoolean("enableSensitiveLogging", false); animations = storage.getBoolean("animations", true); gesturesEnabled = storage.getBoolean("gesturesEnabled", false); useVolumeKeysForNavigation = storage.getBoolean("useVolumeKeysForNavigation", false); useVolumeKeysForListNavigation = storage.getBoolean("useVolumeKeysForListNavigation", false); startIntegratedInbox = storage.getBoolean("startIntegratedInbox", false); measureAccounts = storage.getBoolean("measureAccounts", true); countSearchMessages = storage.getBoolean("countSearchMessages", true); hideSpecialAccounts = storage.getBoolean("hideSpecialAccounts", false); messageListSenderAboveSubject = storage.getBoolean("messageListSenderAboveSubject", false); messageListCheckboxes = storage.getBoolean("messageListCheckboxes", false); messageListStars = storage.getBoolean("messageListStars", true); messageListPreviewLines = storage.getInt("messageListPreviewLines", 2); autofitWidth = storage.getBoolean("autofitWidth", true); quietTimeEnabled = storage.getBoolean("quietTimeEnabled", false); notificationDuringQuietTimeEnabled = storage.getBoolean("notificationDuringQuietTimeEnabled", true); quietTimeStarts = storage.getString("quietTimeStarts", "21:00"); quietTimeEnds = storage.getString("quietTimeEnds", "7:00"); showCorrespondentNames = storage.getBoolean("showCorrespondentNames", true); showContactName = storage.getBoolean("showContactName", false); showContactPicture = storage.getBoolean("showContactPicture", true); changeContactNameColor = storage.getBoolean("changeRegisteredNameColor", false); contactNameColor = storage.getInt("registeredNameColor", 0xff00008f); messageViewFixedWidthFont = storage.getBoolean("messageViewFixedWidthFont", false); messageViewReturnToList = storage.getBoolean("messageViewReturnToList", false);
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 load(Storage storage) { accountName = storage.getInt(ACCOUNT_NAME, accountName); accountDescription = storage.getInt(ACCOUNT_DESCRIPTION, accountDescription); folderName = storage.getInt(FOLDER_NAME, folderName); folderStatus = storage.getInt(FOLDER_STATUS, folderStatus); messageListSubject = storage.getInt(MESSAGE_LIST_SUBJECT, messageListSubject); messageListSender = storage.getInt(MESSAGE_LIST_SENDER, messageListSender); messageListDate = storage.getInt(MESSAGE_LIST_DATE, messageListDate); messageListPreview = storage.getInt(MESSAGE_LIST_PREVIEW, messageListPreview); messageViewSender = storage.getInt(MESSAGE_VIEW_SENDER, messageViewSender); messageViewTo = storage.getInt(MESSAGE_VIEW_TO, messageViewTo); messageViewCC = storage.getInt(MESSAGE_VIEW_CC, messageViewCC); messageViewBCC = storage.getInt(MESSAGE_VIEW_BCC, messageViewBCC); messageViewAdditionalHeaders = storage.getInt(MESSAGE_VIEW_ADDITIONAL_HEADERS, messageViewAdditionalHeaders); messageViewSubject = storage.getInt(MESSAGE_VIEW_SUBJECT, messageViewSubject); messageViewDate = storage.getInt(MESSAGE_VIEW_DATE, messageViewDate); loadMessageViewContentPercent(storage); messageComposeInput = storage.getInt(MESSAGE_COMPOSE_INPUT, messageComposeInput); }
prefHolder.displayClass = FolderClass.valueOf(storage.getString(id + ".displayMode", prefHolder.displayClass.name())); } catch (Exception e) { prefHolder.syncClass = FolderClass.valueOf(storage.getString(id + ".syncMode", prefHolder.syncClass.name())); } catch (Exception e) { prefHolder.notifyClass = FolderClass.valueOf(storage.getString(id + ".notifyMode", prefHolder.notifyClass.name())); } catch (Exception e) { prefHolder.pushClass = FolderClass.valueOf(storage.getString(id + ".pushMode", prefHolder.pushClass.name())); } catch (Exception e) { prefHolder.pushClass = FolderClass.INHERITED; prefHolder.inTopGroup = storage.getBoolean(id + ".inTopGroup", prefHolder.inTopGroup); prefHolder.integrate = storage.getBoolean(id + ".integrate", prefHolder.integrate);
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(); }
static Map<String, String> getAccountSettings(Storage storage, String uuid) { Map<String, String> result = new HashMap<>(); String prefix = uuid + "."; for (String key : SETTINGS.keySet()) { String value = storage.getString(prefix + key, null); if (value != null) { result.put(key, value); } } return result; }
public K9StorageEditor(Storage storage, K9StoragePersister storagePersister) { this.storage = storage; this.storagePersister = storagePersister; snapshot.putAll(storage.getAll()); }
static Map<String, String> getGlobalSettings(Storage storage) { Map<String, String> result = new HashMap<>(); for (String key : SETTINGS.keySet()) { String value = storage.getString(key, null); if (value != null) { result.put(key, value); } } return result; }
Map<String, Object> prefs = new TreeMap<String, Object>(storage.getAll());
static Map<String, String> getIdentitySettings(Storage storage, String uuid, int identityIndex) { Map<String, String> result = new HashMap<>(); String prefix = uuid + "."; String suffix = "." + Integer.toString(identityIndex); for (String key : SETTINGS.keySet()) { String value = storage.getString(prefix + key + suffix, null); if (value != null) { result.put(key, value); } } return result; }
public void loadAccounts() { synchronized (accountLock) { accounts = new HashMap<>(); accountsInOrder = new LinkedList<>(); String accountUuids = getStorage().getString("accountUuids", null); if ((accountUuids != null) && (accountUuids.length() != 0)) { String[] uuids = accountUuids.split(","); for (String uuid : uuids) { Account newAccount = new Account(uuid); accountPreferenceSerializer.loadAccount(newAccount, storage); accounts.put(uuid, newAccount); accountsInOrder.add(newAccount); } } if ((newAccount != null) && newAccount.getAccountNumber() != -1) { accounts.put(newAccount.getUuid(), newAccount); if (!accountsInOrder.contains(newAccount)) { accountsInOrder.add(newAccount); } newAccount = null; } } }
/** * Returns the Account marked as default. If no account is marked as default * the first account in the list is marked as default and then returned. If * there are no accounts on the system the method returns null. */ public Account getDefaultAccount() { Account defaultAccount; synchronized (accountLock) { String defaultAccountUuid = getStorage().getString("defaultAccountUuid", null); defaultAccount = getAccount(defaultAccountUuid); } if (defaultAccount == null) { Collection<Account> accounts = getAvailableAccounts(); if (!accounts.isEmpty()) { defaultAccount = accounts.iterator().next(); setDefaultAccount(defaultAccount); } } return defaultAccount; }
String oldAccountUuids = storage.getString("accountUuids", ""); String newAccountUuids = (oldAccountUuids.length() > 0) ? oldAccountUuids + "," + newUuid : newUuid; String defaultAccountUuid = storage.getString("defaultAccountUuid", null); if (defaultAccountUuid == null) { putString(editor, "defaultAccountUuid", accountUuids.get(0));