Skip to content

Commit b2019ff

Browse files
authored
feat: migrate default weekend and holiday colors to red (folly) (#148)
Changes default sat/sun/holiday colors to `GColorFolly`, a red color that's slightly lightened for readability. This is the loadout I daily drive on the watch face and I think it's a better default because otherwise there's no indication of the weekend/holiday tracking feature. For users who were on the old default (sat/sun/holidays all set to white color), perform one time migration to the new default. Tested with a `dev-config.js` flag which resets the migration completion key: ```js module.exports.resetV134WeekendHolidayColorMigration = true ``` Resolves #143
1 parent 3ebbe03 commit b2019ff

4 files changed

Lines changed: 97 additions & 19 deletions

File tree

src/c/appendix/config.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ static Config config_defaults(void) {
2424
.show_am_pm = false,
2525
.time_font = TIME_FONT_ROBOTO,
2626
.color_today = GColorBlack,
27-
.color_saturday = GColorWhite,
28-
.color_sunday = GColorWhite,
29-
.color_us_federal = GColorWhite,
27+
.color_saturday = GColorFolly,
28+
.color_sunday = GColorFolly,
29+
.color_us_federal = GColorFolly,
3030
.color_time = GColorWhite,
3131
.day_night_shading = true
3232
};

src/c/appendix/persist.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ void persist_init() {
5454
.show_bt_disconnect = true,
5555
.vibe = false,
5656
.show_am_pm = false,
57-
.color_saturday = GColorWhite,
58-
.color_sunday = GColorWhite,
59-
.color_us_federal = GColorWhite,
57+
.color_saturday = GColorFolly,
58+
.color_sunday = GColorFolly,
59+
.color_us_federal = GColorFolly,
6060
.color_time = GColorWhite,
6161
.day_night_shading = true
6262
};

src/pkjs/clay/config.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,24 +126,24 @@ module.exports = [
126126
"type": "color",
127127
"label": "Sunday color",
128128
"messageKey": "colorSunday",
129-
"defaultValue": "#FFFFFF",
129+
"defaultValue": "#FF0055",
130130
"sunlight": false,
131131
"capabilities": ["COLOR"]
132132
},
133133
{
134134
"type": "color",
135135
"label": "Saturday color",
136136
"messageKey": "colorSaturday",
137-
"defaultValue": "#FFFFFF",
137+
"defaultValue": "#FF0055",
138138
"sunlight": false,
139139
"capabilities": ["COLOR"]
140140
},
141141
{
142142
"type": "color",
143143
"label": "US federal holidays color",
144144
"messageKey": "colorUSFederal",
145-
"defaultValue": "#FFFFFF",
146-
"description": "White (default) means disable",
145+
"defaultValue": "#FF0055",
146+
"description": "White means disable",
147147
"sunlight": false,
148148
"capabilities": ["COLOR"]
149149
},

src/pkjs/index.js

Lines changed: 87 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ var KEY_LAST_FETCH_SUCCESS = storageKeys.LAST_FETCH_SUCCESS_KEY;
4545
var KEY_LAST_FETCH_ATTEMPT = storageKeys.LAST_FETCH_ATTEMPT_KEY;
4646
var KEY_GEOCODE_CACHE = storageKeys.GEOCODE_CACHE_KEY;
4747
var KEY_GEOCODE_BACKOFF = storageKeys.GEOCODE_BACKOFF_KEY;
48+
var KEY_V1_34_0_WEEKEND_HOLIDAY_COLOR_MIGRATION = 'v1.34.0_weekend_holiday_color_migration';
49+
var DEFAULT_COLOR_WHITE = pebbleColors.GColorWhite;
50+
var DEFAULT_COLOR_FOLLY = pebbleColors.GColorFolly;
4851

4952
app.fetchInProgress = false;
5053
app.pendingStartupFetch = false;
@@ -103,6 +106,8 @@ Pebble.addEventListener('webviewclosed', function(e) {
103106
// Listen for when the watchface is opened
104107
Pebble.addEventListener('ready',
105108
function (e) {
109+
var migratedWeekendHolidayColors;
110+
106111
app.devConfig = getDevConfig();
107112
maybeHandleDevStorageReset(app.devConfig);
108113
var hadExistingInstall = localStorage.getItem('clay-settings') !== null;
@@ -111,6 +116,7 @@ Pebble.addEventListener('ready',
111116
app.devConfig.forceShowReleaseNotificationOnBoot
112117
);
113118
clayTryDefaults();
119+
migratedWeekendHolidayColors = clayTryWeekendHolidayColorMigration();
114120
clayTryDevConfig(app.devConfig);
115121
clayTryFixtureSettings(activeFixture);
116122
console.log('PebbleKit JS ready!');
@@ -132,6 +138,9 @@ Pebble.addEventListener('ready',
132138
});
133139
return;
134140
}
141+
if (migratedWeekendHolidayColors) {
142+
sendClaySettings(markWeekendHolidayColorMigrationComplete);
143+
}
135144
if (app.pendingStartupFetch) {
136145
app.pendingStartupFetch = false;
137146
fetch(app.provider, true);
@@ -322,11 +331,20 @@ function maybeShowReleaseNotification(hadExistingInstall, forceVersionSpec) {
322331
*/
323332
function maybeHandleDevStorageReset(devConfig) {
324333
var shouldClear = !!(devConfig && devConfig.clearPkjsStorageOnBoot);
334+
var shouldResetV134WeekendHolidayColorMigration = !!(
335+
devConfig &&
336+
devConfig.resetV134WeekendHolidayColorMigration
337+
);
325338

326339
if (shouldClear) {
327340
console.log('[dev] clearPkjsStorageOnBoot=true, clearing localStorage');
328341
localStorage.clear();
329342
}
343+
344+
if (shouldResetV134WeekendHolidayColorMigration) {
345+
console.log('[dev] resetV134WeekendHolidayColorMigration=true, clearing migration marker');
346+
localStorage.removeItem(KEY_V1_34_0_WEEKEND_HOLIDAY_COLOR_MIGRATION);
347+
}
330348
}
331349

332350
/**
@@ -376,7 +394,7 @@ function sendClaySettings(onSuccess, onFailure) {
376394
"CLAY_CELSIUS": app.settings.temperatureUnits === 'c',
377395
"CLAY_TIME_LEAD_ZERO": app.settings.timeLeadingZero,
378396
"CLAY_AXIS_12H": app.settings.axisTimeFormat === '12h',
379-
"CLAY_COLOR_TODAY": app.settings.hasOwnProperty('colorToday') ? app.settings.colorToday : 16777215,
397+
"CLAY_COLOR_TODAY": app.settings.hasOwnProperty('colorToday') ? app.settings.colorToday : DEFAULT_COLOR_WHITE,
380398
"CLAY_START_MON": app.settings.weekStartDay === 'mon',
381399
"CLAY_PREV_WEEK": app.settings.firstWeek === 'prev',
382400
"CLAY_TIME_FONT": ['roboto', 'leco', 'bitham'].indexOf(app.settings.timeFont),
@@ -385,10 +403,10 @@ function sendClaySettings(onSuccess, onFailure) {
385403
"CLAY_SHOW_BT_DISCONNECT": app.settings.btIcons === "disconnected" || app.settings.btIcons === "both",
386404
"CLAY_VIBE": app.settings.vibe,
387405
"CLAY_SHOW_AM_PM": app.settings.timeShowAmPm,
388-
"CLAY_COLOR_SUNDAY": app.settings.hasOwnProperty('colorSunday') ? app.settings.colorSunday : 16777215,
389-
"CLAY_COLOR_SATURDAY": app.settings.hasOwnProperty('colorSaturday') ? app.settings.colorSaturday : 16777215,
390-
"CLAY_COLOR_US_FEDERAL": app.settings.hasOwnProperty('colorUSFederal') ? app.settings.colorUSFederal : 16777215,
391-
"CLAY_COLOR_TIME": app.settings.hasOwnProperty('colorTime') ? app.settings.colorTime : 16777215,
406+
"CLAY_COLOR_SUNDAY": app.settings.hasOwnProperty('colorSunday') ? app.settings.colorSunday : DEFAULT_COLOR_FOLLY,
407+
"CLAY_COLOR_SATURDAY": app.settings.hasOwnProperty('colorSaturday') ? app.settings.colorSaturday : DEFAULT_COLOR_FOLLY,
408+
"CLAY_COLOR_US_FEDERAL": app.settings.hasOwnProperty('colorUSFederal') ? app.settings.colorUSFederal : DEFAULT_COLOR_FOLLY,
409+
"CLAY_COLOR_TIME": app.settings.hasOwnProperty('colorTime') ? app.settings.colorTime : DEFAULT_COLOR_WHITE,
392410
"CLAY_DAY_NIGHT_SHADING": app.settings.hasOwnProperty('dayNightShading') ? app.settings.dayNightShading : true,
393411
}
394412
Pebble.sendAppMessage(payload, function() {
@@ -484,20 +502,79 @@ function getDefaultClaySettings() {
484502
timeShowAmPm: false,
485503
axisTimeFormat: '24h',
486504
timeFont: 'roboto',
487-
colorTime: 16777215,
505+
colorTime: DEFAULT_COLOR_WHITE,
488506
weekStartDay: 'sun',
489507
firstWeek: 'prev',
490508
colorToday: 0,
491-
colorSunday: 16777215,
492-
colorSaturday: 16777215,
493-
colorUSFederal: 16777215,
509+
colorSunday: DEFAULT_COLOR_FOLLY,
510+
colorSaturday: DEFAULT_COLOR_FOLLY,
511+
colorUSFederal: DEFAULT_COLOR_FOLLY,
494512
showQt: true,
495513
vibe: false,
496514
btIcons: 'both',
497515
telemetryEnabled: true
498516
};
499517
}
500518

519+
/**
520+
* Move existing installs from the old all-white weekend/holiday defaults to the
521+
* current highlighted default while preserving any customized color set.
522+
*
523+
* @returns {boolean} True when the migrated settings should be sent to the watch.
524+
*/
525+
function clayTryWeekendHolidayColorMigration() {
526+
var persistClayString = localStorage.getItem('clay-settings');
527+
var persistClay;
528+
529+
if (
530+
persistClayString === null ||
531+
localStorage.getItem(KEY_V1_34_0_WEEKEND_HOLIDAY_COLOR_MIGRATION) !== null
532+
) {
533+
return false;
534+
}
535+
536+
try {
537+
persistClay = JSON.parse(persistClayString);
538+
}
539+
catch (ex) {
540+
console.log('Malformed clay settings found, skipping weekend/holiday color migration');
541+
return false;
542+
}
543+
544+
if (
545+
persistClay.colorSunday === DEFAULT_COLOR_WHITE &&
546+
persistClay.colorSaturday === DEFAULT_COLOR_WHITE &&
547+
persistClay.colorUSFederal === DEFAULT_COLOR_WHITE
548+
) {
549+
persistClay.colorSunday = DEFAULT_COLOR_FOLLY;
550+
persistClay.colorSaturday = DEFAULT_COLOR_FOLLY;
551+
persistClay.colorUSFederal = DEFAULT_COLOR_FOLLY;
552+
localStorage.setItem('clay-settings', JSON.stringify(persistClay));
553+
console.log('Migrated weekend/holiday color defaults to Folly');
554+
return true;
555+
}
556+
557+
if (
558+
persistClay.colorSunday === DEFAULT_COLOR_FOLLY &&
559+
persistClay.colorSaturday === DEFAULT_COLOR_FOLLY &&
560+
persistClay.colorUSFederal === DEFAULT_COLOR_FOLLY
561+
) {
562+
return true;
563+
}
564+
565+
markWeekendHolidayColorMigrationComplete();
566+
return false;
567+
}
568+
569+
/**
570+
* Mark the v1.34.0 weekend/holiday color migration as complete.
571+
*
572+
* @returns {void}
573+
*/
574+
function markWeekendHolidayColorMigrationComplete() {
575+
localStorage.setItem(KEY_V1_34_0_WEEKEND_HOLIDAY_COLOR_MIGRATION, '1');
576+
}
577+
501578
function getDevConfig() {
502579
try {
503580
return require('./dev-config.js');
@@ -518,6 +595,7 @@ function clayTryDevConfig(devConfig) {
518595
var localOnlyDevConfigKeys = {
519596
clearPkjsStorageOnBoot: true,
520597
forceShowReleaseNotificationOnBoot: true,
598+
resetV134WeekendHolidayColorMigration: true,
521599
};
522600

523601
persistClay = getClaySettings();

0 commit comments

Comments
 (0)