Skip to content
Open
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 @@ -5,6 +5,8 @@ import net.thunderbird.core.common.action.SwipeActions

const val INTERACTION_SETTINGS_DEFAULT_USE_VOLUME_KEYS_NAVIGATION = false
val INTERACTION_SETTINGS_DEFAULT_MESSAGE_VIEW_POST_REMOVE_NAVIGATION = PostRemoveNavigation.ReturnToMessageList.name
val INTERACTION_SETTINGS_DEFAULT_MESSAGE_VIEW_POST_MARK_AS_UNREAD_NAVIGATION =
PostMarkAsUnreadNavigation.ReturnToMessageList
val INTERACTION_SETTINGS_DEFAULT_SWIPE_ACTION = SwipeActions(
leftAction = SwipeAction.ToggleRead,
rightAction = SwipeAction.ToggleSelection,
Expand All @@ -19,6 +21,8 @@ const val INTERACTION_SETTINGS_DEFAULT_CONFIRM_MARK_ALL_READ = true
data class InteractionSettings(
val useVolumeKeysForNavigation: Boolean = INTERACTION_SETTINGS_DEFAULT_USE_VOLUME_KEYS_NAVIGATION,
val messageViewPostRemoveNavigation: String = INTERACTION_SETTINGS_DEFAULT_MESSAGE_VIEW_POST_REMOVE_NAVIGATION,
var messageViewPostMarkAsUnreadNavigation: PostMarkAsUnreadNavigation =
INTERACTION_SETTINGS_DEFAULT_MESSAGE_VIEW_POST_MARK_AS_UNREAD_NAVIGATION,
val swipeActions: SwipeActions = INTERACTION_SETTINGS_DEFAULT_SWIPE_ACTION,
val isConfirmDelete: Boolean = INTERACTION_SETTINGS_DEFAULT_CONFIRM_DELETE,
val isConfirmDeleteStarred: Boolean = INTERACTION_SETTINGS_DEFAULT_CONFIRM_DELETE_STARRED,
Expand All @@ -37,3 +41,12 @@ enum class PostRemoveNavigation {
ShowPreviousMessage,
ShowNextMessage,
}

/**
* The navigation actions that can be to performed after the user has marked a
* message as unread from the message view screen.
*/
enum class PostMarkAsUnreadNavigation {
StayOnCurrentMessage,
ReturnToMessageList,
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import net.thunderbird.core.preference.PreferenceManager

const val KEY_USE_VOLUME_KEYS_FOR_NAVIGATION = "useVolumeKeysForNavigation"
const val KEY_MESSAGE_VIEW_POST_DELETE_ACTION = "messageViewPostDeleteAction"
const val KEY_MESSAGE_VIEW_POST_MARK_AS_UNREAD_ACTION = "messageViewPostMarkAsReadAction"
const val KEY_SWIPE_ACTION_LEFT = "swipeLeftAction"
const val KEY_SWIPE_ACTION_RIGHT = "swipeRightAction"
const val KEY_CONFIRM_DELETE = "confirmDelete"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ class DefaultInteractionSettingsPreferenceManager(
KEY_MESSAGE_VIEW_POST_DELETE_ACTION,
INTERACTION_SETTINGS_DEFAULT_MESSAGE_VIEW_POST_REMOVE_NAVIGATION,
),
messageViewPostMarkAsUnreadNavigation = storage.getEnumOrDefault(
KEY_MESSAGE_VIEW_POST_MARK_AS_UNREAD_ACTION,
INTERACTION_SETTINGS_DEFAULT_MESSAGE_VIEW_POST_MARK_AS_UNREAD_NAVIGATION,
),
swipeActions = SwipeActions(
leftAction = storage.getEnumOrDefault(
key = KEY_SWIPE_ACTION_LEFT,
Expand Down Expand Up @@ -87,6 +91,10 @@ class DefaultInteractionSettingsPreferenceManager(
mutex.withLock {
storageEditor.putBoolean(KEY_USE_VOLUME_KEYS_FOR_NAVIGATION, config.useVolumeKeysForNavigation)
storageEditor.putString(KEY_MESSAGE_VIEW_POST_DELETE_ACTION, config.messageViewPostRemoveNavigation)
storageEditor.putEnum(
KEY_MESSAGE_VIEW_POST_MARK_AS_UNREAD_ACTION,
config.messageViewPostMarkAsUnreadNavigation,
)
storageEditor.putEnum(KEY_SWIPE_ACTION_LEFT, config.swipeActions.leftAction)
storageEditor.putEnum(KEY_SWIPE_ACTION_RIGHT, config.swipeActions.rightAction)
storageEditor.putBoolean(KEY_CONFIRM_DELETE, config.isConfirmDelete)
Expand Down
17 changes: 0 additions & 17 deletions legacy/core/src/main/java/com/fsck/k9/K9.kt
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,6 @@ object K9 : KoinComponent {
@JvmStatic
val fontSizes = FontSizes()

var messageViewPostMarkAsUnreadNavigation: PostMarkAsUnreadNavigation =
PostMarkAsUnreadNavigation.ReturnToMessageList

@get:Synchronized
@set:Synchronized
@JvmStatic
Expand Down Expand Up @@ -172,9 +169,6 @@ object K9 : KoinComponent {
@JvmStatic
@Suppress("LongMethod")
fun loadPrefs(storage: Storage) {
messageViewPostMarkAsUnreadNavigation =
storage.getEnum("messageViewPostMarkAsUnreadAction", PostMarkAsUnreadNavigation.ReturnToMessageList)

sortType = storage.getEnum("sortTypeEnum", AccountDefaultsProvider.DEFAULT_SORT_TYPE)

val sortAscendingSetting = storage.getBoolean("sortAscending", AccountDefaultsProvider.DEFAULT_SORT_ASCENDING)
Expand All @@ -199,8 +193,6 @@ object K9 : KoinComponent {

@Suppress("LongMethod")
internal fun save(editor: StorageEditor) {
editor.putEnum("messageViewPostMarkAsUnreadAction", messageViewPostMarkAsUnreadNavigation)

editor.putEnum("sortTypeEnum", sortType)
editor.putBoolean("sortAscending", sortAscending[sortType] ?: false)

Expand Down Expand Up @@ -254,13 +246,4 @@ object K9 : KoinComponent {
const val MAX_SEND_ATTEMPTS = 5

const val MANUAL_WAKE_LOCK_TIMEOUT = 120000

/**
* The navigation actions that can be to performed after the user has marked a message as unread from the message
* view screen.
*/
enum class PostMarkAsUnreadNavigation {
StayOnCurrentMessage,
ReturnToMessageList,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import app.k9mail.feature.telemetry.api.TelemetryManager;
import app.k9mail.legacy.di.DI;
import com.fsck.k9.FontSizes;
import com.fsck.k9.K9.PostMarkAsUnreadNavigation;
import com.fsck.k9.core.R;
import com.fsck.k9.preferences.Settings.BooleanSetting;
import com.fsck.k9.preferences.Settings.ColorSetting;
Expand Down Expand Up @@ -43,6 +42,7 @@
import net.thunderbird.core.preference.SubTheme;
import net.thunderbird.core.preference.display.coreSettings.DisplayCoreSettingsKt;
import net.thunderbird.core.preference.display.visualSettings.message.list.MessageListDateTimeFormat;
import net.thunderbird.core.preference.interaction.PostMarkAsUnreadNavigation;
import net.thunderbird.core.preference.interaction.PostRemoveNavigation;
import net.thunderbird.core.preference.network.NetworkSettingsKt;
import net.thunderbird.core.preference.storage.Storage;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ import app.k9mail.feature.launcher.FeatureLauncherActivity
import app.k9mail.feature.launcher.FeatureLauncherTarget
import app.k9mail.legacy.message.controller.MessageReference
import com.fsck.k9.CoreResourceProvider
import com.fsck.k9.K9
import com.fsck.k9.K9.PostMarkAsUnreadNavigation
import com.fsck.k9.Preferences
import com.fsck.k9.activity.compose.MessageActions
import com.fsck.k9.controller.MessagingController
Expand Down Expand Up @@ -63,6 +61,7 @@ import net.thunderbird.core.logging.Logger
import net.thunderbird.core.logging.legacy.Log
import net.thunderbird.core.preference.GeneralSettingsManager
import net.thunderbird.core.preference.SplitViewMode
import net.thunderbird.core.preference.interaction.PostMarkAsUnreadNavigation
import net.thunderbird.core.preference.interaction.PostRemoveNavigation
import net.thunderbird.feature.account.storage.legacy.mapper.LegacyAccountDataMapper
import net.thunderbird.feature.funding.api.FundingManager
Expand Down Expand Up @@ -1289,7 +1288,7 @@ open class MessageHomeActivity :
}

override fun performNavigationAfterMarkAsUnread() {
when (K9.messageViewPostMarkAsUnreadNavigation) {
when (generalSettingsManager.getConfig().interaction.messageViewPostMarkAsUnreadNavigation) {
PostMarkAsUnreadNavigation.StayOnCurrentMessage -> Unit
PostMarkAsUnreadNavigation.ReturnToMessageList -> returnToMessageList()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package com.fsck.k9.ui.settings.general
import androidx.preference.PreferenceDataStore
import app.k9mail.feature.telemetry.api.TelemetryManager
import com.fsck.k9.K9
import com.fsck.k9.K9.PostMarkAsUnreadNavigation
import com.fsck.k9.job.K9JobManager
import com.fsck.k9.ui.base.AppLanguageManager
import net.thunderbird.core.common.action.SwipeAction
Expand All @@ -17,6 +16,7 @@ import net.thunderbird.core.preference.SplitViewMode
import net.thunderbird.core.preference.SubTheme
import net.thunderbird.core.preference.display.visualSettings.message.list.MessageListDateTimeFormat
import net.thunderbird.core.preference.display.visualSettings.message.list.UiDensity
import net.thunderbird.core.preference.interaction.PostMarkAsUnreadNavigation
import net.thunderbird.core.preference.update

@Suppress("LargeClass")
Expand Down Expand Up @@ -173,7 +173,7 @@ class GeneralSettingsDataStore(
"swipe_action_left" -> swipeActionToString(interactionSettings.swipeActions.leftAction)
"message_list_density" -> messageListSettings.uiDensity.toString()
"post_remove_navigation" -> interactionSettings.messageViewPostRemoveNavigation
"post_mark_as_unread_navigation" -> K9.messageViewPostMarkAsUnreadNavigation.name
"post_mark_as_unread_navigation" -> interactionSettings.messageViewPostMarkAsUnreadNavigation.name
else -> defValue
}
}
Expand Down Expand Up @@ -215,10 +215,7 @@ class GeneralSettingsDataStore(
"swipe_action_left" -> updateSwipeAction(value) { swipeAction -> copy(leftAction = swipeAction) }
"message_list_density" -> updateMessageListDensity(value)
"post_remove_navigation" -> setMessageViewPostRemoveNavigation(value)
"post_mark_as_unread_navigation" -> {
K9.messageViewPostMarkAsUnreadNavigation = PostMarkAsUnreadNavigation.valueOf(value)
}

"post_mark_as_unread_navigation" -> setMessageViewPostMarkAsUnreadNavigation(value)
else -> return
}

Expand Down Expand Up @@ -747,6 +744,17 @@ class GeneralSettingsDataStore(
}
}

private fun setMessageViewPostMarkAsUnreadNavigation(value: String) {
skipSaveSettings = true
generalSettingsManager.update { settings ->
settings.copy(
interaction = settings.interaction.copy(
messageViewPostMarkAsUnreadNavigation = PostMarkAsUnreadNavigation.valueOf(value),
),
)
}
}

private fun appThemeToString(theme: AppTheme) = when (theme) {
AppTheme.LIGHT -> "light"
AppTheme.DARK -> "dark"
Expand Down
Loading