From a65dcd6811626d4b625310f761a9d47c4fb94038 Mon Sep 17 00:00:00 2001 From: Philip Abbey Date: Sun, 11 Feb 2024 19:35:34 +0000 Subject: [PATCH] Removed widget specific code --- HISTORY.md | 1 + README.md | 12 ++- compile_sim.cmd | 11 +- export.cmd | 17 --- include/app/WidgetApp.mc | 28 ----- include/widget/WidgetApp.mc | 28 ----- manifest-widget.xml | 196 ---------------------------------- manifest.xml | 2 +- monkey-widget.jungle | 205 ------------------------------------ monkey.jungle | 5 - source/HomeAssistantApp.mc | 14 +-- source/RootView.mc | 185 -------------------------------- 12 files changed, 19 insertions(+), 685 deletions(-) delete mode 100644 include/app/WidgetApp.mc delete mode 100644 include/widget/WidgetApp.mc delete mode 100644 manifest-widget.xml delete mode 100644 monkey-widget.jungle delete mode 100644 source/RootView.mc diff --git a/HISTORY.md b/HISTORY.md index d7f4c62..6aebc65 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -20,3 +20,4 @@ | 2.5 | A small memory efficiency of about 1kB by removing `RezStrings.mc`. This will aid widgets on old watches that only have 60kB available to an application and are using about 45kB before the menu is fetched, hence 1kB is more significant to those devices. | | 2.6 | Added more information reporting to the background service, in addition to the device battery level and charging status, we now include location, location accuracy, and (if supported by your device) the activity information. Note the updates are sent periodically and are not event driven. | | 2.7 | Bug fix release: 1. Handling a settings change, 2. Avoid caching a bad menu, 3. Managing bad JSON in menu definitions. | +| 2.8 | Separation release. The application and widget are no longer joined and now have separate source code repositories. The widget version is now in "maintenance only mode" and will not receive new features, whilst the application version can now take advantage of not being constrained by the widget's memory limitation, which should allow new features to be added in the future. | diff --git a/README.md b/README.md index c00a529..377b231 100644 --- a/README.md +++ b/README.md @@ -22,9 +22,17 @@ As of version 2.0, there are now two installable versions. For older devices bef | Version | Explanation | |------------------------|-------------| | Application (original) | For newer devices that allow glance views in their applications, e.g. Venu 2, the GarminHomeAssistant application can be started either from a glance or from the list of applications and activities. Head over to the [GarminHomeAssistant](https://apps.garmin.com/en-US/apps/61c91d28-ec5e-438d-9f83-39e9f45b199d) application page on the [Connect IQ application store](https://apps.garmin.com/en-US/) to download the application. The application can be started two different ways, either from the glance in the carousel, or as an application from the list of applications & activities. With the latter, it is worth marking the application as a favourite.

If you place the application on your list of favourites, and rearrange it to appear near the top, then the item is just one button press away from the watch face. This second picture here shows the application menu on a Vivoactive 3 watch.

