Finishing off widget+app code changes.

Glance now updates the status.
Fix for quitting the application when persistently displaying an ErrorView.
Added option for Widget RootView to immediately start HomeAssistant without waiting for a tap as requested by a user.
This commit is contained in:
Philip Abbey
2023-12-23 14:30:58 +00:00
parent 3de2e25b5d
commit 76c2aaa249
42 changed files with 272 additions and 107 deletions

View File

@ -29,37 +29,37 @@ using Toybox.Timer;
class Alert extends WatchUi.View {
private static const bRadius = 10;
private var mTimer;
private var mTimeout;
private var mText;
private var mFont;
private var mFgcolor;
private var mBgcolor;
private var mTimer as Timer.Timer;
private var mTimeout as Lang.Number;
private var mText as Lang.String;
private var mFont as Graphics.FontType;
private var mFgcolor as Graphics.ColorType;
private var mBgcolor as Graphics.ColorType;
function initialize(params as Lang.Dictionary) {
View.initialize();
mText = params.get(:text);
mText = params.get(:text) as Lang.String;
if (mText == null) {
mText = "Alert";
}
mFont = params.get(:font);
mFont = params.get(:font) as Graphics.FontType;
if (mFont == null) {
mFont = Graphics.FONT_MEDIUM;
}
mFgcolor = params.get(:fgcolor);
mFgcolor = params.get(:fgcolor) as Graphics.ColorType;
if (mFgcolor == null) {
mFgcolor = Graphics.COLOR_BLACK;
}
mBgcolor = params.get(:bgcolor);
mBgcolor = params.get(:bgcolor) as Graphics.ColorType;
if (mBgcolor == null) {
mBgcolor = Graphics.COLOR_WHITE;
}
mTimeout = params.get(:timeout);
mTimeout = params.get(:timeout) as Lang.Number;
if (mTimeout == null) {
mTimeout = 2000;
}
@ -83,7 +83,7 @@ class Alert extends WatchUi.View {
var bX = (dc.getWidth() - bWidth) / 2;
var bY = (dc.getHeight() - bHeight) / 2;
if(dc has :setAntiAlias) {
if (dc has :setAntiAlias) {
dc.setAntiAlias(true);
}
@ -112,30 +112,30 @@ class Alert extends WatchUi.View {
// Remove the alert from view, usually on user input, but that is defined by the calling function.
//
function dismiss() {
function dismiss() as Void {
WatchUi.popView(SLIDE_IMMEDIATE);
}
function pushView(transition) {
function pushView(transition) as Void {
WatchUi.pushView(self, new AlertDelegate(self), transition);
}
}
class AlertDelegate extends WatchUi.InputDelegate {
hidden var mView;
private var mView;
function initialize(view) {
InputDelegate.initialize();
mView = view;
}
function onKey(evt) {
function onKey(evt) as Lang.Boolean {
mView.dismiss();
getApp().getQuitTimer().reset();
return true;
}
function onTap(evt) {
function onTap(evt) as Lang.Boolean {
mView.dismiss();
getApp().getQuitTimer().reset();
return true;