Hi,
I was developing a new watchface.
When I run it on venu2 simulator, all works fine. But if I start it on a fr245 sim, the properties won't be saved.
It is my first time to witness such a weird phenomenon.
You can see the demo here https://youtu.be/_9wMeTRnUHs
Did you encounter the similar issue.
Here is my code snippet, the code works when the memory has a lot available
hourMinFont = Ui.loadResource(Rez.Fonts.HourMinFont);
secTempFont = Ui.loadResource(Rez.Fonts.SecTempFont);
smallCharFont = Ui.loadResource(Rez.Fonts.SmallChars);
iconsFont = Ui.loadResource(Rez.Fonts.IconsFont);
themePallete = WatchUi.loadResource(Rez.JsonData.theme_pallete);
isSquareDevice = layout[21] == 1;
arcLineBackgroundColor = layout[17] == 0? Graphics.COLOR_DK_GRAY:Graphics.COLOR_WHITE;
dateUtils = new LunarDateUtils();
var location = Activity.getActivityInfo().currentLocation;
if (location) {
// Sys.println("the location is not empty");
location = location.toDegrees(); // Array of Doubles.
gLocationLat = location[0].toFloat();
gLocationLon = location[1].toFloat();
Storage.setValue("_gLocationLat", gLocationLat);
Storage.setValue("_gLocationLon", gLocationLon);
}
if(testMode){
Storage.setValue("_gLocationLat", 30.52);
Storage.setValue("_gLocationLon", 114.31);
}
onSettingsChanged();
// Sys.println("show second?:" + alwaysShowSeconds);
do1hz = (Ui.WatchFace has :onPartialUpdate );
canDo1hz=do1hz;
WatchFace.initialize();
initTrial();
}
function checkTheme() {
Sys.println("Checking themes......................");
var theme_code = Application.getApp().getProperty("theme_code");
//这段代码是为了兼容老的配置数据
if(theme_code < 30){
theme_code = ("3"+theme_code).toNumber();
Application.getApp().setProperty("theme_code",theme_code);
}
var last_theme_code = Application.getApp().getProperty("last_theme_code");
if (last_theme_code == -1 || last_theme_code != theme_code) {
Sys.println("A theme change detected......................");
var theme = themePallete[""+theme_code];
backgroundColor = theme[0];
hourColor = theme[0];
Sys.println("hourColor changed in the check theme:"+hourColor);
if(App.getApp().getProperty("WeatherIconColorFollowTheme")){
weatherIconColor = theme[0];
App.getApp().setProperty("WeatherIconColor", theme[1]);
// Sys.println("weatherIconColor"+weatherIconColor);
}
App.getApp().setProperty("hourColor", theme[1]);//颜色的后面一个就是颜色对应的代码编号
bottomMeterAccentColor = theme[0];
App.getApp().setProperty("bottomMeterAccentColor", theme[1]);
topMeterAccentColor = theme[0];
App.getApp().setProperty("topMeterAccentColor", theme[1]);
Application.getApp().setProperty("last_theme_code",theme_code);
}
}
function onSettingsChanged() as Void {
Sys.println("View settings is been updating");
alwaysShowSeconds = App.getApp().getProperty("AlwaysShowSeconds");
showColon = App.getApp().getProperty("ShowColon");
disableSecondDisplay = App.getApp().getProperty("DisableSecondDisplay");
drawShadow = App.getApp().getProperty("DrawShadow");
showAmPmSymbol = App.getApp().getProperty("showAmPmSymbol");
hourColor = getColor(App.getApp().getProperty("hourColor"), Gfx.COLOR_WHITE);
Sys.println("hourColor changed in view settings changed:"+hourColor);
minColor = getColor(App.getApp().getProperty("minuteColor"), Gfx.COLOR_WHITE);
secondColor = getColor(App.getApp().getProperty("secondColor"), Gfx.COLOR_WHITE);
ampmColorProperty = App.getApp().getProperty("ampmColor");
ampmColor = getColor(ampmColorProperty,Gfx.COLOR_WHITE);
useColorfulBatteryIcon = App.getApp().getProperty("useColorfulBatteryIcon");
showBottomDataAreaData = App.getApp().getProperty("ShowBottomDataAreaData");
showTopDataAreaData = App.getApp().getProperty("ShowTopDataAreaData");
topDataAreaDataType = App.getApp().getProperty("TopDataAreaDataType");
bottomDataAreaDataType = App.getApp().getProperty("BottomDataAreaDataType");
grid1DataType = App.getApp().getProperty("Grid1DataType");
grid2DataType = App.getApp().getProperty("Grid2DataType");
grid3DataType = App.getApp().getProperty("Grid3DataType");
grid4DataType = App.getApp().getProperty("Grid4DataType");
grid5DataType = App.getApp().getProperty("Grid5DataType");
grid6DataType = App.getApp().getProperty("Grid6DataType");
grid1DataColor = getColor(App.getApp().getProperty("Grid1DataColor"),Graphics.COLOR_WHITE);
grid2DataColor = getColor(App.getApp().getProperty("Grid2DataColor"),Graphics.COLOR_WHITE);
grid3DataColor = getColor(App.getApp().getProperty("Grid3DataColor"),Graphics.COLOR_WHITE);
grid4DataColor = getColor(App.getApp().getProperty("Grid4DataColor"),Graphics.COLOR_WHITE);
grid5DataColor = getColor(App.getApp().getProperty("Grid5DataColor"),Graphics.COLOR_WHITE);
grid6DataColor = getColor(App.getApp().getProperty("Grid6DataColor"),Graphics.COLOR_WHITE);
topMeterDataType = App.getApp().getProperty("TopMeterDataType");
bottomMeterDataType = App.getApp().getProperty("BottomMeterDataType");
//顶部进度条的色彩
topMeterAccentColor = getColor(App.getApp().getProperty("topMeterAccentColor"),Graphics.COLOR_WHITE);
//底部进度条的色彩
bottomMeterAccentColor = getColor(App.getApp().getProperty("bottomMeterAccentColor"),Graphics.COLOR_WHITE);
lunarDateFormat = App.getApp().getProperty("lunarDateFormat");
solarDateFormat = App.getApp().getProperty("solarDateFormat");
superBatterySaverMode = App.getApp().getProperty("superBatterySaverMode");
disableWeather = App.getApp().getProperty("DisableWeather");
noWeatherEmojiType = App.getApp().getProperty("NoWeatherEmojiType");
topHugeAreaDataType = App.getApp().getProperty("topHugeAreaDataType");
bottomHugeAreaDataType = App.getApp().getProperty("bottomHugeAreaDataType");
weatherIconColor = getColor(App.getApp().getProperty("WeatherIconColor"),Graphics.COLOR_WHITE);
isAPACDevice = Application.getApp().getProperty("IsAPACDevice");
if(!isAPACDevice){
gWeatherProvider = 0;
}
checkTheme();
}