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

Unverified Commit e8a798c9 authored by schlagi123's avatar schlagi123 Committed by GitHub
Browse files

Change default color for registered contacts (#5865)

Change default value of `registeredNameColor` to have enough contrast in both the light and dark theme.
parent 0e703cb3
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -171,7 +171,7 @@ object K9 : EarlyInit {
    var isChangeContactNameColor = false

    @JvmStatic
    var contactNameColor = 0xff00008f.toInt()
    var contactNameColor = 0xFF1093F5.toInt()

    @JvmStatic
    var isShowContactPicture = true
@@ -315,7 +315,7 @@ object K9 : EarlyInit {
        isShowContactName = storage.getBoolean("showContactName", false)
        isShowContactPicture = storage.getBoolean("showContactPicture", true)
        isChangeContactNameColor = storage.getBoolean("changeRegisteredNameColor", false)
        contactNameColor = storage.getInt("registeredNameColor", -0xffff71)
        contactNameColor = storage.getInt("registeredNameColor", 0xFF1093F5.toInt())
        isUseMessageViewFixedWidthFont = storage.getBoolean("messageViewFixedWidthFont", false)
        isMessageViewReturnToList = storage.getBoolean("messageViewReturnToList", false)
        isMessageViewShowNext = storage.getBoolean("messageViewShowNext", false)
+25 −1
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@ import java.util.Set;
import java.util.TreeMap;

import android.content.Context;
import android.graphics.Color;

import com.fsck.k9.Account;
import com.fsck.k9.Account.SortType;
@@ -157,7 +158,8 @@ public class GeneralSettingsDescriptions {
                new V(1, new TimeSetting("21:00"))
        ));
        s.put("registeredNameColor", Settings.versions(
                new V(1, new ColorSetting(0xFF00008F))
                new V(1, new ColorSetting(0xFF00008F)),
                new V(79, new ColorSetting(0xFF1093F5))
        ));
        s.put("showContactName", Settings.versions(
                new V(1, new BooleanSetting(false))
@@ -284,6 +286,7 @@ public class GeneralSettingsDescriptions {
        u.put(31, new SettingsUpgraderV31());
        u.put(58, new SettingsUpgraderV58());
        u.put(69, new SettingsUpgraderV69());
        u.put(79, new SettingsUpgraderV79());

        UPGRADERS = Collections.unmodifiableMap(u);
    }
@@ -416,6 +419,27 @@ public class GeneralSettingsDescriptions {
        }
    }

    /**
     * Upgrades the settings from version 78 to 79.
     *
     * <p>
     * Change default value of {@code registeredNameColor} to have enough contrast in both the light and dark theme.
     * </p>
     */
    private static class SettingsUpgraderV79 implements SettingsUpgrader {

        @Override
        public Set<String> upgrade(Map<String, Object> settings) {
            final Integer registeredNameColorValue = (Integer) settings.get("registeredNameColor");

            if (registeredNameColorValue != null && registeredNameColorValue == 0xFF00008F) {
                settings.put("registeredNameColor", 0xFF1093F5);
            }

            return null;
        }
    }

    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 = 78;
    public static final int VERSION = 79;

    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 = 15;
    private static final int DB_VERSION = 16;
    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

/**
 * Change default value of `registeredNameColor` to have enough contrast in both the light and dark theme.
 */
class StorageMigrationTo16(
    private val db: SQLiteDatabase,
    private val migrationsHelper: StorageMigrationsHelper
) {
    fun changeDefaultRegisteredNameColor() {
        val registeredNameColorValue = migrationsHelper.readValue(db, "registeredNameColor")?.toInt()
        if (registeredNameColorValue == 0xFF00008F.toInt()) {
            migrationsHelper.writeValue(db, "registeredNameColor", 0xFF1093F5.toInt().toString())
        }
    }
}
Loading