Skip to content

Commit

Permalink
Make deferredIntent usage conditional on server flag
Browse files Browse the repository at this point in the history
Also return from onMenuItem() immediately after triggering deferredIntent
  • Loading branch information
abs0 committed Jun 13, 2022
1 parent a58ae30 commit 818ae61
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions source/DownloadRequest.mc
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ class DownloadRequest extends RequestDelegate {
* we can exclude the device uniqueIdentifer returned by the Simulator
*/
var deviceSettings = System.getDeviceSettings();
// Application.getApp().log("uniqueIdentifier(" + deviceSettings.uniqueIdentifier + ")");
if (deviceSettings.monkeyVersion[0] < 3 && !deviceSettings.uniqueIdentifier.equals($.ExcludeViewStackWorkaroundPreMonkeyV3)) {
Ui.popView(Ui.SLIDE_IMMEDIATE);
}
Expand Down
7 changes: 7 additions & 0 deletions source/TaoModel.mc
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ const STORE_STEP_NAME = "stepName";
const STORE_ADJUST_TEMPERATURE = "adjustTemperature";
const STORE_ADJUST_UNDULATION = "adjustUndulation";
const STORE_INCLUDE_RUN_BACK_STEP = "includeRunBackStep";
const STORE_DEFERRED_INTENT = "deferredIntent";

const PREF_WORKOUT_STEP_NAME = "workoutStepName";
const PREF_WORKOUT_STEP_TARGET = "workoutStepTarget";
const PREF_ADJUST_FOR_TEMPERATURE = "adjustForTemperature";
const PREF_ADJUST_FOR_UNDULATION ="adjustForUndulation";
const PREF_INCLUDE_RUN_BACK_STEP = "includeRunBackStep";
const PREF_DEFERRED_INTENT = "deferredIntent";

const SUMMARY_NAME = "name";
const SUMMARY_DISPLAY_PREFERENCES = "displayPreferences";
Expand Down Expand Up @@ -84,6 +86,7 @@ class TaoModel {
loadPref(PREF_ADJUST_FOR_TEMPERATURE, STORE_ADJUST_TEMPERATURE);
loadPref(PREF_ADJUST_FOR_UNDULATION, STORE_ADJUST_UNDULATION);
loadPref(PREF_INCLUDE_RUN_BACK_STEP, STORE_INCLUDE_RUN_BACK_STEP);
loadPref(PREF_DEFERRED_INTENT, STORE_DEFERRED_INTENT);
// Application.getApp().log("start: " + serverUrl + " " + accessToken);
}

Expand Down Expand Up @@ -134,6 +137,10 @@ class TaoModel {
return adjustBooleanPreference(PREF_INCLUDE_RUN_BACK_STEP);
}

function deferredIntent() {
return adjustBooleanPreference(PREF_DEFERRED_INTENT);
}

function adjustBooleanPreference(prefName) {
var newVal = !mergedPreference(prefName);
localPref[prefName] = newVal;
Expand Down
9 changes: 7 additions & 2 deletions source/WorkoutDelegate.mc
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,13 @@ class WorkoutMenuDelegate extends Ui.MenuInputDelegate {
break;
case :startWorkout:
// Use deferred intent handling workaround from Garmin to avoid issues on 645 firmware (SDK 3.0.3)
// System.exitTo(mModel.downloadIntent);
_activeTransaction = new self.DeferredIntent(self, mModel.downloadIntent);
Application.getApp().log("intent: " + (mModel.deferredIntent ? "deferred" : "instant"));
if (mModel.deferredIntent) {
_activeTransaction = new self.DeferredIntent(self, mModel.downloadIntent);
return;
} else {
System.exitTo(mModel.downloadIntent);
}
break;
default:
Ui.popView(Ui.SLIDE_IMMEDIATE);
Expand Down

0 comments on commit 818ae61

Please sign in to comment.