Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const val DISPLAY_SETTINGS_DEFAULT_IS_USE_MESSAGE_VIEW_FIXED_WIDTH_FONT = false
const val DISPLAY_SETTINGS_DEFAULT_IS_AUTO_FIT_WIDTH = true
const val DISPLAY_SETTINGS_DEFAULT_IS_SHOW_ANIMATION = true
const val DISPLAY_SETTINGS_DEFAULT_IS_SHOW_CORRESPONDENT_NAMES = true
const val DISPLAY_SETTINGS_DEFAULT_MESSAGE_LIST_PREVIEW_LINES = 2

data class DisplayVisualSettings(
val isShowAnimations: Boolean = DISPLAY_SETTINGS_DEFAULT_IS_SHOW_ANIMATION,
Expand All @@ -20,4 +21,5 @@ data class DisplayVisualSettings(
val isUseBackgroundAsUnreadIndicator: Boolean = DISPLAY_SETTINGS_DEFAULT_IS_USE_BACKGROUND_AS_INDICATOR,
val isUseMessageViewFixedWidthFont: Boolean = DISPLAY_SETTINGS_DEFAULT_IS_USE_MESSAGE_VIEW_FIXED_WIDTH_FONT,
val isAutoFitWidth: Boolean = DISPLAY_SETTINGS_DEFAULT_IS_AUTO_FIT_WIDTH,
val messageListPreviewLines: Int = DISPLAY_SETTINGS_DEFAULT_MESSAGE_LIST_PREVIEW_LINES,
)
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ const val KEY_USE_BACKGROUND_AS_UNREAD_INDICATOR = "isUseBackgroundAsUnreadIndic
const val KEY_MESSAGE_VIEW_FIXED_WIDTH_FONT = "messageViewFixedWidthFont"
const val KEY_AUTO_FIT_WIDTH = "autofitWidth"
const val KEY_SHOW_CONTACT_PICTURE = "showContactPicture"
const val KEY_MESSAGE_LIST_VIEW_PREVIEW_LINES = "messageListPreviewLines"

interface DisplayVisualSettingsPreferenceManager : PreferenceManager<DisplayVisualSettings>
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ class DefaultDisplayVisualSettingsPreferenceManager(
KEY_SHOW_CONTACT_PICTURE,
DISPLAY_SETTINGS_DEFAULT_IS_SHOW_CONTACT_PICTURE,
),
messageListPreviewLines = storage.getInt(
KEY_MESSAGE_LIST_VIEW_PREVIEW_LINES,
DISPLAY_SETTINGS_DEFAULT_MESSAGE_LIST_PREVIEW_LINES,
),
)

