AI语音界面修改,禁用功能键的双击和单击功能,删除Ai模型无用图片
authorluozheng <1732036298@qq.com>
Sat, 27 Jul 2024 10:38:00 +0000 (18:38 +0800)
committerluozheng <1732036298@qq.com>
Sat, 27 Jul 2024 10:38:00 +0000 (18:38 +0800)
13 files changed:
code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoiceModel.h
code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoicePresenter.h
code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoiceView.h
code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceModel.cpp
code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoicePresenter.cpp
code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceView.cpp
code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/RebootAndShutdownModel.cpp
code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/AIVoice/aimodels/aimodels_bg.bin [deleted file]
code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/AIVoice/aimodels/aimodels_chatgpt.bin [moved from code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/AIVoice/aimodels/aimode_lschatgpt_on.bin with 100% similarity]
code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/AIVoice/aimodels/aimodels_chatgpt_off.bin [deleted file]
code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/AIVoice/aimodels/aimodels_select.bin [deleted file]
code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/AIVoice/aimodels/aimodels_title_bg.bin [deleted file]
code/sdk/drivers/peripheral/config/include/ConfigModel.h

index ac1e9d2..681f8b0 100644 (file)
@@ -2,7 +2,7 @@
  * @Author: luozheng 1732036298@qq.com
  * @Date: 2024-06-20 15:14:43
  * @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-07-16 16:12:10
+ * @LastEditTime: 2024-07-27 17:22:08
  * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoiceModel.h
  */
 #ifndef AI_VOICE_MODEL_H
@@ -72,6 +72,10 @@ namespace OHOS
         void AIVoice_StartTimer(uint32_t interval = 2000);
         void AIVoice_StopTimer(void);
 
+        void SetSelectAiModel(int index);
+        int GetSelectAiModel(void);
+        int GetAiModelTextId(void);
+
     private:
         AiVoiceModel();
         ~AiVoiceModel();
index 32bea14..ad1c5d1 100644 (file)
@@ -2,7 +2,7 @@
  * @Author: luozheng 1732036298@qq.com
  * @Date: 2024-06-20 14:44:22
  * @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-07-03 19:31:46
+ * @LastEditTime: 2024-07-27 17:05:56
  * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoicePresenter.h
  */
 #ifndef AI_VOICE_PRESENTER_H
@@ -10,7 +10,7 @@
 
 #include "Presenter.h"
 #include "View.h"
