AI语音优化修改: 848/1
authorluozheng <1732036298@qq.com>
Sat, 31 Aug 2024 08:28:08 +0000 (16:28 +0800)
committerluozheng <1732036298@qq.com>
Sat, 31 Aug 2024 08:28:08 +0000 (16:28 +0800)
1.动画改为imageinfo创建和释放改善内存泄漏
2.添加对应回应类型的错误弹窗

15 files changed:
code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoiceConnectingView.h
code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoiceModel.h
code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoicePresenter.h
code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AivoiceConnectTimeoutView.h
code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AivoiceListeningView.h
code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AivoiceThinkingView.h
code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceConnectingView.cpp
code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceModel.cpp
code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoicePresenter.cpp
code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceView.cpp
code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AivoiceConnectTimeoutView.cpp
code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AivoiceListeningView.cpp
code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AivoiceThinkingView.cpp
code/sdk/application/wearable/fd230app/nativeui/uiservice/include/ui_service.h
code/sdk/application/wearable/fd230app/nativeui/uiservice/src/ui_service.cpp

index dfeb450..4f69a4e 100644 (file)
@@ -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};
     };
 }
 
index 87b1d09..ddee102 100644 (file)
@@ -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<int, std::pair<int, int>> selectAiModelToTextId;            // pair的参数类型<模型的textid,查询模型是否可用id>
         bool AiVoiceConnectStatus{false};                                    //与AI模型的连接状态
         uint8_t AIResponseType;
+        std::string errnote;                                                 //错误信息
+        int16_t curView{0};
     };
 
 }
index 25cf523..8768583 100644 (file)
@@ -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);
index 25d25e4..187c2a5 100644 (file)
@@ -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};
     };
index c897043..3c001b7 100644 (file)
@@ -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
index cad3da1..685791b 100644 (file)
@@ -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
index 2df64ab..7405572 100644 (file)
@@ -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!!");
index c457ba9..3e03713 100644 (file)
@@ -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,进入连接超时界面
             {
index 35c490a..40ccaab 100644 (file)
@@ -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;
index 2343c9d..1af83f7 100644 (file)
@@ -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
index 3687cca..03ff9a1 100644 (file)
@@ -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 <UiConfig.h>
@@ -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
index 237a342..ddfd2fb 100644 (file)
@@ -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!!");
index 4065451..e8054a6 100644 (file)
@@ -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!!");
index cfeef57..99efade 100644 (file)
@@ -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, //手表已配对:给第一次手表启动用配对成功调用
index 25ddee6..6a9d493 100644 (file)
@@ -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)
     {