${CMAKE_CURRENT_SOURCE_DIR}/nativeui/aivoice/src/AivoiceChatContentListItemView.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nativeui/aivoice/src/AivoiceChatContentListAdapter.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nativeui/aivoice/src/AivoiceReturnResultTextView.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/aivoice/src/AiVoiceConnectingView.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nativeui/aivoice/src/apikeys/ApiKeysDeleteView.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nativeui/aivoice/src/apikeys/ApiKeysPresenter.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nativeui/aivoice/src/apikeys/NotSetApiKeysView.cpp
--- /dev/null
+/*
+ * @Author: luozheng 1732036298@qq.com
+ * @Date: 2024-08-03 11:09:56
+ * @LastEditors: luozheng 1732036298@qq.com
+ * @LastEditTime: 2024-08-03 11:32:24
+ * @FilePath: /xts_origin/FD230/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoiceConnectingView.h
+ */
+
+#ifndef AIVOICE_CONNECTING_H
+#define AIVOICE_CONNECTING_H
+#include "components/ui_button.h"
+#include "components/ui_scroll_view.h"
+#include "components/ui_label_ext.h"
+namespace OHOS
+{
+ static constexpr const char *AIVOICECONNECTINGVIEW_CANCEL_BUTTON_VIEW_ID = "AivoiceConnectingcancelButton"; // 正在连接中界面取消按钮
+
+ class AiVoiceConnectingView
+ {
+ 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;
+ };
+
+ AiVoiceConnectingView();
+ ~AiVoiceConnectingView();
+ static AiVoiceConnectingView *GetInstance(void);
+ UIScrollView *CreateAiVoiceConnectingView(void);
+
+ private:
+ UILabelExt *AiVoiceConnectingViewLabelInit(LabelConfig &labelconfig);
+ UIButton *AiVoiceConnectingViewButtonInit(ButtonConfig &buttonconfig);
+ bool CreateAiVoiceConnectingViewLabel(void);
+ bool CreateAiVoiceConnectingViewButton(void);
+ bool CreateAiVoiceConnectingScrollView(void);
+ void ClearAll(void);
+ UIScrollView *scrollView{nullptr};
+ UILabelExt *title{nullptr};
+ UILabelExt *cancelLabel{nullptr};
+ UIButton *cancelButton{nullptr};
+ };
+}
+
+#endif
\ No newline at end of file
* @Author: luozheng 1732036298@qq.com
* @Date: 2024-06-20 15:14:43
* @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-08-02 09:46:58
+ * @LastEditTime: 2024-08-03 14:26:12
* @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoiceModel.h
*/
#ifndef AI_VOICE_MODEL_H
public:
static AiVoiceModel &GetInstance(void); // 获取单例实例
bool ChangeToReturnResultTextView(void);
+ bool ChangeToAIVoiceListeningView(bool value);
// 初始化和状态管理
bool CreateIfNotExists();
void StatusResume(void);
* @Author: luozheng 1732036298@qq.com
* @Date: 2024-06-20 14:44:22
* @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-07-29 10:32:57
+ * @LastEditTime: 2024-08-03 14:27:50
* @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoicePresenter.h
*/
#ifndef AI_VOICE_PRESENTER_H
void OnStop() override;
bool JumpToReturnResultTextView(void);
+ bool ChangeToAIVoiceListeningView(bool val);
bool ChangeViewAndLogicOperator(int16_t hideView, int16_t showView);
private:
* @Author: luozheng 1732036298@qq.com
* @Date: 2024-06-08 09:36:01
* @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-07-30 20:24:56
+ * @LastEditTime: 2024-08-03 11:37:00
* @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/respiratorytraining/include/AiVoiceView.h
*/
#ifndef AI_VOICE_VIEW_H
#include "aivoice/include/apikeys/SetApiKeysView.h"
#include "aivoice/include/apikeys/NotSetApiKeysView.h"
#include "aivoice/include/apikeys/ApiKeysDeleteView.h"
+#include "aivoice/include/AiVoiceConnectingView.h"
#include "ui_resource_string.h"
#include "iostream"
#include "string"
AIVOICE_SETAPIKEYS, // API Keys set界面
AIVOICE_NOTSETAPIKEYS, // API Keys notset界面
AIVOICE_APIKEYS_DELETE, // API Keys 删除界面
+ AIVOICE_AIMODE_CONNECTING, // AI Mode正在连接视图
MAX_AIVOICE_VIEWID,
} AIVOICEVIEWID;
bool ChangeAiVoicSetApiKeysView(int16_t thisView);
bool ChangeAiVoicNotSetApiKeysView(int16_t thisView);
bool ChangeAiVoicApiKeysDeleteView(int16_t thisView);
+ bool ChangeAiVoicConnectingView(int16_t thisView);
void SetAiVoiceViewAllComponentsVisibilityStatus();
void ChangeAiModelAndUpdateComponentsStatus(void);
SetApiKeysView *p_SetApiKeysView{nullptr};
NotSetApiKeysView *p_NotSetApiKeysView{nullptr};
ApiKeysDeleteView *p_ApiKeysDeleteView{nullptr};
+ AiVoiceConnectingView *p_AiVoiceConnectingView{nullptr};
private:
UILabelExt *AiVoiceViewLabelInit(LabelConfig &labelconfig);
--- /dev/null
+/*
+ * @Author: luozheng 1732036298@qq.com
+ * @Date: 2024-08-03 11:10:08
+ * @LastEditors: luozheng 1732036298@qq.com
+ * @LastEditTime: 2024-08-03 15:19:28
+ * @FilePath: /xts_origin/FD230/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceConnectingView.cpp
+ */
+#include "aivoice/include/AiVoiceConnectingView.h"
+#include "aivoice/include/AiVoicePresenter.h"
+#include "wearable_log.h"
+#include "ui_resource_string.h"
+
+namespace OHOS
+{
+ static AiVoiceConnectingView *g_pAiVoiceConnecting{nullptr};
+ AiVoiceConnectingView::AiVoiceConnectingView()
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiVoiceConnectingView::AiVoiceConnectingView");
+ g_pAiVoiceConnecting = this;
+ }
+
+ AiVoiceConnectingView::~AiVoiceConnectingView()
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiVoiceConnectingView::~AiVoiceConnectingView");
+ ClearAll();
+ g_pAiVoiceConnecting = nullptr;
+ }
+
+ void AiVoiceConnectingView::ClearAll(void)
+ {
+ if (scrollView != nullptr)
+ {
+ scrollView->RemoveAll();
+ if (title)
+ {
+ delete title;
+ title = nullptr;
+ }
+ if (cancelLabel)
+ {
+ delete cancelLabel;
+ cancelLabel = nullptr;
+ }
+ if (cancelButton != nullptr)
+ {
+ delete cancelButton;
+ cancelButton = nullptr;
+ }
+
+ delete scrollView;
+ scrollView = nullptr;
+ }
+ }
+
+ AiVoiceConnectingView *AiVoiceConnectingView::GetInstance(void)
+ {
+ return g_pAiVoiceConnecting;
+ }
+
+ UILabelExt *AiVoiceConnectingView::AiVoiceConnectingViewLabelInit(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->SetRollSpeed(70);
+ label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, labelconfig.fontSize);
+ return label;
+ }
+
+ UIButton *AiVoiceConnectingView::AiVoiceConnectingViewButtonInit(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;
+ }
+
+ bool AiVoiceConnectingView::CreateAiVoiceConnectingViewLabel(void)
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoiceConnectingView::CreateAiVoiceConnectingViewLabel");
+ LabelConfig labelConfig = {
+ .left = 83,
+ .top = 50,
+ .width = 300,
+ .height = 35,
+ .fontSize = 30,
+ .lineHeigh = 35,
+ .textId = STR_CONNECTING,
+ .lineBreakMode = UILabel::LINE_BREAK_OSCILLATION,
+ };
+ title = AiVoiceConnectingViewLabelInit(labelConfig);
+ if (title == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "title new fail!");
+ return false;
+ }
+ /* -------------------------------------------------------------------------- */
+ labelConfig = {
+ .left = 133,
+ .top = 368,
+ .width = 200,
+ .height = 35,
+ .fontSize = 30,
+ .lineHeigh = 35,
+ .textId = STR_CANCEL,
+ .lineBreakMode = UILabel::LINE_BREAK_OSCILLATION,
+ };
+ cancelLabel = AiVoiceConnectingViewLabelInit(labelConfig);
+ if (cancelLabel == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiVoiceBluetoothFailedStartView::cancelLabel is nullptr!");
+ return false;
+ }
+ cancelLabel->SetTextColor(Color::GetColorFromRGBA(0xfd, 0x52, 0x13, 0xff));
+
+ return true;
+ }
+
+ bool AiVoiceConnectingView::CreateAiVoiceConnectingViewButton(void)
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoiceConnectingView::CreateAiVoiceConnectingViewButton");
+ ButtonConfig buttonconfig = {
+ .x = 93,
+ .y = 340,
+ .w = 280,
+ .h = 90,
+ .viewId = AIVOICECONNECTINGVIEW_CANCEL_BUTTON_VIEW_ID,
+ };
+ cancelButton = AiVoiceConnectingViewButtonInit(buttonconfig);
+ if (cancelButton == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "cancelButton new fail!");
+ return false;
+ }
+ UIView::OnTouchListener *touchListener = static_cast<UIView::OnTouchListener *>(AiVoicePresenter::GetInstance());
+ if (touchListener == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AivoiceConnectTimeoutView::touchListener can not be nullptr!");
+ return false;
+ }
+ cancelButton->SetOnTouchListener(touchListener);
+
+ return true;
+ }
+
+ bool AiVoiceConnectingView::CreateAiVoiceConnectingScrollView(void)
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoiceConnectingView::CreateAiVoiceConnectingScrollView");
+ scrollView = new UIScrollView();
+ if (scrollView == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AivoiceConnectTimeoutView::scrollView new fail!");
+ return false;
+ }
+ 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->SetPosition(0, 0, 466, 466);
+ scrollView->SetTouchable(true);
+ scrollView->SetDraggable(true);
+
+ return true;
+ }
+
+ UIScrollView *AiVoiceConnectingView::CreateAiVoiceConnectingView(void)
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoiceConnectingView::CreateAiVoiceConnectingView");
+ if (!CreateAiVoiceConnectingScrollView() || !CreateAiVoiceConnectingViewLabel() || !CreateAiVoiceConnectingViewButton())
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoiceConnectingView::CreateAiVoiceConnectingView fail!!");
+ return nullptr;
+ }
+ scrollView->Add(title);
+ scrollView->Add(cancelButton);
+ scrollView->Add(cancelLabel);
+
+ return scrollView;
+ }
+
+}
\ No newline at end of file
* @Author: luozheng 1732036298@qq.com
* @Date: 2024-06-20 15:14:50
* @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-08-02 09:48:30
+ * @LastEditTime: 2024-08-03 15:06:35
* @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceModel.cpp
*/
#include "aivoice/include/AiVoiceModel.h"
static osTimerId_t g_timer = NULL;
static constexpr uint16_t THIRTY_TIME = 31;
static int Time = THIRTY_TIME;
+ static int AiModelConnectTimeout = 5;
AiVoiceModel::AiVoiceModel() {}
return true;
}
+ bool AiVoiceModel::ChangeToAIVoiceListeningView(bool value)
+ {
+ 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_->ChangeToAIVoiceListeningView(value);
+ return true;
+ }
+
/*如果文件不存在就创建*/
bool AiVoiceModel::CreateIfNotExists()
{
void AiVoiceModel::StatusResume(void)
{
Time = THIRTY_TIME;
+ AiModelConnectTimeout = 5;
+ AiVoiceConnectStatus = false;
for (int i = 0; i < ChatContentListCount; i++)
{
/*定时器到期时的处理*/
static void AIVoice_TimerCallbackProc(int data)
{
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AIVoice_TimerCallbackProc,Time = %d", Time);
- Time -= 1;
- if (Time == 30)
+ if (!AiVoiceModel::GetInstance().GetAiVoiceConnectStatus())
{
- AiVoiceModel::GetInstance().CheckFileAndSendAIIsReady();
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AIVoice_TimerCallbackProc,AiModelConnectTimeout = %d", AiModelConnectTimeout);
+ AiModelConnectTimeout--;
+ if (AiModelConnectTimeout < 0)
+ {
+ AiVoiceModel::GetInstance().AIVoice_StopTimer();
+ AiVoiceView *view_ = AiVoiceView::GetInstance();
+ AiVoicePresenter *p_AiVoicePresenter = AiVoicePresenter::GetInstance();
+ if (view_ != nullptr && p_AiVoicePresenter != nullptr)
+ {
+ if ((view_->GetAiVoiceScrollView(AIVOICE_AIMODE_CONNECTING) != nullptr) &&
+ (view_->GetAiVoiceScrollView(AIVOICE_AIMODE_CONNECTING)->IsVisible()))
+ {
+ p_AiVoicePresenter->ChangeViewAndLogicOperator(AIVOICE_AIMODE_CONNECTING, AIVOICE_AIMODEL_CONNECT_FAILED_VIEWID);
+ }
+ }
+ }
}
- if (Time < 0) // 如果思考时间超时30s,进入连接超时界面
+ else
{
- AiVoiceModel::GetInstance().AIVoice_StopTimer();
-
- AiVoiceView *view_ = AiVoiceView::GetInstance();
- AiVoicePresenter *p_AiVoicePresenter = AiVoicePresenter::GetInstance();
- if (view_ != nullptr && p_AiVoicePresenter != nullptr)
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AIVoice_TimerCallbackProc,Time = %d", Time);
+ Time -= 1;
+ if (Time == 30)
{
- if ((view_->GetAiVoiceScrollView(AIVOICE_THINKING_VIEWID) != nullptr) &&
- (view_->GetAiVoiceScrollView(AIVOICE_THINKING_VIEWID)->IsVisible()))
+ AiVoiceModel::GetInstance().CheckFileAndSendAIIsReady();
+ }
+ if (Time < 0) // 如果思考时间超时30s,进入连接超时界面
+ {
+ AiVoiceModel::GetInstance().AIVoice_StopTimer();
+
+ AiVoiceView *view_ = AiVoiceView::GetInstance();
+ AiVoicePresenter *p_AiVoicePresenter = AiVoicePresenter::GetInstance();
+ if (view_ != nullptr && p_AiVoicePresenter != nullptr)
{
- p_AiVoicePresenter->ChangeViewAndLogicOperator(AIVOICE_THINKING_VIEWID, AIVOICE_CONNECT_TIMEOUT_VIEWID);
+ if ((view_->GetAiVoiceScrollView(AIVOICE_THINKING_VIEWID) != nullptr) &&
+ (view_->GetAiVoiceScrollView(AIVOICE_THINKING_VIEWID)->IsVisible()))
+ {
+ p_AiVoicePresenter->ChangeViewAndLogicOperator(AIVOICE_THINKING_VIEWID, AIVOICE_CONNECT_TIMEOUT_VIEWID);
+ }
}
}
}
}
g_timer = NULL;
Time = THIRTY_TIME;
+ AiModelConnectTimeout = 5;
}
}
* @Author: luozheng 1732036298@qq.com
* @Date: 2024-06-20 15:11:17
* @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-08-02 14:35:52
+ * @LastEditTime: 2024-08-03 16:26:41
* @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoicePresenter.cpp
*/
#include "AppViewIDs.h"
return true;
}
+ /*跳转到AI聆听界面界面*/
+ bool AiVoicePresenter::ChangeToAIVoiceListeningView(bool val)
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoicePresenter::ChangeToAIVoiceListeningView");
+ if (view_->GetAiVoiceScrollView(AIVOICE_AIMODE_CONNECTING) != nullptr && view_->GetAiVoiceScrollView(AIVOICE_AIMODE_CONNECTING)->IsVisible())
+ {
+ model->AIVoice_StopTimer(); // 停止定时器
+ model->SetAiVoiceConnectStatus(val);
+ if (val) /*如果查询的AI模型可用跳转到聆听中界面*/
+ {
+ ChangeViewAndLogicOperator(AIVOICE_AIMODE_CONNECTING, AIVOICE_LISTENING_VIEWID);
+ }
+ else
+ {
+ ChangeViewAndLogicOperator(AIVOICE_AIMODE_CONNECTING, AIVOICE_AIMODEL_CONNECT_FAILED_VIEWID);
+ }
+ }
+ else
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiVoicePresenter::ChangeToAIVoiceListeningView fail");
+ return false;
+ }
+ return true;
+ }
+
bool AiVoicePresenter::ChangeViewAndLogicOperator(int16_t hideView, int16_t showView)
{
WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoicePresenter::ChangeViewOperator");
switch (hideView)
{
case AIVOICE_STARTCHAT_VIEWID:
+ model->QuerySelectedAiModelIsConnect(); /*查询用户选择的AI模型是否已经连接*/
+ if (showView == AIVOICE_LISTENING_VIEWID)
+ {
+ model->StartListenAndRecordingUserQuestion();
+ }
+ else if (showView == AIVOICE_AIMODE_CONNECTING)
+ {
+ model->AIVoice_StartTimer(); /*开启一个查询AI模型是否连接成功定时器*/
+ }
+ break;
+
+ case AIVOICE_AIMODE_CONNECTING:
if (showView == AIVOICE_LISTENING_VIEWID)
{
model->StartListenAndRecordingUserQuestion();
}
else if (viewId == AIVOICE_START_CHAT_BUTTON_VIEW_ID) // 如果点击的是开始对话按钮
{
- /* ------------------------ 如果点击的是开始对话按钮,先查询AI模型是否可用 ------------------------ */
- model->QuerySelectedAiModelIsConnect();
- /* -------------------------------------------------------------------------- */
/*
* 进入对话流程:
* 1.当手表4G网络正常+与app连接正常 -> 通过4G调用大模型
*/
bool netWork4GState = model->GetMobileDataIsOpen();
bool appBluetoothConnectState = model->GetAPPBluetoothIsConnect();
- bool aivoiceConnectState = model->GetAiVoiceConnectStatus();
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "netWork4GState = %d,appBluetoothConnectState = %d,aivoiceConnectState =%d",netWork4GState,appBluetoothConnectState,aivoiceConnectState);
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "netWork4GState = %d,appBluetoothConnectState = %d", netWork4GState, appBluetoothConnectState);
if (netWork4GState) // 1.手表4G网络正常
{
- if (aivoiceConnectState) /*如果模型是连接成功的*/
- {
- // 通过4G调用大模型
- }
- else
- {
- ChangeViewAndLogicOperator(AIVOICE_STARTCHAT_VIEWID, AIVOICE_AIMODEL_CONNECT_FAILED_VIEWID);
- }
+ // 通过4G调用大模型
}
else if (appBluetoothConnectState) // 3.只有与APP蓝牙连接正常
{
- if (aivoiceConnectState) /*如果模型是连接成功的*/
- {
- // 通过蓝牙连接APP调用大模型
- ChangeViewAndLogicOperator(AIVOICE_STARTCHAT_VIEWID, AIVOICE_LISTENING_VIEWID);
- }
- else
- {
- ChangeViewAndLogicOperator(AIVOICE_STARTCHAT_VIEWID, AIVOICE_AIMODEL_CONNECT_FAILED_VIEWID);
- }
+ // 通过蓝牙连接APP调用大模型
+ ChangeViewAndLogicOperator(AIVOICE_STARTCHAT_VIEWID, AIVOICE_AIMODE_CONNECTING); // LOADING
}
else // 4.两者连接都异常
{
{AIMODEL_CONNECT_FAILED_ENSURE_BUTTON_VIEW_ID, {AIVOICE_AIMODEL_CONNECT_FAILED_VIEWID, AIVOICE_STARTCHAT_VIEWID}}, // 返回一级界面
{AIVOICECONNECTTIMEOUT_ENSURE_BUTTON_VIEW_ID, {AIVOICE_CONNECT_TIMEOUT_VIEWID, AIVOICE_STARTCHAT_VIEWID}}, // 返回一级界面
{CANCEL_THINKING_BUTTON_VIEW_ID, {AIVOICE_THINKING_VIEWID, AIVOICE_STARTCHAT_VIEWID}}, // 返回一级界面
+ {AIVOICECONNECTINGVIEW_CANCEL_BUTTON_VIEW_ID, {AIVOICE_AIMODE_CONNECTING, 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}}, // 返回继续聆听,并清除手表聊天记录
};
/*连接超时界面右滑退到AI对话界面*/
ChangeViewAndLogicOperator(AIVOICE_CONNECT_TIMEOUT_VIEWID, AIVOICE_STARTCHAT_VIEWID);
}
+ else if (scrollView == view_->GetAiVoiceScrollView(AIVOICE_AIMODE_CONNECTING))
+ {
+ /*连接超时界面右滑退到AI对话界面*/
+ ChangeViewAndLogicOperator(AIVOICE_AIMODE_CONNECTING, 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-07-31 18:33:11
+ * @LastEditTime: 2024-08-03 16:24:36
* @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/AiVoice/src/AiVoiceView.cpp
*/
#include "aivoice/include/AiVoicePresenter.h"
delete p_ApiKeysDeleteView;
p_ApiKeysDeleteView = nullptr;
}
+
+ if (p_AiVoiceConnectingView != nullptr)
+ {
+ delete p_AiVoiceConnectingView;
+ p_AiVoiceConnectingView = nullptr;
+ }
}
}
return true;
}
+ /*切换到AI正在连接中视图*/
+ bool AiVoiceView::ChangeAiVoicConnectingView(int16_t thisView)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiVoiceView::ChangeAiVoicConnectingView");
+ if (AiVoiceScrollView[thisView] == nullptr)
+ {
+ p_AiVoiceConnectingView = new AiVoiceConnectingView();
+ if (p_AiVoiceConnectingView == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "new AiVoiceScrollView[%d] fail", thisView);
+ return false;
+ }
+ AiVoiceScrollView[thisView] = p_AiVoiceConnectingView->CreateAiVoiceConnectingView();
+ container_->Add(AiVoiceScrollView[thisView]);
+ }
+ return true;
+ }
+
struct AiVoiceViewMapper
{
const int16_t viewId;
{AIVOICE_SETAPIKEYS, &AiVoiceView::ChangeAiVoicSetApiKeysView},
{AIVOICE_NOTSETAPIKEYS, &AiVoiceView::ChangeAiVoicNotSetApiKeysView},
{AIVOICE_APIKEYS_DELETE, &AiVoiceView::ChangeAiVoicApiKeysDeleteView},
+ {AIVOICE_AIMODE_CONNECTING, &AiVoiceView::ChangeAiVoicConnectingView},
};
bool AiVoiceView::ClickFunc(int16_t interface)
* @Author: luozheng 1732036298@qq.com
* @Date: 2024-06-12 11:44:04
* @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-07-27 12:34:03
+ * @LastEditTime: 2024-08-03 14:17:30
* @FilePath: /FD230/code/sdk/application/wearable/nativeapp/nativeui/uiservice/include/ui_service.h
*/
/*
UI_UPDATE_MESSAGE_DATA, //更新消息数据
UI_AI_JUMP_TO_RESULT_VIEW, //跳转到返回结果视图
+ UI_AI_JUMP_TO_LISTENING_VIEW,//跳转到AI聆听界面
UI_UPDATE_USER_QUESTION_STR,//更新用户问题的字符串
UI_UPDATE_AI_ANSWER_STR, //更新AI答案的字符串
UI_HAND_WATCH_FIRST_PAIRED, //手表已配对:给第一次手表启动用配对成功调用
static void HandleUpdateVibrationMode(Request *request);
static void HandleUpdateSilentMode(Request *request);
static void HandleAiJumpToResultView(Request *request);
+static void HandleAiJumpToListeningMessage(Request *request);
static void HandleUpdateUserQuestionStr(Request *request);
static void HandleUpdateAIAnswerStr(Request *request);
static void HandleWatchFirstPaired(Request *request);
{UI_UPDATE_AI_ANSWER_STR, HandleUpdateAIAnswerStr},
{UI_HAND_WATCH_FIRST_PAIRED,HandleWatchFirstPaired},
{UI_UPDATE_OBU_MESSAGE,HandleUpdateOBUMessage},
+ {UI_AI_JUMP_TO_LISTENING_VIEW,HandleAiJumpToListeningMessage},
{UI_UPDATE_SLEEP_DATA, HandleUpdateSleep},
{UI_UPDATE_MESSAGE_DATA, HandleUpdateMessage},
std::bind(&OHOS::OBUMessageModel::UpdateOBUMessageViewData, &OHOS::OBUMessageModel::GetInstance()));
}
+//处理更新查询AI模型是否连接成功的状态
+void HandleAiJumpToListeningMessage(Request *request)
+{
+ WEARABLE_LOGI(WEARABLE_LOG_MODULE_UI_SERVICE, "HandleAiJumpToListeningMessage");
+ bool state = *((bool*)request->data);
+ GraphicService::GetInstance()->PostGraphicEvent(
+ std::bind(&OHOS::AiVoiceModel::ChangeToAIVoiceListeningView, &OHOS::AiVoiceModel::GetInstance(),state));
+}
+
//更新睡眠数据
void HandleUpdateSleep(Request *request)
{
#include "SliceTransition.h"
#include "soc_osal.h"
#include "stack"
+#include "wearable_log.h"
namespace OHOS {
const static uint16_t gSliceInvalid = 0;
const static uint16_t gSliceDefaultPriority = 4; // 页面默认是最低优先级
/*打印栈中元素*/
void showsStackSliceId()
{
- printf("\n%d\n",backStack_.size());
std::stack<uint16_t> tempStack = backStack_;
- printf("\n[");
while(!tempStack.empty())
{
- printf("%d,",tempStack.top());
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "%d,", tempStack.top());
tempStack.pop();
}
- printf("]\n");
- printf("\n%d\n",backStack_.size());
}
/* -------------------------------------------------------------------------- */
//在此处实现,给UI回复消息。
void ble_app_reply(bool data)
{
- OHOS::AiVoiceModel::GetInstance().SetAiVoiceConnectStatus(data);
+ bool state = data;
+ SendMsgToUIService(UI_AI_JUMP_TO_LISTENING_VIEW, 0, &state, sizeof(bool));
}
crcvalue);\r
#endif\r
\r
- switch (type)\r
+ if(buffer_handle->handle==data2ae4Cmd)\r
{\r
- case 0x02://获取手机信息\r
- type2AE4Data(buffer_handle,buf_cmd,data,data_size,totalData,crcvalue);\r
- break;\r
- case 0x01:\r
- type2AE3Data(buffer_handle,buf_cmd,data,data_size,totalData,crcvalue);\r
- break;\r
- case 0x03://\r
- type2AE1Data(buf_cmd,data,data_size,totalData,crcvalue);\r
- break;\r
- case 0x04:\r
- type2AE0Data(buffer_handle);\r
- break;\r
- case 0x06:\r
- type2AE6Data(buffer_handle,buf_cmd,data,data_size,totalData,crcvalue);\r
- default:\r
- break;\r
+ type2AE4Data(buffer_handle,buf_cmd,data,data_size,totalData,crcvalue);\r
+ }\r
+ else if (buffer_handle->handle==data2ae3Cmd)\r
+ {\r
+ type2AE3Data(buffer_handle,buf_cmd,data,data_size,totalData,crcvalue);\r
+ }\r
+ else if (buffer_handle->handle==data2ae1Cmd)\r
+ {\r
+ type2AE1Data(buf_cmd,data,data_size,totalData,crcvalue);\r
+ }\r
+ else if (buffer_handle->handle==data2ae0Cmd)\r
+ {\r
+ type2AE0Data(buffer_handle);\r
+ }\r
+ else if (buffer_handle->handle==data2ae6Cmd)\r
+ {\r
+ type2AE6Data(buffer_handle,buf_cmd,data,data_size,totalData,crcvalue);\r
}\r
}\r
\r
#define SYN_BASIC_REAL_HEATR_CMD 0x024B //同步基础训练试试心率记录
#define APP_SEND_CHATGPT_KEY_CMD 0x0223 //APP发送chatGPT key
#define SYN_TODAY_BASIC_TRAIN_TXT_CMD 0x024D //同步当天任意时间之后的基础训练记录
-#define APP_SEND_AI_KEY_IS_AVAILABLE_CMD 0x0601 //查询AI是否可用,APP 回复
+#define APP_SEND_AI_KEY_IS_AVAILABLE_CMD 0x0506 //查询AI是否可用,APP 回复
#define SYN_APP_GET_GPS_DATA_CMD 0x024F //同步gps信息
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:9f24a574150a0072dd4b9a570bab14a82a81ce335f22f0efe2498342396afe75
+size 2184
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:8b271d16d692cc5d6c8657c59b60226788e31faf1bd890ef0d57df395fe2692f
+size 2184
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:a60f07c4c5f84e50c88f7823067b829b724d00265e120ac37c638c4545dd2148
+size 2184
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:83db015575db41bf67d2aa51204b109fb83b6107552a6fa8ef486aa68d9909d3
+size 2184
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:cae43b93ac7641be73c6e76e9cd25e27e95b29851f9fea7640c047db5cb6b3a6
+size 2184
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:970d0e91901900918b829c1b5cf4b5603021a93ad28a3eeeb786de9eb209a5b2
+size 2184
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:e27081e4806b16ec7f48fe292c923783e62d6006daa9c39f27de76d5f8752293
+size 2184
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:ed6681d064ca26cd486203027c55e3ca685a9e3c16dce18364488788c74f57e8
+size 2184
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:65348abc3ef5c0216825e6705f768de189f1c9e9d994ab0793019e1d42977757
+size 2184
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:17e917fc6ff0aba1a0dcdc6b901175eb35c5ce27b161b6a64feff4006cfd2be1
+size 2184
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:9ebc140721c21d1cf38c3d1b76cb7777bfedc508a67cb8be9b345ebe5d748fdf
+size 2184
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:19096bc443031ad77ab0ef1ca4ebfa52dc75ad63de11d9c9e2d6f05fcb435b4c
+size 2184
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:78bbdb272259095dd5682e45cc1ba80b257e6deb99e6760fd2a2a785f1fddc2a
+size 2184
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:cda5f09486aa95998838cc1bb3d8630d9183a77b8fd9eb202c009d13cb9a72ea
+size 2184
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:31f81063025756a6e38d400ff0ca3b1fbef672bf4fa03f160c54a932e9ffb785
+size 2184
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:fb365f3dde965aa9fbc29576c3c3a1c892cf477ea197f3bd0e770eb19b14e0b0
+size 2184
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:cbf0c776d5c99709f6153fc9d0baca614f20e47d05b604bc9c039afb16022542
+size 2184
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:7e0bee053cfe10c98fa05236b89e32ac6855a63918fd9ec1c69b501d1d43908f
+size 2184
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:8be1901268dc16135eabbfdbbb41ad0a5574ffb0c0f9f8acce694c9ac5a23e91
+size 2184
--- /dev/null
+version https://git-lfs.github.com/spec/v1
+oid sha256:a8af7f172f5483cf1fd252d7b614796fa625564b32666c8998eca121bbd62ac7
+size 2184
* @brief Font shaping, which is enabled by default on other platforms.
* Cannot take effect without ENABLE_ICU.
*/
-#define ENABLE_SHAPING 0
+#define ENABLE_SHAPING 1
/**
* @brief Advanced algorithm for line breaks, which is enabled by default on other platforms.
*/
/**
* @brief image bin ability, which is disabled by default on LiteOS.
*/
-#define ENABLE_IMAGE_PACKER 0
+#define ENABLE_IMAGE_PACKER 1
#endif
#define ENABLE_ROTATE_INPUT 1