diff --git a/README.md b/README.md index 2299b13..139ae56 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [![](https://img.shields.io/badge/Fitbit%20App%20Gallery-%2300B0B9?style=flat&logo=fitbit&logoColor=white)](https://gallery.fitbit.com/details/ae441b73-2660-407f-b796-a98d1d0583a0) ![languages](https://img.shields.io/badge/languages-JavaScript%20|%20CSS-blue) ![platform](https://img.shields.io/badge/platforms-Ionic%20|%20Versa%20|%20Versa%202%20|%20Versa%20Lite-silver) -[![version](https://img.shields.io/badge/version-%201.3.0-green)](https://github.com/smirko-dev/fitbit-clockface/releases) +![version](https://img.shields.io/badge/version-%201.4.0-green) [![](https://img.shields.io/github/license/smirko-dev/fitbit-clockface.svg)](https://github.com/smirko-dev/fitbit-clockface/blob/master/LICENSE) [![FitbitBuild Actions Status](https://github.com/smirko-dev/fitbit-clockface/workflows/FitbitBuild/badge.svg)](https://github.com/smirko-dev/fitbit-clockface/actions) [![CodeQL Actions Status](https://github.com/smirko-dev/fitbit-clockface/workflows/CodeQL/badge.svg)](https://github.com/smirko-dev/fitbit-clockface/actions) @@ -14,9 +14,9 @@ This is a simple clock face for Fitbit. It comes with - time (12/24hr format), date (including weekday) - languages: de-DE, en-EN -- battery icon with status in percentage +- battery icon (Ionic: and status in percentage) - next calendar event of the current day -- step count in case of no events +- user activity in case of no events (selectable in settings menu) Find the latest published version in the [Fitbit gallery](https://gallery.fitbit.com/details/ae441b73-2660-407f-b796-a98d1d0583a0). @@ -34,6 +34,10 @@ Icons are from https://materialdesignicons.com/ ([Apache license version 2.0](ht ![Versa 2 Appointment](screenshots/versa2-event.png) ![Versa 2 Activity](screenshots/versa2-activity.png) +### Settings + +![Settings](screenshots/settings.png) + ## How to build ``` diff --git a/app/index.js b/app/index.js index d9a187e..90aeef1 100644 --- a/app/index.js +++ b/app/index.js @@ -8,9 +8,10 @@ import { me as device } from "device"; import * as util from "../common/utils"; import * as appointment from "./appointment"; import * as clock from "./clock"; +import * as messaging from "messaging"; import { fromEpochSec, timeString } from "../common/utils"; -// Get a handle on the elements +// Get a handle on the and elements const hourLabel = document.getElementById("hourLabel"); const minuteLabel = document.getElementById("minuteLabel"); const dateLabel = document.getElementById("dateLabel"); @@ -21,6 +22,32 @@ const batteryLabel = document.getElementById("batteryLabel"); const activityIcon = document.getElementById("activityIcon"); const activityLabel = document.getElementById("activityLabel"); +const ActivitySelection = { + DIST: 'distance', + FLOORS: 'floors', + CAL: 'calories', + STEPS: 'steps' +} + +let activitySelection = ActivitySelection.STEPS; + +// Update app settings +messaging.peerSocket.onmessage = (evt) => { + if (evt.data === "distance") { + activitySelection = ActivitySelection.DIST; + } + else if (evt.data === "floors") { + activitySelection = ActivitySelection.FLOORS; + } + else if (evt.data === "calories") { + activitySelection = ActivitySelection.CAL; + } + else { + activitySelection = ActivitySelection.STEPS; + } + renderAppointment(); +} + clock.initialize("minutes", data => { // Update elements with each tick hourLabel.text = data.hours; @@ -42,7 +69,7 @@ appointment.initialize(() => { }); display.addEventListener("change", () => { - // Update appointment on display on + // Update appointment and battery on display on if (display.on) { renderAppointment(); renderBattery(); @@ -58,19 +85,36 @@ function renderAppointment() { hideActivity(); } else { - appointmentsLabel.text = "" + appointmentsLabel.text = ""; renderActivity(); } } function hideActivity() { - activityIcon.image = "" - activityLabel.text = "" + activityIcon.image = ""; + activityLabel.text = ""; } function renderActivity() { - activityIcon.image = "shoe-print.png" - activityLabel.text = today.adjusted.steps + switch (activitySelection) { + case ActivitySelection.DIST: + activityIcon.image = "distance.png"; + activityLabel.text = today.adjusted.distance; + break; + case ActivitySelection.FLOORS: + + activityIcon.image = "floors.png"; + activityLabel.text = today.adjusted.elevationGain; + break; + case ActivitySelection.CAL: + activityIcon.image = "calories.png"; + activityLabel.text = today.adjusted.calories; + break; + default: + activityIcon.image = "steps.png"; + activityLabel.text = today.adjusted.steps; + break; + } } function renderBattery() { diff --git a/common/utils.js b/common/utils.js index 70214d3..a6bd3cb 100644 --- a/common/utils.js +++ b/common/utils.js @@ -20,6 +20,18 @@ export function dayString(day) { else if (day == 3) { return "3rd" } + if (day == 21) { + return "21st" + } + else if (day == 22) { + return "22nd" + } + else if (day == 23) { + return "23rd" + } + if (day == 31) { + return "31st" + } return day.toString() + "th"; } diff --git a/companion/index.js b/companion/index.js index a3c4f79..1e7abdc 100644 --- a/companion/index.js +++ b/companion/index.js @@ -6,6 +6,19 @@ import { outbox } from "file-transfer"; import { toEpochSec } from "../common/utils"; import { dataFile, millisecondsPerMinute } from "../common/constants"; +import { settingsStorage } from "settings"; +import * as messaging from "messaging"; + +// Update user settings +settingsStorage.onchange = function(evt) { + if (messaging.peerSocket.readyState === messaging.peerSocket.OPEN) { + if (evt.key === "activity") { + let data = JSON.parse(evt.newValue); + messaging.peerSocket.send(data["values"][0].value); + } + } +} + companion.wakeInterval = 15 * millisecondsPerMinute; companion.addEventListener("wakeinterval", refreshEvents); diff --git a/package.json b/package.json index 2181b6b..ee6ac07 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "compactclock", - "version": "1.3.0", + "version": "1.4.0", "license": "MIT", "devDependencies": { "@fitbit/sdk": "~4.2.0", diff --git a/resources/battery-10.png b/resources/battery-10.png index e8f7f15..3406535 100644 --- a/resources/battery-10.png +++ b/resources/battery-10.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3d6b02b3016bed68b9b1a5df9d0ed03c5387e95da46befc615383cd266e43e99 -size 406 +oid sha256:df878505e864b1401548a609e55bcd0b5af9e2b3b968da69c2203cbb842134f9 +size 5756 diff --git a/resources/battery-100.png b/resources/battery-100.png index 3b7a29b..d8b0407 100644 --- a/resources/battery-100.png +++ b/resources/battery-100.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:159a3c75899f5307b3f3a2138dcf782b65d6904aa398a26aa4d1f5323f399149 -size 390 +oid sha256:5edaf5cf8a7c6a374ba89113f83594765bb47a262696173c7a90831d087f1ef8 +size 5586 diff --git a/resources/battery-20.png b/resources/battery-20.png index 657ea77..a7eb7b9 100644 --- a/resources/battery-20.png +++ b/resources/battery-20.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:0a2b3923092ed7919150ab4429922bbc14b5ac0ea7e12e329185c7ad68d7ed62 -size 406 +oid sha256:df935af93b734f56b0fe3042c7122d6f261ee3338e264b8047adda154e916e39 +size 5874 diff --git a/resources/battery-30.png b/resources/battery-30.png index ee208f0..9bc2a89 100644 --- a/resources/battery-30.png +++ b/resources/battery-30.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:bf86cb42d62063ed84c47e94712b6dc4540c8fa98d38a2ed36f734129251496a -size 407 +oid sha256:252c7e06fd9ee04c371ef81849222842ef47ae50b673b0b3b122e594225eea13 +size 5734 diff --git a/resources/battery-40.png b/resources/battery-40.png index c5777e7..fb79523 100644 --- a/resources/battery-40.png +++ b/resources/battery-40.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:333f8c49f9c6f21d0406b905e8f652fe3f608468bf1d0329b67917182e85a17b -size 405 +oid sha256:66e04d7c7051c242ca5d1c56d7fbb1826502273be6ee647e95fff1193de10800 +size 5839 diff --git a/resources/battery-50.png b/resources/battery-50.png index ab46b07..3755950 100644 --- a/resources/battery-50.png +++ b/resources/battery-50.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:cc8a4a9ee5bff99faae9f1a08c783e54a5edb89989bfb4447db29b29d775252b -size 405 +oid sha256:479b1671484a5fa090aad4e37718d015bc0299103b2a09ddcc3a8ffe4a299e74 +size 5887 diff --git a/resources/battery-60.png b/resources/battery-60.png index fab9447..818a11d 100644 --- a/resources/battery-60.png +++ b/resources/battery-60.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:dd32bef6c886784833bd06af710ded1a7874aa4bd4b1965fdd20eaf83a8edd80 -size 406 +oid sha256:9422ebe0ed813239a3be7aa22d321ee9ff55588f7f3449fe734e91eb46b6f3af +size 5713 diff --git a/resources/battery-70.png b/resources/battery-70.png index a450de8..4057287 100644 --- a/resources/battery-70.png +++ b/resources/battery-70.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b026894674cc403c539d4b911b28156bd985cd91a25f0530c9ad703b6c8eddc1 -size 405 +oid sha256:76b9ed46bcfead1c5463273167d20e294a2fd7032146ae3deb64b16aa38fd0ef +size 5867 diff --git a/resources/battery-80.png b/resources/battery-80.png index 7132474..b005246 100644 --- a/resources/battery-80.png +++ b/resources/battery-80.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e97e0bbb5ad81abcbacdfa67efa887ad5cdd932353a40d9678bc61ad9637fde1 -size 405 +oid sha256:a67068a7249f7f778b54211139717288da68490e89eaea4303df330dc2126fce +size 5694 diff --git a/resources/battery-90.png b/resources/battery-90.png index 842e1c6..a99e0f9 100644 --- a/resources/battery-90.png +++ b/resources/battery-90.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5d0095b3f4a77d5d9738980e9939feaa2337cfb9eec8cbb6c30433bf2a01e4b0 -size 405 +oid sha256:646eb5322342c9e90fc6f1dc187e528cab64bee576743d8ae9b582fe0771e50c +size 5812 diff --git a/resources/battery-alert.png b/resources/battery-alert.png index 7e6d683..2afe78c 100644 --- a/resources/battery-alert.png +++ b/resources/battery-alert.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:48697103b61b3ca7458d15e574ed4c44ca34e543620e05d88c8943317ca2977e -size 404 +oid sha256:ad7ad7a19cd82c76c60f73b809de729778a9a8ea80f978ed28608183f871cbc0 +size 5906 diff --git a/resources/calories.png b/resources/calories.png new file mode 100644 index 0000000..43286f3 --- /dev/null +++ b/resources/calories.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:39dfa8af07eb9e0f38a41239aef84be9d1daa7001c73a5c684fc7d140fe47f90 +size 8830 diff --git a/resources/distance.png b/resources/distance.png new file mode 100644 index 0000000..54d1fab --- /dev/null +++ b/resources/distance.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:85165705ed7d0ff229f6f2baa4abb13db149349c5b6cce6c8390d7cbde7ced4d +size 8580 diff --git a/resources/floors.png b/resources/floors.png new file mode 100644 index 0000000..c701950 --- /dev/null +++ b/resources/floors.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b06d3a312482dc988358766ac5b80a222b9055188a2328b3d684af5ff65e527d +size 6189 diff --git a/resources/index.gui b/resources/index.gui index f84ee13..a59860b 100644 --- a/resources/index.gui +++ b/resources/index.gui @@ -1,10 +1,10 @@ - - - - - - + + + + + + \ No newline at end of file diff --git a/resources/shoe-print.png b/resources/steps.png similarity index 100% rename from resources/shoe-print.png rename to resources/steps.png diff --git a/resources/styles.css b/resources/styles.css index 391778f..5f7f20c 100644 --- a/resources/styles.css +++ b/resources/styles.css @@ -65,4 +65,8 @@ .activityIcon { fill: #2490DD +} + +.batteryIcon { + fill: #FFFFFF } \ No newline at end of file diff --git a/screenshots/ionic-activity.png b/screenshots/ionic-activity.png index c6563b4..605b57a 100644 --- a/screenshots/ionic-activity.png +++ b/screenshots/ionic-activity.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9cbe19064048831360880e7cc2f93fef7e0a759bdb7dd2da465458a837e98a16 -size 15793 +oid sha256:15435c99f29d70d32e7921cb4e4ff7e830c59764f2d2d04ee04fdd576cd6e680 +size 16407 diff --git a/screenshots/ionic-event.png b/screenshots/ionic-event.png index 61244b7..1bcd5bf 100644 --- a/screenshots/ionic-event.png +++ b/screenshots/ionic-event.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f13396f058417741359209bd0f5554d62b01db034030319357a22c5d141afaed -size 18918 +oid sha256:21f9b423c41831c2d8ec09d8974547c3a3ab0601986ddd55931b22b4a51343ac +size 20460 diff --git a/screenshots/settings.png b/screenshots/settings.png new file mode 100644 index 0000000..781768e --- /dev/null +++ b/screenshots/settings.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ae45b7a05f7b5817ce3df4331bd6ac197149b5eb4c4a6a04473ec34dd23f68ee +size 6659 diff --git a/screenshots/versa2-activity.png b/screenshots/versa2-activity.png index dfec7d8..e03ade9 100644 --- a/screenshots/versa2-activity.png +++ b/screenshots/versa2-activity.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:665d530932af57251f015ffdf3e6f5605e247ea12266316cf2edaa8d870bd344 -size 14062 +oid sha256:909404a70880753b0dbad08f1b17f7f4a1b46a358182eddf3c1563f9298d283a +size 15167 diff --git a/screenshots/versa2-event.png b/screenshots/versa2-event.png index b9a18dd..d75d5db 100644 --- a/screenshots/versa2-event.png +++ b/screenshots/versa2-event.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d40d939740824bbc7aeeca72d47b9dcec137d25fe7dd5d6645bd0e37a634b32d -size 17956 +oid sha256:20d0e595236fce614838bb1b8d8d6ee944deb15104b604831d4d317586dac443 +size 18608 diff --git a/settings/i18n/de-DE.po b/settings/i18n/de-DE.po new file mode 100644 index 0000000..957f850 --- /dev/null +++ b/settings/i18n/de-DE.po @@ -0,0 +1,15 @@ + +msgid "title" +msgstr "Aktivitäts-Info" + +msgid "steps" +msgstr "Schritte" + +msgid "cal" +msgstr "Kalorien" + +msgid "dist" +msgstr "Distanz" + +msgid "floors" +msgstr "Etagen" diff --git a/settings/i18n/en-US.po b/settings/i18n/en-US.po new file mode 100644 index 0000000..2e0e706 --- /dev/null +++ b/settings/i18n/en-US.po @@ -0,0 +1,15 @@ + +msgid "title" +msgstr "Activity info" + +msgid "steps" +msgstr "Steps" + +msgid "cal" +msgstr "Calories" + +msgid "dist" +msgstr "Distance" + +msgid "floors" +msgstr "Floors" diff --git a/settings/i18n/ru-RU.po b/settings/i18n/ru-RU.po new file mode 100644 index 0000000..5dbc05d --- /dev/null +++ b/settings/i18n/ru-RU.po @@ -0,0 +1,15 @@ + +msgid "title" +msgstr "Инфо о деятельности" + +msgid "steps" +msgstr "Шаги" + +msgid "cal" +msgstr "Калорий" + +msgid "dist" +msgstr "Расстояние" + +msgid "floors" +msgstr "Полы" diff --git a/settings/index.jsx b/settings/index.jsx new file mode 100644 index 0000000..df876b2 --- /dev/null +++ b/settings/index.jsx @@ -0,0 +1,28 @@ + +import { gettext } from "i18n"; + +function settingsFunc(props) { + let title = gettext("title"); + let steps = gettext("steps"); + let dist = gettext("dist"); + let floors = gettext("floors"); + let cal = gettext("cal"); + return ( + +
+