@@ -16,6 +16,36 @@ class QZCompanionGarminDelegate extends WatchUi.BehaviorDelegate {
1616
1717 var session = null ; // set up session variable
1818
19+ function createRecordingSession () {
20+ var sessionOptions = {
21+ :name => " QZ Activity"
22+ };
23+
24+ if (QZCompanionGarminView .bike == false ) {
25+ sessionOptions [:name ] = " QZ Run" ;
26+
27+ if (Toybox has :Activity && Activity has :SPORT_RUNNING ) {
28+ sessionOptions [:sport ] = Activity .SPORT_RUNNING ;
29+ }
30+
31+ if (Toybox has :Activity && Activity has :SUB_SPORT_INDOOR_RUNNING ) {
32+ sessionOptions [:subSport ] = Activity .SUB_SPORT_INDOOR_RUNNING ;
33+ }
34+ } else {
35+ sessionOptions [:name ] = " QZ Ride" ;
36+
37+ if (Toybox has :Activity && Activity has :SPORT_CYCLING ) {
38+ sessionOptions [:sport ] = Activity .SPORT_CYCLING ;
39+ }
40+
41+ if (Toybox has :Activity && Activity has :SUB_SPORT_INDOOR_CYCLING ) {
42+ sessionOptions [:subSport ] = Activity .SUB_SPORT_INDOOR_CYCLING ;
43+ }
44+ }
45+
46+ return ActivityRecording .createSession (sessionOptions );
47+ }
48+
1949 function onBack () {
2050 if (Toybox has :ActivityRecording ) {
2151 if ((session != null ) && session .isRecording ()) {
@@ -33,19 +63,7 @@ class QZCompanionGarminDelegate extends WatchUi.BehaviorDelegate {
3363 function onSelect () {
3464 if (Toybox has :ActivityRecording ) { // check device for activity recording
3565 if ((session == null ) || (session .isRecording () == false )) {
36- if (QZCompanionGarminView .bike == false ) {
37- session = ActivityRecording .createSession ({ // set up recording session
38- :name =>" QZ Run" , // set session name
39- :sport =>Activity .SPORT_RUNNING , // set sport type
40- :subSport =>Activity .SUB_SPORT_INDOOR_RUNNING // set sub sport type
41- });
42- } else {
43- session = ActivityRecording .createSession ({ // set up recording session
44- :name =>" QZ Ride" , // set session name
45- :sport =>Activity .SPORT_CYCLING , // set sport type
46- :subSport =>Activity .SUB_SPORT_INDOOR_CYCLING // set sub sport type
47- });
48- }
66+ session = createRecordingSession ();
4967 session .start (); // call start session
5068 }
5169 else if ((session != null ) && session .isRecording ()) {
@@ -63,6 +81,6 @@ class QZCompanionGarminDelegate extends WatchUi.BehaviorDelegate {
6381 return true ;
6482 }
6583 System .println (keyEvent ); // e.g. KEY_MENU = 7
66- return false ;
84+ return false ;
6785 }
68- }
86+ }
0 commit comments