private fun writeConfig(config: DisplayVisualSettings) {
Expand Down Expand Up @@ -103,6 +107,10 @@ class DefaultDisplayVisualSettingsPreferenceManager(
KEY_SHOW_CORRESPONDENT_NAMES,
config.isShowCorrespondentNames,
)
storageEditor.putInt(
KEY_MESSAGE_LIST_VIEW_PREVIEW_LINES,
config.messageListPreviewLines,
)
storageEditor.commit().also { commited ->
logger.verbose(TAG) { "writeConfig: storageEditor.commit() resulted in: $commited" }
}
Expand Down
5 changes: 0 additions & 5 deletions legacy/core/src/main/java/com/fsck/k9/K9.kt
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,6 @@ object K9 : KoinComponent {
@JvmStatic
var messageListDensity: UiDensity = UiDensity.Default

@JvmStatic
var messageListPreviewLines = 2

@JvmStatic
var contactNameColor = 0xFF1093F5.toInt()

Expand Down Expand Up @@ -233,7 +230,6 @@ object K9 : KoinComponent {
@Suppress("LongMethod")
fun loadPrefs(storage: Storage) {
isShowAccountSelector = storage.getBoolean("showAccountSelector", true)
messageListPreviewLines = storage.getInt("messageListPreviewLines", 2)

messageListDensity = storage.getEnum("messageListDensity", UiDensity.Default)
contactNameColor = storage.getInt("registeredNameColor", 0xFF1093F5.toInt())
Expand Down Expand Up @@ -294,7 +290,6 @@ object K9 : KoinComponent {
internal fun save(editor: StorageEditor) {
editor.putEnum("messageListDensity", messageListDensity)
editor.putBoolean("showAccountSelector", isShowAccountSelector)
editor.putInt("messageListPreviewLines", messageListPreviewLines)
editor.putInt("registeredNameColor", contactNameColor)
editor.putEnum("messageViewPostMarkAsUnreadAction", messageViewPostMarkAsUnreadNavigation)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ data class MessageListActivityConfig(
isShowComposeButton = settings.display.inboxSettings.isShowComposeButtonOnMessageList,
contactNameColor = K9.contactNameColor,
messageViewTheme = settings.display.coreSettings.messageViewTheme,
messageListPreviewLines = K9.messageListPreviewLines,
messageListPreviewLines = settings.display.visualSettings.messageListPreviewLines,
messageListDensity = K9.messageListDensity,
splitViewMode = settings.display.coreSettings.splitViewMode,
fontSizeMessageListSubject = K9.fontSizes.messageListSubject,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,7 @@ class MessageListFragment :
private val messageListAppearance: MessageListAppearance
get() = MessageListAppearance(
fontSizes = K9.fontSizes,
previewLines = K9.messageListPreviewLines,
previewLines = generalSettingsManager.getConfig().display.visualSettings.messageListPreviewLines,
stars = !isOutbox && generalSettingsManager.getConfig().display.inboxSettings.isShowMessageListStars,
senderAboveSubject = generalSettingsManager
.getConfig()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class GeneralSettingsDataStore(

"disable_notifications_during_quiet_time" -> !generalSettingsManager.getConfig()
.notification.isNotificationDuringQuietTimeEnabled

"privacy_hide_useragent" -> generalSettingsManager.getConfig().privacy.isHideUserAgent
"privacy_hide_timezone" -> generalSettingsManager.getConfig().privacy.isHideTimeZone
"debug_logging" -> generalSettingsManager.getConfig().debugging.isDebugLoggingEnabled
Expand Down Expand Up @@ -153,7 +154,9 @@ class GeneralSettingsDataStore(
generalSettingsManager.getConfig().display.coreSettings.messageViewTheme,
)

"messagelist_preview_lines" -> K9.messageListPreviewLines.toString()
"messagelist_preview_lines" -> generalSettingsManager.getConfig()
.display.visualSettings.messageListPreviewLines.toString()

"splitview_mode" -> generalSettingsManager.getConfig().display.coreSettings.splitViewMode.name
"notification_quick_delete" -> K9.notificationQuickDeleteBehaviour.name
"lock_screen_notification_visibility" -> K9.lockScreenNotificationVisibility.name
Expand Down Expand Up @@ -191,7 +194,7 @@ class GeneralSettingsDataStore(
"theme" -> setTheme(value)
"message_compose_theme" -> setMessageComposeTheme(value)
"messageViewTheme" -> setMessageViewTheme(value)
"messagelist_preview_lines" -> K9.messageListPreviewLines = value.toInt()
"messagelist_preview_lines" -> setMessageListPreviewLines(value.toInt())
"splitview_mode" -> setSplitViewModel(SplitViewMode.valueOf(value.uppercase()))
"notification_quick_delete" -> {
K9.notificationQuickDeleteBehaviour = K9.NotificationQuickDelete.valueOf(value)
Expand Down Expand Up @@ -332,6 +335,19 @@ class GeneralSettingsDataStore(
}
}

private fun setMessageListPreviewLines(previewLines: Int) {
skipSaveSettings = true
generalSettingsManager.update { settings ->
settings.copy(
display = settings.display.copy(
visualSettings = settings.display.visualSettings.copy(
messageListPreviewLines = previewLines,
),
),
)
}
}

private fun setSplitViewModel(mode: SplitViewMode) {
skipSaveSettings = true
generalSettingsManager.update { settings ->
Expand Down
Loading