This commit is contained in:
Wade Wegner 2016-03-04 16:37:17 -08:00
Коммит 65216d8557
10 изменённых файлов: 154 добавлений и 0 удалений

4
.gitignore поставляемый Normal file
Просмотреть файл

@ -0,0 +1,4 @@
*.prg
*.prg.*
*.iq
.DS_Store

11
build.sh Executable file
Просмотреть файл

@ -0,0 +1,11 @@
monkeyc -a /Users/wade.wegner/SDKs/connectiq-sdk-mac-1.2.5/bin/api.db -i /Users/wade.wegner/SDKs/connectiq-sdk-mac-1.2.5/bin/api.debug.xml -o ./WidgetJsonRequest.prg -m manifest.xml -z resources/drawables.xml:resources/strings.xml src/WidgetJsonRequest.mc src/WidgetJsonRequestView.mc -d round_watch_sim -w -g
echo -n "Press any key to start emulator... "
read var_name
connectiq
echo -n "Press any key to run app... "
read var_name
monkeydo WidgetJsonRequest.prg

Двоичные данные
images/icon.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 210 B

17
manifest.xml Normal file
Просмотреть файл

@ -0,0 +1,17 @@
<!-- This is a generated file. It is highly recommended that you DO NOT edit this file. -->
<iq:manifest xmlns:iq="http://www.garmin.com/xml/connectiq" version="1">
<iq:application entry="WidgetJsonRequestApp" id="BFFF3D7CF5B045BA88482232D3BE8C99" launcherIcon="@Drawables.LauncherIcon" name="@Strings.AppName" type="widget">
<iq:products>
<iq:product id="fr235"/>
</iq:products>
<iq:permissions>
<iq:uses-permission id="Communications"/>
</iq:permissions>
<iq:languages>
</iq:languages>
</iq:application>
</iq:manifest>

0
package.sh Executable file
Просмотреть файл

3
resources/drawables.xml Normal file
Просмотреть файл

@ -0,0 +1,3 @@
<drawables>
<bitmap id="LauncherIcon" filename="../images/icon.png" />
</drawables>

3
resources/strings.xml Normal file
Просмотреть файл

@ -0,0 +1,3 @@
<strings>
<string id="AppName">WidgetJsonRequest</string>
</strings>

1
sideload.sh Executable file
Просмотреть файл

@ -0,0 +1 @@
cp WidgetJsonRequest.prg /Volumes/GARMIN/GARMIN/APPS/

32
src/WidgetJsonRequest.mc Normal file
Просмотреть файл

@ -0,0 +1,32 @@
//!
//! Copyright 2015 by Garmin Ltd. or its subsidiaries.
//! Subject to Garmin SDK License Agreement and Wearables
//! Application Developer Agreement.
//!
using Toybox.Application as App;
class WidgetJsonRequestApp extends App.AppBase {
hidden var mDelegate;
hidden var mView;
function initialize() {
App.AppBase.initialize();
}
//! onStart() is called on application start up
function onStart() {
mView = new WidgetJsonRequestView();
mDelegate = new BaseInputDelegate();
}
//! onStop() is called when your application is exiting
function onStop() {
}
//! Return the initial view of your application here
function getInitialView() {
return [ mView, mDelegate ];
}
}

Просмотреть файл

@ -0,0 +1,83 @@
//!
//! Copyright 2015 by Garmin Ltd. or its subsidiaries.
//! Subject to Garmin SDK License Agreement and Wearables
//! Application Developer Agreement.
//!
using Toybox.Communications as Comm;
using Toybox.WatchUi as Ui;
using Toybox.Graphics as Gfx;
using Toybox.Lang as Lang;
using Toybox.System as Sys;
class BaseInputDelegate extends Ui.BehaviorDelegate {
function onMenu() {
Ui.requestUpdate();
return true;
}
function initialize(handler) {
Ui.BehaviorDelegate.initialize();
}
function onNextPage() {
}
}
class WidgetJsonRequestView extends Ui.View {
hidden var mMessage = "";
function initialize() {
Ui.View.initialize();
}
//! Load your resources here
function onLayout(dc) {
Comm.makeJsonRequest(
"https://httpbin.org/get",
{
"Monkeys" => "Awesome",
"ConnectIQ" => "1337"
},
{
"Content-Type" => Comm.REQUEST_CONTENT_TYPE_URL_ENCODED
},
method(:onReceive)
);
onUpdate( dc );
}
function onReceive(responseCode, data) {
if( responseCode == 200 ) {
var args = data["args"];
var keys = args.keys();
mMessage = "";
for( var i = 0; i < keys.size(); i++ ) {
mMessage += Lang.format("$1$: $2$\n", [keys[i], args[keys[i]]]);
}
}
else {
mMessage = "Failed to load\nError: " + responseCode.toString();
}
Ui.requestUpdate();
}
//! Restore the state of the app and prepare the view to be shown
function onShow() {
}
//! Update the view
function onUpdate(dc) {
dc.setColor( Gfx.COLOR_TRANSPARENT, Gfx.COLOR_BLACK );
dc.clear();
dc.setColor( Gfx.COLOR_WHITE, Gfx.COLOR_TRANSPARENT );
dc.drawText(25, (dc.getHeight() / 2) + 10, Gfx.FONT_SMALL, mMessage, Gfx.TEXT_JUSTIFY_LEFT);
}
}