From 4ea612a7665e2d9584bea96ad7444334ed356157 Mon Sep 17 00:00:00 2001 From: luozheng <1732036298@qq.com> Date: Thu, 24 Oct 2024 20:39:46 +0800 Subject: [PATCH] =?utf8?q?#1060=EF=BC=8C=E8=A7=A3=E5=86=B3=EF=BC=8C?= =?utf8?q?=E6=89=8B=E8=A1=A8=EF=BC=8CAI=E5=85=A8=E5=AE=B6=E6=A1=B6?= =?utf8?q?=E5=81=B6=E5=B0=94=E7=82=B9=E5=87=BB1=E6=AC=A1=E7=BB=A7=E7=BB=AD?= =?utf8?q?=E5=AF=B9=E8=AF=9D=EF=BC=8C=E4=BC=9A=E6=9C=89=E4=B8=8D=E7=81=B5?= =?utf8?q?=E6=95=8F=E7=9A=84=E6=83=85=E5=86=B5=EF=BC=8C=E9=9C=80=E8=A6=81?= =?utf8?q?=E7=82=B9=E5=87=BB=E7=AC=AC2=E6=AC=A1=E6=89=8D=E8=83=BD=E7=BB=A7?= =?utf8?q?=E7=BB=ADbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../aivoice/include/AiVoicePresenter.h | 3 +- .../nativeui/aivoice/src/AiVoicePresenter.cpp | 55 +++++++++++++++---- 2 files changed, 46 insertions(+), 12 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoicePresenter.h b/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoicePresenter.h index 60257671e..106c4ec99 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoicePresenter.h +++ b/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoicePresenter.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-06-20 14:44:22 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-10-23 11:22:25 + * @LastEditTime: 2024-10-24 17:42:07 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoicePresenter.h */ #ifndef AI_VOICE_PRESENTER_H @@ -57,6 +57,7 @@ namespace OHOS private: bool OnClick(UIView &view, const ClickEvent &event) override; + bool OnPress(UIView& view, const PressEvent& event) override; bool OnRelease(UIView &view, const ReleaseEvent &event) override; bool OnDrag(UIView &view, const DragEvent &event) override; bool OnDragEnd(UIView &view, const DragEvent &event) override; 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 0abbb92b4..4f7a05809 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-10-24 17:32:52 + * @LastEditTime: 2024-10-24 18:35:43 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoicePresenter.cpp */ #include "AppViewIDs.h" @@ -283,6 +283,39 @@ namespace OHOS return true; } + bool AiVoicePresenter::OnPress(UIView& view, const PressEvent& event) + { + UNUSED(event); + std::string viewId = view.GetViewId(); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoicePresenter::OnRelease %s", viewId.c_str()); + /* ----------------------------- 重置60s取消常亮屏timer ---------------------------- */ + model->reset_ai_screen60s_timer_time(); + /* -------------------------------------------------------------------------- */ + std::unordered_map> viewIdMap = { + {AIVOICERETURNRESULTTEXT_RETURN_BUTTON_VIEW_ID, {AIVOICE_RETURN_RESULT_TEXT_VIEWID, AIVOICE_STARTCHAT_VIEWID}}, // 返回一级界面,并清除手表聊天记录 + {AIVOICERETURNRESULTTEXT_CONTINUECHAT_BUTTON_VIEW_ID, {AIVOICE_RETURN_RESULT_TEXT_VIEWID, AIVOICE_LISTENING_VIEWID}}, // 返回继续聆听,并清除手表聊天记录 + }; + auto it = viewIdMap.find(viewId); + if (it != viewIdMap.end()) + { + if (it->first == AIVOICERETURNRESULTTEXT_CONTINUECHAT_BUTTON_VIEW_ID) // 点击继续对话按钮要发取消当前对话指令,避免AI回应中途按继续对话按钮没有取消上一次对话问题 + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CancelCurAIChat"); + AiVoiceModel::GetInstance().CancelCurAIChat(); + PlayersModel::GetInstance()->HandPausePhoneMusic(); // 暂停手机音乐 + PlayersModel::GetInstance()->PlayerPause(); // 暂停手机音乐 + } + ChangeViewAndLogicOperator(it->second.first, it->second.second); + return true; + } + else + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Return false if viewId doesn't match any entry in the map"); + return false; + } + return true; + } + bool AiVoicePresenter::OnRelease(UIView &view, const ReleaseEvent &event) { UNUSED(event); @@ -353,19 +386,19 @@ namespace OHOS {AIVOICECONNECTTIMEOUT_ENSURE_BUTTON_VIEW_ID, {AIVOICE_CONNECT_TIMEOUT_VIEWID, AIVOICE_STARTCHAT_VIEWID}}, // 返回一级界面 {CANCEL_THINKING_BUTTON_VIEW_ID, {AIVOICE_THINKING_VIEWID, AIVOICE_STARTCHAT_VIEWID}}, // 返回一级界面 {AIVOICECONNECTINGVIEW_CANCEL_BUTTON_VIEW_ID, {AIVOICE_AIMODE_CONNECTING, AIVOICE_STARTCHAT_VIEWID}}, // 返回一级界面 - {AIVOICERETURNRESULTTEXT_RETURN_BUTTON_VIEW_ID, {AIVOICE_RETURN_RESULT_TEXT_VIEWID, AIVOICE_STARTCHAT_VIEWID}}, // 返回一级界面,并清除手表聊天记录 - {AIVOICERETURNRESULTTEXT_CONTINUECHAT_BUTTON_VIEW_ID, {AIVOICE_RETURN_RESULT_TEXT_VIEWID, AIVOICE_LISTENING_VIEWID}}, // 返回继续聆听,并清除手表聊天记录 + // {AIVOICERETURNRESULTTEXT_RETURN_BUTTON_VIEW_ID, {AIVOICE_RETURN_RESULT_TEXT_VIEWID, AIVOICE_STARTCHAT_VIEWID}}, // 返回一级界面,并清除手表聊天记录 + // {AIVOICERETURNRESULTTEXT_CONTINUECHAT_BUTTON_VIEW_ID, {AIVOICE_RETURN_RESULT_TEXT_VIEWID, AIVOICE_LISTENING_VIEWID}}, // 返回继续聆听,并清除手表聊天记录 }; auto it = viewIdMap.find(viewId); if (it != viewIdMap.end()) { - if (it->first == AIVOICERETURNRESULTTEXT_CONTINUECHAT_BUTTON_VIEW_ID) // 点击继续对话按钮要发取消当前对话指令,避免AI回应中途按继续对话按钮没有取消上一次对话问题 - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CancelCurAIChat"); - AiVoiceModel::GetInstance().CancelCurAIChat(); - PlayersModel::GetInstance()->HandPausePhoneMusic(); // 暂停手机音乐 - PlayersModel::GetInstance()->PlayerPause(); // 暂停手机音乐 - } + // if (it->first == AIVOICERETURNRESULTTEXT_CONTINUECHAT_BUTTON_VIEW_ID) // 点击继续对话按钮要发取消当前对话指令,避免AI回应中途按继续对话按钮没有取消上一次对话问题 + // { + // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CancelCurAIChat"); + // AiVoiceModel::GetInstance().CancelCurAIChat(); + // PlayersModel::GetInstance()->HandPausePhoneMusic(); // 暂停手机音乐 + // PlayersModel::GetInstance()->PlayerPause(); // 暂停手机音乐 + // } ChangeViewAndLogicOperator(it->second.first, it->second.second); return true; } @@ -466,7 +499,7 @@ namespace OHOS uint16_t keyID = event.GetKeyId(); uint16_t keyState = event.GetState(); // 如果是power键,且是亮屏状态,按键释放就返回上一级 - if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 0 && uapi_get_screen_state() == 0) + if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 1 && uapi_get_screen_state() == 0) { NativeAbility::GetInstance().Back(TransitionType::TRANSITION_BACK_TO_HEXAGONS); AiVoiceModel::GetInstance().CancelCurAIChat(); -- 2.17.1