From ec4e75dec0c9efaac7ff08c59a841ae476e804aa Mon Sep 17 00:00:00 2001 From: luozheng <1732036298@qq.com> Date: Thu, 15 Aug 2024 19:11:32 +0800 Subject: [PATCH] =?utf8?q?AI=E8=AF=AD=E9=9F=B3=E5=B7=B2=E7=BB=8F=E5=AF=B9?= =?utf8?q?=E7=85=A7figma=E4=BF=AE=E6=94=B9=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../nativeui/aivoice/include/AiVoiceView.h | 5 +-- .../nativeui/aivoice/src/AiVoicePresenter.cpp | 20 ++++++++--- .../nativeui/aivoice/src/AiVoiceView.cpp | 36 ++++++++++++++----- .../aivoice/src/apikeys/ApiKeysPresenter.cpp | 28 +++++++++++---- 4 files changed, 67 insertions(+), 22 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoiceView.h b/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoiceView.h index 34a83ecf1..62bddd874 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoiceView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoiceView.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-06-08 09:36:01 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-08-15 17:07:18 + * @LastEditTime: 2024-08-15 18:58:40 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/respiratorytraining/include/AiVoiceView.h */ #ifndef AI_VOICE_VIEW_H @@ -164,7 +164,8 @@ namespace OHOS UILabelExt *chatLabel{nullptr}; /*对话标签,暂时不用*/ UIButton *chatButton{nullptr}; /*对话按钮*/ UIImageView *aiModelImage{nullptr}; /*ai模型图片*/ - UIImageView *buttonBg{nullptr}; /*按钮背景图片*/ + UIImageView *buttonBgImage{nullptr}; /*按钮背景图片*/ + UIImageView *upImage{nullptr}; /*上拉箭头*/ UILabelExt *apiKeysLabel{nullptr}; /*API Keys标签,暂时不用*/ UIButton *apiKeysButton{nullptr}; /*API Keys按钮,,暂时不用*/ UIPicker *aiModelPicker{nullptr}; /*ai模型选择器*/ diff --git a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoicePresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoicePresenter.cpp index 3ce055222..6f09ea77d 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoicePresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoicePresenter.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-06-20 15:11:17 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-08-14 11:22:23 + * @LastEditTime: 2024-08-15 18:53:14 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoicePresenter.cpp */ #include "AppViewIDs.h" @@ -265,7 +265,7 @@ namespace OHOS ChangeViewAndLogicOperator(AIVOICE_STARTCHAT_VIEWID, AIVOICE_NOTSETAPIKEYS); /*开始对话界面->API Keys notset界面*/ return true; } - else if (viewId == AIVOICE_APIKEYS_BUTTON_VIEW_ID) // 如果点击的是API Keys按钮 + else if (viewId == AIVOICE_APIKEYS_BUTTON_VIEW_ID) // 如果点击的是API Keys按钮(注:暂时不用) { if (model->IsExistOpenAIAPIKeys() == true) { @@ -361,11 +361,11 @@ namespace OHOS { return false; } - if (event.GetDragDirection() == DragEvent::DIRECTION_RIGHT_TO_LEFT) + if (event.GetDragDirection() == DragEvent::DIRECTION_RIGHT_TO_LEFT) /*左滑*/ { DragRightToLetfChangeAIModel(); } - else if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && AiVoicePresenter::X_DRAG_FLAG) + else if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && AiVoicePresenter::X_DRAG_FLAG) /*右滑*/ { if (scrollView == view_->GetAiVoiceScrollView(AIVOICE_STARTCHAT_VIEWID)) { @@ -405,6 +405,18 @@ namespace OHOS } AiVoicePresenter::X_DRAG_FLAG = false; } + else if (model->GetAiModelTextId() == STR_AIMODES_CHATGPT && event.GetDragDirection() == DragEvent::DIRECTION_BOTTOM_TO_TOP) /*上滑*/ + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DIRECTION_BOTTOM_TO_TOP"); + if (model->IsExistOpenAIAPIKeys() == true) + { + ChangeViewAndLogicOperator(AIVOICE_STARTCHAT_VIEWID, AIVOICE_SETAPIKEYS); /*开始对话界面->API Keys set界面*/ + } + else + { + ChangeViewAndLogicOperator(AIVOICE_STARTCHAT_VIEWID, AIVOICE_NOTSETAPIKEYS); /*开始对话界面->API Keys notset界面*/ + } + } return true; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceView.cpp b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceView.cpp index 4f1840e0c..7ecc61fef 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceView.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-05-07 11:25:58 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-08-15 17:19:41 + * @LastEditTime: 2024-08-15 19:05:26 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/AiVoice/src/AiVoiceView.cpp */ #include "aivoice/include/AiVoicePresenter.h" @@ -76,8 +76,11 @@ namespace OHOS delete aiModelPicker; aiModelPicker = nullptr; - delete buttonBg; - buttonBg = nullptr; + delete buttonBgImage; + buttonBgImage = nullptr; + + delete upImage; + upImage = nullptr; delete AiVoiceScrollView[AIVOICE_STARTCHAT_VIEWID]; AiVoiceScrollView[AIVOICE_STARTCHAT_VIEWID] = nullptr; @@ -296,7 +299,7 @@ namespace OHOS aiModelImage->SetTouchable(true); aiModelImage->SetViewId(AIVOICE_IMGAE_VIEW_ID); aiModelImage->SetOnClickListener(presenter_); - /* -------------------------------- buttonBg -------------------------------- */ + /* -------------------------------- buttonBgImage -------------------------------- */ imagecinfig = { .x = 208, .y = 340, @@ -304,8 +307,22 @@ namespace OHOS .h = 56, .src = "/user/res/AIVoice/ai_chart_icon.bin", }; - buttonBg = AiVoiceViewImageView(imagecinfig); - if (buttonBg == nullptr) + buttonBgImage = AiVoiceViewImageView(imagecinfig); + if (buttonBgImage == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiVoiceView::aiModelImage is nullptr!!"); + return false; + } + /* --------------------------------- upImage -------------------------------- */ + imagecinfig = { + .x = 213, + .y = static_cast(buttonBgImage->GetY() + buttonBgImage->GetHeight() + 10), + .w = 40, + .h = 40, + .src = "/user/res/Sleep/up.bin", + }; + upImage = AiVoiceViewImageView(imagecinfig); + if (upImage == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiVoiceView::aiModelImage is nullptr!!"); return false; @@ -391,8 +408,8 @@ namespace OHOS aiModelPicker->RequestFocus(); aiModelPicker->RegisterSelectedListener(presenter_); aiModelPicker->SetTextColor(Color::GetColorFromRGBA(0x00, 0x00, 0x00, 0xff), Color::GetColorFromRGBA(0xff, 0x00, 0x00, 0xff)); - const char *uiPicker1Data[] = {"0", "1", "2", "3"}; - aiModelPicker->SetValues(uiPicker1Data, 4); + const char *uiPicker1Data[] = {"0", "1", "2", "3", "4", "5"}; + aiModelPicker->SetValues(uiPicker1Data, sizeof(uiPicker1Data) / sizeof(uiPicker1Data[0])); } return true; @@ -434,7 +451,8 @@ namespace OHOS AiVoiceScrollView[AIVOICE_STARTCHAT_VIEWID]->Add(chatLabel); AiVoiceScrollView[AIVOICE_STARTCHAT_VIEWID]->Add(apiKeysButton); AiVoiceScrollView[AIVOICE_STARTCHAT_VIEWID]->Add(apiKeysLabel); - AiVoiceScrollView[AIVOICE_STARTCHAT_VIEWID]->Add(buttonBg); + AiVoiceScrollView[AIVOICE_STARTCHAT_VIEWID]->Add(buttonBgImage); + AiVoiceScrollView[AIVOICE_STARTCHAT_VIEWID]->Add(upImage); } void AiVoiceView::OnStart() diff --git a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/apikeys/ApiKeysPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/apikeys/ApiKeysPresenter.cpp index 8fac1a678..cc07de1d1 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/apikeys/ApiKeysPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/apikeys/ApiKeysPresenter.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-07-29 16:14:16 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-07-30 15:52:11 + * @LastEditTime: 2024-08-15 18:26:04 * @FilePath: /xts_origin/FD230/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/apikeys/ApiKeysPresenter.cpp */ @@ -80,24 +80,38 @@ namespace OHOS UNUSED(view); WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ApiKeysPresenter::OnDragEnd"); std::string viewId = view.GetViewId(); - + AiVoiceView *p_AiVoiceView = AiVoiceView::GetInstance(); + if (p_AiVoiceView == nullptr) + { + return false; + } if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && X_DRAG_FLAG) { - AiVoiceView *p_AiVoiceView = AiVoiceView::GetInstance(); - std::map> viewMap = { - {SETAPIKEYS_SCROLLVIEW_VIEWID, {AIVOICE_SETAPIKEYS, AIVOICE_STARTCHAT_VIEWID}}, - {NOTSETAPIKEYS_SCROLLVIEW_VIEWID, {AIVOICE_NOTSETAPIKEYS, AIVOICE_STARTCHAT_VIEWID}}, + // {SETAPIKEYS_SCROLLVIEW_VIEWID, {AIVOICE_SETAPIKEYS, AIVOICE_STARTCHAT_VIEWID}}, + // {NOTSETAPIKEYS_SCROLLVIEW_VIEWID, {AIVOICE_NOTSETAPIKEYS, AIVOICE_STARTCHAT_VIEWID}}, {APIKEYS_DELETE_SCROLLVIEW_VIEWID, {AIVOICE_APIKEYS_DELETE, AIVOICE_SETAPIKEYS}}, }; auto it = viewMap.find(viewId); - if (it != viewMap.end() && p_AiVoiceView != nullptr) + if (it != viewMap.end()) { p_AiVoiceView->ChangeView(it->second.first, it->second.second); } X_DRAG_FLAG = false; } + else if (event.GetDragDirection() == DragEvent::DIRECTION_TOP_TO_BOTTOM) /*下滑*/ + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DIRECTION_TOP_TO_BOTTOM"); + if (viewId == SETAPIKEYS_SCROLLVIEW_VIEWID) + { + p_AiVoiceView->ChangeView(AIVOICE_SETAPIKEYS, AIVOICE_STARTCHAT_VIEWID); /*API Keys set界面->开始对话界面*/ + } + else if (viewId == NOTSETAPIKEYS_SCROLLVIEW_VIEWID) + { + p_AiVoiceView->ChangeView(AIVOICE_NOTSETAPIKEYS, AIVOICE_STARTCHAT_VIEWID); /*API Keys notset界面->开始对话界面*/ + } + } return true; } } \ No newline at end of file -- 2.17.1