From: luozheng <1732036298@qq.com> Date: Sat, 27 Jul 2024 04:08:29 +0000 (+0800) Subject: 添加OBU Slice ,添加相应多国语言字体 X-Git-Tag: release_V1.2.70_20241020_135402~742 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=df2bbbffe509cec28508eb6dd72154f8ea53e29f;p=mirrors%2FFD230.git 添加OBU Slice ,添加相应多国语言字体 --- diff --git a/code/sdk/application/wearable/fd230app/CMakeLists.txt b/code/sdk/application/wearable/fd230app/CMakeLists.txt index e7edc78eb..0877e51d8 100644 --- a/code/sdk/application/wearable/fd230app/CMakeLists.txt +++ b/code/sdk/application/wearable/fd230app/CMakeLists.txt @@ -469,6 +469,10 @@ set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/rotate/src/RotateView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/rotate/src/RotatePresenter.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/obumessage/src/OBUMessageModel.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/obumessage/src/OBUMessageView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/obumessage/src/OBUMessagePresenter.cpp + # ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/dialupdate/src/DialUpdateView.cpp # ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/dialupdate/src/DialUpdatePresenter.cpp # ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/dialupdate/src/DialUpdateModel.cpp diff --git a/code/sdk/application/wearable/fd230app/nativelauncher/include/AppViewIDs.h b/code/sdk/application/wearable/fd230app/nativelauncher/include/AppViewIDs.h index 0551fae31..86bbf70f1 100644 --- a/code/sdk/application/wearable/fd230app/nativelauncher/include/AppViewIDs.h +++ b/code/sdk/application/wearable/fd230app/nativelauncher/include/AppViewIDs.h @@ -68,6 +68,9 @@ typedef enum : uint16_t VIEW_AI_MODELS, // AI模型选择界面 VIEW_REBOOTANDSHUTDOWN, //(滑动关机和重启带恢复出厂设置) VIEW_RECORD, + /* -------------------------------------------------------------------------- */ + VIEW_OBU_MESSAGE, + /* -------------------------------------------------------------------------- */ /* ----------------------------------------------------------------------------- */ VIEW_DIAL, // 切换表盘 VIEW_SET_DIAL_STYLE, // 切换表盘样式 diff --git a/code/sdk/application/wearable/fd230app/nativelauncher/include/NativeLauncher.h b/code/sdk/application/wearable/fd230app/nativelauncher/include/NativeLauncher.h index 57b8cf404..335f76ea4 100644 --- a/code/sdk/application/wearable/fd230app/nativelauncher/include/NativeLauncher.h +++ b/code/sdk/application/wearable/fd230app/nativelauncher/include/NativeLauncher.h @@ -64,6 +64,7 @@ namespace OHOS void InitAiVoiceSlice(void); void InitAiModelsSlice(void); void InitRebootAndShutdownSlice(void); + void InitOBUMessageSlice(void); /* --------------------------------界面------------------------------------ */ void InitRotateSlice(void); void InitBloodSlice(void); diff --git a/code/sdk/application/wearable/fd230app/nativelauncher/include/ui_resource_string.h b/code/sdk/application/wearable/fd230app/nativelauncher/include/ui_resource_string.h index 0d3352b48..ff1c030c1 100644 --- a/code/sdk/application/wearable/fd230app/nativelauncher/include/ui_resource_string.h +++ b/code/sdk/application/wearable/fd230app/nativelauncher/include/ui_resource_string.h @@ -502,7 +502,8 @@ enum UIResourceTextId : uint16_t { STR_PTALORTM = 489, STR_MOTION_DETECTION_NOTE = 490, STR_PE4GC = 491, - STR_MAX_ID = 492, + STR_OBU_MESSAGE = 492, + STR_MAX_ID = 493, }; // UIResourceTextId enum FontLanguageId : uint8_t { diff --git a/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp b/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp index 7156b5538..ad0dff95c 100644 --- a/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp +++ b/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp @@ -203,6 +203,9 @@ #include "rebootandshutdown/include/RebootAndShutdownPresenter.h" #include "rebootandshutdown/include/RebootAndShutdownView.h" + +#include "obumessage/include/OBUMessagePresenter.h" +#include "obumessage/include/OBUMessageView.h" /* -------------------------------------------------------------------------- */ #include "traing/include/TraingView.h" #include "traing/include/TraingPresenter.h" @@ -300,6 +303,10 @@ namespace OHOS {VIEW_AI_MODELS, &NativeLauncher::InitAiModelsSlice}, // Ai Models(Ai模型选择界面) {VIEW_REBOOTANDSHUTDOWN, &NativeLauncher::InitRebootAndShutdownSlice}, // 滑动关机和重启带恢复出厂设置 + /* -------------------------------------------------------------------------- */ + {VIEW_OBU_MESSAGE, &NativeLauncher::InitOBUMessageSlice}, + /* -------------------------------------------------------------------------- */ + // {VIEW_SECONDARY_FUNCTION, &NativeLauncher::InitSecondaryFunction}, // {VIEW_FAST_TRAINING, &NativeLauncher::InitFastTrainingSlice}, // {VIEW_FAST_TRAINING_ATTENTION, &NativeLauncher::InitFastTrainingAttentionSlice}, @@ -1312,6 +1319,18 @@ namespace OHOS } NativeAbility::GetInstance().AddSliceProxy(VIEW_REBOOTANDSHUTDOWN, rebootandshutdown); } + + /*OBU Message*/ + void NativeLauncher::InitOBUMessageSlice(void) + { + SliceProxy *obumessage = new AbilitySliceProxy; + if (obumessage == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "obumessage"); + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_OBU_MESSAGE, obumessage); + } /* -------------------------------------------------------------------------- */ void NativeLauncher::InitSetCardSlice(void) diff --git a/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistModel.cpp index b90f8215a..ccf78b9f4 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistModel.cpp @@ -53,6 +53,10 @@ namespace OHOS * - 设置 */ const AppItem g_nativeAppList[] = { + /* ------------------------------- OBU MESSAGE ------------------------------ */ + {VIEW_OBU_MESSAGE, PNG_APPLIST_THEME_IMAGE, PNG_APPLIST_THEME_IMAGE, PNG_APPLIST_DEFAULT_IMG, "OBU", STR_OBU_MESSAGE, nullptr}, + /* -------------------------------------------------------------------------- */ + {VIEW_MAIN_PHONE, PNG_APPLIST_CALLER_IMAGE, PNG_APPLIST_CALLER_IMAGE, PNG_APPLIST_DEFAULT_IMG, "手机", STR_PHONE, nullptr}, {VIEW_HEART, PNG_APPLIST_HEART_IMAGE, PNG_APPLIST_HEART_IMAGE, PNG_APPLIST_DEFAULT_IMG, "心率", STR_HEART_RATE, nullptr}, {VIEW_BLOODOXY, PNG_APPLIST_SPO2_IMAGE, PNG_APPLIST_SPO2_IMAGE, PNG_APPLIST_DEFAULT_IMG, "血氧", STR_BLOOD_OXYGEN, nullptr}, 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 9a4cc12c6..60aefb87d 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 @@ -489,4 +489,5 @@ STR_CONNECTING$Connecting STR_CONNECTION_FAIL$Connection fail STR_PTALORTM$Please try again later or replace the model STR_MOTION_DETECTION_NOTE$It seems that you are performing XX movement, whether to start recording -STR_PE4GC$Please enable 4G capability \ No newline at end of file +STR_PE4GC$Please enable 4G capability +STR_OBU_MESSAGE$OBU \ 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 cb9f616c6..7e3cb0d2e 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 @@ -489,4 +489,5 @@ STR_CONNECTING$正在连接 STR_CONNECTION_FAIL$连接失败 STR_PTALORTM$请稍后再重试或更换模型 STR_MOTION_DETECTION_NOTE$检测到您好像在进行XX运动,是否开始记录 -STR_PE4GC$请开启4G能力 \ No newline at end of file +STR_PE4GC$请开启4G能力 +STR_OBU_MESSAGE$OBU \ 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 fdd32b305..a50f25e5f 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 @@ -491,4 +491,5 @@ + 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 064ea345f..f62068848 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 @@ -491,4 +491,5 @@ + 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 16cbb1d11..2068b3a77 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/ui_resource_string.h b/code/sdk/application/wearable/fd230app/nativeui/language/font/ui_resource_string.h index a245eb39a..920b223a4 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 @@ -502,7 +502,8 @@ enum UIResourceTextId : uint16_t { STR_PTALORTM = 489, STR_MOTION_DETECTION_NOTE = 490, STR_PE4GC = 491, - STR_MAX_ID = 492, + STR_OBU_MESSAGE = 492, + STR_MAX_ID = 493, }; // 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 ba8e460e1..9e273d90e 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/obumessage/include/OBUMessageModel.h b/code/sdk/application/wearable/fd230app/nativeui/obumessage/include/OBUMessageModel.h new file mode 100644 index 000000000..95780ebc2 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/obumessage/include/OBUMessageModel.h @@ -0,0 +1,29 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-07-27 11:22:07 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-07-27 11:37:32 + * @FilePath: /xts_origin/FD230/code/sdk/application/wearable/fd230app/nativeui/obumessage/include/OBUMessageModel.h + * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE + */ + +#ifndef OBU_MESSAGE_MODEL_H +#define OBU_MESSAGE_MODEL_H + +namespace OHOS +{ + class OBUMessageModel + { + public: + static OBUMessageModel &GetInstance(void); + void UpdateOBUMessageViewData(void); + + private: + OBUMessageModel(); + ~OBUMessageModel(); + OBUMessageModel(const OBUMessageModel &) = delete; + OBUMessageModel &operator=(const OBUMessageModel &) = delete; + }; +} + +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/obumessage/include/OBUMessagePresenter.h b/code/sdk/application/wearable/fd230app/nativeui/obumessage/include/OBUMessagePresenter.h new file mode 100644 index 000000000..d374f828b --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/obumessage/include/OBUMessagePresenter.h @@ -0,0 +1,46 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-07-27 10:59:42 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-07-27 11:37:13 + * @FilePath: /xts_origin/FD230/code/sdk/application/wearable/fd230app/nativeui/obumessage/include/OBUMessagePresenter.h + * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE + */ + +#ifndef OBU_MESSAGE_PRESENTER_H +#define OBU_MESSAGE_PRESENTER_H + +#include "Presenter.h" +#include "View.h" + +namespace OHOS +{ + class OBUMessageView; + class OBUMessageModel; + class OBUMessagePresenter : public Presenter, + public UIView::OnClickListener, + public UIView::OnDragListener, + public RootView::OnKeyActListener + { + public: + OBUMessagePresenter(); + virtual ~OBUMessagePresenter(); + static OBUMessagePresenter *GetInstance(); + void UpdateOBUMessageViewData(void); + + void OnStart() override; + void OnResume() override; + void OnPause() override; + void OnStop() override; + + private: + bool OnClick(UIView &view, const ClickEvent &event) override; + bool OnDrag(UIView &view, const DragEvent &event) override; + bool OnDragEnd(UIView &view, const DragEvent &event) override; + bool OnKeyAct(UIView &view, const KeyEvent &event) override; // 增加按键事件 + + bool X_DRAG_FLAG{false}; + }; +} + +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/obumessage/include/OBUMessageView.h b/code/sdk/application/wearable/fd230app/nativeui/obumessage/include/OBUMessageView.h new file mode 100644 index 000000000..7677ee4b7 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/obumessage/include/OBUMessageView.h @@ -0,0 +1,48 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-07-27 10:58:43 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-07-27 12:02:16 + * @FilePath: /xts_origin/FD230/code/sdk/application/wearable/fd230app/nativeui/obumessage/include/OBUMessageView..h + * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE + */ + +#ifndef OBU_MESSAGE_VIEW_H +#define OBU_MESSAGE_VIEW_H + +#include "BaseView.h" +#include "View.h" +#include "components/ui_scroll_view.h" +#include "components/ui_label.h" +#include "components/ui_button.h" +#include "components/ui_view_group.h" +namespace OHOS +{ + class OBUMessagePresenter; + class OBUMessageView : public View + { + + public: + OBUMessageView(); + ~OBUMessageView(); + static OBUMessageView *GetInstance(void); + void UpdateOBUMessageViewDisplayData(void); + + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStop() override; + + private: + void CreateOBUMessageView(void); + void ClearAll(void); + + UIViewGroup *OBUMessageScrollView = nullptr; + UIViewGroup *group = nullptr; + UILabel *title = nullptr; + UILabel *displayTimeLabel = nullptr; + UILabel *obuMessageLabel = nullptr; + bool viewInitStatus{false}; + }; +} +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/obumessage/src/OBUMessageModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/obumessage/src/OBUMessageModel.cpp new file mode 100644 index 000000000..aa65d7a74 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/obumessage/src/OBUMessageModel.cpp @@ -0,0 +1,34 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-07-27 11:22:17 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-07-27 11:37:26 + * @FilePath: /xts_origin/FD230/code/sdk/application/wearable/fd230app/nativeui/obumessage/src/OBUMessageModel.cpp + * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE + */ + +#include "obumessage/include/OBUMessageModel.h" +#include "obumessage/include/OBUMessagePresenter.h" +#include "wearable_log.h" + +namespace OHOS +{ + OBUMessageModel::OBUMessageModel() {} + + OBUMessageModel::~OBUMessageModel() {} + + OBUMessageModel &OBUMessageModel::GetInstance() + { + static OBUMessageModel instance; + return instance; + } + + void OBUMessageModel::UpdateOBUMessageViewData(void) + { + OBUMessagePresenter *obuMessagePresenter = OBUMessagePresenter::GetInstance(); + if (obuMessagePresenter != nullptr) + { + obuMessagePresenter->UpdateOBUMessageViewData(); + } + } +} diff --git a/code/sdk/application/wearable/fd230app/nativeui/obumessage/src/OBUMessagePresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/obumessage/src/OBUMessagePresenter.cpp new file mode 100644 index 000000000..11db0ef4e --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/obumessage/src/OBUMessagePresenter.cpp @@ -0,0 +1,120 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-06-20 15:11:17 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-07-27 12:04:00 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/OBUMessagePresenter.cpp + */ +#include "AppViewIDs.h" +#include "NativeAbility.h" +#include "common/key_code.h" +#include +#include "UiConfig.h" +#include "obumessage/include/OBUMessagePresenter.h" +#include "obumessage/include/OBUMessageView.h" + +namespace OHOS +{ + + // 当前Presenter属性实例化的内存指针 + static OBUMessagePresenter *g_pOBUMessagePresenter = nullptr; + + OBUMessagePresenter::OBUMessagePresenter() + { + g_pOBUMessagePresenter = this; + } + + OBUMessagePresenter::~OBUMessagePresenter() + { + g_pOBUMessagePresenter = nullptr; + } + + OBUMessagePresenter *OBUMessagePresenter::GetInstance() + { + return g_pOBUMessagePresenter; + } + + void OBUMessagePresenter::UpdateOBUMessageViewData(void) + { + if (view_ != nullptr) + { + view_->UpdateOBUMessageViewDisplayData(); + } + } + + // 启动时执行的逻辑 + void OBUMessagePresenter::OnStart() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OBUMessagePresenter::OnStart"); + Presenter::OnStart(); + } + + // 页面已经展示后的调用逻辑 + void OBUMessagePresenter::OnResume(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OBUMessagePresenter::OnResume"); + Presenter::OnResume(); + if (view_ == nullptr) + { + return; + } + } + + // 页面准备切换到后台前执行的逻辑 + void OBUMessagePresenter::OnPause(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OBUMessagePresenter::OnPause"); + Presenter::OnPause(); + } + + // 页面完全置于后台时的逻辑。 + void OBUMessagePresenter::OnStop(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OBUMessagePresenter::OnStop"); + Presenter::OnStop(); + } + + bool OBUMessagePresenter::OnClick(UIView &view, const ClickEvent &event) + { + UNUSED(event); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OBUMessagePresenter::OnClick"); + return true; + } + + bool OBUMessagePresenter::OnDrag(UIView &view, const DragEvent &event) + { + UNUSED(view); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OBUMessagePresenter::OnDrag"); + if ((event.GetDeltaX() > X_DRAG_OFFSET) && (event.GetDeltaX() > (DOUBLES * MATH_ABS(event.GetDeltaY())))) // 拖动过程中判断是否是水平滑动 + { + OBUMessagePresenter::X_DRAG_FLAG = true; + } + return true; + } + + bool OBUMessagePresenter::OnDragEnd(UIView &view, const DragEvent &event) + { + UNUSED(view); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OBUMessagePresenter::OnDragEnd"); + if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && OBUMessagePresenter::X_DRAG_FLAG) + { + NativeAbility::GetInstance().Back(TransitionType::TRANSITION_ZOOM); + OBUMessagePresenter::X_DRAG_FLAG = false; + } + return true; + } + + bool OBUMessagePresenter::OnKeyAct(UIView &view, const KeyEvent &event) // 增加按键事件 + { + UNUSED(view); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OBUMessagePresenter::OnKeyAct"); + uint16_t keyID = event.GetKeyId(); + uint16_t keyState = event.GetState(); + // 如果是power键,且是亮屏状态,按键释放就返回上一级 + if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 0 && uapi_get_screen_state() == 0) + { + NativeAbility::GetInstance().Back(TransitionType::TRANSITION_ZOOM); + } + return true; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/obumessage/src/OBUMessageView.cpp b/code/sdk/application/wearable/fd230app/nativeui/obumessage/src/OBUMessageView.cpp new file mode 100644 index 000000000..7740d62c6 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/obumessage/src/OBUMessageView.cpp @@ -0,0 +1,222 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-05-07 11:25:58 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-07-27 12:02:22 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/OBUMessage/src/OBUMessageView.cpp + */ +#include "obumessage/include/OBUMessagePresenter.h" +#include "obumessage/include/OBUMessageView.h" +#include "wearable_log.h" + +namespace OHOS +{ + + static OBUMessageView *g_pOBUMessageView{nullptr}; + + OBUMessageView::OBUMessageView() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OBUMessageView::OBUMessageView"); + g_pOBUMessageView = this; + } + + OBUMessageView::~OBUMessageView() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OBUMessageView::~OBUMessageView"); + g_pOBUMessageView = nullptr; + } + + OBUMessageView *OBUMessageView::GetInstance() + { + return g_pOBUMessageView; + } + + void OBUMessageView::ClearAll(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OBUMessageView::ClearAll"); + if (viewInitStatus) + { + + if (OBUMessageScrollView != nullptr) + { + OBUMessageScrollView->RemoveAll(); + if (title != nullptr) + { + delete title; + title = nullptr; + } + if (group != nullptr) + { + group->RemoveAll(); + if (displayTimeLabel != nullptr) + { + delete displayTimeLabel; + displayTimeLabel = nullptr; + } + if (obuMessageLabel != nullptr) + { + delete obuMessageLabel; + obuMessageLabel = nullptr; + } + delete group; + group = nullptr; + } + delete OBUMessageScrollView; + OBUMessageScrollView = nullptr; + } + } + } + + void OBUMessageView::CreateOBUMessageView(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OBUMessageView::CreateOBUMessageView"); + /* -------------------------- OBUMessageScrollView -------------------------- */ + if (OBUMessageScrollView == nullptr) + { + OBUMessageScrollView = new UIViewGroup(); + if (OBUMessageScrollView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OBUMessageScrollView fail!!"); + return; + } + } + OBUMessageScrollView->SetPosition(0, 0, 466, 466); + OBUMessageScrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + /* ---------------------------------- title --------------------------------- */ + if (title == nullptr) + { + title = new UILabel(); + if (title == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "title fail!!"); + return; + } + } + title->SetPosition(83, 50, 300, 35); + title->SetStyle(STYLE_TEXT_FONT, 30); + title->SetStyle(STYLE_LINE_HEIGHT, 35); + title->SetText("OBU Message"); + title->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION); + title->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + title->SetRollSpeed(70); + title->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + OBUMessageScrollView->Add(title); + /* -------------------------------------------------------------------------- */ + /* ------------------------------- group ------------------------------- */ + if (group == nullptr) + { + group = new UIViewGroup(); + if (group == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group fail!!"); + return; + } + } + group->SetPosition(0, 120, 466, 466); + group->SetStyle(STYLE_BACKGROUND_COLOR, 0xff4fc34c); + group->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + OBUMessageScrollView->Add(group); + /* ---------------------------- displayTimeLabel ---------------------------- */ + if (displayTimeLabel == nullptr) + { + displayTimeLabel = new UILabel(); + if (displayTimeLabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "displayTimeLabel fail!!"); + return; + } + } + displayTimeLabel->SetPosition(83, 0, 300, 35); + displayTimeLabel->SetStyle(STYLE_TEXT_FONT, 30); + displayTimeLabel->SetStyle(STYLE_LINE_HEIGHT, 35); + displayTimeLabel->SetText("12:30:30"); + displayTimeLabel->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION); + displayTimeLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + displayTimeLabel->SetRollSpeed(70); + displayTimeLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + group->Add(displayTimeLabel); + /* ----------------------------- obuMessageLabel ---------------------------- */ + if (obuMessageLabel == nullptr) + { + obuMessageLabel = new UILabel(); + if (obuMessageLabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "obuMessageLabel fail!!"); + return; + } + } + obuMessageLabel->SetPosition(53, 30, 360, 250); + obuMessageLabel->SetStyle(STYLE_BORDER_RADIUS, 33); + obuMessageLabel->SetStyle(STYLE_TEXT_FONT, 30); + obuMessageLabel->SetStyle(STYLE_LINE_HEIGHT, 35); + obuMessageLabel->SetText("OBU MESSAGE DATA"); + obuMessageLabel->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS); + obuMessageLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + obuMessageLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + group->Add(obuMessageLabel); + viewInitStatus = true; + } + + void OBUMessageView::OnStart() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OBUMessageView::OnStart"); + View::OnStart(); + SetContainerView(new UIViewGroup()); + if (GetContainer() == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SetContainerView fail!!"); + return; + } + container_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); + container_->SetOnDragListener(presenter_); + container_->SetTouchable(true); + container_->SetDraggable(true); + + if (!viewInitStatus) + { + CreateOBUMessageView(); + } + + RootView::GetInstance()->SetOnKeyActListener(presenter_); + return; + } + + void OBUMessageView::OnSetUpView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OBUMessageView::OnSetUpView"); + View::OnSetUpView(); + + container_->Add(OBUMessageScrollView); + Draw(); + return; + } + + void OBUMessageView::OnTearDownView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OBUMessageView::OnTearDownView"); + View::OnTearDownView(); + return; + } + + void OBUMessageView::OnStop() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OBUMessageView::OnStop"); + View::OnStop(); + if (container_ != nullptr) + { + container_->RemoveAll(); + delete container_; + container_ = nullptr; + } + RootView::GetInstance()->ClearOnKeyActListener(); + ClearAll(); + return; + } + + void OBUMessageView::UpdateOBUMessageViewDisplayData(void) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OBUMessageView::UpdateOBUMessageViewDisplayDate"); + displayTimeLabel->SetText(""); + obuMessageLabel->SetText(""); + } +} \ No newline at end of file diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/font/en.lang b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/font/en.lang index 16cbb1d11..2068b3a77 100644 Binary files a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/font/en.lang and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/font/en.lang differ diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/font/ui_resource_string.h b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/font/ui_resource_string.h index a245eb39a..920b223a4 100644 --- a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/font/ui_resource_string.h +++ b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/font/ui_resource_string.h @@ -502,7 +502,8 @@ enum UIResourceTextId : uint16_t { STR_PTALORTM = 489, STR_MOTION_DETECTION_NOTE = 490, STR_PE4GC = 491, - STR_MAX_ID = 492, + STR_OBU_MESSAGE = 492, + STR_MAX_ID = 493, }; // UIResourceTextId enum FontLanguageId : uint8_t { diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/font/zh.lang b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/font/zh.lang index ba8e460e1..9e273d90e 100644 Binary files a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/font/zh.lang and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/font/zh.lang differ