添加功能鍵进入AI语音界面,和单击切换模型功能 643/2
authorluozheng <1732036298@qq.com>
Sat, 3 Aug 2024 10:25:37 +0000 (18:25 +0800)
committerluozheng <1732036298@qq.com>
Sat, 3 Aug 2024 10:25:37 +0000 (18:25 +0800)
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/src/AiVoiceModel.cpp
code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoicePresenter.cpp
code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/RebootAndShutdownModel.cpp

index 651199c..9990df9 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-08-03 14:26:12
+ * @LastEditTime: 2024-08-03 17:45:26
  * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoiceModel.h
  */
 #ifndef AI_VOICE_MODEL_H
@@ -30,6 +30,7 @@ namespace OHOS
         static AiVoiceModel &GetInstance(void); // 获取单例实例
         bool ChangeToReturnResultTextView(void);
         bool ChangeToAIVoiceListeningView(bool value);
+        void FunctionKeyOnClickToChangeAIModel(void);
         // 初始化和状态管理
         bool CreateIfNotExists();
         void StatusResume(void);
index 4438950..afd2f32 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-08-03 17:28:03
+ * @LastEditTime: 2024-08-03 17:46:15
  * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoicePresenter.h
  */
 #ifndef AI_VOICE_PRESENTER_H
@@ -44,6 +44,7 @@ namespace OHOS
         bool JumpToReturnResultTextView(void);
         bool ChangeToAIVoiceListeningView(bool val);
         bool ChangeViewAndLogicOperator(int16_t hideView, int16_t showView);
+        void FunctionKeyOnClickToChangeAIModel(void);
 
     private:
         bool OnClick(UIView &view, const ClickEvent &event) override;
index c6d26a9..5853ceb 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-08-03 15:06:35
+ * @LastEditTime: 2024-08-03 17:47:08
  * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceModel.cpp
  */
 #include "aivoice/include/AiVoiceModel.h"
@@ -69,6 +69,19 @@ namespace OHOS
         return true;
     }
 
+    void AiVoiceModel::FunctionKeyOnClickToChangeAIModel(void)
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoiceModel::FunctionKeyOnClickToChangeAIModel");
+        AiVoicePresenter *Aipresenter_ = AiVoicePresenter::GetInstance();
+        if (Aipresenter_ == nullptr)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiVoiceModel::FunctionKeyOnClickToChangeAIModel fail!!");
+            return;
+        }
+        Aipresenter_->FunctionKeyOnClickToChangeAIModel();
+        return;
+    }
+
     /*如果文件不存在就创建*/
     bool AiVoiceModel::CreateIfNotExists()
     {
index 7012df0..9b1b97a 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-08-03 16:26:41
+ * @LastEditTime: 2024-08-03 17:48:50
  * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoicePresenter.cpp
  */
 #include "AppViewIDs.h"
@@ -130,6 +130,19 @@ namespace OHOS
         return true;
     }
 
+    void AiVoicePresenter::FunctionKeyOnClickToChangeAIModel(void)
+    {
+        int index = model->GetSelectAiModel() + 1;
+        if (index >= AIMODES_MAX_NUM)
+        {
+            index = 0;
+        }
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiModelsPresenter::index = %d", index);
+        model->SetSelectAiModel(index);
+        view_->ChangeAiModelAndUpdateComponentsStatus();
+        return;
+    }
+
     bool AiVoicePresenter::ChangeViewAndLogicOperator(int16_t hideView, int16_t showView)
     {
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoicePresenter::ChangeViewOperator");
index 7981ad1..f7b0919 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-08-02 11:57:16
+ * @LastEditTime: 2024-08-03 17:53:50
  * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/RebootAndShutdownModel.cpp
  */
 
@@ -15,7 +15,7 @@
 #include "settings/include/SettingModel.h"
 #include <custom_utils.h>
 #include "themestyle/include/ThemeStyleModel.h"
-#include "aimodels/include/AiModelsModel.h"
+#include "aivoice/include/AiVoiceModel.h"
 #include "ConfigModel.h"
 #include "graphic_service.h"
 namespace OHOS
@@ -276,10 +276,15 @@ namespace OHOS
 
         if (display_api->get_screen_state() == SCREEN_ON)
         {
-            AiModelsModel &aiModelsModel = AiModelsModel::GetInstance();
-            if (!aiModelsModel.ChangeAiModel())
+            uint16_t curSliceId = NativeAbility::GetInstance().GetCurSliceId();
+            if (curSliceId == VIEW_AI_VOICE) // 如果当前已在ai语音界面单击切换模型
+            {
+                AiVoiceModel::GetInstance().FunctionKeyOnClickToChangeAIModel();
+                return;
+            }
+            else
             {
-                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to change AI model");
+                NativeAbility::GetInstance().EnterSlice(VIEW_AI_VOICE);// 切换到Ai语音界面
             }
         }
         else
@@ -363,8 +368,8 @@ namespace OHOS
         RegisterPowerKeyDoubleClickEvent();
         RegisterPowerKeyLongPressEvent();
         RegisterFuncKeyPressEvent();
-        RegisterFuncKeyLongPressEvent();
-        // RegisterFuncKeyClickEvent();
+        // RegisterFuncKeyLongPressEvent();
+        RegisterFuncKeyClickEvent();
         // RegisterFuncKeyDoubleClickEvent();
     }
 }