-
+#include "ui_resource_string.h"
 namespace OHOS
 {
     class AiVoiceView;
@@ -22,6 +22,14 @@ namespace OHOS
                              public UIView::OnTouchListener
     {
     public:
+        typedef enum : uint8_t
+        {
+            AIMODES_WENXINYIYAN = 0, /*文心一言*/
+            AIMODES_KIMI,            /*KIMI*/
+            AIMODES_DOUBAO,          /*豆包*/
+            AIMODES_CHATGPT,         /*chatgpt*/
+            AIMODES_MAX_NUM,
+        } aimodels;
         AiVoicePresenter();
         virtual ~AiVoicePresenter();
         static AiVoicePresenter *GetInstance();
index a8012c7..0afd187 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-06-25 14:53:47
+ * @LastEditTime: 2024-07-27 18:22:22
  * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/respiratorytraining/include/AiVoiceView.h
  */
 #ifndef AI_VOICE_VIEW_H
 #include "components/ui_button.h"
 #include "components/ui_scroll_view.h"
 #include "components/ui_image_view.h"
+#include "components/ui_picker.h"
 #include "aivoice/include/AiVoiceBluetoothFailedStartView.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"
+#include "iostream"
+#include "string"
+#include "map"
 namespace OHOS
 {
-    static constexpr const char *START_CHAT_BUTTON_VIEW_ID = "StartChatButton"; // 开始对话
+    static constexpr const char *AIMODEL_WENXINYIYAN_PATH = "/user/res/AIVoice/aimodels/aimodels_wenxinyiyan.bin"; /*文心一言*/
+    static constexpr const char *AIMODEL_CHATGPT_ON_PATH = "/user/res/AIVoice/aimodels/aimodels_chatgpt.bin";      /*ChatGPT*/
+    static constexpr const char *AIMODEL_KIMI_PATH = "/user/res/AIVoice/aimodels/aimodels_kimi.bin";               /*KIMI*/
+    static constexpr const char *AIMODEL_DOUBAO_PATH = "/user/res/AIVoice/aimodels/aimodels_doubao.bin";           /*豆包*/
+
+    static constexpr const char *AIVOICE_START_CHAT_BUTTON_VIEW_ID = "aivoice_start_chat_button_view_id"; // 开始对话
+    static constexpr const char *AIVOICE_CHAT_BUTTON_VIEW_ID = "aivoice_chat_button_view_id";             // 对话
+    static constexpr const char *AIVOICE_APIKEYS_BUTTON_VIEW_ID = "aivoice_apikeys_button_view_id";       // API Keys
+    static constexpr const char *AIVOICE_PICKER_VIEW_ID = "aivoice_picker_view_id";
+    static constexpr const char *AIVOICE_IMGAE_VIEW_ID = "aivoice_imgae_view_id";
 
     typedef enum
     {
@@ -36,6 +49,13 @@ namespace OHOS
         MAX_AIVOICE_VIEWID,
     } AIVOICEVIEWID;
 
+    static std::map<int, const char *> TextIdToImagePath = {
+        {STR_AIMODES_WENXINYIYAN, AIMODEL_WENXINYIYAN_PATH},
+        {STR_AIMODES_KIMI, AIMODEL_KIMI_PATH},
+        {STR_AIMODELS_DOUBAO, AIMODEL_DOUBAO_PATH},
+        {STR_AIMODES_CHATGPT, AIMODEL_CHATGPT_ON_PATH},
+    };
+
     class AiVoicePresenter;
     class AiVoiceView : public View<AiVoicePresenter>
     {
@@ -59,6 +79,7 @@ namespace OHOS
             int16_t y;
             int16_t w;
             int16_t h;
+            const char *src;
         };
 
         struct ButtonConfig
@@ -84,6 +105,9 @@ namespace OHOS
         bool ChangeAiVoicThinkingView(int16_t thisView);
         bool ChangeAiVoicReturnResultTextView(int16_t thisView);
 
+        void SetAiVoiceViewAllComponentsVisibilityStatus();
+        void ChangeAiModelAndUpdateComponentsStatus(void);
+
         void OnStart() override;
         void OnSetUpView() override;
         void OnTearDownView() override;
@@ -104,15 +128,21 @@ namespace OHOS
         bool CreateAiVoiceViewLabel(void);
         bool CreateAiVoiceViewImageView(void);
         bool CreateAiVoiceViewButton(void);
+        bool CreateAiVoiceViewPicker(void);
         bool CreateAiVoiceScrollView(void);
         void CreateAiVoiceView(void);
         void ClearAll(void);
-        UILabelExt *title{nullptr};
-        UILabelExt *startChatLabel{nullptr};
-        UIButton *startChatButton{nullptr};
-        UIImageView *startChatImage{nullptr};
+        void SetComponentVisibility(UIView *component, bool isVisible);
+        UILabelExt *title{nullptr};          /*标题*/
+        UILabelExt *startChatLabel{nullptr}; /*开始对话标签*/
+        UIButton *startChatButton{nullptr};  /*开始对话按钮*/
+        UILabelExt *chatLabel{nullptr};      /*对话标签*/
+        UIButton *chatButton{nullptr};       /*对话按钮*/
+        UIImageView *aiModelImage{nullptr};  /*ai模型图片*/
+        UILabelExt *apiKeysLabel{nullptr};   /*API Keys标签*/
+        UIButton *apiKeysButton{nullptr};    /*API Keys按钮*/
+        UIPicker *aiModelPicker{nullptr};    /*ai模型选择器*/
         UIScrollView *AiVoiceScrollView[MAX_AIVOICE_VIEWID]{nullptr};
-
         bool viewInitStatus{false};
     };
 }
index f00c8e0..cc98be9 100644 (file)
@@ -2,7 +2,7 @@
  * @Author: luozheng 1732036298@qq.com
  * @Date: 2024-06-20 15:14:50
  * @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-07-16 10:00:58
+ * @LastEditTime: 2024-07-27 18:35:32
  * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceModel.cpp
  */
 #include "aivoice/include/AiVoiceModel.h"
@@ -22,6 +22,7 @@
 #include <custom_utils.h>
 #include <bleEvent.h>
 #include <unistd.h>
+#include "ConfigModel.h"
 namespace OHOS
 {
     // 声明定时器变量
@@ -588,10 +589,10 @@ namespace OHOS
      */
     void AiVoiceModel::AIVoice_StopTimer(void)
     {
-        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiVoiceModel::AIVoice_StopTimer");
         // 检查定时器是否存在
         if (g_timer != NULL)
         {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiVoiceModel::AIVoice_StopTimer");
             // 删除定时器并置为 NULL
             osStatus_t ret = osTimerDelete(g_timer);
             if (ret != osOK)
@@ -602,4 +603,37 @@ namespace OHOS
             Time = THIRTY_TIME;
         }
     }
+
+    // 设置选择的ai模型
+    void AiVoiceModel::SetSelectAiModel(int index)
+    {
+        ConfigModel::GetInstance()->SetSelectAiModel(index);
+    }
+
+    int AiVoiceModel::GetSelectAiModel(void)
+    {
+        return ConfigModel::GetInstance()->GetSelectAiModel();
+    }
+
+    /*获取已选择的ai模型的textid*/
+    int AiVoiceModel::GetAiModelTextId(void)
+    {
+        std::map<int, int> selectAiModelToTextId = {
+            {AiVoicePresenter::AIMODES_WENXINYIYAN, STR_AIMODES_WENXINYIYAN},
+            {AiVoicePresenter::AIMODES_KIMI, STR_AIMODES_KIMI},
+            {AiVoicePresenter::AIMODES_DOUBAO, STR_AIMODELS_DOUBAO},
+            {AiVoicePresenter::AIMODES_CHATGPT, STR_AIMODES_CHATGPT},
+        };
+
+        // 根据视图ID设置文本ID
+        auto it = selectAiModelToTextId.find(GetSelectAiModel());
+        if (it != selectAiModelToTextId.end())
+        {
+            return it->second;
+        }
+        else 
+        {
+            return STR_AIMODES_WENXINYIYAN;
+        }
+    }
 }
index a726b03..61c7a71 100644 (file)
@@ -2,7 +2,7 @@
  * @Author: luozheng 1732036298@qq.com
  * @Date: 2024-06-20 15:11:17
  * @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-07-12 10:49:59
+ * @LastEditTime: 2024-07-27 18:21:46
  * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoicePresenter.cpp
  */
 #include "AppViewIDs.h"
@@ -28,7 +28,6 @@
 
 namespace OHOS
 {
-
     // 当前Presenter属性实例化的内存指针
     static AiVoicePresenter *g_pAiVoicePresenter = nullptr;
 
@@ -274,8 +273,21 @@ namespace OHOS
 
     bool AiVoicePresenter::OnClick(UIView &view, const ClickEvent &event)
     {
-        UNUSED(view);
         UNUSED(event);
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoicePresenter::OnClick");
+
+        if (strcmp(view.GetViewId(), AIVOICE_IMGAE_VIEW_ID) == 0)
+        {
+            int index = model->GetSelectAiModel() + 1;
+            if (index >= AIMODES_MAX_NUM)
+            {
+                index = AIMODES_WENXINYIYAN;
+            }
+            WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiModelsPresenter::index = %d", index);
+            model->SetSelectAiModel(index);
+            view_->ChangeAiModelAndUpdateComponentsStatus();
+        }
+
         return true;
     }
 
@@ -286,7 +298,7 @@ namespace OHOS
         std::string viewId = view.GetViewId();
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiVoicePresenter::OnRelease %s", viewId.c_str());
 
-        if (viewId == START_CHAT_BUTTON_VIEW_ID) // 如果点击的是开始对话按钮
+        if (viewId == AIVOICE_START_CHAT_BUTTON_VIEW_ID) // 如果点击的是开始对话按钮
         {
 #if 0
             if (model->GetMobileDataIsOpen() == false) // 判断移动数据是否开启
index ce9430f..377c6e3 100644 (file)
@@ -2,14 +2,15 @@
  * @Author: luozheng 1732036298@qq.com
  * @Date: 2024-05-07 11:25:58
  * @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-07-12 16:05:22
+ * @LastEditTime: 2024-07-27 18:22:15
  * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/AiVoice/src/AiVoiceView.cpp
  */
 #include "aivoice/include/AiVoicePresenter.h"
 #include "aivoice/include/AiVoiceView.h"
+#include "aivoice/include/AiVoiceModel.h"
 #include "wearable_log.h"
 #include "ui_resource_string.h"
-#include "aimodels/include/AiModelsModel.h"
+#include "ConfigModel.h"
 namespace OHOS
 {
 
@@ -51,8 +52,8 @@ namespace OHOS
                 delete title;
                 title = nullptr;
 
-                delete startChatImage;
-                startChatImage = nullptr;
+                delete aiModelImage;
+                aiModelImage = nullptr;
 
                 delete startChatButton;
                 startChatButton = nullptr;
@@ -60,6 +61,21 @@ namespace OHOS
                 delete startChatLabel;
                 startChatLabel = nullptr;
 
+                delete chatButton;
+                chatButton = nullptr;
+
+                delete chatLabel;
+                chatLabel = nullptr;
+
+                delete apiKeysLabel;
+                apiKeysLabel = nullptr;
+
+                delete apiKeysButton;
+                apiKeysButton = nullptr;
+
+                delete aiModelPicker;
+                aiModelPicker = nullptr;
+
                 delete AiVoiceScrollView[AIVOICE_STARTCHAT_VIEWID];
                 AiVoiceScrollView[AIVOICE_STARTCHAT_VIEWID] = nullptr;
             }
@@ -128,6 +144,7 @@ namespace OHOS
             return nullptr;
         }
         Image->SetPosition(imageconfig.x, imageconfig.y, imageconfig.w, imageconfig.h);
+        Image->SetSrc(imageconfig.src);
         return Image;
     }
 
@@ -158,7 +175,7 @@ namespace OHOS
             .height = 35,
             .fontSize = 30,
             .lineHeigh = 35,
-            .textId = AiModelsModel::GetInstance().GetAiModelTextId(),
+            .textId = AiVoiceModel::GetInstance().GetAiModelTextId(),
             .lineBreakMode = UILabel::LINE_BREAK_OSCILLATION,
         };
         title = AiVoiceViewLabelInit(labelConfig);
