When an activity is started or stopped, the next up or down button press will be missed by the event handler.
Here's a video that shows the problem on a 735XT.
https://youtu.be/dssvYvn5Cqc
Devices I know HAVE the problem:
fr735XT
fr235
VivoActive HR
Devices I know DON'T have the problem:
Fenix3
Edge1000
Edge520
I don't have the other devices available to test right now. The 920XT and vivoactive used to have this problem, but I haven't verified them lately.
Here's the test case. If you just comment out the mActivity.start() and .stop(), the problem goes away.
using Toybox.Application as App;
using Toybox.ActivityRecording as Arc;
using Toybox.WatchUi as Ui;
using Toybox.Graphics as Gfx;
using Toybox.System as Sys;
class MissedButtonPressApp extends App.AppBase {
var mActivity;
var mTimer;
var mView;
function initialize() {
AppBase.initialize();
mActivity = Arc.createSession({
:sport => Arc.SPORT_CYCLING,
:subSport => Arc.SUB_SPORT_GENERIC,
:name => "cycling"
});
mTimer = new Timer.Timer();
mTimer.start(self.method(:onTimerCallback), 1000, true);
}
function getInitialView() {
mView = new MissedButtonPressView();
return [mView , new MissedButtonPressDelegate() ];
}
function PressDown() {
mView.Display(1);
Ui.requestUpdate();
}
function PressUp() {
mView.Display(2);
Ui.requestUpdate();
}
function StartStopAct() {
if (mActivity.isRecording()) {
mActivity.stop();
mView.Display(4);
}
else {
mActivity.start();
mView.Display(3);
}
Ui.requestUpdate();
}
function SomeKey() {
mView.Display(5);
Ui.requestUpdate();
}
function onTimerCallback() {
Ui.requestUpdate();
}
}
class MissedButtonPressView extends Ui.View {
var message = "Idle";
var mTime = Sys.getTimer();
function initialize() {
View.initialize();
}
function onUpdate(dc) {
View.onUpdate(dc);
dc.setColor(Gfx.COLOR_WHITE, Gfx.COLOR_BLACK);
dc.clear();
var width = dc.getWidth();
var height = dc.getHeight();
if (Sys.getTimer() - mTime > 4000) {
message = "Idle";
}
dc.drawText(width/2, height/2, Gfx.FONT_LARGE, message, Gfx.TEXT_JUSTIFY_CENTER | Gfx.TEXT_JUSTIFY_VCENTER);
}
function Display(val) {
mTime = Sys.getTimer();
if (val == 1) {
message = "Down";
}
else if (val == 2) {
message = "Up";
}
else if (val == 3) {
message = "Start";
}
else if (val == 4) {
message = "Stop";
}
else if (val == 5) {
message = "Some Other Button";
}
}
}
class MissedButtonPressDelegate extends Ui.BehaviorDelegate {
function initialize() {
BehaviorDelegate.initialize();
}
function onKey(evt) {
var key = evt.getKey();
if (key == Ui.KEY_DOWN) {
App.getApp().PressDown();
}
else if (key == Ui.KEY_UP) {
App.getApp().PressUp();
}
else if (key == Ui.KEY_START) {
App.getApp().StartStopAct();
}
else if (key == Ui.KEY_ENTER) {
App.getApp().StartStopAct();
}
else if (key == Ui.KEY_ESC) {
return false;
}
else {
App.getApp().SomeKey();
}
return true;
}
function onTap(evt) {
App.getApp().SomeKey();
return true;
}
function onSwipe(evt) {
App.getApp().SomeKey();
return true;
}
}