添加拨号方式Slice 108/2 108/head
authorluozheng <1732036298@qq.com>
Mon, 29 Apr 2024 02:17:06 +0000 (10:17 +0800)
committerluozheng <1732036298@qq.com>
Mon, 29 Apr 2024 02:17:06 +0000 (10:17 +0800)
12 files changed:
code/sdk/application/wearable/fd230app/CMakeLists.txt
code/sdk/application/wearable/fd230app/nativelauncher/include/AppViewIDs.h
code/sdk/application/wearable/fd230app/nativelauncher/include/NativeLauncher.h
code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp
code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistModel.cpp
code/sdk/application/wearable/fd230app/nativeui/phone/include/DialingMethodPresenter.h [new file with mode: 0644]
code/sdk/application/wearable/fd230app/nativeui/phone/include/DialingMethodView.h [new file with mode: 0644]
code/sdk/application/wearable/fd230app/nativeui/phone/include/TelephonyInitInterface.h
code/sdk/application/wearable/fd230app/nativeui/phone/src/DialingMethodPresenter.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230app/nativeui/phone/src/DialingMethodView.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230app/nativeui/phone/src/MainPhonePresenter.cpp
code/sdk/application/wearable/fd230app/nativeui/phone/src/MainPhoneView.cpp

index db7d545..dbbe46a 100644 (file)
@@ -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
index 0cb2d03..46c0234 100644 (file)
@@ -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, // 测试
 /* -------------------------------------------------------------------------- */
index 76f8469..e9657b9 100644 (file)
@@ -97,6 +97,7 @@ namespace OHOS
 
         /* -------------------------------------------------------------------------- */
         void InitMainPhoneSlice(void);
+        void InitDialingMethodSlice(void);
         /* -------------------------------------------------------------------------- */
 
         void InittestSlice(void);
index 2a4b50e..8ce45dd 100644 (file)
 /* -------------------------------------------------------------------------- */
 #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<DialingMethodView, DialingMethodPresenter>;
+        if (dialingmethodview == nullptr)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "dialingmethodview");
+            return;
+        }
+        NativeAbility::GetInstance().AddSliceProxy(VIEW_DIALING_METHOD, dialingmethodview);
+    }
     /* -------------------------------------------------------------------------- */
 
     void NativeLauncher::InittestSlice(void)
index 4ce02bc..9af2962 100644 (file)
@@ -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 (file)
index 0000000..fc64f7d
--- /dev/null
@@ -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<DialingMethodView>,
+                                       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 (file)
index 0000000..65a99f2
--- /dev/null
@@ -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<DialingMethodPresenter>
+    {
+
+    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
index 236b137..76fadc3 100644 (file)
@@ -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
 #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 (file)
index 0000000..6d44a9a
--- /dev/null
@@ -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 <custom_utils.h>
+#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<DialingMethodView>::OnStart();
+    }
+
+    void DialingMethodPresenter::OnPause(void)
+    {
+        Presenter<DialingMethodView>::OnPause();
+    }
+
+    void DialingMethodPresenter::OnResume(void)
+    {
+        Presenter<DialingMethodView>::OnResume();
+    }
+
+    void DialingMethodPresenter::OnStop(void)
+    {
+        Presenter<DialingMethodView>::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<uint16_t>(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 (file)
index 0000000..f2695f7
--- /dev/null
@@ -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<UIView::OnDragListener *>(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<UIView::OnClickListener *>(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<DialingMethodPresenter>::OnStart();
+        DialingMethodViewInit();
+        // 增加按键监听
+        RootView::OnKeyActListener *keyactListener = (RootView::OnKeyActListener *)OHOS::DialingMethodPresenter::GetInstance();
+        RootView::GetInstance()->SetOnKeyActListener(keyactListener);
+    }
+
+    void DialingMethodView::OnSetUpView()
+    {
+        View<DialingMethodPresenter>::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<DialingMethodPresenter>::OnTearDownView();
+        return;
+    }
+
+    void DialingMethodView::OnStop()
+    {
+
+        View<DialingMethodPresenter>::OnStop();
+        RootView::GetInstance()->RemoveAll();
+        RootView::GetInstance()->ClearOnKeyActListener();
+        return;
+    }
+}
\ No newline at end of file
index c64bc5c..4cb20db 100644 (file)
@@ -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<uint16_t>(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;
     }
index 89a0a84..2791bd4 100644 (file)
@@ -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)