├── .gitignore ├── .project ├── LICENSE.txt ├── Makefile ├── README.md ├── manifest-app.xml ├── monkey-app.jungleinc ├── monkey-base.jungleinc ├── monkey-widget.jungleinc ├── monkey.jungle ├── properties.mk ├── resources-fit └── strings │ └── gpxorfit.xml ├── resources-launcher-33x33 └── drawables │ ├── drawables.xml │ └── launcher_icon.png ├── resources-launcher-35x35 └── drawables │ ├── drawables.xml │ └── launcher_icon.png ├── resources-launcher-36x36 └── drawables │ ├── drawables.xml │ └── launcher_icon.png ├── resources-launcher-38x33 └── drawables │ ├── drawables.xml │ └── launcher_icon.png ├── resources-launcher-40x33 └── drawables │ ├── drawables.xml │ └── launcher_icon.png ├── resources-launcher-40x40 └── drawables │ ├── drawables.xml │ └── launcher_icon.png ├── resources-launcher-54x54 └── drawables │ ├── drawables.xml │ └── launcher_icon.png ├── resources-nofit └── strings │ └── gpxorfit.xml ├── resources-rectangle-148x205 └── layouts │ └── layout.xml ├── resources-rectangle-200x265 └── layouts │ └── layout.xml ├── resources-rectangle-240x400 └── layouts │ └── layout.xml ├── resources-rectangle-246x322 └── layouts │ └── layout.xml ├── resources-rectangle-282x470 └── layouts │ └── layout.xml ├── resources-rectangle-480x800 └── layouts │ └── layout.xml ├── resources-round-218x218 └── layouts │ └── layout.xml ├── resources-round-240x240 └── layouts │ └── layout.xml ├── resources-round-260x260 └── layouts │ └── layout.xml ├── resources-round-280x280 └── layouts │ └── layout.xml ├── resources-round-390x390 └── layouts │ └── layout.xml ├── resources-semiround-215x180 └── layouts │ └── layout.xml ├── resources └── strings │ └── strings.xml └── source ├── TrackChooser.mc └── gimporterApp.mc /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | .\#* 3 | \#*\# 4 | /manifest.xml 5 | /manifest-widget.xml 6 | /bin 7 | .DS_Store 8 | /.settings 9 | /.id_rsa_garmin.der 10 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | gimporter 4 | 5 | 6 | 7 | 8 | 9 | connectiq.builder 10 | 11 | 12 | 13 | 14 | 15 | connectiq.projectNature 16 | 17 | 18 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | include properties.mk 2 | 3 | SUPPORTED_DEVICES_LIST = $(shell sed -n -e 's//\1/p' manifest-app.xml) 4 | SOURCES = $(shell find source -name '[^.]*.mc') 5 | RESFILES = $(shell find resources* -name '[^.]*.xml') 6 | APPNAME = $(shell grep entry manifest-app.xml | sed 's/.*entry="\([^"]*\).*/\1/' | sed 's/App$$//') 7 | SIMULATOR = LD_LIBRARY_PATH="$(SDK_HOME)/bin" "$(SDK_HOME)/bin/connectiq" 8 | MONKEYC = "$(SDK_HOME)/bin/monkeyc" 9 | MONKEYDO = "$(SDK_HOME)/bin/monkeydo" 10 | 11 | .PHONY: build deploy buildall run package clean sim package-widget package-app 12 | 13 | all: build 14 | 15 | clean: 16 | @rm -fr bin 17 | @find . -name '*~' -print0 | xargs -0 rm -f 18 | 19 | build: bin/$(APPNAME)-$(DEVICE).prg bin/$(APPNAME)-widget-$(DEVICE).prg 20 | 21 | bin/$(APPNAME)-$(DEVICE).prg: $(SOURCES) $(RESFILES) manifest-app.xml 22 | $(MONKEYC) --warn --output bin/$(APPNAME)-$(DEVICE).prg \ 23 | -f 'monkey-base.jungleinc;monkey-app.jungleinc' \ 24 | -y $(PRIVATE_KEY) \ 25 | -d $(DEVICE) 26 | 27 | bin/$(APPNAME)-widget-$(DEVICE).prg: $(SOURCES) $(RESFILES) manifest-widget.xml 28 | $(MONKEYC) --warn --output bin/$(APPNAME)-widget-$(DEVICE).prg \ 29 | -f 'monkey-base.jungleinc;monkey-widget.jungleinc' \ 30 | -y $(PRIVATE_KEY) \ 31 | -d $(DEVICE) 32 | 33 | bin/$(APPNAME)-$(DEVICE)-test.prg: $(SOURCES) $(RESFILES) 34 | $(MONKEYC) --warn --output bin/$(APPNAME)-$(DEVICE)-test.prg \ 35 | -f 'monkey-base.jungleinc;monkey-app.jungleinc' \ 36 | -y $(PRIVATE_KEY) \ 37 | --unit-test \ 38 | -d $(DEVICE) 39 | 40 | buildall: 41 | @for device in $(SUPPORTED_DEVICES_LIST); do \ 42 | echo "-----"; \ 43 | echo "Building for" $$device; \ 44 | $(MONKEYC) --warn --output bin/$(APPNAME)-$$device.prg \ 45 | -f 'monkey-base.jungleinc;monkey-app.jungleinc' \ 46 | -y $(PRIVATE_KEY) \ 47 | -d $$device; \ 48 | done 49 | 50 | sim: 51 | @pidof 'simulator*' &>/dev/null || ( $(SIMULATOR) & sleep 3 ) 52 | 53 | run: sim bin/$(APPNAME)-$(DEVICE).prg 54 | $(MONKEYDO) bin/$(APPNAME)-$(DEVICE).prg $(DEVICE) & 55 | 56 | test: sim bin/$(APPNAME)-$(DEVICE)-test.prg 57 | $(MONKEYDO) bin/$(APPNAME)-$(DEVICE)-test.prg $(DEVICE) -t 58 | 59 | $(DEPLOY)/$(APPNAME).prg: bin/$(APPNAME)-$(DEVICE).prg 60 | @cp bin/$(APPNAME)-$(DEVICE).prg $(DEPLOY)/$(APPNAME).prg 61 | @touch $(DEPLOY)/LOGS/76963622.TXT 62 | 63 | $(DEPLOY)/$(APPNAME)-widget.prg: bin/$(APPNAME)-widget-$(DEVICE).prg 64 | @cp bin/$(APPNAME)-widget-$(DEVICE).prg $(DEPLOY)/$(APPNAME)-widget.prg 65 | @touch $(DEPLOY)/LOGS/76A74803.TXT 66 | 67 | deploy: build $(DEPLOY)/$(APPNAME).prg $(DEPLOY)/$(APPNAME)-widget.prg 68 | 69 | manifest-widget.xml: manifest-app.xml 70 | sed -e 's/watch-app/widget/g;s/9B0A09CFC89E4F7CA5E4AB21400EE424/B5FD4C5FE0F848E88A03E37E86971CEB/g' < manifest-app.xml > manifest-widget.xml 71 | 72 | package: package-app package-widget 73 | 74 | package-app: 75 | $(MONKEYC) --warn -e --output bin/$(APPNAME)-app.iq -f 'monkey-base.jungleinc;monkey-app.jungleinc' \ 76 | -y $(PRIVATE_KEY) -r 77 | 78 | package-widget: manifest-widget.xml 79 | $(MONKEYC) --warn -e --output bin/$(APPNAME)-widget.iq -f 'monkey-base.jungleinc;monkey-widget.jungleinc' \ 80 | -y $(PRIVATE_KEY) -r 81 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # gimporter 2 | Garmin Connect App to import GPX and FIT files 3 | 4 | * ConnectIQ App: https://apps.garmin.com/en-US/apps/de11adc4-fdbb-40b5-86ac-7f93b47ea5bb 5 | * Android App: https://play.google.com/store/apps/details?id=org.surfsite.gexporter 6 | 7 | 8 | ## HOWTO 9 | * start the Android app https://github.com/gimportexportdevs/gexporter on your mobile device (where your Garmin Connect app runs) 10 | * build and start this Connect IQ app 11 | * select a course to download 12 | * start the course, or download more 13 | * check that the FIT file was imported (e.g. check the courses folder or start an activitiy with the course) 14 | 15 | ## TODO 16 | * use the companion SDK 17 | * let the user configure the initial URL/server/port 18 | 19 | ## iOS 20 | * There is an experimental iOS app https://github.com/clawoo/gexporter-ios 21 | -------------------------------------------------------------------------------- /manifest-app.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | eng 69 | 70 | 71 | 72 | 73 | -------------------------------------------------------------------------------- /monkey-app.jungleinc: -------------------------------------------------------------------------------- 1 | project.manifest = manifest-app.xml 2 | -------------------------------------------------------------------------------- /monkey-base.jungleinc: -------------------------------------------------------------------------------- 1 | base.sourcePath = source 2 | 3 | gpsmap66.resourcePath = resources-launcher-38x33;resources-nofit;$(gpsmap66.resourcePath) 4 | gpsmap67.resourcePath = resources-launcher-38x33;resources-nofit;$(gpsmap67.resourcePath) 5 | oregon7xx.resourcePath = resources-launcher-54x54;resources-nofit;$(oregon7xx.resourcePath) 6 | rino7xx.resourcePath = resources-launcher-54x54;resources-nofit;$(rino7xx.resourcePath) 7 | montana7xx.resourcePath = resources-launcher-54x54;resources-nofit;$(montana7xx.resourcePath) 8 | 9 | approachs60.resourcePath = resources-launcher-40x33;resources-fit;$(approachs60.resourcePath) 10 | approachs62.resourcePath = resources-launcher-33x33;resources-fit;$(approachs62.resourcePath) 11 | 12 | d2air.resourcePath = resources-launcher-54x54;resources-fit;$(d2air.resourcePath) 13 | d2charlie.resourcePath = resources-launcher-40x40;resources-fit;$(d2charlie.resourcePath) 14 | d2delta.resourcePath = resources-launcher-40x40;resources-fit;$(d2delta.resourcePath) 15 | d2deltapx.resourcePath = resources-launcher-40x40;resources-fit;$(d2deltapx.resourcePath) 16 | d2deltas.resourcePath = resources-launcher-40x40;resources-fit;$(d2deltas.resourcePath) 17 | descentmk1.resourcePath = resources-launcher-40x40;resources-fit;$(descentmk1.resourcePath) 18 | descentmk2.resourcePath = resources-launcher-40x40;resources-fit;$(descentmk2.resourcePath) 19 | 20 | edge1040.resourcePath = resources-launcher-40x40;resources-fit;$(edge1040.resourcePath) 21 | edge840.resourcePath = resources-launcher-35x35;resources-fit;$(edge840.resourcePath) 22 | edge540.resourcePath = resources-launcher-35x35;resources-fit;$(edge540.resourcePath) 23 | edge1030.resourcePath = resources-launcher-36x36;resources-fit;$(edge1030.resourcePath) 24 | edge1030plus.resourcePath = resources-launcher-36x36;resources-fit;$(edge1030plus.resourcePath) 25 | edge1030bontrager.resourcePath = resources-launcher-36x36;resources-fit;$(edge1030bontrager.resourcePath) 26 | edge520plus.resourcePath = resources-launcher-35x35;resources-fit;$(edge520plus.resourcePath) 27 | edge530.resourcePath = resources-launcher-35x35;resources-fit;$(edge530.resourcePath) 28 | edge830.resourcePath = resources-launcher-35x35;resources-fit;$(edge830.resourcePath) 29 | edge820.resourcePath = resources-launcher-35x35;resources-fit;$(edge820.resourcePath) 30 | edge_1000.resourcePath = resources-launcher-36x36;resources-fit;$(edge_1000.resourcePath) 31 | edge_520.resourcePath = resources-launcher-35x35;resources-fit;$(edge_520.resourcePath) 32 | edgeexplore.resourcePath = resources-launcher-36x36;resources-fit;$(edgeexplore.resourcePath) 33 | 34 | fenix5.resourcePath = resources-launcher-40x40;resources-fit;$(fenix5.resourcePath) 35 | fenix5plus.resourcePath = resources-launcher-40x40;resources-fit;$(fenix5plus.resourcePath) 36 | fenix5s.resourcePath = resources-launcher-36x36;resources-fit;$(fenix5s.resourcePath) 37 | fenix5splus.resourcePath = resources-launcher-40x40;resources-fit;$(fenix5splus.resourcePath) 38 | fenix5x.resourcePath = resources-launcher-40x40;resources-fit;$(fenix5x.resourcePath) 39 | fenix5xplus.resourcePath = resources-launcher-40x40;resources-fit;$(fenix5xplus.resourcePath) 40 | fenixchronos.resourcePath = resources-launcher-36x36;resources-fit;$(fenixchronos.resourcePath) 41 | fr645.resourcePath = resources-launcher-40x40;resources-fit;$(fr645.resourcePath) 42 | fr645m.resourcePath = resources-launcher-40x40;resources-fit;$(fr645m.resourcePath) 43 | fr735xt.resourcePath = resources-launcher-40x40;resources-fit;$(fr735xt.resourcePath) 44 | fr935.resourcePath = resources-launcher-40x40;resources-fit;$(fr935.resourcePath) 45 | fr945.resourcePath = resources-launcher-40x40;resources-fit;$(fr945.resourcePath) 46 | fr945lte.resourcePath = resources-launcher-40x40;resources-fit;$(fr945lte.resourcePath) 47 | fr245.resourcePath = resources-launcher-40x40;resources-fit;$(fr245.resourcePath) 48 | fr245m.resourcePath = resources-launcher-40x40;resources-fit;$(fr245m.resourcePath) 49 | fenix6.resourcePath = resources-launcher-40x40;resources-fit;$(fenix6.resourcePath) 50 | fenix6pro.resourcePath = resources-launcher-40x40;resources-fit;$(fenix6pro.resourcePath) 51 | fenix6s.resourcePath = resources-launcher-40x40;resources-fit;$(fenix6s.resourcePath) 52 | fenix6spro.resourcePath = resources-launcher-40x40;resources-fit;$(fenix6spro.resourcePath) 53 | fenix6xpro.resourcePath = resources-launcher-40x40;resources-fit;$(fenix6xpro.resourcePath) 54 | fenix7.resourcePath = resources-launcher-40x40;resources-fit;$(fenix7.resourcePath) 55 | fenix7s.resourcePath = resources-launcher-40x40;resources-fit;$(fenix7s.resourcePath) 56 | fenix7x.resourcePath = resources-launcher-40x40;resources-fit;$(fenix7x.resourcePath) 57 | 58 | marqathlete.resourcePath = resources-launcher-40x40;resources-fit;$(marqathlete.resourcePath) 59 | marqdriver.resourcePath = resources-launcher-40x40;resources-fit;$(marqdriver.resourcePath) 60 | marqexpedition.resourcePath = resources-launcher-40x40;resources-fit;$(marqexpedition.resourcePath) 61 | marqadventurer.resourcePath = resources-launcher-40x40;resources-fit;$(marqadventurer.resourcePath) 62 | marqaviator.resourcePath = resources-launcher-40x40;resources-fit;$(marqaviator.resourcePath) 63 | marqcaptain.resourcePath = resources-launcher-40x40;resources-fit;$(marqcaptain.resourcePath) 64 | marqgolfer.resourcePath = resources-launcher-40x40;resources-fit;$(marqgolfer.resourcePath) 65 | 66 | enduro.resourcePath = resources-launcher-40x40;resources-fit;$(enduro.resourcePath) 67 | -------------------------------------------------------------------------------- /monkey-widget.jungleinc: -------------------------------------------------------------------------------- 1 | project.manifest = manifest-widget.xml 2 | -------------------------------------------------------------------------------- /monkey.jungle: -------------------------------------------------------------------------------- 1 | project.manifest = manifest-app.xml 2 | 3 | base.sourcePath = source 4 | 5 | gpsmap66.resourcePath = resources-launcher-38x33;resources-nofit;$(gpsmap66.resourcePath) 6 | gpsmap67.resourcePath = resources-launcher-38x33;resources-nofit;$(gpsmap67.resourcePath) 7 | oregon7xx.resourcePath = resources-launcher-54x54;resources-nofit;$(oregon7xx.resourcePath) 8 | rino7xx.resourcePath = resources-launcher-54x54;resources-nofit;$(rino7xx.resourcePath) 9 | montana7xx.resourcePath = resources-launcher-54x54;resources-nofit;$(montana7xx.resourcePath) 10 | 11 | approachs60.resourcePath = resources-launcher-40x33;resources-fit;$(approachs60.resourcePath) 12 | approachs62.resourcePath = resources-launcher-33x33;resources-fit;$(approachs62.resourcePath) 13 | 14 | d2air.resourcePath = resources-launcher-54x54;resources-fit;$(d2air.resourcePath) 15 | d2charlie.resourcePath = resources-launcher-40x40;resources-fit;$(d2charlie.resourcePath) 16 | d2delta.resourcePath = resources-launcher-40x40;resources-fit;$(d2delta.resourcePath) 17 | d2deltapx.resourcePath = resources-launcher-40x40;resources-fit;$(d2deltapx.resourcePath) 18 | d2deltas.resourcePath = resources-launcher-40x40;resources-fit;$(d2deltas.resourcePath) 19 | descentmk1.resourcePath = resources-launcher-40x40;resources-fit;$(descentmk1.resourcePath) 20 | descentmk2.resourcePath = resources-launcher-40x40;resources-fit;$(descentmk2.resourcePath) 21 | 22 | edge1040.resourcePath = resources-launcher-40x40;resources-fit;$(edge1040.resourcePath) 23 | edge840.resourcePath = resources-launcher-35x35;resources-fit;$(edge840.resourcePath) 24 | edge540.resourcePath = resources-launcher-35x35;resources-fit;$(edge540.resourcePath) 25 | edge1030.resourcePath = resources-launcher-36x36;resources-fit;$(edge1030.resourcePath) 26 | edge1030plus.resourcePath = resources-launcher-36x36;resources-fit;$(edge1030plus.resourcePath) 27 | edge1030bontrager.resourcePath = resources-launcher-36x36;resources-fit;$(edge1030bontrager.resourcePath) 28 | edge520plus.resourcePath = resources-launcher-35x35;resources-fit;$(edge520plus.resourcePath) 29 | edge530.resourcePath = resources-launcher-35x35;resources-fit;$(edge530.resourcePath) 30 | edge830.resourcePath = resources-launcher-35x35;resources-fit;$(edge830.resourcePath) 31 | edge820.resourcePath = resources-launcher-35x35;resources-fit;$(edge820.resourcePath) 32 | edge_1000.resourcePath = resources-launcher-36x36;resources-fit;$(edge_1000.resourcePath) 33 | edge_520.resourcePath = resources-launcher-35x35;resources-fit;$(edge_520.resourcePath) 34 | edgeexplore.resourcePath = resources-launcher-36x36;resources-fit;$(edgeexplore.resourcePath) 35 | 36 | fenix5.resourcePath = resources-launcher-40x40;resources-fit;$(fenix5.resourcePath) 37 | fenix5plus.resourcePath = resources-launcher-40x40;resources-fit;$(fenix5plus.resourcePath) 38 | fenix5s.resourcePath = resources-launcher-36x36;resources-fit;$(fenix5s.resourcePath) 39 | fenix5splus.resourcePath = resources-launcher-40x40;resources-fit;$(fenix5splus.resourcePath) 40 | fenix5x.resourcePath = resources-launcher-40x40;resources-fit;$(fenix5x.resourcePath) 41 | fenix5xplus.resourcePath = resources-launcher-40x40;resources-fit;$(fenix5xplus.resourcePath) 42 | fenixchronos.resourcePath = resources-launcher-36x36;resources-fit;$(fenixchronos.resourcePath) 43 | fr645.resourcePath = resources-launcher-40x40;resources-fit;$(fr645.resourcePath) 44 | fr645m.resourcePath = resources-launcher-40x40;resources-fit;$(fr645m.resourcePath) 45 | fr735xt.resourcePath = resources-launcher-40x40;resources-fit;$(fr735xt.resourcePath) 46 | fr935.resourcePath = resources-launcher-40x40;resources-fit;$(fr935.resourcePath) 47 | fr945.resourcePath = resources-launcher-40x40;resources-fit;$(fr945.resourcePath) 48 | fr245.resourcePath = resources-launcher-40x40;resources-fit;$(fr245.resourcePath) 49 | fr245m.resourcePath = resources-launcher-40x40;resources-fit;$(fr245m.resourcePath) 50 | fenix6.resourcePath = resources-launcher-40x40;resources-fit;$(fenix6.resourcePath) 51 | fenix6pro.resourcePath = resources-launcher-40x40;resources-fit;$(fenix6pro.resourcePath) 52 | fenix6s.resourcePath = resources-launcher-40x40;resources-fit;$(fenix6s.resourcePath) 53 | fenix6spro.resourcePath = resources-launcher-40x40;resources-fit;$(fenix6spro.resourcePath) 54 | fenix6xpro.resourcePath = resources-launcher-40x40;resources-fit;$(fenix6xpro.resourcePath) 55 | 56 | marqathlete.resourcePath = resources-launcher-40x40;resources-fit;$(marqathlete.resourcePath) 57 | marqdriver.resourcePath = resources-launcher-40x40;resources-fit;$(marqdriver.resourcePath) 58 | marqexpedition.resourcePath = resources-launcher-40x40;resources-fit;$(marqexpedition.resourcePath) 59 | marqadventurer.resourcePath = resources-launcher-40x40;resources-fit;$(marqadventurer.resourcePath) 60 | marqaviator.resourcePath = resources-launcher-40x40;resources-fit;$(marqaviator.resourcePath) 61 | marqcaptain.resourcePath = resources-launcher-40x40;resources-fit;$(marqcaptain.resourcePath) 62 | marqgolfer.resourcePath = resources-launcher-40x40;resources-fit;$(marqgolfer.resourcePath) 63 | 64 | enduro.resourcePath = resources-launcher-40x40;resources-fit;$(enduro.resourcePath) 65 | -------------------------------------------------------------------------------- /properties.mk: -------------------------------------------------------------------------------- 1 | DEVICE ?= fr945 2 | SDK_HOME = $(shell cat $(HOME)/Library/Application\ Support/Garmin/ConnectIQ/current-sdk.cfg) 3 | DEPLOY = $(HOME) 4 | PRIVATE_KEY = $(HOME)/.id_rsa_garmin.der 5 | -------------------------------------------------------------------------------- /resources-fit/strings/gpxorfit.xml: -------------------------------------------------------------------------------- 1 | 2 | FIT 3 | 4 | -------------------------------------------------------------------------------- /resources-launcher-33x33/drawables/drawables.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /resources-launcher-33x33/drawables/launcher_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gimportexportdevs/gimporter/530b6db76d1d587c7226bdb8392c85b9e8195820/resources-launcher-33x33/drawables/launcher_icon.png -------------------------------------------------------------------------------- /resources-launcher-35x35/drawables/drawables.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /resources-launcher-35x35/drawables/launcher_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gimportexportdevs/gimporter/530b6db76d1d587c7226bdb8392c85b9e8195820/resources-launcher-35x35/drawables/launcher_icon.png -------------------------------------------------------------------------------- /resources-launcher-36x36/drawables/drawables.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /resources-launcher-36x36/drawables/launcher_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gimportexportdevs/gimporter/530b6db76d1d587c7226bdb8392c85b9e8195820/resources-launcher-36x36/drawables/launcher_icon.png -------------------------------------------------------------------------------- /resources-launcher-38x33/drawables/drawables.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /resources-launcher-38x33/drawables/launcher_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gimportexportdevs/gimporter/530b6db76d1d587c7226bdb8392c85b9e8195820/resources-launcher-38x33/drawables/launcher_icon.png -------------------------------------------------------------------------------- /resources-launcher-40x33/drawables/drawables.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /resources-launcher-40x33/drawables/launcher_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gimportexportdevs/gimporter/530b6db76d1d587c7226bdb8392c85b9e8195820/resources-launcher-40x33/drawables/launcher_icon.png -------------------------------------------------------------------------------- /resources-launcher-40x40/drawables/drawables.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /resources-launcher-40x40/drawables/launcher_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gimportexportdevs/gimporter/530b6db76d1d587c7226bdb8392c85b9e8195820/resources-launcher-40x40/drawables/launcher_icon.png -------------------------------------------------------------------------------- /resources-launcher-54x54/drawables/drawables.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /resources-launcher-54x54/drawables/launcher_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gimportexportdevs/gimporter/530b6db76d1d587c7226bdb8392c85b9e8195820/resources-launcher-54x54/drawables/launcher_icon.png -------------------------------------------------------------------------------- /resources-nofit/strings/gpxorfit.xml: -------------------------------------------------------------------------------- 1 | 2 | GPX 3 | -------------------------------------------------------------------------------- /resources-rectangle-148x205/layouts/layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | -------------------------------------------------------------------------------- /resources-rectangle-200x265/layouts/layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | -------------------------------------------------------------------------------- /resources-rectangle-240x400/layouts/layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | -------------------------------------------------------------------------------- /resources-rectangle-246x322/layouts/layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | -------------------------------------------------------------------------------- /resources-rectangle-282x470/layouts/layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | -------------------------------------------------------------------------------- /resources-rectangle-480x800/layouts/layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | -------------------------------------------------------------------------------- /resources-round-218x218/layouts/layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | -------------------------------------------------------------------------------- /resources-round-240x240/layouts/layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | -------------------------------------------------------------------------------- /resources-round-260x260/layouts/layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | -------------------------------------------------------------------------------- /resources-round-280x280/layouts/layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | -------------------------------------------------------------------------------- /resources-round-390x390/layouts/layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | -------------------------------------------------------------------------------- /resources-semiround-215x180/layouts/layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | -------------------------------------------------------------------------------- /resources/strings/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | gimporter 3 | V6.3.3 4 | Press Start/Menu 5 | Getting track list 6 | Bluetooth disconnected 7 | Waiting for Bluetooth 8 | Please switch off Wifi 9 | Connection failed 10 | Select Track 11 | Download failed 12 | Device unsupported 13 | Download complete 14 | Already Downloaded 15 | Downloading 16 | No Tracks found 17 | [...] 18 | Start to launch Track 19 | 20 | -------------------------------------------------------------------------------- /source/TrackChooser.mc: -------------------------------------------------------------------------------- 1 | import Toybox.Lang; 2 | 3 | using Toybox.Graphics as Gfx; 4 | using Toybox.WatchUi as Ui; 5 | using Toybox.Application as App; 6 | 7 | class TrackChooser extends Ui.Menu { 8 | 9 | function initialize(page as Number) { 10 | var app = $.getApp(); 11 | Menu.initialize(); 12 | Menu.setTitle(Rez.Strings.trackChooserTitle); 13 | var tracks = app.getTracks() as [ Dictionary ]; 14 | var num = tracks.size(); 15 | var off = page*15; 16 | if ((num - off) <= 16) { 17 | // simple case, all fit in 18 | for(var i = page*15; i < num; i++) { 19 | Menu.addItem( 20 | tracks[i]["title"], 21 | toSym(i - off) ); 22 | } 23 | return; 24 | } 25 | 26 | for(var i = off, iMax = 15 + off; i < iMax; i++) { 27 | Menu.addItem( 28 | tracks[i]["title"], 29 | toSym(i - off) ); 30 | } 31 | Menu.addItem(Rez.Strings.MORE, :MORE); 32 | } 33 | 34 | function toSym(i as Number) as Symbol { 35 | if (i == 0) { 36 | return :ITEM_0; 37 | } else if (i == 1) { 38 | return :ITEM_1; 39 | } else if (i == 2) { 40 | return :ITEM_2; 41 | } else if (i == 3) { 42 | return :ITEM_3; 43 | } else if (i == 4) { 44 | return :ITEM_4; 45 | } else if (i == 5) { 46 | return :ITEM_5; 47 | } else if (i == 6) { 48 | return :ITEM_6; 49 | } else if (i == 7) { 50 | return :ITEM_7; 51 | } else if (i == 8) { 52 | return :ITEM_8; 53 | } else if (i == 9) { 54 | return :ITEM_9; 55 | } else if (i == 10) { 56 | return :ITEM_10; 57 | } else if (i == 11) { 58 | return :ITEM_11; 59 | } else if (i == 12) { 60 | return :ITEM_12; 61 | } else if (i == 13) { 62 | return :ITEM_13; 63 | } else if (i == 14) { 64 | return :ITEM_14; 65 | } else if (i == 15) { 66 | return :ITEM_15; 67 | } 68 | return :ITEM_0; 69 | } 70 | } 71 | 72 | class TrackChooserDelegate extends Ui.MenuInputDelegate { 73 | var app as gimporterApp; 74 | var page as Number; 75 | 76 | function initialize(p as Number) { 77 | page = p; 78 | 79 | MenuInputDelegate.initialize(); 80 | app = $.getApp(); 81 | } 82 | 83 | function toInt(sym as Symbol) as Number { 84 | if (sym.equals(:ITEM_0)) { 85 | return 0; 86 | } else if (sym.equals(:ITEM_1)) { 87 | return 1; 88 | } else if (sym.equals(:ITEM_2)) { 89 | return 2; 90 | } else if (sym.equals(:ITEM_3)) { 91 | return 3; 92 | } else if (sym.equals(:ITEM_4)) { 93 | return 4; 94 | } else if (sym.equals(:ITEM_5)) { 95 | return 5; 96 | } else if (sym.equals(:ITEM_6)) { 97 | return 6; 98 | } else if (sym.equals(:ITEM_7)) { 99 | return 7; 100 | } else if (sym.equals(:ITEM_8)) { 101 | return 8; 102 | } else if (sym.equals(:ITEM_9)) { 103 | return 9; 104 | } else if (sym.equals(:ITEM_10)) { 105 | return 10; 106 | } else if (sym.equals(:ITEM_11)) { 107 | return 11; 108 | } else if (sym.equals(:ITEM_12)) { 109 | return 12; 110 | } else if (sym.equals(:ITEM_13)) { 111 | return 13; 112 | } else if (sym.equals(:ITEM_14)) { 113 | return 14; 114 | } else if (sym.equals(:ITEM_15)) { 115 | return 15; 116 | } 117 | return 0; 118 | } 119 | 120 | function onMenuItem(item as Symbol) as Void { 121 | if (item.equals(:MORE)) { 122 | Ui.pushView(new TrackChooser(page + 1), new TrackChooserDelegate(page + 1), Ui.SLIDE_IMMEDIATE); 123 | } else { 124 | app.loadTrackNum(toInt(item) + page*15); 125 | } 126 | } 127 | } 128 | -------------------------------------------------------------------------------- /source/gimporterApp.mc: -------------------------------------------------------------------------------- 1 | import Toybox.Lang; 2 | 3 | using Toybox.Application as App; 4 | using Toybox.WatchUi as Ui; 5 | using Toybox.Communications as Comm; 6 | using Toybox.PersistedContent as PC; 7 | using Toybox.Timer as TIME; 8 | using Toybox.System as System; 9 | using Toybox.Graphics as GFX; 10 | 11 | function getApp() as gimporterApp { 12 | return App.getApp() as gimporterApp; 13 | } 14 | 15 | class gimporterApp extends App.AppBase { 16 | var tracks as Array? = null; 17 | var trackToStart as String?; 18 | var canLoadList as Boolean; 19 | var status as String or ResourceId = ""; 20 | var mGPXorFIT as String; 21 | var bluetoothTimer as TIME.Timer; 22 | var exitTimer as TIME.Timer; 23 | var mIntent as System.Intent? = null; 24 | 25 | function initialize() { 26 | AppBase.initialize(); 27 | 28 | mGPXorFIT = Ui.loadResource(Rez.Strings.GPXorFIT); 29 | System.println("GPXorFit = " + mGPXorFIT); 30 | 31 | canLoadList = true; 32 | bluetoothTimer = new TIME.Timer(); 33 | exitTimer = new TIME.Timer(); 34 | } 35 | 36 | // onStart() is called on application start up 37 | function onStart(state as Lang.Dictionary?) as Void { 38 | //loadTrackList(); 39 | status = Rez.Strings.PressStart; 40 | } 41 | 42 | // onStop() is called when your application is exiting 43 | function onStop(state as Lang.Dictionary?) as Void { 44 | } 45 | 46 | // Return the initial view of your application here 47 | function getInitialView() as [ Ui.Views ] or [ Ui.Views, Ui.InputDelegates ] { 48 | return [ new gimporterView(), new gimporterDelegate() ]; 49 | } 50 | 51 | function getStatus() as String { 52 | return status; 53 | } 54 | 55 | function getTracks() as Array { 56 | return tracks; 57 | } 58 | 59 | function loadTrackList() as Void { 60 | tracks = null; 61 | trackToStart = null; 62 | mIntent = null; 63 | 64 | var settings = System.getDeviceSettings(); 65 | 66 | if (! settings.phoneConnected) { 67 | bluetoothTimer.stop(); 68 | status = Rez.Strings.WaitingForBluetooth; 69 | bluetoothTimer.start(method(:loadTrackList), 1000, false); 70 | Ui.requestUpdate(); 71 | return; 72 | } 73 | 74 | if ((settings has :connectionInfo) && (settings.connectionInfo has :wifi) && (settings.connectionInfo[:wifi].state == System.CONNECTION_STATE_CONNECTED)) { 75 | bluetoothTimer.stop(); 76 | status = Rez.Strings.SwitchOffWifi; 77 | bluetoothTimer.start(method(:loadTrackList), 1000, false); 78 | Ui.requestUpdate(); 79 | return; 80 | } 81 | 82 | // if ((settings has :connectionInfo) || !(settings.connectionInfo has :bluetooth) || (settings.connectionInfo[:bluetooth].state != CONNECTION_STATE_CONNECTED)) { 83 | // bluetoothTimer.stop(); 84 | // status = Rez.Strings.WaitingForBluetooth; 85 | // bluetoothTimer.start(method(:loadTrackList), 1000, false); 86 | // Ui.requestUpdate(); 87 | // return; 88 | // } 89 | 90 | status = Rez.Strings.GettingTracklist; 91 | canLoadList = false; 92 | try { 93 | Comm.makeWebRequest( 94 | "http://127.0.0.1:22222/dir.json", 95 | { 96 | "type" => mGPXorFIT, 97 | "short" => "1", 98 | "longname" => "1" }, 99 | { 100 | :method => Comm.HTTP_REQUEST_METHOD_GET, 101 | :headers => { 102 | "Content-Type" => Comm.REQUEST_CONTENT_TYPE_JSON }, 103 | :responseType => Comm.HTTP_RESPONSE_CONTENT_TYPE_JSON }, 104 | method(:onReceiveTracks) ); 105 | } catch( ex ) { 106 | canLoadList = true; 107 | status = ex.getErrorMessage(); 108 | } 109 | 110 | Ui.requestUpdate(); 111 | 112 | } 113 | 114 | function onReceiveTracks(responseCode as Number, data as Dictionary) as Void { 115 | status = ""; 116 | canLoadList = true; 117 | 118 | if (responseCode == Comm.BLE_CONNECTION_UNAVAILABLE) { 119 | System.println("Bluetooth disconnected"); 120 | status = Rez.Strings.BluetoothDisconnected; 121 | Ui.requestUpdate(); 122 | return; 123 | } 124 | 125 | if (responseCode != 200) { 126 | System.println("data == null\nCode " + responseCode.toString() + "\n"); 127 | status = Rez.Strings.ConnectionFailed; 128 | Ui.requestUpdate(); 129 | return; 130 | } 131 | 132 | if (!(data instanceof Toybox.Lang.Dictionary)) { 133 | System.println("data is not Dict"); 134 | status = Rez.Strings.ConnectionFailed; 135 | Ui.requestUpdate(); 136 | return; 137 | } 138 | 139 | if (! data.hasKey("tracks")) { 140 | System.println("data has no track key"); 141 | status = Rez.Strings.ConnectionFailed; 142 | Ui.requestUpdate(); 143 | return; 144 | } 145 | 146 | tracks = data["tracks"]; 147 | 148 | if (tracks == null) { 149 | System.println("tracks == null"); 150 | status = Rez.Strings.NoTracks; 151 | Ui.requestUpdate(); 152 | return; 153 | } 154 | 155 | if (!(tracks instanceof Toybox.Lang.Array)) { 156 | System.println("tracks != Array"); 157 | status = Rez.Strings.NoTracks; 158 | tracks = null; 159 | Ui.requestUpdate(); 160 | return; 161 | } 162 | 163 | Ui.pushView(new TrackChooser(0), new TrackChooserDelegate(0), Ui.SLIDE_IMMEDIATE); 164 | 165 | } 166 | 167 | function loadTrackNum(index as Number) as Void { 168 | System.println("loadTrack: " + tracks[index].toString()); 169 | 170 | // TODO: check hasKey 171 | var trackurl = (tracks[index] as Dictionary)["url"]; 172 | trackToStart = (tracks[index] as Dictionary)["title"]; 173 | 174 | if ((trackurl.length() < 7) || (!trackurl.substring(0, 7).equals("http://"))) { 175 | trackurl = "http://127.0.0.1:22222/" + trackurl; 176 | } 177 | 178 | status = Rez.Strings.Downloading; 179 | canLoadList = false; 180 | System.println("GPXorFIT: " + mGPXorFIT); 181 | 182 | Ui.pushView( 183 | new gimporterView(), 184 | new gimporterDelegate(), 185 | Ui.SLIDE_IMMEDIATE ); 186 | Ui.requestUpdate(); 187 | 188 | try { 189 | if (mGPXorFIT.equals("FIT")) { 190 | System.println("Downloading FIT"); 191 | Comm.makeWebRequest( 192 | trackurl, 193 | { 194 | "type" => "FIT", 195 | "longname" => "1" }, 196 | { 197 | :method => Comm.HTTP_REQUEST_METHOD_GET, 198 | :responseType => Comm.HTTP_RESPONSE_CONTENT_TYPE_FIT }, 199 | method(:onReceiveTrack) ); 200 | } else { 201 | System.println("Downloading GPX"); 202 | Comm.makeWebRequest( 203 | trackurl, 204 | { 205 | "type" => "GPX", 206 | "longname" => "1" }, 207 | { 208 | :method => Comm.HTTP_REQUEST_METHOD_GET, 209 | :responseType => Comm.HTTP_RESPONSE_CONTENT_TYPE_GPX }, 210 | method(:onReceiveTrack) ); 211 | } 212 | } catch( ex ) { 213 | status = Rez.Strings.DownloadNotSupported; 214 | } 215 | 216 | Ui.requestUpdate(); 217 | } 218 | 219 | function doExitInto() as Void { 220 | if (mIntent != null) { 221 | System.exitTo(mIntent); 222 | mIntent = null; 223 | } 224 | } 225 | 226 | function exitInto(intent as System.Intent) as Void { 227 | if (intent != null) { 228 | mIntent = intent; 229 | exitTimer.start(method(:doExitInto), 200, false); 230 | } 231 | } 232 | 233 | function onReceiveTrack(responseCode as Number, downloads as PC.Iterator) as Void { 234 | System.println("onReceiveTrack"); 235 | 236 | if (responseCode == Comm.BLE_CONNECTION_UNAVAILABLE) { 237 | System.println("Bluetooth disconnected"); 238 | status = Rez.Strings.BluetoothDisconnected; 239 | Ui.requestUpdate(); 240 | return; 241 | } 242 | else if (responseCode != 200) { 243 | System.println("Code: " + responseCode); 244 | status = Rez.Strings.DownloadFailed; 245 | Ui.requestUpdate(); 246 | return; 247 | } 248 | else if (downloads == null) { 249 | System.println("downloads == null"); 250 | status = Rez.Strings.DownloadFailed; 251 | Ui.requestUpdate(); 252 | return; 253 | } 254 | else { 255 | var download = downloads.next(); 256 | System.println("onReceiveTrack: " + (download == null ? null : download.getName() + "/" + download.getId())); 257 | 258 | // FIXME: Garmin 259 | // Without switchToView() the widget is gone 260 | Ui.switchToView(new gimporterView(), new gimporterDelegate(), Ui.SLIDE_IMMEDIATE); 261 | 262 | status = Rez.Strings.DownloadComplete; 263 | 264 | if (download != null) { 265 | Ui.requestUpdate(); 266 | exitInto(download.toIntent()); 267 | return; 268 | } 269 | 270 | status = Rez.Strings.AlreadyDownloaded; 271 | 272 | // if (trackToStart.length() > 4) { 273 | // var postfix = trackToStart.substring(trackToStart.length()-4, trackToStart.length()).toLower(); 274 | // if (postfix.equals(".fit") || postfix.equals(".gpx")) { 275 | // trackToStart = trackToStart.substring(0, trackToStart.length()-4); 276 | // } 277 | // } 278 | // if (trackToStart.length() > 15) { 279 | // trackToStart = trackToStart.substring(0, 15); 280 | // } 281 | 282 | var ret = false; 283 | 284 | if (PC has :getAppCourses) { 285 | System.println("Searching in App courses"); 286 | ret = searchCourse(PC.getAppCourses()); 287 | } 288 | if (PC has :getCourses) { 289 | System.println("Searching in courses"); 290 | ret = searchCourse(PC.getCourses()); 291 | } 292 | 293 | if ((ret == false) && (PC has :getAppTracks)) { 294 | System.println("Searching in App tracks"); 295 | ret = searchCourse(PC.getTracks()); 296 | } 297 | if ((ret == false) && (PC has :getTracks)) { 298 | System.println("Searching in tracks"); 299 | ret = searchCourse(PC.getTracks()); 300 | } 301 | 302 | if ((ret == false ) && (PC has :getAppRoutes)) { 303 | System.println("Searching in App routes"); 304 | ret = searchCourse(PC.getAppRoutes()); 305 | } 306 | if ((ret == false ) && (PC has :getRoutes)) { 307 | System.println("Searching in routes"); 308 | ret = searchCourse(PC.getRoutes()); 309 | } 310 | 311 | Ui.requestUpdate(); 312 | return; 313 | } 314 | } 315 | 316 | function searchCourse(cit as PC.Iterator) as Boolean { 317 | var course; 318 | var startcourse = null; 319 | // var startcoursename = null; //not-used 320 | var sclen = 0; 321 | var tlen = trackToStart.length(); 322 | 323 | // Search for the longest coursename matching ours 324 | while (cit != null) { 325 | course = cit.next(); 326 | if (course == null) { 327 | break; 328 | } 329 | var coursename = course.getName(); 330 | var clen = coursename.length(); 331 | 332 | if ((clen > 11) && coursename.substring(clen-11, clen).equals("_course.fit")) { 333 | coursename = coursename.substring(0, clen-11); 334 | clen = clen - 11; 335 | } 336 | 337 | // Shortened course names end with 60b2 on Fenix 5 338 | 339 | System.println("Checking if " + trackToStart + " == " + coursename); 340 | 341 | if ((clen > tlen) || (sclen > clen) || (!trackToStart.substring(0, clen).equals(coursename))) { 342 | continue; 343 | } 344 | startcourse = course; 345 | // startcoursename = coursename; 346 | sclen = clen; 347 | } 348 | 349 | if (startcourse != null) { 350 | System.println("Found course: " + startcourse.getName() + " asking for start"); 351 | Ui.popView(Ui.SLIDE_IMMEDIATE); 352 | canLoadList = true; 353 | status = Rez.Strings.PressStart; 354 | // FIXME: Garmin 355 | // I can't do System.exitTo(course.toIntent()) 356 | // It causes the Fenix5 to be in a strange state 357 | exitInto(startcourse.toIntent()); // workaround 358 | return true; 359 | } else { 360 | System.println("No course found"); 361 | } 362 | return false; 363 | } 364 | } 365 | 366 | 367 | 368 | class gimporterView extends Ui.View { 369 | var st as Ui.Text?; 370 | var ps as String or ResourceId = ""; 371 | var app as gimporterApp; 372 | 373 | function initialize() { 374 | View.initialize(); 375 | app = $.getApp(); 376 | } 377 | 378 | function onLayout(dc as GFX.Dc) as Void { 379 | setLayout(Rez.Layouts.MainLayout(dc)); 380 | st = findDrawableById("status"); 381 | ps = Ui.loadResource(Rez.Strings.PressStart); 382 | } 383 | 384 | function onUpdate(dc as GFX.Dc) as Void { 385 | var status = app.getStatus(); 386 | if (status.equals("")) { 387 | st.setText(ps); 388 | } else { 389 | st.setText(status); 390 | } 391 | 392 | View.onUpdate(dc); 393 | } 394 | } 395 | 396 | class gimporterDelegate extends Ui.BehaviorDelegate { 397 | var app as gimporterApp; 398 | 399 | function initialize() { 400 | BehaviorDelegate.initialize(); 401 | app = App.getApp(); 402 | } 403 | 404 | function onBack() as Boolean { 405 | app.canLoadList = true; 406 | app.status = Rez.Strings.PressStart; 407 | Ui.requestUpdate(); 408 | return false; 409 | } 410 | 411 | function onMenu() as Boolean { 412 | if (app.canLoadList) { 413 | app.loadTrackList(); 414 | } 415 | return true; 416 | } 417 | 418 | function onSelect() as Boolean { 419 | if (app.canLoadList) { 420 | app.loadTrackList(); 421 | } 422 | return true; 423 | } 424 | } 425 | --------------------------------------------------------------------------------