Skip to content
This repository has been archived by the owner on Feb 14, 2022. It is now read-only.

Commit

Permalink
Added menu item for changing update speed to menu2, and added full st…
Browse files Browse the repository at this point in the history
…rings to be used in settings controller on phone or pc
  • Loading branch information
ggoraa committed May 28, 2021
1 parent e791f48 commit a14bdea
Show file tree
Hide file tree
Showing 6 changed files with 106 additions and 21 deletions.
4 changes: 2 additions & 2 deletions resources/settings/settings.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<settings>
<setting propertyKey="@Properties.ShowPwmInsteadOfSpeed" title="@Strings.MainMenu_ShowPwmInsteadOfSpeed">
<setting propertyKey="@Properties.ShowPwmInsteadOfSpeed" title="@Strings.MainMenu_ShowPwmInsteadOfSpeed_Full">
<settingConfig type="boolean" />
</setting>
<setting propertyKey="@Properties.AppTheme" title="@Strings.MainMenu_AppTheme">
Expand All @@ -8,7 +8,7 @@
<listEntry value="1">@Strings.MainMenu_AppTheme_Dark</listEntry>
</settingConfig>
</setting>
<setting propertyKey="@Properties.DataUpdateSpeed" title="@Strings.MainMenu_DataUpdateSpeed_CIQSettings">
<setting propertyKey="@Properties.DataUpdateSpeed" title="@Strings.MainMenu_DataUpdateSpeed_Full">
<settingConfig type="list">
<listEntry value="400">@Strings.MainMenu_DataUpdateSpeed_Fast</listEntry>
<listEntry value="1000">@Strings.MainMenu_DataUpdateSpeed_Medium</listEntry>
Expand Down
4 changes: 3 additions & 1 deletion resources/strings/main/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,19 @@

<string id="MainMenu_Title">Settings</string>
<string id="MainMenu_ShowPwmInsteadOfSpeed">Show PWM on speed arc</string>
<string id="MainMenu_ShowPwmInsteadOfSpeed_Full">Show PWM on speed arc</string>
<string id="MainMenu_ShowPwmInsteadOfSpeed_Title">Enabled</string>
<string id="MainMenu_AppTheme">App Theme</string>
<string id="MainMenu_AppTheme_Title">Choose theme</string>
<string id="MainMenu_AppTheme_Light">Light theme</string>
<string id="MainMenu_AppTheme_Dark">Dark theme</string>
<string id="MainMenu_DataUpdateSpeed">Update speed</string>
<string id="MainMenu_DataUpdateSpeed_CIQSettings">Data update speed</string>
<string id="MainMenu_DataUpdateSpeed_Full">Data update speed</string>
<string id="MainMenu_DataUpdateSpeed_Fast">Fast</string>
<string id="MainMenu_DataUpdateSpeed_Medium">Medium</string>
<string id="MainMenu_DataUpdateSpeed_Slow">Slow</string>
<string id="MainMenu_DataUpdateSpeed_SuperSlow">Super slow</string>
<string id="MainMenu_DataUpdateSpeed_SuperSlow_Full">Super slow</string>

<string id="Kmh">km/h</string>

Expand Down
4 changes: 3 additions & 1 deletion resources/strings/rus/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,19 @@

<!-- <string id="MainMenu_Title">Настройки</string> -->
<string id="MainMenu_ShowPwmInsteadOfSpeed">Выводить ПВМ на арке скор.</string>
<string id="MainMenu_ShowPwmInsteadOfSpeed_Full">Выводить ПВМ на арке скорости</string>
<string id="MainMenu_ShowPwmInsteadOfSpeed_Title">Включено</string>
<string id="MainMenu_AppTheme">Тема</string>
<!-- <string id="MainMenu_AppTheme_Title">Выберите тему</string> -->
<string id="MainMenu_AppTheme_Light">Светлая</string>
<string id="MainMenu_AppTheme_Dark">Темная</string>
<string id="MainMenu_DataUpdateSpeed">Скорость обновл.</string>
<string id="MainMenu_DataUpdateSpeed_CIQSettings">Скорость обновл.</string>
<string id="MainMenu_DataUpdateSpeed_Full">Скорость обновления</string>
<string id="MainMenu_DataUpdateSpeed_Fast">Быстро</string>
<string id="MainMenu_DataUpdateSpeed_Medium">Средне</string>
<string id="MainMenu_DataUpdateSpeed_Slow">Медленно</string>
<string id="MainMenu_DataUpdateSpeed_SuperSlow">Супер медл.</string>
<string id="MainMenu_DataUpdateSpeed_SuperSlow_Full">Супер медленно</string>

<string id="Kmh">км/ч</string>

Expand Down
43 changes: 26 additions & 17 deletions src/view/homeView/HomeViewDelegate.mc
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,13 @@ class HomeViewDelegate extends WatchUi.BehaviorDelegate {
:title => Rez.Strings.MainMenu_Title
});

