From a5f2bc45d3f59cca0ce1b7ec3cb0fc51f73aaa98 Mon Sep 17 00:00:00 2001 From: luozheng <1732036298@qq.com> Date: Thu, 20 Jun 2024 20:27:21 +0800 Subject: [PATCH] =?utf8?q?1.=E6=B7=BB=E5=8A=A0Ai=20Voice=20slice=20?= =?utf8?q?=E6=95=B4=E4=BD=93=E6=A1=86=E6=9E=B6=20=EF=BC=8C=E5=A2=9E?= =?utf8?q?=E5=8A=A0=E5=AF=B9=E5=BA=94=E5=A4=9A=E5=9B=BD=E8=AF=AD=E8=A8=80?= =?utf8?q?=20=EF=BC=8C=E5=9B=BE=E7=89=87=E8=B5=84=E6=BA=90=202.Ability=20?= =?utf8?q?=E6=B7=BB=E5=8A=A0=E5=88=87=E6=8D=A2slice=E6=B8=85=E9=99=A4?= =?utf8?q?=E8=81=9A=E7=84=A6=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../wearable/fd230app/CMakeLists.txt | 7 +- .../nativelauncher/include/AppViewIDs.h | 1 + .../nativelauncher/include/NativeLauncher.h | 1 + .../nativelauncher/include/UiConfig.h | 1 + .../nativelauncher/src/NativeLauncher.cpp | 16 ++ .../nativeui/aivoice/include/AiVoiceModel.h | 26 +++ .../aivoice/include/AiVoicePresenter.h | 45 ++++ .../nativeui/aivoice/include/AiVoiceView.h | 67 ++++++ .../nativeui/aivoice/src/AiVoiceModel.cpp | 23 +++ .../nativeui/aivoice/src/AiVoicePresenter.cpp | 111 ++++++++++ .../nativeui/aivoice/src/AiVoiceView.cpp | 195 ++++++++++++++++++ .../nativeui/applist/src/ApplistModel.cpp | 3 +- .../nativeui/applist/src/ApplistPresenter.cpp | 2 + .../nativeui/applist/src/ApplistView.cpp | 2 +- .../language/Language_xml/input_list_zh.txt | 15 +- .../language/Language_xml/language_zh.xml | 13 ++ .../fd230app/nativeui/language/font/en.lang | Bin 8971 -> 9036 bytes .../fd230app/nativeui/language/font/ja.lang | Bin 7274 -> 7339 bytes .../language/font/ui_resource_string.h | 15 +- .../fd230app/nativeui/language/font/zh.lang | Bin 8853 -> 9096 bytes .../src/SoundAndVibrationPresenter.cpp | 6 +- .../src/SoundAndVibrationView.cpp | 6 +- .../wearable/nativeabilityfwk/src/Ability.cpp | 3 +- .../fd230/fs/user/res/AIVoice/AIRecBlack.bin | 3 + .../fd230/fs/user/res/AIVoice/AIRecGreen.bin | 3 + .../fd230/fs/user/res/AIVoice/AIUnion.bin | 3 + .../fs/user/res/applist_icon/aivoice.bin | 3 + .../fd230/fs/user/res/font/en.lang | Bin 8971 -> 9036 bytes .../fd230/fs/user/res/font/ja.lang | Bin 7274 -> 7339 bytes .../fs/user/res/font/ui_resource_string.h | 15 +- .../fd230/fs/user/res/font/zh.lang | Bin 8853 -> 9096 bytes 31 files changed, 573 insertions(+), 12 deletions(-) create mode 100644 code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoiceModel.h create mode 100644 code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoicePresenter.h create mode 100644 code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoiceView.h create mode 100644 code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceModel.cpp create mode 100644 code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoicePresenter.cpp create mode 100644 code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceView.cpp create mode 100644 code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/AIVoice/AIRecBlack.bin create mode 100644 code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/AIVoice/AIRecGreen.bin create mode 100644 code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/AIVoice/AIUnion.bin create mode 100644 code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/applist_icon/aivoice.bin diff --git a/code/sdk/application/wearable/fd230app/CMakeLists.txt b/code/sdk/application/wearable/fd230app/CMakeLists.txt index 5ede29a58..880e46803 100644 --- a/code/sdk/application/wearable/fd230app/CMakeLists.txt +++ b/code/sdk/application/wearable/fd230app/CMakeLists.txt @@ -376,11 +376,16 @@ set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/respiratorytraining/src/RespiratoryTrainingCompletedView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/respiratorytraining/src/RespiratoryTrainingModel.cpp - #呼吸训练 + #显示方式 ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/themestyle/src/ThemeStyleModel.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/themestyle/src/ThemeStylePresenter.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/themestyle/src/ThemeStyleView.cpp + #Ai Voice + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/aivoice/src/AiVoiceModel.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/aivoice/src/AiVoicePresenter.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/aivoice/src/AiVoiceView.cpp + #声音与震动 ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/soundandvibration/src/SoundAndVibrationPresenter.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/soundandvibration/src/SoundAndVibrationView.cpp diff --git a/code/sdk/application/wearable/fd230app/nativelauncher/include/AppViewIDs.h b/code/sdk/application/wearable/fd230app/nativelauncher/include/AppViewIDs.h index 502cb9567..3ef0123c3 100644 --- a/code/sdk/application/wearable/fd230app/nativelauncher/include/AppViewIDs.h +++ b/code/sdk/application/wearable/fd230app/nativelauncher/include/AppViewIDs.h @@ -66,6 +66,7 @@ typedef enum : uint16_t VIEW_WATCH_QR_CODE, // 手表二维码 VIEW_RESPIRATORY_TRAINING, // 呼吸训练 VIEW_THEME_STYLE, // 主题样式 + VIEW_AI_VOICE, // AI Voice(人工智能语音) /* ----------------------------------- 录音 ----------------------------------- */ VIEW_RECORD, diff --git a/code/sdk/application/wearable/fd230app/nativelauncher/include/NativeLauncher.h b/code/sdk/application/wearable/fd230app/nativelauncher/include/NativeLauncher.h index df262f511..99a9b5efa 100644 --- a/code/sdk/application/wearable/fd230app/nativelauncher/include/NativeLauncher.h +++ b/code/sdk/application/wearable/fd230app/nativelauncher/include/NativeLauncher.h @@ -62,6 +62,7 @@ namespace OHOS void InitWatchQRCodeSlice(void); void InitRespiratoryTrainingSlice(void); void InitThemeStyleSlice(void); + void InitAiVoiceSlice(void); /* --------------------------------界面------------------------------------ */ void InitRotateSlice(void); void InitBloodSlice(void); diff --git a/code/sdk/application/wearable/fd230app/nativelauncher/include/UiConfig.h b/code/sdk/application/wearable/fd230app/nativelauncher/include/UiConfig.h index faff5e53c..90b6f77f3 100644 --- a/code/sdk/application/wearable/fd230app/nativelauncher/include/UiConfig.h +++ b/code/sdk/application/wearable/fd230app/nativelauncher/include/UiConfig.h @@ -272,6 +272,7 @@ namespace OHOS static constexpr const char *PNG_APPLIST_BREATHE_IMAGE = APP_LIST_PATH "/breathe.bin"; // 呼吸训练 static constexpr const char *PNG_APPLIST_GOAL_IMAGE = APP_LIST_PATH "/sport.bin"; // 每日目标 static constexpr const char *PNG_APPLIST_VOICE_IMAGE = APP_LIST_PATH "/voice.bin"; // 声音 + static constexpr const char *PNG_APPLIST_AIVOICE_IMAGE = APP_LIST_PATH "/aivoice.bin"; // AI Voice(人工智能语音) /* ---------------------------------- 快速训练 ---------------------------------- */ static constexpr const char *PNG_TRAING_BOUTTONMORE_IMAGE = APP_RES_PATH "/Training/More.bin"; diff --git a/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp b/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp index 0af4c2d38..3b646de74 100644 --- a/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp +++ b/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp @@ -191,6 +191,9 @@ #include "themestyle/include/ThemeStyleView.h" #include "themestyle/include/ThemeStylePresenter.h" + +#include "aivoice/include/AiVoicePresenter.h" +#include "aivoice/include/AiVoiceView.h" /* -------------------------------------------------------------------------- */ #include "traing/include/TraingView.h" #include "traing/include/TraingPresenter.h" @@ -284,6 +287,7 @@ namespace OHOS {VIEW_WATCH_QR_CODE, &NativeLauncher::InitWatchQRCodeSlice}, // 手表二维码界面 {VIEW_RESPIRATORY_TRAINING, &NativeLauncher::InitRespiratoryTrainingSlice}, // 呼吸训练界面 {VIEW_THEME_STYLE, &NativeLauncher::InitThemeStyleSlice}, // 主题样式界面 + {VIEW_AI_VOICE, &NativeLauncher::InitAiVoiceSlice}, // Ai Voice(人工智能语音) // {VIEW_SECONDARY_FUNCTION, &NativeLauncher::InitSecondaryFunction}, // {VIEW_FAST_TRAINING, &NativeLauncher::InitFastTrainingSlice}, @@ -1241,6 +1245,18 @@ namespace OHOS } NativeAbility::GetInstance().AddSliceProxy(VIEW_THEME_STYLE, ThemeStyle); } + + /*Ai Voice(人工智能语音)*/ + void NativeLauncher::InitAiVoiceSlice(void) + { + SliceProxy *AiVoice = new AbilitySliceProxy; + if (AiVoice == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiVoice"); + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_AI_VOICE, AiVoice); + } /* -------------------------------------------------------------------------- */ void NativeLauncher::InitSetDesktopSlice(void) { diff --git a/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoiceModel.h b/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoiceModel.h new file mode 100644 index 000000000..9c40b548a --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoiceModel.h @@ -0,0 +1,26 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-06-20 15:14:43 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-06-20 20:13:47 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoiceModel.h + */ +#ifndef AI_VOICE_MODEL_H +#define AI_VOICE_MODEL_H + +namespace OHOS +{ + class AiVoiceModel + { + public: + static AiVoiceModel &GetInstance(void); + + private: + AiVoiceModel(); + ~AiVoiceModel(); + AiVoiceModel(const AiVoiceModel &) = delete; + AiVoiceModel &operator=(const AiVoiceModel &) = delete; + }; +} + +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoicePresenter.h b/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoicePresenter.h new file mode 100644 index 000000000..94b32d2c6 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoicePresenter.h @@ -0,0 +1,45 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-06-20 14:44:22 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-06-20 15:25:08 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoicePresenter.h + */ +#ifndef AI_VOICE_PRESENTER_H +#define AI_VOICE_PRESENTER_H + +#include "Presenter.h" +#include "View.h" + +namespace OHOS +{ + class AiVoiceView; + class AiVoiceModel; + class AiVoicePresenter : public Presenter, + public UIView::OnClickListener, + public UIView::OnDragListener, + public RootView::OnKeyActListener + { + public: + AiVoicePresenter(); + virtual ~AiVoicePresenter(); + static AiVoicePresenter *GetInstance(); + + void OnStart() override; + void OnPause() override; + void OnResume() 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; // 增加按键事件 + + AiVoiceModel *model; + bool X_DRAG_FLAG{false}; + }; +} + +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoiceView.h b/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoiceView.h new file mode 100644 index 000000000..7e2375235 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoiceView.h @@ -0,0 +1,67 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-06-08 09:36:01 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-06-20 19:53:13 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/respiratorytraining/include/AiVoiceView.h + */ +#ifndef AI_VOICE_VIEW_H +#define AI_VOICE_VIEW_H + +#include "BaseView.h" +#include "View.h" +#include "components/ui_label_ext.h" +#include "components/ui_button.h" + +namespace OHOS +{ + class AiVoicePresenter; + class AiVoiceView : public View + { + + public: + struct LabelConfig + { + int16_t left; + int16_t top; + int16_t width; + int16_t height; + int16_t fontSize; + int16_t lineHeigh; + uint16_t textId; + uint8_t lineBreakMode; + }; + + struct ButtonConfig + { + int16_t x; + int16_t y; + int16_t w; + int16_t h; + const char *ViewId; + }; + + AiVoiceView(); + ~AiVoiceView(); + static AiVoiceView *GetInstance(void); + + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStop() override; + + private: + UILabelExt *AiVoiceViewLabelInit(LabelConfig &labelconfig); + UIButton *AiVoiceViewLabelButtonInit(ButtonConfig &buttonconfig); + bool CreateAiVoiceViewLabel(void); + bool CreateAiVoiceViewButton(void); + void CreateAiVoiceView(void); + void ClearAll(void); + UILabelExt *title{nullptr}; + UILabelExt *startChatLabel{nullptr}; + UIButton *startChatButton{nullptr}; + + bool viewInitStatus{false}; + }; +} +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceModel.cpp new file mode 100644 index 000000000..7de4eb606 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceModel.cpp @@ -0,0 +1,23 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-06-20 15:14:50 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-06-20 15:25:15 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceModel.cpp + */ +#include "aivoice/include/AiVoiceModel.h" +#include "wearable_log.h" + +namespace OHOS +{ + AiVoiceModel::AiVoiceModel() {} + + AiVoiceModel::~AiVoiceModel() {} + + AiVoiceModel &AiVoiceModel::GetInstance() + { + static AiVoiceModel instance; + return instance; + } + +} diff --git a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoicePresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoicePresenter.cpp new file mode 100644 index 000000000..8ece842df --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoicePresenter.cpp @@ -0,0 +1,111 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-06-20 15:11:17 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-06-20 16:52:30 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoicePresenter.cpp + */ +#include "AppViewIDs.h" +#include "NativeAbility.h" +#include "aivoice/include/AiVoicePresenter.h" +#include "aivoice/include/AiVoiceView.h" +#include "aivoice/include/AiVoiceModel.h" +#include "common/key_code.h" +#include +#include "UiConfig.h" + +namespace OHOS +{ + + // 当前Presenter属性实例化的内存指针 + static AiVoicePresenter *g_pAiVoicePresenter = nullptr; + + AiVoicePresenter::AiVoicePresenter() + { + model = &AiVoiceModel::GetInstance(); + g_pAiVoicePresenter = this; + } + + AiVoicePresenter::~AiVoicePresenter() + { + g_pAiVoicePresenter = nullptr; + } + + AiVoicePresenter *AiVoicePresenter::GetInstance() + { + return g_pAiVoicePresenter; + } + + void AiVoicePresenter::OnStart() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoicePresenter::OnStart"); + Presenter::OnStart(); + } + + void AiVoicePresenter::OnPause(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoicePresenter::OnPause"); + Presenter::OnPause(); + } + + void AiVoicePresenter::OnResume(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoicePresenter::OnResume"); + Presenter::OnResume(); + if (view_ == nullptr) + { + return; + } + RootView::GetInstance()->SetOnKeyActListener(this); + } + + void AiVoicePresenter::OnStop(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoicePresenter::OnStop"); + Presenter::OnStop(); + } + + bool AiVoicePresenter::OnClick(UIView &view, const ClickEvent &event) + { + UNUSED(event); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoicePresenter::OnClick"); + return true; + } + + bool AiVoicePresenter::OnDrag(UIView &view, const DragEvent &event) + { + UNUSED(view); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoicePresenter::OnDrag"); + if ((event.GetDeltaX() > X_DRAG_OFFSET) && (event.GetDeltaX() > (DOUBLES * MATH_ABS(event.GetDeltaY())))) // 拖动过程中判断是否是水平滑动 + { + AiVoicePresenter::X_DRAG_FLAG = true; + } + return true; + } + + bool AiVoicePresenter::OnDragEnd(UIView &view, const DragEvent &event) + { + UNUSED(view); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoicePresenter::OnDragEnd"); + if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && AiVoicePresenter::X_DRAG_FLAG) + { + NativeAbility::GetInstance().Back(TransitionType::TRANSITION_BACK_TO_HEXAGONS); + AiVoicePresenter::X_DRAG_FLAG = false; + } + return true; + } + + bool AiVoicePresenter::OnKeyAct(UIView &view, const KeyEvent &event) // 增加按键事件 + { + UNUSED(view); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoicePresenter::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_BACK_TO_HEXAGONS); + } + return true; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceView.cpp b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceView.cpp new file mode 100644 index 000000000..1386fc2fb --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceView.cpp @@ -0,0 +1,195 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-05-07 11:25:58 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-06-20 20:22:36 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/AiVoice/src/AiVoiceView.cpp + */ +#include "aivoice/include/AiVoicePresenter.h" +#include "aivoice/include/AiVoiceView.h" +#include "wearable_log.h" +#include "language/font/ui_resource_string.h" +namespace OHOS +{ + + static AiVoiceView *g_pAiVoiceView{nullptr}; + + AiVoiceView::AiVoiceView() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiVoiceView::AiVoiceView"); + g_pAiVoiceView = this; + } + + AiVoiceView::~AiVoiceView() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiVoiceView::~AiVoiceView"); + g_pAiVoiceView = nullptr; + } + + AiVoiceView *AiVoiceView::GetInstance() + { + return g_pAiVoiceView; + } + + void AiVoiceView::ClearAll(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoiceView::ClearAll"); + if (viewInitStatus) + { + if (container_ != nullptr) + { + container_->RemoveAll(); + delete container_; + container_ = nullptr; + } + } + } + + UILabelExt *AiVoiceView::AiVoiceViewLabelInit(LabelConfig &labelconfig) + { + UILabelExt *label = new UILabelExt(); + if (label == nullptr) + { + return nullptr; + } + label->SetPosition(labelconfig.left, labelconfig.top, labelconfig.width, labelconfig.height); + label->SetStyle(STYLE_TEXT_FONT, labelconfig.fontSize); + label->SetStyle(STYLE_LINE_HEIGHT, labelconfig.lineHeigh); + label->SetTextId(labelconfig.textId); + label->SetLineBreakMode(labelconfig.lineBreakMode); + label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, labelconfig.fontSize); + return label; + } + + UIButton *AiVoiceView::AiVoiceViewLabelButtonInit(ButtonConfig &buttonconfig) + { + UIButton *button = new UIButton(); + if (button == nullptr) + { + return nullptr; + } + button->SetPosition(buttonconfig.x, buttonconfig.y, buttonconfig.w, buttonconfig.h); + button->SetViewId(buttonconfig.ViewId); + button->SetStyle(STYLE_BACKGROUND_COLOR, 0xff4fc34c); + button->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + button->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff191919, UIButton::PRESSED); + button->SetOnClickListener(presenter_); + + return button; + } + + bool AiVoiceView::CreateAiVoiceViewLabel(void) + { + LabelConfig labelConfig = { + .left = 83, + .top = 52, + .width = 300, + .height = 35, + .fontSize = 30, + .lineHeigh = 35, + .textId = STR_AI_INTELLIGENT_ASSISTANT, + .lineBreakMode = UILabel::LINE_BREAK_MARQUEE, + }; + title = AiVoiceViewLabelInit(labelConfig); + if (title == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "title new fail!"); + return false; + } + + labelConfig = { + .left = 133, + .top = 368, + .width = 200, + .height = 35, + .fontSize = 30, + .lineHeigh = 35, + .textId = STR_START_CHAT, + .lineBreakMode = UILabel::LINE_BREAK_MARQUEE, + }; + startChatLabel = AiVoiceViewLabelInit(labelConfig); + if (startChatLabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "startChatLabel new fail!"); + return false; + } + + return true; + } + + bool AiVoiceView::CreateAiVoiceViewButton(void) + { + ButtonConfig buttonconfig = { + .x = 93, + .y = 340, + .w = 280, + .h = 90, + .ViewId = "StartChat", + }; + startChatButton = AiVoiceViewLabelButtonInit(buttonconfig); + if (startChatButton == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "startChatButton new fail!"); + return false; + } + + return true; + } + + void AiVoiceView::CreateAiVoiceView(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoiceView::CreateAiVoiceView"); + if (!CreateAiVoiceViewLabel() || !CreateAiVoiceViewButton()) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiVoiceView::CreateAiVoiceView fail!"); + return; + } + container_->Add(title); + container_->Add(startChatButton); + container_->Add(startChatLabel); + } + + void AiVoiceView::OnStart() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoiceView::OnStart"); + View::OnStart(); + SetContainerView(new UIViewGroup()); + container_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); + container_->SetOnDragListener(presenter_); + container_->SetTouchable(true); + container_->SetDraggable(true); + + if (!viewInitStatus) + { + CreateAiVoiceView(); + viewInitStatus = true; + } + + return; + } + + void AiVoiceView::OnSetUpView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoiceView::OnSetUpView"); + View::OnSetUpView(); + Draw(); + return; + } + + void AiVoiceView::OnTearDownView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoiceView::OnTearDownView"); + View::OnTearDownView(); + return; + } + + void AiVoiceView::OnStop() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoiceView::OnStop"); + View::OnStop(); + RootView::GetInstance()->ClearOnKeyActListener(); + ClearAll(); + return; + } +} \ No newline at end of file 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 e2bdc19f5..c6b9e16d7 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistModel.cpp @@ -44,7 +44,7 @@ namespace OHOS {VIEW_THEME_STYLE, PNG_APPLIST_THEME_IMAGE, PNG_APPLIST_THEME_IMAGE, "显示方式", STR_DISPLAY_MODE, nullptr}, {VIEW_SET_CARD, PNG_APPLIST_CARDSET_IMAGE, PNG_APPLIST_CARDSET_IMAGE, "卡片管理", STR_CARD_MANAGEMENT, nullptr}, {VIEW_SET_DIAL, PNG_APPLIST_CHANGEDIAL_IMAGE, PNG_APPLIST_CHANGEDIAL_IMAGE, "更换表盘", STR_WATCH_FACE, nullptr}, - {VIEW_SOUND_VIBRATION, PNG_APPLIST_VOICE_IMAGE, PNG_APPLIST_VOICE_IMAGE, "声音", STR_WATCH_FACE, nullptr}, + {VIEW_SOUND_VIBRATION, PNG_APPLIST_VOICE_IMAGE, PNG_APPLIST_VOICE_IMAGE, "声音", STR_SOUND, nullptr}, {VIEW_CLASSIC_BLUETOOTH, PNG_APPLIST_BLUETOOTH_IMAGE, PNG_APPLIST_BLUETOOTH_IMAGE, "蓝牙", STR_BLUETOOTH, nullptr}, {VIEW_DNOTDISTURB, PNG_APPLIST_DISTURB_IMAGE, PNG_APPLIST_DISTURB_IMAGE, "勿扰模式", STR_DO_NOT_DISTURB, nullptr}, {VIEW_FLASHLIGHT, PNG_APPLIST_FLASHLIGHT_IMAGE, PNG_APPLIST_FLASHLIGHT_IMAGE, "手电筒", STR_FLASHLIGHT, nullptr}, @@ -53,6 +53,7 @@ namespace OHOS {VIEW_MESSAGE, PNG_APPLIST_MESSAGE_IMAGE, PNG_APPLIST_MESSAGE_IMAGE, "消息通知", STR_MESSAGE_NOTIFICATION, nullptr}, {VIEW_TAKEPHOTOS, PNG_APPLIST_TACKEPHOTOS_IMAGE, PNG_APPLIST_TACKEPHOTOS_IMAGE, "遥控拍照", STR_REMOTE_SHOOTING, nullptr}, {VIEW_RESPIRATORY_TRAINING, PNG_APPLIST_BREATHE_IMAGE, PNG_APPLIST_BREATHE_IMAGE, "呼吸训练", STR_BREATH_TRAINING, nullptr}, + //{VIEW_AI_VOICE, PNG_APPLIST_AIVOICE_IMAGE, PNG_APPLIST_AIVOICE_IMAGE, "AI Voice", STR_AI_VOICE, nullptr}, #ifdef SUPPORT_ALIPAY_SEC {VIEW_MAIN_ALIPAY, PNG_APPLIST_ALIPAY_IMAGE, PNG_APPLIST_ALIPAY_IMAGE, "支付宝", STR_ALIPAY, nullptr}, #endif diff --git a/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistPresenter.cpp index 888874039..644c540dc 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistPresenter.cpp @@ -62,11 +62,13 @@ namespace OHOS { void ApplistPresenter::OnPause() { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ApplistPresenter::OnPause"); Presenter::OnPause(); } void ApplistPresenter::OnStop(void) { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ApplistPresenter::OnStop"); Presenter::OnStop(); } diff --git a/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistView.cpp b/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistView.cpp index 67763dc55..c01a756fb 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistView.cpp @@ -174,7 +174,7 @@ void ApplistView::OnStop() container_ = nullptr; } RootView::GetInstance()->ClearOnKeyActListener(); - FocusManager::GetInstance()->ClearFocus(); + //FocusManager::GetInstance()->ClearFocus(); return; } 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 e080bb323..0b67237ae 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 @@ -459,4 +459,17 @@ STR_GRID_DISPLAY$网格显示 STR_CELLULAR_DISPLAY$蜂窝显示 STR_RECORDING_LIST$录音列表 STR_CRLEMPTY$当前录音列表为空 -STR_CALL_VOLUME$通话音量 \ No newline at end of file +STR_CALL_VOLUME$通话音量 +STR_AI_VOICE$AI Voice +STR_AI_INTELLIGENT_ASSISTANT$AI智能助手 +STR_START_CHAT$开始对话 +STR_BOOT_FAILED$启动失败 +STR_ENABLE_MOBILE_DATA_FIRST$请先开启移动数据 +STR_ENABLE_BLUETOOTH_FIRST$请先开启蓝牙 +STR_LISTENING$正在聆听... +STR_FINISH_SPEAKING$说话完毕 +STR_THINKING$正在思考 +STR_CANCEL$取消 +STR_CONNECT_TIMEOUT$连接超时 +STR_PLEASE_RESTART_CHAT$请开始重新对话 +STR_CONTINUE_CHAT$继续对话 \ No newline at end of file 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 503010b7b..f03ceb6d6 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 @@ -461,4 +461,17 @@ + + + + + + + + + + + + + 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 8b36d0d4464d3e760958754e6ae4b633aa15ce77..f1028ed8f1e0ece2e4105a2c6181ab0a5b4a78d3 100644 GIT binary patch delta 89 zcmeBnJL4w0WJj`PY90d$c(zeAmECZnGy}sVAf61wQ-F9X5KjZ*=|DUKh-U)vEFhi@ T#B+dn?&fm#DbkZ4DDeUSVloqc delta 35 fcmX@(*6k)*Y4*D_HID%W+}tRd%D#CW`$TB~uZ;;F diff --git a/code/sdk/application/wearable/fd230app/nativeui/language/font/ja.lang b/code/sdk/application/wearable/fd230app/nativeui/language/font/ja.lang index 527f904b70d93e629dbf0d5f653d3a5730c9574e..13f845c2b1d119f0acb4a3c85005fcdcdab135bb 100644 GIT binary patch delta 89 zcmaE5vD#9!X2!;yS&0lN;MqpeRCdD;A`A>4f%p>;e+J?&K>QVmzX9=gApQZwKY{oc T5dQ|^Kbyd~R0f>EpI1Pv^fw&WhrvdR|AYKK; z+kyD(=5ls9>3T;`g|Ph0>^PaBjdA5EkSkht6if0XTUo::OnStart(); } void SoundAndVibrationPresenter::OnPause(void) { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationPresenter::OnPause"); Presenter::OnPause(); } void SoundAndVibrationPresenter::OnResume(void) { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationPresenter::OnResume"); Presenter::OnResume(); if (view_ == nullptr) { @@ -62,6 +65,7 @@ namespace OHOS void SoundAndVibrationPresenter::OnStop(void) { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationPresenter::OnStop"); Presenter::OnStop(); } diff --git a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationView.cpp b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationView.cpp index 9f0427e18..fe77925c4 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationView.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-02-19 10:39:14 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-06-19 17:46:53 + * @LastEditTime: 2024-06-20 18:03:01 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationView.cpp */ #include "soundandvibration/include/SoundAndVibrationView.h" @@ -250,9 +250,7 @@ namespace OHOS container_->SetDraggable(true); CreateSoundAndVibrationView(); - - RootView::OnKeyActListener *keyactListener = (RootView::OnKeyActListener *)OHOS::SoundAndVibrationPresenter::GetInstance(); - RootView::GetInstance()->SetOnKeyActListener(keyactListener); + RootView::GetInstance()->SetOnKeyActListener(presenter_); } void SoundAndVibrationView::OnSetUpView() diff --git a/code/sdk/application/wearable/nativeabilityfwk/src/Ability.cpp b/code/sdk/application/wearable/nativeabilityfwk/src/Ability.cpp index 75376b1f4..0df25d504 100755 --- a/code/sdk/application/wearable/nativeabilityfwk/src/Ability.cpp +++ b/code/sdk/application/wearable/nativeabilityfwk/src/Ability.cpp @@ -17,7 +17,7 @@ #include "graphic_service.h" #include "abilityms_slite_client.h" #include "common/input_device_manager.h" - +#include "dock/focus_manager.h" namespace OHOS { /* * @brief 负责将一个SliceProxy对象添加到Ability对象中,如果传入的sliceId是无效的或者代理对象proxy为空,则不执行任何操作。 @@ -134,6 +134,7 @@ void Ability::PostChangeSlice(const uint16_t targetSliceId, TransitionType type, */ bool useTransition = sliceTransition_.SetTransitionType(type); bool isCurSnapshotEnabled = sliceTransition_.IsCurrentSnapshotEnabled(); + FocusManager::GetInstance()->ClearFocus(); if (!useTransition) { StopSlice(); diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/AIVoice/AIRecBlack.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/AIVoice/AIRecBlack.bin new file mode 100644 index 000000000..e73db6e10 --- /dev/null +++ b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/AIVoice/AIRecBlack.bin @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fd2acea8d7166abd98536687c9a59a37e66dcadf5dc0152bb6185e04ce9fa13d +size 1560 diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/AIVoice/AIRecGreen.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/AIVoice/AIRecGreen.bin new file mode 100644 index 000000000..c216e1bfd --- /dev/null +++ b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/AIVoice/AIRecGreen.bin @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:96e2af6c30df028b9c9c0e032325f1e45d8b872aaffe8712215d3d2262ea9c0e +size 1560 diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/AIVoice/AIUnion.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/AIVoice/AIUnion.bin new file mode 100644 index 000000000..4507f4219 --- /dev/null +++ b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/AIVoice/AIUnion.bin @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:72c650a3bf3f61a231a466b92b72c75322b158da9bb966dd72d37619fb79830f +size 408 diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/applist_icon/aivoice.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/applist_icon/aivoice.bin new file mode 100644 index 000000000..9832b7c60 --- /dev/null +++ b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/applist_icon/aivoice.bin @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2aac78100175b3b8cf9b5fc04ac3c41611825058e88601847a0f03263248b771 +size 5544 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 8b36d0d4464d3e760958754e6ae4b633aa15ce77..f1028ed8f1e0ece2e4105a2c6181ab0a5b4a78d3 100644 GIT binary patch delta 89 zcmeBnJL4w0WJj`PY90d$c(zeAmECZnGy}sVAf61wQ-F9X5KjZ*=|DUKh-U)vEFhi@ T#B+dn?&fm#DbkZ4DDeUSVloqc delta 35 fcmX@(*6k)*Y4*D_HID%W+}tRd%D#CW`$TB~uZ;;F diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/font/ja.lang b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/font/ja.lang index 527f904b70d93e629dbf0d5f653d3a5730c9574e..13f845c2b1d119f0acb4a3c85005fcdcdab135bb 100644 GIT binary patch delta 89 zcmaE5vD#9!X2!;yS&0lN;MqpeRCdD;A`A>4f%p>;e+J?&K>QVmzX9=gApQZwKY{oc T5dQ|^Kbyd~R0f>EpI1Pv^fw&WhrvdR|AYKK; z+kyD(=5ls9>3T;`g|Ph0>^PaBjdA5EkSkht6if0XTUo