${CMAKE_CURRENT_SOURCE_DIR}/nativeui/aivoice/src/AivoiceMobileDataFailedStartView.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nativeui/aivoice/src/AivoiceConnectTimeoutView.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nativeui/aivoice/src/AivoiceListeningView.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/aivoice/src/AivoiceThinkingView.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/aivoice/src/AivoiceReturnResultTextView.cpp
#声音与震动
${CMAKE_CURRENT_SOURCE_DIR}/nativeui/soundandvibration/src/SoundAndVibrationPresenter.cpp
* @Author: luozheng 1732036298@qq.com
* @Date: 2024-06-20 15:14:43
* @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-06-22 17:55:53
+ * @LastEditTime: 2024-06-25 17:50:45
* @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoiceModel.h
*/
#ifndef AI_VOICE_MODEL_H
#define AI_VOICE_MODEL_H
+#include "iostream"
+#include "string"
namespace OHOS
{
class AiVoiceModel
{
public:
static AiVoiceModel &GetInstance(void);
+ bool ChangeToReturnResultTextView(void);
+
bool GetBluetoothIsOpen(void);
bool GetMobileDataIsOpen(void);
bool GetAiVoiceConnectStatus(void);
+ std::string GetUserQuestionStr(void);
+ void SetUserQuestionStr(std::string str);
+
+ std::string GetAiAnswerStrStr(void);
+ void SetaiAnswerStrStr(std::string str);
+
+ std::string GetAIAudioPath(void);
+
private:
AiVoiceModel();
~AiVoiceModel();
AiVoiceModel(const AiVoiceModel &) = delete;
AiVoiceModel &operator=(const AiVoiceModel &) = delete;
+ std::string AIAIAudioPath = "/user/userdata/AiRecording/AIAudio.pcm"; // ai录音的文件名
+
+ std::string userQuestionStr; // 存储用户提出的问题
+ std::string aiAnswerStr; // 存储ai回答的问题
};
}
-#endif
\ No newline at end of file
+#endif
\ No newline at end of file
* @Author: luozheng 1732036298@qq.com
* @Date: 2024-06-20 14:44:22
* @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-06-22 09:51:24
+ * @LastEditTime: 2024-06-25 17:39:55
* @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoicePresenter.h
*/
#ifndef AI_VOICE_PRESENTER_H
void OnPause() override;
void OnStop() override;
+ bool JumpToReturnResultTextView(void);
private:
bool OnClick(UIView &view, const ClickEvent &event) override;
* @Author: luozheng 1732036298@qq.com
* @Date: 2024-06-08 09:36:01
* @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-06-22 17:48:56
+ * @LastEditTime: 2024-06-25 14:53:47
* @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/respiratorytraining/include/AiVoiceView.h
*/
#ifndef AI_VOICE_VIEW_H
#include "aivoice/include/AivoiceMobileDataFailedStartView.h"
#include "aivoice/include/AivoiceConnectTimeoutView.h"
#include "aivoice/include/AivoiceListeningView.h"
-
+#include "aivoice/include/AivoiceThinkingView.h"
+#include "aivoice/include/AivoiceReturnResultTextView.h"
namespace OHOS
{
static constexpr const char *START_CHAT_BUTTON_VIEW_ID = "StartChatButton"; // 开始对话
AivoiceMobileDataFailedStartView *p_AivoiceMobileDataFailedStartView{nullptr};
AivoiceConnectTimeoutView *p_AivoiceConnectTimeoutView{nullptr};
AivoiceListeningView *p_AivoiceListeningView{nullptr};
+ AivoiceThinkingView *p_AivoiceThinkingView{nullptr};
+ AivoiceReturnResultTextView *p_AivoiceReturnResultTextView{nullptr};
private:
UILabelExt *AiVoiceViewLabelInit(LabelConfig &labelconfig);
* @Author: luozheng 1732036298@qq.com
* @Date: 2024-06-22 16:46:26
* @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-06-22 17:41:04
+ * @LastEditTime: 2024-06-25 15:39:07
* @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AivoiceListeningView.h
*/
#include "components/ui_label_ext.h"
#include "components/ui_button.h"
#include "components/ui_image_view.h"
-
+#include "components/ui_image_animator.h"
namespace OHOS
{
static constexpr const char *FINISH_SPEAKING_BUTTON_VIEW_ID = "FinishSpeakingButton"; // 聆听中界面说话完毕按钮
+ static constexpr int16_t AIVOICE_LISTENING_IMAGE_ANIMATOR_VIEW_X = 113;
+ static constexpr int16_t AIVOICE_LISTENING_IMAGE_ANIMATOR_VIEW_Y = 182;
+ static constexpr int16_t AIVOICE_LISTENING_IMAGE_ANIMATOR_VIEW_W = 240;
+ static constexpr int16_t AIVOICE_LISTENING_IMAGE_ANIMATOR_VIEW_H = 60;
+ static constexpr int16_t AIVOICE_LISTENING_IMAGE_ANIMATOR_VIEW_NUM_FRAMES = 20; // 图片帧数
+ static constexpr int16_t AIVOICE_LISTENING_IMAGE_ANIMATOR_DELAY = 150; // 图片更新间隔
+ static constexpr char *AIVoiceListeningImagePaths = "/user/res/AIVoice/AIVoiceListening/Ai_Listening_";
class AivoiceListeningView
{
public:
const char *ViewId;
};
- struct ImageConfig
+ struct ImageAnimatorConfig
{
int16_t x;
int16_t y;
- int16_t w;
- int16_t h;
+ int16_t width;
+ int16_t height;
+ ImageAnimatorInfo* imageInfoArray;
+ const char* const* pathsArray;
+ uint8_t numFrames;
+ int delay;
};
AivoiceListeningView();
private:
void ClearAll(void);
+ const char **CreateImagePathsArray(const char *basePath, const int numImages, const char *fileExtension = "bin");
+ void FreeImagePathsArray(const char **imagePaths, const int numImages);
UILabelExt *AivoiceListeningLabelInit(LabelConfig &labelconfig);
UIButton *AivoiceListeningButtonInit(ButtonConfig &buttonconfig);
- UIImageView *AivoiceListeningImageInit(ImageConfig &imageconfig);
+ UIImageAnimatorView *AivoiceListeningImageAnimatorInit(ImageAnimatorConfig &imageanimatorconfig);
bool CreateAivoiceListeningLabel(void);
bool CreateAivoiceListeningButton(void);
- bool CreateAivoiceListeningImage(void);
+ bool CreateAivoiceListeningImageAnimator(void);
bool CreateAivoiceListeningScrollView(void);
UIScrollView *scrollView{nullptr};
UILabelExt *title{nullptr};
- UIImageView *attentionImage{nullptr};
UILabelExt *finishSpeak{nullptr};
UIButton *finishSpeakButton{nullptr};
+ UIImageAnimatorView *AiVoiceListeningImageAnimatorView{nullptr};
+ ImageAnimatorInfo AiVoiceListeningImageInfo[AIVOICE_LISTENING_IMAGE_ANIMATOR_VIEW_NUM_FRAMES];
+ const char **AiVoiceListeningPathsArray{nullptr};
};
}
#endif
--- /dev/null
+/*
+ * @Author: luozheng 1732036298@qq.com
+ * @Date: 2024-06-22 16:46:26
+ * @LastEditors: luozheng 1732036298@qq.com
+ * @LastEditTime: 2024-06-25 17:40:57
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AivoiceReturnResultTextView.h
+ */
+
+#ifndef AIVOICE_RETURN_RESULT_TEXT_VIEW_H
+#define AIVOICE_RETURN_RESULT_TEXT_VIEW_H
+
+#include "components/ui_scroll_view.h"
+#include "components/ui_label_ext.h"
+#include "components/ui_button.h"
+#include "components/ui_image_view.h"
+
+namespace OHOS
+{
+ static constexpr const char *AIVOICERETURNRESULTTEXT_RETURN_BUTTON_VIEW_ID = "AivoiceReturnResultTextReturnButton"; // 返回对话内容界面的返回按钮
+ static constexpr const char *AIVOICERETURNRESULTTEXT_CONTINUECHAT_BUTTON_VIEW_ID = "AivoiceReturnResultTextContinueChatButton"; // 返回对话内容界面的继续对话按钮
+
+ class AivoiceReturnResultTextView
+ {
+ public:
+ struct LabelConfig
+ {
+ int16_t left;
+ int16_t top;
+ int16_t width;
+ int16_t height;
+ int16_t fontSize;
+ int16_t lineHeight;
+ uint16_t textId;
+ uint8_t lineBreakMode;
+ };
+ struct ButtonConfig
+ {
+ int16_t x;
+ int16_t y;
+ int16_t w;
+ int16_t h;
+ const char *ViewId;
+ };
+ struct ImageConfig
+ {
+ int16_t x;
+ int16_t y;
+ int16_t w;
+ int16_t h;
+ const char *src;
+ };
+
+ AivoiceReturnResultTextView();
+ ~AivoiceReturnResultTextView();
+ static AivoiceReturnResultTextView *GetInstance(void);
+ UIScrollView *CreateAivoiceReturnResultTextView(void);
+
+ private:
+ void ClearAll(void);
+ UILabelExt *AivoiceReturnResultTextLabelInit(LabelConfig &labelconfig);
+ UIButton *AivoiceReturnResultTextButtonInit(ButtonConfig &buttonconfig);
+ UIImageView *AivoiceReturnResultTextImageInit(ImageConfig &imageconfig);
+ bool CreateAivoiceReturnResultTextLabel(void);
+ bool CreateAivoiceReturnResultTextUserQuestionLabel(void);
+ bool CreateAivoiceReturnResultTextAIAnswerLabel(void);
+ bool CreateAivoiceReturnResultTextLImage(void);
+ bool CreateAivoiceReturnResultTextButton(void);
+ bool CreateAivoiceReturnResultTextScrollView(void);
+ UIScrollView *scrollView{nullptr};
+ UILabelExt *title{nullptr};
+
+ UILabelExt *question{nullptr}; // 提出的问题
+ UIScrollView *questionScrollView{nullptr};
+ UIImageView *recGreenImage{nullptr};
+
+ UILabelExt *answer{nullptr}; // AI回答的答案
+ UIScrollView *answerScrollView{nullptr};
+ UIImageView *recBlackImage{nullptr};
+
+ UIButton *returnButton{nullptr};
+
+ UIButton *continueChatButton{nullptr};
+ UILabelExt *continueChat{nullptr};
+ };
+}
+#endif
--- /dev/null
+/*
+ * @Author: luozheng 1732036298@qq.com
+ * @Date: 2024-06-22 16:46:26
+ * @LastEditors: luozheng 1732036298@qq.com
+ * @LastEditTime: 2024-06-24 16:18:51
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AivoiceThinkingView.h
+ */
+
+#ifndef AIVOICE_THINKING_VIEW_H
+#define AIVOICE_THINKING_VIEW_H
+
+#include "components/ui_scroll_view.h"
+#include "components/ui_label_ext.h"
+#include "components/ui_button.h"
+#include "components/ui_image_view.h"
+#include "components/ui_image_animator.h"
+namespace OHOS
+{
+ static constexpr const char *CANCEL_THINKING_BUTTON_VIEW_ID = "CancelThinkingButton"; // 思考中界面说话完毕按钮
+
+ static constexpr int16_t AIVOICE_THINKING_IMAGE_ANIMATOR_VIEW_X = 153;
+ static constexpr int16_t AIVOICE_THINKING_IMAGE_ANIMATOR_VIEW_Y = 120;
+ static constexpr int16_t AIVOICE_THINKING_IMAGE_ANIMATOR_VIEW_W = 160;
+ static constexpr int16_t AIVOICE_THINKING_IMAGE_ANIMATOR_VIEW_H = 160;
+ static constexpr int16_t AIVOICE_THINKING_IMAGE_ANIMATOR_VIEW_NUM_FRAMES = 29; // 图片帧数
+ static constexpr int16_t AIVOICE_THINKING_IMAGE_ANIMATOR_DELAY = 200; // 图片更新间隔
+ static constexpr char *AIVoiceThinkingImagePaths = "/user/res/AIVoice/AIVoiceThinking/Ai_Thinking_";
+ class AivoiceThinkingView
+ {
+ 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;
+ };
+
+ struct ImageAnimatorConfig
+ {
+ int16_t x;
+ int16_t y;
+ int16_t width;
+ int16_t height;
+ ImageAnimatorInfo *imageInfoArray;
+ const char *const *pathsArray;
+ uint8_t numFrames;
+ int delay;
+ };
+
+ AivoiceThinkingView();
+ ~AivoiceThinkingView();
+ static AivoiceThinkingView *GetInstance(void);
+ UIScrollView *CreateAivoiceThinkingView(void);
+
+ private:
+ void ClearAll(void);
+ const char **CreateImagePathsArray(const char *basePath, const int numImages, const char *fileExtension = "bin");
+ void FreeImagePathsArray(const char **imagePaths, const int numImages);
+ UILabelExt *AivoiceThinkingLabelInit(LabelConfig &labelconfig);
+ UIButton *AivoiceThinkingButtonInit(ButtonConfig &buttonconfig);
+ UIImageAnimatorView *AivoiceThinkingImageAnimatorInit(ImageAnimatorConfig &imageanimatorconfig);
+ bool CreateAivoiceThinkingLabel(void);
+ bool CreateAivoiceThinkingButton(void);
+ bool CreateAivoiceThinkingImageAnimator(void);
+ bool CreateAivoiceThinkingScrollView(void);
+ UIScrollView *scrollView{nullptr};
+ UILabelExt *title{nullptr};
+ UILabelExt *cancelThink{nullptr};
+ UIButton *cancelThinkButton{nullptr};
+ UIImageAnimatorView *AiVoiceThinkingImageAnimatorView{nullptr};
+ ImageAnimatorInfo AiVoiceThinkingImageInfo[AIVOICE_THINKING_IMAGE_ANIMATOR_VIEW_NUM_FRAMES];
+ const char **AiVoiceThinkingPathsArray{nullptr};
+ };
+}
+#endif
* @Author: luozheng 1732036298@qq.com
* @Date: 2024-05-07 11:25:58
* @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-06-22 15:34:59
+ * @LastEditTime: 2024-06-24 10:39:08
* @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/AiVoice/src/AiVoiceBluetoothFailedStartView.cpp
*/
#include "aivoice/include/AiVoicePresenter.h"
AiVoiceBluetoothFailedStartView::~AiVoiceBluetoothFailedStartView()
{
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiVoiceBluetoothFailedStartView::~AiVoiceBluetoothFailedStartView");
+ ClearAll();
g_pAiVoiceBluetoothFailedStartView = nullptr;
}
* @Author: luozheng 1732036298@qq.com
* @Date: 2024-06-20 15:14:50
* @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-06-22 17:56:04
+ * @LastEditTime: 2024-06-25 17:50:59
* @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceModel.cpp
*/
#include "aivoice/include/AiVoiceModel.h"
+#include "aivoice/include/AiVoicePresenter.h"
#include "wearable_log.h"
namespace OHOS
return instance;
}
+ bool AiVoiceModel::ChangeToReturnResultTextView(void)
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoiceModel::ChangeToReturnResultTextView");
+ AiVoicePresenter *Aipresenter_ = AiVoicePresenter::GetInstance();
+ if (Aipresenter_ == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiVoiceModel::ChangeToReturnResultTextView fail!!");
+ return false;
+ }
+ Aipresenter_->JumpToReturnResultTextView();
+ return true;
+ }
+
+ // 获取蓝牙是否打开
bool AiVoiceModel::GetBluetoothIsOpen(void)
{
return true;
}
+ // 获取移动数据是否打开
bool AiVoiceModel::GetMobileDataIsOpen(void)
{
return true;
// 获取与AI模型的连接状态
bool AiVoiceModel::GetAiVoiceConnectStatus(void)
{
- return false;
+ return true;
+ }
+
+ std::string AiVoiceModel::GetUserQuestionStr(void)
+ {
+ userQuestionStr = "写一篇100字文章";
+ return userQuestionStr;
}
+ void AiVoiceModel::SetUserQuestionStr(std::string str)
+ {
+ userQuestionStr = str;
+ }
+
+ std::string AiVoiceModel::GetAiAnswerStrStr(void)
+ {
+ aiAnswerStr = "春风化雨,时光荏苒。百年之内,生命如白驹过隙,转瞬即逝。唯有心存善念,用爱化解芥蒂,用智慧建构未来,才是人生的真正意义。让我们携手共进,用每一分时光去关爱他人,用每一滴汗水去创造奇迹,用每一个眼神去传递温暖。让这个世界因我们的存在而变得更加美好。生命短暂,但只要我们怀着虔诚的心,坚韧前行,我们就一定能在有限的时光里留下无限的可能。";
+ return aiAnswerStr;
+ }
+
+ void AiVoiceModel::SetaiAnswerStrStr(std::string str)
+ {
+ aiAnswerStr = str;
+ }
+
+ std::string AiVoiceModel::GetAIAudioPath(void)
+ {
+ return AIAIAudioPath;
+ }
}
* @Author: luozheng 1732036298@qq.com
* @Date: 2024-06-20 15:11:17
* @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-06-22 18:42:34
+ * @LastEditTime: 2024-06-25 17:39:51
* @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoicePresenter.cpp
*/
#include "AppViewIDs.h"
{
WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoicePresenter::OnStart");
Presenter<AiVoiceView>::OnStart();
+ ScreenAlwaysOnCtr(OPEN_SCREEN_ALWAYS_ON);
}
// 页面已经展示后的调用逻辑
{
WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoicePresenter::OnStop");
Presenter<AiVoiceView>::OnStop();
+ ScreenAlwaysOnCtr(CANCEL_SCREEN_ALWAYS_ON);
+ }
+
+ bool AiVoicePresenter::JumpToReturnResultTextView(void)
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoicePresenter::JumpToReturnResultTextView");
+ if (view_ == nullptr)
+ {
+ return false;
+ }
+ if (view_->GetAiVoiceScrollView(AIVOICE_THINKING_VIEWID) != nullptr && view_->GetAiVoiceScrollView(AIVOICE_THINKING_VIEWID)->IsVisible())
+ {
+ view_->ChangeView(AIVOICE_THINKING_VIEWID, AIVOICE_RETURN_RESULT_TEXT_VIEWID); // 思考中界面->返回结果
+ }
+ else
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiVoicePresenter::JumpToReturnResultTextView fail");
+ return false;
+ }
+
+ return true;
}
bool AiVoicePresenter::OnClick(UIView &view, const ClickEvent &event)
}
std::unordered_map<std::string, std::pair<int16_t, int16_t>> viewIdMap = {
- {BLUETOOTHFAILEDSTART_ENSURE_BUTTON_VIEW_ID, {AIVOICE_BLUETOOTH_FAILEDSTART_VIEWID, AIVOICE_STARTCHAT_VIEWID}},
- {MOBILEDATAFAILEDSTART_ENSURE_BUTTON_VIEW_ID, {AIVOICE_MOBILEDATA_FAILEDSTART_VIEWID, AIVOICE_STARTCHAT_VIEWID}},
- {AIVOICECONNECTTIMEOUT_ENSURE_BUTTON_VIEW_ID, {AIVOICE_CONNECT_TIMEOUT_VIEWID, AIVOICE_LISTENING_VIEWID}},
+ {BLUETOOTHFAILEDSTART_ENSURE_BUTTON_VIEW_ID, {AIVOICE_BLUETOOTH_FAILEDSTART_VIEWID, AIVOICE_STARTCHAT_VIEWID}}, // 返回一级界面
+ {MOBILEDATAFAILEDSTART_ENSURE_BUTTON_VIEW_ID, {AIVOICE_MOBILEDATA_FAILEDSTART_VIEWID, AIVOICE_STARTCHAT_VIEWID}}, // 返回一级界面
+ {AIVOICECONNECTTIMEOUT_ENSURE_BUTTON_VIEW_ID, {AIVOICE_CONNECT_TIMEOUT_VIEWID, AIVOICE_LISTENING_VIEWID}}, // 返回继续聆听
+ {CANCEL_THINKING_BUTTON_VIEW_ID, {AIVOICE_THINKING_VIEWID, AIVOICE_STARTCHAT_VIEWID}}, // 返回一级界面
+ {AIVOICERETURNRESULTTEXT_RETURN_BUTTON_VIEW_ID, {AIVOICE_RETURN_RESULT_TEXT_VIEWID, AIVOICE_STARTCHAT_VIEWID}}, // 返回一级界面,并清除手表聊天记录
+ {AIVOICERETURNRESULTTEXT_CONTINUECHAT_BUTTON_VIEW_ID, {AIVOICE_RETURN_RESULT_TEXT_VIEWID, AIVOICE_LISTENING_VIEWID}}, // 返回继续聆听,并清除手表聊天记录
};
auto it = viewIdMap.find(viewId);
if (it != viewIdMap.end())
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Return false if viewId doesn't match any entry in the map");
return false;
}
+ return true;
}
bool AiVoicePresenter::OnDrag(UIView &view, const DragEvent &event)
{
view_->ChangeView(AIVOICE_LISTENING_VIEWID, AIVOICE_STARTCHAT_VIEWID); // 聆听中->开始对话界面
}
+ else if (scrollView == view_->GetAiVoiceScrollView(AIVOICE_THINKING_VIEWID))
+ {
+ view_->ChangeView(AIVOICE_THINKING_VIEWID, AIVOICE_STARTCHAT_VIEWID); // 思考中->开始对话界面
+ }
AiVoicePresenter::X_DRAG_FLAG = false;
}
return true;
* @Author: luozheng 1732036298@qq.com
* @Date: 2024-05-07 11:25:58
* @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-06-22 17:49:44
+ * @LastEditTime: 2024-06-25 17:43:03
* @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/AiVoice/src/AiVoiceView.cpp
*/
#include "aivoice/include/AiVoicePresenter.h"
delete p_AivoiceListeningView;
p_AivoiceListeningView = nullptr;
}
+
+ if (p_AivoiceThinkingView != nullptr)
+ {
+ delete p_AivoiceThinkingView;
+ p_AivoiceThinkingView = nullptr;
+ }
+
+ if (p_AivoiceReturnResultTextView != nullptr)
+ {
+ delete p_AivoiceReturnResultTextView;
+ p_AivoiceReturnResultTextView = nullptr;
+ }
}
}
p_AiVoiceBluetoothFailedStartView = new AiVoiceBluetoothFailedStartView();
if (p_AiVoiceBluetoothFailedStartView == nullptr)
{
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "new AiVoiceScrollView[AIVOICE_STARTCHAT_VIEWID][%d] fail", thisView);
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "new AiVoiceScrollView[%d] fail", thisView);
return false;
}
AiVoiceScrollView[thisView] = p_AiVoiceBluetoothFailedStartView->CreateAiVoiceBluetoothFailedStartView();
p_AivoiceMobileDataFailedStartView = new AivoiceMobileDataFailedStartView();
if (p_AivoiceMobileDataFailedStartView == nullptr)
{
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "new AiVoiceScrollView[AIVOICE_STARTCHAT_VIEWID][%d] fail", thisView);
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "new AiVoiceScrollView[%d] fail", thisView);
return false;
}
AiVoiceScrollView[thisView] = p_AivoiceMobileDataFailedStartView->CreateAivoiceMobileDataFailedStartView();
p_AivoiceConnectTimeoutView = new AivoiceConnectTimeoutView();
if (p_AivoiceConnectTimeoutView == nullptr)
{
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "new AiVoiceScrollView[AIVOICE_STARTCHAT_VIEWID][%d] fail", thisView);
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "new AiVoiceScrollView[%d] fail", thisView);
return false;
}
AiVoiceScrollView[thisView] = p_AivoiceConnectTimeoutView->CreateAivoiceConnectTimeoutView();
p_AivoiceListeningView = new AivoiceListeningView();
if (p_AivoiceListeningView == nullptr)
{
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "new AiVoiceScrollView[AIVOICE_STARTCHAT_VIEWID][%d] fail", thisView);
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "new AiVoiceScrollView[%d] fail", thisView);
return false;
}
AiVoiceScrollView[thisView] = p_AivoiceListeningView->CreateAivoiceListeningView();
bool AiVoiceView::ChangeAiVoicThinkingView(int16_t thisView)
{
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiVoiceView::ChangeAiVoicThinkingView");
-
+ if (AiVoiceScrollView[thisView] == nullptr)
+ {
+ p_AivoiceThinkingView = new AivoiceThinkingView();
+ if (p_AivoiceThinkingView == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "new AiVoiceScrollView[%d] fail", thisView);
+ return false;
+ }
+ AiVoiceScrollView[thisView] = p_AivoiceThinkingView->CreateAivoiceThinkingView();
+ container_->Add(AiVoiceScrollView[thisView]);
+ }
return true;
}
bool AiVoiceView::ChangeAiVoicReturnResultTextView(int16_t thisView)
{
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiVoiceView::ChangeAiVoicReturnResultTextView");
-
+ if (AiVoiceScrollView[thisView] == nullptr)
+ {
+ p_AivoiceReturnResultTextView = new AivoiceReturnResultTextView();
+ if (p_AivoiceReturnResultTextView == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "new AiVoiceScrollView[%d] fail", thisView);
+ return false;
+ }
+ AiVoiceScrollView[thisView] = p_AivoiceReturnResultTextView->CreateAivoiceReturnResultTextView();
+ container_->Add(AiVoiceScrollView[thisView]);
+ }
+ else
+ {
+ container_->Remove(AiVoiceScrollView[thisView]);
+ delete p_AivoiceReturnResultTextView;
+ p_AivoiceReturnResultTextView = nullptr;
+
+ p_AivoiceReturnResultTextView = new AivoiceReturnResultTextView();
+ if (p_AivoiceReturnResultTextView == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "new AiVoiceScrollView[%d] fail", thisView);
+ return false;
+ }
+ AiVoiceScrollView[thisView] = p_AivoiceReturnResultTextView->CreateAivoiceReturnResultTextView();
+ container_->Add(AiVoiceScrollView[thisView]);
+ }
return true;
}
* @Author: luozheng 1732036298@qq.com
* @Date: 2024-05-07 11:25:58
* @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-06-22 16:49:46
+ * @LastEditTime: 2024-06-24 10:38:42
* @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/AiVoice/src/AivoiceConnectTimeoutView.cpp
*/
#include "aivoice/include/AiVoicePresenter.h"
AivoiceConnectTimeoutView::~AivoiceConnectTimeoutView()
{
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AivoiceConnectTimeoutView::~AivoiceConnectTimeoutView");
+ ClearAll();
g_pAivoiceConnectTimeoutView = nullptr;
}
* @Author: luozheng 1732036298@qq.com
* @Date: 2024-05-07 11:25:58
* @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-06-22 17:47:58
+ * @LastEditTime: 2024-06-24 16:39:51
* @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/AiVoice/src/AivoiceListeningView.cpp
*/
#include "aivoice/include/AiVoicePresenter.h"
#include "wearable_log.h"
#include "language/font/ui_resource_string.h"
#include <UiConfig.h>
+// #include "common/image_cache_manager.h"
namespace OHOS
{
AivoiceListeningView::~AivoiceListeningView()
{
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AivoiceListeningView::~AivoiceListeningView");
+ ClearAll();
g_pAivoiceListeningView = nullptr;
}
title = nullptr;
}
- if (attentionImage != nullptr)
+ if (AiVoiceListeningImageAnimatorView != nullptr)
{
- delete attentionImage;
- attentionImage = nullptr;
+ AiVoiceListeningImageAnimatorView->Stop();
+ delete AiVoiceListeningImageAnimatorView;
+ AiVoiceListeningImageAnimatorView = nullptr;
+
+ FreeImagePathsArray(AiVoiceListeningPathsArray, AIVOICE_LISTENING_IMAGE_ANIMATOR_VIEW_NUM_FRAMES);
}
if (finishSpeak != nullptr)
}
}
+ const char **AivoiceListeningView::CreateImagePathsArray(const char *basePath, const int numImages, const char *fileExtension)
+ {
+ const char **imagePaths = new const char *[numImages];
+ if (imagePaths == nullptr)
+ {
+ return nullptr;
+ }
+
+ char buffer[256];
+ for (int i = 0; i < numImages; i++)
+ {
+ snprintf(buffer, sizeof(buffer), "%s%d.%s", basePath, i + 1, fileExtension);
+ imagePaths[i] = strdup(buffer);
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, " imagePaths[%d] = %s", i, imagePaths[i]);
+ }
+ return imagePaths;
+ }
+
+ void AivoiceListeningView::FreeImagePathsArray(const char **imagePaths, const int numImages)
+ {
+ for (int i = 0; i < numImages; i++)
+ {
+ // ImageCacheManager::GetInstance().UnloadSingleRes(imagePaths[i]);
+ delete imagePaths[i];
+ imagePaths[i] = nullptr;
+ }
+ }
+
UILabelExt *AivoiceListeningView::AivoiceListeningLabelInit(LabelConfig &labelconfig)
{
UILabelExt *label = new UILabelExt();
return button;
}
- UIImageView *AivoiceListeningView::AivoiceListeningImageInit(ImageConfig &imageconfig)
+ UIImageAnimatorView *AivoiceListeningView::AivoiceListeningImageAnimatorInit(ImageAnimatorConfig &imageanimatorconfig)
{
- UIImageView *Image = new UIImageView();
- if (Image == nullptr)
+ UIImageAnimatorView *animatorView = new UIImageAnimatorView();
+ if (animatorView == nullptr)
{
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiVoiceListeningImageAnimatorView::AiVoiceListeningImageAnimatorView new fail");
return nullptr;
}
- Image->SetPosition(imageconfig.x, imageconfig.y, imageconfig.w, imageconfig.h);
- return Image;
+
+ 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].pos.x = imageanimatorconfig.x;
+ imageanimatorconfig.imageInfoArray[i].pos.y = imageanimatorconfig.y;
+ imageanimatorconfig.imageInfoArray[i].width = imageanimatorconfig.width;
+ imageanimatorconfig.imageInfoArray[i].height = imageanimatorconfig.height;
+ }
+
+ animatorView->SetPosition(imageanimatorconfig.x, imageanimatorconfig.y, imageanimatorconfig.width, imageanimatorconfig.height);
+ animatorView->SetImageAnimatorSrc(imageanimatorconfig.imageInfoArray, imageanimatorconfig.numFrames, imageanimatorconfig.delay);
+ animatorView->SetRepeat(true);
+ animatorView->SetAutoEnable(false);
+ animatorView->SetResizeMode(UIImageAnimatorView::FILL);
+ animatorView->Start();
+
+ return animatorView;
}
bool AivoiceListeningView::CreateAivoiceListeningScrollView(void)
return true;
}
- bool AivoiceListeningView::CreateAivoiceListeningImage(void)
+ bool AivoiceListeningView::CreateAivoiceListeningImageAnimator(void)
{
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AivoiceListeningView::CreateAivoiceListeningImage");
- ImageConfig imageconfig = {
- .x = 193,
- .y = 120,
- .w = 80,
- .h = 80,
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AivoiceListeningView::CreateAivoiceListeningImageAnimator");
+ AiVoiceListeningPathsArray = CreateImagePathsArray(AIVoiceListeningImagePaths, AIVOICE_LISTENING_IMAGE_ANIMATOR_VIEW_NUM_FRAMES);
+ if (AiVoiceListeningPathsArray == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AivoiceListeningView::AiVoiceListeningPathsArray is nullptr!!");
+ return false;
+ }
+
+ ImageAnimatorConfig imageanimatorconfig = {
+ .x = AIVOICE_LISTENING_IMAGE_ANIMATOR_VIEW_X,
+ .y = AIVOICE_LISTENING_IMAGE_ANIMATOR_VIEW_Y,
+ .width = AIVOICE_LISTENING_IMAGE_ANIMATOR_VIEW_W,
+ .height = AIVOICE_LISTENING_IMAGE_ANIMATOR_VIEW_H,
+ .imageInfoArray = AiVoiceListeningImageInfo,
+ .pathsArray = AiVoiceListeningPathsArray,
+ .numFrames = AIVOICE_LISTENING_IMAGE_ANIMATOR_VIEW_NUM_FRAMES,
+ .delay = AIVOICE_LISTENING_IMAGE_ANIMATOR_DELAY,
};
- attentionImage = AivoiceListeningImageInit(imageconfig);
- if (attentionImage == nullptr)
+ AiVoiceListeningImageAnimatorView = AivoiceListeningImageAnimatorInit(imageanimatorconfig);
+ if (AiVoiceListeningImageAnimatorView == nullptr)
{
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "attentionImage new fail!");
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiVoiceListeningImageAnimatorView::AiVoiceListeningImageAnimatorView new fail");
return false;
}
- attentionImage->SetStyle(STYLE_BORDER_RADIUS, 100);
- attentionImage->SetSrc(PNG_ATTENTION_IMAGE);
return true;
}
if (scrollView == nullptr)
{
if (!CreateAivoiceListeningScrollView() || !CreateAivoiceListeningLabel() ||
- !CreateAivoiceListeningButton() || !CreateAivoiceListeningImage())
+ !CreateAivoiceListeningButton() || !CreateAivoiceListeningImageAnimator())
{
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AivoiceListeningView::CreateAivoiceListeningView fail!!");
return nullptr;
}
scrollView->Add(title);
- scrollView->Add(attentionImage);
+ scrollView->Add(AiVoiceListeningImageAnimatorView);
scrollView->Add(finishSpeakButton);
scrollView->Add(finishSpeak);
}
return scrollView;
}
-
}
\ No newline at end of file
* @Author: luozheng 1732036298@qq.com
* @Date: 2024-05-07 11:25:58
* @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-06-22 15:38:12
+ * @LastEditTime: 2024-06-24 10:39:26
* @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/AiVoice/src/AivoiceMobileDataFailedStartView.cpp
*/
#include "aivoice/include/AiVoicePresenter.h"
AivoiceMobileDataFailedStartView::~AivoiceMobileDataFailedStartView()
{
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AivoiceMobileDataFailedStartView::~AivoiceMobileDataFailedStartView");
+ ClearAll();
g_pAivoiceMobileDataFailedStartView = nullptr;
}
--- /dev/null
+/*
+ * @Author: luozheng 1732036298@qq.com
+ * @Date: 2024-05-07 11:25:58
+ * @LastEditors: luozheng 1732036298@qq.com
+ * @LastEditTime: 2024-06-25 17:45:39
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/AiVoice/src/AivoiceReturnResultTextView.cpp
+ */
+#include "aivoice/include/AiVoicePresenter.h"
+#include "aivoice/include/AivoiceReturnResultTextView.h"
+#include "wearable_log.h"
+#include "language/font/ui_resource_string.h"
+#include "aivoice/include/AiVoiceModel.h"
+#include <UiConfig.h>
+#include <iostream>
+#include "string"
+
+namespace OHOS
+{
+
+ /* -------------------------------------------------------------------------- */
+ static constexpr const int16_t QUESTION_SCROLLVIEW_X = 112;
+ static constexpr const int16_t QUESTION_SCROLLVIEW_Y = 120;
+ static constexpr const int16_t QUESTION_SCROLLVIEW_W = 280;
+ static constexpr const int16_t QUESTION_SCROLLVIEW_H = 80;
+ static constexpr const int64_t QUESTION_BACKGROUND_COLOR = 0xff4fc34c;
+
+ static constexpr const int16_t QUESTION_LABEL_W = 200;
+ static constexpr const int16_t QUESTION_LABEL_H = 30;
+ static constexpr const int16_t QUESTION_LABEL_FONTSIZE = 26;
+ static constexpr const int16_t QUESTION_LABEL_LINEHEIGHT = 30;
+ /* -------------------------------------------------------------------------- */
+
+ static constexpr const int16_t ANSWER_SCROLLVIEW_X = 53;
+ static constexpr const int16_t ANSWER_SCROLLVIEW_Y = QUESTION_SCROLLVIEW_Y + QUESTION_SCROLLVIEW_H + 30;
+ static constexpr const int16_t ANSWER_SCROLLVIEW_W = 360;
+ static constexpr const int16_t ANSWER_SCROLLVIEW_H = 250;
+ static constexpr const int64_t ANSWER_BACKGROUND_COLOR = 0xff191919;
+
+ static constexpr const int16_t ANSWER_LABEL_W = 270;
+ static constexpr const int16_t ANSWER_LABEL_H = 194;
+ static constexpr const int16_t ANSWER_LABEL_FONTSIZE = 26;
+ static constexpr const int16_t ANSWER_LABEL_LINEHEIGHT = 30;
+
+ /* -------------------------------------------------------------------------- */
+ static constexpr const int16_t RECGREEN_IMAGE_X = 342;
+ static constexpr const int16_t RECGREEN_IMAGE_Y = QUESTION_SCROLLVIEW_Y;
+ static constexpr const int16_t RECGREEN_IMAGE_W = 70;
+ static constexpr const int16_t RECGREEN_IMAGE_H = 30;
+ static constexpr const char *RECGREEN_IMAGE_PATH = "/user/res/AIVoice/AI_RecGreen.bin";
+
+ static constexpr const int16_t RECBLACK_IMAGE_X = 32;
+ static constexpr const int16_t RECBLACK_IMAGE_Y = ANSWER_SCROLLVIEW_Y;
+ static constexpr const int16_t RECBLACK_IMAGE_W = 70;
+ static constexpr const int16_t RECBLACK_IMAGE_H = 30;
+ static constexpr const char *RECBLACK_IMAGE_PATH = "/user/res/AIVoice/AI_RecBlack.bin";
+ /* -------------------------------------------------------------------------- */
+ static constexpr const int16_t RETURN_BUTTON_X = 73;
+ static constexpr const int16_t RETURN_BUTTON_Y = ANSWER_SCROLLVIEW_Y + ANSWER_SCROLLVIEW_H + 20;
+ static constexpr const int16_t RETURN_BUTTON_W = 100;
+ static constexpr const int16_t RETURN_BUTTON_H = 100;
+ static constexpr const char *RETURN_BUTTON_PATH = "/user/res/AIVoice/AI_Union.bin";
+
+ static constexpr const int16_t CONTINUECHAT_BUTTON_X = 183;
+ static constexpr const int16_t CONTINUECHAT_BUTTON_Y = ANSWER_SCROLLVIEW_Y + ANSWER_SCROLLVIEW_H + 20;
+ static constexpr const int16_t CONTINUECHAT_BUTTON_W = 210;
+ static constexpr const int16_t CONTINUECHAT_BUTTON_H = 100;
+ /* -------------------------------------------------------------------------- */
+ static constexpr const int16_t CONTINUECHAT_X = CONTINUECHAT_BUTTON_X + 45;
+ static constexpr const int16_t CONTINUECHAT_Y = CONTINUECHAT_BUTTON_Y + 33;
+ static constexpr const int16_t CONTINUECHAT_W = 120;
+ static constexpr const int16_t CONTINUECHAT_H = 35;
+
+ static constexpr const int16_t ONE_HALF_NUM = 2;
+
+ static AivoiceReturnResultTextView *g_pAivoiceReturnResultTextView{nullptr};
+
+ AivoiceReturnResultTextView::AivoiceReturnResultTextView()
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AivoiceReturnResultTextView::AivoiceReturnResultTextView");
+ g_pAivoiceReturnResultTextView = this;
+ }
+
+ AivoiceReturnResultTextView::~AivoiceReturnResultTextView()
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AivoiceReturnResultTextView::~AivoiceReturnResultTextView");
+ ClearAll();
+ g_pAivoiceReturnResultTextView = nullptr;
+ }
+
+ AivoiceReturnResultTextView *AivoiceReturnResultTextView::GetInstance()
+ {
+ return g_pAivoiceReturnResultTextView;
+ }
+
+ void AivoiceReturnResultTextView::ClearAll(void)
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AivoiceReturnResultTextView::ClearAll");
+ if (scrollView != nullptr)
+ {
+ scrollView->RemoveAll();
+
+ if (title != nullptr)
+ {
+ delete title;
+ title = nullptr;
+ }
+
+ if (questionScrollView != nullptr)
+ {
+ questionScrollView->Remove(question);
+ if (question != nullptr)
+ {
+ delete question;
+ question = nullptr;
+ }
+ delete questionScrollView;
+ questionScrollView = nullptr;
+ }
+
+ if (recGreenImage != nullptr)
+ {
+ delete recGreenImage;
+ recGreenImage = nullptr;
+ }
+
+ if (answerScrollView != nullptr)
+ {
+ answerScrollView->Remove(answer);
+ if (answer != nullptr)
+ {
+ delete answer;
+ answer = nullptr;
+ }
+ delete answerScrollView;
+ answerScrollView = nullptr;
+ }
+
+ if (recBlackImage != nullptr)
+ {
+ delete recBlackImage;
+ recBlackImage = nullptr;
+ }
+
+ if (returnButton != nullptr)
+ {
+ delete returnButton;
+ returnButton = nullptr;
+ }
+
+ if (continueChatButton != nullptr)
+ {
+ delete continueChatButton;
+ continueChatButton = nullptr;
+ }
+
+ if (continueChat != nullptr)
+ {
+ delete continueChat;
+ continueChat = nullptr;
+ }
+
+ delete scrollView;
+ scrollView = nullptr;
+ }
+ }
+
+ UILabelExt *AivoiceReturnResultTextView::AivoiceReturnResultTextLabelInit(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.lineHeight);
+ 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 *AivoiceReturnResultTextView::AivoiceReturnResultTextButtonInit(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, 0xff191919);
+ button->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
+ button->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff383838, UIButton::PRESSED);
+
+ return button;
+ }
+
+ UIImageView *AivoiceReturnResultTextView::AivoiceReturnResultTextImageInit(ImageConfig &imageconfig)
+ {
+ UIImageView *Image = new UIImageView();
+ if (Image == nullptr)
+ {
+ return nullptr;
+ }
+ Image->SetPosition(imageconfig.x, imageconfig.y, imageconfig.w, imageconfig.h);
+ Image->SetSrc(imageconfig.src);
+ return Image;
+ }
+
+ bool AivoiceReturnResultTextView::CreateAivoiceReturnResultTextScrollView(void)
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AivoiceReturnResultTextView::CreateAivoiceReturnResultTextScrollView");
+ scrollView = new UIScrollView();
+ if (scrollView == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AivoiceReturnResultTextView::scrollView new fail!");
+ return false;
+ }
+ scrollView->SetPosition(0, 0, 466, 466);
+ scrollView->SetTouchable(true);
+ scrollView->SetDraggable(true);
+ scrollView->SetReboundSize(40);
+ scrollView->SetScrollBlankSize(70);
+ scrollView->SetThrowDrag(true);
+ scrollView->SetMaxScrollDistance(1000);
+ scrollView->SetDirection(UIScrollView::VERTICAL);
+
+ return true;
+ }
+
+ bool AivoiceReturnResultTextView::CreateAivoiceReturnResultTextUserQuestionLabel(void)
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AivoiceReturnResultTextView::CreateAivoiceReturnResultTextUserQuestionLabel");
+ if (questionScrollView == nullptr)
+ {
+ questionScrollView = new UIScrollView();
+ if (questionScrollView == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AivoiceReturnResultTextView::questionScrollView is nullptr!");
+ return false;
+ }
+ questionScrollView->SetPosition(QUESTION_SCROLLVIEW_X, QUESTION_SCROLLVIEW_Y, QUESTION_SCROLLVIEW_W, QUESTION_SCROLLVIEW_H);
+ questionScrollView->SetStyle(STYLE_BACKGROUND_COLOR, QUESTION_BACKGROUND_COLOR);
+ questionScrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
+ questionScrollView->SetStyle(STYLE_BORDER_RADIUS, 20);
+ }
+ /* -------------------------------------------------------------------------- */
+ int16_t QUESTION_LABEL_X = (questionScrollView->GetWidth() - QUESTION_LABEL_W) / ONE_HALF_NUM;
+ int16_t QUESTION_LABEL_Y = (questionScrollView->GetHeight() - QUESTION_LABEL_H) / ONE_HALF_NUM;
+ if (question == nullptr)
+ {
+ question = new UILabelExt();
+ if (question == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AivoiceReturnResultTextView::question is nullptr!");
+ return false;
+ }
+
+ question->SetPosition(QUESTION_LABEL_X, QUESTION_LABEL_Y, QUESTION_LABEL_W, QUESTION_LABEL_H);
+ question->SetStyle(STYLE_TEXT_FONT, QUESTION_LABEL_FONTSIZE);
+ question->SetStyle(STYLE_LINE_HEIGHT, QUESTION_LABEL_LINEHEIGHT);
+ std::string questionStr = AiVoiceModel::GetInstance().GetUserQuestionStr();
+ question->SetText(questionStr.c_str());
+ question->SetTextColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0xcc));
+ question->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE);
+ question->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+ question->SetFont(DEFAULT_VECTOR_FONT_FILENAME, QUESTION_LABEL_FONTSIZE);
+
+ questionScrollView->Add(question);
+ }
+ return true;
+ }
+
+ bool AivoiceReturnResultTextView::CreateAivoiceReturnResultTextAIAnswerLabel(void)
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AivoiceReturnResultTextView::CreateAivoiceReturnResultTextAIAnswerLabel");
+ if (answerScrollView == nullptr)
+ {
+ answerScrollView = new UIScrollView();
+ if (answerScrollView == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AivoiceReturnResultTextView::answerScrollView is nullptr!");
+ return false;
+ }
+ answerScrollView->SetPosition(ANSWER_SCROLLVIEW_X, ANSWER_SCROLLVIEW_Y, ANSWER_SCROLLVIEW_W, ANSWER_SCROLLVIEW_H);
+ answerScrollView->SetStyle(STYLE_BACKGROUND_COLOR, ANSWER_BACKGROUND_COLOR);
+ answerScrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
+ answerScrollView->SetStyle(STYLE_BORDER_RADIUS, 20);
+ /* -------------------------------------------------------------------------- */
+ int16_t ANSWER_LABEL_X = (answerScrollView->GetWidth() - ANSWER_LABEL_W) / ONE_HALF_NUM;
+ int16_t ANSWER_LABEL_Y = (answerScrollView->GetHeight() - ANSWER_LABEL_H) / ONE_HALF_NUM;
+ if (answer == nullptr)
+ {
+ answer = new UILabelExt();
+ if (answer == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AivoiceReturnResultTextView::answer is nullptr!");
+ return false;
+ }
+
+ answer->SetPosition(ANSWER_LABEL_X, ANSWER_LABEL_Y, ANSWER_LABEL_W, ANSWER_LABEL_H);
+ answer->SetStyle(STYLE_TEXT_FONT, ANSWER_LABEL_FONTSIZE);
+ answer->SetStyle(STYLE_LINE_HEIGHT, ANSWER_LABEL_LINEHEIGHT);
+ std::string answerStr = AiVoiceModel::GetInstance().GetAiAnswerStrStr();
+ answer->SetText(answerStr.c_str());
+ answer->SetTextColor(Color::GetColorFromRGBA(0x99, 0x99, 0x99, 0xff));
+ answer->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS);
+ answer->SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_CENTER);
+ answer->SetFont(DEFAULT_VECTOR_FONT_FILENAME, QUESTION_LABEL_FONTSIZE);
+
+ answerScrollView->Add(answer);
+ }
+ }
+ return true;
+ }
+
+ bool AivoiceReturnResultTextView::CreateAivoiceReturnResultTextLabel(void)
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AivoiceReturnResultTextView::CreateAivoiceReturnResultTextLabel");
+ LabelConfig labelconfig = {
+ .left = 83,
+ .top = 52,
+ .width = 300,
+ .height = 35,
+ .fontSize = 30,
+ .lineHeight = 35,
+ .textId = STR_AI_INTELLIGENT_ASSISTANT,
+ .lineBreakMode = UILabel::LINE_BREAK_MARQUEE,
+ };
+ title = AivoiceReturnResultTextLabelInit(labelconfig);
+ if (title == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AivoiceReturnResultTextView::title is nullptr!");
+ return false;
+ }
+ /* -------------------------------------------------------------------------- */
+ if (!CreateAivoiceReturnResultTextUserQuestionLabel() || !CreateAivoiceReturnResultTextAIAnswerLabel())
+ {
+ return false;
+ }
+ /* -------------------------------------------------------------------------- */
+ labelconfig = {
+ .left = CONTINUECHAT_X,
+ .top = CONTINUECHAT_Y,
+ .width = CONTINUECHAT_W,
+ .height = CONTINUECHAT_H,
+ .fontSize = 30,
+ .lineHeight = 35,
+ .textId = STR_CONTINUE_CHAT,
+ .lineBreakMode = UILabel::LINE_BREAK_MARQUEE,
+ };
+ continueChat = AivoiceReturnResultTextLabelInit(labelconfig);
+ if (continueChat == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AivoiceReturnResultTextView::continueChat is nullptr!");
+ return false;
+ }
+
+ return true;
+ }
+
+ bool AivoiceReturnResultTextView::CreateAivoiceReturnResultTextLImage(void)
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AivoiceReturnResultTextView::CreateAivoiceReturnResultTextLImage");
+ ImageConfig imageconfig = {
+ .x = RECGREEN_IMAGE_X,
+ .y = RECGREEN_IMAGE_Y,
+ .w = RECGREEN_IMAGE_W,
+ .h = RECGREEN_IMAGE_H,
+ .src = RECGREEN_IMAGE_PATH,
+ };
+ recGreenImage = AivoiceReturnResultTextImageInit(imageconfig);
+ if (recGreenImage == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AivoiceReturnResultTextView::recGreenImage is nullptr!");
+ return false;
+ }
+ /* -------------------------------------------------------------------------- */
+ imageconfig = {
+ .x = RECBLACK_IMAGE_X,
+ .y = RECBLACK_IMAGE_Y,
+ .w = RECBLACK_IMAGE_W,
+ .h = RECBLACK_IMAGE_H,
+ .src = RECBLACK_IMAGE_PATH,
+ };
+ recBlackImage = AivoiceReturnResultTextImageInit(imageconfig);
+ if (recBlackImage == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AivoiceReturnResultTextView::recBlackImage is nullptr!");
+ return false;
+ }
+
+ return true;
+ }
+
+ bool AivoiceReturnResultTextView::CreateAivoiceReturnResultTextButton(void)
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AivoiceReturnResultTextView::CreateAivoiceReturnResultTextButton");
+ ButtonConfig buttonconfig = {
+ .x = RETURN_BUTTON_X,
+ .y = RETURN_BUTTON_Y,
+ .w = RETURN_BUTTON_W,
+ .h = RETURN_BUTTON_H,
+ .ViewId = AIVOICERETURNRESULTTEXT_RETURN_BUTTON_VIEW_ID,
+ };
+ returnButton = AivoiceReturnResultTextButtonInit(buttonconfig);
+ if (returnButton == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "returnButton new fail!");
+ return false;
+ }
+ returnButton->SetImagePosition(39, 39);
+ returnButton->SetImageSrc(RETURN_BUTTON_PATH, RETURN_BUTTON_PATH);
+ UIView::OnClickListener *clickListener = static_cast<UIView::OnClickListener *>(AiVoicePresenter::GetInstance());
+ if (clickListener == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AivoiceReturnResultTextView::draglistener can not be nullptr!");
+ return false;
+ }
+ returnButton->SetOnClickListener(clickListener);
+ /* -------------------------------------------------------------------------- */
+ buttonconfig = {
+ .x = CONTINUECHAT_BUTTON_X,
+ .y = CONTINUECHAT_BUTTON_Y,
+ .w = CONTINUECHAT_BUTTON_W,
+ .h = CONTINUECHAT_BUTTON_H,
+ .ViewId = AIVOICERETURNRESULTTEXT_CONTINUECHAT_BUTTON_VIEW_ID,
+ };
+ continueChatButton = AivoiceReturnResultTextButtonInit(buttonconfig);
+ if (continueChatButton == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "continueChatButton new fail!");
+ return false;
+ }
+ continueChatButton->SetOnClickListener(clickListener);
+
+ return true;
+ }
+
+ UIScrollView *AivoiceReturnResultTextView::CreateAivoiceReturnResultTextView(void)
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AivoiceReturnResultTextView::CreateAivoiceReturnResultTextView");
+ if (scrollView == nullptr)
+ {
+ if (!CreateAivoiceReturnResultTextScrollView() || !CreateAivoiceReturnResultTextLabel() ||
+ !CreateAivoiceReturnResultTextLImage() || !CreateAivoiceReturnResultTextButton())
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AivoiceReturnResultTextView::CreateAivoiceReturnResultTextView fail!!");
+ return nullptr;
+ }
+ /* ----------------------------------- Add ---------------------------------- */
+ scrollView->Add(title);
+ scrollView->Add(questionScrollView);
+ scrollView->Add(recGreenImage);
+ scrollView->Add(answerScrollView);
+ scrollView->Add(recBlackImage);
+ scrollView->Add(returnButton);
+ scrollView->Add(continueChatButton);
+ scrollView->Add(continueChat);
+ }
+ return scrollView;
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * @Author: luozheng 1732036298@qq.com
+ * @Date: 2024-05-07 11:25:58
+ * @LastEditors: luozheng 1732036298@qq.com
+ * @LastEditTime: 2024-06-24 16:39:53
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/AiVoice/src/AivoiceThinkingView.cpp
+ */
+#include "aivoice/include/AiVoicePresenter.h"
+#include "aivoice/include/AivoiceThinkingView.h"
+#include "wearable_log.h"
+#include "language/font/ui_resource_string.h"
+#include <UiConfig.h>
+// #include "common/image_cache_manager.h"
+namespace OHOS
+{
+
+ static AivoiceThinkingView *g_pAivoiceThinkingView{nullptr};
+
+ AivoiceThinkingView::AivoiceThinkingView()
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AivoiceThinkingView::AivoiceThinkingView");
+ g_pAivoiceThinkingView = this;
+ }
+
+ AivoiceThinkingView::~AivoiceThinkingView()
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AivoiceThinkingView::~AivoiceThinkingView");
+ ClearAll();
+ g_pAivoiceThinkingView = nullptr;
+ }
+
+ AivoiceThinkingView *AivoiceThinkingView::GetInstance()
+ {
+ return g_pAivoiceThinkingView;
+ }
+
+ void AivoiceThinkingView::ClearAll(void)
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AivoiceThinkingView::ClearAll");
+ if (scrollView != nullptr)
+ {
+ scrollView->RemoveAll();
+
+ if (title != nullptr)
+ {
+ delete title;
+ title = nullptr;
+ }
+
+ if (AiVoiceThinkingImageAnimatorView != nullptr)
+ {
+ AiVoiceThinkingImageAnimatorView->Stop();
+ delete AiVoiceThinkingImageAnimatorView;
+ AiVoiceThinkingImageAnimatorView = nullptr;
+
+ FreeImagePathsArray(AiVoiceThinkingPathsArray, AIVOICE_THINKING_IMAGE_ANIMATOR_VIEW_NUM_FRAMES);
+ }
+
+ if (cancelThink != nullptr)
+ {
+ delete cancelThink;
+ cancelThink = nullptr;
+ }
+
+ if (cancelThinkButton != nullptr)
+ {
+ delete cancelThinkButton;
+ cancelThinkButton = nullptr;
+ }
+
+ delete scrollView;
+ scrollView = nullptr;
+ }
+ }
+
+ const char **AivoiceThinkingView::CreateImagePathsArray(const char *basePath, const int numImages, const char *fileExtension)
+ {
+ const char **imagePaths = new const char *[numImages];
+ if (imagePaths == nullptr)
+ {
+ return nullptr;
+ }
+
+ char buffer[256];
+ for (int i = 0; i < numImages; i++)
+ {
+ snprintf(buffer, sizeof(buffer), "%s%d.%s", basePath, i + 1, fileExtension);
+ imagePaths[i] = strdup(buffer);
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, " imagePaths[%d] = %s", i, imagePaths[i]);
+ }
+ return imagePaths;
+ }
+
+ void AivoiceThinkingView::FreeImagePathsArray(const char **imagePaths, const int numImages)
+ {
+ for (int i = 0; i < numImages; i++)
+ {
+ // ImageCacheManager::GetInstance().UnloadSingleRes(imagePaths[i]);
+ delete imagePaths[i];
+ imagePaths[i] = nullptr;
+ }
+ }
+
+ UILabelExt *AivoiceThinkingView::AivoiceThinkingLabelInit(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 *AivoiceThinkingView::AivoiceThinkingButtonInit(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, 0xff191919);
+ button->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
+ button->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff383838, UIButton::PRESSED);
+
+ return button;
+ }
+
+ UIImageAnimatorView *AivoiceThinkingView::AivoiceThinkingImageAnimatorInit(ImageAnimatorConfig &imageanimatorconfig)
+ {
+ UIImageAnimatorView *animatorView = new UIImageAnimatorView();
+ if (animatorView == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiVoiceThinkingImageAnimatorView::AiVoiceThinkingImageAnimatorView new fail");
+ return nullptr;
+ }
+
+ 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].pos.x = imageanimatorconfig.x;
+ imageanimatorconfig.imageInfoArray[i].pos.y = imageanimatorconfig.y;
+ imageanimatorconfig.imageInfoArray[i].width = imageanimatorconfig.width;
+ imageanimatorconfig.imageInfoArray[i].height = imageanimatorconfig.height;
+ }
+
+ animatorView->SetPosition(imageanimatorconfig.x, imageanimatorconfig.y, imageanimatorconfig.width, imageanimatorconfig.height);
+ animatorView->SetImageAnimatorSrc(imageanimatorconfig.imageInfoArray, imageanimatorconfig.numFrames, imageanimatorconfig.delay);
+ animatorView->SetRepeat(true);
+ animatorView->SetAutoEnable(false);
+ animatorView->SetResizeMode(UIImageAnimatorView::FILL);
+ animatorView->Start();
+
+ return animatorView;
+ }
+
+ bool AivoiceThinkingView::CreateAivoiceThinkingScrollView(void)
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AivoiceThinkingView::CreateAivoiceThinkingScrollView");
+ scrollView = new UIScrollView();
+ if (scrollView == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AivoiceThinkingView::scrollView new fail!");
+ return false;
+ }
+ scrollView->SetPosition(0, 0, 466, 466);
+ UIView::OnDragListener *dragListener = static_cast<UIView::OnDragListener *>(AiVoicePresenter::GetInstance());
+ if (dragListener == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AivoiceThinkingView::dragListener new fail!");
+ return false;
+ }
+ scrollView->SetOnDragListener(dragListener);
+ scrollView->SetTouchable(true);
+ scrollView->SetDraggable(true);
+
+ return true;
+ }
+
+ bool AivoiceThinkingView::CreateAivoiceThinkingLabel(void)
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AivoiceThinkingView::CreateAivoiceThinkingLabel");
+ LabelConfig labelconfig = {
+ .left = 83,
+ .top = 52,
+ .width = 300,
+ .height = 35,
+ .fontSize = 30,
+ .lineHeigh = 35,
+ .textId = STR_THINKING,
+ .lineBreakMode = UILabel::LINE_BREAK_MARQUEE,
+ };
+ title = AivoiceThinkingLabelInit(labelconfig);
+ if (title == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AivoiceThinkingView::title is nullptr!");
+ return false;
+ }
+ /* -------------------------------------------------------------------------- */
+ labelconfig = {
+ .left = 133,
+ .top = 368,
+ .width = 200,
+ .height = 35,
+ .fontSize = 30,
+ .lineHeigh = 35,
+ .textId = STR_CANCEL,
+ .lineBreakMode = UILabel::LINE_BREAK_MARQUEE,
+ };
+ cancelThink = AivoiceThinkingLabelInit(labelconfig);
+ if (cancelThink == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AivoiceThinkingView::cancelThink is nullptr!");
+ return false;
+ }
+ cancelThink->SetTextColor(Color::GetColorFromRGBA(0xfd, 0x52, 0x03, 0xff));
+
+ return true;
+ }
+
+ bool AivoiceThinkingView::CreateAivoiceThinkingButton(void)
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AivoiceThinkingView::CreateAivoiceThinkingButton");
+ ButtonConfig buttonconfig = {
+ .x = 93,
+ .y = 340,
+ .w = 280,
+ .h = 90,
+ .ViewId = CANCEL_THINKING_BUTTON_VIEW_ID,
+ };
+ cancelThinkButton = AivoiceThinkingButtonInit(buttonconfig);
+ if (cancelThinkButton == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "cancelThinkButton new fail!");
+ return false;
+ }
+ UIView::OnClickListener *clickListener = static_cast<UIView::OnClickListener *>(AiVoicePresenter::GetInstance());
+ if (clickListener == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AivoiceThinkingView::draglistener can not be nullptr!");
+ return false;
+ }
+ cancelThinkButton->SetOnClickListener(clickListener);
+
+ return true;
+ }
+
+ bool AivoiceThinkingView::CreateAivoiceThinkingImageAnimator(void)
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AivoiceThinkingView::CreateAivoiceThinkingImageAnimator");
+ AiVoiceThinkingPathsArray = CreateImagePathsArray(AIVoiceThinkingImagePaths, AIVOICE_THINKING_IMAGE_ANIMATOR_VIEW_NUM_FRAMES);
+ if (AiVoiceThinkingPathsArray == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AivoiceThinkingView::AiVoiceThinkingPathsArray is nullptr!!");
+ return false;
+ }
+
+ ImageAnimatorConfig imageanimatorconfig = {
+ .x = AIVOICE_THINKING_IMAGE_ANIMATOR_VIEW_X,
+ .y = AIVOICE_THINKING_IMAGE_ANIMATOR_VIEW_Y,
+ .width = AIVOICE_THINKING_IMAGE_ANIMATOR_VIEW_W,
+ .height = AIVOICE_THINKING_IMAGE_ANIMATOR_VIEW_H,
+ .imageInfoArray = AiVoiceThinkingImageInfo,
+ .pathsArray = AiVoiceThinkingPathsArray,
+ .numFrames = AIVOICE_THINKING_IMAGE_ANIMATOR_VIEW_NUM_FRAMES,
+ .delay = AIVOICE_THINKING_IMAGE_ANIMATOR_DELAY,
+ };
+ AiVoiceThinkingImageAnimatorView = AivoiceThinkingImageAnimatorInit(imageanimatorconfig);
+ if (AiVoiceThinkingImageAnimatorView == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiVoiceThinkingImageAnimatorView::AiVoiceThinkingImageAnimatorView new fail");
+ return false;
+ }
+
+ return true;
+ }
+
+ UIScrollView *AivoiceThinkingView::CreateAivoiceThinkingView(void)
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AivoiceThinkingView::CreateAivoiceThinkingView");
+ if (scrollView == nullptr)
+ {
+ if (!CreateAivoiceThinkingScrollView() || !CreateAivoiceThinkingLabel() ||
+ !CreateAivoiceThinkingButton() || !CreateAivoiceThinkingImageAnimator())
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AivoiceThinkingView::CreateAivoiceThinkingView fail!!");
+ return nullptr;
+ }
+ scrollView->Add(title);
+ scrollView->Add(AiVoiceThinkingImageAnimatorView);
+ scrollView->Add(cancelThinkButton);
+ scrollView->Add(cancelThink);
+ }
+ return scrollView;
+ }
+}
\ No newline at end of file
* @Author: luozheng 1732036298@qq.com
* @Date: 2024-06-12 11:44:04
* @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-06-19 19:06:47
+ * @LastEditTime: 2024-06-25 17:58:27
* @FilePath: /FD230/code/sdk/application/wearable/nativeapp/nativeui/uiservice/include/ui_service.h
*/
/*
UI_UPDATE_SILENT_MODE, //更新静音模式
UI_UPDATE_WEATHER_DATA, //天气数据更新
+ UI_AI_RESPONSE_USERDATA, //跳转到返回结果视图
MAX_NUM_HANDLER,
} UiServiceMsgId;
#include <iostream>
#include "displaybrightness/include/DisplayBrightnessModel.h"
#include "soundandvibration/include/SoundAndVibrationModel.h"
+#include "aivoice/include/AiVoiceModel.h"
#include "weather/include/WeatherModel.h"
#include "uiservice/include/ui_service.h"
#include "wearable_log.h"
static void HandleUpdateCallVolume(Request *request);
static void HandleUpdateVibrationMode(Request *request);
static void HandleUpdateSilentMode(Request *request);
+static void HandleAiResponseUserData(Request *request);
// 消息处理程序项数组(每个消息类型对应一个处理函数,函数名以 Handle 开头)
MsgHandlerEntry msgHandlers[] = {
{UI_UPDATE_CALL_VOLUME, HandleUpdateCallVolume},
{UI_UPDATE_VIBRATION_MODE, HandleUpdateVibrationMode},
{UI_UPDATE_SILENT_MODE, HandleUpdateSilentMode},
+ {UI_AI_RESPONSE_USERDATA, HandleAiResponseUserData},
};
/* -------------------------------------------------------------------------- */
static void ScreenTurnOn(Request *request)
GraphicService::GetInstance()->PostGraphicEvent(
std::bind(&OHOS::SoundAndVibrationModel::UpdateSilentModeSwitch, OHOS::SoundAndVibrationModel::GetInstance()));
}
+
+//处理Ai回应的用户数据
+void HandleAiResponseUserData(Request *request)
+{
+ WEARABLE_LOGI(WEARABLE_LOG_MODULE_UI_SERVICE, "HandleAiResponseUserData");
+ GraphicService::GetInstance()->PostGraphicEvent(
+ std::bind(&OHOS::AiVoiceModel::ChangeToReturnResultTextView, &OHOS::AiVoiceModel::GetInstance()));
+}
/* -------------------------------------------------------------------------- */
#ifdef __cplusplus
}
+++ /dev/null
-version https://git-lfs.github.com/spec/v1
-oid sha256:fd2acea8d7166abd98536687c9a59a37e66dcadf5dc0152bb6185e04ce9fa13d
-size 1560
+++ /dev/null
-version https://git-lfs.github.com/spec/v1
-oid sha256:96e2af6c30df028b9c9c0e032325f1e45d8b872aaffe8712215d3d2262ea9c0e
-size 1560
+++ /dev/null
-version https://git-lfs.github.com/spec/v1
-oid sha256:72c650a3bf3f61a231a466b92b72c75322b158da9bb966dd72d37619fb79830f
-size 408
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:60f5f967ae239a0bc79113e86c21174c3cfee1ca1ec68f0eb810340a2817e4e7
+size 1144
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:9025ed7a813dc9d52a53e4603b103f2642dd4a698cb92d09fa15574c0d471cb4
+size 1144
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:dab8b1368f70a87eb4b1c74e35b76ec0135f39c476d9b9f9065a1d21cf721a33
+size 1144
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:55cc3ac3d4fc8d879b4b728d74fdd3c0a01000a7270c225f9150834db8b3d8b9
+size 1144
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:d893daaceb55ab00827506ac94e85120baa96f9cc0234dee50309217b9317e81
+size 1144
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:63c2392c12f976943dfaeab521520c803e7d4ca497e6885d074b39d5fcb4f15e
+size 1144
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:efd97a61466e116c8ef43a7dcef507ff331a08d5c4445aa8f1bf9ec8f87ef7ae
+size 1144
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:eb9f31a34145a42bbdec1e349b5bcefa9d7f4411f09f5d19e7d6ac13cc8525a6
+size 1144
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:d5e5934627dc73f80f3dbee84edeaab7963ec9e4d9bada606b24a03840542ad8
+size 1144
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:cb8be16fae0dff99ec5ca21761d1dc6992fa19af92469664dab93cae6e4aee34
+size 1144
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:02b75c43a76f184ca9e0ecefcf50e24520d301185d2880e26c681a51ba31eead
+size 1144
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:54a003553b6edf8ece7202e3fa551a03a37bcd0dd88e84b2152a3ad3b6e549c6
+size 1144
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:926e23232177b8b4a99a3bebaf850f7b1ac9ff2d444a60879e100ff598f303ca
+size 1144
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:f41f7f219f95d69bede446830a544aaecff2b28d9c4eaf39a0ca5fa5831ef0bf
+size 1144
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:8af5a5f7ba0c1d6a5aaea08c0f082a574bcb96cc54312a6f96e4cfc762691091
+size 1144
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:34b6f38611695eb90ec6d2135a7000b27c94961b1c0042ca1cfc2891c7410f63
+size 1144
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:544413cf24c02a5f6ac1aee8b153154b3e7988d56b54c831189d7edd1cc41a2a
+size 1144
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:c9c9c4f2ec1e1b074ebf2eb291233f97c6be30df7569e8478a71a14cd5b59c32
+size 1144
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:54d7039fc3f0e92eb97de9098a425e6f043dc48ba1e6f462bd6b979eb23b2038
+size 1144
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:6e5bbe8140adda885479b6778c37e50ebe8c7be8366010e00953d440e2e2e8d1
+size 1144
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:14d6cf8fbeecf0a35111b830053fafd80a9fe66071728401edb479b551f2ab1d
+size 3016
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:c16d58ec48b67eb99240c7d2a1fd0b09770eaae011c05671d1b1b0916f6a192c
+size 3016
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:0323f667dda9690b8e48cc8da86359141314ba57f90e22cc427806efd48a9c99
+size 3016
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:1ba59661c2d6a939ac785a826c4e9747efb06bea84a31bc4916c432ae9d83562
+size 3016
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:6cb490686998507f00a6f980f9cdf33a80212eca547346c9924ef5d00ad3de4c
+size 3016
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:754deb6d264a84f13aa655dd22b7f0030131a8738a3bed79affb0cd8911719ab
+size 3016
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:7b21c6bd275f47643a56426869837da73a62b34e845c32f9c92d2291a5e100a1
+size 3016
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:90767c9549c7ee8edfe1f7b17945a95bf077a93494d25c2edf660c8cc78a3ed5
+size 3016
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:b11221e0574d0fe43ef8593a35e77c637a32c8735b3e8c50e7cea135ca194bfa
+size 3016
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:32b655a351836a864879173503bdda4bd32452c0a458c0d836eac14e4526fecb
+size 3016
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:48d07db5bc8deb6f414cf2c9b76f9a8bd26f6d234a11a9e2761e7b89bec5977a
+size 3016
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:34e6509cd43d584a3f2ef9f497172cceb0eda651ae2cfa1cc79bfe1296728454
+size 3016
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:7a4b04745f294852ad6cf4703337d0954e907a50d40791c92d625b4c7e61e63c
+size 3016
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:fe38cdc0d9a082493d9e19356445e70366b7bc4a45ff0a9225a69c79b8df6b38
+size 3016
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:f841f40e39a2904faa47546a52f341795af77045c2684aaffa9d27c3056cdfeb
+size 3016
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:ac652e98736a69e8f92a540ee662d4ee83f5947f7074fc0df73cf0035acd680f
+size 3016
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:9b7e555f1f737288f8237f2e7c5ab97a6db31981b8318d80d0571652ca37aa4d
+size 3016
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:f3a739d70dd7013e1147cb878cb831e449f6f19dff84fd51e4c8c9fba4e229ed
+size 3016
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:6cf1933121ac6f854840240e46e260f773c8139bc61007b835e15ceedbb734cc
+size 3016
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:1f474fa8a88687f9876d6d01d2c052c3c2c436b737461789247063ef209ae41b
+size 3016
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:54131df27e631a54c5063a9d86f8bdfce3d902bf955c1a5fac1a283f18a4330c
+size 3016
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:01be5f743eabacdf5b175154bd7d6d9c42f9bf2cb7da8cccf9f98c318371fc77
+size 3016
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:4001d19087061e82e3ca0f45ba29ec14d576ee531a30a9e2f8aacb94dba67bec
+size 3016
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:fc656d102a75ffd3d4698cf516ec5b2a1e827d8c9270b1a2275c86acbb0ed917
+size 3016
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:712650a3e3ce3f5cfe325282c6813e3aef81a90fd69605883746de02f63e4f04
+size 3016
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:ebcbb6581eaff40f7bcd72c14c204631a8c3f3b9fe9cbbe31d0ba53bc8f8cf96
+size 3016
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:dbf660b9e8a0ea265285d16a9f69d42b8adf3a4477c047e44439955d843575a1
+size 3016
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:b145b87dd060cfdf7c470a1fa2b23f4486aa2ac294d9d6da3f60d3f4344d4d53
+size 3016
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:a73320662cc00b7ea0065e43e80e05c6104a428baf0455791a6ad4316cbc5da8
+size 3016