Non-touch screens cannot use PIN

When a menu item requests a PIN on devices without a touch screen, replace the menu item with an info item displaying a message for the user.
This commit is contained in:
Philip Abbey
2026-06-24 00:17:26 +01:00
parent a97440b997
commit 8c5bdbc1f8
2 changed files with 33 additions and 17 deletions

View File

@@ -112,7 +112,7 @@ class HomeAssistantMenuItemFactory {
label as Lang.String or Lang.Symbol, label as Lang.String or Lang.Symbol,
entity_id as Lang.String?, entity_id as Lang.String?,
template as Lang.String?, template as Lang.String?,
action as Lang.String?, action as Lang.String?,
data as Lang.Dictionary?, data as Lang.Dictionary?,
options as { options as {
:exit as Lang.Boolean, :exit as Lang.Boolean,

View File

@@ -133,23 +133,39 @@ class HomeAssistantView extends WatchUi.Menu2 {
)); ));
} }
} else if (type.equals("numeric") && action != null) { } else if (type.equals("numeric") && action != null) {
if (tap_action != null) { if (System.getDeviceSettings().isTouchScreen) {
var picker = tap_action.get("picker") as Lang.Dictionary?; // Numeric items are only actionable on touch screen devices.
if (picker != null) { if (tap_action != null) {
addItem(HomeAssistantMenuItemFactory.create().numeric( var picker = tap_action.get("picker") as Lang.Dictionary?;
name, if (picker != null) {
entity, addItem(HomeAssistantMenuItemFactory.create().numeric(
content, name,
action, entity,
data, content,
picker, action,
{ data,
:exit => exit, picker,
:confirm => confirm, {
:pin => pin :exit => exit,
} :confirm => confirm,
)); :pin => pin
}
));
}
} }
} else {
addItem(HomeAssistantMenuItemFactory.create().tap(
"PIN requires Touchscreen",
null,
null,
null,
data,
{
:exit => false,
:confirm => false,
:pin => false
}
));
} }
} else if (type.equals("info") && content != null) { } else if (type.equals("info") && content != null) {
// Cannot exit from a non-actionable information only menu item. // Cannot exit from a non-actionable information only menu item.