Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit f6036223 authored by Wolf-Martell Montwé's avatar Wolf-Martell Montwé Committed by GitHub
Browse files

Merge pull request #9834 from shamim-emon/fix-issue-9833

Migrate messageViewPostRemoveNavigation to PreferenceDataStore
parents 3f694686 ea1ecca8
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
package net.thunderbird.core.preference.interaction

const val INTERACTION_SETTINGS_DEFAULT_USE_VOLUME_KEYS_NAVIGATION = false
val INTERACTION_SETTINGS_DEFAULT_MESSAGE_VIEW_POST_REMOVE_NAVIGATION = PostRemoveNavigation.ReturnToMessageList.name

data class InteractionSettings(
    val useVolumeKeysForNavigation: Boolean = INTERACTION_SETTINGS_DEFAULT_USE_VOLUME_KEYS_NAVIGATION,
    val messageViewPostRemoveNavigation: String = INTERACTION_SETTINGS_DEFAULT_MESSAGE_VIEW_POST_REMOVE_NAVIGATION,
)

/**
 * The navigation actions that can be to performed after the user has deleted or moved a message from the message
 * view screen.
 */
enum class PostRemoveNavigation {
    ReturnToMessageList,
    ShowPreviousMessage,
    ShowNextMessage,
}
+1 −0
Original line number Diff line number Diff line
@@ -3,4 +3,5 @@ package net.thunderbird.core.preference.interaction
import net.thunderbird.core.preference.PreferenceManager

const val KEY_USE_VOLUME_KEYS_FOR_NAVIGATION = "useVolumeKeysForNavigation"
const val KEY_MESSAGE_VIEW_POST_DELETE_ACTION = "messageViewPostDeleteAction"
interface InteractionSettingsPreferenceManager : PreferenceManager<InteractionSettings>
+5 −0
Original line number Diff line number Diff line
@@ -40,6 +40,10 @@ class DefaultInteractionSettingsPreferenceManager(
            KEY_USE_VOLUME_KEYS_FOR_NAVIGATION,
            INTERACTION_SETTINGS_DEFAULT_USE_VOLUME_KEYS_NAVIGATION,
        ),
        messageViewPostRemoveNavigation = storage.getStringOrDefault(
            KEY_MESSAGE_VIEW_POST_DELETE_ACTION,
            INTERACTION_SETTINGS_DEFAULT_MESSAGE_VIEW_POST_REMOVE_NAVIGATION,
        ),
    )

    private fun writeConfig(config: InteractionSettings) {
@@ -47,6 +51,7 @@ class DefaultInteractionSettingsPreferenceManager(
        scope.launch(ioDispatcher) {
            mutex.withLock {
                storageEditor.putBoolean(KEY_USE_VOLUME_KEYS_FOR_NAVIGATION, config.useVolumeKeysForNavigation)
                storageEditor.putString(KEY_MESSAGE_VIEW_POST_DELETE_ACTION, config.messageViewPostRemoveNavigation)
                storageEditor.commit().also { commited ->
                    logger.verbose(TAG) { "writeConfig: storageEditor.commit() resulted in: $commited" }
                }
+0 −15
Original line number Diff line number Diff line
@@ -149,8 +149,6 @@ object K9 : KoinComponent {
    @JvmStatic
    var contactNameColor = 0xFF1093F5.toInt()

    var messageViewPostRemoveNavigation: PostRemoveNavigation = PostRemoveNavigation.ReturnToMessageList

    var messageViewPostMarkAsUnreadNavigation: PostMarkAsUnreadNavigation =
        PostMarkAsUnreadNavigation.ReturnToMessageList

@@ -243,8 +241,6 @@ object K9 : KoinComponent {

        messageListDensity = storage.getEnum("messageListDensity", UiDensity.Default)
        contactNameColor = storage.getInt("registeredNameColor", 0xFF1093F5.toInt())
        messageViewPostRemoveNavigation =
            storage.getEnum("messageViewPostDeleteAction", PostRemoveNavigation.ReturnToMessageList)
        messageViewPostMarkAsUnreadNavigation =
            storage.getEnum("messageViewPostMarkAsUnreadAction", PostMarkAsUnreadNavigation.ReturnToMessageList)

@@ -305,7 +301,6 @@ object K9 : KoinComponent {
        editor.putBoolean("showAccountSelector", isShowAccountSelector)
        editor.putInt("messageListPreviewLines", messageListPreviewLines)
        editor.putInt("registeredNameColor", contactNameColor)
        editor.putEnum("messageViewPostDeleteAction", messageViewPostRemoveNavigation)
        editor.putEnum("messageViewPostMarkAsUnreadAction", messageViewPostMarkAsUnreadNavigation)

        editor.putBoolean("confirmDelete", isConfirmDelete)
@@ -398,16 +393,6 @@ object K9 : KoinComponent {
        NOTHING,
    }

    /**
     * The navigation actions that can be to performed after the user has deleted or moved a message from the message
     * view screen.
     */
    enum class PostRemoveNavigation {
        ReturnToMessageList,
        ShowPreviousMessage,
        ShowNextMessage,
    }

    /**
     * The navigation actions that can be to performed after the user has marked a message as unread from the message
     * view screen.
+1 −1
Original line number Diff line number Diff line
@@ -14,7 +14,6 @@ import app.k9mail.legacy.di.DI;
import com.fsck.k9.FontSizes;
import com.fsck.k9.K9.NotificationQuickDelete;
import com.fsck.k9.K9.PostMarkAsUnreadNavigation;
import com.fsck.k9.K9.PostRemoveNavigation;
import com.fsck.k9.UiDensity;
import com.fsck.k9.core.R;
import com.fsck.k9.preferences.Settings.BooleanSetting;
@@ -42,6 +41,7 @@ import net.thunderbird.core.preference.GeneralSettingsManager;
import net.thunderbird.core.preference.SplitViewMode;
import net.thunderbird.core.preference.SubTheme;
import net.thunderbird.core.preference.display.coreSettings.DisplayCoreSettingsKt;
import net.thunderbird.core.preference.interaction.PostRemoveNavigation;
import net.thunderbird.core.preference.network.NetworkSettingsKt;
import net.thunderbird.core.preference.storage.Storage;

Loading