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

Unverified Commit 6a63698b authored by cketti's avatar cketti Committed by GitHub
Browse files

Merge pull request #5126 from k9mail/rename_hide_unified_inbox

Rename "hideSpecialAccounts" to "showUnifiedInbox"
parents 2fa90e8b ddabe3a2
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -227,7 +227,7 @@ object K9 : EarlyInit {
    var isUseVolumeKeysForListNavigation = false

    @JvmStatic
    var isHideSpecialAccounts = false
    var isShowUnifiedInbox = true

    @JvmStatic
    var isAutoFitWidth: Boolean = false
@@ -338,7 +338,7 @@ object K9 : EarlyInit {
        isShowAnimations = storage.getBoolean("animations", true)
        isUseVolumeKeysForNavigation = storage.getBoolean("useVolumeKeysForNavigation", false)
        isUseVolumeKeysForListNavigation = storage.getBoolean("useVolumeKeysForListNavigation", false)
        isHideSpecialAccounts = storage.getBoolean("hideSpecialAccounts", false)
        isShowUnifiedInbox = storage.getBoolean("showUnifiedInbox", true)
        isMessageListSenderAboveSubject = storage.getBoolean("messageListSenderAboveSubject", false)
        isShowMessageListStars = storage.getBoolean("messageListStars", true)
        messageListPreviewLines = storage.getInt("messageListPreviewLines", 2)
@@ -424,7 +424,7 @@ object K9 : EarlyInit {
        editor.putString("quietTimeEnds", quietTimeEnds)

        editor.putBoolean("messageListSenderAboveSubject", isMessageListSenderAboveSubject)
        editor.putBoolean("hideSpecialAccounts", isHideSpecialAccounts)
        editor.putBoolean("showUnifiedInbox", isShowUnifiedInbox)
        editor.putBoolean("messageListStars", isShowMessageListStars)
        editor.putInt("messageListPreviewLines", messageListPreviewLines)
        editor.putBoolean("showCorrespondentNames", isShowCorrespondentNames)
+25 −1
Original line number Diff line number Diff line
@@ -129,7 +129,8 @@ public class GeneralSettingsDescriptions {
                new V(1, new FontSizeSetting(FontSizes.FONT_DEFAULT))
        ));
        s.put("hideSpecialAccounts", Settings.versions(
                new V(1, new BooleanSetting(false))
                new V(1, new BooleanSetting(false)),
                new V(69, null)
        ));
        s.put("keyguardPrivacy", Settings.versions(
                new V(1, new BooleanSetting(false)),
@@ -171,6 +172,9 @@ public class GeneralSettingsDescriptions {
        s.put("showCorrespondentNames", Settings.versions(
                new V(1, new BooleanSetting(true))
        ));
        s.put("showUnifiedInbox", Settings.versions(
                new V(69, new BooleanSetting(true))
        ));
        s.put("sortTypeEnum", Settings.versions(
                new V(10, new EnumSetting<>(SortType.class, Account.DEFAULT_SORT_TYPE))
        ));
@@ -284,6 +288,7 @@ public class GeneralSettingsDescriptions {
        u.put(24, new SettingsUpgraderV24());
        u.put(31, new SettingsUpgraderV31());
        u.put(58, new SettingsUpgraderV58());
        u.put(69, new SettingsUpgraderV69());

        UPGRADERS = Collections.unmodifiableMap(u);
    }
@@ -418,6 +423,25 @@ public class GeneralSettingsDescriptions {
        }
    }

    /**
     * Upgrades the settings from version 68 to 69.
     *
     * <p>
     * Renames {@code hideSpecialAccounts} to {@code showUnifiedInbox}.
     * </p>
     */
    private static class SettingsUpgraderV69 implements SettingsUpgrader {

        @Override
        public Set<String> upgrade(Map<String, Object> settings) {
            Boolean hideSpecialAccounts = (Boolean) settings.get("hideSpecialAccounts");
            boolean showUnifiedInbox = hideSpecialAccounts == null || !hideSpecialAccounts;
            settings.put("showUnifiedInbox", showUnifiedInbox);

            return new HashSet<>(Collections.singleton("hideSpecialAccounts"));
        }
    }

    private static class LanguageSetting extends PseudoEnumSetting<String> {
        private final Context context = DI.get(Context.class);
        private final Map<String, String> mapping;
+1 −1
Original line number Diff line number Diff line
@@ -36,7 +36,7 @@ public class Settings {
     *
     * @see SettingsExporter
     */
    public static final int VERSION = 68;
    public static final int VERSION = 69;

    static Map<String, Object> validate(int version, Map<String, TreeMap<Integer, SettingsDescription>> settings,
            Map<String, String> importedSettings, boolean useDefaultValues) {
+1 −1
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@ import timber.log.Timber;


public class K9StoragePersister implements StoragePersister {
    private static final int DB_VERSION = 12;
    private static final int DB_VERSION = 13;
    private static final String DB_NAME = "preferences_storage";

    private final Context context;
+18 −0
Original line number Diff line number Diff line
package com.fsck.k9.preferences.migrations

import android.database.sqlite.SQLiteDatabase

/**
 * Rename `hideSpecialAccounts` to `showUnifiedInbox` (and invert value).
 */
class StorageMigrationTo13(
    private val db: SQLiteDatabase,
    private val migrationsHelper: StorageMigrationsHelper
) {
    fun renameHideSpecialAccounts() {
        val hideSpecialAccounts = migrationsHelper.readValue(db, "hideSpecialAccounts")?.toBoolean() ?: false
        val showUnifiedInbox = !hideSpecialAccounts
        migrationsHelper.insertValue(db, "showUnifiedInbox", showUnifiedInbox.toString())
        migrationsHelper.writeValue(db, "hideSpecialAccounts", null)
    }
}
Loading