Change default color for registered contacts (#5865)
Change default value of `registeredNameColor` to have enough contrast in both the light and dark theme.
This commit is contained in:
parent
0e703cb380
commit
e8a798c9de
7 changed files with 50 additions and 6 deletions
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
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())
|
||||
}
|
||||
}
|
||||
}
|
|
@ -21,5 +21,6 @@ internal object StorageMigrations {
|
|||
if (oldVersion < 13) StorageMigrationTo13(db, migrationsHelper).renameHideSpecialAccounts()
|
||||
if (oldVersion < 14) StorageMigrationTo14(db, migrationsHelper).disablePushFoldersForNonImapAccounts()
|
||||
if (oldVersion < 15) StorageMigrationTo15(db, migrationsHelper).rewriteIdleRefreshInterval()
|
||||
if (oldVersion < 16) StorageMigrationTo16(db, migrationsHelper).changeDefaultRegisteredNameColor()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -292,7 +292,8 @@
|
|||
<com.takisoft.preferencex.ColorPickerPreference
|
||||
android:dependency="messagelist_change_contact_name_color"
|
||||
android:key="messagelist_contact_name_color"
|
||||
android:title="Contact name color" />
|
||||
android:title="Contact name color"
|
||||
android:defaultValue="#FF1093F5" />
|
||||
|
||||
<CheckBoxPreference
|
||||
android:key="messagelist_show_contact_picture"
|
||||
|
|
Loading…
Reference in a new issue