From b13cb15410e7d4e327bc876144f236bc75a41df6 Mon Sep 17 00:00:00 2001 From: luozheng <1732036298@qq.com> Date: Thu, 15 Aug 2024 17:28:14 +0800 Subject: [PATCH] =?utf8?q?AI=E8=AF=AD=E9=9F=B3=E7=9A=84=E6=8C=89=E9=92=AE?= =?utf8?q?=E8=83=8C=E6=99=AF=E4=B8=8E=E5=9B=BE=E7=89=87=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../nativeui/aivoice/include/AiVoiceView.h | 11 ++-- .../nativeui/aivoice/src/AiVoiceView.cpp | 52 +++++++++++++------ .../fs/user/res/AIVoice/ai_chart_icon.bin | 3 ++ .../fs/user/res/AIVoice/ai_chart_icon_bg.bin | 3 ++ .../res/AIVoice/aimodels/aimodels_chatgpt.bin | 2 +- .../res/AIVoice/aimodels/aimodels_kimi.bin | 2 +- 6 files changed, 50 insertions(+), 23 deletions(-) create mode 100644 code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/AIVoice/ai_chart_icon.bin create mode 100644 code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/AIVoice/ai_chart_icon_bg.bin 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 1a5aeb436..34a83ecf1 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-09 20:14:30 + * @LastEditTime: 2024-08-15 17:07:18 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/respiratorytraining/include/AiVoiceView.h */ #ifndef AI_VOICE_VIEW_H @@ -159,13 +159,14 @@ namespace OHOS void ClearAll(void); void SetComponentVisibility(UIView *component, bool isVisible); UILabelExt *title{nullptr}; /*标题*/ - UILabelExt *startChatLabel{nullptr}; /*开始对话标签*/ + UILabelExt *startChatLabel{nullptr}; /*开始对话标签,暂时不用*/ UIButton *startChatButton{nullptr}; /*开始对话按钮*/ - UILabelExt *chatLabel{nullptr}; /*对话标签*/ + UILabelExt *chatLabel{nullptr}; /*对话标签,暂时不用*/ UIButton *chatButton{nullptr}; /*对话按钮*/ UIImageView *aiModelImage{nullptr}; /*ai模型图片*/ - UILabelExt *apiKeysLabel{nullptr}; /*API Keys标签*/ - UIButton *apiKeysButton{nullptr}; /*API Keys按钮*/ + UIImageView *buttonBg{nullptr}; /*按钮背景图片*/ + UILabelExt *apiKeysLabel{nullptr}; /*API Keys标签,暂时不用*/ + UIButton *apiKeysButton{nullptr}; /*API Keys按钮,,暂时不用*/ UIPicker *aiModelPicker{nullptr}; /*ai模型选择器*/ UIScrollView *AiVoiceScrollView[MAX_AIVOICE_VIEWID]{nullptr}; bool viewInitStatus{false}; 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 63a19962b..4f1840e0c 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-03 16:45:06 + * @LastEditTime: 2024-08-15 17:19:41 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/AiVoice/src/AiVoiceView.cpp */ #include "aivoice/include/AiVoicePresenter.h" @@ -76,6 +76,9 @@ namespace OHOS delete aiModelPicker; aiModelPicker = nullptr; + delete buttonBg; + buttonBg = nullptr; + delete AiVoiceScrollView[AIVOICE_STARTCHAT_VIEWID]; AiVoiceScrollView[AIVOICE_STARTCHAT_VIEWID] = nullptr; } @@ -182,8 +185,8 @@ namespace OHOS button->SetPosition(buttonconfig.x, buttonconfig.y, buttonconfig.w, buttonconfig.h); button->SetViewId(buttonconfig.ViewId); button->SetStyle(STYLE_BACKGROUND_COLOR, 0xff4fc34c); - button->SetStyle(STYLE_BACKGROUND_OPA, 0xff); - button->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff383838, UIButton::PRESSED); + button->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + button->SetStyleForState(STYLE_BACKGROUND_COLOR, 0x00, UIButton::PRESSED); button->SetOnTouchListener(presenter_); return button; @@ -293,7 +296,20 @@ namespace OHOS aiModelImage->SetTouchable(true); aiModelImage->SetViewId(AIVOICE_IMGAE_VIEW_ID); aiModelImage->SetOnClickListener(presenter_); - + /* -------------------------------- buttonBg -------------------------------- */ + imagecinfig = { + .x = 208, + .y = 340, + .w = 48, + .h = 56, + .src = "/user/res/AIVoice/ai_chart_icon.bin", + }; + buttonBg = AiVoiceViewImageView(imagecinfig); + if (buttonBg == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiVoiceView::aiModelImage is nullptr!!"); + return false; + } return true; } @@ -302,10 +318,10 @@ namespace OHOS WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoiceView::CreateAiVoiceViewButton"); /* ----------------------------- startChatButton ---------------------------- */ ButtonConfig buttonconfig = { - .x = 93, - .y = 320, - .w = 280, - .h = 90, + .x = 43, + .y = 328, + .w = 380, + .h = 80, .ViewId = AIVOICE_START_CHAT_BUTTON_VIEW_ID, }; startChatButton = AiVoiceViewButtonInit(buttonconfig); @@ -315,12 +331,14 @@ namespace OHOS return false; } startChatButton->SetVisible(false); + const char *image = "/user/res/AIVoice/ai_chart_icon_bg.bin"; + startChatButton->SetImageSrc(image, image); /* ------------------------------- chatButton ------------------------------- */ buttonconfig = { - .x = 58, - .y = 320, - .w = 170, - .h = 90, + .x = 43, + .y = 328, + .w = 380, + .h = 80, .ViewId = AIVOICE_CHAT_BUTTON_VIEW_ID, }; chatButton = AiVoiceViewButtonInit(buttonconfig); @@ -330,6 +348,7 @@ namespace OHOS return false; } chatButton->SetVisible(false); + chatButton->SetImageSrc(image, image); /* ------------------------------ apiKeysButton ----------------------------- */ buttonconfig = { .x = 238, @@ -415,6 +434,7 @@ 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); } void AiVoiceView::OnStart() @@ -780,11 +800,11 @@ namespace OHOS bool isAiModeChatGpt = (AiVoiceModel::GetInstance().GetAiModelTextId() == STR_AIMODES_CHATGPT); SetComponentVisibility(chatButton, isAiModeChatGpt); - SetComponentVisibility(chatLabel, isAiModeChatGpt); - SetComponentVisibility(apiKeysButton, isAiModeChatGpt); - SetComponentVisibility(apiKeysLabel, isAiModeChatGpt); + // SetComponentVisibility(chatLabel, isAiModeChatGpt); + // SetComponentVisibility(apiKeysButton, isAiModeChatGpt); + // SetComponentVisibility(apiKeysLabel, isAiModeChatGpt); - SetComponentVisibility(startChatLabel, !isAiModeChatGpt); + // SetComponentVisibility(startChatLabel, !isAiModeChatGpt); SetComponentVisibility(startChatButton, !isAiModeChatGpt); } diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/AIVoice/ai_chart_icon.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/AIVoice/ai_chart_icon.bin new file mode 100644 index 000000000..0b1706104 --- /dev/null +++ b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/AIVoice/ai_chart_icon.bin @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4b7152b9dfd5e2ee0c45c36e98a54778910358b39617880779ceee7d60a907b2 +size 1944 diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/AIVoice/ai_chart_icon_bg.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/AIVoice/ai_chart_icon_bg.bin new file mode 100644 index 000000000..e17f48ce7 --- /dev/null +++ b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/AIVoice/ai_chart_icon_bg.bin @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2b7a2a2a12eb5042502cd7a345ece2fa16fb0dcd7601f7ce4eeddabd45d7c4ae +size 20504 diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/AIVoice/aimodels/aimodels_chatgpt.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/AIVoice/aimodels/aimodels_chatgpt.bin index 95c04b9a3..680ae8dc0 100644 --- a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/AIVoice/aimodels/aimodels_chatgpt.bin +++ b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/AIVoice/aimodels/aimodels_chatgpt.bin @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:fa5149094c14526b56913b4267664319b80efaaa2c25b502efbc040bfcfe823e +oid sha256:8f48b849f7783dd946a8752d329c9d49b37a86ae19a9d4cf763bf7d67f1c45bf size 9624 diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/AIVoice/aimodels/aimodels_kimi.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/AIVoice/aimodels/aimodels_kimi.bin index f121c8f06..8f6bff1a5 100644 --- a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/AIVoice/aimodels/aimodels_kimi.bin +++ b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/AIVoice/aimodels/aimodels_kimi.bin @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:2edeb79f68820099d597ccfbeabd81466a2e5dec856792fa6cdc5cc5e3130e41 +oid sha256:2e3e7508a7d93e80ea7005122524b28641c77834539d82036291463db059b79b size 9624 -- 2.17.1