Loading feature/account/storage/legacy/src/main/kotlin/net/thunderbird/feature/account/storage/legacy/AccountStorageLegacyModule.kt +7 −1 Original line number Diff line number Diff line Loading @@ -25,9 +25,15 @@ val featureAccountStorageLegacyModule = module { factory { ServerSettingsDtoSerializer() } single { factory<ProfileDtoStorageHandler> { LegacyProfileDtoStorageHandler( ) } single<StorageHandler<LegacyAccount>> { LegacyAccountStorageHandler( serverSettingsDtoSerializer = get(), profileDtoStorageHandler = get(), logger = get(), ) } Loading feature/account/storage/legacy/src/main/kotlin/net/thunderbird/feature/account/storage/legacy/LegacyAccountStorageHandler.kt +1 −9 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import net.thunderbird.feature.notification.VibratePattern class LegacyAccountStorageHandler( private val serverSettingsDtoSerializer: ServerSettingsDtoSerializer, private val profileDtoStorageHandler: LegacyProfileDtoStorageHandler, private val logger: Logger, ) : StorageHandler<LegacyAccount> { Loading @@ -42,7 +43,6 @@ class LegacyAccountStorageHandler( storage.getStringOrDefault(keyGen.create(OUTGOING_SERVER_SETTINGS_KEY), ""), ) oAuthState = storage.getStringOrNull(keyGen.create("oAuthState")) name = storage.getStringOrNull(keyGen.create("description")) alwaysBcc = storage.getStringOrNull(keyGen.create("alwaysBcc")) ?: alwaysBcc automaticCheckIntervalMinutes = storage.getInt( keyGen.create("automaticCheckIntervalMinutes"), Loading Loading @@ -182,8 +182,6 @@ class LegacyAccountStorageHandler( AccountDefaultsProvider.Companion.UNASSIGNED_ACCOUNT_NUMBER, ) chipColor = storage.getInt(keyGen.create("chipColor"), FALLBACK_ACCOUNT_COLOR) sortType = getEnumStringPref<SortType>(storage, keyGen.create("sortTypeEnum"), SortType.SORT_DATE) setSortAscending(sortType, storage.getBoolean(keyGen.create("sortAscending"), false)) Loading Loading @@ -325,7 +323,6 @@ class LegacyAccountStorageHandler( serverSettingsDtoSerializer.serialize(outgoingServerSettings), ) editor.putString(keyGen.create("oAuthState"), oAuthState) editor.putString(keyGen.create("description"), name) editor.putString(keyGen.create("alwaysBcc"), alwaysBcc) editor.putInt(keyGen.create("automaticCheckIntervalMinutes"), automaticCheckIntervalMinutes) editor.putInt(keyGen.create("idleRefreshMinutes"), idleRefreshMinutes) Loading Loading @@ -369,7 +366,6 @@ class LegacyAccountStorageHandler( editor.putString(keyGen.create("expungePolicy"), expungePolicy.name) editor.putBoolean(keyGen.create("syncRemoteDeletions"), isSyncRemoteDeletions) editor.putInt(keyGen.create("maxPushFolders"), maxPushFolders) editor.putInt(keyGen.create("chipColor"), chipColor) editor.putBoolean(keyGen.create("subscribedFoldersOnly"), isSubscribedFoldersOnly) editor.putInt(keyGen.create("maximumPolledMessageAge"), maximumPolledMessageAge) editor.putInt(keyGen.create("maximumAutoDownloadMessageSize"), maximumAutoDownloadMessageSize) Loading Loading @@ -450,7 +446,6 @@ class LegacyAccountStorageHandler( editor.remove(keyGen.create(INCOMING_SERVER_SETTINGS_KEY)) editor.remove(keyGen.create(OUTGOING_SERVER_SETTINGS_KEY)) editor.remove(keyGen.create("description")) editor.remove(keyGen.create("name")) editor.remove(keyGen.create("email")) editor.remove(keyGen.create("alwaysBcc")) editor.remove(keyGen.create("automaticCheckIntervalMinutes")) Loading Loading @@ -485,7 +480,6 @@ class LegacyAccountStorageHandler( editor.remove(keyGen.create("expungePolicy")) editor.remove(keyGen.create("syncRemoteDeletions")) editor.remove(keyGen.create("maxPushFolders")) editor.remove(keyGen.create("chipColor")) editor.remove(keyGen.create("notificationLight")) editor.remove(keyGen.create("subscribedFoldersOnly")) editor.remove(keyGen.create("maximumPolledMessageAge")) Loading Loading @@ -617,7 +611,5 @@ class LegacyAccountStorageHandler( const val IDENTITY_NAME_KEY = "name" const val IDENTITY_EMAIL_KEY = "email" const val IDENTITY_DESCRIPTION_KEY = "description" const val FALLBACK_ACCOUNT_COLOR = 0x0099CC } } feature/account/storage/legacy/src/main/kotlin/net/thunderbird/feature/account/storage/legacy/LegacyProfileDtoStorageHandler.kt 0 → 100644 +53 −0 Original line number Diff line number Diff line package net.thunderbird.feature.account.storage.legacy import net.thunderbird.core.android.account.LegacyAccount import net.thunderbird.core.preference.storage.Storage import net.thunderbird.core.preference.storage.StorageEditor class LegacyProfileDtoStorageHandler( ) : ProfileDtoStorageHandler { override fun load( data: LegacyAccount, storage: Storage, ) { val keyGen = AccountKeyGenerator(data.id) with(data) { name = storage.getStringOrNull(keyGen.create(KEY_NAME)) chipColor = storage.getInt(keyGen.create(KEY_COLOR), FALLBACK_ACCOUNT_COLOR) } } override fun save( data: LegacyAccount, storage: Storage, editor: StorageEditor, ) { val keyGen = AccountKeyGenerator(data.id) with(data) { editor.putString(keyGen.create(KEY_NAME), name) editor.putInt(keyGen.create(KEY_COLOR), chipColor) } } override fun delete( data: LegacyAccount, storage: Storage, editor: StorageEditor, ) { val keyGen = AccountKeyGenerator(data.id) editor.remove(keyGen.create(KEY_NAME)) editor.remove(keyGen.create(KEY_COLOR)) } private companion object Companion { const val KEY_COLOR = "chipColor" const val KEY_NAME = "description" // TODO why? const val FALLBACK_ACCOUNT_COLOR = 0x0099CC } } feature/account/storage/legacy/src/main/kotlin/net/thunderbird/feature/account/storage/legacy/StorageHandler.kt +3 −0 Original line number Diff line number Diff line package net.thunderbird.feature.account.storage.legacy import androidx.annotation.Discouraged import net.thunderbird.core.android.account.LegacyAccount import net.thunderbird.core.preference.storage.Storage import net.thunderbird.core.preference.storage.StorageEditor Loading Loading @@ -41,3 +42,5 @@ interface StorageHandler<T> { fun delete(data: T, storage: Storage, editor: StorageEditor) } interface ProfileDtoStorageHandler : StorageHandler<LegacyAccount> Loading
feature/account/storage/legacy/src/main/kotlin/net/thunderbird/feature/account/storage/legacy/AccountStorageLegacyModule.kt +7 −1 Original line number Diff line number Diff line Loading @@ -25,9 +25,15 @@ val featureAccountStorageLegacyModule = module { factory { ServerSettingsDtoSerializer() } single { factory<ProfileDtoStorageHandler> { LegacyProfileDtoStorageHandler( ) } single<StorageHandler<LegacyAccount>> { LegacyAccountStorageHandler( serverSettingsDtoSerializer = get(), profileDtoStorageHandler = get(), logger = get(), ) } Loading
feature/account/storage/legacy/src/main/kotlin/net/thunderbird/feature/account/storage/legacy/LegacyAccountStorageHandler.kt +1 −9 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import net.thunderbird.feature.notification.VibratePattern class LegacyAccountStorageHandler( private val serverSettingsDtoSerializer: ServerSettingsDtoSerializer, private val profileDtoStorageHandler: LegacyProfileDtoStorageHandler, private val logger: Logger, ) : StorageHandler<LegacyAccount> { Loading @@ -42,7 +43,6 @@ class LegacyAccountStorageHandler( storage.getStringOrDefault(keyGen.create(OUTGOING_SERVER_SETTINGS_KEY), ""), ) oAuthState = storage.getStringOrNull(keyGen.create("oAuthState")) name = storage.getStringOrNull(keyGen.create("description")) alwaysBcc = storage.getStringOrNull(keyGen.create("alwaysBcc")) ?: alwaysBcc automaticCheckIntervalMinutes = storage.getInt( keyGen.create("automaticCheckIntervalMinutes"), Loading Loading @@ -182,8 +182,6 @@ class LegacyAccountStorageHandler( AccountDefaultsProvider.Companion.UNASSIGNED_ACCOUNT_NUMBER, ) chipColor = storage.getInt(keyGen.create("chipColor"), FALLBACK_ACCOUNT_COLOR) sortType = getEnumStringPref<SortType>(storage, keyGen.create("sortTypeEnum"), SortType.SORT_DATE) setSortAscending(sortType, storage.getBoolean(keyGen.create("sortAscending"), false)) Loading Loading @@ -325,7 +323,6 @@ class LegacyAccountStorageHandler( serverSettingsDtoSerializer.serialize(outgoingServerSettings), ) editor.putString(keyGen.create("oAuthState"), oAuthState) editor.putString(keyGen.create("description"), name) editor.putString(keyGen.create("alwaysBcc"), alwaysBcc) editor.putInt(keyGen.create("automaticCheckIntervalMinutes"), automaticCheckIntervalMinutes) editor.putInt(keyGen.create("idleRefreshMinutes"), idleRefreshMinutes) Loading Loading @@ -369,7 +366,6 @@ class LegacyAccountStorageHandler( editor.putString(keyGen.create("expungePolicy"), expungePolicy.name) editor.putBoolean(keyGen.create("syncRemoteDeletions"), isSyncRemoteDeletions) editor.putInt(keyGen.create("maxPushFolders"), maxPushFolders) editor.putInt(keyGen.create("chipColor"), chipColor) editor.putBoolean(keyGen.create("subscribedFoldersOnly"), isSubscribedFoldersOnly) editor.putInt(keyGen.create("maximumPolledMessageAge"), maximumPolledMessageAge) editor.putInt(keyGen.create("maximumAutoDownloadMessageSize"), maximumAutoDownloadMessageSize) Loading Loading @@ -450,7 +446,6 @@ class LegacyAccountStorageHandler( editor.remove(keyGen.create(INCOMING_SERVER_SETTINGS_KEY)) editor.remove(keyGen.create(OUTGOING_SERVER_SETTINGS_KEY)) editor.remove(keyGen.create("description")) editor.remove(keyGen.create("name")) editor.remove(keyGen.create("email")) editor.remove(keyGen.create("alwaysBcc")) editor.remove(keyGen.create("automaticCheckIntervalMinutes")) Loading Loading @@ -485,7 +480,6 @@ class LegacyAccountStorageHandler( editor.remove(keyGen.create("expungePolicy")) editor.remove(keyGen.create("syncRemoteDeletions")) editor.remove(keyGen.create("maxPushFolders")) editor.remove(keyGen.create("chipColor")) editor.remove(keyGen.create("notificationLight")) editor.remove(keyGen.create("subscribedFoldersOnly")) editor.remove(keyGen.create("maximumPolledMessageAge")) Loading Loading @@ -617,7 +611,5 @@ class LegacyAccountStorageHandler( const val IDENTITY_NAME_KEY = "name" const val IDENTITY_EMAIL_KEY = "email" const val IDENTITY_DESCRIPTION_KEY = "description" const val FALLBACK_ACCOUNT_COLOR = 0x0099CC } }
feature/account/storage/legacy/src/main/kotlin/net/thunderbird/feature/account/storage/legacy/LegacyProfileDtoStorageHandler.kt 0 → 100644 +53 −0 Original line number Diff line number Diff line package net.thunderbird.feature.account.storage.legacy import net.thunderbird.core.android.account.LegacyAccount import net.thunderbird.core.preference.storage.Storage import net.thunderbird.core.preference.storage.StorageEditor class LegacyProfileDtoStorageHandler( ) : ProfileDtoStorageHandler { override fun load( data: LegacyAccount, storage: Storage, ) { val keyGen = AccountKeyGenerator(data.id) with(data) { name = storage.getStringOrNull(keyGen.create(KEY_NAME)) chipColor = storage.getInt(keyGen.create(KEY_COLOR), FALLBACK_ACCOUNT_COLOR) } } override fun save( data: LegacyAccount, storage: Storage, editor: StorageEditor, ) { val keyGen = AccountKeyGenerator(data.id) with(data) { editor.putString(keyGen.create(KEY_NAME), name) editor.putInt(keyGen.create(KEY_COLOR), chipColor) } } override fun delete( data: LegacyAccount, storage: Storage, editor: StorageEditor, ) { val keyGen = AccountKeyGenerator(data.id) editor.remove(keyGen.create(KEY_NAME)) editor.remove(keyGen.create(KEY_COLOR)) } private companion object Companion { const val KEY_COLOR = "chipColor" const val KEY_NAME = "description" // TODO why? const val FALLBACK_ACCOUNT_COLOR = 0x0099CC } }
feature/account/storage/legacy/src/main/kotlin/net/thunderbird/feature/account/storage/legacy/StorageHandler.kt +3 −0 Original line number Diff line number Diff line package net.thunderbird.feature.account.storage.legacy import androidx.annotation.Discouraged import net.thunderbird.core.android.account.LegacyAccount import net.thunderbird.core.preference.storage.Storage import net.thunderbird.core.preference.storage.StorageEditor Loading Loading @@ -41,3 +42,5 @@ interface StorageHandler<T> { fun delete(data: T, storage: Storage, editor: StorageEditor) } interface ProfileDtoStorageHandler : StorageHandler<LegacyAccount>