diff --git a/source/Delegates/AdvancedViewDelegate.mc b/source/Delegates/AdvancedViewDelegate.mc index 7ef2f4a..9b302c8 100644 --- a/source/Delegates/AdvancedViewDelegate.mc +++ b/source/Delegates/AdvancedViewDelegate.mc @@ -5,9 +5,11 @@ import Toybox.Application; class AdvancedViewDelegate extends WatchUi.BehaviorDelegate { + //private var _view as AdvancedView; function initialize(view as AdvancedView) { - BehaviorDelegate.initialize(); + InputDelegate.initialize(); + //_view = view; } function onMenu(){ @@ -44,9 +46,7 @@ class AdvancedViewDelegate extends WatchUi.BehaviorDelegate { } if(direction == WatchUi.SWIPE_LEFT){ - var currentView = new SettingsView(); - System.println("Swiped Left"); - WatchUi.pushView(currentView, new SettingsDelegate(currentView), WatchUi.SLIDE_LEFT); + pushSettingsView(); return true; } @@ -57,5 +57,16 @@ class AdvancedViewDelegate extends WatchUi.BehaviorDelegate { WatchUi.popView(WatchUi.SLIDE_BLINK); return true; } + + function pushSettingsView() as Void{ + var settingsMenu = new WatchUi.Menu2({ :title => "Settings" }); + + settingsMenu.addItem(new WatchUi.MenuItem("Profile", null, :set_profile, null)); + settingsMenu.addItem(new WatchUi.MenuItem("Customization", null, :cust_options, null)); + settingsMenu.addItem(new WatchUi.MenuItem("Feedback", null, :feedback_options, null)); + settingsMenu.addItem(new WatchUi.MenuItem("Cadence Range", null, :cadence_range, null)); + + WatchUi.pushView(settingsMenu, new SettingsMenuDelegate(), WatchUi.SLIDE_UP); + } } \ No newline at end of file diff --git a/source/Delegates/SettingsDelegate.mc b/source/Delegates/SettingsDelegate.mc deleted file mode 100644 index 5dbf62f..0000000 --- a/source/Delegates/SettingsDelegate.mc +++ /dev/null @@ -1,77 +0,0 @@ -import Toybox.Lang; -import Toybox.System; -import Toybox.WatchUi; -import Toybox.Application; - -class SettingsDelegate extends WatchUi.InputDelegate { - - private var _view as SettingsView; - - function initialize(view as SettingsView) { - InputDelegate.initialize(); - _view = view; - } - - - function onBack() as Boolean{ - WatchUi.popView(WatchUi.SLIDE_DOWN); - return true; - } - - // This check for a tap on the screen - function onTap(event as WatchUi.ClickEvent) as Boolean { - - var x = 0; - var y = 0; - - // Use has check to safely retrieve coordinates from the event object. - if (event has :getCoordinates) { - // event.getCoordinates() returns Array [x, y]. - var tapCoords = event.getCoordinates() as Array; - x = tapCoords[0]; - y = tapCoords[1]; - } else if (event has :getX) { - // Fallback for devices without getCoordinates() - x = 0; - y = 0; - } - - System.println(x.toString() + "and" + y.toString()); - - // Get the button coordinates from the associated View - var coords = _view.getButtonCoords(); - var x1 = coords[0]; - var y1 = coords[1]; - var x2 = coords[2]; - var y2 = coords[3]; - - System.println(x1.toString() + " " + y1.toString() + " " + x2.toString() + " " + y2.toString()); - - // Check if the tap was on the button and sends to cadence range select menu - if (x >= x1 && x <= x1 + x2 && y >= y1 && y <= y1 + y2) { - System.println("Button Pressed"); - - - var app = Application.getApp() as GarminApp; - var minCadence = app.getMinCadence(); - var maxCadence = app.getMaxCadence(); - - var menu = new WatchUi.Menu2({ - :title => Lang.format("Cadence: $1$ - $2$", [minCadence, maxCadence]) - }); - - // these are def in strings.xml - menu.addItem(new WatchUi.MenuItem(WatchUi.loadResource(Rez.Strings.menu_inc_min), null, :item_inc_min, null)); - menu.addItem(new WatchUi.MenuItem(WatchUi.loadResource(Rez.Strings.menu_dec_min), null, :item_dec_min, null)); - menu.addItem(new WatchUi.MenuItem(WatchUi.loadResource(Rez.Strings.menu_inc_max), null, :item_inc_max, null)); - menu.addItem(new WatchUi.MenuItem(WatchUi.loadResource(Rez.Strings.menu_dec_max), null, :item_dec_max, null)); - - // push the menu made above with selectcadencedelegate - WatchUi.pushView(menu, new SelectCadenceDelegate(menu), WatchUi.SLIDE_LEFT); - - return true; - } - - return false; - } -} \ No newline at end of file diff --git a/source/Delegates/SettingsDelegates/CustomizableDelegates/SelectBarChartDelegate.mc b/source/Delegates/SettingsDelegates/CustomizableDelegates/SelectBarChartDelegate.mc new file mode 100644 index 0000000..196f907 --- /dev/null +++ b/source/Delegates/SettingsDelegates/CustomizableDelegates/SelectBarChartDelegate.mc @@ -0,0 +1,54 @@ +import Toybox.Lang; +import Toybox.System; +import Toybox.WatchUi; +import Toybox.Application; + +class SelectBarChartDelegate extends WatchUi.Menu2InputDelegate { + + private var _menu as WatchUi.Menu2; + var app = Application.getApp() as GarminApp; + var chartDuration = app.getChartDuration(); + + function initialize(menu as WatchUi.Menu2) { + Menu2InputDelegate.initialize(); + _menu = menu; + var newTitle = Lang.format("Chart: $1$", [chartDuration]); + + // This updates the UI when the chart duration is changed + _menu.setTitle(newTitle); + } + + function onSelect(item) as Void { + + var id = item.getId(); + + //Try to change cadence range based off menu selection + if (id == :chart_15m){ + app.setChartDuration("FifteenminChart"); + System.println("Chart Duration: Fifteenmin"); + } + else if (id == :chart_30m){ + app.setChartDuration("ThirtyminChart"); + System.println("Chart Duration: Thirtymin"); + } + else if (id == :chart_1h){ + app.setChartDuration("OneHourChart"); + System.println("Chart Duration: OneHour"); + } + else if (id == :chart_2h){ + app.setChartDuration("TwoHourChart"); + System.println("Chart Duration: TwoHour"); + } + else {System.println("ERROR");} + + WatchUi.popView(WatchUi.SLIDE_RIGHT); + + } + + function onMenuItem(item as Symbol) as Void {} + + //returns back one menu + function onBack() as Void { + WatchUi.popView(WatchUi.SLIDE_RIGHT); + } +} \ No newline at end of file diff --git a/source/Delegates/SettingsDelegates/CustomizableDelegates/SelectCustomizableDelegate.mc b/source/Delegates/SettingsDelegates/CustomizableDelegates/SelectCustomizableDelegate.mc new file mode 100644 index 0000000..345a3b5 --- /dev/null +++ b/source/Delegates/SettingsDelegates/CustomizableDelegates/SelectCustomizableDelegate.mc @@ -0,0 +1,47 @@ +import Toybox.Lang; +import Toybox.System; +import Toybox.WatchUi; +import Toybox.Application; + +class SelectCutomizableDelegate extends WatchUi.Menu2InputDelegate { + + //private var _menu as WatchUi.Menu2; + + function initialize(menu as WatchUi.Menu2) { + Menu2InputDelegate.initialize(); + //_menu = menu; + } + + function onSelect(item) as Void { + + var id = item.getId(); + + //Add if more customizable options are added + if (id == :cust_bar_chart){ + pushBarChartMenu(); + } + else {System.println("ERROR");} + + } + + function pushBarChartMenu() as Void { + var menu = new WatchUi.Menu2({ + :title => "Bar Chart Length:" + }); + + menu.addItem(new WatchUi.MenuItem("15 Minute", null, :chart_15m, null)); + menu.addItem(new WatchUi.MenuItem("30 Minute", null, :chart_30m, null)); + menu.addItem(new WatchUi.MenuItem("1 Hour", null, :chart_1h, null)); + menu.addItem(new WatchUi.MenuItem("2 Hour", null, :chart_2h, null)); + + //pushes the view to the screen with the relevent delegate + WatchUi.pushView(menu, new SelectBarChartDelegate(menu), WatchUi.SLIDE_LEFT); + } + + function onMenuItem(item as Symbol) as Void {} + + //returns back one menu + function onBack() as Void { + WatchUi.popView(WatchUi.SLIDE_RIGHT); + } +} \ No newline at end of file diff --git a/source/Delegates/SettingsDelegates/FeedbackDelegates/SelectAudibleDelegate.mc b/source/Delegates/SettingsDelegates/FeedbackDelegates/SelectAudibleDelegate.mc new file mode 100644 index 0000000..68d5708 --- /dev/null +++ b/source/Delegates/SettingsDelegates/FeedbackDelegates/SelectAudibleDelegate.mc @@ -0,0 +1,50 @@ +import Toybox.Lang; +import Toybox.System; +import Toybox.WatchUi; +import Toybox.Application; + +class SelectAudibleDelegate extends WatchUi.Menu2InputDelegate { + + private var _menu as WatchUi.Menu2; + var app = Application.getApp() as GarminApp; + //var Audible = app.getAudible(); + var Audible = "low";// make sure to change to above!! - after feature has been added + + function initialize(menu as WatchUi.Menu2) { + Menu2InputDelegate.initialize(); + _menu = menu; + + var newTitle = Lang.format("Audible: $1$", [Audible]); + + // This updates the UI when the cadence is changed + _menu.setTitle(newTitle); + } + + function onSelect(item) as Void { + + var id = item.getId(); + + //Try to change cadence range based off menu selection + if (id == :audible_low){ + System.println("Audible Feedback: LOW"); + //app.setAudible("low"); + } + else if (id == :audible_med){ + System.println("Audible Feedback: MEDIUM"); + //app.setUserAudible("med"); + } + else if (id == :audible_high){ + System.println("Audible Feedback: HIGH"); + //app.setUserAudible("high"); + } else {System.println("ERROR");} + + WatchUi.popView(WatchUi.SLIDE_RIGHT); + } + + function onMenuItem(item as Symbol) as Void {} + + // Returns back one menu + function onBack() as Void { + WatchUi.popView(WatchUi.SLIDE_RIGHT); + } +} \ No newline at end of file diff --git a/source/Delegates/SettingsDelegates/FeedbackDelegates/SelectFeedbackDelegate.mc b/source/Delegates/SettingsDelegates/FeedbackDelegates/SelectFeedbackDelegate.mc new file mode 100644 index 0000000..50515b9 --- /dev/null +++ b/source/Delegates/SettingsDelegates/FeedbackDelegates/SelectFeedbackDelegate.mc @@ -0,0 +1,66 @@ +import Toybox.Lang; +import Toybox.System; +import Toybox.WatchUi; +import Toybox.Application; + +class SelectFeedbackDelegate extends WatchUi.Menu2InputDelegate { + + //private var _menu as WatchUi.Menu2; + var app = Application.getApp() as GarminApp; + //var experienceLvl = app.getUserGender(); + var gender = "Other";// make sure to change to above!! + + function initialize(menu as WatchUi.Menu2) { + Menu2InputDelegate.initialize(); + //_menu = menu; + } + + function onSelect(item) as Void { + + var id = item.getId(); + + //Try to change cadence range based off menu selection + if (id == :haptic_feedback){ + System.println("Haptic menu selected"); + pushHapticSettings(); + } + else if (id == :audible_feedback){ + System.println("Audible menu selected"); + pushAudibleSettings(); + } else {System.println("ERROR");} + + } + + function pushHapticSettings() as Void{ + var menu = new WatchUi.Menu2({ + :title => "Haptic Settings" + }); + //temp items since feedback has not yet been implemented + menu.addItem(new WatchUi.MenuItem("Low", null, :haptic_low, null)); + menu.addItem(new WatchUi.MenuItem("Medium", null, :haptic_med, null)); + menu.addItem(new WatchUi.MenuItem("High", null, :haptic_high, null)); + + //pushes the view to the screen with the relevent delegate + WatchUi.pushView(menu, new SelectHapticDelegate(menu), WatchUi.SLIDE_LEFT); + } + + function pushAudibleSettings() as Void{ + var menu = new WatchUi.Menu2({ + :title => "Audible Settings" + }); + + menu.addItem(new WatchUi.MenuItem("Low", null, :audible_low, null)); + menu.addItem(new WatchUi.MenuItem("Medium", null, :audible_med, null)); + menu.addItem(new WatchUi.MenuItem("High", null, :audible_high, null)); + + //pushes the view to the screen with the relevent delegate + WatchUi.pushView(menu, new SelectAudibleDelegate(menu), WatchUi.SLIDE_LEFT); + } + + function onMenuItem(item as Symbol) as Void {} + + // Returns back one menu + function onBack() as Void { + WatchUi.popView(WatchUi.SLIDE_RIGHT); + } +} \ No newline at end of file diff --git a/source/Delegates/SettingsDelegates/FeedbackDelegates/SelectHapticDelegate.mc b/source/Delegates/SettingsDelegates/FeedbackDelegates/SelectHapticDelegate.mc new file mode 100644 index 0000000..d701071 --- /dev/null +++ b/source/Delegates/SettingsDelegates/FeedbackDelegates/SelectHapticDelegate.mc @@ -0,0 +1,50 @@ +import Toybox.Lang; +import Toybox.System; +import Toybox.WatchUi; +import Toybox.Application; + +class SelectHapticDelegate extends WatchUi.Menu2InputDelegate { + + private var _menu as WatchUi.Menu2; + var app = Application.getApp() as GarminApp; + //var haptic = app.getHaptic(); + var haptic = "low";// make sure to change to above!! - after feature has been added + + function initialize(menu as WatchUi.Menu2) { + Menu2InputDelegate.initialize(); + _menu = menu; + + var newTitle = Lang.format("Haptic: $1$", [haptic]); + + // This updates the UI when the cadence is changed + _menu.setTitle(newTitle); + } + + function onSelect(item) as Void { + + var id = item.getId(); + + //Try to change cadence range based off menu selection + if (id == :haptic_low){ + System.println("Haptic Feedback: LOW"); + //app.setHaptic("low"); + } + else if (id == :haptic_med){ + System.println("Haptic Feedback: MEDIUM"); + //app.setUserHaptic("med"); + } + else if (id == :haptic_high){ + System.println("Haptic Feedback: HIGH"); + //app.setUserHaptic("high"); + } else {System.println("ERROR");} + + WatchUi.popView(WatchUi.SLIDE_RIGHT); + } + + function onMenuItem(item as Symbol) as Void {} + + // Returns back one menu + function onBack() as Void { + WatchUi.popView(WatchUi.SLIDE_RIGHT); + } +} \ No newline at end of file diff --git a/source/Delegates/SettingsDelegates/ProfileDelegates/ProfilePickerDelegate.mc b/source/Delegates/SettingsDelegates/ProfileDelegates/ProfilePickerDelegate.mc new file mode 100644 index 0000000..61d7218 --- /dev/null +++ b/source/Delegates/SettingsDelegates/ProfileDelegates/ProfilePickerDelegate.mc @@ -0,0 +1,37 @@ +import Toybox.WatchUi; +import Toybox.System; +import Toybox.Application; +import Toybox.Lang; + +class ProfilePickerDelegate extends WatchUi.PickerDelegate { + + private var _typeId; + + function initialize(typeId) { + PickerDelegate.initialize(); + _typeId = typeId; + } + + function onAccept(values as Array) as Boolean { + var pickedValue = values[0]; // Gets the "selected" value + + var app = Application.getApp() as GarminApp; + + if (_typeId == :prof_height) { + System.println("Height Saved: " + pickedValue); + app.setUserHeight(pickedValue); + } + else if (_typeId == :prof_speed) { + System.println("Speed Saved: " + pickedValue); + app.setUserSpeed(pickedValue); + } + + WatchUi.popView(WatchUi.SLIDE_RIGHT); + return true; + } + + function onCancel() as Boolean { + WatchUi.popView(WatchUi.SLIDE_RIGHT); + return true; + } +} \ No newline at end of file diff --git a/source/Delegates/SettingsDelegates/ProfileDelegates/ProfilePickerFactory.mc b/source/Delegates/SettingsDelegates/ProfileDelegates/ProfilePickerFactory.mc new file mode 100644 index 0000000..a6140f5 --- /dev/null +++ b/source/Delegates/SettingsDelegates/ProfileDelegates/ProfilePickerFactory.mc @@ -0,0 +1,64 @@ +import Toybox.WatchUi; +import Toybox.Graphics; +import Toybox.Lang; + +class ProfilePickerFactory extends WatchUi.PickerFactory { + private var _start as Number; + private var _stop as Number; + private var _increment as Number; + private var _label as String; + + function initialize(start as Number, stop as Number, increment as Number, options as Dictionary?) { + PickerFactory.initialize(); + _start = start; + _stop = stop; + _increment = increment; + _label = ""; + + if (options != null) { + if (options.hasKey(:label)) { + _label = options[:label] as String; + } + } + } + + function getSize() as Number { + return (_stop - _start) / _increment + 1; + } + + function getValue(index as Number) as Object? { + return _start + (index * _increment); + } + + function getDrawable(index as Number, selected as Boolean) as Drawable? { + + // gets the selected value + var val = getValue(index); + + // converts to number if needed + if (val has :toNumber) { + val = val.toNumber(); + } + + // string that is displayed (e.g. "175" + " cm") + var displayString = Lang.format("$1$$2$", [val, _label]); + + return new WatchUi.Text({ + :text => displayString, + :color => Graphics.COLOR_WHITE, + :font => Graphics.FONT_MEDIUM, + :locX => WatchUi.LAYOUT_HALIGN_CENTER, + :locY => WatchUi.LAYOUT_VALIGN_CENTER + }); + } + + function getIndex(value as Number) as Number { + + var safeValue = value; + if (safeValue has :toNumber) { + safeValue = safeValue.toNumber(); + } + + return (safeValue - _start) / _increment; + } +} \ No newline at end of file diff --git a/source/Delegates/SettingsDelegates/ProfileDelegates/SelectExperienceDelegate.mc b/source/Delegates/SettingsDelegates/ProfileDelegates/SelectExperienceDelegate.mc new file mode 100644 index 0000000..6e1a254 --- /dev/null +++ b/source/Delegates/SettingsDelegates/ProfileDelegates/SelectExperienceDelegate.mc @@ -0,0 +1,59 @@ +import Toybox.Lang; +import Toybox.System; +import Toybox.WatchUi; +import Toybox.Application; + +class SelectExperienceDelegate extends WatchUi.Menu2InputDelegate { + + private var _menu as WatchUi.Menu2; + var app = Application.getApp() as GarminApp; + var experienceLvl = app.getExperienceLvl(); + var experienceLvlString = "NULL"; + + function initialize(menu as WatchUi.Menu2) { + Menu2InputDelegate.initialize(); + _menu = menu; + + if (experienceLvl == 1.06){ + experienceLvlString = "Beginner"; + } else if (experienceLvl == 1.04){ + experienceLvlString = "Intermediate"; + } else if (experienceLvl == 1.02){ + experienceLvlString = "Advanced"; + } + var newTitle = Lang.format("Experience: $1$", [experienceLvlString]); + + // This updates the UI when the experience level is changed + _menu.setTitle(newTitle); + } + + function onSelect(item) as Void { + + var id = item.getId(); + + //Try to change user experience lvl based off menu selection + if (id == :exp_beginner){ + System.println("User ExperienceLvl: Beginner"); + app.setExperienceLvl(1.06); + } + else if (id == :exp_intermediate){ + System.println("User ExperienceLvl: Intermediate"); + app.setExperienceLvl(1.04); + } + else if (id == :exp_advanced){ + System.println("User ExperienceLvl: Advanced"); + app.setExperienceLvl(1.02); + } else {System.println("ERROR");} + + WatchUi.popView(WatchUi.SLIDE_RIGHT); + + } + + + function onMenuItem(item as Symbol) as Void {} + + // Returns back one menu + function onBack() as Void { + WatchUi.popView(WatchUi.SLIDE_RIGHT); + } +} \ No newline at end of file diff --git a/source/Delegates/SettingsDelegates/ProfileDelegates/SelectGenderDelegate.mc b/source/Delegates/SettingsDelegates/ProfileDelegates/SelectGenderDelegate.mc new file mode 100644 index 0000000..8f2179b --- /dev/null +++ b/source/Delegates/SettingsDelegates/ProfileDelegates/SelectGenderDelegate.mc @@ -0,0 +1,50 @@ +import Toybox.Lang; +import Toybox.System; +import Toybox.WatchUi; +import Toybox.Application; + +class SelectGenderDelegate extends WatchUi.Menu2InputDelegate { + + private var _menu as WatchUi.Menu2; + var app = Application.getApp() as GarminApp; + var gender = app.getUserGender(); + + function initialize(menu as WatchUi.Menu2) { + Menu2InputDelegate.initialize(); + _menu = menu; + + // need if statements to display experiencelvl string instead of float values + var newTitle = Lang.format("Gender: $1$", [gender]); + + // This updates the UI when the cadence is changed + _menu.setTitle(newTitle); + } + + function onSelect(item) as Void { + + var id = item.getId(); + + //Try to change user gender based off menu selection + if (id == :user_male){ + app.setUserGender("Male"); + System.println("User Gender: Male"); + } + else if (id == :user_female){ + app.setUserGender("Female"); + System.println("User Gender: Female"); + } + else if (id == :user_other){ + app.setUserGender("Other"); + System.println("User Gender: Other"); + } else {System.println("ERROR");} + + WatchUi.popView(WatchUi.SLIDE_RIGHT); + } + + function onMenuItem(item as Symbol) as Void {} + + // Returns back one menu + function onBack() as Void { + WatchUi.popView(WatchUi.SLIDE_RIGHT); + } +} \ No newline at end of file diff --git a/source/Delegates/SettingsDelegates/ProfileDelegates/SelectProfileDelegate.mc b/source/Delegates/SettingsDelegates/ProfileDelegates/SelectProfileDelegate.mc new file mode 100644 index 0000000..2e55f3e --- /dev/null +++ b/source/Delegates/SettingsDelegates/ProfileDelegates/SelectProfileDelegate.mc @@ -0,0 +1,103 @@ +import Toybox.Lang; +import Toybox.System; +import Toybox.WatchUi; +import Toybox.Application; +import Toybox.Graphics; + +class SelectProfileDelegate extends WatchUi.Menu2InputDelegate { + + //private var _menu as WatchUi.Menu2; + var app = Application.getApp() as GarminApp; + + function initialize(menu as WatchUi.Menu2) { + Menu2InputDelegate.initialize(); + //_menu = menu; + } + + function onSelect(item) as Void { + + var id = item.getId(); + + //displays the menu for the selected item + if (id == :profile_height){ + heightPicker(); + } + else if (id == :profile_speed){ + speedPicker(); + } + else if (id == :profile_experience){ + experienceMenu(); + } + else if (id == :profile_gender){ + genderMenu(); + } + } + + function onMenuItem(item as Symbol) as Void {} + + // Returns back one menu + function onBack() as Void { + WatchUi.popView(WatchUi.SLIDE_RIGHT); + } + + function heightPicker() as Void { + + var currentHeight = app.getUserHeight(); + if (currentHeight == null) { currentHeight = 175; } // Default 175 cm + + var factory = new ProfilePickerFactory(100, 250, 1, {:label=>" cm"}); + + var picker = new WatchUi.Picker({ + :title => new WatchUi.Text({:text=>"Set Height", :locX=>WatchUi.LAYOUT_HALIGN_CENTER, :locY=>WatchUi.LAYOUT_VALIGN_BOTTOM, :color=>Graphics.COLOR_WHITE}), + :pattern => [factory], + :defaults => [factory.getIndex(currentHeight)] + }); + + WatchUi.pushView(picker, new ProfilePickerDelegate(:prof_height), WatchUi.SLIDE_LEFT); + + } + + function speedPicker() as Void { + //uses number not float + var currentSpeed = app.getUserSpeed().toNumber(); + if (currentSpeed == null) { currentSpeed = 10; } // Default 10 km/h + + var factory = new ProfilePickerFactory(5, 30, 1, {:label=>" km/h"}); + + var picker = new WatchUi.Picker({ + :title => new WatchUi.Text({:text=>"Set Speed", :locX=>WatchUi.LAYOUT_HALIGN_CENTER, :locY=>WatchUi.LAYOUT_VALIGN_BOTTOM, :color=>Graphics.COLOR_WHITE}), + :pattern => [factory], + :defaults => [factory.getIndex(currentSpeed)] + }); + + WatchUi.pushView(picker, new ProfilePickerDelegate(:prof_speed), WatchUi.SLIDE_LEFT); + + } + + function experienceMenu() as Void { + var menu = new WatchUi.Menu2({ + :title => "Set Experience" + }); + + menu.addItem(new WatchUi.MenuItem("Beginner", null, :exp_beginner, null)); + menu.addItem(new WatchUi.MenuItem("Intermediate", null, :exp_intermediate, null)); + menu.addItem(new WatchUi.MenuItem("Advanced", null, :exp_advanced, null)); + + //pushes the view to the screen with the relevent delegate + WatchUi.pushView(menu, new SelectExperienceDelegate(menu), WatchUi.SLIDE_LEFT); + } + + function genderMenu() as Void { + var menu = new WatchUi.Menu2({ + :title => "Set Gender" + }); + + menu.addItem(new WatchUi.MenuItem("Male", null, :user_male, null)); + menu.addItem(new WatchUi.MenuItem("Female", null, :user_female, null)); + menu.addItem(new WatchUi.MenuItem("Other", null, :user_other, null)); + + //pushes the view to the screen with the relevent delegate + WatchUi.pushView(menu, new SelectGenderDelegate(menu), WatchUi.SLIDE_LEFT); + } + +} \ No newline at end of file diff --git a/source/Delegates/SelectCadenceDelegate.mc b/source/Delegates/SettingsDelegates/SelectCadenceDelegate.mc similarity index 94% rename from source/Delegates/SelectCadenceDelegate.mc rename to source/Delegates/SettingsDelegates/SelectCadenceDelegate.mc index e4a7cf7..01dd931 100644 --- a/source/Delegates/SelectCadenceDelegate.mc +++ b/source/Delegates/SettingsDelegates/SelectCadenceDelegate.mc @@ -61,11 +61,13 @@ class SelectCadenceDelegate extends WatchUi.Menu2InputDelegate { var newTitle = Lang.format("Cadence: $1$ - $2$", [newMin, newMax]); - // This updates the UI immediately + //this updates the UI when the cadence is changed _menu.setTitle(newTitle); } - // Returns back one menu + //function onMenuItem(item as Symbol) as Void {} + + //returns back one menu function onBack() as Void { WatchUi.popView(WatchUi.SLIDE_BLINK); } diff --git a/source/Delegates/SettingsDelegates/SettingsDelegate.mc b/source/Delegates/SettingsDelegates/SettingsDelegate.mc new file mode 100644 index 0000000..972f1e0 --- /dev/null +++ b/source/Delegates/SettingsDelegates/SettingsDelegate.mc @@ -0,0 +1,101 @@ +import Toybox.Lang; +import Toybox.System; +import Toybox.WatchUi; +import Toybox.Application; + +//this Delegate handels the menu items and creates the menus for each item +class SettingsMenuDelegate extends WatchUi.Menu2InputDelegate { + + function initialize() { + Menu2InputDelegate.initialize(); + } + + //triggers when user selects a menu option + function onSelect(item as WatchUi.MenuItem) as Void { + var id = item.getId(); + + //pushes next menu view based on selection + if (id == :set_profile) { + System.println("Selected: Set Profile"); + //function to push next view + pushProfileMenu(); + } + else if (id == :cust_options) { + System.println("Selected: Customizable Options"); + pushCustMenu(); + } + else if (id == :feedback_options) { + System.println("Selected: Feedback Options"); + pushFeedbackMenu(); + } + else if (id == :cadence_range) { + pushCadenceMenu(); + } + } + + //allows user to go back from the menu view + function onBack() as Void { + WatchUi.popView(WatchUi.SLIDE_RIGHT); + } + + function pushProfileMenu() as Void{ + + //creates the secondary menu and sets title + var menu = new WatchUi.Menu2({ + :title => "Profile Options" + }); + + //creates the new menu items + menu.addItem(new WatchUi.MenuItem("Height", null, :profile_height, null)); + menu.addItem(new WatchUi.MenuItem("Speed", null, :profile_speed, null)); + menu.addItem(new WatchUi.MenuItem("Experience level", null, :profile_experience, null)); + menu.addItem(new WatchUi.MenuItem("Gender", null, :profile_gender, null)); + + //pushes the view to the screen with the relevent delegate + WatchUi.pushView(menu, new SelectProfileDelegate(menu), WatchUi.SLIDE_LEFT); + + } + + function pushCustMenu() as Void{ + + var menu = new WatchUi.Menu2({ + :title => "Customization Options" + }); + + menu.addItem(new WatchUi.MenuItem("Bar Chart", null, :cust_bar_chart, null)); + + WatchUi.pushView(menu, new SelectCutomizableDelegate(menu), WatchUi.SLIDE_LEFT); + + } + + function pushFeedbackMenu() as Void{ + + var menu = new WatchUi.Menu2({ + :title => "Feedback Options" + }); + + menu.addItem(new WatchUi.MenuItem("Haptic Feedback", null, :haptic_feedback, null)); + menu.addItem(new WatchUi.MenuItem("Audible Feedback", null, :audible_feedback, null)); + + WatchUi.pushView(menu, new SelectFeedbackDelegate(menu), WatchUi.SLIDE_LEFT); + } + + function pushCadenceMenu() as Void { + + //sets the cadence variables to the global app variable to be used within the title + var app = Application.getApp() as GarminApp; + var minCadence = app.getMinCadence(); + var maxCadence = app.getMaxCadence(); + + var menu = new WatchUi.Menu2({ + :title => Lang.format("Cadence: $1$ - $2$", [minCadence, maxCadence]) + }); + + menu.addItem(new WatchUi.MenuItem(WatchUi.loadResource(Rez.Strings.menu_inc_min), null, :item_inc_min, null)); + menu.addItem(new WatchUi.MenuItem(WatchUi.loadResource(Rez.Strings.menu_dec_min), null, :item_dec_min, null)); + menu.addItem(new WatchUi.MenuItem(WatchUi.loadResource(Rez.Strings.menu_inc_max), null, :item_inc_max, null)); + menu.addItem(new WatchUi.MenuItem(WatchUi.loadResource(Rez.Strings.menu_dec_max), null, :item_dec_max, null)); + + WatchUi.pushView(menu, new SelectCadenceDelegate(menu), WatchUi.SLIDE_LEFT); + } +} \ No newline at end of file diff --git a/source/Delegates/SimpleViewDelegate.mc b/source/Delegates/SimpleViewDelegate.mc index 814efe8..163d145 100644 --- a/source/Delegates/SimpleViewDelegate.mc +++ b/source/Delegates/SimpleViewDelegate.mc @@ -11,12 +11,7 @@ class SimpleViewDelegate extends WatchUi.BehaviorDelegate { // Long-press MENU (optional settings) function onMenu() as Boolean { - var menu = new WatchUi.Menu2({:resources => "menus/menu.xml"}); - WatchUi.pushView( - new Rez.Menus.MainMenu(), - new SelectCadenceDelegate(menu), - WatchUi.SLIDE_BLINK - ); + pushSettingsView(); return true; } @@ -71,18 +66,24 @@ class SimpleViewDelegate extends WatchUi.BehaviorDelegate { } if (direction == WatchUi.SWIPE_LEFT) { - _currentView = new SettingsView(); - WatchUi.pushView( - _currentView, - new SettingsDelegate(_currentView), - WatchUi.SLIDE_LEFT - ); + pushSettingsView(); return true; } return false; } + function pushSettingsView() as Void{ + var settingsMenu = new WatchUi.Menu2({ :title => "Settings" }); + + settingsMenu.addItem(new WatchUi.MenuItem("Profile", null, :set_profile, null)); + settingsMenu.addItem(new WatchUi.MenuItem("Customization", null, :cust_options, null)); + settingsMenu.addItem(new WatchUi.MenuItem("Feedback", null, :feedback_options, null)); + settingsMenu.addItem(new WatchUi.MenuItem("Cadence Range", null, :cadence_range, null)); + + WatchUi.pushView(settingsMenu, new SettingsMenuDelegate(), WatchUi.SLIDE_UP); + } + function onBack() as Boolean { // Prevent accidental app exit return true; diff --git a/source/GarminApp.mc b/source/GarminApp.mc index f8ea2d8..61d2518 100644 --- a/source/GarminApp.mc +++ b/source/GarminApp.mc @@ -188,7 +188,7 @@ class GarminApp extends Application.AppBase { if (DEBUG_MODE) { System.println("[CADENCE] " + newCadence); } - } else { + else { // Track missing cadence samples (sensor dropouts) _missingCadenceCount++; } @@ -427,9 +427,6 @@ function writeDiagnosticLog() as Void { System.println("===== END DIAGNOSTIC SUMMARY ====="); } - - - function getMinCadence() as Number { return _idealMinCadence; } @@ -463,7 +460,17 @@ function writeDiagnosticLog() as Void { } function setChartDuration(value as String) as Void { - _chartDuration = value; + if (value == "FifteenminChart"){ + _chartDuration = FifteenminChart; + } else if (value == "ThirtyminChart"){ + _chartDuration = ThirtyminChart; + } else if (value == "OneHourChart"){ + _chartDuration = OneHourChart; + } else if (value == "TwoHourChart"){ + _chartDuration = TwoHourChart; + } else {System.println("ERROR");} + + System.println(_chartDuration); } function getUserGender() as String { @@ -482,6 +489,10 @@ function writeDiagnosticLog() as Void { _userHeight = value; } + function getUserHeight() as Number { + return _userHeight; + } + function getUserSpeed() as Float { return _userSpeed; } diff --git a/source/Views/SimpleView.mc b/source/Views/SimpleView.mc index db9d268..c20332f 100644 --- a/source/Views/SimpleView.mc +++ b/source/Views/SimpleView.mc @@ -18,8 +18,6 @@ class SimpleView extends WatchUi.View { private var _cqDisplay; private var _hardcoreDisplay; - - function _secondVibe() as Void { // Haptics not available on this target SDK/device in this workspace. // Replace the println below with the device vibration call when supported,