@@ -167,15 +184,15 @@ namespace OHOS
             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "title new fail!");
             return false;
         }
-
+        /* ----------------------------- startChatLabel ----------------------------- */
         labelConfig = {
             .left = 133,
-            .top = 368,
+            .top = 348,
             .width = 200,
             .height = 35,
             .fontSize = 30,
             .lineHeigh = 35,
-            .textId = STR_START_CHAT,
+            .textId = STR_START_CHAT, /*开始对话*/
             .lineBreakMode = UILabel::LINE_BREAK_OSCILLATION,
         };
         startChatLabel = AiVoiceViewLabelInit(labelConfig);
@@ -184,6 +201,43 @@ namespace OHOS
             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "startChatLabel new fail!");
             return false;
         }
+        startChatLabel->SetVisible(false);
+        /* -------------------------------- ChatLabel ------------------------------- */
+        labelConfig = {
+            .left = 93,
+            .top = 350,
+            .width = 100,
+            .height = 30,
+            .fontSize = 26,
+            .lineHeigh = 30,
+            .textId = STR_CHAT, /*对话*/
+            .lineBreakMode = UILabel::LINE_BREAK_OSCILLATION,
+        };
+        chatLabel = AiVoiceViewLabelInit(labelConfig);
+        if (chatLabel == nullptr)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "chatLabel new fail!");
+            return false;
+        }
+        chatLabel->SetVisible(false);
+        /* ------------------------------ apiKeysLabel ------------------------------ */
+        labelConfig = {
+            .left = 273,
+            .top = 350,
+            .width = 100,
+            .height = 30,
+            .fontSize = 26,
+            .lineHeigh = 30,
+            .textId = STR_API_KEYS, /*API Keys标签*/
+            .lineBreakMode = UILabel::LINE_BREAK_OSCILLATION,
+        };
+        apiKeysLabel = AiVoiceViewLabelInit(labelConfig);
+        if (apiKeysLabel == nullptr)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "apiKeysLabel new fail!");
+            return false;
+        }
+        apiKeysLabel->SetVisible(false);
 
         return true;
     }
