From: 罗正 <1732036298@qq.com> Date: Fri, 10 May 2024 04:04:36 +0000 (+0000) Subject: Merge #156 into xts_origin from refs/changes/156/head X-Git-Tag: release_V1.2.70_20241020_135402~1025^2~8^2^2 X-Git-Url: http://git.snicker.com.cn/?a=commitdiff_plain;h=refs%2Fchanges%2F157%2Ftarget%2F1;p=mirrors%2FFD230.git Merge #156 into xts_origin from refs/changes/156/head Code review from 罗正 * refs/changes/156/head: (4 commits squashed) - 优化下拉界面的数据更新逻辑 如果当前是下拉界面,先更新一次下拉窗口的数据包括,电池电量时间,信号强度等等数据,然后开启一个每2秒更新数据的定时器。 如果不在下拉界面了停止定时器。 遗留一个问题:如果在下拉界面息屏时候停止了定时器,亮屏后需要手动上拉界面再下拉回到下拉界面才能更新数据。 - Merge branch 'xts_origin' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into xts_origin - 1.优化天气显示主界面和applist已经同步显示 遗留问题,手机app同步天气数据时候如果当前界面再天气界面,需要先退出界面在进入才能刷新数据。 2.多国语言包更新需要重新下载资源 - Merge branch 'xts_origin' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into xts_origin Signed-off-by: 罗正 <1732036298@qq.com> Reviewed-by: snickersun@163.com Merged-by: snickersun@163.com CR-link: https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230/change/156 --- diff --git a/code/sdk/application/wearable/fd230app/nativeui/language/Language_xml/input_list_en.txt b/code/sdk/application/wearable/fd230app/nativeui/language/Language_xml/input_list_en.txt index ec7fcb2a7..e56f97edf 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/language/Language_xml/input_list_en.txt +++ b/code/sdk/application/wearable/fd230app/nativeui/language/Language_xml/input_list_en.txt @@ -392,4 +392,30 @@ STR_INSERT_WATCH_SIM_OR_CONNECT_PHONE$Insert watch SIM or connect phone to make STR_ENABLE_BLUETOOTH_CALL$Enable Bluetooth Call STR_ENABLE_BLUETOOTH_CALL_NOTE$The solution:\n1. IPhone\nPlease go to the phone \"Settings\" → \"Bluetooth\" list to find\n“KUMI_XXXX”\nClick and try again\n\n2. Android phones\nPlease go to the phone \"Settings\" → \"Bluetooth\" list to find\n“KUMI_XXXX”\nClick the icon on the right to enter Bluetooth Settings\nEnable the call and media functions and try again STR_SIM_CARD_ERROR$SIM Card Error -STR_CHECK_SIM_CARD_INSERTION$Check if the watch’s SIM card is properly inserted \ No newline at end of file +STR_CHECK_SIM_CARD_INSERTION$Check if the watch’s SIM card is properly inserted +STR_WEATHER_REPORT$Weather report +STR_ULTRAVIOLET$Ultraviolet +STR_WIND_SPEED$WindSpeed +STR_HUMIDITY$Humidity +STR_NEXT_7_DAYS$Next 7 Days +STR_GET_WEATHER_ERROR$No weather information was obtained Please go to APP Update +STR_MUSIC_SOURCE$Music source +STR_MOBILE_MUSIC$Mobile music +STR_WATCH_MUSIC$Watch music +STR_MUSIC_SOURCE$Music source +STR_MUSIC_LIST$Music list +STR_BLUETOOTH_CONNECTION_FAILED$Bluetooth connection failed +STR_SCANNING_BINDING$Scanning binding +STR_DEVICE_BINDING$Device binding +STR_DEVICE_BINDING_NOTE$XX wants to connect and bind with you +STR_EQUIPMENT_UNTYING$Equipment untying +STR_EQUIPMENT_UNTYING_NOTE$XX would like to unbind you +STR_DRINK_WATER_REMINDER$Drink water reminder +STR_DRINK_WATER_REMINDER_NOTE$Time for some water! And stay hydrated (๑•̀ㅂ•́) +STR_SEDENTARY_REMINDER$Sedentary reminder +STR_SEDENTARY_REMINDER_NOTE$You haven't moved for XX hours. Get up and move. +STR_SYSTEM_UPGRADING$System upgrading +STR_NEWDEVICE_BIND_REMIND_NOTE$The current device is already tied to the Iphone 13 pro\n\nContinuing to connect will unbind the Iphone 13 pro and restore the watch to factory Settings (will erase the watch data)\n\nWhether to continue the operation +STR_TABULAR_DISPLAY$Tabular display +STR_GRID_DISPLAY$Grid display +STR_CELLULAR_DISPLAY$Cellular display \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/language/Language_xml/input_list_zh.txt b/code/sdk/application/wearable/fd230app/nativeui/language/Language_xml/input_list_zh.txt index 8573f257a..c8c81c5d5 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/language/Language_xml/input_list_zh.txt +++ b/code/sdk/application/wearable/fd230app/nativeui/language/Language_xml/input_list_zh.txt @@ -428,4 +428,30 @@ STR_INSERT_WATCH_SIM_OR_CONNECT_PHONE$请插入手表SIM卡或连接手机并确 STR_ENABLE_BLUETOOTH_CALL$开启蓝牙通话 STR_ENABLE_BLUETOOTH_CALL_NOTE$解决方法:\n1.苹果手机\n请前往手机“设置”→“蓝牙”列表找到\n“KUMI_XXXX”\n并点击后重试\n\n2.安卓手机\n请前往手机“设置”→“蓝牙”列表找到\n“KUMI_XXXX”\n点击右侧图标进入蓝牙设置\n开启通话及媒体功能后重试 STR_SIM_CARD_ERROR$Sim卡异常 -STR_CHECK_SIM_CARD_INSERTION$SIM卡拨号异常,请检查手表SIM卡是否正确插入 \ No newline at end of file +STR_CHECK_SIM_CARD_INSERTION$SIM卡拨号异常,请检查手表SIM卡是否正确插入 +STR_WEATHER_REPORT$气象报告 +STR_ULTRAVIOLET$紫外线 +STR_WIND_SPEED$风速 +STR_HUMIDITY$湿度 +STR_NEXT_7_DAYS$未来七天 +STR_GET_WEATHER_ERROR$未获取到天气信息请前往APP更新 +STR_MUSIC_SOURCE$音乐来源 +STR_MOBILE_MUSIC$手机音乐 +STR_WATCH_MUSIC$手表音乐 +STR_MUSIC_SOURCE$音乐来源 +STR_MUSIC_LIST$音乐列表 +STR_BLUETOOTH_CONNECTION_FAILED$蓝牙连接失败 +STR_SCANNING_BINDING$扫码绑定 +STR_DEVICE_BINDING$设备绑定 +STR_DEVICE_BINDING_NOTE$XX想要与你进行连接绑定 +STR_EQUIPMENT_UNTYING$设备解绑 +STR_EQUIPMENT_UNTYING_NOTE$XX 想要与你进行解绑 +STR_DRINK_WATER_REMINDER$喝水提醒 +STR_DRINK_WATER_REMINDER_NOTE$该喝水啦!记得按时保持水分充足(๑•̀ㅂ•́)و✧ +STR_SEDENTARY_REMINDER$久坐提醒 +STR_SEDENTARY_REMINDER_NOTE$你已经XX小时未活动了,站起来活动一下吧。 +STR_SYSTEM_UPGRADING$系统升级中 +STR_NEWDEVICE_BIND_REMIND_NOTE$当前设备已经与 XX 绑定继续连接操作会解除与 XX 的绑定并将手表恢复出厂设置(会清空手表数据)是否继续此操作 +STR_TABULAR_DISPLAY$列表显示 +STR_GRID_DISPLAY$网格显示 +STR_CELLULAR_DISPLAY$蜂窝显示 \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/language/Language_xml/language_en.xml b/code/sdk/application/wearable/fd230app/nativeui/language/Language_xml/language_en.xml index 61eda9752..99f7a0c49 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/language/Language_xml/language_en.xml +++ b/code/sdk/application/wearable/fd230app/nativeui/language/Language_xml/language_en.xml @@ -394,4 +394,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/code/sdk/application/wearable/fd230app/nativeui/language/Language_xml/language_zh.xml b/code/sdk/application/wearable/fd230app/nativeui/language/Language_xml/language_zh.xml index 2a085ceaf..b772e48c0 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/language/Language_xml/language_zh.xml +++ b/code/sdk/application/wearable/fd230app/nativeui/language/Language_xml/language_zh.xml @@ -430,4 +430,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/code/sdk/application/wearable/fd230app/nativeui/language/font/en.lang b/code/sdk/application/wearable/fd230app/nativeui/language/font/en.lang index ae14358fa..65675412e 100644 Binary files a/code/sdk/application/wearable/fd230app/nativeui/language/font/en.lang and b/code/sdk/application/wearable/fd230app/nativeui/language/font/en.lang differ diff --git a/code/sdk/application/wearable/fd230app/nativeui/language/font/ja.lang b/code/sdk/application/wearable/fd230app/nativeui/language/font/ja.lang index 65427ed9d..f5336af95 100644 Binary files a/code/sdk/application/wearable/fd230app/nativeui/language/font/ja.lang and b/code/sdk/application/wearable/fd230app/nativeui/language/font/ja.lang differ diff --git a/code/sdk/application/wearable/fd230app/nativeui/language/font/ui_resource_string.h b/code/sdk/application/wearable/fd230app/nativeui/language/font/ui_resource_string.h index 9e192532a..47818ab70 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/language/font/ui_resource_string.h +++ b/code/sdk/application/wearable/fd230app/nativeui/language/font/ui_resource_string.h @@ -397,64 +397,87 @@ enum UIResourceTextId : uint16_t { STR_ENABLE_BLUETOOTH_CALL_NOTE = 384, STR_SIM_CARD_ERROR = 385, STR_CHECK_SIM_CARD_INSERTION = 386, - STR_RANGE_MILE = 387, - STR_CLOSE = 388, - STR_MORE_APP = 389, - STR_SAVENOTE = 390, - STR_SAVEBACK = 391, - STR_SAVEASK = 392, - STR_BLOOD = 393, - STR_CHECK = 394, - STR_CHECKNEW = 395, - STR_CHECKTIME = 396, - STR_CHECKLONG = 397, - STR_CHECKNO = 398, - STR_CHECKNOTE = 399, - STR_CHECKON = 400, - STR_CHECKSTOP = 401, - STR_CHECKERROR = 402, - STR_WAERKEEP = 403, - STR_WEARRE = 404, - STR_WEARREADY = 405, - STR_RECHECK = 406, - STR_CHECKEWARN = 407, - STR_BLOODSHORT = 408, - STR_HEARTNOTE = 409, - STR_KONW = 410, - STR_EXPLAIN = 411, - STR_HEARTREST = 412, - STR_HEARTDATA = 413, - STR_HEARTTITLE = 414, - STR_HEARTMAX = 415, - STR_HEARTMIN = 416, - STR_TRAINGNO = 417, - STR_TRAINGGO = 418, - STR_MESSAGE = 419, - STR_MESSAGENO = 420, - STR_DIS = 421, - STR_DUR = 422, - STR_STANDUP = 423, - STR_SLEEPHOUR = 424, - STR_SLEEPMGOAL = 425, - STR_REATTIME = 426, - STR_SLEEPTIME = 427, - STR_WALKTIME = 428, - STR_DISTURB = 429, - STR_DISTURBNOTE = 430, - STR_MORNNING = 431, - STR_NOW = 432, - STR_NAP = 433, - STR_TACK = 434, - STR_CLICK = 435, - STR_TACKNUM = 436, - STR_MON = 437, - STR_TUES = 438, - STR_WEDNES = 439, - STR_THURS = 440, - STR_FRI = 441, - STR_SATUR = 442, - STR_SUN = 443, - STR_MAX_ID = 444, + STR_WEATHER_REPORT = 387, + STR_ULTRAVIOLET = 388, + STR_WIND_SPEED = 389, + STR_HUMIDITY = 390, + STR_NEXT_7_DAYS = 391, + STR_GET_WEATHER_ERROR = 392, + STR_MUSIC_SOURCE = 393, + STR_MOBILE_MUSIC = 394, + STR_WATCH_MUSIC = 395, + STR_MUSIC_LIST = 396, + STR_BLUETOOTH_CONNECTION_FAILED = 397, + STR_SCANNING_BINDING = 398, + STR_DEVICE_BINDING = 399, + STR_DEVICE_BINDING_NOTE = 400, + STR_EQUIPMENT_UNTYING = 401, + STR_EQUIPMENT_UNTYING_NOTE = 402, + STR_DRINK_WATER_REMINDER = 403, + STR_DRINK_WATER_REMINDER_NOTE = 404, + STR_SEDENTARY_REMINDER = 405, + STR_SEDENTARY_REMINDER_NOTE = 406, + STR_SYSTEM_UPGRADING = 407, + STR_NEWDEVICE_BIND_REMIND_NOTE = 408, + STR_TABULAR_DISPLAY = 409, + STR_RANGE_MILE = 410, + STR_CLOSE = 411, + STR_MORE_APP = 412, + STR_SAVENOTE = 413, + STR_SAVEBACK = 414, + STR_SAVEASK = 415, + STR_BLOOD = 416, + STR_CHECK = 417, + STR_CHECKNEW = 418, + STR_CHECKTIME = 419, + STR_CHECKLONG = 420, + STR_CHECKNO = 421, + STR_CHECKNOTE = 422, + STR_CHECKON = 423, + STR_CHECKSTOP = 424, + STR_CHECKERROR = 425, + STR_WAERKEEP = 426, + STR_WEARRE = 427, + STR_WEARREADY = 428, + STR_RECHECK = 429, + STR_CHECKEWARN = 430, + STR_BLOODSHORT = 431, + STR_HEARTNOTE = 432, + STR_KONW = 433, + STR_EXPLAIN = 434, + STR_HEARTREST = 435, + STR_HEARTDATA = 436, + STR_HEARTTITLE = 437, + STR_HEARTMAX = 438, + STR_HEARTMIN = 439, + STR_TRAINGNO = 440, + STR_TRAINGGO = 441, + STR_MESSAGE = 442, + STR_MESSAGENO = 443, + STR_DIS = 444, + STR_DUR = 445, + STR_STANDUP = 446, + STR_SLEEPHOUR = 447, + STR_SLEEPMGOAL = 448, + STR_REATTIME = 449, + STR_SLEEPTIME = 450, + STR_WALKTIME = 451, + STR_DISTURB = 452, + STR_DISTURBNOTE = 453, + STR_MORNNING = 454, + STR_NOW = 455, + STR_NAP = 456, + STR_TACK = 457, + STR_CLICK = 458, + STR_TACKNUM = 459, + STR_MON = 460, + STR_TUES = 461, + STR_WEDNES = 462, + STR_THURS = 463, + STR_FRI = 464, + STR_SATUR = 465, + STR_SUN = 466, + STR_MAX_ID = 467, }; // UIResourceTextId enum FontLanguageId : uint8_t { diff --git a/code/sdk/application/wearable/fd230app/nativeui/language/font/zh.lang b/code/sdk/application/wearable/fd230app/nativeui/language/font/zh.lang index f7fe8d220..c5b1081d1 100644 Binary files a/code/sdk/application/wearable/fd230app/nativeui/language/font/zh.lang and b/code/sdk/application/wearable/fd230app/nativeui/language/font/zh.lang differ diff --git a/code/sdk/application/wearable/fd230app/nativeui/weather/include/FutureWeatherView.h b/code/sdk/application/wearable/fd230app/nativeui/weather/include/FutureWeatherView.h index eeeaa5011..82c9edeeb 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/weather/include/FutureWeatherView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/weather/include/FutureWeatherView.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-03-30 09:14:38 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-04-15 14:24:52 + * @LastEditTime: 2024-05-10 11:36:50 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/weather/include/FutureWeatherView.h */ #ifndef FUTURE_WEATHER_VIEW_H diff --git a/code/sdk/application/wearable/fd230app/nativeui/weather/include/GetWeatherDataErrorView.h b/code/sdk/application/wearable/fd230app/nativeui/weather/include/GetWeatherDataErrorView.h index a45a17ab8..4f84f2d14 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/weather/include/GetWeatherDataErrorView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/weather/include/GetWeatherDataErrorView.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-03-30 09:14:38 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-04-12 16:22:24 + * @LastEditTime: 2024-05-10 10:49:52 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/weather/include/GetWeatherDataErrorView.h */ #ifndef Get_WEATHER_DATA_ERROR_VIEW_H diff --git a/code/sdk/application/wearable/fd230app/nativeui/weather/include/MainWeatherPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/weather/include/MainWeatherPresenter.h index 1950dbd2b..d149d71e5 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/weather/include/MainWeatherPresenter.h +++ b/code/sdk/application/wearable/fd230app/nativeui/weather/include/MainWeatherPresenter.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-01-29 15:37:44 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-04-13 10:09:34 + * @LastEditTime: 2024-05-10 10:58:31 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/weather/include/MainWeatherPresenter.h */ #ifndef MAIN_WEATHER_PRESENTER_H @@ -51,6 +51,7 @@ namespace OHOS void OnSwipe(UISwipeView &view) override; WeatherModel *weatherModel{nullptr}; + bool X_DRAG_FLAG{false}; }; } // namespace OHOS diff --git a/code/sdk/application/wearable/fd230app/nativeui/weather/include/MainWeatherView.h b/code/sdk/application/wearable/fd230app/nativeui/weather/include/MainWeatherView.h index 04c1807f6..1e6064f9f 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/weather/include/MainWeatherView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/weather/include/MainWeatherView.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-01-29 15:37:44 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-04-13 10:04:53 + * @LastEditTime: 2024-05-10 11:22:41 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/weather/include/MainWeatherView.h */ #ifndef MAIN_WEATHER_VIEW_H @@ -38,7 +38,9 @@ namespace OHOS AppGroupView *WeatherViewPageInit(void); AppGroupView *WeatherReportViewPageInit(void); AppGroupView *FutureWeatherViewPageInit(void); + UIScrollView *WeatherDataErrorViewPageInit(void); WeatherView *GetWeatherView(void); + UIView *GetWeatherPageView(void); WeatherReportView *GetWeatherReportView(void); FutureWeatherView *GetFutureWeatherView(void); @@ -53,11 +55,11 @@ namespace OHOS WeatherReportView *weatherReportView{nullptr}; FutureWeatherView *futureWeatherView{nullptr}; GetWeatherDataErrorView *getWeatherDataErrorView{nullptr}; + private: int16_t maxPage = MAX_WEATHERVIEW; UISwipeView *weatherSwipeViewList{nullptr}; // 天气滑动视图列表 AppGroupView *recordCard[MAX_WEATHERVIEW]{nullptr}; - bool pageStatus[MAX_WEATHERVIEW]{false}; AppGroupView *CreatePage(int32_t WeatherPageId); }; } // namespace OHOS diff --git a/code/sdk/application/wearable/fd230app/nativeui/weather/include/WeatherModel.h b/code/sdk/application/wearable/fd230app/nativeui/weather/include/WeatherModel.h index b3fa3779d..c9f5a2dd3 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/weather/include/WeatherModel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/weather/include/WeatherModel.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-04-08 18:40:20 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-04-16 09:57:34 + * @LastEditTime: 2024-05-09 15:46:16 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/weather/include/WeatherModel.h */ #ifndef WEATHER_MODEL_H @@ -61,6 +61,7 @@ namespace OHOS } #endif /* __cplusplus */ +#define DAYS_OF_THE_WEEK 7 #define weather_src "/user/res/weather/weather65x65/" static const char *weather65x65[] = { @@ -102,13 +103,16 @@ namespace OHOS std::string GetHumidity(); std::string GetWindScale(); std::string GetUVIndex(); - static uint8_t WEATHER_DATA_VALID; // 天气数据是否有效 + /* -------------------------------------------------------------------------- */ + bool GetWeatherDataIsValid(void); + void SetWeatherDataIsValid(bool value); private: WeatherModel(); WeatherModel(const WeatherModel &) = delete; WeatherModel &operator=(const WeatherModel &) = delete; virtual ~WeatherModel(); - FutureWeather FutureWeatherItem[7]; + FutureWeather FutureWeatherItem[DAYS_OF_THE_WEEK]; + bool WEATHER_DATA_VALID{false}; // 天气数据是否有效 }; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/weather/include/WeatherReportView.h b/code/sdk/application/wearable/fd230app/nativeui/weather/include/WeatherReportView.h index 553edbf14..295fe46d2 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/weather/include/WeatherReportView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/weather/include/WeatherReportView.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-03-30 09:14:38 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-04-13 18:01:59 + * @LastEditTime: 2024-05-09 17:49:13 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/weather/include/WeatherReportView.h */ #ifndef WEATHER_REPORT_VIEW_H @@ -31,7 +31,8 @@ namespace OHOS int16_t height; int16_t fontSize; // 字体大小 int16_t lineHeigh; // 行高 - std::string text; // 文本 + std::string text; // 文本 + uint16_t textId; uint8_t lineBreakMode; // 断行模式。 }; WeatherReportView(); @@ -49,6 +50,7 @@ namespace OHOS const char **CreateImagePathsArray(const char *basePath, const char *fileExtension, int numImages); void FreeImagePathsArray(const char **imagePaths, const int numImages); UILabelExt *SetUpLabel(LabelConfig &labelconfig); // 设置标签 + UILabelExt *SetUpLabelExt(LabelConfig &labelconfig); bool WeatherReportViewLabelInit(void); bool WeatherReportViewImageAnimatorViewInit(void); UILabelExt *title{nullptr}; // 标题 diff --git a/code/sdk/application/wearable/fd230app/nativeui/weather/src/FutureWeatherView.cpp b/code/sdk/application/wearable/fd230app/nativeui/weather/src/FutureWeatherView.cpp index 4076d5bd8..51f24c16d 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/weather/src/FutureWeatherView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/weather/src/FutureWeatherView.cpp @@ -2,13 +2,15 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-01-29 15:37:44 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-04-15 15:01:52 + * @LastEditTime: 2024-05-10 11:19:59 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/weather/src/FutureWeatherView.cpp */ #include "weather/include/FutureWeatherView.h" #include "wearable_log.h" #include "weather/include/WeatherModel.h" #include "common/image_cache_manager.h" +#include "language/font/ui_resource_string.h" +#include "weather/include/WeatherModel.h" namespace OHOS { @@ -52,8 +54,6 @@ namespace OHOS bool FutureWeatherView::InitPage(void) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "FutureWeatherView::InitPage"); - /* -------------------------------------------------------------------------- */ - /* -------------------------------------------------------------------------- */ Title = new UILabelExt(); if (Title == nullptr) @@ -64,10 +64,9 @@ namespace OHOS Title->SetPosition(93, 52, 280, 47); Title->SetStyle(STYLE_TEXT_FONT, 30); Title->SetStyle(STYLE_LINE_HEIGHT, 35); - Title->SetText("未来7天"); + Title->SetTextId(STR_NEXT_7_DAYS); Title->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE); Title->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - Title->SetRollSpeed(40); Title->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); Add(Title); /* -------------------------------------------------------------------------- */ @@ -108,6 +107,9 @@ namespace OHOS } SetDraggable(true); SetTouchable(true); + /* -------------------------------------------------------------------------- */ + WeatherModel::GetInstance().InitFutureWeatherItem(); + /* -------------------------------------------------------------------------- */ return true; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/weather/src/GetWeatherDataErrorView.cpp b/code/sdk/application/wearable/fd230app/nativeui/weather/src/GetWeatherDataErrorView.cpp index 7a2087494..1e36a452d 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/weather/src/GetWeatherDataErrorView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/weather/src/GetWeatherDataErrorView.cpp @@ -2,12 +2,14 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-01-29 15:37:44 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-04-13 19:23:06 + * @LastEditTime: 2024-05-10 10:49:39 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/weather/src/GetWeatherDataErrorView.cpp */ #include "weather/include/GetWeatherDataErrorView.h" #include "wearable_log.h" #include "weather/include/MainWeatherPresenter.h" +#include "language/font/ui_resource_string.h" +#include "uicomponents/UIComponents.h" /* 天气获取数据失败后会调用该视图*/ namespace OHOS @@ -46,13 +48,6 @@ namespace OHOS scrollView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); scrollView->SetViewId(GETWEATHERDATAERRORVIEW); scrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff); - UIView::OnDragListener *listener = static_cast(MainWeatherPresenter::GetInstance()); - if (listener == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "listener is nullptr!!"); - return nullptr; - } - scrollView->SetOnDragListener(listener); /* -------------------------------------------------------------------------- */ image = new UIImageView(); if (image == nullptr) @@ -74,13 +69,14 @@ namespace OHOS return nullptr; } label->SetPosition(33, 268, 400, 70); - label->SetStyle(STYLE_TEXT_FONT, 26); + label->SetStyle(STYLE_TEXT_FONT, 30); label->SetStyle(STYLE_LINE_HEIGHT, 35); - label->SetText("未获取到天气信息\n请前往APP更新"); + SetLabelId(label,STR_GET_WEATHER_ERROR); label->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - label->SetRollSpeed(40); - label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 26); + label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + scrollView->Add(label); } return scrollView; diff --git a/code/sdk/application/wearable/fd230app/nativeui/weather/src/MainWeatherPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/weather/src/MainWeatherPresenter.cpp index 92415d6bc..a882bd326 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/weather/src/MainWeatherPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/weather/src/MainWeatherPresenter.cpp @@ -5,6 +5,7 @@ #include "common/key_code.h" #include #include +#include "UiConfig.h" namespace OHOS { @@ -43,35 +44,32 @@ namespace OHOS void MainWeatherPresenter::OnResume(void) { - weatherModel->InitFutureWeatherItem(); Presenter::OnResume(); } void MainWeatherPresenter::OnStop(void) { - Presenter::OnStop(); } bool MainWeatherPresenter::OnDrag(UIView &view, const DragEvent &event) { UNUSED(view); - UNUSED(event); - + if ((event.GetDeltaX() > X_DRAG_OFFSET) && (event.GetDeltaX() > (DOUBLES * MATH_ABS(event.GetDeltaY())))) // 拖动过程中判断是否是水平滑动 + { + MainWeatherPresenter::X_DRAG_FLAG = true; + } return true; } bool MainWeatherPresenter::OnDragEnd(UIView &view, const DragEvent &event) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, " MainWeatherPresenter::OnDragEnd"); - if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) - { - NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST); - return true; - } - if (strcmp(view.GetViewId(), GETWEATHERDATAERRORVIEW) == 0 && event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) + UNUSED(view); + if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && MainWeatherPresenter::X_DRAG_FLAG) { - NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST); + NativeAbility::GetInstance().Back(); + X_DRAG_FLAG = false; } return true; } @@ -94,8 +92,7 @@ namespace OHOS // 如果是power键就返回上一级 if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 0 && uapi_get_screen_state() == 0) { - uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId(); - NativeAbility::GetInstance().ChangeSlice(preSlice); + NativeAbility::GetInstance().Back(); } return true; } @@ -116,6 +113,7 @@ namespace OHOS if (view.GetCurrentPage() == MAINWEATHERVIEW) { view.SetIntercept(false); + MainWeatherView::GetInstance()->GetFutureWeatherView()->GetFutureWeatherList()->RefreshList(); } else { diff --git a/code/sdk/application/wearable/fd230app/nativeui/weather/src/MainWeatherView.cpp b/code/sdk/application/wearable/fd230app/nativeui/weather/src/MainWeatherView.cpp index f98918fe7..002044dba 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/weather/src/MainWeatherView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/weather/src/MainWeatherView.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-01-29 15:37:44 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-04-15 15:06:51 + * @LastEditTime: 2024-05-10 11:31:08 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/weather/src/MainWeatherView.cpp */ #include "weather/include/MainWeatherView.h" @@ -93,68 +93,74 @@ namespace OHOS return weatherSwipeViewList; } + // 获取天气页面视图 + UIView *MainWeatherView::GetWeatherPageView() + { + if (WeatherModel::GetInstance().GetWeatherDataIsValid()) // 如果天气数据有效 + { + return dynamic_cast(MainWeatherViewInit()); + } + else + { + return dynamic_cast(WeatherDataErrorViewPageInit()); + } + return nullptr; + } + void MainWeatherView::OnStart() { View::OnStart(); - if (WeatherModel::WEATHER_DATA_VALID) + RootView::GetInstance()->Add(GetWeatherPageView()); + if (weatherSwipeViewList != nullptr) { - MainWeatherViewInit(); - /* -------------------------------------------------------------------------- */ - if (weatherSwipeViewList != nullptr) + UIView::OnClickListener *weatherOnClickListener = (UIView::OnClickListener *)OHOS::MainWeatherPresenter::GetInstance(); + if (weatherOnClickListener == nullptr) { - UIView::OnClickListener *weatherOnClickListener = (UIView::OnClickListener *)OHOS::MainWeatherPresenter::GetInstance(); - if (weatherOnClickListener == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "weatherOnClickListener new fail"); - return; - } - - UIView::OnDragListener *weatherOnDragListener = (UIView::OnDragListener *)OHOS::MainWeatherPresenter::GetInstance(); - if (weatherOnDragListener == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "weatherOnDragListener new fail"); - return; - } + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "weatherOnClickListener new fail"); + return; + } - UISwipeView::OnSwipeListener *weatherOnSwipeListener = (UISwipeView::OnSwipeListener *)OHOS::MainWeatherPresenter::GetInstance(); - if (weatherOnSwipeListener == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "weatherOnSwipeListener new fail"); - return; - } + UIView::OnDragListener *weatherOnDragListener = (UIView::OnDragListener *)OHOS::MainWeatherPresenter::GetInstance(); + if (weatherOnDragListener == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "weatherOnDragListener new fail"); + return; + } - weatherSwipeViewList->SetOnClickListener(weatherOnClickListener); - weatherSwipeViewList->SetOnDragListener(weatherOnDragListener); - weatherSwipeViewList->SetOnSwipeListener(weatherOnSwipeListener); + UISwipeView::OnSwipeListener *weatherOnSwipeListener = (UISwipeView::OnSwipeListener *)OHOS::MainWeatherPresenter::GetInstance(); + if (weatherOnSwipeListener == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "weatherOnSwipeListener new fail"); + return; } - /* -------------------------------------------------------------------------- */ - RootView::GetInstance()->Add(weatherSwipeViewList); + weatherSwipeViewList->SetOnClickListener(weatherOnClickListener); + weatherSwipeViewList->SetOnDragListener(weatherOnDragListener); + weatherSwipeViewList->SetOnSwipeListener(weatherOnSwipeListener); } else { - getWeatherDataErrorView = new GetWeatherDataErrorView(); - if (getWeatherDataErrorView == nullptr) + UIView::OnDragListener *dragListener = static_cast(MainWeatherPresenter::GetInstance()); + if (dragListener == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "getWeatherDataErrorView new fail!!"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "dragListener is nullptr!!"); return; } - RootView::GetInstance()->Add(getWeatherDataErrorView->GetWeatherDataErrorViewInit()); + getWeatherDataErrorView->GetWeatherDataErrorViewInit()->SetOnDragListener(dragListener); } - /* -------------------------------------------------------------------------- */ + /* --------------------------------- 添加按键监听 --------------------------------- */ RootView::OnKeyActListener *keyactListener = (RootView::OnKeyActListener *)OHOS::MainWeatherPresenter::GetInstance(); RootView::GetInstance()->SetOnKeyActListener(keyactListener); + /* -------------------------------------------------------------------------- */ } void MainWeatherView::OnSetUpView() { View::OnSetUpView(); - Draw(); } void MainWeatherView::OnTearDownView() { - View::OnTearDownView(); return; } @@ -225,6 +231,20 @@ namespace OHOS return futureWeatherView; } + /* + * @brief 获取天气数据失败视图初始化 + */ + UIScrollView *MainWeatherView::WeatherDataErrorViewPageInit(void) + { + getWeatherDataErrorView = new GetWeatherDataErrorView(); + if (getWeatherDataErrorView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "getWeatherDataErrorView new fail!!"); + return nullptr; + } + return getWeatherDataErrorView->GetWeatherDataErrorViewInit(); + } + struct MainWeatherViewMapper { const int16_t viewId; diff --git a/code/sdk/application/wearable/fd230app/nativeui/weather/src/WeatherControlView.cpp b/code/sdk/application/wearable/fd230app/nativeui/weather/src/WeatherControlView.cpp index 90743448a..987ba3103 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/weather/src/WeatherControlView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/weather/src/WeatherControlView.cpp @@ -21,11 +21,17 @@ namespace OHOS RemoveAll(); if (mainWeatherView != nullptr) { - delete weatherOnSwipeListener; - weatherOnSwipeListener = nullptr; - - delete mainWeatherView; - mainWeatherView = nullptr; + if (weatherOnSwipeListener != nullptr) + { + delete weatherOnSwipeListener; + weatherOnSwipeListener = nullptr; + } + + if (mainWeatherView != nullptr) + { + delete mainWeatherView; + mainWeatherView = nullptr; + } } } } @@ -39,20 +45,28 @@ namespace OHOS WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "WeatherView::new mainweatherView fail!"); return false; } - UISwipeView *weatherSwipView = mainWeatherView->MainWeatherViewInit(); - if (weatherSwipView == nullptr) + + if (WeatherModel::GetInstance().GetWeatherDataIsValid()) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "mainWeatherView->MainWeatherViewInit() == nullptr!!"); - return false; + UISwipeView *weatherSwipView = dynamic_cast(mainWeatherView->GetWeatherPageView()); + if (weatherSwipView == nullptr) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "mainWeatherView->MainWeatherViewInit() == nullptr!!"); + return false; + } + weatherOnSwipeListener = static_cast(new WeatherControlViewOnSwipeListener()); + if (weatherOnSwipeListener == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "weatherOnSwipeListener new fail"); + return false; + } + weatherSwipView->SetOnSwipeListener(weatherOnSwipeListener); + Add(weatherSwipView); } - weatherOnSwipeListener = static_cast(new WeatherControlViewOnSwipeListener()); - if (weatherOnSwipeListener == nullptr) + else { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "weatherOnSwipeListener new fail"); - return false; + Add(mainWeatherView->GetWeatherPageView()); } - weatherSwipView->SetOnSwipeListener(weatherOnSwipeListener); - Add(weatherSwipView); return true; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/weather/src/WeatherModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/weather/src/WeatherModel.cpp index 72bd30d33..39cfd0b14 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/weather/src/WeatherModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/weather/src/WeatherModel.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-04-08 18:40:09 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-04-18 18:42:24 + * @LastEditTime: 2024-05-10 11:27:16 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/weather/src/WeatherModel.cpp */ #include "weather/include/WeatherModel.h" @@ -38,7 +38,7 @@ namespace OHOS Weather_data_t_now.temp = temp; Weather_data_t_now.iconNight = iconNight; - WeatherModel::WEATHER_DATA_VALID = 1; + WeatherModel::GetInstance().SetWeatherDataIsValid(true); } /* @@ -78,29 +78,13 @@ namespace OHOS } } - void jsonCheck_weather(uint8_t *buf); #if __cplusplus } #endif /* __cplusplus */ - static constexpr const char json_data[] = - "{\"now\": {\"humidity\":89,\"windScale\":\"2\",\"textNight\":\"多云\",\"uvIndex\":3,\"temp\":24,\"iconNight\":4}," - "\"address\": {\"lat\":225737664,\"atm\":\"1010\",\"city\":\"深圳\",\"subLocality\":\"宝安\",\"lon\":1138535138}," - "\"daily\": [{\"tempMin\":22,\"iconDay\":6,\"fxDate\":1712505600,\"textDay\":\"阵雨\",\"tempMax\":29}," - "{\"tempMax\":27,\"textDay\":\"多云\",\"iconDay\":3,\"fxDate\":1712592000,\"tempMin\":22}," - "{\"tempMax\":29,\"fxDate\":1712678400,\"textDay\":\"多云\",\"iconDay\":3,\"tempMin\":22}," - "{\"tempMin\":23,\"textDay\":\"多云\",\"fxDate\":1712764800,\"tempMax\":30,\"iconDay\":3}," - "{\"fxDate\":1712851200,\"textDay\":\"多云\",\"iconDay\":3,\"tempMax\":31,\"tempMin\":24}," - "{\"fxDate\":1712937600,\"iconDay\":3,\"tempMax\":31,\"tempMin\":24,\"textDay\":\"多云\"}," - "{\"fxDate\":1713024000,\"textDay\":\"多云\",\"iconDay\":3,\"tempMax\":29,\"tempMin\":25}]," - "\"code\":1}"; - //static constexpr const char json_data[] = "{\"now\":{\"humidity\":89,\"windScale\":\"2\",\"textNight\":\"多云\",\"uvIndex\":3,\"temp\":24,\"iconNight\":4},\"address\":{\"lat\":225737664,\"atm\":\"1010\",\"city\":\"深圳\",\"subLocality\":\"宝安\",\"lon\":1138535138},\"daily\":[{\"tempMin\":22,\"iconDay\":6,\"fxDate\":1712505600,\"textDay\":\"阵雨\",\"tempMax\":29},{\"tempMax\":27,\"textDay\":\"多云\",\"iconDay\":3,\"fxDate\":1712592000,\"tempMin\":22},{\"tempMax\":29,\"fxDate\":1712678400,\"textDay\":\"多云\",\"iconDay\":3,\"tempMin\":22},{\"tempMin\":23,\"textDay\":\"多云\",\"fxDate\":1712764800,\"tempMax\":30,\"iconDay\":3},{\"fxDate\":1712851200,\"textDay\":\"多云\",\"iconDay\":3,\"tempMax\":31,\"tempMin\":24},{\"fxDate\":1712937600,\"iconDay\":3,\"tempMax\":31,\"tempMin\":24,\"textDay\":\"多云\"},{\"fxDate\":1713024000,\"textDay\":\"多云\",\"iconDay\":3,\"tempMax\":29,\"tempMin\":25}],\"code\":1}"; - /* -------------------------------------------------------------------------- */ - uint8_t WeatherModel::WEATHER_DATA_VALID = 0; WeatherModel::WeatherModel() { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "WeatherModel::WeatherModel"); - // jsonCheck_weather((uint8_t *)json_data); } WeatherModel::~WeatherModel() @@ -117,20 +101,23 @@ namespace OHOS void WeatherModel::InitFutureWeatherItem() { MainWeatherView *p_MainWeatherView = MainWeatherView::GetInstance(); - for (uint8_t i = 0; i < 7; i++) + if (p_MainWeatherView == nullptr) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainWeatherView::GetInstance fail!!"); + return; + } + for (uint8_t i = 0; i < DAYS_OF_THE_WEEK; i++) { FutureWeatherItem[i].iconDay = GetWeather_data_seven_data_iconDay(i); FutureWeatherItem[i].fxDate = GetWeather_data_seven_data_fxDate(i); FutureWeatherItem[i].tempMinAndMax = GetWeather_data_seven_data_tempMinAndtempMax(i); - // FutureWeatherItem[i].tempMin = GetWeather_data_seven_data_tempMin(i); - // FutureWeatherItem[i].tempMax = GetWeather_data_seven_data_tempMax(i); p_MainWeatherView->GetFutureWeatherView()->AddFutureWeatherItemToList(FutureWeatherItem[i]); } } void WeatherModel::TimestampToMonthDayString(time_t timestamp, char *buffer) { - // 将时间戳转换成tm结构 + // 将时间戳转换成tm结构 struct tm timeinfo; localtime_r(×tamp, &timeinfo); @@ -235,9 +222,9 @@ namespace OHOS /*获取湿度*/ std::string WeatherModel::GetHumidity() { - int humidity = Weather_data_t_now.humidity; - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "humidity:%d", humidity); - return std::to_string(humidity); + std::string humidity = std::to_string(Weather_data_t_now.humidity) + "%"; + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "humidity:%s", humidity.c_str()); + return humidity; } /*获取风速*/ @@ -251,8 +238,20 @@ namespace OHOS /*获取紫外线指数*/ std::string WeatherModel::GetUVIndex() { - std::string uvIndex = std::to_string(Weather_data_t_now.uvIndex) + "%"; + std::string uvIndex = std::to_string(Weather_data_t_now.uvIndex); WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "uvIndex:%s", uvIndex.c_str()); return uvIndex; } + + // 设置天气数据是否有效 + void WeatherModel::SetWeatherDataIsValid(bool value) + { + WEATHER_DATA_VALID = value; + } + + // 获取天气数据是否有效 + bool WeatherModel::GetWeatherDataIsValid() + { + return WEATHER_DATA_VALID; + } } \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/weather/src/WeatherReportView.cpp b/code/sdk/application/wearable/fd230app/nativeui/weather/src/WeatherReportView.cpp index 58cf2a37f..a69740923 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/weather/src/WeatherReportView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/weather/src/WeatherReportView.cpp @@ -103,9 +103,25 @@ namespace OHOS label->SetPosition(labelconfig.left, labelconfig.top, labelconfig.width, labelconfig.height); // 位置大小 label->SetStyle(STYLE_TEXT_FONT, labelconfig.fontSize); // 字体大小 label->SetStyle(STYLE_LINE_HEIGHT, labelconfig.lineHeigh); // 字体行高 - label->SetText(labelconfig.text.c_str()); // 内容 + label->SetText(labelconfig.text.c_str()); // 内容 + label->SetLineBreakMode(labelconfig.lineBreakMode); // 断行模式。 + label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, labelconfig.fontSize); + return label; + } + + UILabelExt *WeatherReportView::SetUpLabelExt(LabelConfig &labelconfig) + { + UILabelExt *label = new UILabelExt(); + if (label == nullptr) + { + return nullptr; + } + label->SetPosition(labelconfig.left, labelconfig.top, labelconfig.width, labelconfig.height); // 位置大小 + label->SetStyle(STYLE_TEXT_FONT, labelconfig.fontSize); // 字体大小 + label->SetStyle(STYLE_LINE_HEIGHT, labelconfig.lineHeigh); // 字体行高 + label->SetTextId(labelconfig.textId); // 内容 label->SetLineBreakMode(labelconfig.lineBreakMode); // 断行模式。 - label->SetRollSpeed(40); label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, labelconfig.fontSize); return label; @@ -114,16 +130,17 @@ namespace OHOS bool WeatherReportView::WeatherReportViewLabelInit(void) { LabelConfig labelconfig = { - .left = 93, + .left = 83, .top = 52, - .width = 280, - .height = 47, + .width = 300, + .height = 35, .fontSize = 30, .lineHeigh = 35, - .text = "气象报告", + //.text = "气象报告", + .textId = STR_WEATHER_REPORT, .lineBreakMode = UILabel::LINE_BREAK_MARQUEE, }; - title = SetUpLabel(labelconfig); + title = SetUpLabelExt(labelconfig); if (title == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "WeatherReportView::title new fail!"); @@ -138,7 +155,7 @@ namespace OHOS .height = 50, .fontSize = 40, .lineHeigh = 50, - .text = p_WeatherModel->GetHumidity().c_str(), + .text = p_WeatherModel->GetUVIndex(), //紫外线强度 .lineBreakMode = UILabel::LINE_BREAK_ELLIPSIS, }; UV_Number = SetUpLabel(labelconfig); @@ -149,7 +166,7 @@ namespace OHOS } labelconfig.left = 173; - labelconfig.text = p_WeatherModel->GetWindScale(); + labelconfig.text = p_WeatherModel->GetWindScale();//风速 WindSpeed_Number = SetUpLabel(labelconfig); if (WindSpeed_Number == nullptr) { @@ -158,7 +175,7 @@ namespace OHOS } labelconfig.left = 323; - labelconfig.text = p_WeatherModel->GetUVIndex(); + labelconfig.text = p_WeatherModel->GetHumidity().c_str(); //湿度 Humidity_Number = SetUpLabel(labelconfig); if (Humidity_Number == nullptr) { @@ -174,10 +191,11 @@ namespace OHOS .height = 35, .fontSize = 26, .lineHeigh = 35, - .text = "紫外线", + //.text = "紫外线", + .textId = STR_ULTRAVIOLET, .lineBreakMode = UILabel::LINE_BREAK_MARQUEE, }; - UV = SetUpLabel(labelconfig); + UV = SetUpLabelExt(labelconfig); if (UV == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "WeatherReportView::UV new fail!"); @@ -186,8 +204,9 @@ namespace OHOS UV->SetTextColor(Color::GetColorFromRGBA(0x99, 0x99, 0x99, 0xff)); labelconfig.left = 173; - labelconfig.text = "风速"; - WindSpeed = SetUpLabel(labelconfig); + //labelconfig.text = "风速"; + labelconfig.textId = STR_WIND_SPEED; + WindSpeed = SetUpLabelExt(labelconfig); if (WindSpeed == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "WeatherReportView::WindSpeed new fail!"); @@ -196,8 +215,9 @@ namespace OHOS WindSpeed->SetTextColor(Color::GetColorFromRGBA(0x99, 0x99, 0x99, 0xff)); labelconfig.left = 323; - labelconfig.text = "湿度"; - Humidity = SetUpLabel(labelconfig); + //labelconfig.text = "湿度"; + labelconfig.textId = STR_HUMIDITY; + Humidity = SetUpLabelExt(labelconfig); if (Humidity == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "WeatherReportView::Humidity new fail!"); diff --git a/code/sdk/application/wearable/fd230app/nativeui/weather/src/WeatherView.cpp b/code/sdk/application/wearable/fd230app/nativeui/weather/src/WeatherView.cpp index 837f6314c..243837eb6 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/weather/src/WeatherView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/weather/src/WeatherView.cpp @@ -166,7 +166,6 @@ namespace OHOS label->SetText(text); label->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE); label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - label->SetRollSpeed(40); label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, textfont); return label; }