From 30c4f94b30dc722d98818983b43c80bb91389d7c Mon Sep 17 00:00:00 2001 From: cketti Date: Thu, 23 Feb 2023 15:23:23 +0100 Subject: [PATCH] Add setting for message list density --- app/core/src/main/java/com/fsck/k9/K9.kt | 5 +++++ app/core/src/main/java/com/fsck/k9/UiDensity.kt | 7 +++++++ .../fsck/k9/preferences/GeneralSettingsDescriptions.java | 4 ++++ .../src/main/java/com/fsck/k9/preferences/Settings.java | 2 +- .../k9/ui/settings/general/GeneralSettingsDataStore.kt | 3 +++ app/ui/legacy/src/main/res/values/arrays.xml | 6 ++++++ .../main/res/values/arrays_general_settings_strings.xml | 6 ++++++ app/ui/legacy/src/main/res/values/strings.xml | 6 ++++++ app/ui/legacy/src/main/res/xml/general_settings.xml | 8 ++++++++ 9 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 app/core/src/main/java/com/fsck/k9/UiDensity.kt diff --git a/app/core/src/main/java/com/fsck/k9/K9.kt b/app/core/src/main/java/com/fsck/k9/K9.kt index ed634d2bc..95f7fe1cc 100644 --- a/app/core/src/main/java/com/fsck/k9/K9.kt +++ b/app/core/src/main/java/com/fsck/k9/K9.kt @@ -152,6 +152,9 @@ object K9 : EarlyInit { @JvmStatic var lockScreenNotificationVisibility = LockScreenNotificationVisibility.MESSAGE_COUNT + @JvmStatic + var messageListDensity: UiDensity = UiDensity.Default + @JvmStatic var isShowMessageListStars = true @@ -320,6 +323,7 @@ object K9 : EarlyInit { quietTimeStarts = storage.getString("quietTimeStarts", "21:00") quietTimeEnds = storage.getString("quietTimeEnds", "7:00") + messageListDensity = storage.getEnum("messageListDensity", UiDensity.Default) isShowCorrespondentNames = storage.getBoolean("showCorrespondentNames", true) isShowContactName = storage.getBoolean("showContactName", false) isShowContactPicture = storage.getBoolean("showContactPicture", true) @@ -388,6 +392,7 @@ object K9 : EarlyInit { editor.putString("quietTimeStarts", quietTimeStarts) editor.putString("quietTimeEnds", quietTimeEnds) + editor.putEnum("messageListDensity", messageListDensity) editor.putBoolean("messageListSenderAboveSubject", isMessageListSenderAboveSubject) editor.putBoolean("showUnifiedInbox", isShowUnifiedInbox) editor.putBoolean("showStarredCount", isShowStarredCount) diff --git a/app/core/src/main/java/com/fsck/k9/UiDensity.kt b/app/core/src/main/java/com/fsck/k9/UiDensity.kt new file mode 100644 index 000000000..21f8e3878 --- /dev/null +++ b/app/core/src/main/java/com/fsck/k9/UiDensity.kt @@ -0,0 +1,7 @@ +package com.fsck.k9 + +enum class UiDensity { + Compact, + Default, + Relaxed, +} diff --git a/app/core/src/main/java/com/fsck/k9/preferences/GeneralSettingsDescriptions.java b/app/core/src/main/java/com/fsck/k9/preferences/GeneralSettingsDescriptions.java index cb4bfeb8e..0c947ad9d 100644 --- a/app/core/src/main/java/com/fsck/k9/preferences/GeneralSettingsDescriptions.java +++ b/app/core/src/main/java/com/fsck/k9/preferences/GeneralSettingsDescriptions.java @@ -20,6 +20,7 @@ import com.fsck.k9.K9.BACKGROUND_OPS; import com.fsck.k9.K9.NotificationQuickDelete; import com.fsck.k9.K9.SplitViewMode; import com.fsck.k9.SwipeAction; +import com.fsck.k9.UiDensity; import com.fsck.k9.core.R; import com.fsck.k9.preferences.Settings.BooleanSetting; import com.fsck.k9.preferences.Settings.ColorSetting; @@ -274,6 +275,9 @@ public class GeneralSettingsDescriptions { s.put("showComposeButtonOnMessageList", Settings.versions( new V(85, new BooleanSetting(true)) )); + s.put("messageListDensity", Settings.versions( + new V(86, new EnumSetting(UiDensity.class, UiDensity.Default)) + )); SETTINGS = Collections.unmodifiableMap(s); diff --git a/app/core/src/main/java/com/fsck/k9/preferences/Settings.java b/app/core/src/main/java/com/fsck/k9/preferences/Settings.java index 7f1274952..2176427ce 100644 --- a/app/core/src/main/java/com/fsck/k9/preferences/Settings.java +++ b/app/core/src/main/java/com/fsck/k9/preferences/Settings.java @@ -36,7 +36,7 @@ public class Settings { * * @see SettingsExporter */ - public static final int VERSION = 85; + public static final int VERSION = 86; static Map validate(int version, Map> settings, Map importedSettings, boolean useDefaultValues) { diff --git a/app/ui/legacy/src/main/java/com/fsck/k9/ui/settings/general/GeneralSettingsDataStore.kt b/app/ui/legacy/src/main/java/com/fsck/k9/ui/settings/general/GeneralSettingsDataStore.kt index 54bc38c5a..33e67787a 100644 --- a/app/ui/legacy/src/main/java/com/fsck/k9/ui/settings/general/GeneralSettingsDataStore.kt +++ b/app/ui/legacy/src/main/java/com/fsck/k9/ui/settings/general/GeneralSettingsDataStore.kt @@ -3,6 +3,7 @@ package com.fsck.k9.ui.settings.general import androidx.preference.PreferenceDataStore import com.fsck.k9.K9 import com.fsck.k9.SwipeAction +import com.fsck.k9.UiDensity import com.fsck.k9.job.K9JobManager import com.fsck.k9.preferences.AppTheme import com.fsck.k9.preferences.GeneralSettingsManager @@ -123,6 +124,7 @@ class GeneralSettingsDataStore( "message_compose_input_font" -> K9.fontSizes.messageComposeInput.toString() "swipe_action_right" -> swipeActionToString(K9.swipeRightAction) "swipe_action_left" -> swipeActionToString(K9.swipeLeftAction) + "message_list_density" -> K9.messageListDensity.toString() else -> defValue } } @@ -157,6 +159,7 @@ class GeneralSettingsDataStore( "message_compose_input_font" -> K9.fontSizes.messageComposeInput = value.toInt() "swipe_action_right" -> K9.swipeRightAction = stringToSwipeAction(value) "swipe_action_left" -> K9.swipeLeftAction = stringToSwipeAction(value) + "message_list_density" -> K9.messageListDensity = UiDensity.valueOf(value) else -> return } diff --git a/app/ui/legacy/src/main/res/values/arrays.xml b/app/ui/legacy/src/main/res/values/arrays.xml index b26c35272..4f8a2f770 100644 --- a/app/ui/legacy/src/main/res/values/arrays.xml +++ b/app/ui/legacy/src/main/res/values/arrays.xml @@ -92,4 +92,10 @@ 22 + + Compact + Default + Relaxed + + diff --git a/app/ui/legacy/src/main/res/values/arrays_general_settings_strings.xml b/app/ui/legacy/src/main/res/values/arrays_general_settings_strings.xml index b81a82e8a..213f6ea87 100644 --- a/app/ui/legacy/src/main/res/values/arrays_general_settings_strings.xml +++ b/app/ui/legacy/src/main/res/values/arrays_general_settings_strings.xml @@ -168,4 +168,10 @@ @string/general_settings_swipe_action_move + + @string/general_settings_ui_density_compact + @string/general_settings_ui_density_default + @string/general_settings_ui_density_relaxed + + diff --git a/app/ui/legacy/src/main/res/values/strings.xml b/app/ui/legacy/src/main/res/values/strings.xml index 5e4e8945a..745c9707a 100644 --- a/app/ui/legacy/src/main/res/values/strings.xml +++ b/app/ui/legacy/src/main/res/values/strings.xml @@ -336,6 +336,12 @@ Please submit bug reports, contribute new features and ask questions at Move + + Density + Compact + Default + Relaxed + Hide mail client Remove K-9 User-Agent from mail headers Hide timezone diff --git a/app/ui/legacy/src/main/res/xml/general_settings.xml b/app/ui/legacy/src/main/res/xml/general_settings.xml index a197ce237..f0b7a3994 100644 --- a/app/ui/legacy/src/main/res/xml/general_settings.xml +++ b/app/ui/legacy/src/main/res/xml/general_settings.xml @@ -186,6 +186,14 @@ android:key="messagelist_preferences" android:title="@string/messagelist_preferences"> + +