From d75bcac4a4b5cd1c3e62536f332702aa717ca1c0 Mon Sep 17 00:00:00 2001 From: luozheng <1732036298@qq.com> Date: Mon, 29 Apr 2024 17:28:13 +0800 Subject: [PATCH] =?utf8?q?=E6=8B=A8=E5=8F=B7=E8=A7=86=E5=9B=BE=E4=BF=AE?= =?utf8?q?=E6=94=B9=EF=BC=8C=E5=B7=B2=E6=B5=8B=E8=AF=95=E9=80=9A=E8=BF=87s?= =?utf8?q?im=E5=8D=A1=E6=8B=A8=E5=8F=B7=E6=88=90=E5=8A=9F=E4=BD=86?= =?utf8?q?=E5=8F=91=E7=8E=B0=E5=96=87=E5=8F=AD=E4=B8=8D=E5=87=BA=E5=A3=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../phone/include/PhoneCallPresenter.h | 2 ++ .../phone/include/PhoneDirPresenter.h | 3 ++ .../phone/include/TelephonyInitInterface.h | 11 +++++-- .../phone/src/DialingMethodPresenter.cpp | 10 ++++-- .../nativeui/phone/src/MainPhonePresenter.cpp | 8 ++--- .../nativeui/phone/src/PhoneCallPresenter.cpp | 33 +++++++++++++++++-- .../nativeui/phone/src/PhoneCallView.cpp | 5 +++ .../phone/src/PhoneCallingPresenter.cpp | 2 +- .../phone/src/PhoneCallupPresenter.cpp | 2 +- .../nativeui/phone/src/PhoneDirPresenter.cpp | 20 +++++++++-- .../nativeui/phone/src/PhoneDirView.cpp | 5 +++ .../nativeui/phone/src/PhoneRingPresenter.cpp | 2 +- .../phone/src/TelephonyInitInterface.cpp | 3 +- 13 files changed, 89 insertions(+), 17 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/include/PhoneCallPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/phone/include/PhoneCallPresenter.h index 7f21805c1..6f995e328 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/include/PhoneCallPresenter.h +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/include/PhoneCallPresenter.h @@ -11,6 +11,7 @@ namespace OHOS class PhoneCallView; class PhoneCallPresenter : public Presenter, public UIView::OnClickListener, + public RootView::OnKeyActListener, public UIView::OnDragListener { @@ -33,6 +34,7 @@ namespace OHOS // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; bool OnClick(UIView &view, const ClickEvent &event) override; bool OnDrag(UIView &view, const DragEvent &event) override; + bool OnKeyAct(UIView &view, const KeyEvent &event) override; // 增加按键事件 }; } // namespace OHOS diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/include/PhoneDirPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/phone/include/PhoneDirPresenter.h index 97c709738..e63653e33 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/include/PhoneDirPresenter.h +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/include/PhoneDirPresenter.h @@ -11,6 +11,7 @@ namespace OHOS class PhoneDirPresenter : public Presenter, public UIView::OnClickListener, + public RootView::OnKeyActListener, public UIView::OnDragListener { public: @@ -29,6 +30,8 @@ namespace OHOS // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; bool OnClick(UIView &view, const ClickEvent &event) override; bool OnDrag(UIView &view, const DragEvent &event) override; + bool OnKeyAct(UIView &view, const KeyEvent &event) override; // 增加按键事件 + }; } // namespace OHOS diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/include/TelephonyInitInterface.h b/code/sdk/application/wearable/fd230app/nativeui/phone/include/TelephonyInitInterface.h index 76fadc395..394ade7a1 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/include/TelephonyInitInterface.h +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/include/TelephonyInitInterface.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-04-28 09:58:04 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-04-29 09:24:21 + * @LastEditTime: 2024-04-29 16:21:03 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/phone/include/TelephonyInitInterface.h */ #ifndef TELEPHONY_INIT_INTERFACE_H @@ -15,6 +15,8 @@ #include "components/ui_image_view.h" #include "iostream" #include "UiConfig.h" +#include "gfx_utils/mem_check.h" +#define DUMPMEMORY 0 namespace OHOS { @@ -31,10 +33,15 @@ namespace OHOS static constexpr const char *PNG_FREQUENTLYCONTACTEDBUTTON_IMAGE = "/user/res/Phone/Telephone/FrequentlyContacted.bin"; // 常用联系人按钮icon图片 static constexpr const char *PNG_TELEPHONELINE_IMAGE = "/user/res/Phone/Telephone/TelephoneLine.bin"; // 线 + // 拨号方式 + static constexpr uint8_t DIALINGMETHOD_USINGWATCHSIM = 1; // 手表SIM卡拨号 + static constexpr uint8_t DIALINGMETHOD_USINGPHONE = 0; // 手机拨号 + class TelephonyInitInterface { public: - static bool X_DRAG_FLAG; // 水平拖拽标志 + static bool X_DRAG_FLAG; // 水平拖拽标志 + static uint8_t DIALINGMETHOD; // 拨号方式 typedef struct { diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/src/DialingMethodPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/phone/src/DialingMethodPresenter.cpp index 6d44a9a6d..0b676f405 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/src/DialingMethodPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/src/DialingMethodPresenter.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-03-28 14:17:43 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-04-29 10:01:43 + * @LastEditTime: 2024-04-29 16:18:09 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/language/src/DialingMethodPresenter.cpp */ #include "AppViewIDs.h" @@ -60,11 +60,15 @@ namespace OHOS if (curViewId == USINGWATCHSIMBUTTON_VIEWID) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s OnClick",curViewId.c_str()); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s OnClick", curViewId.c_str()); + TelephonyInitInterface::DIALINGMETHOD = DIALINGMETHOD_USINGWATCHSIM; // 手表SIM卡拨号 + NativeAbility::GetInstance().EnterSlice(VIEW_PHONECALL); } else if (curViewId == USINGPHONEBUTTON_VIEWID) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s OnClick",curViewId.c_str()); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s OnClick", curViewId.c_str()); + TelephonyInitInterface::DIALINGMETHOD = DIALINGMETHOD_USINGPHONE; // 手机拨号 + NativeAbility::GetInstance().EnterSlice(VIEW_PHONECALL); } return true; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/src/MainPhonePresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/phone/src/MainPhonePresenter.cpp index 4cb20db41..82d5792a6 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/src/MainPhonePresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/src/MainPhonePresenter.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-03-28 14:17:43 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-04-29 10:02:49 + * @LastEditTime: 2024-04-29 15:45:54 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/language/src/MainPhonePresenter.cpp */ #include "AppViewIDs.h" @@ -63,13 +63,13 @@ namespace OHOS if (curViewId == DIALINGMETHODBUTTON_VIEWID) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s OnClick",curViewId.c_str()); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s OnClick", curViewId.c_str()); NativeAbility::GetInstance().EnterSlice(VIEW_DIALING_METHOD); } else if (curViewId == FREQUENTLYCONTACTEDBUTTON_VIEWID) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s OnClick",curViewId.c_str()); - + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s OnClick", curViewId.c_str()); + NativeAbility::GetInstance().EnterSlice(VIEW_PHONEDIR); } return true; diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneCallPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneCallPresenter.cpp index 62a93c51c..97447f18a 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneCallPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneCallPresenter.cpp @@ -8,6 +8,9 @@ #include "cat1_server_hal.h" #include "PhoneService.h" #include "phone/include/PhoneCallView.h" +#include "phone/include/TelephonyInitInterface.h" +#include "common/key_code.h" +#include namespace OHOS { @@ -70,7 +73,7 @@ namespace OHOS if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && (event.GetDeltaX() > 20) && (event.GetDeltaX() > (2 * MATH_ABS(event.GetDeltaY())))) { - NativeAbility::GetInstance().ChangeSlice(VIEW_PHONE); + NativeAbility::GetInstance().Back(); } @@ -106,7 +109,18 @@ namespace OHOS // 拨号键 //NativeAbility::GetInstance().ChangeSlice(VIEW_PHONERING); //calldial_event_sendmsg_toUI((char *)phoneNumber.c_str()); - PhoneCallView::GetInstance()->container_child_SetVisible(true); + //PhoneCallView::GetInstance()->container_child_SetVisible(true); + if(TelephonyInitInterface::DIALINGMETHOD == DIALINGMETHOD_USINGWATCHSIM) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DIALINGMETHOD_USINGWATCHSIM"); + calldial_event_sendmsg_toUI((char *)phoneNumber.c_str()); + } + else if(TelephonyInitInterface::DIALINGMETHOD == DIALINGMETHOD_USINGPHONE) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DIALINGMETHOD_USINGPHONE"); + DialCall((unsigned char *)phoneNumber.c_str(),phoneNumber.length()); + } + } else if (strcmp(viewId, BUTTONDEL) == 0) { @@ -184,4 +198,19 @@ namespace OHOS printf("**************************\n"); return true; } + + + bool PhoneCallPresenter::OnKeyAct(UIView &view, const KeyEvent &event) // 增加按键事件 + { + UNUSED(view); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "DialingMethodPresenter::OnKeyAct"); + unsigned short keyID = event.GetKeyId(); + unsigned short keyState = event.GetState(); + // 如果是power键,且是亮屏状态,按键释放就返回上一级 + if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 0 && uapi_get_screen_state() == 0) + { + NativeAbility::GetInstance().Back(); + } + return true; + } } \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneCallView.cpp b/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneCallView.cpp index 772266540..496d085d4 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneCallView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneCallView.cpp @@ -352,6 +352,10 @@ namespace OHOS // GetView(); GetView(); RootView::GetInstance()->Add(container_); + + // 增加按键监听 + RootView::OnKeyActListener *keyactListener = (RootView::OnKeyActListener *)OHOS::PhoneCallPresenter::GetInstance(); + RootView::GetInstance()->SetOnKeyActListener(keyactListener); } void PhoneCallView::OnSetUpView() @@ -372,6 +376,7 @@ namespace OHOS { View::OnStop(); RootView::GetInstance()->RemoveAll(); + RootView::GetInstance()->ClearOnKeyActListener(); return; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneCallingPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneCallingPresenter.cpp index 95a17c77a..af177c3f9 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneCallingPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneCallingPresenter.cpp @@ -75,7 +75,7 @@ namespace OHOS } if (strcmp(view.GetViewId(), PHONEOFFBUTTON) == 0) { - NativeAbility::GetInstance().ChangeSlice(VIEW_PHONE); + NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN_PHONE); } return true; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneCallupPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneCallupPresenter.cpp index 300d68352..e80cae8f9 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneCallupPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneCallupPresenter.cpp @@ -70,7 +70,7 @@ namespace OHOS // 根据控件id查找是哪个控件触发了点击回调 if (strcmp(view.GetViewId(), OFFBUTTON) == 0) { - NativeAbility::GetInstance().ChangeSlice(VIEW_PHONE); + NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN_PHONE); } if (strcmp(view.GetViewId(), "button2") == 0) { diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneDirPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneDirPresenter.cpp index cb616295f..5f6e4f308 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneDirPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneDirPresenter.cpp @@ -7,7 +7,8 @@ #include "phone/include/PhoneDirView.h" #include "components/ui_button.h" #include "components/ui_label_button_ext.h" - +#include "common/key_code.h" +#include namespace OHOS { @@ -68,7 +69,7 @@ namespace OHOS } else { - NativeAbility::GetInstance().ChangeSlice(VIEW_PHONE); + NativeAbility::GetInstance().Back(); } @@ -92,4 +93,19 @@ namespace OHOS // if (strcmp(view.GetViewId(), 控件ID) == 0) return true; } + + + bool PhoneDirPresenter::OnKeyAct(UIView &view, const KeyEvent &event) // 增加按键事件 + { + UNUSED(view); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "DialingMethodPresenter::OnKeyAct"); + unsigned short keyID = event.GetKeyId(); + unsigned short keyState = event.GetState(); + // 如果是power键,且是亮屏状态,按键释放就返回上一级 + if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 0 && uapi_get_screen_state() == 0) + { + NativeAbility::GetInstance().Back(); + } + return true; + } } \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneDirView.cpp b/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneDirView.cpp index 025024b78..e2beaf862 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneDirView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneDirView.cpp @@ -423,6 +423,10 @@ namespace OHOS RootView::GetInstance()->Add(container_); + + // 增加按键监听 + RootView::OnKeyActListener *keyactListener = (RootView::OnKeyActListener *)OHOS::PhoneDirPresenter::GetInstance(); + RootView::GetInstance()->SetOnKeyActListener(keyactListener); } void PhoneDirView::OnSetUpView() @@ -443,6 +447,7 @@ namespace OHOS { View::OnStop(); RootView::GetInstance()->RemoveAll(); + RootView::GetInstance()->ClearOnKeyActListener(); return; } } diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneRingPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneRingPresenter.cpp index 38fdf2d7b..621910d9a 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneRingPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/src/PhoneRingPresenter.cpp @@ -70,7 +70,7 @@ namespace OHOS // 根据控件id查找是哪个控件触发了点击回调 if (strcmp(view.GetViewId(), OFFBUTTON) == 0) { - NativeAbility::GetInstance().ChangeSlice(VIEW_PHONE); + NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN_PHONE); } return true; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/src/TelephonyInitInterface.cpp b/code/sdk/application/wearable/fd230app/nativeui/phone/src/TelephonyInitInterface.cpp index aa04152f2..77e291b74 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/src/TelephonyInitInterface.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/src/TelephonyInitInterface.cpp @@ -3,7 +3,8 @@ namespace OHOS { - bool TelephonyInitInterface::X_DRAG_FLAG = false; // 水平拖拽标志 + bool TelephonyInitInterface::X_DRAG_FLAG = false; // 水平拖拽标志 + uint8_t TelephonyInitInterface::DIALINGMETHOD = -1; // 默认未选择任何拨号方式 TelephonyInitInterface::TelephonyInitInterface() { -- 2.17.1