From: 罗正yun <1732036298@qq.com> Date: Fri, 19 Jan 2024 09:51:24 +0000 (+0800) Subject: 主界面和applist天气视图添加并同步添加图片 X-Git-Tag: release_V1.2.70_20241020_135402~1351^2~8^2~1 X-Git-Url: http://git.snicker.com.cn/Users/apple/Desktop/static/gitweb.css?a=commitdiff_plain;h=e66aeef08858decd653b112e8f65c3a47c0e167f;p=mirrors%2FFD230.git 主界面和applist天气视图添加并同步添加图片 --- diff --git a/code/sdk/application/wearable/nativeapp/CMakeLists.txt b/code/sdk/application/wearable/nativeapp/CMakeLists.txt index 9207ae679..0708deb71 100755 --- a/code/sdk/application/wearable/nativeapp/CMakeLists.txt +++ b/code/sdk/application/wearable/nativeapp/CMakeLists.txt @@ -202,6 +202,18 @@ set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/src/TraingView.cpp + #天气 + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/weather/src/MainWeatherPresenter.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/weather/src/MainWeatherView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/weather/src/WeatherReportPresenter.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/weather/src/WeatherReportView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/weather/src/FutureWeatherPresenter.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/weather/src/FutureWeatherView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/weather/src/GetWeatherDataErrorPresenter.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/weather/src/GetWeatherDataErrorView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/weather/src/WeatherControlView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/weather/src/WeatherView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/compass/src/CompassControlView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/compass/src/CompassCalibrationView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/compass/src/CompassModel.cpp diff --git a/code/sdk/application/wearable/nativeapp/nativelauncher/include/AppViewIDs.h b/code/sdk/application/wearable/nativeapp/nativelauncher/include/AppViewIDs.h index bacf7b3f3..1af2dd963 100755 --- a/code/sdk/application/wearable/nativeapp/nativelauncher/include/AppViewIDs.h +++ b/code/sdk/application/wearable/nativeapp/nativelauncher/include/AppViewIDs.h @@ -47,6 +47,11 @@ typedef enum : uint16_t { VIEW_UISAMPLE, VIEW_DIAL,//切换表盘 + VIEW_WEATHER, // 天气 + VIEW_WEATHER_REPORT, // 气象报告 + VIEW_FUTURE_WEATHER, // 未来天气 + VIEW_GET_WEATHER_DATA_ERROR, // 获取天气数据失败 + VIEW_MAX_INTER_APP, // 在此之前添加native应用ID. VIEW_EXTERN_APP = 0xFFFE, // 三方应用 VIEW_INVALIDE_APP = 0xFFFF, diff --git a/code/sdk/application/wearable/nativeapp/nativelauncher/include/NativeLauncher.h b/code/sdk/application/wearable/nativeapp/nativelauncher/include/NativeLauncher.h index 93cb6f5fd..8870ce8fc 100755 --- a/code/sdk/application/wearable/nativeapp/nativelauncher/include/NativeLauncher.h +++ b/code/sdk/application/wearable/nativeapp/nativelauncher/include/NativeLauncher.h @@ -42,7 +42,12 @@ namespace OHOS void InitRebootSlice(void); void InitUISampleSlice(void); void InitDialSlice(void); - + /* ----------------------------------- 天气 ----------------------------------- */ + void InitWeatherSlice(void); + void InitWeatherReportSlice(void); + void InitFutureWeatherSlice(void); + void InitGetWeatherDataErrorSlice(void); + /* -------------------------------------------------------------------------- */ private: void InitAllNativeSlices(void); diff --git a/code/sdk/application/wearable/nativeapp/nativelauncher/include/UiConfig.h b/code/sdk/application/wearable/nativeapp/nativelauncher/include/UiConfig.h index ae607fe77..b275a696e 100755 --- a/code/sdk/application/wearable/nativeapp/nativelauncher/include/UiConfig.h +++ b/code/sdk/application/wearable/nativeapp/nativelauncher/include/UiConfig.h @@ -166,11 +166,12 @@ namespace OHOS static constexpr const char *PNG_A019_095_IMAGE_PATH = APP_RES_PATH "/BLUETOOTH_IMAGE_16.bin"; static constexpr const char *PNG_BLUETOOTHEAR = APP_RES_PATH "/BLUETOOTHEAR.bin"; /* --------------------------------- AppList -------------------------------- */ - static constexpr const char *PNG_APPLIST_ALARM_IMAGE = APP_RES_PATH "/APPLIST_ALARM.bin"; // 闹钟 - static constexpr const char *PNG_APPLIST_SPO2_IMAGE = APP_RES_PATH "/APPLIST_SPO2.bin"; // 血氧 - static constexpr const char *PNG_APPLIST_SETTING_IMAGE = APP_RES_PATH "/APPLIST_SETTING.bin"; // 设置 - static constexpr const char *PNG_APPLIST_CALLER_IMAGE = APP_RES_PATH "/APPLIST_CALLER_IMAGE.bin"; - static constexpr const char *PNG_APPLIST_COMPASS_IMAGE = APP_RES_PATH "/APPLIST_COMPASS_IMAGE.bin"; + static constexpr const char *PNG_APPLIST_ALARM_IMAGE = APP_RES_PATH "/APPLIST_ALARM.bin"; // 闹钟 + static constexpr const char *PNG_APPLIST_SPO2_IMAGE = APP_RES_PATH "/APPLIST_SPO2.bin"; // 血氧 + static constexpr const char *PNG_APPLIST_SETTING_IMAGE = APP_RES_PATH "/APPLIST_SETTING.bin"; // 设置 + static constexpr const char *PNG_APPLIST_CALLER_IMAGE = APP_RES_PATH "/APPLIST_CALLER_IMAGE.bin"; // 打电话 + static constexpr const char *PNG_APPLIST_COMPASS_IMAGE = APP_RES_PATH "/APPLIST_COMPASS_IMAGE.bin"; // 指南针 + static constexpr const char *PNG_APPLIST_WEATHER_IMAGE = APP_RES_PATH "/APPLIST_WEATHER_IMAGE.bin"; // 天气 /* ---------------------------------- 快速训练 ---------------------------------- */ static constexpr const char *PNG_TRAING_BOUTTONMORE_IMAGE = APP_RES_PATH "/Training/More.bin"; static constexpr const char *PNG_TRAING_BUTTONGRONG_IMAGE = APP_RES_PATH "/Training/Bouttonground.bin"; @@ -197,7 +198,7 @@ namespace OHOS static constexpr const char *PNG_SETTINGS_DISPLAY_BRIGHTNESS = APP_RES_PATH "/settings/SETTINGS_DISPLAY_BRIGHTNESS.bin"; // 显示与亮度 static constexpr const char *PNG_SETTINGS_BLUETOOTH = APP_RES_PATH "/settings/SETTINGS_BLUETOOTH.bin"; // 蓝牙 static constexpr const char *PNG_SETTINGS_SOUND_VIBRATION = APP_RES_PATH "/settings/SETTINGS_SOUND_VIBRATION.bin"; // 声音与震动 - static constexpr const char *PNG_SETTINGS_SECONDARY_FUNCTION = APP_RES_PATH "/settings/SETTINGS_QUICK_ACCESS.bin"; // 辅助功能 + static constexpr const char *PNG_SETTINGS_SECONDARY_FUNCTION = APP_RES_PATH "/settings/SETTINGS_QUICK_ACCESS.bin"; // 辅助功能 static constexpr const char *PNG_SETTINGS_SYSTEM = APP_RES_PATH "/settings/SETTINGS_SYSTEM.bin"; // 系统 /* ---------------------------------- 通用图片 ---------------------------------- */ static constexpr const char *PNG_CHECKBOX_OFF_IMAGE = APP_RES_PATH "/CHECKBOX_OFF.bin"; // checkbox未选中图片 @@ -205,6 +206,8 @@ namespace OHOS static constexpr const char *PNG_SETTING_NEXT_IMAGE = APP_RES_PATH "/SETTING_NEXT.bin"; // 箭头图片 static constexpr const char *PNG_SETTING_BACKGROUND_IMAGE = APP_RES_PATH "/SETTING_BACKGROUND.bin"; // 按钮的背景图片 static constexpr const char *PNG_VOLUME_CONTROL_VECTOR = APP_RES_PATH "/VolumeControlVector.bin"; // 调节音量图片 + static constexpr const char *PNG_ANIMATOR1_IMAGE = APP_RES_PATH "/Record/animator1.bin"; + static constexpr const char *PNG_ANIMATOR2_IMAGE = APP_RES_PATH "/Record/animator2.bin"; /* -------------------------------- 已删除的不必要图片 ------------------------------- */ static constexpr const char *PNG_APPLIST_UI_SAMPLE_IMAGE = APP_RES_PATH "/APPLIST_UI_SAMPLE.bin"; // Applist图标 static constexpr const char *PNG_APPLIST_TEMP_IMAGE = APP_RES_PATH "/TEMP_IMAGE.bin"; diff --git a/code/sdk/application/wearable/nativeapp/nativelauncher/src/NativeLauncher.cpp b/code/sdk/application/wearable/nativeapp/nativelauncher/src/NativeLauncher.cpp index 166278f68..3f47fcef7 100755 --- a/code/sdk/application/wearable/nativeapp/nativelauncher/src/NativeLauncher.cpp +++ b/code/sdk/application/wearable/nativeapp/nativelauncher/src/NativeLauncher.cpp @@ -62,6 +62,15 @@ #include "dial/include/DialPresenter.h" #include "dial/include/DialView.h" +#include "weather/include/MainWeatherPresenter.h" +#include "weather/include/MainWeatherView.h" +#include "weather/include/WeatherReportPresenter.h" +#include "weather/include/WeatherReportView.h" +#include "weather/include/FutureWeatherPresenter.h" +#include "weather/include/FutureWeatherView.h" +#include "weather/include/GetWeatherDataErrorPresenter.h" +#include "weather/include/GetWeatherDataErrorView.h" + #include "BluetoothHeadsetEvent.h" #include "graphic_hardware_config.h" #include "graphic_service.h" @@ -101,6 +110,10 @@ namespace OHOS {VIEW_REBOOT, &NativeLauncher::InitRebootSlice}, {VIEW_DIAL, &NativeLauncher::InitDialSlice}, + {VIEW_WEATHER,&NativeLauncher::InitWeatherSlice}, //天气 + {VIEW_WEATHER_REPORT,&NativeLauncher::InitWeatherReportSlice}, //气象报告 + {VIEW_FUTURE_WEATHER,&NativeLauncher::InitFutureWeatherSlice}, //未来天气 + {VIEW_GET_WEATHER_DATA_ERROR,&NativeLauncher::InitGetWeatherDataErrorSlice}, //获取天气数据失败 {VIEW_UISAMPLE, &NativeLauncher::InitUISampleSlice}}; static const ViewIdToString VIEW_MAPPER[] = { @@ -380,7 +393,7 @@ namespace OHOS } void NativeLauncher::InitDialSlice(void) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitBloodSlice"); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitDialSlice"); SliceProxy *dialview = new AbilitySliceProxy; if (dialview == nullptr) { @@ -390,4 +403,48 @@ namespace OHOS NativeAbility::GetInstance().AddSliceProxy(VIEW_DIAL, dialview); } + void NativeLauncher::InitWeatherSlice(void) // 天气 + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitWeatherSlice"); + SliceProxy *mainweather = new AbilitySliceProxy; + if (mainweather == nullptr) + { + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_WEATHER, mainweather); + } + + void NativeLauncher::InitWeatherReportSlice(void) // 气象报告 + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitWeatherReportSlice"); + SliceProxy *weatherreport = new AbilitySliceProxy; + if (weatherreport == nullptr) + { + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_WEATHER_REPORT, weatherreport); + } + + void NativeLauncher::InitFutureWeatherSlice(void) // 未来天气 + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitFutureWeatherSlice"); + SliceProxy *futureweather = new AbilitySliceProxy; + if (futureweather == nullptr) + { + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_FUTURE_WEATHER, futureweather); + } + + void NativeLauncher::InitGetWeatherDataErrorSlice(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitGetWeatherDataErrorSlice"); + SliceProxy *getweatherdataerror = new AbilitySliceProxy; + if (getweatherdataerror == nullptr) + { + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_GET_WEATHER_DATA_ERROR, getweatherdataerror); + } + } diff --git a/code/sdk/application/wearable/nativeapp/nativeui/applist/src/ApplistModel.cpp b/code/sdk/application/wearable/nativeapp/nativeui/applist/src/ApplistModel.cpp index 877edb6a4..a9d386af3 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/applist/src/ApplistModel.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/applist/src/ApplistModel.cpp @@ -24,6 +24,7 @@ namespace OHOS {VIEW_BLOODOXY_SAMPLE, PNG_APPLIST_SPO2_IMAGE, PNG_APPLIST_SPO2_IMAGE, "血氧饱和度", nullptr}, {VIEW_COMPASS, PNG_APPLIST_COMPASS_IMAGE, PNG_APPLIST_COMPASS_IMAGE, "指南针", nullptr}, {VIEW_INDOORWALK, PNG_APPLIST_WALK_IMAGE, PNG_APPLIST_WALK_IMAGE, "室内步行", nullptr}, + {VIEW_WEATHER, PNG_APPLIST_WEATHER_IMAGE, PNG_APPLIST_WEATHER_IMAGE, "天气", nullptr}, {VIEW_SETTING, PNG_APPLIST_SETTING_IMAGE, PNG_APPLIST_SETTING_IMAGE, "设置", nullptr}, #if 0 {VIEW_MAIN_TEMP, PNG_APPLIST_TEMP_IMAGE, PNG_APPLIST_TEMP_IMAGE, "体温", nullptr}, diff --git a/code/sdk/application/wearable/nativeapp/nativeui/main/include/MainViewSample.h b/code/sdk/application/wearable/nativeapp/nativeui/main/include/MainViewSample.h index 21689df0e..2d4a462cd 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/main/include/MainViewSample.h +++ b/code/sdk/application/wearable/nativeapp/nativeui/main/include/MainViewSample.h @@ -32,6 +32,7 @@ #include "blood/include/BloodView.h" #include "traing/include/TraingView.h" #include "ApplistCardView.h" +#include "weather/include/WeatherControlView.h" namespace OHOS { class MainPresenterSample; @@ -83,6 +84,7 @@ namespace OHOS HeartRateView *heartRateView{nullptr}; Digital_clockView *dialView{nullptr}; BloodView *bloodView{nullptr}; + WeatherControlView *weatherControlView{nullptr}; TraingView *traingView{nullptr}; ApplistCardView *applistCardView{nullptr}; /* -------------------------------------------------------------------------- */ diff --git a/code/sdk/application/wearable/nativeapp/nativeui/main/src/MainViewSample.cpp b/code/sdk/application/wearable/nativeapp/nativeui/main/src/MainViewSample.cpp index 9d15a22b1..b19bcc4ae 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/main/src/MainViewSample.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/main/src/MainViewSample.cpp @@ -31,6 +31,7 @@ namespace OHOS {BloodOxygen, &MainViewSample::InitBloodOxygenPage}, {TRAINING, &MainViewSample::InitTrainingPage}, {COMPASS, &MainViewSample::InitCompassPage}, + {WEATHER, &MainViewSample::InitWeatherPage}, {PLAYER,&MainViewSample::InitMusicPlayerPage}, #if 0 {APPLIST,&MainViewSample::InitApplistPage} @@ -379,6 +380,18 @@ namespace OHOS return traingView; } + //主界面天气卡片 + UICardPage *MainViewSample::InitWeatherPage(void) + { + weatherControlView = new WeatherControlView(); + if(weatherControlView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "mainweatherView new fail"); + return nullptr; + } + return weatherControlView; + } + // 主界面功能列表界面 UICardPage *MainViewSample::InitApplistPage(void) { diff --git a/code/sdk/application/wearable/nativeapp/nativeui/screensetting/include/ScreenModels.h b/code/sdk/application/wearable/nativeapp/nativeui/screensetting/include/ScreenModels.h index 4e0f8de4b..b38f6f484 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/screensetting/include/ScreenModels.h +++ b/code/sdk/application/wearable/nativeapp/nativeui/screensetting/include/ScreenModels.h @@ -28,6 +28,7 @@ typedef enum { TRAINING, BloodOxygen, COMPASS, + WEATHER, PLAYER, //APPLIST, MAX_CARD, diff --git a/code/sdk/application/wearable/nativeapp/nativeui/weather/include/FutureWeatherPresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/weather/include/FutureWeatherPresenter.h new file mode 100644 index 000000000..645130639 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/weather/include/FutureWeatherPresenter.h @@ -0,0 +1,34 @@ +#ifndef FUTURE_WEATHER_PRESENTER_H +#define FUTURE_WEATHER_PRESENTER_H + +#include "Presenter.h" + +#include "FutureWeatherView.h" + +namespace OHOS +{ + class FutureWeatherView; + + class FutureWeatherPresenter : public Presenter, + public UIView::OnClickListener, + public UIView::OnDragListener + { + public: + FutureWeatherPresenter(); + virtual ~FutureWeatherPresenter(); + + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + + static FutureWeatherPresenter *GetInstance(); + + private: + // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; + bool OnClick(UIView &view, const ClickEvent &event) override; + bool OnDrag(UIView &view, const DragEvent &event) override; + }; +} // namespace OHOS + +#endif // FutureWeather_PRESENTER_H \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/weather/include/FutureWeatherView.h b/code/sdk/application/wearable/nativeapp/nativeui/weather/include/FutureWeatherView.h new file mode 100644 index 000000000..d4ba47d16 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/weather/include/FutureWeatherView.h @@ -0,0 +1,66 @@ +#ifndef FUTURE_WEATHER_VIEW_H +#define FUTURE_WEATHER_VIEW_H + +#include "BaseView.h" +#include "View.h" +#include "components/ui_view_group.h" +#include "components/ui_scroll_view.h" +#include "components/ui_label.h" +#include "components/ui_list.h" +#include "components/icon_adapter.h" + +namespace OHOS +{ +#define weather_src "/user/res/weather/" +static const char *weather65x65[] = +{ +weather_src"weather_sunny.bin", //晴天 +weather_src"weather_clear-cloudy.bin", //多云 +weather_src"weather_rain.bin", //阵雨 +weather_src"weather_thundershower.bin", +weather_src"weather_foggy.bin", +weather_src"weather_unknown.bin", +weather_src"weather_overcast.bin", +weather_src"weather_clear-sunny.bin", +weather_src"weather_duststorm.bin", +weather_src"weather_haze.bin", +weather_src"weather_snow.bin", +weather_src"weather_sunny-cloudy.bin", +}; + + +} + +namespace OHOS +{ + class FutureWeatherPresenter; + class FutureWeatherView : public View + { + + public: + FutureWeatherView(); + virtual ~FutureWeatherView(); + static FutureWeatherView *GetInstance(void); + + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStop() override; + + private: + void InitView(void); + void DeInitView(void); + void PreLoad(void); + + private: + UIView::OnDragListener *draglistener{nullptr}; + UIViewGroup *container_ = nullptr; + UIScrollView *scrollView1_ = nullptr; + UILabel *label1_ = nullptr; + UIList *list = nullptr; + IconAdapter *listadapter = nullptr; + List *listdata = nullptr; + bool viewInitStatus{false}; + }; +} // namespace OHOS +#endif // FutureWeather_PRESENTER_H \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/weather/include/GetWeatherDataErrorPresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/weather/include/GetWeatherDataErrorPresenter.h new file mode 100644 index 000000000..2bda7b5ee --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/weather/include/GetWeatherDataErrorPresenter.h @@ -0,0 +1,33 @@ +#ifndef Get_WEATHER_DATA_ERROR_PRESENTER_H +#define Get_WEATHER_DATA_ERROR_PRESENTER_H + +#include "Presenter.h" +#include "GetWeatherDataErrorView.h" + +namespace OHOS +{ + class GetWeatherDataErrorView; + + class GetWeatherDataErrorPresenter : public Presenter, + public UIView::OnClickListener, + public UIView::OnDragListener + { + public: + GetWeatherDataErrorPresenter(); + virtual ~GetWeatherDataErrorPresenter(); + + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + + static GetWeatherDataErrorPresenter *GetInstance(); + + private: + // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; + bool OnClick(UIView &view, const ClickEvent &event) override; + bool OnDrag(UIView &view, const DragEvent &event) override; + }; +} // namespace OHOS + +#endif // GetWeatherDataError_PRESENTER_H \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/weather/include/GetWeatherDataErrorView.h b/code/sdk/application/wearable/nativeapp/nativeui/weather/include/GetWeatherDataErrorView.h new file mode 100644 index 000000000..b22d63314 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/weather/include/GetWeatherDataErrorView.h @@ -0,0 +1,40 @@ +#ifndef Get_WEATHER_DATA_ERROR_VIEW_H +#define Get_WEATHER_DATA_ERROR_VIEW_H + +#include "BaseView.h" +#include "View.h" +#include "components/ui_view_group.h" +#include "components/ui_scroll_view.h" +#include "components/ui_label.h" +#include "components/ui_image_view.h" +namespace OHOS +{ + class GetWeatherDataErrorPresenter; + class GetWeatherDataErrorView : public View + { + + public: + GetWeatherDataErrorView(); + virtual ~GetWeatherDataErrorView(); + static GetWeatherDataErrorView *GetInstance(void); + + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStop() override; + + private: + void InitView(void); + void DeInitView(void); + void PreLoad(void); + + private: + UIView::OnDragListener *draglistener{nullptr}; + UIViewGroup *container_ = nullptr; + UIScrollView *scrollView1_ = nullptr; + UILabel *label1_ = nullptr; + UIImageView *image1_ = nullptr; + bool viewInitStatus{false}; + }; +} // namespace OHOS +#endif // GetWeatherDataError_PRESENTER_H \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/weather/include/MainWeatherPresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/weather/include/MainWeatherPresenter.h new file mode 100644 index 000000000..70bbd4ec2 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/weather/include/MainWeatherPresenter.h @@ -0,0 +1,34 @@ +#ifndef MAIN_WEATHER_PRESENTER_H +#define MAIN_WEATHER_PRESENTER_H + +#include "Presenter.h" +#include "MainWeatherView.h" + +/*主天气视图*/ +namespace OHOS +{ + class MainWeatherView; + + class MainWeatherPresenter : public Presenter, + public UIView::OnClickListener, + public UIView::OnDragListener + { + public: + MainWeatherPresenter(); + virtual ~MainWeatherPresenter(); + + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + + static MainWeatherPresenter *GetInstance(); + + private: + // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; + bool OnClick(UIView &view, const ClickEvent &event) override; + bool OnDrag(UIView &view, const DragEvent &event) override; + }; +} // namespace OHOS + +#endif // MainWeather_PRESENTER_H \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/weather/include/MainWeatherView.h b/code/sdk/application/wearable/nativeapp/nativeui/weather/include/MainWeatherView.h new file mode 100644 index 000000000..37bd30567 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/weather/include/MainWeatherView.h @@ -0,0 +1,65 @@ +#ifndef MAIN_WEATHER_VIEW_H +#define MAIN_WEATHER_VIEW_H + +#include "BaseView.h" +#include "View.h" + +#include "components/ui_view_group.h" +#include "components/ui_scroll_view.h" +#include "components/ui_label.h" +#include "components/ui_image_view.h" +#include "components/ui_image_animator.h" +#include "weather/include/WeatherView.h" +#include + + +namespace OHOS +{ + class MainWeatherPresenter; + class MainWeatherView : public View + { + + public: + MainWeatherView(); + virtual ~MainWeatherView(); + static MainWeatherView *GetInstance(void); + + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStop() override; + + private: + void InitView(void); + void DeInitView(void); + UILabel *InitLabel(int x, int y, const char *text, const char *id, int textfont, int lineheight); + void PreLoad(void); + + private: + std::string GetTime(); + std::string GetWeatherImage(); + std::string GetWeatherTemperature(); + std::string GetWeatherDescription(); + std::string GetWeatherArea(); + std::string GetWeatherMaxAndMinTemperature(); + + std::string Time; // 时间 + std::string WeatherImag; // 天气图片 + std::string Temperature; // 温度 + std::string WeatherDescription; // 天气描述 + std::string WeatherArea; // 天气地区 + std::string MaxandMinTemperature; // 最高与最低气温 + private: + UIViewGroup *container_ = nullptr; + UIScrollView *scrollView1_ = nullptr; + UILabel *label1_ = nullptr; + UILabel *label2_ = nullptr; + UIImageView *image1_ = nullptr; + UILabel *label3_ = nullptr; + UILabel *label4_ = nullptr; + UILabel *label5_ = nullptr; + UIImageAnimatorView *imageAnimator1_ = nullptr; + bool viewInitStatus{false}; + }; +} // namespace OHOS +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/weather/include/WeatherControlView.h b/code/sdk/application/wearable/nativeapp/nativeui/weather/include/WeatherControlView.h new file mode 100644 index 000000000..488253a81 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/weather/include/WeatherControlView.h @@ -0,0 +1,26 @@ +#ifndef WEATHER_CONTROL_VIEW_H +#define WEATHER_CONTROL_VIEW_H +/*该视图主要放在主视图*/ + +#include "components/root_view.h" +#include "components/ui_card_page.h" +#include "wearable_log.h" +#include "weather/include/WeatherView.h" +namespace OHOS +{ + class WeatherControlView : public UICardPage + { + public: + WeatherControlView(); + virtual ~WeatherControlView(); + bool InitView(void); + void PreLoad(void) override; + void UnLoad(void) override; + + private: + void ClearAll(void); + WeatherView *weatherView{nullptr}; + bool viewiInitStatus{false}; + }; +} +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/weather/include/WeatherReportPresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/weather/include/WeatherReportPresenter.h new file mode 100644 index 000000000..a6049260a --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/weather/include/WeatherReportPresenter.h @@ -0,0 +1,33 @@ +#ifndef WEATHER_REPORT_PRESENTER_H +#define WEATHER_REPORT_PRESENTER_H + +#include "Presenter.h" +#include "WeatherReportView.h" + +namespace OHOS +{ + class WeatherReportView; + + class WeatherReportPresenter : public Presenter, + public UIView::OnClickListener, + public UIView::OnDragListener + { + public: + WeatherReportPresenter(); + virtual ~WeatherReportPresenter(); + + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + + static WeatherReportPresenter *GetInstance(); + + private: + // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; + bool OnClick(UIView &view, const ClickEvent &event) override; + bool OnDrag(UIView &view, const DragEvent &event) override; + }; +} // namespace OHOS + +#endif // WeatherReport_PRESENTER_H \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/weather/include/WeatherReportView.h b/code/sdk/application/wearable/nativeapp/nativeui/weather/include/WeatherReportView.h new file mode 100644 index 000000000..31c90825f --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/weather/include/WeatherReportView.h @@ -0,0 +1,48 @@ +#ifndef WEATHER_REPORT_VIEW_H +#define WEATHER_REPORT_VIEW_H + +#include "BaseView.h" +#include "View.h" +#include "components/ui_view_group.h" +#include "components/ui_scroll_view.h" +#include "components/ui_label.h" +#include "components/ui_image_animator.h" +namespace OHOS +{ + class WeatherReportPresenter; + class WeatherReportView : public View + { + + public: + WeatherReportView(); + virtual ~WeatherReportView(); + static WeatherReportView *GetInstance(void); + + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStop() override; + + private: + void InitView(void); + void DeInitView(void); + void PreLoad(void); + + private: + UIViewGroup *container_ = nullptr; + UIScrollView *scrollView1_ = nullptr; + UILabel *label5_ = nullptr; + UIImageAnimatorView *imageAnimator3_ = nullptr; + UIImageAnimatorView *imageAnimator2_ = nullptr; + UIImageAnimatorView *imageAnimator1_ = nullptr; + UIImageAnimatorView *imageAnimator = nullptr; + UILabel *label6_ = nullptr; + UILabel *label7_ = nullptr; + UILabel *label8_ = nullptr; + UILabel *label9_ = nullptr; + UILabel *label10_ = nullptr; + UILabel *label11_ = nullptr; + bool viewInitStatus{false}; + }; +} // namespace OHOS +#endif // WeatherReport_PRESENTER_H \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/weather/include/WeatherView.h b/code/sdk/application/wearable/nativeapp/nativeui/weather/include/WeatherView.h new file mode 100644 index 000000000..24b8e64d4 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/weather/include/WeatherView.h @@ -0,0 +1,79 @@ +#ifndef WEATHER_VIEW_H +#define WEATHER_VIEW_H + +#include "BaseView.h" +#include "View.h" + +#include "components/root_view.h" +#include "components/ui_view_group.h" +#include "components/ui_scroll_view.h" +#include "components/ui_label.h" +#include "components/ui_image_view.h" +#include "components/ui_image_animator.h" +#include "wearable_log.h" +#include "AppGroupView.h" +#include + +namespace OHOS +{ +#define weather_src "/user/res/weather/" + static const char *background = weather_src "WEATHER_BACKGROUND.bin"; + static const char *weather130x130[] = + { + weather_src "WEATHER_CLEAR-CLOUDY.bin", + weather_src "WEATHER_CLEAR-SUNNY.bin", + weather_src "WEATHER_DUSTSTORM.bin", + weather_src "WEATHER_FOGGY.bin", + weather_src "WEATHER_HAZE.bin", + weather_src "WEATHER_OVERCAST.bin", + weather_src "WEATHER_RAIN.bin", + weather_src "WEATHER_SNOW.bin", + weather_src "WEATHER_SUNNY.bin", + weather_src "WEATHER_SUNNY-CLOUNDY.bin", + weather_src "WEATHER_THUNDERSHOWER.bin", + weather_src "WEATHER_UNKNOWN.bin"}; +} + +namespace OHOS +{ + class WeatherView : public UIViewGroup + { + + public: + WeatherView(); + virtual ~WeatherView(); + static WeatherView *GetInstance(void); + bool InitPage(void); + bool InitView(void); + void ClearAll(); + bool GetInitViewState(void); + + private: + UILabel *InitLabel(int x, int y, const char *text, const char *id, int textfont, int lineheight); + + private: + std::string GetTime(); + std::string GetWeatherImage(); + std::string GetWeatherTemperature(); + std::string GetWeatherDescription(); + std::string GetWeatherArea(); + std::string GetWeatherMaxAndMinTemperature(); + + std::string Time; // 时间 + std::string WeatherImag; // 天气图片 + std::string Temperature; // 温度 + std::string WeatherDescription; // 天气描述 + std::string WeatherArea; // 天气地区 + std::string MaxandMinTemperature; // 最高与最低气温 + private: + UIImageView *showWeatherImage = nullptr; // 显示天气图片 + UILabel *showCurrentTimeLabel{nullptr}; // 显示当前时间 + UILabel *showTemperatureLabel{nullptr}; // 显示天气温度 + UILabel *showWeatherDescriptionLabel{nullptr}; // 显示天气描述 + UILabel *showWeatherAreaLabel{nullptr}; // 显示天气地区 + UILabel *showMaxandMinTemperatureLabel{nullptr}; // 显示最高与最低气温 + bool viewInitStatus{false}; + }; +} // namespace OHOS + +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/weather/src/FutureWeatherPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/weather/src/FutureWeatherPresenter.cpp new file mode 100644 index 000000000..8c2d22b4a --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/weather/src/FutureWeatherPresenter.cpp @@ -0,0 +1,72 @@ +#include "AppViewIDs.h" +#include "NativeAbility.h" + +#include "weather/include/FutureWeatherPresenter.h" + +namespace OHOS +{ + + // 当前Presenter属性实例化的内存指针 + static FutureWeatherPresenter *g_pFutureWeatherPresenter = nullptr; + + FutureWeatherPresenter::FutureWeatherPresenter() + { + + g_pFutureWeatherPresenter = this; + } + + FutureWeatherPresenter::~FutureWeatherPresenter() + { + + g_pFutureWeatherPresenter = nullptr; + } + + FutureWeatherPresenter *FutureWeatherPresenter::GetInstance() + { + + return g_pFutureWeatherPresenter; + } + + void FutureWeatherPresenter::OnStart() + { + + Presenter::OnStart(); + } + + void FutureWeatherPresenter::OnPause(void) + { + + Presenter::OnPause(); + } + + void FutureWeatherPresenter::OnResume(void) + { + + Presenter::OnResume(); + } + + void FutureWeatherPresenter::OnStop(void) + { + + Presenter::OnStop(); + } + + bool FutureWeatherPresenter::OnDrag(UIView &view, const DragEvent &event) + { + + if (event.GetDragDirection() == DragEvent::DIRECTION_TOP_TO_BOTTOM && + (event.GetDeltaY() > 20) && (event.GetDeltaY() > (2 * MATH_ABS(event.GetDeltaX())))) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_WEATHER_REPORT); // 未来天气界面从上往下滑进入气象报告界面 + } + return true; + } + + bool FutureWeatherPresenter::OnClick(UIView &view, const ClickEvent &event) + { + + // 根据控件id查找是哪个控件触发了点击回调 + // if (strcmp(view.GetViewId(), 控件ID) == 0) + return true; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/weather/src/FutureWeatherView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/weather/src/FutureWeatherView.cpp new file mode 100644 index 000000000..093399a4e --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/weather/src/FutureWeatherView.cpp @@ -0,0 +1,200 @@ +#include "weather/include/FutureWeatherView.h" +#include "weather/include/FutureWeatherPresenter.h" + +#include "common/image_cache_manager.h" +#include "UiConfig.h" +#include "ui_resource_image.h" + +namespace OHOS +{ + + static FutureWeatherView *g_pFutureWeatherView{nullptr}; + + FutureWeatherView::FutureWeatherView() + { + + g_pFutureWeatherView = this; + } + + FutureWeatherView::~FutureWeatherView() + { + DeInitView(); + g_pFutureWeatherView = nullptr; + } + + FutureWeatherView *FutureWeatherView::GetInstance() + { + + return g_pFutureWeatherView; + } + + void FutureWeatherView::InitView() + { + if (scrollView1_ == nullptr) + { + scrollView1_ = new UIScrollView(); + } + scrollView1_->SetPosition(0, 0); // widget's left position and top position + scrollView1_->Resize(466, 466); // widget's width and height + scrollView1_->SetViewId("scrollView1"); // Set style + scrollView1_->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + scrollView1_->SetReboundSize(50); // 设置回弹大小 + scrollView1_->SetScrollBarCenter({200, 200}); + container_->Add(scrollView1_); + scrollView1_->SetVisible(true); + + if (label1_ == nullptr) + { + label1_ = new UILabel(); + } + label1_->SetPosition(179, 52); + label1_->Resize(108, 35); + label1_->SetViewId("label1"); + label1_->SetStyle(STYLE_TEXT_FONT, 30); + label1_->SetStyle(STYLE_LINE_HEIGHT, 35); + label1_->SetText("未来7天"); + label1_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label1_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label1_->SetRollSpeed(0); + label1_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + scrollView1_->Add(label1_); + label1_->SetVisible(true); + + if (list == nullptr) + { + list = new UIList(); + } + list->SetPosition(65, 140); + list->Resize(354, 520); + list->SetViewId("list1"); + list->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); + list->SetReboundSize(50); // 设置回弹值 + if (listdata == nullptr) + { + listdata = new List(); + } + IconItemNode *list3data1 = new IconItemNode(); + list3data1->imagePath = "/user/res/weather/weather_sunny.bin"; + list3data1->txt = "周一 晴天 18°/24°"; + listdata->PushBack(list3data1); + + IconItemNode *list3data2 = new IconItemNode(); + list3data2->imagePath = "/user/res/weather/weather_clear-cloudy.bin"; + list3data2->txt = "周二 多云 19°/24°"; + listdata->PushBack(list3data2); + + IconItemNode *list3data3 = new IconItemNode(); + list3data3->imagePath = "/user/res/weather/weather_rain.bin"; + list3data3->txt = " 周三 阵雨 -11°/-12°"; + listdata->PushBack(list3data3); + + IconItemNode *list3data4 = new IconItemNode(); + list3data4->imagePath = "/user/res/weather/weather_sunny.bin"; + list3data4->txt = "周四 晴天 18°/22°"; + listdata->PushBack(list3data4); + + IconItemNode *list3data5 = new IconItemNode(); + list3data5->imagePath = "/user/res/weather/weather_foggy.bin"; + list3data5->txt = "周五 阴天 16°/20°"; + listdata->PushBack(list3data5); + + IconItemNode *list3data6 = new IconItemNode(); + list3data6->imagePath = "/user/res/weather/weather_thundershower.bin"; + list3data6->txt = " 周六 雷阵雨 10°/15°"; + listdata->PushBack(list3data6); + + IconItemNode *list3data7 = new IconItemNode(); + list3data7->imagePath = "/user/res/weather/weather_overcast.bin"; + list3data7->txt = "周日 阴 20°/24°"; + listdata->PushBack(list3data7); + if (listadapter == nullptr) + { + listadapter = new IconAdapter(); + } + listadapter->SetItemSize(355, 65); + listadapter->SetImageSize(65, 65); + listadapter->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 26); + listadapter->SetData(listdata); + list->SetAdapter(listadapter); + + // Add to scrollView1 + scrollView1_->Add(list); + list->SetVisible(true); + } + + void FutureWeatherView::DeInitView() + { + if (viewInitStatus == true) + { + container_->RemoveAll(); + scrollView1_->RemoveAll(); + delete label1_; + label1_ = nullptr; + + delete list; + list = nullptr; + + delete listadapter; + listadapter = nullptr; + + delete draglistener; + draglistener = nullptr; + + listdata->Clear(); + delete listdata; + listdata = nullptr; + + delete scrollView1_; + scrollView1_ = nullptr; + + delete container_; + container_ = nullptr; + } + } + + void FutureWeatherView::PreLoad(void) + { + if (!viewInitStatus) + { + InitView(); + viewInitStatus = true; + } + } + void FutureWeatherView::OnStart() + { + View::OnStart(); + if (container_ == nullptr) + { + container_ = new UIViewGroup(); + container_->Resize(466, 466); + container_->SetTouchable(true); + container_->SetDraggable(true); + draglistener = static_cast(FutureWeatherPresenter::GetInstance()); + container_->SetOnDragListener(draglistener); + } + PreLoad(); + RootView::GetInstance()->Add(container_); + } + + void FutureWeatherView::OnSetUpView() + { + + View::OnSetUpView(); + Draw(); + } + + void FutureWeatherView::OnTearDownView() + { + + View::OnTearDownView(); + return; + } + + void FutureWeatherView::OnStop() + { + + View::OnStop(); + RootView::GetInstance()->RemoveAll(); + return; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/weather/src/GetWeatherDataErrorPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/weather/src/GetWeatherDataErrorPresenter.cpp new file mode 100644 index 000000000..6fffd0098 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/weather/src/GetWeatherDataErrorPresenter.cpp @@ -0,0 +1,71 @@ +#include "AppViewIDs.h" +#include "NativeAbility.h" +#include "weather/include/GetWeatherDataErrorPresenter.h" + +namespace OHOS +{ + + // 当前Presenter属性实例化的内存指针 + static GetWeatherDataErrorPresenter *g_pGetWeatherDataErrorPresenter = nullptr; + + GetWeatherDataErrorPresenter::GetWeatherDataErrorPresenter() + { + + g_pGetWeatherDataErrorPresenter = this; + } + + GetWeatherDataErrorPresenter::~GetWeatherDataErrorPresenter() + { + + g_pGetWeatherDataErrorPresenter = nullptr; + } + + GetWeatherDataErrorPresenter *GetWeatherDataErrorPresenter::GetInstance() + { + + return g_pGetWeatherDataErrorPresenter; + } + + void GetWeatherDataErrorPresenter::OnStart() + { + + Presenter::OnStart(); + } + + void GetWeatherDataErrorPresenter::OnPause(void) + { + + Presenter::OnPause(); + } + + void GetWeatherDataErrorPresenter::OnResume(void) + { + + Presenter::OnResume(); + } + + void GetWeatherDataErrorPresenter::OnStop(void) + { + + Presenter::OnStop(); + } + + bool GetWeatherDataErrorPresenter::OnDrag(UIView &view, const DragEvent &event) + { + + if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && + (event.GetDeltaX() > 20) && (event.GetDeltaX() > (2 * MATH_ABS(event.GetDeltaY())))) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_WEATHER); + } + return true; + } + + bool GetWeatherDataErrorPresenter::OnClick(UIView &view, const ClickEvent &event) + { + + // 根据控件id查找是哪个控件触发了点击回调 + // if (strcmp(view.GetViewId(), 控件ID) == 0) + return true; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/weather/src/GetWeatherDataErrorView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/weather/src/GetWeatherDataErrorView.cpp new file mode 100644 index 000000000..55a43f67c --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/weather/src/GetWeatherDataErrorView.cpp @@ -0,0 +1,162 @@ +#include "weather/include/GetWeatherDataErrorView.h" +#include "weather/include/GetWeatherDataErrorPresenter.h" +#include "UiConfig.h" + +/* 天气获取数据失败后会调用该视图*/ +namespace OHOS +{ + + static GetWeatherDataErrorView *g_pGetWeatherDataErrorView{nullptr}; + + GetWeatherDataErrorView::GetWeatherDataErrorView() + { + + g_pGetWeatherDataErrorView = this; + } + + GetWeatherDataErrorView::~GetWeatherDataErrorView() + { + if (viewInitStatus == true) + { + DeInitView(); + } + g_pGetWeatherDataErrorView = nullptr; + } + + GetWeatherDataErrorView *GetWeatherDataErrorView::GetInstance() + { + + return g_pGetWeatherDataErrorView; + } + + void GetWeatherDataErrorView::InitView() + { + // Add ScrollView to App + if (scrollView1_ == nullptr) + { + scrollView1_ = new UIScrollView(); + } + scrollView1_->SetPosition(0, 0); + scrollView1_->Resize(466, 466); + scrollView1_->SetViewId("scrollView1"); + scrollView1_->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + container_->Add(scrollView1_); + scrollView1_->SetVisible(true); + + // Add Label to App + if (label1_ == nullptr) + { + label1_ = new UILabel(); + } + label1_->SetPosition(113, 268); + label1_->Resize(240, 70); + label1_->SetViewId("label1"); + label1_->SetStyle(STYLE_TEXT_FONT, 30); + label1_->SetStyle(STYLE_LINE_HEIGHT, 35); + + // Set additional property + label1_->SetText("未获取到天气信息\n请前往APP更新"); + label1_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label1_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label1_->SetRollSpeed(0); + label1_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to scrollView1 + scrollView1_->Add(label1_); + label1_->SetVisible(true); + + // Add ImageView to App + if (image1_ == nullptr) + { + image1_ = new UIImageView(); + } + image1_->SetPosition(168, 127); + image1_->Resize(130, 130); + image1_->SetViewId("image1"); + image1_->SetSrc("/user/res/weather/WEATHER_UNKNOWN.bin"); + + // Add to scrollView1 + scrollView1_->Add(image1_); + image1_->SetVisible(true); + } + + void GetWeatherDataErrorView::DeInitView() + { + container_->RemoveAll(); + scrollView1_->RemoveAll(); + if (label1_ != nullptr) + { + delete label1_; + label1_ = nullptr; + } + if (image1_ != nullptr) + { + delete image1_; + image1_ = nullptr; + } + if (scrollView1_ != nullptr) + { + delete scrollView1_; + scrollView1_ = nullptr; + } + if (container_ != nullptr) + { + delete container_; + container_ = nullptr; + } + } + + void GetWeatherDataErrorView::PreLoad(void) + { + if (!viewInitStatus) + { + InitView(); + viewInitStatus = true; + } + } + void GetWeatherDataErrorView::OnStart() + { + container_ = new UIViewGroup(); + if (container_ == nullptr) + { + return; + } + // container_容器属性 扩展 + container_->SetPosition(0, 0); + container_->SetWidth(Screen::GetInstance().GetWidth()); + container_->SetHeight(Screen::GetInstance().GetHeight()); + + draglistener = static_cast(GetWeatherDataErrorPresenter::GetInstance()); + if (draglistener == nullptr) + { + return; + } + container_->SetOnDragListener(draglistener); + container_->SetTouchable(true); + container_->SetDraggable(true); + PreLoad(); + RootView::GetInstance()->Add(container_); + } + + void GetWeatherDataErrorView::OnSetUpView() + { + + View::OnSetUpView(); + Draw(); + } + + void GetWeatherDataErrorView::OnTearDownView() + { + + View::OnTearDownView(); + return; + } + + void GetWeatherDataErrorView::OnStop() + { + + View::OnStop(); + RootView::GetInstance()->RemoveAll(); + return; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/weather/src/MainWeatherPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/weather/src/MainWeatherPresenter.cpp new file mode 100644 index 000000000..d065faf1f --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/weather/src/MainWeatherPresenter.cpp @@ -0,0 +1,76 @@ +#include "AppViewIDs.h" +#include "NativeAbility.h" +#include "weather/include/MainWeatherPresenter.h" + +namespace OHOS +{ + + // 当前Presenter属性实例化的内存指针 + static MainWeatherPresenter *g_pMainWeatherPresenter = nullptr; + + MainWeatherPresenter::MainWeatherPresenter() + { + + g_pMainWeatherPresenter = this; + } + + MainWeatherPresenter::~MainWeatherPresenter() + { + + g_pMainWeatherPresenter = nullptr; + } + + MainWeatherPresenter *MainWeatherPresenter::GetInstance() + { + + return g_pMainWeatherPresenter; + } + + void MainWeatherPresenter::OnStart() + { + + Presenter::OnStart(); + } + + void MainWeatherPresenter::OnPause(void) + { + + Presenter::OnPause(); + } + + void MainWeatherPresenter::OnResume(void) + { + + Presenter::OnResume(); + } + + void MainWeatherPresenter::OnStop(void) + { + + Presenter::OnStop(); + } + + bool MainWeatherPresenter::OnDrag(UIView &view, const DragEvent &event) + { + if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && + (event.GetDeltaX() > 20) && (event.GetDeltaX() > (2 * MATH_ABS(event.GetDeltaY())))) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST); + return true; + } + else if (event.GetDragDirection() == DragEvent::DIRECTION_BOTTOM_TO_TOP) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_WEATHER_REPORT); // 主天气界面从下往上滑进入气象报告界面 + return true; + } + return false; + } + + bool MainWeatherPresenter::OnClick(UIView &view, const ClickEvent &event) + { + + // 根据控件id查找是哪个控件触发了点击回调 + // if (strcmp(view.GetViewId(), 控件ID) == 0) + return true; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/weather/src/MainWeatherView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/weather/src/MainWeatherView.cpp new file mode 100644 index 000000000..bf37ce375 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/weather/src/MainWeatherView.cpp @@ -0,0 +1,285 @@ +#include "weather/include/MainWeatherView.h" +#include "weather/include/MainWeatherPresenter.h" +#include "UiConfig.h" +/* +当至天气界面时,主动获取最新天气数据。 +(此操作静默将进行,获取到则立刻更新显示,获取不到则重试 +重试3次无果结束更新) +在加载该视图时,需要加载:1时间,2天气图片,3温度,4天气描述,5,地点,6,温度范围 +*/ + +namespace OHOS +{ + static ImageAnimatorInfo g_imageAnimator1Info[2] = { + {PNG_ANIMATOR1_IMAGE, {213, 400}, 40, 40, IMG_SRC_FILE_PATH}, + {PNG_ANIMATOR2_IMAGE, {213, 400}, 40, 40, IMG_SRC_FILE_PATH}, + }; + static MainWeatherView *g_pMainWeatherView{nullptr}; + + MainWeatherView::MainWeatherView() + { + Time = GetTime(); + WeatherImag = GetWeatherImage(); + Temperature = GetWeatherTemperature(); + WeatherDescription = GetWeatherDescription(); + WeatherArea = GetWeatherArea(); + MaxandMinTemperature = GetWeatherMaxAndMinTemperature(); + g_pMainWeatherView = this; + } + + MainWeatherView::~MainWeatherView() + { + if (viewInitStatus == true) + { + DeInitView(); + } + g_pMainWeatherView = nullptr; + } + + MainWeatherView *MainWeatherView::GetInstance() + { + return g_pMainWeatherView; + } + + // 获取时间 + std::string MainWeatherView::GetTime() + { + srand(time(0)); + std::string area[] = {"23:54", "12:00", "7:25"}; + int num = rand() % (sizeof(area) / sizeof(area[0])); + return area[1]; + } + + // 获取天气图片 + std::string MainWeatherView::GetWeatherImage() + { + int size = sizeof(weather130x130) / sizeof(weather130x130[0]); + return weather130x130[8]; + } + // 获取温度 + + std::string MainWeatherView::GetWeatherTemperature() + { + // 使用系统时间作为种子 + srand(time(0)); + int temperature = rand() % 50; + return std::to_string(22) + "°"; + } + // 获取天气描述 + + std::string MainWeatherView::GetWeatherDescription() + { + srand(time(0)); + std::string area[] = {"晴", "雨夹雪", "雷阵雨伴有冰雹"}; + int num = rand() % (sizeof(area) / sizeof(area[0])); + return area[0]; + } + // 获取天气地区 + + std::string MainWeatherView::GetWeatherArea() + { + srand(time(0)); + std::string area[] = {"北京市东城区", "深圳市保安区"}; + int num = rand() % (sizeof(area) / sizeof(area[0])); + return area[1]; + } + // 获取最高气温和最低气温 + + std::string MainWeatherView::GetWeatherMaxAndMinTemperature() + { + // 使用系统时间作为种子 + srand(time(0)); + // 生成随机数 + int maxtemperature = 20 + rand() % 40; // 最高气温:20°~60° + int mintemperature = -5 + rand() % 20; + std::string MaxandMinTemperature = "最高" + std::to_string(22) + "°" + " " + "最低" + std::to_string(18) + "°"; + return MaxandMinTemperature; + } + + // 初始化标签 + UILabel *MainWeatherView::InitLabel(int x, int y, const char *text, const char *id, int textfont, int lineheight) + { + UILabel *label = new UILabel(); + label->SetPosition(x, y); + label->Resize(200, 30); + label->SetViewId(id); + label->SetStyle(STYLE_TEXT_FONT, textfont); + label->SetStyle(STYLE_LINE_HEIGHT, lineheight); + label->SetText(text); + label->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label->SetRollSpeed(0); + label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, textfont); + label->SetVisible(true); + return label; + } + + void MainWeatherView::InitView(void) + { + if (container_ == nullptr) + { + return; + } + // Add ScrollView to App + if (scrollView1_ == nullptr) + { + scrollView1_ = new UIScrollView(); + } + scrollView1_->SetPosition(0, 0); + scrollView1_->Resize(466, 466); + scrollView1_->SetViewId("scrollView1"); + scrollView1_->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + scrollView1_->SetVerticalScrollState(false); // 设置纵向是否可滚动。 + scrollView1_->SetHorizontalScrollState(false); // 设置横向是否可滚动。 + container_->Add(scrollView1_); + scrollView1_->SetVisible(true); + /* -------------------------------------------------------------------------- */ + if (image1_ == nullptr) + { + image1_ = new UIImageView(); + } + image1_->SetPosition(109, 124); + image1_->Resize(100, 100); + image1_->SetViewId("image1"); + image1_->SetSrc(WeatherImag.c_str()); + scrollView1_->Add(image1_); + image1_->SetVisible(true); + /* -------------------------------------------------------------------------- */ + label1_ = InitLabel(185, 52, Time.c_str(), "label1", 40, 47); + scrollView1_->Add(label1_); + /* -------------------------------------------------------------------------- */ + label2_ = InitLabel(249, 126, Temperature.c_str(), "label2", 100, 125); + scrollView1_->Add(label2_); + /* -------------------------------------------------------------------------- */ + label3_ = InitLabel(111, 264, WeatherDescription.c_str(), "label3", 35, 41); + scrollView1_->Add(label3_); + /* -------------------------------------------------------------------------- */ + label4_ = InitLabel(155, 330, WeatherArea.c_str(), "label4", 26, 30); + label4_->SetTextColor(Color::GetColorFromRGBA(0x99, 0x99, 0x99, 0xff)); + scrollView1_->Add(label4_); + /* -------------------------------------------------------------------------- */ + label5_ = InitLabel(158, 368, MaxandMinTemperature.c_str(), "label5", 20, 23); + label5_->SetTextColor(Color::GetColorFromRGBA(0x99, 0x99, 0x99, 0xff)); + scrollView1_->Add(label5_); + /* -------------------------------------------------------------------------- */ + #if 0 + // Add ImageAnimatorView to App + if (imageAnimator1_ == nullptr) + { + imageAnimator1_ = new UIImageAnimatorView(); + } + imageAnimator1_->SetPosition(213, 400); + imageAnimator1_->Resize(40, 40); + imageAnimator1_->SetViewId("imageAnimator1"); + imageAnimator1_->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + + // Set additional property + imageAnimator1_->SetImageAnimatorSrc(g_imageAnimator1Info, 2, 200); + imageAnimator1_->SetTimeOfPause(200); + imageAnimator1_->SetRepeatTimes(1); + imageAnimator1_->SetReverse(true); + imageAnimator1_->Start(); + + // Add to scrollView1 + scrollView1_->Add(imageAnimator1_); + imageAnimator1_->SetVisible(true); + #endif + } + + void MainWeatherView::DeInitView() + { + container_->RemoveAll(); + scrollView1_->RemoveAll(); + if (label1_ != nullptr) + { + delete label1_; + label1_ = nullptr; + } + if (label2_ != nullptr) + { + delete label2_; + label2_ = nullptr; + } + if (image1_ != nullptr) + { + delete image1_; + image1_ = nullptr; + } + if (label3_ != nullptr) + { + delete label3_; + label3_ = nullptr; + } + if (label4_ != nullptr) + { + delete label4_; + label4_ = nullptr; + } + if (label5_ != nullptr) + { + delete label5_; + label5_ = nullptr; + } + if (imageAnimator1_ != nullptr) + { + imageAnimator1_->Stop(); // 视图退出后动画停止 + delete imageAnimator1_; + imageAnimator1_ = nullptr; + } + if (scrollView1_ != nullptr) + { + delete scrollView1_; + scrollView1_ = nullptr; + } + if (container_ != nullptr) + { + delete container_; + container_ = nullptr; + } + } + + void MainWeatherView::PreLoad(void) + { + if (!viewInitStatus) + { + InitView(); + viewInitStatus = true; + } + } + void MainWeatherView::OnStart() + { + View::OnStart(); + if (container_ == nullptr) + { + container_ = new UIViewGroup(); + container_->Resize(466, 466); + container_->SetTouchable(true); + container_->SetDraggable(true); + UIView::OnDragListener *draglistener = static_cast(MainWeatherPresenter::GetInstance()); + container_->SetOnDragListener(draglistener); + } + PreLoad(); + RootView::GetInstance()->Add(container_); + } + + void MainWeatherView::OnSetUpView() + { + View::OnSetUpView(); + Draw(); + } + + void MainWeatherView::OnTearDownView() + { + + View::OnTearDownView(); + return; + } + + void MainWeatherView::OnStop() + { + + View::OnStop(); + RootView::GetInstance()->RemoveAll(); + return; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/weather/src/WeatherControlView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/weather/src/WeatherControlView.cpp new file mode 100644 index 000000000..43affebe3 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/weather/src/WeatherControlView.cpp @@ -0,0 +1,63 @@ +#include "weather/include/WeatherControlView.h" + +namespace OHOS +{ + WeatherControlView::WeatherControlView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "WeatherControlView::WeatherControlView()"); + SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); + } + + WeatherControlView::~WeatherControlView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "WeatherControlView::~WeatherControlView()"); + ClearAll(); + } + + void WeatherControlView::ClearAll(void) + { + if (viewiInitStatus == true) + { + RemoveAll(); + if (weatherView != nullptr) + { + delete weatherView; + weatherView = nullptr; + } + } + } + + bool WeatherControlView::InitView(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "WeatherControlView::InitView()"); + weatherView = new WeatherView(); + if (weatherView == nullptr) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "WeatherView::new mainweatherView fail!"); + return false; + } + if (weatherView->InitPage() == false) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "WeatherView->InitPage() == false!"); + return false; + } + Add(weatherView); + viewiInitStatus = true; + return true; + } + + void WeatherControlView::PreLoad(void) + { + if (!viewiInitStatus) + { + InitView(); + viewiInitStatus = true; + } + } + + void WeatherControlView::UnLoad(void) + { + // Weather's usage scenes is complicated, so we do not release it's resources inner slice. + } + +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/weather/src/WeatherReportPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/weather/src/WeatherReportPresenter.cpp new file mode 100644 index 000000000..22ef28cdb --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/weather/src/WeatherReportPresenter.cpp @@ -0,0 +1,78 @@ +#include "AppViewIDs.h" +#include "NativeAbility.h" + +#include "weather/include/WeatherReportPresenter.h" + +namespace OHOS +{ + + // 当前Presenter属性实例化的内存指针 + static WeatherReportPresenter *g_pWeatherReportPresenter = nullptr; + + WeatherReportPresenter::WeatherReportPresenter() + { + + g_pWeatherReportPresenter = this; + } + + WeatherReportPresenter::~WeatherReportPresenter() + { + + g_pWeatherReportPresenter = nullptr; + } + + WeatherReportPresenter *WeatherReportPresenter::GetInstance() + { + + return g_pWeatherReportPresenter; + } + + void WeatherReportPresenter::OnStart() + { + + Presenter::OnStart(); + } + + void WeatherReportPresenter::OnPause(void) + { + + Presenter::OnPause(); + } + + void WeatherReportPresenter::OnResume(void) + { + + Presenter::OnResume(); + } + + void WeatherReportPresenter::OnStop(void) + { + + Presenter::OnStop(); + } + + bool WeatherReportPresenter::OnDrag(UIView &view, const DragEvent &event) + { + + if (event.GetDragDirection() == DragEvent::DIRECTION_TOP_TO_BOTTOM && + (event.GetDeltaY() > 20) && (event.GetDeltaY() > (2 * MATH_ABS(event.GetDeltaX())))) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_WEATHER); // 气象报告界面从上往下滑进入主天气界面 + return true; + } + if (event.GetDragDirection() == DragEvent::DIRECTION_BOTTOM_TO_TOP) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_FUTURE_WEATHER); // 气象报告界面从下往上进入未来天气界面 + return true; + } + return false; + } + + bool WeatherReportPresenter::OnClick(UIView &view, const ClickEvent &event) + { + + // 根据控件id查找是哪个控件触发了点击回调 + // if (strcmp(view.GetViewId(), 控件ID) == 0) + return true; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/weather/src/WeatherReportView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/weather/src/WeatherReportView.cpp new file mode 100644 index 000000000..9207a8995 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/weather/src/WeatherReportView.cpp @@ -0,0 +1,427 @@ +#include "weather/include/WeatherReportView.h" +#include "weather/include/WeatherReportPresenter.h" +#include "UiConfig.h" + +namespace OHOS +{ + + const char *IMAGEANIMATOR3 = "/user/res/weather/WEATHER_WINDSPEED.bin"; + const char *IMAGEANIMATOR2 = "/user/res/weather/WEATHER_HUMIDITY.bin"; + const char *IMAGEANIMATOR1 = "/user/res/weather/WEATHER_UVI.bin"; + static ImageAnimatorInfo g_imageAnimator3Info[2] = { + {IMAGEANIMATOR3, {341, 167}, 60, 60, IMG_SRC_FILE_PATH}, + {"", {341, 167}, 60, 60, IMG_SRC_FILE_PATH}, + }; + static ImageAnimatorInfo g_imageAnimator2Info[2] = { + {IMAGEANIMATOR2, {207, 167}, 60, 60, IMG_SRC_FILE_PATH}, + {"", {207, 167}, 60, 60, IMG_SRC_FILE_PATH}, + }; + + static ImageAnimatorInfo g_imageAnimator1Info[2] = { + {IMAGEANIMATOR1, {73, 167}, 60, 60, IMG_SRC_FILE_PATH}, + {"", {73, 167}, 60, 60, IMG_SRC_FILE_PATH}, + }; + static ImageAnimatorInfo g_imageAnimatorInfo[2] = { + {PNG_ANIMATOR1_IMAGE, {213, 400}, 40, 40, IMG_SRC_FILE_PATH}, + {PNG_ANIMATOR2_IMAGE, {213, 400}, 40, 40, IMG_SRC_FILE_PATH}, + }; + static WeatherReportView *g_pWeatherReportView{nullptr}; + + WeatherReportView::WeatherReportView() + { + + g_pWeatherReportView = this; + } + + WeatherReportView::~WeatherReportView() + { + if (viewInitStatus == true) + { + DeInitView(); + } + g_pWeatherReportView = nullptr; + } + + WeatherReportView *WeatherReportView::GetInstance() + { + + return g_pWeatherReportView; + } + + void WeatherReportView::InitView() + { + if (container_ == nullptr) + { + container_ = new UIViewGroup(); + container_->SetPosition(0, 0, 466, 466); + container_->SetStyle(STYLE_BACKGROUND_OPA, 0); + container_->SetTouchable(true); + container_->SetDraggable(true); + UIView::OnDragListener *draglistener = static_cast(WeatherReportPresenter::GetInstance()); + container_->SetOnDragListener(draglistener); + } + + // Add ScrollView to App + if (scrollView1_ == nullptr) + { + scrollView1_ = new UIScrollView(); + } + scrollView1_->SetPosition(0, 0); // widget's left position and top position + scrollView1_->Resize(466, 466); // widget's width and height + scrollView1_->SetViewId("scrollView1"); // Set style + scrollView1_->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + + // Set additional property + + // Add to rootView + container_->Add(scrollView1_); + scrollView1_->SetVisible(true); + + // Add Label to App + if (label5_ == nullptr) + { + label5_ = new UILabel(); + } + label5_->SetPosition(173, 52); // widget's left position and top position + label5_->Resize(120, 35); // widget's width and height + label5_->SetViewId("label5"); // Set style + label5_->SetStyle(STYLE_TEXT_FONT, 30); + label5_->SetStyle(STYLE_LINE_HEIGHT, 35); + + // Set additional property + label5_->SetText("气象报告"); + label5_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label5_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label5_->SetRollSpeed(0); + label5_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + + // Add to scrollView1 + scrollView1_->Add(label5_); + label5_->SetVisible(true); + + // Add ImageAnimatorView to App + if (imageAnimator3_ == nullptr) + { + imageAnimator3_ = new UIImageAnimatorView(); + } + imageAnimator3_->SetPosition(341, 167); // widget's left position and top position + imageAnimator3_->Resize(60, 60); // widget's width and height + imageAnimator3_->SetViewId("imageAnimator3"); // Set style + + // Set additional property + imageAnimator3_->SetImageAnimatorSrc(g_imageAnimator3Info, 2, 200); + imageAnimator3_->SetTimeOfPause(500); + imageAnimator3_->SetRepeatTimes(1); + imageAnimator3_->SetReverse(true); + imageAnimator3_->Start(); + + // Add to scrollView1 + scrollView1_->Add(imageAnimator3_); + imageAnimator3_->SetVisible(true); + + // Add ImageAnimatorView to App + if (imageAnimator2_ == nullptr) + { + imageAnimator2_ = new UIImageAnimatorView(); + } + imageAnimator2_->SetPosition(207, 167); // widget's left position and top position + imageAnimator2_->Resize(60, 60); // widget's width and height + imageAnimator2_->SetViewId("imageAnimator2"); // Set style + + // Set additional property + imageAnimator2_->SetImageAnimatorSrc(g_imageAnimator2Info, 2, 200); + imageAnimator2_->SetTimeOfPause(500); + imageAnimator2_->SetRepeatTimes(1); + imageAnimator2_->SetReverse(true); + imageAnimator2_->Start(); + + // Add to scrollView1 + scrollView1_->Add(imageAnimator2_); + imageAnimator2_->SetVisible(true); + + // Add ImageAnimatorView to App + if (imageAnimator1_ == nullptr) + { + imageAnimator1_ = new UIImageAnimatorView(); + } + imageAnimator1_->SetPosition(73, 167); // widget's left position and top position + imageAnimator1_->Resize(60, 60); // widget's width and height + imageAnimator1_->SetViewId("imageAnimator1"); // Set style + + // Set additional property + imageAnimator1_->SetImageAnimatorSrc(g_imageAnimator1Info, 2, 200); + imageAnimator1_->SetTimeOfPause(500); + imageAnimator1_->SetRepeatTimes(1); + imageAnimator1_->SetReverse(true); + imageAnimator1_->Start(); + + // Add to scrollView1 + scrollView1_->Add(imageAnimator1_); + imageAnimator1_->SetVisible(true); + + // Add Label to App + if (label6_ == nullptr) + { + label6_ = new UILabel(); + } + label6_->SetPosition(93, 240); // widget's left position and top position + label6_->Resize(20, 50); // widget's width and height + label6_->SetViewId("label6"); // Set style + label6_->SetStyle(STYLE_TEXT_FONT, 40); + label6_->SetStyle(STYLE_LINE_HEIGHT, 50); + + // Set additional property + label6_->SetText("7"); + label6_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label6_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label6_->SetRollSpeed(0); + label6_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 40); + + // Add to scrollView1 + scrollView1_->Add(label6_); + label6_->SetVisible(true); + + // Add Label to App + if (label7_ == nullptr) + { + label7_ = new UILabel(); + } + label7_->SetPosition(210, 240); // widget's left position and top position + label7_->Resize(200, 60); // widget's width and height + label7_->SetViewId("label7"); // Set style + label7_->SetStyle(STYLE_TEXT_FONT, 40); + label7_->SetStyle(STYLE_LINE_HEIGHT, 50); + + // Set additional property + label7_->SetText("1-2"); + label7_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label7_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label7_->SetRollSpeed(0); + label7_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 40); + + // Add to scrollView1 + scrollView1_->Add(label7_); + label7_->SetVisible(true); + + // Add Label to App + if (label8_ == nullptr) + { + label8_ = new UILabel(); + } + label8_->SetPosition(337, 240); // widget's left position and top position + label8_->Resize(200, 60); // widget's width and height + label8_->SetViewId("label8"); // Set style + label8_->SetStyle(STYLE_TEXT_FONT, 40); + label8_->SetStyle(STYLE_LINE_HEIGHT, 50); + + // Set additional property + label8_->SetText("75%"); + label8_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label8_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label8_->SetRollSpeed(0); + label8_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 40); + + // Add to scrollView1 + scrollView1_->Add(label8_); + label8_->SetVisible(true); + + // Add Label to App + if (label9_ == nullptr) + { + label9_ = new UILabel(); + } + label9_->SetPosition(63, 293); // widget's left position and top position + label9_->Resize(200, 60); // widget's width and height + label9_->SetViewId("label9"); // Set style + label9_->SetStyle(STYLE_TEXT_FONT, 26); + label9_->SetStyle(STYLE_LINE_HEIGHT, 30); + + // Set additional property + label9_->SetText("紫外线"); + label9_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label9_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label9_->SetRollSpeed(0); + label9_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 26); + + // Add to scrollView1 + scrollView1_->Add(label9_); + label9_->SetVisible(true); + + // Add Label to App + if (label10_ == nullptr) + { + label10_ = new UILabel(); + } + label10_->SetPosition(212, 293); // widget's left position and top position + label10_->Resize(290, 60); // widget's width and height + label10_->SetViewId("label10"); // Set style + label10_->SetStyle(STYLE_TEXT_FONT, 26); + label10_->SetStyle(STYLE_LINE_HEIGHT, 30); + + // Set additional property + label10_->SetText("风速"); + label10_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label10_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label10_->SetRollSpeed(0); + label10_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 26); + + // Add to scrollView1 + scrollView1_->Add(label10_); + label10_->SetVisible(true); + + // Add Label to App + if (label11_ == nullptr) + { + label11_ = new UILabel(); + } + label11_->SetPosition(345, 293); // widget's left position and top position + label11_->Resize(200, 60); // widget's width and height + label11_->SetViewId("label11"); // Set style + label11_->SetStyle(STYLE_TEXT_FONT, 26); + label11_->SetStyle(STYLE_LINE_HEIGHT, 30); + + // Set additional property + label11_->SetText("湿度"); + label11_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label11_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label11_->SetRollSpeed(0); + label11_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 26); + + // Add to scrollView1 + scrollView1_->Add(label11_); + label11_->SetVisible(true); + /* -------------------------------------------------------------------------- */ + #if 0 + // Add ImageAnimatorView to App + if (imageAnimator == nullptr) + { + imageAnimator = new UIImageAnimatorView(); + } + imageAnimator->SetPosition(213, 400); + imageAnimator->Resize(40, 40); + imageAnimator->SetViewId("imageAnimator1"); + imageAnimator->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + + // Set additional property + imageAnimator->SetImageAnimatorSrc(g_imageAnimatorInfo, 2, 200); + imageAnimator->SetTimeOfPause(200); + imageAnimator->SetRepeatTimes(1); + imageAnimator->SetReverse(true); + imageAnimator->Start(); + + // Add to scrollView1 + scrollView1_->Add(imageAnimator); + #endif + } + + void WeatherReportView::DeInitView() + { + if (label5_ != nullptr) + { + delete label5_; + label5_ = nullptr; + } + if (imageAnimator3_ != nullptr) + { + imageAnimator3_->Stop(); + delete imageAnimator3_; + imageAnimator3_ = nullptr; + } + if (imageAnimator2_ != nullptr) + { + imageAnimator2_->Stop(); + delete imageAnimator2_; + imageAnimator2_ = nullptr; + } + if (imageAnimator1_ != nullptr) + { + imageAnimator1_->Stop(); + delete imageAnimator1_; + imageAnimator1_ = nullptr; + } + if (imageAnimator != nullptr) + { + imageAnimator->Stop(); + delete imageAnimator; + imageAnimator = nullptr; + } + if (label6_ != nullptr) + { + delete label6_; + label6_ = nullptr; + } + if (label7_ != nullptr) + { + delete label7_; + label7_ = nullptr; + } + if (label8_ != nullptr) + { + delete label8_; + label8_ = nullptr; + } + if (label9_ != nullptr) + { + delete label9_; + label9_ = nullptr; + } + if (label10_ != nullptr) + { + delete label10_; + label10_ = nullptr; + } + if (label11_ != nullptr) + { + delete label11_; + label11_ = nullptr; + } + if (scrollView1_ != nullptr) + { + delete scrollView1_; + scrollView1_ = nullptr; + } + if (container_ != nullptr) + { + container_->RemoveAll(); + delete container_; + container_ = nullptr; + } + } + + void WeatherReportView::PreLoad(void) + { + if (!viewInitStatus) + { + InitView(); + viewInitStatus = true; + } + } + void WeatherReportView::OnStart() + { + View::OnStart(); + PreLoad(); + RootView::GetInstance()->Add(container_); + } + + void WeatherReportView::OnSetUpView() + { + + View::OnSetUpView(); + Draw(); + } + + void WeatherReportView::OnTearDownView() + { + + View::OnTearDownView(); + return; + } + + void WeatherReportView::OnStop() + { + + View::OnStop(); + RootView::GetInstance()->RemoveAll(); + return; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/weather/src/WeatherView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/weather/src/WeatherView.cpp new file mode 100644 index 000000000..273ba54de --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/weather/src/WeatherView.cpp @@ -0,0 +1,242 @@ +#include "weather/include/WeatherView.h" +#include "UiConfig.h" + +/* +当至天气界面时,主动获取最新天气数据。 +(此操作静默将进行,获取到则立刻更新显示,获取不到则重试 +重试3次无果结束更新) +在加载该视图时,需要加载:1时间,2天气图片,3温度,4天气描述,5,地点,6,温度范围 +*/ + +namespace OHOS +{ + static WeatherView *g_pWeatherView{nullptr}; + WeatherView::WeatherView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "WeatherView::WeatherView()"); + SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); + Time = GetTime(); + WeatherImag = GetWeatherImage(); + Temperature = GetWeatherTemperature(); + WeatherDescription = GetWeatherDescription(); + WeatherArea = GetWeatherArea(); + MaxandMinTemperature = GetWeatherMaxAndMinTemperature(); + g_pWeatherView = this; + } + + WeatherView::~WeatherView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, " WeatherView::~WeatherView()"); + ClearAll(); + g_pWeatherView = nullptr; + } + + void WeatherView::ClearAll() + { + if (viewInitStatus == true) + { + RemoveAll(); + if (showCurrentTimeLabel != nullptr) + { + delete showCurrentTimeLabel; + showCurrentTimeLabel = nullptr; + } + if (showTemperatureLabel != nullptr) + { + delete showTemperatureLabel; + showTemperatureLabel = nullptr; + } + if (showWeatherImage != nullptr) + { + delete showWeatherImage; + showWeatherImage = nullptr; + } + if (showWeatherDescriptionLabel != nullptr) + { + delete showWeatherDescriptionLabel; + showWeatherDescriptionLabel = nullptr; + } + if (showWeatherAreaLabel != nullptr) + { + delete showWeatherAreaLabel; + showWeatherAreaLabel = nullptr; + } + if (showMaxandMinTemperatureLabel != nullptr) + { + delete showMaxandMinTemperatureLabel; + showMaxandMinTemperatureLabel = nullptr; + } + } + } + + WeatherView *WeatherView::GetInstance() + { + return g_pWeatherView; + } + + // 获取时间 + std::string WeatherView::GetTime() + { + srand(time(0)); + std::string area[] = {"23:54", "12:00", "7:25"}; + int num = rand() % (sizeof(area) / sizeof(area[0])); + return area[1]; + } + + // 获取天气图片 + std::string WeatherView::GetWeatherImage() + { + int size = sizeof(weather130x130) / sizeof(weather130x130[0]); + return weather130x130[8]; + } + // 获取温度 + + std::string WeatherView::GetWeatherTemperature() + { + // 使用系统时间作为种子 + srand(time(0)); + int temperature = rand() % 50; + return std::to_string(22) + "°"; + } + // 获取天气描述 + + std::string WeatherView::GetWeatherDescription() + { + srand(time(0)); + std::string area[] = {"晴", "雨夹雪", "雷阵雨伴有冰雹"}; + int num = rand() % (sizeof(area) / sizeof(area[0])); + return area[0]; + } + // 获取天气地区 + + std::string WeatherView::GetWeatherArea() + { + srand(time(0)); + std::string area[] = {"北京市东城区", "深圳市保安区"}; + int num = rand() % (sizeof(area) / sizeof(area[0])); + return area[1]; + } + // 获取最高气温和最低气温 + + std::string WeatherView::GetWeatherMaxAndMinTemperature() + { + // 使用系统时间作为种子 + srand(time(0)); + // 生成随机数 + int maxtemperature = 20 + rand() % 40; // 最高气温:20°~60° + int mintemperature = -5 + rand() % 20; + std::string MaxandMinTemperature = "最高" + std::to_string(22) + "°" + " " + "最低" + std::to_string(18) + "°"; + return MaxandMinTemperature; + } + + // 初始化标签 + UILabel *WeatherView::InitLabel(int x, int y, const char *text, const char *id, int textfont, int lineheight) + { + UILabel *label = new UILabel(); + if (label == nullptr) + { + return nullptr; + } + label->SetPosition(x, y); + label->Resize(200, 30); + label->SetViewId(id); + label->SetStyle(STYLE_TEXT_FONT, textfont); + label->SetStyle(STYLE_LINE_HEIGHT, lineheight); + label->SetText(text); + label->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label->SetRollSpeed(0); + label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, textfont); + label->SetVisible(true); + return label; + } + + // 初始化天气页面 + bool WeatherView::InitPage(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, " WeatherView::InitPage()"); + /* -------------------------------------------------------------------------- */ + showWeatherImage = new UIImageView(); + if (showWeatherImage == nullptr) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "WeatherView::new showWeatherImage fail!"); + return false; + } + showWeatherImage->SetPosition(109, 124, 100, 100); + showWeatherImage->SetSrc(WeatherImag.c_str()); + /* -------------------------------------------------------------------------- */ + showCurrentTimeLabel = InitLabel(185, 52, Time.c_str(), "showCurrentTimeLabel", 40, 47); + if (showCurrentTimeLabel == nullptr) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "WeatherView::new showCurrentTimeLabel fail!"); + return false; + } + /* -------------------------------------------------------------------------- */ + showTemperatureLabel = InitLabel(249, 126, Temperature.c_str(), "showTemperatureLabel", 100, 125); + if (showTemperatureLabel == nullptr) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "WeatherView::new showTemperatureLabel fail!"); + return false; + } + /* -------------------------------------------------------------------------- */ + UILabel *showWeatherDescriptionLabel = new UILabel(); + showWeatherDescriptionLabel->SetPosition(83, 264,300,40); + showWeatherDescriptionLabel->SetViewId("showWeatherDescriptionLabel"); + showWeatherDescriptionLabel->SetStyle(STYLE_TEXT_FONT, 35); + showWeatherDescriptionLabel->SetStyle(STYLE_LINE_HEIGHT, 41); + showWeatherDescriptionLabel->SetText(WeatherDescription.c_str()); + showWeatherDescriptionLabel->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); + showWeatherDescriptionLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + showWeatherDescriptionLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 35); + if (showWeatherDescriptionLabel == nullptr) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "WeatherView::new showWeatherDescriptionLabel fail!"); + return false; + } + /* -------------------------------------------------------------------------- */ + showWeatherAreaLabel = InitLabel(155, 330, WeatherArea.c_str(), "showWeatherAreaLabel", 26, 30); + if (showWeatherAreaLabel == nullptr) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "WeatherView::new showWeatherAreaLabel fail!"); + return false; + } + showWeatherAreaLabel->SetTextColor(Color::GetColorFromRGBA(0x99, 0x99, 0x99, 0xff)); + /* -------------------------------------------------------------------------- */ + showMaxandMinTemperatureLabel = InitLabel(158, 368, MaxandMinTemperature.c_str(), "showMaxandMinTemperatureLabel", 20, 23); + if (showMaxandMinTemperatureLabel == nullptr) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "WeatherView::new showMaxandMinTemperatureLabel fail!"); + return false; + } + showMaxandMinTemperatureLabel->SetTextColor(Color::GetColorFromRGBA(0x99, 0x99, 0x99, 0xff)); + + /* -------------------------------- 将组件添加到根视图 ------------------------------- */ + Add(showWeatherImage); + Add(showCurrentTimeLabel); + Add(showTemperatureLabel); + Add(showWeatherDescriptionLabel); + Add(showWeatherAreaLabel); + Add(showMaxandMinTemperatureLabel); + viewInitStatus = true; + return true; + } + + bool WeatherView::InitView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "WeatherView::InitView"); + if (InitPage() == false) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitPage fail"); + return false; + } + SetDraggable(true); + SetTouchable(true); + return true; + } + + // 获取视图初始化状态 + bool WeatherView::GetInitViewState(void) + { + return viewInitStatus; + } +} \ No newline at end of file diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/APPLIST_COMPASS_IMAGE.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/APPLIST_COMPASS_IMAGE.bin index d1fa4b53c..381dbe9d6 100644 Binary files a/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/APPLIST_COMPASS_IMAGE.bin and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/APPLIST_COMPASS_IMAGE.bin differ diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/APPLIST_WEATHER_IMAGE.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/APPLIST_WEATHER_IMAGE.bin new file mode 100644 index 000000000..30da839a2 Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/APPLIST_WEATHER_IMAGE.bin differ diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/weather/WEATHER_BACKGROUND.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/weather/WEATHER_BACKGROUND.bin new file mode 100644 index 000000000..143df271c Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/weather/WEATHER_BACKGROUND.bin differ diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/weather/WEATHER_CLEAR-CLOUDY.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/weather/WEATHER_CLEAR-CLOUDY.bin new file mode 100644 index 000000000..f253a7ea1 Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/weather/WEATHER_CLEAR-CLOUDY.bin differ diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/weather/WEATHER_CLEAR-SUNNY.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/weather/WEATHER_CLEAR-SUNNY.bin new file mode 100644 index 000000000..150f9023d Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/weather/WEATHER_CLEAR-SUNNY.bin differ diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/weather/WEATHER_DUSTSTORM.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/weather/WEATHER_DUSTSTORM.bin new file mode 100644 index 000000000..f1a9c607e Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/weather/WEATHER_DUSTSTORM.bin differ diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/weather/WEATHER_FOGGY.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/weather/WEATHER_FOGGY.bin new file mode 100644 index 000000000..b16fc33fe Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/weather/WEATHER_FOGGY.bin differ diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/weather/WEATHER_HAZE.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/weather/WEATHER_HAZE.bin new file mode 100644 index 000000000..a77f3a7ad Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/weather/WEATHER_HAZE.bin differ diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/weather/WEATHER_HUMIDITY.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/weather/WEATHER_HUMIDITY.bin new file mode 100644 index 000000000..678ff935d Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/weather/WEATHER_HUMIDITY.bin differ diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/weather/WEATHER_OVERCAST.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/weather/WEATHER_OVERCAST.bin new file mode 100644 index 000000000..e888f9c85 Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/weather/WEATHER_OVERCAST.bin differ diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/weather/WEATHER_RAIN.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/weather/WEATHER_RAIN.bin new file mode 100644 index 000000000..ede837596 Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/weather/WEATHER_RAIN.bin differ diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/weather/WEATHER_SNOW.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/weather/WEATHER_SNOW.bin new file mode 100644 index 000000000..27d521ee2 Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/weather/WEATHER_SNOW.bin differ diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/weather/WEATHER_SUNNY-CLOUNDY.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/weather/WEATHER_SUNNY-CLOUNDY.bin new file mode 100644 index 000000000..4460e9254 Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/weather/WEATHER_SUNNY-CLOUNDY.bin differ diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/weather/WEATHER_SUNNY.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/weather/WEATHER_SUNNY.bin new file mode 100644 index 000000000..75c954299 Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/weather/WEATHER_SUNNY.bin differ diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/weather/WEATHER_THUNDERSHOWER.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/weather/WEATHER_THUNDERSHOWER.bin new file mode 100644 index 000000000..4954d5ee1 Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/weather/WEATHER_THUNDERSHOWER.bin differ diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/weather/WEATHER_UNKNOWN.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/weather/WEATHER_UNKNOWN.bin new file mode 100644 index 000000000..604d809cf Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/weather/WEATHER_UNKNOWN.bin differ diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/weather/WEATHER_UVI.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/weather/WEATHER_UVI.bin new file mode 100644 index 000000000..9a1e8cee2 Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/weather/WEATHER_UVI.bin differ diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/weather/WEATHER_WINDSPEED.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/weather/WEATHER_WINDSPEED.bin new file mode 100644 index 000000000..1b02cdeb4 Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/weather/WEATHER_WINDSPEED.bin differ diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/weather/weather_clear-cloudy.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/weather/weather_clear-cloudy.bin new file mode 100644 index 000000000..96d16533d Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/weather/weather_clear-cloudy.bin differ diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/weather/weather_clear-sunny.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/weather/weather_clear-sunny.bin new file mode 100644 index 000000000..bda9c3e0c Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/weather/weather_clear-sunny.bin differ diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/weather/weather_duststorm.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/weather/weather_duststorm.bin new file mode 100644 index 000000000..c6710e714 Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/weather/weather_duststorm.bin differ diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/weather/weather_foggy.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/weather/weather_foggy.bin new file mode 100644 index 000000000..d38ac2e77 Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/weather/weather_foggy.bin differ diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/weather/weather_haze.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/weather/weather_haze.bin new file mode 100644 index 000000000..6f795a16e Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/weather/weather_haze.bin differ diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/weather/weather_overcast.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/weather/weather_overcast.bin new file mode 100644 index 000000000..272962347 Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/weather/weather_overcast.bin differ diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/weather/weather_rain.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/weather/weather_rain.bin new file mode 100644 index 000000000..b3874bd26 Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/weather/weather_rain.bin differ diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/weather/weather_snow.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/weather/weather_snow.bin new file mode 100644 index 000000000..f92e6feed Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/weather/weather_snow.bin differ diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/weather/weather_sunny-cloudy.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/weather/weather_sunny-cloudy.bin new file mode 100644 index 000000000..b3eae3b41 Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/weather/weather_sunny-cloudy.bin differ diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/weather/weather_sunny.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/weather/weather_sunny.bin new file mode 100644 index 000000000..548273d1e Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/weather/weather_sunny.bin differ diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/weather/weather_thundershower.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/weather/weather_thundershower.bin new file mode 100644 index 000000000..148c18b45 Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/weather/weather_thundershower.bin differ diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/weather/weather_unknown.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/weather/weather_unknown.bin new file mode 100644 index 000000000..50b0ff892 Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user/res/weather/weather_unknown.bin differ