@@ -192,20 +246,32 @@ namespace OHOS
     {
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoiceView::CreateAiVoiceViewImageView");
         ImageConfig imagecinfig = {
-            .x = 207,
-            .y = 182,
-            .w = 52,
-            .h = 52,
+            .x = 173,
+            .y = 143,
+            .w = 120,
+            .h = 120,
+            .src = "",
         };
-        startChatImage = AiVoiceViewImageView(imagecinfig);
-        if (startChatImage == nullptr)
+
+        // 根据视图ID设置文本ID
+        auto it = TextIdToImagePath.find(AiVoiceModel::GetInstance().GetAiModelTextId());
+        if (it != TextIdToImagePath.end())
+        {
+            imagecinfig.src = it->second;
+        }
+
+        aiModelImage = AiVoiceViewImageView(imagecinfig);
+        if (aiModelImage == nullptr)
         {
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiVoiceView::startChatImage is nullptr!!");
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiVoiceView::aiModelImage is nullptr!!");
             return false;
         }
-        startChatImage->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff);
-        startChatImage->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
-        startChatImage->SetStyle(STYLE_BORDER_RADIUS, 100);
+        aiModelImage->SetTouchable(true);
+        aiModelImage->SetViewId(AIVOICE_IMGAE_VIEW_ID);
+        aiModelImage->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff);
+        aiModelImage->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
+        aiModelImage->SetStyle(STYLE_BORDER_RADIUS, 100);
+        aiModelImage->SetOnClickListener(presenter_);
 
         return true;
     }
