From 7249f0d69fb2bebd887110345db2a6591cd1a957 Mon Sep 17 00:00:00 2001 From: luozheng <1732036298@qq.com> Date: Sat, 31 Aug 2024 16:28:08 +0800 Subject: [PATCH] =?utf8?q?AI=E8=AF=AD=E9=9F=B3=E4=BC=98=E5=8C=96=E4=BF=AE?= =?utf8?q?=E6=94=B9=EF=BC=9A=201.=E5=8A=A8=E7=94=BB=E6=94=B9=E4=B8=BAimage?= =?utf8?q?info=E5=88=9B=E5=BB=BA=E5=92=8C=E9=87=8A=E6=94=BE=E6=94=B9?= =?utf8?q?=E5=96=84=E5=86=85=E5=AD=98=E6=B3=84=E6=BC=8F=202.=E6=B7=BB?= =?utf8?q?=E5=8A=A0=E5=AF=B9=E5=BA=94=E5=9B=9E=E5=BA=94=E7=B1=BB=E5=9E=8B?= =?utf8?q?=E7=9A=84=E9=94=99=E8=AF=AF=E5=BC=B9=E7=AA=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../aivoice/include/AiVoiceConnectingView.h | 9 +-- .../nativeui/aivoice/include/AiVoiceModel.h | 9 ++- .../aivoice/include/AiVoicePresenter.h | 3 +- .../include/AivoiceConnectTimeoutView.h | 7 +- .../aivoice/include/AivoiceListeningView.h | 10 +-- .../aivoice/include/AivoiceThinkingView.h | 6 +- .../aivoice/src/AiVoiceConnectingView.cpp | 15 ++-- .../nativeui/aivoice/src/AiVoiceModel.cpp | 61 +++++++++++++++-- .../nativeui/aivoice/src/AiVoicePresenter.cpp | 17 ++++- .../nativeui/aivoice/src/AiVoiceView.cpp | 7 +- .../aivoice/src/AivoiceConnectTimeoutView.cpp | 68 +++++++++++-------- .../aivoice/src/AivoiceListeningView.cpp | 13 ++-- .../aivoice/src/AivoiceThinkingView.cpp | 14 ++-- .../nativeui/uiservice/include/ui_service.h | 3 +- .../nativeui/uiservice/src/ui_service.cpp | 10 +++ 15 files changed, 179 insertions(+), 73 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoiceConnectingView.h b/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoiceConnectingView.h index dfeb450d6..4f69a4e44 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoiceConnectingView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoiceConnectingView.h @@ -1,4 +1,4 @@ -/*** +/*** * @Date: 2024-08-19 19:20:08 * @LastEditors: Caisking 3449750381@qq.com * @LastEditTime: 2024-08-30 18:57:30 @@ -8,7 +8,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-08-03 11:09:56 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-08-19 16:19:42 + * @LastEditTime: 2024-08-31 15:11:11 * @FilePath: /xts_origin/FD230/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoiceConnectingView.h */ @@ -53,7 +53,7 @@ namespace OHOS int16_t width; int16_t height; ImageAnimatorInfo *imageInfoArray; - const char *const *pathsArray; + const ImageInfo **pathsArray; uint8_t numFrames; int delay; }; @@ -63,6 +63,7 @@ namespace OHOS static AiVoiceConnectingView *GetInstance(void); UIScrollView *CreateAiVoiceConnectingView(void); UIScrollView *CreateAiVoiceConnectingView(uint8_t); + private: UIImageAnimatorView *connectingImageAnimatorInit(ImageAnimatorConfig &imageanimatorconfig); UILabelExt *AiVoiceConnectingViewLabelInit(LabelConfig &labelconfig); @@ -79,7 +80,7 @@ namespace OHOS UIButton *cancelButton{nullptr}; UIImageAnimatorView *connectingAnimatorView{nullptr}; ImageAnimatorInfo connectingImageInfo[AIVOICE_CONNECTING_IMAGE_ANIMATOR_VIEW_NUM_FRAMES]; - const char **connectingPathsArray{nullptr}; + const ImageInfo **connectingPathsArray{nullptr}; }; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoiceModel.h b/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoiceModel.h index 87b1d09b1..ddee102c4 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoiceModel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoiceModel.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-06-20 15:14:43 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-08-28 17:45:47 + * @LastEditTime: 2024-08-31 16:14:37 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoiceModel.h */ #ifndef AI_VOICE_MODEL_H @@ -38,6 +38,7 @@ namespace OHOS static AiVoiceModel &GetInstance(void); // 获取单例实例 bool ChangeToReturnResultTextView(void); bool ChangeToAIVoiceListeningView(bool value); + bool ChangeToAIVoiceConnectTimeoutView(); void FunctionKeyOnClickToChangeAIModel(void); // 初始化和状态管理 bool CreateIfNotExists(); @@ -51,6 +52,10 @@ namespace OHOS void SetAiVoiceConnectStatus(bool state); void QuerySelectedAiModelIsConnect(); void CancelCurAIChat(void); + int GetAIResponseType(void); + std::string GetErrnote(void); + void SetCurView(int16_t viewNum); + int GetCurView(void); // 聊天内容管理 bool InitchatContentItems(void); @@ -116,6 +121,8 @@ namespace OHOS std::map> selectAiModelToTextId; // pair的参数类型<模型的textid,查询模型是否可用id> bool AiVoiceConnectStatus{false}; //与AI模型的连接状态 uint8_t AIResponseType; + std::string errnote; //错误信息 + int16_t curView{0}; }; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoicePresenter.h b/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoicePresenter.h index 25cf52333..8768583ce 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoicePresenter.h +++ b/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoicePresenter.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-06-20 14:44:22 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-08-09 19:52:53 + * @LastEditTime: 2024-08-31 16:13:42 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoicePresenter.h */ #ifndef AI_VOICE_PRESENTER_H @@ -45,6 +45,7 @@ namespace OHOS bool JumpToReturnResultTextView(void); bool ChangeToAIVoiceListeningView(bool val); + bool ChangeToAIVoiceConnectTimeoutView(); bool ChangeViewAndLogicOperator(int16_t hideView, int16_t showView); void FunctionKeyOnClickToChangeAIModel(void); void DragLeftToRightChangeAIModel(void); diff --git a/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AivoiceConnectTimeoutView.h b/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AivoiceConnectTimeoutView.h index 25d25e4ff..187c2a579 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AivoiceConnectTimeoutView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AivoiceConnectTimeoutView.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-06-22 16:46:26 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-06-22 17:00:33 + * @LastEditTime: 2024-08-31 16:14:01 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AivoiceConnectTimeoutView.h */ @@ -53,7 +53,8 @@ namespace OHOS ~AivoiceConnectTimeoutView(); static AivoiceConnectTimeoutView *GetInstance(void); UIScrollView *CreateAivoiceConnectTimeoutView(void); - + void UpdateTitleTextId(int textId); + void UpdateNoteText(); private: void ClearAll(void); UILabelExt *AivoiceConnectTimeoutLabelInit(LabelConfig &labelconfig); @@ -66,7 +67,7 @@ namespace OHOS UIScrollView *scrollView{nullptr}; UILabelExt *title{nullptr}; UIImageView *attentionImage{nullptr}; - UILabelExt *label[2]{nullptr}; + UILabelExt *NoteLabel{nullptr}; UILabelExt *ensure{nullptr}; UIButton *ensureButton{nullptr}; }; diff --git a/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AivoiceListeningView.h b/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AivoiceListeningView.h index c89704334..3c001b7f6 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AivoiceListeningView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AivoiceListeningView.h @@ -1,4 +1,4 @@ -/*** +/*** * @Date: 2024-06-26 16:59:51 * @LastEditors: Caisking 3449750381@qq.com * @LastEditTime: 2024-08-30 18:57:36 @@ -8,7 +8,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-06-22 16:46:26 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-06-25 15:39:07 + * @LastEditTime: 2024-08-31 14:56:06 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AivoiceListeningView.h */ @@ -60,8 +60,8 @@ namespace OHOS int16_t y; int16_t width; int16_t height; - ImageAnimatorInfo* imageInfoArray; - const char* const* pathsArray; + ImageAnimatorInfo *imageInfoArray; + const ImageInfo **pathsArray; uint8_t numFrames; int delay; }; @@ -86,7 +86,7 @@ namespace OHOS UIButton *finishSpeakButton{nullptr}; UIImageAnimatorView *AiVoiceListeningImageAnimatorView{nullptr}; ImageAnimatorInfo AiVoiceListeningImageInfo[AIVOICE_LISTENING_IMAGE_ANIMATOR_VIEW_NUM_FRAMES]; - const char **AiVoiceListeningPathsArray{nullptr}; + const ImageInfo **AiVoiceListeningPathsArray{nullptr}; }; } #endif diff --git a/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AivoiceThinkingView.h b/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AivoiceThinkingView.h index cad3da12f..685791b33 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AivoiceThinkingView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AivoiceThinkingView.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-06-22 16:46:26 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-07-31 11:33:33 + * @LastEditTime: 2024-08-31 15:08:52 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AivoiceThinkingView.h */ @@ -55,7 +55,7 @@ namespace OHOS int16_t width; int16_t height; ImageAnimatorInfo *imageInfoArray; - const char *const *pathsArray; + const ImageInfo **pathsArray; uint8_t numFrames; int delay; }; @@ -80,7 +80,7 @@ namespace OHOS UIButton *cancelThinkButton{nullptr}; UIImageAnimatorView *AiVoiceThinkingImageAnimatorView{nullptr}; ImageAnimatorInfo AiVoiceThinkingImageInfo[AIVOICE_THINKING_IMAGE_ANIMATOR_VIEW_NUM_FRAMES]; - const char **AiVoiceThinkingPathsArray{nullptr}; + const ImageInfo **AiVoiceThinkingPathsArray{nullptr}; }; } #endif diff --git a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceConnectingView.cpp b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceConnectingView.cpp index 2df64ab0c..7405572fc 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceConnectingView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceConnectingView.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-08-03 11:10:08 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-08-19 16:41:43 + * @LastEditTime: 2024-08-31 15:11:39 * @FilePath: /xts_origin/FD230/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceConnectingView.cpp */ #include "aivoice/include/AiVoiceConnectingView.h" @@ -50,7 +50,8 @@ namespace OHOS connectingAnimatorView->Stop(); delete connectingAnimatorView; connectingAnimatorView = nullptr; - FreeImagePathsArray(connectingPathsArray, AIVOICE_CONNECTING_IMAGE_ANIMATOR_VIEW_NUM_FRAMES); + FreeImageInfoArray(connectingPathsArray, AIVoiceListeningImagePaths, AIVOICE_CONNECTING_IMAGE_ANIMATOR_VIEW_NUM_FRAMES); + } if (cancelLabel) { @@ -118,10 +119,10 @@ namespace OHOS for (uint8_t i = 0; i < imageanimatorconfig.numFrames; i++) { - // imageanimatorconfig.imageInfoArray[i].imageInfo = ImageCacheManager::GetInstance().LoadSingleRes(imageanimatorconfig.pathsArray[i]); - // imageanimatorconfig.imageInfoArray[i].imageType = IMG_SRC_IMAGE_INFO; - imageanimatorconfig.imageInfoArray[i].imagePath = (imageanimatorconfig.pathsArray[i]); - imageanimatorconfig.imageInfoArray[i].imageType = IMG_SRC_FILE_PATH; + imageanimatorconfig.imageInfoArray[i].imageInfo = (imageanimatorconfig.pathsArray[i]); + imageanimatorconfig.imageInfoArray[i].imageType = IMG_SRC_IMAGE_INFO; + // imageanimatorconfig.imageInfoArray[i].imagePath = (imageanimatorconfig.pathsArray[i]); + // imageanimatorconfig.imageInfoArray[i].imageType = IMG_SRC_FILE_PATH; imageanimatorconfig.imageInfoArray[i].pos.x = imageanimatorconfig.x; imageanimatorconfig.imageInfoArray[i].pos.y = imageanimatorconfig.y; imageanimatorconfig.imageInfoArray[i].width = imageanimatorconfig.width; @@ -209,7 +210,7 @@ namespace OHOS bool AiVoiceConnectingView::CreateAivoiceConnectingImageAnimator(void) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoiceConnectingView::CreateAivoiceConnectingImageAnimator"); - connectingPathsArray = CreateImagePathsArray(AIVoiceListeningImagePaths, AIVOICE_CONNECTING_IMAGE_ANIMATOR_VIEW_NUM_FRAMES); + connectingPathsArray = CreateImageInfoArray(AIVoiceListeningImagePaths, AIVOICE_CONNECTING_IMAGE_ANIMATOR_VIEW_NUM_FRAMES); if (connectingPathsArray == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiVoiceConnectingView::connectingPathsArray is nullptr!!"); diff --git a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceModel.cpp index c457ba92c..3e03713cd 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceModel.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-06-20 15:14:50 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-08-28 17:46:07 + * @LastEditTime: 2024-08-31 16:13:29 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceModel.cpp */ #include "aivoice/include/AiVoiceModel.h" @@ -42,6 +42,7 @@ namespace OHOS return instance; } + // 跳转到返回结果界面 bool AiVoiceModel::ChangeToReturnResultTextView(void) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoiceModel::ChangeToReturnResultTextView"); @@ -69,6 +70,21 @@ namespace OHOS return true; } + // 切换到AI回应错误界面 + bool AiVoiceModel::ChangeToAIVoiceConnectTimeoutView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoiceModel::ChangeToAIVoiceConnectTimeoutView"); + AiVoicePresenter *Aipresenter_ = AiVoicePresenter::GetInstance(); + if (Aipresenter_ == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiVoicePresenter::GetInstance() fail!!"); + return false; + } + Aipresenter_->ChangeToAIVoiceConnectTimeoutView(); + return true; + } + + // 功能键切换模型 void AiVoiceModel::FunctionKeyOnClickToChangeAIModel(void) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoiceModel::FunctionKeyOnClickToChangeAIModel"); @@ -166,12 +182,34 @@ namespace OHOS } } - /*取消当前AI对话*/ + /*取消当前AI对话*/ void AiVoiceModel::CancelCurAIChat(void) { cancel_AI_cur_chat(); } + int AiVoiceModel::GetAIResponseType(void) + { + return AIResponseType; + } + + std::string AiVoiceModel::GetErrnote(void) + { + return errnote; + } + + /*设置当前哪个子视图是可见的*/ + void AiVoiceModel::SetCurView(int16_t viewNum) + { + curView = viewNum; + } + + /*获取当前哪个子视图是可见的*/ + int AiVoiceModel::GetCurView(void) + { + return curView; + } + /*列表数量*/ uint8_t AiVoiceModel::GetChatContentListCount(void) { @@ -306,6 +344,9 @@ namespace OHOS WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoiceModel::UpdateUserQuestionStr"); RemoveLastTwoItemsOrClear(); + /* -------------------------------------------------------------------------- */ + ScreenTurnOn(5 * 1000); // 有消息来就亮屏5秒 + /* -------------------------------------------------------------------------- */ if (!AddUserQuestionToChatItems()) { @@ -425,7 +466,7 @@ namespace OHOS std::string AiVoiceModel::GetAiAnswerStr(void) { // aiAnswerStr = "春风化雨,时光荏苒。百年之内,生命如白驹过隙,转瞬即逝。唯有心存善念,用爱化解芥蒂,用智慧建构未来,才是人生的真正意义。让我们携手共进,用每一分时光去关爱他人,用每一滴汗水去创造奇迹,用每一个眼神去传递温暖。让这个世界因我们的存在而变得更加美好。生命短暂,但只要我们怀着虔诚的心,坚韧前行,我们就一定能在有限的时光里留下无限的可能。"; - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "GetAiAnswerStr:%s\n", aiAnswerStr.c_str()); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "GetAiAnswerStr:%s", aiAnswerStr.c_str()); return aiAnswerStr; } @@ -449,8 +490,16 @@ namespace OHOS void AiVoiceModel::SetAiAnswerStrStr(std::string str, uint8_t type) { - aiAnswerStr += str; AIResponseType = type; + errnote = str; + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AIResponseType = %d,errnote = %s\n", AIResponseType, errnote.c_str()); + if (AIResponseType == AiVoiceModel::AI_RECORDING_PARSING_ERROR || AIResponseType == AiVoiceModel::AI_RESPONSE_ERROR) + { + SendMsgToUIService(UI_AI_JUMP_TO_RESPONDERR_VIEW, 0, (void *)errnote.c_str(), errnote.length()); + ScreenTurnOn(5 * 1000); // 有消息来就亮屏5秒 + return; + } + aiAnswerStr += str; SendMsgToUIService(UI_UPDATE_AI_ANSWER_STR, 0, nullptr, 0); } @@ -597,7 +646,7 @@ namespace OHOS { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AIVoice_TimerCallbackProc,AiModelConnectTimeout = %d", AiModelConnectTimeout); AiModelConnectTimeout--; - if (AiModelConnectTimeout < 0) + if (AiModelConnectTimeout < 0) // 模型连接失败有5秒超时 { AiVoiceModel::GetInstance().AIVoice_StopTimer(); AiVoiceView *view_ = AiVoiceView::GetInstance(); @@ -619,6 +668,8 @@ namespace OHOS if (Time == 30) { AiVoiceModel::GetInstance().CheckFileAndSendAIIsReady(); + AiVoiceModel::GetInstance().AIVoice_StopTimer(); + return; } if (Time < 0) // 如果思考时间超时30s,进入连接超时界面 { diff --git a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoicePresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoicePresenter.cpp index 35c490adf..40ccaab12 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoicePresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoicePresenter.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-06-20 15:11:17 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-08-28 17:46:50 + * @LastEditTime: 2024-08-31 16:13:34 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoicePresenter.cpp */ #include "AppViewIDs.h" @@ -127,6 +127,21 @@ namespace OHOS return true; } + bool AiVoicePresenter::ChangeToAIVoiceConnectTimeoutView() + { + if ((view_->GetAiVoiceScrollView(AIVOICE_THINKING_VIEWID) != nullptr) && + (view_->GetAiVoiceScrollView(AIVOICE_THINKING_VIEWID)->IsVisible())) + { + ChangeViewAndLogicOperator(AiVoiceModel::GetInstance().GetCurView(), AIVOICE_CONNECT_TIMEOUT_VIEWID); + AivoiceConnectTimeoutView *p_AivoiceConnectTimeoutView = AivoiceConnectTimeoutView::GetInstance(); + if (p_AivoiceConnectTimeoutView) + { + p_AivoiceConnectTimeoutView->UpdateNoteText(); + } + } + return true; + } + void AiVoicePresenter::FunctionKeyOnClickToChangeAIModel(void) { int index = model->GetSelectAiModel() + 1; diff --git a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceView.cpp b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceView.cpp index 2343c9df6..1af83f7a8 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceView.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-05-07 11:25:58 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-08-28 17:47:15 + * @LastEditTime: 2024-08-31 14:32:02 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/AiVoice/src/AiVoiceView.cpp */ #include "aivoice/include/AiVoicePresenter.h" @@ -797,6 +797,7 @@ namespace OHOS AiVoiceScrollView[showView]->SetVisible(true); Draw(); DestroyTempView(hideView); + AiVoiceModel::GetInstance().SetCurView(showView); return; } @@ -870,6 +871,10 @@ namespace OHOS { p_AivoiceMobileDataFailedStartView->UpdateTitleTextId(textId); } + if (p_AivoiceConnectTimeoutView) + { + p_AivoiceConnectTimeoutView->UpdateTitleTextId(textId); + } } } \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AivoiceConnectTimeoutView.cpp b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AivoiceConnectTimeoutView.cpp index 3687cca0c..03ff9a1bf 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AivoiceConnectTimeoutView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AivoiceConnectTimeoutView.cpp @@ -2,11 +2,12 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-05-07 11:25:58 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-08-02 15:44:02 + * @LastEditTime: 2024-08-31 16:13:53 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/AiVoice/src/AivoiceConnectTimeoutView.cpp */ #include "aivoice/include/AiVoicePresenter.h" #include "aivoice/include/AivoiceConnectTimeoutView.h" +#include "aivoice/include/AiVoiceModel.h" #include "wearable_log.h" #include "ui_resource_string.h" #include @@ -40,40 +41,31 @@ namespace OHOS if (scrollView != nullptr) { scrollView->RemoveAll(); - if (title != nullptr) { delete title; title = nullptr; } - if (attentionImage != nullptr) { delete attentionImage; attentionImage = nullptr; } - - for (int i = 0; i < 2; i++) + if (NoteLabel != nullptr) { - if (label[i] != nullptr) - { - delete label[i]; - label[i] = nullptr; - } + delete NoteLabel; + NoteLabel = nullptr; } - if (ensure != nullptr) { delete ensure; ensure = nullptr; } - if (ensureButton != nullptr) { delete ensureButton; ensureButton = nullptr; } - delete scrollView; scrollView = nullptr; } @@ -91,7 +83,6 @@ namespace OHOS label->SetStyle(STYLE_LINE_HEIGHT, labelconfig.lineHeigh); label->SetTextId(labelconfig.textId); label->SetLineBreakMode(labelconfig.lineBreakMode); - label->SetRollSpeed(70); label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, labelconfig.fontSize); label->SetRollSpeed(LABEL_ROLL_SPEED); @@ -158,7 +149,7 @@ namespace OHOS .height = 35, .fontSize = 30, .lineHeigh = 35, - .textId = STR_AI_INTELLIGENT_ASSISTANT, + .textId = AiVoiceModel::GetInstance().GetAiModelTextId(), .lineBreakMode = UILabel::LINE_BREAK_OSCILLATION, }; title = AivoiceConnectTimeoutLabelInit(labelconfig); @@ -168,20 +159,19 @@ namespace OHOS return false; } /* -------------------------------------------------------------------------- */ - labelconfig.left = 53; - labelconfig.width = 360; - int textId[] = {STR_CONNECT_TIMEOUT, STR_PLEASE_RESTART_CHAT}; - for (int i = 0; i < 2; i++) + NoteLabel = new UILabelExt(); + if (NoteLabel == nullptr) { - labelconfig.top = 222 + i * labelconfig.height; - labelconfig.textId = textId[i]; - label[i] = AivoiceConnectTimeoutLabelInit(labelconfig); - if (label[i] == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AivoiceConnectTimeoutView::label[%d] is nullptr!", i); - return false; - } + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "NoteLabel is nullptr!"); + return false; } + NoteLabel->SetPosition(53, 222, 360, 70); + NoteLabel->SetStyle(STYLE_TEXT_FONT, 30); + NoteLabel->SetStyle(STYLE_LINE_HEIGHT, 35); + NoteLabel->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION); + NoteLabel->SetRollSpeed(70); + NoteLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + NoteLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); /* -------------------------------------------------------------------------- */ labelconfig = { .left = 133, @@ -264,12 +254,32 @@ namespace OHOS } scrollView->Add(title); scrollView->Add(attentionImage); - scrollView->Add(label[0]); - scrollView->Add(label[1]); + scrollView->Add(NoteLabel); scrollView->Add(ensureButton); scrollView->Add(ensure); } return scrollView; } + void AivoiceConnectTimeoutView::UpdateTitleTextId(int textId) + { + if (title) + { + title->SetTextId(textId); + title->ForceResetText(); + } + } + + // 更新错误信息内容 + void AivoiceConnectTimeoutView::UpdateNoteText() + { + if (NoteLabel) + { + NoteLabel->SetText(""); + std::string text = AiVoiceModel::GetInstance().GetErrnote(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "text = %s", text.c_str()); + NoteLabel->SetText(text.c_str()); + NoteLabel->Invalidate(); + } + } } \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AivoiceListeningView.cpp b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AivoiceListeningView.cpp index 237a34224..ddfd2fb6b 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AivoiceListeningView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AivoiceListeningView.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-05-07 11:25:58 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-08-02 15:44:32 + * @LastEditTime: 2024-08-31 15:12:44 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/AiVoice/src/AivoiceListeningView.cpp */ #include "aivoice/include/AiVoicePresenter.h" @@ -54,7 +54,7 @@ namespace OHOS delete AiVoiceListeningImageAnimatorView; AiVoiceListeningImageAnimatorView = nullptr; - FreeImagePathsArray(AiVoiceListeningPathsArray, AIVOICE_LISTENING_IMAGE_ANIMATOR_VIEW_NUM_FRAMES); + FreeImageInfoArray(AiVoiceListeningPathsArray, AIVoiceListeningImagePaths, AIVOICE_LISTENING_IMAGE_ANIMATOR_VIEW_NUM_FRAMES); } if (finishSpeak != nullptr) @@ -119,9 +119,10 @@ namespace OHOS for (uint8_t i = 0; i < imageanimatorconfig.numFrames; i++) { - // imageanimatorconfig.imageInfoArray[i].imageInfo = ImageCacheManager::GetInstance().LoadSingleRes(imageanimatorconfig.pathsArray[i]); - imageanimatorconfig.imageInfoArray[i].imagePath = (imageanimatorconfig.pathsArray[i]); - imageanimatorconfig.imageInfoArray[i].imageType = IMG_SRC_FILE_PATH; + imageanimatorconfig.imageInfoArray[i].imageInfo = imageanimatorconfig.pathsArray[i]; + // imageanimatorconfig.imageInfoArray[i].imagePath = (imageanimatorconfig.pathsArray[i]); + // imageanimatorconfig.imageInfoArray[i].imageType = IMG_SRC_FILE_PATH; + imageanimatorconfig.imageInfoArray[i].imageType = IMG_SRC_IMAGE_INFO; imageanimatorconfig.imageInfoArray[i].pos.x = imageanimatorconfig.x; imageanimatorconfig.imageInfoArray[i].pos.y = imageanimatorconfig.y; imageanimatorconfig.imageInfoArray[i].width = imageanimatorconfig.width; @@ -231,7 +232,7 @@ namespace OHOS bool AivoiceListeningView::CreateAivoiceListeningImageAnimator(void) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AivoiceListeningView::CreateAivoiceListeningImageAnimator"); - AiVoiceListeningPathsArray = CreateImagePathsArray(AIVoiceListeningImagePaths, AIVOICE_LISTENING_IMAGE_ANIMATOR_VIEW_NUM_FRAMES); + AiVoiceListeningPathsArray = CreateImageInfoArray(AIVoiceListeningImagePaths, AIVOICE_LISTENING_IMAGE_ANIMATOR_VIEW_NUM_FRAMES); if (AiVoiceListeningPathsArray == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AivoiceListeningView::AiVoiceListeningPathsArray is nullptr!!"); diff --git a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AivoiceThinkingView.cpp b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AivoiceThinkingView.cpp index 40654518e..e8054a6d9 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AivoiceThinkingView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AivoiceThinkingView.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-05-07 11:25:58 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-08-02 15:44:41 + * @LastEditTime: 2024-08-31 15:09:13 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/AiVoice/src/AivoiceThinkingView.cpp */ #include "aivoice/include/AiVoicePresenter.h" @@ -54,7 +54,8 @@ namespace OHOS delete AiVoiceThinkingImageAnimatorView; AiVoiceThinkingImageAnimatorView = nullptr; - FreeImagePathsArray(AiVoiceThinkingPathsArray, AIVOICE_THINKING_IMAGE_ANIMATOR_VIEW_NUM_FRAMES); + // FreeImagePathsArray(AiVoiceThinkingPathsArray, AIVOICE_THINKING_IMAGE_ANIMATOR_VIEW_NUM_FRAMES); + FreeImageInfoArray(AiVoiceThinkingPathsArray, AIVoiceThinkingImagePaths, AIVOICE_THINKING_IMAGE_ANIMATOR_VIEW_NUM_FRAMES); } if (cancelThink != nullptr) @@ -119,9 +120,10 @@ namespace OHOS for (uint8_t i = 0; i < imageanimatorconfig.numFrames; i++) { - // imageanimatorconfig.imageInfoArray[i].imageInfo = ImageCacheManager::GetInstance().LoadSingleRes(imageanimatorconfig.pathsArray[i]); - imageanimatorconfig.imageInfoArray[i].imagePath = (imageanimatorconfig.pathsArray[i]); - imageanimatorconfig.imageInfoArray[i].imageType = IMG_SRC_FILE_PATH; + imageanimatorconfig.imageInfoArray[i].imageInfo = (imageanimatorconfig.pathsArray[i]); + // imageanimatorconfig.imageInfoArray[i].imagePath = (imageanimatorconfig.pathsArray[i]); + // imageanimatorconfig.imageInfoArray[i].imageType = IMG_SRC_FILE_PATH; + imageanimatorconfig.imageInfoArray[i].imageType = IMG_SRC_IMAGE_INFO; imageanimatorconfig.imageInfoArray[i].pos.x = imageanimatorconfig.x; imageanimatorconfig.imageInfoArray[i].pos.y = imageanimatorconfig.y; imageanimatorconfig.imageInfoArray[i].width = imageanimatorconfig.width; @@ -232,7 +234,7 @@ namespace OHOS bool AivoiceThinkingView::CreateAivoiceThinkingImageAnimator(void) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AivoiceThinkingView::CreateAivoiceThinkingImageAnimator"); - AiVoiceThinkingPathsArray = CreateImagePathsArray(AIVoiceThinkingImagePaths, AIVOICE_THINKING_IMAGE_ANIMATOR_VIEW_NUM_FRAMES); + AiVoiceThinkingPathsArray = CreateImageInfoArray(AIVoiceThinkingImagePaths, AIVOICE_THINKING_IMAGE_ANIMATOR_VIEW_NUM_FRAMES); if (AiVoiceThinkingPathsArray == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AivoiceThinkingView::AiVoiceThinkingPathsArray is nullptr!!"); diff --git a/code/sdk/application/wearable/fd230app/nativeui/uiservice/include/ui_service.h b/code/sdk/application/wearable/fd230app/nativeui/uiservice/include/ui_service.h index cfeef57bc..99efadec4 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/uiservice/include/ui_service.h +++ b/code/sdk/application/wearable/fd230app/nativeui/uiservice/include/ui_service.h @@ -8,7 +8,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-06-12 11:44:04 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-08-29 18:44:06 + * @LastEditTime: 2024-08-31 14:20:21 * @FilePath: /FD230/code/sdk/application/wearable/nativeapp/nativeui/uiservice/include/ui_service.h */ /* @@ -81,6 +81,7 @@ typedef enum { UI_AI_JUMP_TO_RESULT_VIEW, //跳转到返回结果视图 UI_AI_JUMP_TO_LISTENING_VIEW,//跳转到AI聆听界面 + UI_AI_JUMP_TO_RESPONDERR_VIEW,//处理跳转AI回应错误界面 UI_UPDATE_USER_QUESTION_STR,//更新用户问题的字符串 UI_UPDATE_AI_ANSWER_STR, //更新AI答案的字符串 UI_HAND_WATCH_FIRST_PAIRED, //手表已配对:给第一次手表启动用配对成功调用 diff --git a/code/sdk/application/wearable/fd230app/nativeui/uiservice/src/ui_service.cpp b/code/sdk/application/wearable/fd230app/nativeui/uiservice/src/ui_service.cpp index 25ddee6a4..6a9d493fb 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/uiservice/src/ui_service.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/uiservice/src/ui_service.cpp @@ -116,6 +116,7 @@ extern "C" static void HandleUpdateMusicPlayerList(Request *request); static void HandleAiJumpToResultView(Request *request); static void HandleAiJumpToListeningMessage(Request *request); + static void HandleAiJumpToRespondErrMessage(Request *request); static void HandleUpdateUserQuestionStr(Request *request); static void HandleUpdateAIAnswerStr(Request *request); static void HandleWatchFirstPaired(Request *request); @@ -155,6 +156,7 @@ extern "C" {UI_HAND_WATCH_FIRST_PAIRED, HandleWatchFirstPaired}, {UI_UPDATE_OBU_MESSAGE, HandleUpdateOBUMessage}, {UI_AI_JUMP_TO_LISTENING_VIEW, HandleAiJumpToListeningMessage}, + {UI_AI_JUMP_TO_RESPONDERR_VIEW, HandleAiJumpToRespondErrMessage}, {UI_UPDATE_RECORDPROCESS, HandleUpdateRecordProcess}, {UI_UPDATE_PLAYERPROCESS, HandleUpdatePlayerProcess}, @@ -613,6 +615,14 @@ extern "C" std::bind(&OHOS::AiVoiceModel::ChangeToAIVoiceListeningView, &OHOS::AiVoiceModel::GetInstance(), state)); } + // 处理更新查询AI模型是否连接成功的状态 + void HandleAiJumpToRespondErrMessage(Request *request) + { + WEARABLE_LOGI(WEARABLE_LOG_MODULE_UI_SERVICE, "HandleAiJumpToRespondErrMessage"); + GraphicService::GetInstance()->PostGraphicEvent( + std::bind(&OHOS::AiVoiceModel::ChangeToAIVoiceConnectTimeoutView, &OHOS::AiVoiceModel::GetInstance())); + } + //处理更新录音进度条 void HandleUpdateRecordProcess(Request *request) { -- 2.17.1