mirror of
https://github.com/house-of-abbey/GarminHomeAssistant.git
synced 2025-04-30 20:52:27 +00:00
Add application property "confirm_timeout"
After this time (in seconds), a confirmation dialog for an action is automatically closed and the action is cancelled. Set to 0 to disable the timeout. The default value is 3 seconds.
This commit is contained in:
@ -30,6 +30,12 @@
|
||||
-->
|
||||
<property id="app_timeout" type="number">0</property>
|
||||
|
||||
<!--
|
||||
After this time (in seconds), a confirmation dialog for an action is automatically closed and the action is cancelled.
|
||||
Set to 0 to disable the timeout. The default value is 3 seconds.
|
||||
-->
|
||||
<property id="confirm_timeout" type="number">3</property>
|
||||
|
||||
<property id="types_representation" type="boolean"></property>
|
||||
|
||||
<property id="menu_alignment" type="boolean"></property>
|
||||
|
@ -53,6 +53,16 @@
|
||||
/>
|
||||
</setting>
|
||||
|
||||
<setting
|
||||
propertyKey="@Properties.confirm_timeout"
|
||||
title="After this time (in seconds), a confirmation dialog for an action is automatically closed and the action is cancelled. Set to 0 to disable the timeout."
|
||||
>
|
||||
<settingConfig
|
||||
type="numeric"
|
||||
min="0"
|
||||
/>
|
||||
</setting>
|
||||
|
||||
<setting
|
||||
propertyKey="@Properties.types_representation"
|
||||
title="Representing types with icons (off) or with labels (on)"
|
||||
|
@ -23,6 +23,7 @@ using Toybox.Lang;
|
||||
typedef Method as Toybox.Lang.Method;
|
||||
using Toybox.WatchUi;
|
||||
using Toybox.Timer;
|
||||
using Toybox.Application.Properties;
|
||||
|
||||
class HomeAssistantConfirmation extends WatchUi.Confirmation {
|
||||
function initialize() {
|
||||
@ -38,13 +39,18 @@ class HomeAssistantConfirmationDelegate extends WatchUi.ConfirmationDelegate {
|
||||
function initialize(callback as Method() as Void) {
|
||||
WatchUi.ConfirmationDelegate.initialize();
|
||||
confirmMethod = callback;
|
||||
var timeoutSeconds = Properties.getValue("confirm_timeout") as Lang.Number;
|
||||
if (timeoutSeconds > 0) {
|
||||
timeout = new Timer.Timer();
|
||||
timeout.start(method(:onTimeout), 3000, true);
|
||||
timeout.start(method(:onTimeout), timeoutSeconds * 1000, true);
|
||||
}
|
||||
}
|
||||
|
||||
function onResponse(response) as Lang.Boolean {
|
||||
getApp().getQuitTimer().reset();
|
||||
if (timeout) {
|
||||
timeout.stop();
|
||||
}
|
||||
if (response == WatchUi.CONFIRM_YES) {
|
||||
confirmMethod.invoke();
|
||||
}
|
||||
|
Reference in New Issue
Block a user