AI语音的按钮背景与图片更新
authorluozheng <1732036298@qq.com>
Thu, 15 Aug 2024 09:28:14 +0000 (17:28 +0800)
committerluozheng <1732036298@qq.com>
Thu, 15 Aug 2024 09:28:14 +0000 (17:28 +0800)
code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoiceView.h
code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceView.cpp
code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/AIVoice/ai_chart_icon.bin [new file with mode: 0644]
code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/AIVoice/ai_chart_icon_bg.bin [new file with mode: 0644]
code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/AIVoice/aimodels/aimodels_chatgpt.bin
code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/AIVoice/aimodels/aimodels_kimi.bin

index 1a5aeb4..34a83ec 100644 (file)
@@ -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};
index 63a1996..4f1840e 100644 (file)
@@ -2,7 +2,7 @@
  * @Author: luozheng 1732036298@qq.com
  * @Date: 2024-05-07 11:25:58
  * @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-08-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 (file)
index 0000000..0b17061
--- /dev/null
@@ -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 (file)
index 0000000..e17f48c
--- /dev/null
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:2b7a2a2a12eb5042502cd7a345ece2fa16fb0dcd7601f7ce4eeddabd45d7c4ae
+size 20504