On newer watches, you can also start the application from the glance carousel. The glance view here typically displays some trackable status, so ours provides some early indication of availability. Older watches will still allow you to start this application from the list of applications and activities. | -| Widget | For older devices that use widgets, e.g. Venu (1) as opposed to applications with "glances", the GarminHomeAssistant application can instead be started from the widget carousel. This is a separate item in the Connect IQ AppStore and with this installation, the application will no longer appear in the list of applications and activities. Head over to the [GarminHomeAssistant](https://apps.garmin.com/en-US/apps/) widget page on the [Connect IQ application store](https://apps.garmin.com/en-US/) to download the widget.

Typically the widget view implements something similar to the glance view, e.g. status, and exists in a widget carousel to allow you to select an application to launch.
**Please note that memory in widgets is more limited than applications. This means a large menu definition can crash the widget without the code catching the error.** | +| Widget | **"Maintenance only mode"** so no new features will be added to this version.
For older devices that use widgets, e.g. Venu (1) as opposed to applications with "glances", the GarminHomeAssistant application can instead be started from the widget carousel. This is a separate item in the Connect IQ AppStore and with this installation, the application will no longer appear in the list of applications and activities. Head over to the [GarminHomeAssistant](https://apps.garmin.com/en-US/apps/) widget page on the [Connect IQ application store](https://apps.garmin.com/en-US/) to download the widget.

Typically the widget view implements something similar to the glance view, e.g. status, and exists in a widget carousel to allow you to select an application to launch.
**Please note that memory in widgets is more limited than applications. This means a large menu definition can crash the widget without the code catching the error.**
This version was born out of the application version and from Ver 2.0 shared the same source code repository until Ver 2.8 when they were [separated](https://github.com/house-of-abbey/GarminHomeAssistantWidget) to allow the application version to take advantage of its increase memory availability. | -As the source code base for both is the same, the version numbers of each will be kept in step. That means that the widget version starts version numbering at 2.0. +### Source Code Repositories + +* [Application](https://github.com/house-of-abbey/GarminHomeAssistant) +* [Widget](https://github.com/house-of-abbey/GarminHomeAssistantWidget) + +### Connect IQ Store + +* [Application](https://apps.garmin.com/en-US/apps/61c91d28-ec5e-438d-9f83-39e9f45b199d) +* [Widget](https://apps.garmin.com/en-US/apps/559f5174-177f-4f46-b170-f31c7e74dea3) ## Dashboard Definition diff --git a/compile_sim.cmd b/compile_sim.cmd index e7e5048..90670ec 100644 --- a/compile_sim.cmd +++ b/compile_sim.cmd @@ -29,13 +29,8 @@ rem Assume we can create and use this directory set DEST=export rem Device for simulation -rem set DEVICE=venu2 -set DEVICE=vivoactive3 - -rem Application -rem set JUNGLE=monkey.jungle -rem Or Widget -set JUNGLE=monkey-widget.jungle +set DEVICE=venu2 +set JUNGLE=monkey.jungle rem C:\>java -jar %SDK_PATH%\monkeybrains.jar -h rem usage: monkeyc [-a ] [-b ] [--build-stats ] [-c ] [-d ] @@ -104,7 +99,7 @@ rem Compile PRG for a single device for side loading -Dapple.awt.UIElement=true ^ -jar %SDK_PATH%\monkeybrains.jar ^ --output %SRC%\bin\HomeAssistant.prg ^ - --jungles %SRC%\monkey-widget.jungle ^ + --jungles %SRC%\%JUNGLE% ^ --private-key %SRC%\..\developer_key ^ --device %DEVICE%_sim ^ --warn ^ diff --git a/export.cmd b/export.cmd index 4f5315f..8b17b1e 100644 --- a/export.cmd +++ b/export.cmd @@ -98,23 +98,6 @@ echo. --release rem --warn -echo. -echo Starting export of HomeAssistant Widget -echo. - -"%JAVA_PATH%\java.exe" ^ - -Xms1g ^ - -Dfile.encoding=UTF-8 ^ - -Dapple.awt.UIElement=true ^ - -jar %SDK_PATH%\monkeybrains.jar ^ - --api-level 3.1.0 ^ - --output %SRC%\export\HomeAssistant-widget.iq ^ - --jungles %SRC%\monkey-widget.jungle ^ - --private-key %SRC%\..\developer_key ^ - --package-app ^ - --release -rem --warn - echo. echo Finished exporting HomeAssistant dir %SRC%\export\HomeAssistant*.iq diff --git a/include/app/WidgetApp.mc b/include/app/WidgetApp.mc deleted file mode 100644 index 1234385..0000000 --- a/include/app/WidgetApp.mc +++ /dev/null @@ -1,28 +0,0 @@ -//----------------------------------------------------------------------------------- -// -// Distributed under MIT Licence -// See https://github.com/house-of-abbey/GarminHomeAssistant/blob/main/LICENSE. -// -//----------------------------------------------------------------------------------- -// -// GarminHomeAssistant is a Garmin IQ application written in Monkey C and routinely -// tested on a Venu 2 device. The source code is provided at: -// https://github.com/house-of-abbey/GarminHomeAssistant. -// -// P A Abbey & J D Abbey & Someone0nEarth, 20 December 2023 -// -// -// Description: -// -// A tedious diversion intended to make it possible to have the same source code for -// both a widget and an application. This file provides a single constant to -// determine which, and then the source file is conditionally included by the each -// .jungle file. -// -//----------------------------------------------------------------------------------- - -using Toybox.Lang; - -class WidgetApp { - static const isWidget = false; -} diff --git a/include/widget/WidgetApp.mc b/include/widget/WidgetApp.mc deleted file mode 100644 index b86ec4c..0000000 --- a/include/widget/WidgetApp.mc +++ /dev/null @@ -1,28 +0,0 @@ -//----------------------------------------------------------------------------------- -// -// Distributed under MIT Licence -// See https://github.com/house-of-abbey/GarminHomeAssistant/blob/main/LICENSE. -// -//----------------------------------------------------------------------------------- -// -// GarminHomeAssistant is a Garmin IQ application written in Monkey C and routinely -// tested on a Venu 2 device. The source code is provided at: -// https://github.com/house-of-abbey/GarminHomeAssistant. -// -// P A Abbey & J D Abbey & Someone0nEarth, 20 December 2023 -// -// -// Description: -// -// A tedious diversion intended to make it possible to have the same source code for -// both a widget and an application. This file provides a single constant to -// determine which, and then the source file is conditionally included by the each -// .jungle file. -// -//----------------------------------------------------------------------------------- - -using Toybox.Lang; - -class WidgetApp { - static const isWidget = true; -} diff --git a/manifest-widget.xml b/manifest-widget.xml deleted file mode 100644 index cfa41e1..0000000 --- a/manifest-widget.xml +++ /dev/null @@ -1,196 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ara - bul - zhs - zht - hrv - ces - dan - dut - deu - gre - eng - est - fin - fre - heb - hun - ind - ita - jpn - kor - lav - lit - zsm - nob - pol - por - slo - ron - - slv - spa - swe - tha - tur - ukr - vie - - - - - \ No newline at end of file diff --git a/manifest.xml b/manifest.xml index 13d29bc..e5a740f 100644 --- a/manifest.xml +++ b/manifest.xml @@ -28,7 +28,7 @@ Testing in VSCode requires monkey.jungle, so for convenience, swap between watch-app and widget by changing which of the next two lines are commented out --> - + diff --git a/monkey-widget.jungle b/monkey-widget.jungle deleted file mode 100644 index bdf2502..0000000 --- a/monkey-widget.jungle +++ /dev/null @@ -1,205 +0,0 @@ -#----------------------------------------------------------------------------------- -# -# Distributed under MIT Licence -# See https://github.com/house-of-abbey/GarminHomeAssistant/blob/main/LICENSE. -# -#----------------------------------------------------------------------------------- -# -# GarminHomeAssistant is a Garmin IQ application written in Monkey C and routinely -# tested on a Venu 2 device. The source code is provided at: -# https://github.com/house-of-abbey/GarminHomeAssistant. -# -# J D Abbey & P A Abbey, 28 December 2022 -# -# Reference: -# * https://developer.garmin.com/connect-iq/reference-guides/jungle-reference/ -# -#----------------------------------------------------------------------------------- - -project.manifest = manifest-widget.xml - -base.sourcePath = source;include/widget - -# Device References -# * https://developer.garmin.com/connect-iq/compatible-devices/ -# * https://developer.garmin.com/connect-iq/reference-guides/devices-reference/ -# -# Widget launcher icon, multiple resolutions -# https://forums.garmin.com/developer/connect-iq/f/discussion/255433/widget-launcher-icon-multiple-resolutions/1563305 -# -# Use the online SVG converter to write out PNGs from "resources\drawables\launcher.svg" by changing -# the 'width' and 'height' attributes of the SVG. -# https://svgtopng.com/ -# -# The icons need to scale as a ratio of screen size 48:416 pixels -# -# Icon 53 48 46 42 37 32 30 28 26 24 21 18 -# Screen 454 416 390 360 320 280 260 240 218 208 176 156 - -# Screen Size 390x390 launcher icon size 70x70 -approachs7042mm.resourcePath = $(approachs7042mm.resourcePath);resources-launcher-70-70;resources-icons-46 -# Screen Size 454x454 launcher icon size 80x80 -approachs7047mm.resourcePath = $(approachs7047mm.resourcePath);resources-launcher-80-80;resources-icons-53 -# Screen Size 390x390 launcher icon size 60x60 -d2air.resourcePath = $(d2air.resourcePath);resources-launcher-60-60;resources-icons-46 -# Screen Size 416x416 launcher icon size 70x70 -d2airx10.resourcePath = $(d2airx10.resourcePath);resources-launcher-70-70;resources-icons-48 -# Screen Size 240x240 launcher icon size 40x40 -d2delta.resourcePath = $(d2delta.resourcePath);resources-launcher-40-40;resources-icons-28 -d2deltapx.resourcePath = $(d2deltapx.resourcePath);resources-launcher-40-40;resources-icons-28 -d2deltas.resourcePath = $(d2deltas.resourcePath);resources-launcher-40-40;resources-icons-28 -# Screen Size 416x416 launcher icon size 60x60 -d2mach1.resourcePath = $(d2mach1.resourcePath);resources-launcher-60-60;resources-icons-48 -# Screen Size 176x176 launcher icon size 62x62 -descentg1.resourcePath = $(descentg1.resourcePath);resources-launcher-62-62;resources-icons-21 -# Screen Size 280x280 launcher icon size 40x40 -descentmk2.resourcePath = $(descentmk2.resourcePath);resources-launcher-40-40;resources-icons-32 -# Screen Size 240x240 launcher icon size 40x40 -descentmk2s.resourcePath = $(descentmk2s.resourcePath);resources-launcher-40-40;resources-icons-28 -# Screen Size 282x470 launcher icon size 36x36 -edge1030.resourcePath = $(descentmk2s.resourcePath);resources-launcher-36-36;resources-icons-32 -edge1030bontrager.resourcePath = $(edge1030bontrager.resourcePath);resources-launcher-36-36;resources-icons-32 -edge1030plus.resourcePath = $(edge1030plus.resourcePath);resources-launcher-36-36;resources-icons-32 -# Screen Size 282x470 launcher icon size 40x40 -edge1040.resourcePath = $(edge1040.resourcePath);resources-launcher-40-40;resources-icons-32 -# Screen Size 200x265 launcher icon size 35x35 -edge520plus.resourcePath = $(edge520plus.resourcePath);resources-launcher-35-35;resources-icons-24 -# Screen Size 246x322 launcher icon size 35x35 -edge530.resourcePath = $(edge530.resourcePath);resources-launcher-35-35;resources-icons-28 -# Screen Size 200x265 launcher icon size 35x35 -edge820.resourcePath = $(edge820.resourcePath);resources-launcher-35-35;resources-icons-24 -# Screen Size 246x322 launcher icon size 35x35 -edge830.resourcePath = $(edge830.resourcePath);resources-launcher-35-35;resources-icons-28 -# Screen Size 240x400 launcher icon size 36x36 -edgeexplore.resourcePath = $(edgeexplore.resourcePath);resources-launcher-36-36;resources-icons-28 -edgeexplore2.resourcePath = $(edgeexplore2.resourcePath);resources-launcher-36-36;resources-icons-28 -# Screen Size 280x280 launcher icon size 40x40 -enduro.resourcePath = $(enduro.resourcePath);resources-launcher-40-40;resources-icons-32 -# Screen Size 416x416 launcher icon size 60x60 -epix2.resourcePath = $(epix2.resourcePath);resources-launcher-60-60;resources-icons-48 -# Screen Size 390x390 launcher icon size 60x60 -epix2pro42mm.resourcePath = $(epix2pro42mm.resourcePath);resources-launcher-60-60;resources-icons-46 -epix2pro47mm.resourcePath = $(epix2pro47mm.resourcePath);resources-launcher-60-60;resources-icons-46 -# Screen Size 454x454 launcher icon size 60x60 -epix2pro51mm.resourcePath = $(epix2pro51mm.resourcePath);resources-launcher-60-60;resources-icons-53 -# Screen Size 240x240 launcher icon size 40x40 -fenix5.resourcePath = $(fenix5.resourcePath);resources-launcher-40-40;resources-icons-28 -fenix5plus.resourcePath = $(fenix5plus.resourcePath);resources-launcher-40-40;resources-icons-28 -# Screen Size 218x218 launcher icon size 36x36 -fenix5s.resourcePath = $(fenix5s.resourcePath);resources-launcher-36-36;resources-icons-26 -# Screen Size 240x240 launcher icon size 40x40 -fenix5splus.resourcePath = $(fenix5splus.resourcePath);resources-launcher-40-40;resources-icons-28 -fenix5x.resourcePath = $(fenix5x.resourcePath);resources-launcher-40-40;resources-icons-28 -fenix5xplus.resourcePath = $(fenix5xplus.resourcePath);resources-launcher-40-40;resources-icons-28 -# Screen Size 260x260 launcher icon size 40x40 -fenix6.resourcePath = $(fenix6.resourcePath);resources-launcher-40-40;resources-icons-30 -fenix6pro.resourcePath = $(fenix6pro.resourcePath);resources-launcher-40-40;resources-icons-30 -# Screen Size 240x240 launcher icon size 40x40 -fenix6s.resourcePath = $(fenix6s.resourcePath);resources-launcher-40-40;resources-icons-28 -fenix6spro.resourcePath = $(fenix6spro.resourcePath);resources-launcher-40-40;resources-icons-28 -# Screen Size 280x280 launcher icon size 40x40 -fenix6xpro.resourcePath = $(fenix6xpro.resourcePath);resources-launcher-40-40;resources-icons-32 -# Screen Size 260x260 launcher icon size 40x40 -fenix7.resourcePath = $(fenix7.resourcePath);resources-launcher-40-40;resources-icons-30 -# Screen Size 260x260 launcher icon size 40x40 -fenix7pro.resourcePath = $(fenix7pro.resourcePath);resources-launcher-40-40;resources-icons-30 -fenix7pronowifi.resourcePath = $(fenix7pronowifi.resourcePath);resources-launcher-40-40;resources-icons-30 -# Screen Size 218x218 launcher icon size 36x36 -fenixchronos.resourcePath = $(fenixchronos.resourcePath);resources-launcher-36-36;resources-icons-26 -# Screen Size 240x240 launcher icon size 40x40 -fenix7s.resourcePath = $(fenix7s.resourcePath);resources-launcher-40-40;resources-icons-28 -# Screen Size 240x240 launcher icon size 40x40 -fenix7spro.resourcePath = $(fenix7spro.resourcePath);resources-launcher-40-40;resources-icons-28 -# Screen Size 280x280 launcher icon size 40x40 -fenix7x.resourcePath = $(fenix7x.resourcePath);resources-launcher-40-40;resources-icons-32 -# Screen Size 280x280 launcher icon size 40x40 -fenix7xpro.resourcePath = $(fenix7xpro.resourcePath);resources-launcher-40-40;resources-icons-32 -fenix7xpronowifi.resourcePath = $(fenix7xpronowifi.resourcePath);resources-launcher-40-40;resources-icons-32 -# Screen Size 240x240 launcher icon size 40x40 -fr245.resourcePath = $(fr245.resourcePath);resources-launcher-40-40;resources-icons-28 -fr245m.resourcePath = $(fr245m.resourcePath);resources-launcher-40-40;resources-icons-28 -# Screen Size 260x260 launcher icon size 40x40 -fr255.resourcePath = $(fr255.resourcePath);resources-launcher-40-40;resources-icons-30 -fr255m.resourcePath = $(fr255m.resourcePath);resources-launcher-40-40;resources-icons-30 -# Screen Size 218x218 launcher icon size 40x40 -fr255s.resourcePath = $(fr255s.resourcePath);resources-launcher-40-40;resources-icons-26 -fr255sm.resourcePath = $(fr255sm.resourcePath);resources-launcher-40-40;resources-icons-26 -# Screen Size 416x416 launcher icon size 60x60 -fr265.resourcePath = $(fr265.resourcePath);resources-launcher-60-60;resources-icons-48 -fr265s.resourcePath = $(fr265s.resourcePath);resources-launcher-60-60;resources-icons-48 -# Screen Size 208x208 launcher icon size 35x35 -fr55.resourcePath = $(fr55.resourcePath);resources-launcher-35-35;resources-icons-24 -# Screen Size 240x240 launcher icon size 40x40 -fr645.resourcePath = $(fr645.resourcePath);resources-launcher-40-40;resources-icons-28 -fr645m.resourcePath = $(fr645m.resourcePath);resources-launcher-40-40;resources-icons-28 -# Screen Size 240x240 launcher icon size 40x40 -fr745.resourcePath = $(fr745.resourcePath);resources-launcher-40-40;resources-icons-28 -fr935.resourcePath = $(fr935.resourcePath);resources-launcher-40-40;resources-icons-28 -fr945.resourcePath = $(fr945.resourcePath);resources-launcher-40-40;resources-icons-28 -fr945lte.resourcePath = $(fr945lte.resourcePath);resources-launcher-40-40;resources-icons-28 -# Screen Size 260x260 launcher icon size 40x40 -fr955.resourcePath = $(fr955.resourcePath);resources-launcher-40-40;resources-icons-30 -# Screen Size 454x454 launcher icon size 65x65 -fr965.resourcePath = $(fr965.resourcePath);resources-launcher-65-65;resources-icons-53 -# Screen Size 240x400 launcher icon size 38x33 -gpsmap67.resourcePath = $(gpsmap67.resourcePath);resources-launcher-33-33;resources-icons-28 -# Screen Size 176x176 launcher icon size 62x62 -instinct2.resourcePath = $(instinct2.resourcePath);resources-launcher-62-62;resources-icons-21 -# Screen Size 163x156 launcher icon size 54x54 -instinct2s.resourcePath = $(instinct2s.resourcePath);resources-launcher-54-54;resources-icons-18 -# Screen Size 176x176 launcher icon size 62x62 -instinct2x.resourcePath = $(instinct2x.resourcePath);resources-launcher-62-62;resources-icons-21 -# Screen Size 176x176 launcher icon size 26x26 -instinctcrossover.resourcePath = $(instinctcrossover.resourcePath);resources-launcher-26-26;resources-icons-21 -# Screen Size 218x218 launcher icon size 30x30 -legacyherocaptainmarvel.resourcePath = $(legacyherocaptainmarvel.resourcePath);resources-launcher-30-30;resources-icons-26 -# Screen Size 260x260 launcher icon size 35x35 -legacyherofirstavenger.resourcePath = $(legacyherofirstavenger.resourcePath);resources-launcher-35-35;resources-icons-30 -legacysagadarthvader.resourcePath = $(legacysagadarthvader.resourcePath);resources-launcher-35-35;resources-icons-30 -# Screen Size 218x218 launcher icon size 30x30 -legacysagarey.resourcePath = $(legacysagarey.resourcePath);resources-launcher-30-30;resources-icons-26 -# Screen Size 390x390 launcher icon size 60x60 -marq2.resourcePath = $(marq2.resourcePath);resources-launcher-60-60;resources-icons-46 -marq2aviator.resourcePath = $(marq2aviator.resourcePath);resources-launcher-60-60;resources-icons-46 -# Screen Size 240x240 launcher icon size 40x40 -marqadventurer.resourcePath = $(marqadventurer.resourcePath);resources-launcher-40-40;resources-icons-28 -marqathlete.resourcePath = $(marqathlete.resourcePath);resources-launcher-40-40;resources-icons-28 -marqaviator.resourcePath = $(marqaviator.resourcePath);resources-launcher-40-40;resources-icons-28 -marqcaptain.resourcePath = $(marqcaptain.resourcePath);resources-launcher-40-40;resources-icons-28 -marqcommander.resourcePath = $(marqcommander.resourcePath);resources-launcher-40-40;resources-icons-28 -marqdriver.resourcePath = $(marqdriver.resourcePath);resources-launcher-40-40;resources-icons-28 -marqexpedition.resourcePath = $(marqexpedition.resourcePath);resources-launcher-40-40;resources-icons-28 -marqgolfer.resourcePath = $(marqgolfer.resourcePath);resources-launcher-40-40;resources-icons-28 -# Screen Size 480x800 launcher icon size 60x60 -montana7xx.resourcePath = $(montana7xx.resourcePath);resources-launcher-60-60;resources-icons-53 -# Screen Size 390x390 launcher icon size 60x60 -venu.resourcePath = $(venu.resourcePath);resources-launcher-60-60;resources-icons-46 -# Screen Size 416x416 launcher icon size 70x70 -venu2.resourcePath = $(venu2.resourcePath);resources-launcher-70-70;resources-icons-48 -venu2plus.resourcePath = $(venu2plus.resourcePath);resources-launcher-70-70;resources-icons-48 -# Screen Size 360x360 launcher icon size 61x61 -venu2s.resourcePath = $(venu2s.resourcePath);resources-launcher-61-61;resources-icons-42 -# Screen Size 454x454 launcher icon size 70x70 -venu3.resourcePath = $(venu3.resourcePath);resources-launcher-70-70;resources-icons-53 -# Screen Size 390x390 launcher icon size 70x70 -venu3s.resourcePath = $(venu3s.resourcePath);resources-launcher-70-70;resources-icons-46 -# Screen Size 390x390 launcher icon size 60x60 -venud.resourcePath = $(venud.resourcePath);resources-launcher-60-60;resources-icons-46 -# Screen Size 240x240 launcher icon size 36x36 -venusq.resourcePath = $(venusq.resourcePath);resources-launcher-36-36;resources-icons-28 -# Screen Size 320x360 launcher icon size 40x40 -venusq2.resourcePath = $(venusq2.resourcePath);resources-launcher-40-40;resources-icons-38 -# Screen Size 320x360 launcher icon size 40x40 -venusq2m.resourcePath = $(venusq2m.resourcePath);resources-launcher-40-40;resources-icons-38 -# Screen Size 240x240 launcher icon size 36x36 -venusqm.resourcePath = $(venusqm.resourcePath);resources-launcher-36-36;resources-icons-28 -# Screen Size 240x240 launcher icon size 40x33 -vivoactive3.resourcePath = $(vivoactive3.resourcePath);resources-launcher-33-33;resources-icons-28 -vivoactive3m.resourcePath = $(vivoactive3m.resourcePath);resources-launcher-33-33;resources-icons-28 -vivoactive3mlte.resourcePath = $(vivoactive3mlte.resourcePath);resources-launcher-33-33;resources-icons-28 -# Screen Size 260x260 launcher icon size 35x35 -vivoactive4.resourcePath = $(vivoactive4.resourcePath);resources-launcher-35-35;resources-icons-30 -# Screen Size 218x218 launcher icon size 30x30 -vivoactive4s.resourcePath = $(vivoactive4s.resourcePath);resources-launcher-30-30;resources-icons-26 -# Screen Size 390x390 launcher icon size 70x70 -vivoactive5.resourcePath = $(vivoactive5.resourcePath);resources-launcher-70-70;resources-icons-46 diff --git a/monkey.jungle b/monkey.jungle index 6a8ad06..9adc574 100644 --- a/monkey.jungle +++ b/monkey.jungle @@ -18,11 +18,6 @@ project.manifest = manifest.xml -# Testing in VSCode requires monkey.jungle, so for convenience, swap between -# watch-app and widget by changing which of the next two lines are commented out -base.sourcePath = source;include/app -#base.sourcePath = source;include/widget - # Device References # * https://developer.garmin.com/connect-iq/compatible-devices/ # * https://developer.garmin.com/connect-iq/reference-guides/devices-reference/ diff --git a/source/HomeAssistantApp.mc b/source/HomeAssistantApp.mc index 4c22c69..b22d203 100644 --- a/source/HomeAssistantApp.mc +++ b/source/HomeAssistantApp.mc @@ -115,14 +115,10 @@ class HomeAssistantApp extends Application.AppBase { } else { var isCached = fetchMenuConfig(); fetchApiStatus(); - if (WidgetApp.isWidget) { - return [new RootView(self), new RootViewDelegate(self)] as Lang.Array; + if (isCached) { + return [mHaMenu, new HomeAssistantViewDelegate(true)] as Lang.Array; } else { - if (isCached) { - return [mHaMenu, new HomeAssistantViewDelegate(true)] as Lang.Array; - } else { - return [new WatchUi.View(), new WatchUi.BehaviorDelegate()] as Lang.Array; - } + return [new WatchUi.View(), new WatchUi.BehaviorDelegate()] as Lang.Array; } } } @@ -188,9 +184,7 @@ class HomeAssistantApp extends Application.AppBase { ErrorView.show(WatchUi.loadResource($.Rez.Strings.NoJson) as Lang.String); } else { buildMenu(data); - if (!WidgetApp.isWidget) { - WatchUi.switchToView(mHaMenu, new HomeAssistantViewDelegate(false), WatchUi.SLIDE_IMMEDIATE); - } + WatchUi.switchToView(mHaMenu, new HomeAssistantViewDelegate(false), WatchUi.SLIDE_IMMEDIATE); } } break; diff --git a/source/RootView.mc b/source/RootView.mc deleted file mode 100644 index 6edef1c..0000000 --- a/source/RootView.mc +++ /dev/null @@ -1,185 +0,0 @@ -//----------------------------------------------------------------------------------- -// -// Distributed under MIT Licence -// See https://github.com/house-of-abbey/GarminHomeAssistant/blob/main/LICENSE. -// -//----------------------------------------------------------------------------------- -// -// GarminHomeAssistant is a Garmin IQ application written in Monkey C and routinely -// tested on a Venu 2 device. The source code is provided at: -// https://github.com/house-of-abbey/GarminHomeAssistant. -// -// P A Abbey & J D Abbey & Someone0nEarth, 5 December 2023 -// -// -// Description: -// -// Application root view for GarminHomeAssistant -// -//----------------------------------------------------------------------------------- - -using Toybox.Graphics; -using Toybox.Lang; -using Toybox.WatchUi; -using Toybox.System; - -class RootView extends ScalableView { - - // ATTENTION when the app is running as a "widget" (that means, it runs on devices - // without glance view support), the input events in this view are limited, as - // described under "Base View and the Widget Carousel" on: - // - // https://developer.garmin.com/connect-iq/connect-iq-basics/app-types/ - // - // Also the view type of the base view is limited too (for example "WatchUi.Menu2" - // is not possible)). - // - // Also System.exit() is not working/do nothing when running as a widget: A widget will be - // terminated automatically by OS after some time or can be quit manually, when on the base - // view a swipe to left / "back button" press is done. - - private static const scMidSep = 10; // Middle Separator "text:_text" in pixels - private var mApp as HomeAssistantApp; - private var mTitle as WatchUi.Text or Null; - private var mApiText as WatchUi.Text or Null; - private var mApiStatus as WatchUi.Text or Null; - private var mMenuText as WatchUi.Text or Null; - private var mMenuStatus as WatchUi.Text or Null; - private var mMemText as WatchUi.Text or Null; - private var mMemStatus as WatchUi.Text or Null; - private var mAntiAlias as Lang.Boolean = false; - - function initialize(app as HomeAssistantApp) { - ScalableView.initialize(); - mApp = app; - if (Graphics.Dc has :setAntiAlias) { - mAntiAlias = true; - } - } - - function onLayout(dc as Graphics.Dc) as Void { - var w = dc.getWidth(); - - mTitle = new WatchUi.Text({ - :text => WatchUi.loadResource($.Rez.Strings.AppName) as Lang.String, - :color => Graphics.COLOR_WHITE, - :font => Graphics.FONT_TINY, - :justification => Graphics.TEXT_JUSTIFY_CENTER | Graphics.TEXT_JUSTIFY_VCENTER, - :locX => w/2, - :locY => pixelsForScreen(30.0) - }); - - mApiText = new WatchUi.Text({ - :text => "API:", - :color => Graphics.COLOR_WHITE, - :font => Graphics.FONT_XTINY, - :justification => Graphics.TEXT_JUSTIFY_RIGHT | Graphics.TEXT_JUSTIFY_VCENTER, - :locX => w/2 - scMidSep/2, - :locY => pixelsForScreen(50.0) - }); - mApiStatus = new WatchUi.Text({ - :text => WatchUi.loadResource($.Rez.Strings.Checking) as Lang.String, - :color => Graphics.COLOR_WHITE, - :font => Graphics.FONT_XTINY, - :justification => Graphics.TEXT_JUSTIFY_LEFT | Graphics.TEXT_JUSTIFY_VCENTER, - :locX => w/2 + scMidSep/2, - :locY => pixelsForScreen(50.0) - }); - mMenuText = new WatchUi.Text({ - :text => WatchUi.loadResource($.Rez.Strings.GlanceMenu) as Lang.String + ":", - :color => Graphics.COLOR_WHITE, - :font => Graphics.FONT_XTINY, - :justification => Graphics.TEXT_JUSTIFY_RIGHT | Graphics.TEXT_JUSTIFY_VCENTER, - :locX => w/2 - scMidSep/2, - :locY => pixelsForScreen(60.0) - }); - mMenuStatus = new WatchUi.Text({ - :text => WatchUi.loadResource($.Rez.Strings.Checking) as Lang.String, - :color => Graphics.COLOR_WHITE, - :font => Graphics.FONT_XTINY, - :justification => Graphics.TEXT_JUSTIFY_LEFT | Graphics.TEXT_JUSTIFY_VCENTER, - :locX => w/2 + scMidSep/2, - :locY => pixelsForScreen(60.0) - }); - mMemText = new WatchUi.Text({ - :text => WatchUi.loadResource($.Rez.Strings.Memory) as Lang.String + ":", - :color => Graphics.COLOR_WHITE, - :font => Graphics.FONT_XTINY, - :justification => Graphics.TEXT_JUSTIFY_RIGHT | Graphics.TEXT_JUSTIFY_VCENTER, - :locX => w/2 - scMidSep/2, - :locY => pixelsForScreen(70.0) - }); - mMemStatus = new WatchUi.Text({ - :text => WatchUi.loadResource($.Rez.Strings.Checking) as Lang.String, - :color => Graphics.COLOR_WHITE, - :font => Graphics.FONT_XTINY, - :justification => Graphics.TEXT_JUSTIFY_LEFT | Graphics.TEXT_JUSTIFY_VCENTER, - :locX => w/2 + scMidSep/2, - :locY => pixelsForScreen(70.0) - }); - } - - function onUpdate(dc as Graphics.Dc) as Void { - if (mAntiAlias) { - dc.setAntiAlias(true); - } - dc.setColor(Graphics.COLOR_WHITE, Graphics.COLOR_BLACK); - dc.clear(); - // Initialise this locally, otherwise the venu1 device runs out of memory when stored at class level. - var launcherIcon = Application.loadResource(Rez.Drawables.LauncherIcon); - var w = dc.getWidth(); - var h = dc.getHeight(); - dc.drawBitmap(w/2 - launcherIcon.getWidth()/2, h/8 - launcherIcon.getHeight()/2, launcherIcon); - mTitle.draw(dc); - mApiText.draw(dc); - mApiStatus.setText(mApp.getApiStatus()); - mApiStatus.draw(dc); - mMenuText.draw(dc); - mMenuStatus.setText(mApp.getMenuStatus()); - mMenuStatus.draw(dc); - mMemText.draw(dc); - var stats = System.getSystemStats(); - var memUsed = (100f * stats.usedMemory) / stats.totalMemory; - mMemStatus.setText(memUsed.format("%.1f") + "%"); - if (stats.usedMemory > Globals.scLowMem * stats.totalMemory) { - mMemStatus.setColor(Graphics.COLOR_RED); - } else { - mMemStatus.setColor(Graphics.COLOR_WHITE); - } - mMemStatus.draw(dc); - } - - function onShow() as Void { - WatchUi.requestUpdate(); - } -} - -class RootViewDelegate extends WatchUi.BehaviorDelegate { - - var mApp as HomeAssistantApp; - - function initialize(app as HomeAssistantApp) { - BehaviorDelegate.initialize(); - mApp = app; - } - - function onTap(evt as WatchUi.ClickEvent) as Lang.Boolean { - return backToMainMenu(); - } - - function onSelect() as Lang.Boolean { - return backToMainMenu(); - } - - function onMenu() as Lang.Boolean { - return backToMainMenu(); - } - - private function backToMainMenu() as Lang.Boolean { - if (mApp.isHomeAssistantMenuLoaded()) { - mApp.pushHomeAssistantMenuView(); - return true; - } - return false; - } -}