From 35c4c7d2ae50c4eed64f4ab141e707625c7b9870 Mon Sep 17 00:00:00 2001 From: Fahim Salam Chowdhury Date: Wed, 10 Aug 2022 16:53:18 +0600 Subject: [PATCH 1/2] 5901-Show_image_by_default issue: https://gitlab.e.foundation/e/backlog/-/issues/5901 We want to show images always on reading mails. To achieve this, account.showPictures preference needs to set to `Account.showPictures.ALWAYS`. For already setup accounts, to achieve same functionality, new preference is added account.isShowPIctureOptionLoadedCorrectly. Which's default value is false. But for new accounts, it is set to true. On MessageList page, when all data are loaded, isShowPIctureOptionLoadedCorrectly needs to be checked for all accounts. If it is false, update the showPictures to ALWAYS & isShowPIctureOptionLoadedCorrectly = true. --- app/core/src/main/java/com/fsck/k9/Account.kt | 6 +++++- .../com/fsck/k9/AccountPreferenceSerializer.kt | 7 +++++-- .../preferences/AccountSettingsDescriptions.java | 2 +- .../main/java/com/fsck/k9/activity/MessageList.kt | 15 +++++++++++++++ 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/app/core/src/main/java/com/fsck/k9/Account.kt b/app/core/src/main/java/com/fsck/k9/Account.kt index 7f155d5cf5..0f0b5c5437 100644 --- a/app/core/src/main/java/com/fsck/k9/Account.kt +++ b/app/core/src/main/java/com/fsck/k9/Account.kt @@ -209,7 +209,11 @@ class Account(override val uuid: String) : BaseAccount { @get:Synchronized @set:Synchronized - var showPictures = ShowPictures.NEVER + var showPictures = ShowPictures.ALWAYS + + @get:Synchronized + @set:Synchronized + var isShowPictureOptionLoadedCorrectly = false @get:Synchronized @set:Synchronized diff --git a/app/core/src/main/java/com/fsck/k9/AccountPreferenceSerializer.kt b/app/core/src/main/java/com/fsck/k9/AccountPreferenceSerializer.kt index 83db324da0..2483fbeb9b 100644 --- a/app/core/src/main/java/com/fsck/k9/AccountPreferenceSerializer.kt +++ b/app/core/src/main/java/com/fsck/k9/AccountPreferenceSerializer.kt @@ -132,7 +132,8 @@ class AccountPreferenceSerializer( setSortAscending(sortType, storage.getBoolean("$accountUuid.sortAscending", false)) - showPictures = getEnumStringPref(storage, "$accountUuid.showPicturesEnum", ShowPictures.NEVER) + showPictures = getEnumStringPref(storage, "$accountUuid.showPicturesEnum", ShowPictures.ALWAYS) + isShowPictureOptionLoadedCorrectly = storage.getBoolean("$accountUuid.isShowPictureOptionLoadedCorrectly", false) updateNotificationSettings { NotificationSettings( @@ -283,6 +284,7 @@ class AccountPreferenceSerializer( editor.putString("$accountUuid.sortTypeEnum", sortType.name) editor.putBoolean("$accountUuid.sortAscending", isSortAscending(sortType)) editor.putString("$accountUuid.showPicturesEnum", showPictures.name) + editor.putBoolean("$accountUuid.isShowPictureOptionLoadedCorrectly", isShowPictureOptionLoadedCorrectly) editor.putString("$accountUuid.folderDisplayMode", folderDisplayMode.name) editor.putString("$accountUuid.folderSyncMode", folderSyncMode.name) editor.putString("$accountUuid.folderPushMode", folderPushMode.name) @@ -553,7 +555,8 @@ class AccountPreferenceSerializer( folderTargetMode = FolderMode.NOT_SECOND_CLASS sortType = DEFAULT_SORT_TYPE setSortAscending(DEFAULT_SORT_TYPE, DEFAULT_SORT_ASCENDING) - showPictures = ShowPictures.NEVER + showPictures = ShowPictures.ALWAYS + isShowPictureOptionLoadedCorrectly = true isSignatureBeforeQuotedText = false expungePolicy = Expunge.EXPUNGE_IMMEDIATELY importedAutoExpandFolder = null diff --git a/app/core/src/main/java/com/fsck/k9/preferences/AccountSettingsDescriptions.java b/app/core/src/main/java/com/fsck/k9/preferences/AccountSettingsDescriptions.java index 519b014da4..1971a5f63c 100644 --- a/app/core/src/main/java/com/fsck/k9/preferences/AccountSettingsDescriptions.java +++ b/app/core/src/main/java/com/fsck/k9/preferences/AccountSettingsDescriptions.java @@ -184,7 +184,7 @@ public class AccountSettingsDescriptions { new V(9, new BooleanSetting(Account.DEFAULT_SORT_ASCENDING)) )); s.put("showPicturesEnum", Settings.versions( - new V(1, new EnumSetting<>(ShowPictures.class, ShowPictures.NEVER)) + new V(1, new EnumSetting<>(ShowPictures.class, ShowPictures.ALWAYS)) )); s.put("signatureBeforeQuotedText", Settings.versions( new V(1, new BooleanSetting(false)) diff --git a/app/ui/legacy/src/main/java/com/fsck/k9/activity/MessageList.kt b/app/ui/legacy/src/main/java/com/fsck/k9/activity/MessageList.kt index d82501ae9f..e920ad5757 100644 --- a/app/ui/legacy/src/main/java/com/fsck/k9/activity/MessageList.kt +++ b/app/ui/legacy/src/main/java/com/fsck/k9/activity/MessageList.kt @@ -174,6 +174,8 @@ open class MessageList : return } + accounts.forEach(this::refreshShowPictureOption) + if (useSplitView()) { setLayout(R.layout.split_message_list) } else { @@ -1700,6 +1702,19 @@ open class MessageList : } } + /** + * We want to show pictures by default. + * For already setup accounts, we need to first check isShowPictureOptionLoadedCorrectly pref value for account, by default it is false. + * If it is false, update {@code account.showPictures = ShowPictures.ALWAYS} + * else ignore + */ + private fun refreshShowPictureOption(account: Account) { + if (!account.isShowPictureOptionLoadedCorrectly) { + account.showPictures = Account.ShowPictures.ALWAYS + account.isShowPictureOptionLoadedCorrectly = true + preferences.saveAccount(account) + } + } companion object : KoinComponent { private const val EXTRA_SEARCH = "search_bytes" -- GitLab From b43ed726c27b4f27903645deca2446740a63b966 Mon Sep 17 00:00:00 2001 From: Jonathan Klee Date: Thu, 11 Aug 2022 07:01:27 +0000 Subject: [PATCH 2/2] Apply 1 suggestion(s) to 1 file(s) --- app/ui/legacy/src/main/java/com/fsck/k9/activity/MessageList.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/ui/legacy/src/main/java/com/fsck/k9/activity/MessageList.kt b/app/ui/legacy/src/main/java/com/fsck/k9/activity/MessageList.kt index e920ad5757..6d80249594 100644 --- a/app/ui/legacy/src/main/java/com/fsck/k9/activity/MessageList.kt +++ b/app/ui/legacy/src/main/java/com/fsck/k9/activity/MessageList.kt @@ -1702,7 +1702,7 @@ open class MessageList : } } - /** + /* * We want to show pictures by default. * For already setup accounts, we need to first check isShowPictureOptionLoadedCorrectly pref value for account, by default it is false. * If it is false, update {@code account.showPictures = ShowPictures.ALWAYS} -- GitLab