menu.addItem(
new ToggleMenuItem(
Rez.Strings.MainMenu_ShowPwmInsteadOfSpeed,
null,
"SpeedArcData",
AppStorage.getValue("ShowPwmInsteadOfSpeed"),
null
)
);
menu.addItem(new ToggleMenuItem(
Rez.Strings.MainMenu_ShowPwmInsteadOfSpeed,
null,
"SpeedArcData",
AppStorage.getValue("ShowPwmInsteadOfSpeed"),
null
));
var appThemeValue;
if (AppStorage.getValue("AppTheme") == 0){
appThemeValue = false;
Expand All @@ -34,14 +32,25 @@ class HomeViewDelegate extends WatchUi.BehaviorDelegate {
} else {
appThemSubLabel = Rez.Strings.MainMenu_AppTheme_Dark;
}
menu.addItem(
new MenuItem(
Rez.Strings.MainMenu_AppTheme,
appThemSubLabel,
"AppTheme",
null
)
);
menu.addItem(new MenuItem(
Rez.Strings.MainMenu_AppTheme,
appThemSubLabel,
"AppTheme",
null
));
var dataUpdateSpeedSublabel;
switch (AppStorage.getValue("DataUpdateSpeed")) {
case 400: dataUpdateSpeedSublabel = WatchUi.loadResource(Rez.Strings.MainMenu_DataUpdateSpeed_Fast); break;
case 1000: dataUpdateSpeedSublabel = WatchUi.loadResource(Rez.Strings.MainMenu_DataUpdateSpeed_Medium); break;
case 1500: dataUpdateSpeedSublabel = WatchUi.loadResource(Rez.Strings.MainMenu_DataUpdateSpeed_Slow); break;
case 2000: dataUpdateSpeedSublabel = WatchUi.loadResource(Rez.Strings.MainMenu_DataUpdateSpeed_SuperSlow); break;
}
menu.addItem(new MenuItem(
Rez.Strings.MainMenu_DataUpdateSpeed,
dataUpdateSpeedSublabel,
"DataUpdateSpeed",
null
));
WatchUi.pushView(menu, new SettingsMenu2Delegate(), WatchUi.SLIDE_UP);
} else {
WatchUi.pushView(new Rez.Menus.SettingsMenu(), new SettingsMenuDelegate(), WatchUi.SLIDE_UP);
Expand Down
33 changes: 33 additions & 0 deletions src/view/menu/menu2/DataUpdateSpeedMenu2Controller.mc
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using Toybox.WatchUi;
using Toybox.System;

class DataUpdateSpeedMenu2Controller extends WatchUi.Menu2InputDelegate {
function initialize() {
Menu2InputDelegate.initialize();
}

function onSelect(item) {
switch (item.getId()) {
case "Fast": {
AppStorage.setValue("DataUpdateSpeed", 400);
WatchUi.popView(WatchUi.SLIDE_RIGHT);
break;
}
case "Medium": {
AppStorage.setValue("DataUpdateSpeed", 1000);
WatchUi.popView(WatchUi.SLIDE_RIGHT);
break;
}
case "Slow": {
AppStorage.setValue("DataUpdateSpeed", 1500);
WatchUi.popView(WatchUi.SLIDE_RIGHT);
break;
}
case "SuperSlow": {
AppStorage.setValue("DataUpdateSpeed", 2000);
WatchUi.popView(WatchUi.SLIDE_RIGHT);
break;
}
}
}
}
39 changes: 39 additions & 0 deletions src/view/menu/menu2/SettingsMenu2Delegate.mc
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,45 @@ class SettingsMenu2Delegate extends WatchUi.Menu2InputDelegate {
WatchUi.pushView(menu, new AppThemeMenu2Controller(), WatchUi.SLIDE_LEFT);
break;
}
case "DataUpdateSpeed": {
var menu = new WatchUi.Menu2({
:title => Rez.Strings.MainMenu_DataUpdateSpeed
});

menu.addItem(
new MenuItem(
Rez.Strings.MainMenu_DataUpdateSpeed_Fast,
null,
"Fast",
null
)
);
menu.addItem(
new MenuItem(
Rez.Strings.MainMenu_DataUpdateSpeed_Medium,
null,
"Medium",
null
)
);
menu.addItem(
new MenuItem(
Rez.Strings.MainMenu_DataUpdateSpeed_Slow,
null,
"Slow",
null
)
);
menu.addItem(
new MenuItem(
Rez.Strings.MainMenu_DataUpdateSpeed_SuperSlow,
null,
"SuperSlow",
null
)
);
WatchUi.pushView(menu, new DataUpdateSpeedMenu2Controller(), WatchUi.SLIDE_LEFT);
}
}
}
}

0 comments on commit a14bdea

Please sign in to comment.