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

Verified Commit bb551fae authored by cketti's avatar cketti Committed by Fahim M. Choudhury
Browse files

Combine settings for navigation action after removing a message

After the user deletes or moves a message in the message view screen, the available navigation options are:
- Return to message list
- Show previous message
- Show next message

We get rid of the "magic" mode that tries to keep going in the direction in which the user was moving previously.

(cherry picked from commit a75c7abb)
parent 1d37ac36
Loading
Loading
Loading
Loading
Loading
+14 −9
Original line number Diff line number Diff line
@@ -198,11 +198,7 @@ object K9 : EarlyInit {
    @JvmStatic
    var isUseMessageViewFixedWidthFont = false

    @JvmStatic
    var isMessageViewReturnToList = false

    @JvmStatic
    var isMessageViewShowNext = false
    var messageViewPostRemoveNavigation: PostRemoveNavigation = PostRemoveNavigation.ReturnToMessageList

    @JvmStatic
    var isUseVolumeKeysForNavigation = false
@@ -351,8 +347,8 @@ object K9 : EarlyInit {
        isChangeContactNameColor = storage.getBoolean("changeRegisteredNameColor", false)
        contactNameColor = storage.getInt("registeredNameColor", 0xFF1093F5.toInt())
        isUseMessageViewFixedWidthFont = storage.getBoolean("messageViewFixedWidthFont", false)
        isMessageViewReturnToList = storage.getBoolean("messageViewReturnToList", false)
        isMessageViewShowNext = storage.getBoolean("messageViewShowNext", false)
        messageViewPostRemoveNavigation =
            storage.getEnum("messageViewPostDeleteAction", PostRemoveNavigation.ReturnToMessageList)
        isHideUserAgent = storage.getBoolean("hideUserAgent", false)
        isHideTimeZone = storage.getBoolean("hideTimeZone", false)

@@ -432,8 +428,7 @@ object K9 : EarlyInit {
        editor.putBoolean("changeRegisteredNameColor", isChangeContactNameColor)
        editor.putInt("registeredNameColor", contactNameColor)
        editor.putBoolean("messageViewFixedWidthFont", isUseMessageViewFixedWidthFont)
        editor.putBoolean("messageViewReturnToList", isMessageViewReturnToList)
        editor.putBoolean("messageViewShowNext", isMessageViewShowNext)
        editor.putEnum("messageViewPostDeleteAction", messageViewPostRemoveNavigation)
        editor.putBoolean("hideUserAgent", isHideUserAgent)
        editor.putBoolean("hideTimeZone", isHideTimeZone)

@@ -586,4 +581,14 @@ object K9 : EarlyInit {
            Share.EXTRA_FROM = "$packageName.intent.extra.SENDER"
        }
    }

    /**
     * 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,
    }
}
+10 −2
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@ import com.fsck.k9.FontSizes;
import com.fsck.k9.K9;
import com.fsck.k9.K9.BACKGROUND_OPS;
import com.fsck.k9.K9.NotificationQuickDelete;
import com.fsck.k9.K9.PostRemoveNavigation;
import com.fsck.k9.K9.SplitViewMode;
import com.fsck.k9.SwipeAction;
import com.fsck.k9.UiDensity;
@@ -37,6 +38,7 @@ import com.fsck.k9.preferences.upgrader.GeneralSettingsUpgraderTo31;
import com.fsck.k9.preferences.upgrader.GeneralSettingsUpgraderTo58;
import com.fsck.k9.preferences.upgrader.GeneralSettingsUpgraderTo69;
import com.fsck.k9.preferences.upgrader.GeneralSettingsUpgraderTo79;
import com.fsck.k9.preferences.upgrader.GeneralSettingsUpgraderTo89;

import static com.fsck.k9.K9.LockScreenNotificationVisibility;

@@ -138,10 +140,12 @@ public class GeneralSettingsDescriptions {
                new V(1, new BooleanSetting(false))
        ));
        s.put("messageViewReturnToList", Settings.versions(
                new V(1, new BooleanSetting(false))
                new V(1, new BooleanSetting(false)),
                new V(89, null)
        ));
        s.put("messageViewShowNext", Settings.versions(
                new V(1, new BooleanSetting(false))
                new V(1, new BooleanSetting(false)),
                new V(89, null)
        ));
        s.put("quietTimeEnabled", Settings.versions(
                new V(1, new BooleanSetting(false))
@@ -289,6 +293,9 @@ public class GeneralSettingsDescriptions {
        s.put("fontSizeMessageViewAccountName", Settings.versions(
            new V(87, new FontSizeSetting(FontSizes.FONT_DEFAULT))
        ));
        s.put("messageViewPostDeleteAction", Settings.versions(
            new V(89, new EnumSetting<>(PostRemoveNavigation.class, PostRemoveNavigation.ReturnToMessageList))
        ));

        SETTINGS = Collections.unmodifiableMap(s);

@@ -298,6 +305,7 @@ public class GeneralSettingsDescriptions {
        u.put(58, new GeneralSettingsUpgraderTo58());
        u.put(69, new GeneralSettingsUpgraderTo69());
        u.put(79, new GeneralSettingsUpgraderTo79());
        u.put(89, new GeneralSettingsUpgraderTo89());

        UPGRADERS = Collections.unmodifiableMap(u);
    }
+1 −1
Original line number Diff line number Diff line
@@ -36,7 +36,7 @@ public class Settings {
     *
     * @see SettingsExporter
     */
    public static final int VERSION = 88;
    public static final int VERSION = 89;

    static Map<String, Object> validate(int version, Map<String, TreeMap<Integer, SettingsDescription>> settings,
            Map<String, String> importedSettings, boolean useDefaultValues) {
+23 −0
Original line number Diff line number Diff line
package com.fsck.k9.preferences.upgrader

import com.fsck.k9.preferences.Settings.SettingsUpgrader

/**
 * Combine `messageViewReturnToList` and `messageViewShowNext` into `messageViewPostDeleteAction`.
 */
class GeneralSettingsUpgraderTo89 : SettingsUpgrader {
    override fun upgrade(settings: MutableMap<String, Any>): Set<String> {
        val messageViewReturnToList = settings["messageViewReturnToList"] as? Boolean
        val messageViewShowNext = settings["messageViewShowNext"] as? Boolean

        if (messageViewReturnToList == true) {
            settings["messageViewPostDeleteAction"] = "ReturnToMessageList"
        } else if (messageViewShowNext == true) {
            settings["messageViewPostDeleteAction"] = "ShowNextMessage"
        } else {
            settings["messageViewPostDeleteAction"] = "ShowPreviousMessage"
        }

        return setOf("messageViewReturnToList", "messageViewShowNext")
    }
}
+6 −0
Original line number Diff line number Diff line
@@ -221,4 +221,10 @@
        <item>move</item>
    </string-array>

    <string-array name="post_remove_navigation_values" translatable="false">
        <item>ReturnToMessageList</item>
        <item>ShowPreviousMessage</item>
        <item>ShowNextMessage</item>
    </string-array>

</resources>
Loading