From ec89e3b98c1894fde5034c3fb1d1d94e59be4102 Mon Sep 17 00:00:00 2001 From: luozheng <1732036298@qq.com> Date: Mon, 29 Apr 2024 10:17:06 +0800 Subject: [PATCH] =?utf8?q?=E6=B7=BB=E5=8A=A0=E6=8B=A8=E5=8F=B7=E6=96=B9?= =?utf8?q?=E5=BC=8FSlice?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../wearable/fd230app/CMakeLists.txt | 2 + .../nativelauncher/include/AppViewIDs.h | 3 +- .../nativelauncher/include/NativeLauncher.h | 1 + .../nativelauncher/src/NativeLauncher.cpp | 16 ++ .../nativeui/applist/src/ApplistModel.cpp | 2 +- .../phone/include/DialingMethodPresenter.h | 42 ++++ .../phone/include/DialingMethodView.h | 46 ++++ .../phone/include/TelephonyInitInterface.h | 8 +- .../phone/src/DialingMethodPresenter.cpp | 109 +++++++++ .../nativeui/phone/src/DialingMethodView.cpp | 225 ++++++++++++++++++ .../nativeui/phone/src/MainPhonePresenter.cpp | 16 +- .../nativeui/phone/src/MainPhoneView.cpp | 4 +- 12 files changed, 460 insertions(+), 14 deletions(-) create mode 100644 code/sdk/application/wearable/fd230app/nativeui/phone/include/DialingMethodPresenter.h create mode 100644 code/sdk/application/wearable/fd230app/nativeui/phone/include/DialingMethodView.h create mode 100644 code/sdk/application/wearable/fd230app/nativeui/phone/src/DialingMethodPresenter.cpp create mode 100644 code/sdk/application/wearable/fd230app/nativeui/phone/src/DialingMethodView.cpp diff --git a/code/sdk/application/wearable/fd230app/CMakeLists.txt b/code/sdk/application/wearable/fd230app/CMakeLists.txt index db7d54594..dbbe46a20 100644 --- a/code/sdk/application/wearable/fd230app/CMakeLists.txt +++ b/code/sdk/application/wearable/fd230app/CMakeLists.txt @@ -598,6 +598,8 @@ set(SOURCES #电话 ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/phone/src/MainPhonePresenter.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/phone/src/MainPhoneView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/phone/src/DialingMethodPresenter.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/phone/src/DialingMethodView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/phone/src/TelephonyInitInterface.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/producttest/src/testPresenter.cpp diff --git a/code/sdk/application/wearable/fd230app/nativelauncher/include/AppViewIDs.h b/code/sdk/application/wearable/fd230app/nativelauncher/include/AppViewIDs.h index 0cb2d0369..46c023433 100644 --- a/code/sdk/application/wearable/fd230app/nativelauncher/include/AppViewIDs.h +++ b/code/sdk/application/wearable/fd230app/nativelauncher/include/AppViewIDs.h @@ -102,7 +102,8 @@ typedef enum : uint16_t VIEW_PHONECALLUP, // 通话界面 VIEW_PHONEDIR, // 电话簿 - VIEW_MAIN_PHONE, // 主电话Slice + VIEW_MAIN_PHONE, // 主电话Slice + VIEW_DIALING_METHOD, // 拨号方式 VIEW_TEST, // 测试 /* -------------------------------------------------------------------------- */ diff --git a/code/sdk/application/wearable/fd230app/nativelauncher/include/NativeLauncher.h b/code/sdk/application/wearable/fd230app/nativelauncher/include/NativeLauncher.h index 76f8469dd..e9657b937 100644 --- a/code/sdk/application/wearable/fd230app/nativelauncher/include/NativeLauncher.h +++ b/code/sdk/application/wearable/fd230app/nativelauncher/include/NativeLauncher.h @@ -97,6 +97,7 @@ namespace OHOS /* -------------------------------------------------------------------------- */ void InitMainPhoneSlice(void); + void InitDialingMethodSlice(void); /* -------------------------------------------------------------------------- */ void InittestSlice(void); diff --git a/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp b/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp index 2a4b50e9b..8ce45ddb0 100644 --- a/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp +++ b/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp @@ -135,6 +135,8 @@ /* -------------------------------------------------------------------------- */ #include "phone/include/MainPhoneView.h" #include "phone/include/MainPhonePresenter.h" +#include "phone/include/DialingMethodView.h" +#include "phone/include/DialingMethodPresenter.h" /* -------------------------------------------------------------------------- */ #include "producttest/include/testPresenter.h" @@ -288,6 +290,7 @@ namespace OHOS /* -------------------------------------------------------------------------- */ {VIEW_MAIN_PHONE, &NativeLauncher::InitMainPhoneSlice}, + {VIEW_DIALING_METHOD, &NativeLauncher::InitDialingMethodSlice}, /* -------------------------------------------------------------------------- */ {VIEW_TEST, &NativeLauncher::InittestSlice}, @@ -888,6 +891,19 @@ namespace OHOS } NativeAbility::GetInstance().AddSliceProxy(VIEW_MAIN_PHONE, mainphoneview); } + + //拨号方式 + void NativeLauncher::InitDialingMethodSlice(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitMainPhoneSlice"); + SliceProxy *dialingmethodview = new AbilitySliceProxy; + if (dialingmethodview == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "dialingmethodview"); + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_DIALING_METHOD, dialingmethodview); + } /* -------------------------------------------------------------------------- */ void NativeLauncher::InittestSlice(void) diff --git a/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistModel.cpp index 4ce02bcbc..9af296267 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistModel.cpp @@ -33,7 +33,7 @@ namespace OHOS {VIEW_TRAINING_RECORD, PNG_APPLIST_TRAINING_RECORD_IMAGE, PNG_APPLIST_TRAINING_RECORD_IMAGE, "训练记录", nullptr}, {VIEW_RECORD, PNG_APPLIST_RECORD_IMAGE, PNG_APPLIST_RECORD_IMAGE, "录音", nullptr}, {VIEW_CALLER_LOG, PNG_APPLIST_CALLLOG_IMAGE, PNG_APPLIST_CALLLOG_IMAGE, "通话记录", nullptr}, - {VIEW_PHONE, PNG_APPLIST_CALLER_IMAGE, PNG_APPLIST_CALLER_IMAGE, "电话", nullptr}, + {VIEW_MAIN_PHONE, PNG_APPLIST_CALLER_IMAGE, PNG_APPLIST_CALLER_IMAGE, "电话", nullptr}, {VIEW_MAIN_STOPWATCH, PNG_APPLIST_STOPWATCH_IMAGE, PNG_APPLIST_STOPWATCH_IMAGE, "秒表", nullptr}, {VIEW_MAIN_COUNTDOWN, PNG_APPLIST_COUNTDOWN_IMAGE, PNG_APPLIST_COUNTDOWN_IMAGE, "计时器", nullptr}, {VIEW_FIND_PHONE, PNG_APPLIST_FINDPHONE_IMAGE, PNG_APPLIST_FINDPHONE_IMAGE, "查找手机", nullptr}, diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/include/DialingMethodPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/phone/include/DialingMethodPresenter.h new file mode 100644 index 000000000..fc64f7dd4 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/include/DialingMethodPresenter.h @@ -0,0 +1,42 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-04-28 18:22:08 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-04-28 18:33:29 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/phone/include/DialingMethodPresenter.h + */ + +#ifndef DIALING_METHOD_PRESENTER_H +#define DIALING_METHOD_PRESENTER_H + +#include "Presenter.h" +#include "View.h" + +namespace OHOS +{ + class DialingMethodView; + class DialingMethodPresenter : public Presenter, + public UIView::OnClickListener, + public RootView::OnKeyActListener, + public UIView::OnDragListener + { + public: + DialingMethodPresenter(); + virtual ~DialingMethodPresenter(); + + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + + static DialingMethodPresenter *GetInstance(); + + private: + bool OnClick(UIView &view, const ClickEvent &event) override; + bool OnDrag(UIView &view, const DragEvent &event) override; + bool OnDragEnd(UIView &view, const DragEvent &event) override; + bool OnKeyAct(UIView &view, const KeyEvent &event) override; // 增加按键事件 + }; +} + +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/include/DialingMethodView.h b/code/sdk/application/wearable/fd230app/nativeui/phone/include/DialingMethodView.h new file mode 100644 index 000000000..65a99f255 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/include/DialingMethodView.h @@ -0,0 +1,46 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-04-28 18:21:10 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-04-29 09:25:43 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/phone/include/DialingMethodView.h + */ + +#ifndef DIALING_METHOD_VIEW_H +#define DIALING_METHOD_VIEW_H + +#include "BaseView.h" +#include "View.h" +#include "components/ui_view_group.h" +#include "components/ui_scroll_view.h" +#include "components/ui_button.h" +#include "components/ui_label_ext.h" + +namespace OHOS +{ + class DialingMethodPresenter; + class DialingMethodView : public View + { + + public: + DialingMethodView(); + virtual ~DialingMethodView(); + static DialingMethodView *GetInstance(void); + + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStop() override; + + private: + void DialingMethodViewInit(void); + void ClearAll(void); + UIScrollView *DialingMethodScrollView{nullptr}; + UILabelExt *DialingMethodTitleLabel{nullptr}; + UIButton *UsingWatchSimButton{nullptr}; // 手表SIM卡拨号 + UIButton *UsingPhoneButton = nullptr; // 通过手机拨号 + UILabelExt *UsingWatchSimLabel{nullptr}; + UILabelExt *UsingPhoneLabel{nullptr}; + }; +} +#endif \ No newline at end of file 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 236b13788..76fadc395 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-28 16:55:20 + * @LastEditTime: 2024-04-29 09:24:21 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/phone/include/TelephonyInitInterface.h */ #ifndef TELEPHONY_INIT_INTERFACE_H @@ -13,14 +13,18 @@ #include "components/ui_label_ext.h" #include "components/ui_button.h" #include "components/ui_image_view.h" - +#include "iostream" +#include "UiConfig.h" namespace OHOS { // 视图id static constexpr const char *MAINPHONE_VIEWID = "MainPhoneView"; + static constexpr const char *DIALINGMETHODVIEW_VIEWID = "DialingMethodView"; static constexpr const char *DIALINGMETHODBUTTON_VIEWID = "DialingMethodButton"; // 通话方式按钮视图id static constexpr const char *FREQUENTLYCONTACTEDBUTTON_VIEWID = "FrequentlyContactedButton"; // 常用联系人按钮视图id + static constexpr const char *USINGWATCHSIMBUTTON_VIEWID = "UsingWatchSimButton"; // 手表SIM卡拨号按钮视图id + static constexpr const char *USINGPHONEBUTTON_VIEWID = "UsingPhoneButton"; // 通过手机拨号按钮视图id // 图片 static constexpr const char *PNG_DIALINGMETHODBUTTON_IMAGE = "/user/res/Phone/Telephone/DialingMethod.bin"; // 通话方式按钮icon图片 diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/src/DialingMethodPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/phone/src/DialingMethodPresenter.cpp new file mode 100644 index 000000000..6d44a9a6d --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/src/DialingMethodPresenter.cpp @@ -0,0 +1,109 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-03-28 14:17:43 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-04-29 10:01:43 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/language/src/DialingMethodPresenter.cpp + */ +#include "AppViewIDs.h" +#include "NativeAbility.h" +#include "phone/include/DialingMethodView.h" +#include "phone/include/DialingMethodPresenter.h" +#include "common/key_code.h" +#include +#include "phone/include/TelephonyInitInterface.h" +namespace OHOS +{ + + // 当前Presenter属性实例化的内存指针 + static DialingMethodPresenter *g_pDialingMethodPresenter = nullptr; + + DialingMethodPresenter::DialingMethodPresenter() + { + g_pDialingMethodPresenter = this; + } + + DialingMethodPresenter::~DialingMethodPresenter() + { + g_pDialingMethodPresenter = nullptr; + } + + DialingMethodPresenter *DialingMethodPresenter::GetInstance() + { + return g_pDialingMethodPresenter; + } + + void DialingMethodPresenter::OnStart() + { + Presenter::OnStart(); + } + + void DialingMethodPresenter::OnPause(void) + { + Presenter::OnPause(); + } + + void DialingMethodPresenter::OnResume(void) + { + Presenter::OnResume(); + } + + void DialingMethodPresenter::OnStop(void) + { + Presenter::OnStop(); + } + + bool DialingMethodPresenter::OnClick(UIView &view, const ClickEvent &event) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "DialingMethodPresenter::OnClick"); + std::string curViewId = view.GetViewId(); + + if (curViewId == USINGWATCHSIMBUTTON_VIEWID) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s OnClick",curViewId.c_str()); + } + else if (curViewId == USINGPHONEBUTTON_VIEWID) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s OnClick",curViewId.c_str()); + } + return true; + } + + bool DialingMethodPresenter::OnDrag(UIView &view, const DragEvent &event) + { + UNUSED(view); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "DialingMethodPresenter::OnDrag"); + if ((event.GetDeltaX() > X_DRAG_OFFSET) && (event.GetDeltaX() > (DOUBLES * MATH_ABS(event.GetDeltaY())))) // 拖动过程中判断是否是水平滑动 + { + TelephonyInitInterface::X_DRAG_FLAG = true; + } + return true; + } + + bool DialingMethodPresenter::OnDragEnd(UIView &view, const DragEvent &event) + { + UNUSED(view); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "DialingMethodPresenter::OnDragEnd"); + if ((event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) && TelephonyInitInterface::X_DRAG_FLAG) // 拖动结束判断是否是右滑 + { + NativeAbility::GetInstance().Back(); + TelephonyInitInterface::X_DRAG_FLAG = false; + } + + return true; + } + + bool DialingMethodPresenter::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/DialingMethodView.cpp b/code/sdk/application/wearable/fd230app/nativeui/phone/src/DialingMethodView.cpp new file mode 100644 index 000000000..f2695f7d5 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/src/DialingMethodView.cpp @@ -0,0 +1,225 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-04-23 17:28:52 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-04-29 10:00:25 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/motionrecognition/src/DialingMethodView.cpp + */ +#include "phone/include/DialingMethodView.h" +#include "phone/include/DialingMethodPresenter.h" +#include "wearable_log.h" +#include "phone/include/TelephonyInitInterface.h" +namespace OHOS +{ + + static DialingMethodView *g_pDialingMethodView{nullptr}; + + DialingMethodView::DialingMethodView() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DialingMethodView::DialingMethodView"); + g_pDialingMethodView = this; + } + + DialingMethodView::~DialingMethodView() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DialingMethodView::~DialingMethodView"); + ClearAll(); + g_pDialingMethodView = nullptr; + } + + DialingMethodView *DialingMethodView::GetInstance() + { + + return g_pDialingMethodView; + } + + void DialingMethodView::ClearAll(void) + { + if (DialingMethodScrollView != nullptr) + { + DialingMethodScrollView->RemoveAll(); + + delete DialingMethodTitleLabel; + DialingMethodTitleLabel = nullptr; + + delete UsingWatchSimButton; + UsingWatchSimButton = nullptr; + + delete UsingPhoneButton; + UsingPhoneButton = nullptr; + + delete UsingWatchSimLabel; + UsingWatchSimLabel = nullptr; + + delete UsingPhoneLabel; + UsingPhoneLabel = nullptr; + + delete DialingMethodScrollView; + DialingMethodScrollView = nullptr; + } + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DialingMethodView::ClearAll success!!"); + } + + void DialingMethodView::DialingMethodViewInit(void) + { + if (DialingMethodScrollView == nullptr) + { + /* ------------------------- DialingMethodScrollView ------------------------ */ + TelephonyInitInterface::ScrollViewParams scrollviewParam = { + .x = 0, + .y = 0, + .width = Screen::GetInstance().GetWidth(), + .height = Screen::GetInstance().GetHeight(), + .viewId = DIALINGMETHODVIEW_VIEWID, + .scrollBlankSize = 50, + .reboundSize = 35, + .direction = 1, + }; + DialingMethodScrollView = TelephonyInitInterface::ScrollViewInit(scrollviewParam); + if (DialingMethodScrollView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DialingMethodView::DialingMethodScrollView new fail!"); + return; + } + UIView::OnDragListener *dragListener = static_cast(DialingMethodPresenter::GetInstance()); + if (dragListener == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "dragListener new fail!"); + return; + } + DialingMethodScrollView->SetOnDragListener(dragListener); + /* ------------------------- DialingMethodTitleLabel ------------------------ */ + TelephonyInitInterface::LabelParams labelParam = { + .x = 83, + .y = 53, + .width = 300, + .height = 35, + .fontSize = 30, + .lineHeigh = 35, + .text = "拨号方式", + .lineBreakMode = UILabel::LINE_BREAK_MARQUEE, + }; + DialingMethodTitleLabel = TelephonyInitInterface::LabelViewInit(labelParam); + if (DialingMethodTitleLabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainPhoneView::DialingMethodTitleLabel new fail!"); + return; + } + DialingMethodTitleLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + /* --------------------------- UsingWatchSimButton -------------------------- */ + TelephonyInitInterface::ButtonParams buttonParam = { + .x = 43, + .y = 120, + .width = 380, + .height = 100, + .viewId = USINGWATCHSIMBUTTON_VIEWID, + .backgroundColor = 0xff191919, + .pressedBackgroundColor = 0xff1996ff, + }; + UsingWatchSimButton = TelephonyInitInterface::ButtonViewInit(buttonParam); + if (UsingWatchSimButton == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainPhoneView::UsingWatchSimButton new fail!"); + return; + } + /* ------------------------ UsingPhoneButton ----------------------- */ + buttonParam = { + .x = 43, + .y = 240, + .width = 380, + .height = 100, + .viewId = USINGPHONEBUTTON_VIEWID, + .backgroundColor = 0xff191919, + .pressedBackgroundColor = 0xff1996ff, + }; + UsingPhoneButton = TelephonyInitInterface::ButtonViewInit(buttonParam); + if (UsingPhoneButton == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainPhoneView::UsingPhoneButton new fail!"); + return; + } + /* --------------------------- ButtonOnclickListen -------------------------- */ + UIView::OnClickListener *ButtonOnclickListen = static_cast(DialingMethodPresenter::GetInstance()); + if (ButtonOnclickListen == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ButtonOnclickListen new fail!"); + return; + } + UsingWatchSimButton->SetOnClickListener(ButtonOnclickListen); + UsingPhoneButton->SetOnClickListener(ButtonOnclickListen); + /* --------------------------- UsingWatchSimLabel --------------------------- */ + labelParam = { + .x = 83, + .y = 153, + .width = 300, + .height = 35, + .fontSize = 30, + .lineHeigh = 35, + .text = "通过手表SIM卡拨号", + .lineBreakMode = UILabel::LINE_BREAK_MARQUEE, + }; + UsingWatchSimLabel = TelephonyInitInterface::LabelViewInit(labelParam); + if (UsingWatchSimLabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainPhoneView::UsingWatchSimLabel new fail!"); + return; + } + UsingWatchSimLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + /* --------------------------- UsingPhoneLabel --------------------------- */ + labelParam = { + .x = 83, + .y = 273, + .width = 300, + .height = 35, + .fontSize = 30, + .lineHeigh = 35, + .text = "通过手机拨号", + .lineBreakMode = UILabel::LINE_BREAK_MARQUEE, + }; + UsingPhoneLabel = TelephonyInitInterface::LabelViewInit(labelParam); + if (UsingPhoneLabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainPhoneView::UsingPhoneLabel new fail!"); + return; + } + UsingPhoneLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + } + } + + void DialingMethodView::OnStart() + { + View::OnStart(); + DialingMethodViewInit(); + // 增加按键监听 + RootView::OnKeyActListener *keyactListener = (RootView::OnKeyActListener *)OHOS::DialingMethodPresenter::GetInstance(); + RootView::GetInstance()->SetOnKeyActListener(keyactListener); + } + + void DialingMethodView::OnSetUpView() + { + View::OnSetUpView(); + DialingMethodScrollView->Add(DialingMethodTitleLabel); + DialingMethodScrollView->Add(UsingWatchSimButton); + DialingMethodScrollView->Add(UsingPhoneButton); + DialingMethodScrollView->Add(UsingWatchSimLabel); + DialingMethodScrollView->Add(UsingPhoneLabel); + RootView::GetInstance()->Add(DialingMethodScrollView); + Draw(); + } + + void DialingMethodView::OnTearDownView() + { + + View::OnTearDownView(); + return; + } + + void DialingMethodView::OnStop() + { + + View::OnStop(); + RootView::GetInstance()->RemoveAll(); + RootView::GetInstance()->ClearOnKeyActListener(); + return; + } +} \ No newline at end of file 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 c64bc5c43..4cb20db41 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-28 16:54:51 + * @LastEditTime: 2024-04-29 10:02:49 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/language/src/MainPhonePresenter.cpp */ #include "AppViewIDs.h" @@ -63,11 +63,13 @@ namespace OHOS if (curViewId == DIALINGMETHODBUTTON_VIEWID) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DIALINGMETHODBUTTON_VIEWID OnClick"); + 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, "FREQUENTLYCONTACTEDBUTTON_VIEWID OnClick"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s OnClick",curViewId.c_str()); + } return true; @@ -77,8 +79,7 @@ namespace OHOS { UNUSED(view); WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainPhonePresenter::OnDrag"); - if ((event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) && - (event.GetDeltaX() > X_DRAG_OFFSET) && (event.GetDeltaX() > (DOUBLES * MATH_ABS(event.GetDeltaY())))) + if ((event.GetDeltaX() > X_DRAG_OFFSET) && (event.GetDeltaX() > (DOUBLES * MATH_ABS(event.GetDeltaY())))) // 拖动过程中判断是否是水平滑动 { TelephonyInitInterface::X_DRAG_FLAG = true; } @@ -89,7 +90,7 @@ namespace OHOS { UNUSED(view); WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainPhonePresenter::OnDragEnd"); - if (TelephonyInitInterface::X_DRAG_FLAG) + if ((event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) && TelephonyInitInterface::X_DRAG_FLAG) // 拖动结束判断是否是右滑 { NativeAbility::GetInstance().Back(); TelephonyInitInterface::X_DRAG_FLAG = false; @@ -107,8 +108,7 @@ namespace OHOS // 如果是power键,且是亮屏状态,按键释放就返回上一级 if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 0 && uapi_get_screen_state() == 0) { - uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId(); - NativeAbility::GetInstance().ChangeSlice(preSlice); + NativeAbility::GetInstance().Back(); } return true; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/src/MainPhoneView.cpp b/code/sdk/application/wearable/fd230app/nativeui/phone/src/MainPhoneView.cpp index 89a0a84f6..2791bd475 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/src/MainPhoneView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/src/MainPhoneView.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-04-28 10:09:51 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-04-28 15:58:43 + * @LastEditTime: 2024-04-29 10:08:42 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/phone/src/MainPhoneView.cpp */ #include "phone/include/MainPhoneView.h" @@ -34,7 +34,6 @@ namespace OHOS void MainPhoneView::ClearAll(void) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainPhoneView::ClearAll"); if (MainPhoneViewScrollView != nullptr) { MainPhoneViewScrollView->RemoveAll(); @@ -60,6 +59,7 @@ namespace OHOS delete MainPhoneViewScrollView; MainPhoneViewScrollView = nullptr; } + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainPhoneView::ClearAll success!!"); } void MainPhoneView::MainPhoneViewInit(void) -- 2.17.1