@@ -213,12 +279,13 @@ namespace OHOS
     bool AiVoiceView::CreateAiVoiceViewButton(void)
     {
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoiceView::CreateAiVoiceViewButton");
+        /* ----------------------------- startChatButton ---------------------------- */
         ButtonConfig buttonconfig = {
             .x = 93,
-            .y = 340,
+            .y = 320,
             .w = 280,
             .h = 90,
-            .ViewId = START_CHAT_BUTTON_VIEW_ID,
+            .ViewId = AIVOICE_START_CHAT_BUTTON_VIEW_ID,
         };
         startChatButton = AiVoiceViewButtonInit(buttonconfig);
         if (startChatButton == nullptr)
@@ -226,6 +293,64 @@ namespace OHOS
             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "startChatButton new fail!");
             return false;
         }
+        startChatButton->SetVisible(false);
+        /* ------------------------------- chatButton ------------------------------- */
+        buttonconfig = {
+            .x = 58,
+            .y = 320,
+            .w = 170,
+            .h = 90,
+            .ViewId = AIVOICE_CHAT_BUTTON_VIEW_ID,
+        };
+        chatButton = AiVoiceViewButtonInit(buttonconfig);
+        if (chatButton == nullptr)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "chatButton new fail!");
+            return false;
+        }
+        chatButton->SetVisible(false);
+        /* ------------------------------ apiKeysButton ----------------------------- */
+        buttonconfig = {
+            .x = 238,
+            .y = 320,
+            .w = 170,
+            .h = 90,
+            .ViewId = AIVOICE_APIKEYS_BUTTON_VIEW_ID,
+        };
+        apiKeysButton = AiVoiceViewButtonInit(buttonconfig);
+        if (apiKeysButton == nullptr)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "apiKeysButton new fail!");
+            return false;
+        }
+        apiKeysButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);
+        apiKeysButton->SetVisible(false);
+
+        return true;
+    }
+
+    bool AiVoiceView::CreateAiVoiceViewPicker(void)
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoiceView::CreateAiVoiceViewPicker");
+        if (aiModelPicker == nullptr)
+        {
+            aiModelPicker = new UIPicker();
+            if (aiModelPicker == nullptr)
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "aiModelPicker new fail!");
+                return false;
+            }
+            aiModelPicker->SetPosition(203, 203, 60, 60);
+            aiModelPicker->SetViewId(AIVOICE_PICKER_VIEW_ID);
+            aiModelPicker->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff);
+            aiModelPicker->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
+            aiModelPicker->SetStyle(STYLE_BORDER_RADIUS, 150);
+            aiModelPicker->SetItemHeight(40);
+            aiModelPicker->SetLoopState(true);
+            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);
+        }
 
         return true;
     }
