From b77a20a7d1edc16424ec645df538dd92b83f894f Mon Sep 17 00:00:00 2001 From: dliedke Date: Sun, 7 Aug 2022 21:03:15 -0300 Subject: [PATCH] Fix issues with tap to turn on/off backlight during activity --- Meditate/source/activity/MeditateDelegate.mc | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Meditate/source/activity/MeditateDelegate.mc b/Meditate/source/activity/MeditateDelegate.mc index 0d9840c..70766d3 100644 --- a/Meditate/source/activity/MeditateDelegate.mc +++ b/Meditate/source/activity/MeditateDelegate.mc @@ -97,4 +97,23 @@ class MeditateDelegate extends Ui.BehaviorDelegate { } return false; } + + var backlightOn = false; + + function onTap(clickEvent) { + try { + + // Touch screen to disable/enable backlight during activity + // This will still respect the backligh timeout configured in the device + backlightOn = !backlightOn; + Attention.backlight(backlightOn); + + } catch(ex) { + + // Just in case we get a BacklightOnTooLongException for OLED display devices, + // disable backlight + backlightOn = false; + Attention.backlight(backlightOn); + } + } } \ No newline at end of file