mirror of
https://github.com/house-of-abbey/GarminHomeAssistant.git
synced 2025-06-17 11:58:30 +00:00
remove transcoding, move pin to settings, remove pin from schema
This commit is contained in:
@ -217,9 +217,6 @@
|
|||||||
"type": "object",
|
"type": "object",
|
||||||
"title": "Your services's parameters",
|
"title": "Your services's parameters",
|
||||||
"description": "The object containing the parameters and their values to be passed to the entity. No schema checking can be done here, you are on your own! On application crash, remove the parameters."
|
"description": "The object containing the parameters and their values to be passed to the entity. No schema checking can be done here, you are on your own! On application crash, remove the parameters."
|
||||||
},
|
|
||||||
"pin": {
|
|
||||||
"$ref": "#/$defs/pin"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": ["service"]
|
"required": ["service"]
|
||||||
@ -233,12 +230,6 @@
|
|||||||
"default": false,
|
"default": false,
|
||||||
"title": "Confirmation",
|
"title": "Confirmation",
|
||||||
"description": "Optional confirmation of the action before execution as a precaution."
|
"description": "Optional confirmation of the action before execution as a precaution."
|
||||||
},
|
|
||||||
"pin": {
|
|
||||||
"title": "Confirmation PIN",
|
|
||||||
"type": "string",
|
|
||||||
"pattern": "^[1-4]+$",
|
|
||||||
"description": "Optional confirmation PIN to be entered before execution as a simple security measure."
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@
|
|||||||
des Geräts zu schonen.</string>
|
des Geräts zu schonen.</string>
|
||||||
<string id="SettingsConfirmTimeout">Nach dieser Zeit (in Sekunden) wird der Bestätigungsdialog einer Aktion geschlossen und die
|
<string id="SettingsConfirmTimeout">Nach dieser Zeit (in Sekunden) wird der Bestätigungsdialog einer Aktion geschlossen und die
|
||||||
Aktion abgebrochen. Auf 0 setzen, um den Timeout zu deaktivieren.</string>
|
Aktion abgebrochen. Auf 0 setzen, um den Timeout zu deaktivieren.</string>
|
||||||
<string id="SettingsPinMask">Schablone um die PIN aus der Dashboard Config zu transkodieren.</string>
|
<string id="SettingsPin">PIN für alle Actions mit 'confirm': true.</string>
|
||||||
<string id="SettingsWidgetStart">(Nur Widget) Anwendung automatisch über das Widget starten ohne drauftippen zu müssen.</string>
|
<string id="SettingsWidgetStart">(Nur Widget) Anwendung automatisch über das Widget starten ohne drauftippen zu müssen.</string>
|
||||||
<string id="SettingsEnableBatteryLevel">Hintergrunddienst aktivieren, um den Ladezustand der Batterie an HomeAssistant zu senden.</string>
|
<string id="SettingsEnableBatteryLevel">Hintergrunddienst aktivieren, um den Ladezustand der Batterie an HomeAssistant zu senden.</string>
|
||||||
<string id="SettingsBatteryLevelRefreshRate">Die Aktualisierungsrate (in Minuten) mit der der Ladezustand der Batterie
|
<string id="SettingsBatteryLevelRefreshRate">Die Aktualisierungsrate (in Minuten) mit der der Ladezustand der Batterie
|
||||||
|
@ -60,7 +60,6 @@
|
|||||||
<string id="SettingsPollDelay">Zusätzliche Abfrageverzögerung (in Sekunden). Fügt eine Verzögerung zwischen der Statusaktualisierung aller Menüelemente hinzu.</string>
|
<string id="SettingsPollDelay">Zusätzliche Abfrageverzögerung (in Sekunden). Fügt eine Verzögerung zwischen der Statusaktualisierung aller Menüelemente hinzu.</string>
|
||||||
<string id="SettingsConfirmTimeout">Nach dieser Zeit (in Sekunden) wird der Bestätigungsdialog einer Aktion geschlossen und die
|
<string id="SettingsConfirmTimeout">Nach dieser Zeit (in Sekunden) wird der Bestätigungsdialog einer Aktion geschlossen und die
|
||||||
Aktion abgebrochen. Auf 0 setzen, um den Timeout zu deaktivieren.</string>
|
Aktion abgebrochen. Auf 0 setzen, um den Timeout zu deaktivieren.</string>
|
||||||
<string id="SettingsPinMask">Schablone um die PIN aus der Dashboard Config zu transkodieren.</string>
|
|
||||||
<string id="SettingsTextAlign">Menüausrichtung links (aus) oder rechts (ein).</string>
|
<string id="SettingsTextAlign">Menüausrichtung links (aus) oder rechts (ein).</string>
|
||||||
<string id="LeftToRight">Links nach rechts</string>
|
<string id="LeftToRight">Links nach rechts</string>
|
||||||
<string id="RightToLeft">Rechts nach links</string>
|
<string id="RightToLeft">Rechts nach links</string>
|
||||||
|
@ -66,12 +66,10 @@
|
|||||||
<property id="confirm_timeout" type="number">3</property>
|
<property id="confirm_timeout" type="number">3</property>
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
This mask transcodes the plain text PIN from the public dashboard config.
|
PIN to be used for confirmation. If a PIN is set, every action with 'confirm': true
|
||||||
Every digit is used to increase the corresponding digit at this position
|
will show the PIN confirmation dialog.
|
||||||
in the PIN by the value given, starting at 1 if a value bigger than 4 has
|
|
||||||
been reached.
|
|
||||||
-->
|
-->
|
||||||
<property id="pin_mask" type="string"></property>
|
<property id="pin" type="string"></property>
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
Left to right or right to left text. Language dependent.
|
Left to right or right to left text. Language dependent.
|
||||||
|
@ -80,8 +80,8 @@
|
|||||||
</setting>
|
</setting>
|
||||||
|
|
||||||
<setting
|
<setting
|
||||||
propertyKey="@Properties.pin_mask"
|
propertyKey="@Properties.pin"
|
||||||
title="@Strings.SettingsPinMask"
|
title="@Strings.SettingsPin"
|
||||||
>
|
>
|
||||||
<settingConfig type="alphaNumeric" />
|
<settingConfig type="alphaNumeric" />
|
||||||
</setting>
|
</setting>
|
||||||
|
@ -53,7 +53,7 @@
|
|||||||
<string id="SettingsAppTimeout">Timeout in seconds. Exit the application after this period of inactivity to save the device battery.</string>
|
<string id="SettingsAppTimeout">Timeout in seconds. Exit the application after this period of inactivity to save the device battery.</string>
|
||||||
<string id="SettingsPollDelay">Additional poll delay (in seconds). Adds a delay between the status update of all menu items.</string>
|
<string id="SettingsPollDelay">Additional poll delay (in seconds). Adds a delay between the status update of all menu items.</string>
|
||||||
<string id="SettingsConfirmTimeout">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.</string>
|
<string id="SettingsConfirmTimeout">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.</string>
|
||||||
<string id="SettingsPinMask">Integer Mask to transcode the plain text PIN from the public dashboard config.</string>
|
<string id="SettingsPin">PIN to be used for all actions that require confirmation.</string>
|
||||||
<string id="SettingsTextAlign">Left (off) or Right (on) Menu Alignment.</string>
|
<string id="SettingsTextAlign">Left (off) or Right (on) Menu Alignment.</string>
|
||||||
<string id="LeftToRight">Left to right</string>
|
<string id="LeftToRight">Left to right</string>
|
||||||
<string id="RightToLeft">Right to Left</string>
|
<string id="RightToLeft">Right to Left</string>
|
||||||
|
@ -85,8 +85,7 @@ class HomeAssistantMenuItemFactory {
|
|||||||
template as Lang.String or Null,
|
template as Lang.String or Null,
|
||||||
service as Lang.String or Null,
|
service as Lang.String or Null,
|
||||||
confirm as Lang.Boolean,
|
confirm as Lang.Boolean,
|
||||||
data as Lang.Dictionary or Null,
|
data as Lang.Dictionary or Null
|
||||||
pin as Lang.String or Null
|
|
||||||
) as WatchUi.MenuItem {
|
) as WatchUi.MenuItem {
|
||||||
if (entity != null) {
|
if (entity != null) {
|
||||||
if (data == null) {
|
if (data == null) {
|
||||||
@ -101,7 +100,6 @@ class HomeAssistantMenuItemFactory {
|
|||||||
template,
|
template,
|
||||||
service,
|
service,
|
||||||
confirm,
|
confirm,
|
||||||
pin,
|
|
||||||
data,
|
data,
|
||||||
mTapTypeIcon,
|
mTapTypeIcon,
|
||||||
mMenuItemOptions,
|
mMenuItemOptions,
|
||||||
@ -113,7 +111,6 @@ class HomeAssistantMenuItemFactory {
|
|||||||
template,
|
template,
|
||||||
service,
|
service,
|
||||||
confirm,
|
confirm,
|
||||||
pin,
|
|
||||||
data,
|
data,
|
||||||
mInfoTypeIcon,
|
mInfoTypeIcon,
|
||||||
mMenuItemOptions,
|
mMenuItemOptions,
|
||||||
|
@ -127,7 +127,7 @@ class HomeAssistantPinConfirmationDelegate extends WatchUi.BehaviorDelegate {
|
|||||||
if (Attention has :vibrate && Settings.getVibrate()) {
|
if (Attention has :vibrate && Settings.getVibrate()) {
|
||||||
Attention.vibrate([new Attention.VibeProfile(25, 25)]);
|
Attention.vibrate([new Attention.VibeProfile(25, 25)]);
|
||||||
}
|
}
|
||||||
var currentDigit = getTranscodedCurrentDigit();
|
var currentDigit = mPin[mCurrentIndex].toString().toNumber(); // this is ugly, but apparently the only way for char<->number conversions
|
||||||
if (currentDigit != null && currentDigit == instance.getDigit()) {
|
if (currentDigit != null && currentDigit == instance.getDigit()) {
|
||||||
// System.println("Pin digit " + (mCurrentIndex+1) + " matches");
|
// System.println("Pin digit " + (mCurrentIndex+1) + " matches");
|
||||||
if (mCurrentIndex == mPin.size()-1) {
|
if (mCurrentIndex == mPin.size()-1) {
|
||||||
@ -150,19 +150,6 @@ class HomeAssistantPinConfirmationDelegate extends WatchUi.BehaviorDelegate {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTranscodedCurrentDigit() as Number or Null {
|
|
||||||
var currentDigit = mPin[mCurrentIndex].toString().toNumber(); // this is ugly, but apparently the only way for char<->number conversions
|
|
||||||
if (currentDigit == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
var pinMask = Settings.getPinMask();
|
|
||||||
var maskDigit = pinMask.substring(mCurrentIndex, mCurrentIndex+1).toNumber();
|
|
||||||
if (maskDigit == null) {
|
|
||||||
return currentDigit;
|
|
||||||
}
|
|
||||||
return ((currentDigit + maskDigit - 1) % 4) + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
function resetTimer() {
|
function resetTimer() {
|
||||||
var timeout = Settings.getConfirmTimeout(); // ms
|
var timeout = Settings.getConfirmTimeout(); // ms
|
||||||
if (timeout > 0) {
|
if (timeout > 0) {
|
||||||
|
@ -28,14 +28,12 @@ class HomeAssistantTapMenuItem extends WatchUi.IconMenuItem {
|
|||||||
private var mService as Lang.String or Null;
|
private var mService as Lang.String or Null;
|
||||||
private var mConfirm as Lang.Boolean;
|
private var mConfirm as Lang.Boolean;
|
||||||
private var mData as Lang.Dictionary or Null;
|
private var mData as Lang.Dictionary or Null;
|
||||||
private var mPin as Lang.String or Null;
|
|
||||||
|
|
||||||
function initialize(
|
function initialize(
|
||||||
label as Lang.String or Lang.Symbol,
|
label as Lang.String or Lang.Symbol,
|
||||||
template as Lang.String,
|
template as Lang.String,
|
||||||
service as Lang.String or Null,
|
service as Lang.String or Null,
|
||||||
confirm as Lang.Boolean,
|
confirm as Lang.Boolean,
|
||||||
pin as Lang.String or Null,
|
|
||||||
data as Lang.Dictionary or Null,
|
data as Lang.Dictionary or Null,
|
||||||
icon as Graphics.BitmapType or WatchUi.Drawable,
|
icon as Graphics.BitmapType or WatchUi.Drawable,
|
||||||
options as {
|
options as {
|
||||||
@ -56,7 +54,6 @@ class HomeAssistantTapMenuItem extends WatchUi.IconMenuItem {
|
|||||||
mService = service;
|
mService = service;
|
||||||
mConfirm = confirm;
|
mConfirm = confirm;
|
||||||
mData = data;
|
mData = data;
|
||||||
mPin = pin;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function hasTemplate() as Lang.Boolean {
|
function hasTemplate() as Lang.Boolean {
|
||||||
@ -87,19 +84,23 @@ class HomeAssistantTapMenuItem extends WatchUi.IconMenuItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function callService() as Void {
|
function callService() as Void {
|
||||||
|
if (mConfirm) {
|
||||||
var hasTouchScreen = System.getDeviceSettings().isTouchScreen;
|
var hasTouchScreen = System.getDeviceSettings().isTouchScreen;
|
||||||
if (mPin != null && hasTouchScreen) {
|
var pin = Settings.getPin();
|
||||||
WatchUi.pushView(
|
System.println("HomeAsistantTemplateMenuItem callService() pin = '" + pin + "'");
|
||||||
new HomeAssistantPinConfirmationView(),
|
if (!hasTouchScreen || "".equals(pin)) {
|
||||||
new HomeAssistantPinConfirmationDelegate(method(:onConfirm), false, mPin),
|
|
||||||
WatchUi.SLIDE_IMMEDIATE
|
|
||||||
);
|
|
||||||
} else if (mConfirm || (mPin!=null && !hasTouchScreen)) {
|
|
||||||
WatchUi.pushView(
|
WatchUi.pushView(
|
||||||
new HomeAssistantConfirmation(),
|
new HomeAssistantConfirmation(),
|
||||||
new HomeAssistantConfirmationDelegate(method(:onConfirm), false),
|
new HomeAssistantConfirmationDelegate(method(:onConfirm), false),
|
||||||
WatchUi.SLIDE_IMMEDIATE
|
WatchUi.SLIDE_IMMEDIATE
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
WatchUi.pushView(
|
||||||
|
new HomeAssistantPinConfirmationView(),
|
||||||
|
new HomeAssistantPinConfirmationDelegate(method(:onConfirm), false, pin),
|
||||||
|
WatchUi.SLIDE_IMMEDIATE
|
||||||
|
);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
onConfirm(false);
|
onConfirm(false);
|
||||||
}
|
}
|
||||||
|
@ -52,12 +52,10 @@ class HomeAssistantView extends WatchUi.Menu2 {
|
|||||||
var service = items[i].get("service") as Lang.String or Null; // Deprecated schema
|
var service = items[i].get("service") as Lang.String or Null; // Deprecated schema
|
||||||
var confirm = false as Lang.Boolean or Null;
|
var confirm = false as Lang.Boolean or Null;
|
||||||
var data = null as Lang.Dictionary or Null;
|
var data = null as Lang.Dictionary or Null;
|
||||||
var pin = null as Lang.String or Null;
|
|
||||||
if (tap_action != null) {
|
if (tap_action != null) {
|
||||||
service = tap_action.get("service");
|
service = tap_action.get("service");
|
||||||
confirm = tap_action.get("confirm"); // Optional
|
confirm = tap_action.get("confirm"); // Optional
|
||||||
data = tap_action.get("data"); // Optional
|
data = tap_action.get("data"); // Optional
|
||||||
pin = tap_action.get("pin"); // Optional
|
|
||||||
if (confirm == null) {
|
if (confirm == null) {
|
||||||
confirm = false;
|
confirm = false;
|
||||||
}
|
}
|
||||||
@ -66,7 +64,7 @@ class HomeAssistantView extends WatchUi.Menu2 {
|
|||||||
if (type.equals("toggle") && entity != null) {
|
if (type.equals("toggle") && entity != null) {
|
||||||
addItem(HomeAssistantMenuItemFactory.create().toggle(name, entity, content, confirm));
|
addItem(HomeAssistantMenuItemFactory.create().toggle(name, entity, content, confirm));
|
||||||
} else if ((type.equals("tap") && service != null) || (type.equals("template") && content != null)) {
|
} else if ((type.equals("tap") && service != null) || (type.equals("template") && content != null)) {
|
||||||
addItem(HomeAssistantMenuItemFactory.create().tap(name, entity, content, service, confirm, data, pin));
|
addItem(HomeAssistantMenuItemFactory.create().tap(name, entity, content, service, confirm, data));
|
||||||
} else if (type.equals("group")) {
|
} else if (type.equals("group")) {
|
||||||
addItem(HomeAssistantMenuItemFactory.create().group(items[i], content));
|
addItem(HomeAssistantMenuItemFactory.create().group(items[i], content));
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ class Settings {
|
|||||||
private static var mAppTimeout as Lang.Number = 0; // seconds
|
private static var mAppTimeout as Lang.Number = 0; // seconds
|
||||||
private static var mPollDelay as Lang.Number = 0; // seconds
|
private static var mPollDelay as Lang.Number = 0; // seconds
|
||||||
private static var mConfirmTimeout as Lang.Number = 3; // seconds
|
private static var mConfirmTimeout as Lang.Number = 3; // seconds
|
||||||
private static var mPinMask as Lang.String = "";
|
private static var mPin as Lang.String = "";
|
||||||
private static var mMenuAlignment as Lang.Number = WatchUi.MenuItem.MENU_ITEM_LABEL_ALIGN_LEFT;
|
private static var mMenuAlignment as Lang.Number = WatchUi.MenuItem.MENU_ITEM_LABEL_ALIGN_LEFT;
|
||||||
private static var mIsSensorsLevelEnabled as Lang.Boolean = false;
|
private static var mIsSensorsLevelEnabled as Lang.Boolean = false;
|
||||||
private static var mBatteryRefreshRate as Lang.Number = 15; // minutes
|
private static var mBatteryRefreshRate as Lang.Number = 15; // minutes
|
||||||
@ -60,7 +60,7 @@ class Settings {
|
|||||||
mAppTimeout = Properties.getValue("app_timeout");
|
mAppTimeout = Properties.getValue("app_timeout");
|
||||||
mPollDelay = Properties.getValue("poll_delay_combined");
|
mPollDelay = Properties.getValue("poll_delay_combined");
|
||||||
mConfirmTimeout = Properties.getValue("confirm_timeout");
|
mConfirmTimeout = Properties.getValue("confirm_timeout");
|
||||||
mPinMask = Properties.getValue("pin_mask");
|
mPin = Properties.getValue("pin");
|
||||||
mMenuAlignment = Properties.getValue("menu_alignment");
|
mMenuAlignment = Properties.getValue("menu_alignment");
|
||||||
mIsSensorsLevelEnabled = Properties.getValue("enable_battery_level");
|
mIsSensorsLevelEnabled = Properties.getValue("enable_battery_level");
|
||||||
mBatteryRefreshRate = Properties.getValue("battery_level_refresh_rate");
|
mBatteryRefreshRate = Properties.getValue("battery_level_refresh_rate");
|
||||||
@ -166,8 +166,8 @@ class Settings {
|
|||||||
return mConfirmTimeout * 1000; // Convert to milliseconds
|
return mConfirmTimeout * 1000; // Convert to milliseconds
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getPinMask() as Lang.String {
|
static function getPin() as Lang.String {
|
||||||
return mPinMask;
|
return mPin;
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getMenuAlignment() as Lang.Number {
|
static function getMenuAlignment() as Lang.Number {
|
||||||
|
Reference in New Issue
Block a user