@@ -251,16 +376,21 @@ namespace OHOS
     void AiVoiceView::CreateAiVoiceView(void)
     {
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoiceView::CreateAiVoiceView");
-        if (!CreateAiVoiceScrollView() || !CreateAiVoiceViewLabel() ||
-            !CreateAiVoiceViewImageView() || !CreateAiVoiceViewButton())
+        if (!CreateAiVoiceScrollView() || !CreateAiVoiceViewImageView() || !CreateAiVoiceViewPicker() ||
+            !CreateAiVoiceViewLabel() || !CreateAiVoiceViewButton())
         {
             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiVoiceView::CreateAiVoiceView fail!");
             return;
         }
         AiVoiceScrollView[AIVOICE_STARTCHAT_VIEWID]->Add(title);
-        AiVoiceScrollView[AIVOICE_STARTCHAT_VIEWID]->Add(startChatImage);
+        AiVoiceScrollView[AIVOICE_STARTCHAT_VIEWID]->Add(aiModelPicker);
+        AiVoiceScrollView[AIVOICE_STARTCHAT_VIEWID]->Add(aiModelImage);
         AiVoiceScrollView[AIVOICE_STARTCHAT_VIEWID]->Add(startChatButton);
         AiVoiceScrollView[AIVOICE_STARTCHAT_VIEWID]->Add(startChatLabel);
+        AiVoiceScrollView[AIVOICE_STARTCHAT_VIEWID]->Add(chatButton);
+        AiVoiceScrollView[AIVOICE_STARTCHAT_VIEWID]->Add(chatLabel);
+        AiVoiceScrollView[AIVOICE_STARTCHAT_VIEWID]->Add(apiKeysButton);
+        AiVoiceScrollView[AIVOICE_STARTCHAT_VIEWID]->Add(apiKeysLabel);
     }
 
     void AiVoiceView::OnStart()
@@ -283,6 +413,8 @@ namespace OHOS
             viewInitStatus = true;
         }
 
+        SetAiVoiceViewAllComponentsVisibilityStatus();
+
         RootView::GetInstance()->SetOnKeyActListener(presenter_);
         return;
     }
@@ -493,4 +625,48 @@ namespace OHOS
             return nullptr;
         }
     }
+
+    void AiVoiceView::SetAiVoiceViewAllComponentsVisibilityStatus(void)
+    {
+        bool isAiModeChatGpt = (AiVoiceModel::GetInstance().GetAiModelTextId() == STR_AIMODES_CHATGPT);
+
+        SetComponentVisibility(chatButton, isAiModeChatGpt);
+        SetComponentVisibility(chatLabel, isAiModeChatGpt);
+        SetComponentVisibility(apiKeysButton, isAiModeChatGpt);
+        SetComponentVisibility(apiKeysLabel, isAiModeChatGpt);
+
+        SetComponentVisibility(startChatLabel, !isAiModeChatGpt);
+        SetComponentVisibility(startChatButton, !isAiModeChatGpt);
+    }
+
+    void AiVoiceView::SetComponentVisibility(UIView *component, bool isVisible)
+    {
+        if (component)
+        {
+            component->SetVisible(isVisible);
+        }
+    }
+
+    void AiVoiceView::ChangeAiModelAndUpdateComponentsStatus(void)
+    {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiVoiceView::ChangeAiModelAndUpdateComponentsStatus");
+        int textId = AiVoiceModel::GetInstance().GetAiModelTextId();
+        if (title)
+        {
+            title->SetTextId(textId);
+            title->ForceResetText();
+        }
+        if (aiModelImage)
+        {
+            auto it = TextIdToImagePath.find(textId);
+            if (it != TextIdToImagePath.end())
+            {
+                aiModelImage->SetSrc(it->second);
+                aiModelImage->Invalidate();
+            }
+        }
+
+        SetAiVoiceViewAllComponentsVisibilityStatus();
+    }
+
 }
