Skip to content

Commit

Permalink
feat(devices): more support, including vivosmart 3
Browse files Browse the repository at this point in the history
Specifically, this trims some memory, adds
better touch-screen support, and updates the
manifest.
  • Loading branch information
blaskovicz committed Dec 21, 2018
1 parent c3fc1e8 commit e1c3f16
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 18 deletions.
17 changes: 12 additions & 5 deletions manifest.xml
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
<!-- 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="0">
<iq:application entry="GNCCApp" id="c8ee13b0b670420aa998d16cae60a928" launcherIcon="@Drawables.LauncherIcon" minSdkVersion="1.4.0" name="@Strings.AppName" type="widget">
<iq:products>
<iq:product id="fr230"/>
<iq:product id="fenix3"/>
<iq:product id="fenix5x"/>
<iq:product id="fr630"/>
<iq:product id="fenix3_hr"/>
<iq:product id="fenix5"/>
<iq:product id="fenix5plus"/>
<iq:product id="fenix5s"/>
<iq:product id="fenix5splus"/>
<iq:product id="fenix5x"/>
<iq:product id="fenix5xplus"/>
<iq:product id="fenixchronos"/>
<iq:product id="fr230"/>
<iq:product id="fr235"/>
<iq:product id="fr920xt"/>
<iq:product id="fr630"/>
<iq:product id="fr645"/>
<iq:product id="fr645m"/>
<iq:product id="fr735xt"/>
<iq:product id="fenix3_hr"/>
<iq:product id="fr920xt"/>
<iq:product id="fr935"/>
<iq:product id="vivoactive3"/>
<iq:product id="vivoactive3m"/>
</iq:products>
<iq:permissions>
<iq:uses-permission id="Communications"/>
Expand Down
9 changes: 7 additions & 2 deletions source/CameraListView.mc
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,17 @@ class CameraListDelegate extends Ui.BehaviorDelegate {
BehaviorDelegate.initialize();
}

function onSelect() {
var camera = NestApi.getInstance().getCameraList()[self.page];
NestApi.getInstance().requestToggleStreaming(camera);
return true;
}

function onKey(ev) {
var key = ev.getKey();
Logger.getInstance().infoF("ref=camera-list-delegate at=on-key key=$1$", [key]);
if (key == Ui.KEY_START || key == Ui.KEY_ENTER) {
var camera = NestApi.getInstance().getCameraList()[self.page];
NestApi.getInstance().requestToggleStreaming(camera);
return onSelect();
} else if (key == Ui.KEY_DOWN) {
return onNextPage();
} else if (key == Ui.KEY_UP) {
Expand Down
5 changes: 4 additions & 1 deletion source/NestApi.mc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ var _api;
// TODO: buffer, splay and retry request to handle BLE QUEUE FULL error (code -101)
// TODO also a way of queueing or handlying multiple request/response pairs
static class NestApi {
static const unusedCameraFields = ["app_url", "web_url", "last_event", "where_id", "where_name", "structure_id", "software_version", "name_long", "last_is_online_change", "is_video_history_enabled", "is_audio_input_enabled"];
// static const unusedCameraFields = ["app_url", "web_url", "last_event", "where_id", "where_name", "structure_id", "software_version", "name_long", "last_is_online_change", "is_video_history_enabled", "is_audio_input_enabled"];
static const unusedCameraFields = ["fwId", "hwId", "appServerUrl", "deviceHwVer", "deviceMac", "oemId", "isSameRegion", "role", "fwVer", "deviceName", "deviceType"];

enum {
StateRequestError = 0,
Expand Down Expand Up @@ -194,6 +195,8 @@ static class NestApi {
self.setPollerStateRequestError(Lang.format("Error $1$", [responseCode]));
}
} else if (self.setPollerStateRequestSuccess()) {
Properties.clearCameraList();

var cameraList = data;
// clean out some of the data we don't use since the memory usage may be too beefy
for (var i = 0; i < cameraList.size(); i++) {
Expand Down
8 changes: 8 additions & 0 deletions source/Properties.mc
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ static class Properties {
Logger.getInstance().info("ref=properties at=get-camera-list");
return cameraList;
}
static function clearCameraList() {
if (getApp().getProperty("camera_list") == null) {
return;
}

Logger.getInstance().info("ref=properties at=clear-camera-list");
getApp().setProperty("camera_list", null);
}
static function setCameraList(cameraList) {
if (!(cameraList instanceof Lang.Array)) {
throw new InvalidArgumentError("expected camera_list to be Toybox.Lang.Array");
Expand Down
29 changes: 19 additions & 10 deletions source/SummaryView.mc
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,34 @@ class SummaryDelegate extends Ui.BehaviorDelegate {
self.summaryUi = summaryUi;
BehaviorDelegate.initialize();
}

function onBack() {
Ui.popView(Ui.SLIDE_IMMEDIATE);
return true;
}

function onKey(ev) {
var key = ev.getKey();
if (Ui.KEY_START != key && Ui.KEY_ENTER != key) {
return false;
}

Logger.getInstance().info("ref=summary-delegate at=on-ok");
function onSelect() {
if (!NestApi.getInstance().isConnected()) {
NestApi.getInstance().requestOauthConnect();
return true;
} else if (NestApi.getInstance().hasCameras()) {
var view = new CameraListView();
Ui.pushView(view, new CameraListDelegate(view), Ui.SLIDE_LEFT);
return true;
} else {
NestApi.getInstance().requestCameraStatus();
}
return false;
return true;
}

function onKey(ev) {
var key = ev.getKey();
Logger.getInstance().infoF("ref=summary-delegate at=on-key key=$1$", [key]);

if (Ui.KEY_START == key || Ui.KEY_ENTER == key) {
return onSelect();
} else if (key == Ui.KEY_ESC || key == Ui.KEY_LAP) {
return onBack();
}
return false;
}
}

Expand Down

0 comments on commit e1c3f16

Please sign in to comment.