\ No newline at end of file
index 227c699..1b19df7 100644 (file)
@@ -2,7 +2,7 @@
  * @Author: luozheng 1732036298@qq.com
  * @Date: 2024-07-18 14:55:27
  * @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-07-22 18:52:05
+ * @LastEditTime: 2024-07-27 18:27:16
  * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/RebootAndShutdownModel.cpp
  */
 
@@ -280,7 +280,7 @@ namespace OHOS
         RegisterPowerKeyLongPressEvent();
         RegisterFuncKeyPressEvent();
         RegisterFuncKeyLongPressEvent();
-        RegisterFuncKeyClickEvent();
-        RegisterFuncKeyDoubleClickEvent();
+        // RegisterFuncKeyClickEvent();
+        // RegisterFuncKeyDoubleClickEvent();
     }
 }
diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/AIVoice/aimodels/aimodels_bg.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/AIVoice/aimodels/aimodels_bg.bin
deleted file mode 100644 (file)
index 1275fbc..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-version https://git-lfs.github.com/spec/v1
-oid sha256:88c0f9a3719468cfab7a7396d43edaba4a1ce2b313e0e1f95833f0ef0032f52b
-size 77544
diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/AIVoice/aimodels/aimodels_chatgpt_off.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/AIVoice/aimodels/aimodels_chatgpt_off.bin
deleted file mode 100644 (file)
index 9f76ce3..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-version https://git-lfs.github.com/spec/v1
-oid sha256:1b091fbb1ad5c7188b4a2e0348fedc8a97cc37b446068021db7ab5bc2144dad8
-size 9624
diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/AIVoice/aimodels/aimodels_select.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/AIVoice/aimodels/aimodels_select.bin
deleted file mode 100644 (file)
index 56851a5..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-version https://git-lfs.github.com/spec/v1
-oid sha256:f08808b0413214c93e9f596a4bbfd7103ec7b2f592c5aba308792951969ee07f
-size 888
diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/AIVoice/aimodels/aimodels_title_bg.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/AIVoice/aimodels/aimodels_title_bg.bin
deleted file mode 100644 (file)
index a68ef86..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-version https://git-lfs.github.com/spec/v1
-oid sha256:d2d49375658ab31058d0190983d0594d9b3492dcc4ceca3db889e6a17def56a7
-size 8984
index 4210bec..80ae167 100644 (file)
@@ -370,7 +370,7 @@ namespace OHOS
             #endif
             {ConfigDataType::DATATYPE_INT,     "time_hour_show_model",       "24"          },//CONFIGMODEL_ITEM_24HOUR,//默认24小时模式显示 ,12 12小时显示 ,24 24小时显示
                        {ConfigDataType::DATATYPE_STRING,     "dmp_china_mobile_address", "b.fxltsbl.com"},//CONFIGMOFEL_ITEM_DMP_CHINA_MOBILE_ADDRESS 移动入库地址 测试使用适配地址 IP = b.fxltsbl.com 出正式使用商用地址 IP = a.fxltsbl.com
-            {ConfigDataType::DATATYPE_INT,     "select_aimodel",       "0"          },//CONFIGMODEL_ITEM_SELECT_AIMODEL 0:豆包 1:文心一言 2:kimi 3:ChatGPT
+            {ConfigDataType::DATATYPE_INT,     "select_aimodel",       "0"          },//CONFIGMODEL_ITEM_SELECT_AIMODEL
             {ConfigDataType::DATATYPE_BOOL,     "is_first_time_start",       "true"    }, //CONFIGMODEL_ITEM_FIRSTTIMESTART true :手表第一次启动,否则不是
         };
         ConfigModel();                                        // 私有构造函数,确保无法在外部实例化