【4G】UI 1732/1 1732/head 1733/target/1 1734/target/1
authormaomao <2144439972@qq.com>
Thu, 24 Apr 2025 07:21:05 +0000 (15:21 +0800)
committermaomao <2144439972@qq.com>
Thu, 24 Apr 2025 07:21:05 +0000 (15:21 +0800)
code/sdk/application/wearable/fd230/nativeapp/nativeui/networkandcall/include/MobileDataOptionsView.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/networkandcall/include/NetworkAndCallC.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/networkandcall/include/NetworkAndCallPresenter.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/networkandcall/include/NetworkAndCallView.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/networkandcall/src/MobileDataOptionsView.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/networkandcall/src/NetworkAndCallPresenter.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/networkandcall/src/NetworkAndCallView.cpp [new file with mode: 0644]
code/sdk/zhihui/config/src/ConfigModel.cpp

diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/networkandcall/include/MobileDataOptionsView.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/networkandcall/include/MobileDataOptionsView.h
new file mode 100644 (file)
index 0000000..691af5a
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * @Author: luozheng 1732036298@qq.com
+ * @Date: 2024-04-23 15:29:51
+ * @LastEditors: luozheng 1732036298@qq.com
+ * @LastEditTime: 2024-04-23 16:25:18
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/networkandcall/include/MobileDataOptionsView.h
+ */
+
+#ifndef MOBILE_DATA_OPTIONS_VIEW_H
+#define MOBILE_DATA_OPTIONS_VIEW_H
+
+#include "components/ui_toggle_button.h"
+#include "components/ui_scroll_view.h"
+#include "components/ui_label_ext.h"
+
+namespace OHOS
+{
+    static constexpr const char *MOBILEDATAOPTIONSVIEWID = "mobiledataoptionsview";
+    class MobileDataOptionsView
+    {
+    public:
+        MobileDataOptionsView();
+        virtual ~MobileDataOptionsView();
+        static MobileDataOptionsView *GetInstance(void);
+        UIScrollView *MobileDataOptionsViewInit(void);
+        UIToggleButton *GetSystemUpdateToggleButton(void);
+        UIToggleButton *GetOnlineMusicToggleButton(void);
+
+    private:
+        void ClearAll(void);
+        UIScrollView *scrollView{nullptr};
+        UILabelExt *Title{nullptr};
+        UIImageView *MobileDataOptionsImage[2]{nullptr};
+        UILabelExt *MobileDataOptionsImageLabel[2]{nullptr};
+        UIToggleButton *SystemUpdateToggleButton{nullptr}; // 系统更新开关:开启系统更新时闲时将安装包下载到本地并添加小红点提示
+        UIToggleButton *OnlineMusicToggleButton{nullptr};  // 在线音乐开关
+    };
+}
+#endif
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/networkandcall/include/NetworkAndCallC.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/networkandcall/include/NetworkAndCallC.h
new file mode 100644 (file)
index 0000000..b9778fe
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * @Author: luozheng 1732036298@qq.com
+ * @Date: 2024-04-24 10:25:39
+ * @LastEditors: luozheng 1732036298@qq.com
+ * @LastEditTime: 2024-04-24 10:46:13
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/networkandcall/include/NetworkAndCallC.h
+ */
+#ifndef NETWORKANDCALLC_H
+#define NETWORKANDCALLC_H
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C"
+{
+#endif
+#endif
+#include <stdint.h>
+#include <stdbool.h>
+
+    void power_on_cat1(void);
+    void power_off_cat1(void);
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif
+#endif
+#endif
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/networkandcall/include/NetworkAndCallPresenter.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/networkandcall/include/NetworkAndCallPresenter.h
new file mode 100644 (file)
index 0000000..2524b1e
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * @Author: luozheng 1732036298@qq.com
+ * @Date: 2024-04-23 09:59:18
+ * @LastEditors: luozheng 1732036298@qq.com
+ * @LastEditTime: 2024-04-23 14:44:56
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/networkandcall/include/NetworkAndCallPresenter.h
+ */
+
+#ifndef NETWORK_AND_CALL_PRESENTER_H
+#define NETWORK_AND_CALL_PRESENTER_H
+
+#include "Presenter.h"
+#include "View.h"
+
+namespace OHOS
+{
+    class NetworkAndCallView;
+    class NetworkAndCallPresenter : public Presenter<NetworkAndCallView>,
+                                    public UIView::OnClickListener,
+                                    public RootView::OnKeyActListener,
+                                    public UIView::OnDragListener
+    {
+    public:
+        NetworkAndCallPresenter();
+        virtual ~NetworkAndCallPresenter();
+
+        void OnStart() override;
+        void OnPause() override;
+        void OnResume() override;
+        void OnStop() override;
+
+        static NetworkAndCallPresenter *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/fd230/nativeapp/nativeui/networkandcall/include/NetworkAndCallView.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/networkandcall/include/NetworkAndCallView.h
new file mode 100644 (file)
index 0000000..8c47fd7
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ * @Author: luozheng 1732036298@qq.com
+ * @Date: 2024-04-23 09:57:53
+ * @LastEditors: luozheng 1732036298@qq.com
+ * @LastEditTime: 2024-09-14 14:30:20
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/networkandcall/include/NetworkAndCallView.h
+ */
+
+#ifndef NETWORK_AND_CALL_VIEW_H
+#define NETWORK_AND_CALL_VIEW_H
+
+//#include "BaseView.h"
+#include "View.h"
+#include "components/ui_label_ext.h"
+#include "components/ui_image_view.h"
+#include "components/ui_toggle_button.h"
+#include "components/ui_scroll_view.h"
+#include "networkandcall/include/MobileDataOptionsView.h"
+
+namespace OHOS
+{
+    typedef enum
+    {
+        NETWORKANDCALLVIEW = 0,
+        MOBILEDATAOPTIONSVIEW,
+        MAX_NETWORKANDCALLVIEWID,
+    } NETWORKANDCALLVIEWID;
+
+#if defined(SUPPORT_CHINA_MOBILE_DMP)
+    static constexpr const uint8_t ITEM_NUM = 2;
+#else
+    static constexpr const uint8_t ITEM_NUM = 1;
+#endif
+
+    class NetworkAndCallPresenter;
+    class NetworkAndCallView : public View<NetworkAndCallPresenter>
+    {
+
+    public:
+        NetworkAndCallView();
+        virtual ~NetworkAndCallView();
+        static NetworkAndCallView *GetInstance(void);
+        UIToggleButton *GetVoLTEToggleButton(void);
+        UIToggleButton *GetMobileDataToggleButton(void);
+        UIImageView *GetNetworkAndCallImage(int index);
+        MobileDataOptionsView *GetMobileDataOptionsView(void);
+        bool ChangeNetworkAndCallView(int16_t thisView);
+        bool ChangeMobileDataOptionsView(int16_t thisView);
+        bool ClickFunc(int16_t interface);
+        void ChangeView(int16_t hideView, int16_t showView);
+
+        void OnStart() override;
+
+
+    private:
+        MobileDataOptionsView *mobileDataOptionsView{nullptr};
+
+    private:
+        void NetworkAndCallViewInit(void);
+        void ClearAll(void);
+
+        UIScrollView *NetworkAndCallScrollView[MAX_NETWORKANDCALLVIEWID]{nullptr};
+        UILabelExt *Title{nullptr};
+        UIImageView *NetworkAndCallImage[ITEM_NUM]{nullptr};
+        UILabelExt *NetworkAndCallLabel[ITEM_NUM]{nullptr};
+        UIToggleButton *VoLTE_toggleButton{nullptr};      // VoLTE通话开关
+        UIToggleButton *MobileData_toggleButton{nullptr}; // 移动数据开关
+        UILabelExt *note{nullptr};
+        // UIImageView *NextImage{nullptr};
+    };
+}
+#endif
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/networkandcall/src/MobileDataOptionsView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/networkandcall/src/MobileDataOptionsView.cpp
new file mode 100644 (file)
index 0000000..5e977b8
--- /dev/null
@@ -0,0 +1,173 @@
+#include "networkandcall/include/MobileDataOptionsView.h"
+#include "networkandcall/include/NetworkAndCallPresenter.h"
+#include "wearable_log.h"
+#include "ui_resource_string.h"
+
+namespace OHOS
+{
+    static MobileDataOptionsView *g_pMobileDataOptionsView{nullptr};
+    MobileDataOptionsView::MobileDataOptionsView()
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MobileDataOptionsView::MobileDataOptionsView");
+        g_pMobileDataOptionsView = this;
+    }
+
+    MobileDataOptionsView::~MobileDataOptionsView()
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MobileDataOptionsView::~MobileDataOptionsView");
+        ClearAll();
+        g_pMobileDataOptionsView = nullptr;
+    }
+
+    MobileDataOptionsView *MobileDataOptionsView::GetInstance(void)
+    {
+        return g_pMobileDataOptionsView;
+    }
+
+    UIScrollView *MobileDataOptionsView::MobileDataOptionsViewInit(void)
+    {
+        if (scrollView == nullptr)
+        {
+            scrollView = new UIScrollView();
+            if (scrollView == nullptr)
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "LanguageSwitchView::scrollView new fail!");
+                return nullptr;
+            }
+            scrollView->SetPosition(0, 0, 466, 466);
+            scrollView->SetViewId(MOBILEDATAOPTIONSVIEWID);
+            UIView::OnDragListener *draglistener = static_cast<UIView::OnDragListener *>(NetworkAndCallPresenter::GetInstance());
+            if (draglistener == nullptr)
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "LanguageSwitchView::draglistener can not be nullptr!");
+                return nullptr;
+            }
+            scrollView->SetOnDragListener(draglistener);
+            scrollView->SetScrollBlankSize(50);
+            scrollView->SetReboundSize(35);
+            scrollView->SetHorizontalScrollState(false);
+            scrollView->SetTouchable(true);
+            scrollView->SetDraggable(true);
+            /* ---------------------------------- Title --------------------------------- */
+            Title = new UILabelExt();
+            if (Title == nullptr)
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "LanguageSwitchView::Title is nullptr!");
+                return nullptr;
+            }
+            Title->SetPosition(83, 50, 300, 40);
+            Title->SetStyle(STYLE_TEXT_FONT, 30);
+            Title->SetStyle(STYLE_LINE_HEIGHT, 35);
+            //Title->SetText("移动数据选项");
+            Title->SetTextId(STR_MOBILE_DATA_OPTION);
+            Title->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE);
+            Title->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+            //Title->SetRollSpeed(40);
+            Title->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
+            scrollView->Add(Title);
+            /* -------------------------------------------------------------------------- */
+            int positionY_Img = 120;
+            //const char *text[] = {"系统更新", "在线音乐"};
+            const UIResourceTextId textId[] = {STR_SYSTEM_UPDATE, STR_ONLINE_MUSIC};
+            for (int i = 0; i < 2; i++)
+            {
+                MobileDataOptionsImage[i] = new UIImageView(); // Create a new UIImageView for each iteration
+                if (MobileDataOptionsImage[i] == nullptr)
+                {
+                    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "LanguageSwitchView::MobileDataOptionsImage[%d] is nullptr!", i);
+                    return nullptr; 
+                }
+                MobileDataOptionsImage[i]->SetPosition(43, positionY_Img + (i * 120), 380, 100); // Adjust Y position based on iteration
+                MobileDataOptionsImage[i]->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);
+                MobileDataOptionsImage[i]->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
+                MobileDataOptionsImage[i]->SetStyle(STYLE_BORDER_RADIUS, 100);
+                scrollView->Add(MobileDataOptionsImage[i]);
+                /* -------------------------------------------------------------------------- */
+                MobileDataOptionsImageLabel[i] = new UILabelExt(); // Create a new UILabel for each iteration
+                if (MobileDataOptionsImageLabel[i] == nullptr)
+                {
+                    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "LanguageSwitchView::MobileDataOptionsImageLabel[%d] is nullptr!", i);
+                    return nullptr;
+                }
+                MobileDataOptionsImageLabel[i]->SetPosition(90, 153 + (i * 120), 180, 40); // Adjust Y position based on iteration
+                MobileDataOptionsImageLabel[i]->SetStyle(STYLE_TEXT_FONT, 30);
+                MobileDataOptionsImageLabel[i]->SetStyle(STYLE_LINE_HEIGHT, 35);
+                //MobileDataOptionsImageLabel[i]->SetText(text[i]);
+                MobileDataOptionsImageLabel[i]->SetTextId(textId[i]);
+                MobileDataOptionsImageLabel[i]->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE);
+                //MobileDataOptionsImageLabel[i]->SetRollSpeed(40);
+                MobileDataOptionsImageLabel[i]->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
+                scrollView->Add(MobileDataOptionsImageLabel[i]);
+            }
+            /* -------------------------------------------------------------------------- */
+            SystemUpdateToggleButton = new UIToggleButton();
+            if (SystemUpdateToggleButton == nullptr)
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "LanguageSwitchView::SystemUpdateToggleButton is nullptr!");
+                return nullptr;
+            }
+            SystemUpdateToggleButton->SetPosition(298, 145, 100, 50);
+            SystemUpdateToggleButton->SetStyle(STYLE_BACKGROUND_OPA, 0x00);
+            const char *selectedImg = "/user/res/TOGGLEBUTTON_ON.bin";
+            const char *unSelectedImg = "/user/res/TOGGLEBUTTON_OFF.bin";
+            SystemUpdateToggleButton->SetImages(selectedImg, unSelectedImg);
+            scrollView->Add(SystemUpdateToggleButton);
+            /* -------------------------------------------------------------------------- */
+            OnlineMusicToggleButton = new UIToggleButton();
+            if (OnlineMusicToggleButton == nullptr)
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "LanguageSwitchView::OnlineMusicToggleButton is nullptr!");
+                return nullptr;
+            }
+            OnlineMusicToggleButton->SetPosition(298, 265, 100, 50);
+            OnlineMusicToggleButton->SetStyle(STYLE_BACKGROUND_OPA, 0x00);
+            OnlineMusicToggleButton->SetImages(selectedImg, unSelectedImg);
+            scrollView->Add(OnlineMusicToggleButton);
+            /* ----------------------------- onclickListener ---------------------------- */
+            UIView::OnClickListener *toggleButtonClick = static_cast<UIView::OnClickListener *>(NetworkAndCallPresenter::GetInstance());
+            SystemUpdateToggleButton->SetOnClickListener(toggleButtonClick);
+            OnlineMusicToggleButton->SetOnClickListener(toggleButtonClick);
+        }
+        return scrollView;
+    }
+
+    void MobileDataOptionsView::ClearAll(void)
+    {
+        if (scrollView != nullptr)
+        {
+            scrollView->RemoveAll();
+
+            delete Title;
+            Title = nullptr;
+
+            for (int i = 0; i < 2; i++)
+            {
+                delete MobileDataOptionsImage[i];
+                MobileDataOptionsImage[i] = nullptr;
+
+                delete MobileDataOptionsImageLabel[i];
+                MobileDataOptionsImageLabel[i] = nullptr;
+            }
+
+            delete SystemUpdateToggleButton;
+            SystemUpdateToggleButton = nullptr;
+
+            delete OnlineMusicToggleButton;
+            OnlineMusicToggleButton = nullptr;
+
+            delete scrollView;
+            scrollView = nullptr;
+        }
+    }
+
+    UIToggleButton *MobileDataOptionsView::GetSystemUpdateToggleButton(void)
+    {
+        return SystemUpdateToggleButton;
+    }
+    
+    UIToggleButton *MobileDataOptionsView::GetOnlineMusicToggleButton(void)
+    {
+        return OnlineMusicToggleButton;
+    }
+
+}
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/networkandcall/src/NetworkAndCallPresenter.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/networkandcall/src/NetworkAndCallPresenter.cpp
new file mode 100644 (file)
index 0000000..bff252e
--- /dev/null
@@ -0,0 +1,194 @@
+/*
+ * @Author: luozheng 1732036298@qq.com
+ * @Date: 2024-04-23 09:59:32
+ * @LastEditors: luozheng 1732036298@qq.com
+ * @LastEditTime: 2024-11-05 14:25:03
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/networkandcall/src/NetworkAndCallPresenter.cpp
+ */
+#include "AppViewIDs.h"
+#include "NativeAbility.h"
+#include "networkandcall/include/NetworkAndCallPresenter.h"
+#include "common/key_code.h"
+#include <custom_utils.h>
+#include "networkandcall/include/NetworkAndCallView.h"
+#include "map"
+#include "functional"
+#include "iostream"
+#include "ConfigModel.h"
+#include "networkandcall/include/NetworkAndCallC.h"
+#include "cat1_ctl.h"
+#include "NativeRegisterManager.h"
+namespace OHOS
+{
+
+    REGIST_SLICE(VIEW_NETWORKANDCALL, NetworkAndCallView, NetworkAndCallPresenter);
+    // 当前Presenter属性实例化的内存指针
+    static NetworkAndCallPresenter *g_pNetworkAndCallPresenter = nullptr;
+
+    NetworkAndCallPresenter::NetworkAndCallPresenter()
+    {
+        g_pNetworkAndCallPresenter = this;
+    }
+
+    NetworkAndCallPresenter::~NetworkAndCallPresenter()
+    {
+        g_pNetworkAndCallPresenter = nullptr;
+    }
+
+    NetworkAndCallPresenter *NetworkAndCallPresenter::GetInstance()
+    {
+        return g_pNetworkAndCallPresenter;
+    }
+
+    void NetworkAndCallPresenter::OnStart()
+    {
+        Presenter<NetworkAndCallView>::OnStart();
+    }
+
+    void NetworkAndCallPresenter::OnPause(void)
+    {
+        Presenter<NetworkAndCallView>::OnPause();
+    }
+
+    void NetworkAndCallPresenter::OnResume(void)
+    {
+        Presenter<NetworkAndCallView>::OnResume();
+    }
+
+    void NetworkAndCallPresenter::OnStop(void)
+    {
+        Presenter<NetworkAndCallView>::OnStop();
+    }
+
+    bool NetworkAndCallPresenter::OnClick(UIView &view, const ClickEvent &event)
+    {
+        UNUSED(event);
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NetworkAndCallPresenter::OnClick");
+        NetworkAndCallView *p_NetworkAndCallView = NetworkAndCallView::GetInstance();
+        if (p_NetworkAndCallView == nullptr)
+        {
+            WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NetworkAndCallView::GetInstance fail!!");
+            return false;
+        }
+
+        std::map<UIView *, std::string> buttonMap = {
+            {p_NetworkAndCallView->GetMobileDataToggleButton(), "4GCapability"},
+            {p_NetworkAndCallView->GetVoLTEToggleButton(), "VoLTE"},
+            {p_NetworkAndCallView->GetMobileDataOptionsView()->GetSystemUpdateToggleButton(), "SystemUpdate"},
+            {p_NetworkAndCallView->GetMobileDataOptionsView()->GetOnlineMusicToggleButton(), "OnlineMusic"}};
+
+        auto it = buttonMap.find(&view);
+        if (it != buttonMap.end())
+        {
+            UIToggleButton *toggleButton = dynamic_cast<UIToggleButton *>(&view);
+            if (toggleButton != nullptr)
+            {
+                if (toggleButton->GetState() == true)
+                {
+                    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "%s is enable!", it->second.c_str());
+                    if (it->second == "VoLTE" && p_NetworkAndCallView->GetMobileDataToggleButton()->GetState() == true)
+                    {
+                        ConfigModel::GetInstance()->SetVoLTE_Call(true);
+
+                    }
+                    else if (it->second == "4GCapability")
+                    {
+                        uapi_set4GCapability(true);
+                        #ifdef FD230_650
+                        ConfigModel::GetInstance()->SetCat1_4Gability(uapi_cat1_get_power_stat());
+                        #endif
+                        if(p_NetworkAndCallView->GetVoLTEToggleButton())
+                        {
+                            p_NetworkAndCallView->GetVoLTEToggleButton()->SetTouchable(true);
+                        }
+                    }
+                }
+                else
+                {
+                    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "%s is disable!", it->second.c_str());
+                    if (it->second == "VoLTE" && p_NetworkAndCallView->GetMobileDataToggleButton()->GetState() == true)
+                    {
+                        ConfigModel::GetInstance()->SetVoLTE_Call(false);
+                    }
+                    else if (it->second == "4GCapability")
+                    {
+                        #if defined(A5133_DEMO_CLIENT) || defined(A5133_DEMO_SERVER)
+                        uapi_set4GCapability(true);
+                        #else
+                        uapi_set4GCapability(false);
+                        #endif
+                        #ifdef FD230_650
+                        ConfigModel::GetInstance()->SetCat1_4Gability(uapi_cat1_get_power_stat());
+                        #endif
+                        if(p_NetworkAndCallView->GetVoLTEToggleButton() && p_NetworkAndCallView->GetVoLTEToggleButton()->GetState())
+                        {
+                            p_NetworkAndCallView->GetVoLTEToggleButton()->SetState(false);
+                            p_NetworkAndCallView->GetVoLTEToggleButton()->SetTouchable(false);
+                        }
+                    }
+                }
+            }
+            return true;
+        }
+
+        if (&view == p_NetworkAndCallView->GetNetworkAndCallImage(2) && p_NetworkAndCallView->GetMobileDataToggleButton()->GetState() == true)
+        {
+            p_NetworkAndCallView->ChangeView(NETWORKANDCALLVIEW, MOBILEDATAOPTIONSVIEW);
+            return true;
+        }
+
+        return false;
+    }
+
+    bool NetworkAndCallPresenter::OnDrag(UIView &view, const DragEvent &event)
+    {
+        UNUSED(view);
+        UNUSED(event);
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NetworkAndCallPresenter::OnDrag");
+        return true;
+    }
+
+    bool NetworkAndCallPresenter::OnDragEnd(UIView &view, const DragEvent &event)
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NetworkAndCallPresenter::OnDragEnd");
+        if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT)
+        {
+            if (strcmp(view.GetViewId(), MOBILEDATAOPTIONSVIEWID) == 0)
+            {
+                NetworkAndCallView::GetInstance()->ChangeView(MOBILEDATAOPTIONSVIEW, NETWORKANDCALLVIEW);
+            }
+            else
+            {
+                NativeAbility::GetInstance().Back();
+            }
+        }
+        return true;
+    }
+    bool NetworkAndCallPresenter::OnKeyAct(UIView &view, const KeyEvent &event) // 增加按键事件
+    {
+        UNUSED(view);
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NetworkAndCallPresenter::OnKeyAct");
+        uint16_t keyID = event.GetKeyId();
+        uint16_t keyState = event.GetState();
+        // 如果是power键,且是亮屏状态,按键释放就返回上一级
+        if (keyID == static_cast<uint16_t>(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 1 && uapi_get_screen_state() == 0)
+        {
+            NativeAbility::GetInstance().Back();
+        }
+        return true;
+    }
+}
+#ifdef __cplusplus
+#if __cplusplus
+extern "C"
+{
+#endif /* __cplusplus */
+#endif /* __cplusplus */
+
+    
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cplusplus */
+#endif /* __cplusplus */
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/networkandcall/src/NetworkAndCallView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/networkandcall/src/NetworkAndCallView.cpp
new file mode 100644 (file)
index 0000000..18d3b50
--- /dev/null
@@ -0,0 +1,327 @@
+#include "networkandcall/include/NetworkAndCallPresenter.h"
+#include "networkandcall/include/NetworkAndCallView.h"
+#include "wearable_log.h"
+#include "UiConfig.h"
+#include "ConfigModel.h"
+#include "cat1_ctl.h"
+#include "ui_resource_string.h"
+namespace OHOS
+{
+
+    static NetworkAndCallView *g_pNetworkAndCallView{nullptr};
+
+    NetworkAndCallView::NetworkAndCallView()
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NetworkAndCallView::NetworkAndCallView");
+
+        g_pNetworkAndCallView = this;
+    }
+
+    NetworkAndCallView::~NetworkAndCallView()
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NetworkAndCallView::~NetworkAndCallView");
+        ClearAll();
+        g_pNetworkAndCallView = nullptr;
+    }
+
+    NetworkAndCallView *NetworkAndCallView::GetInstance()
+    {
+        return g_pNetworkAndCallView;
+    }
+
+    void NetworkAndCallView::ClearAll(void)
+    {
+        if (NetworkAndCallScrollView[NETWORKANDCALLVIEW] != nullptr)
+        {
+            NetworkAndCallScrollView[NETWORKANDCALLVIEW]->RemoveAll();
+
+            if (Title != nullptr)
+            {
+                delete Title;
+                Title = nullptr;
+            }
+
+            for (int i = 0; i < ITEM_NUM; i++)
+            {
+                delete NetworkAndCallImage[i];
+                NetworkAndCallImage[i] = nullptr;
+
+                delete NetworkAndCallLabel[i];
+                NetworkAndCallLabel[i] = nullptr;
+            }
+
+            if (VoLTE_toggleButton != nullptr)
+            {
+                delete VoLTE_toggleButton;
+                VoLTE_toggleButton = nullptr;
+            }
+
+            if (MobileData_toggleButton != nullptr)
+            {
+                delete MobileData_toggleButton;
+                MobileData_toggleButton = nullptr;
+            }
+
+            if (note != nullptr)
+            {
+                delete note;
+                note = nullptr;
+            }
+
+            delete NetworkAndCallScrollView[NETWORKANDCALLVIEW];
+            NetworkAndCallScrollView[NETWORKANDCALLVIEW] = nullptr;
+        }
+    }
+
+    void NetworkAndCallView::NetworkAndCallViewInit(void)
+    {
+        if (NetworkAndCallScrollView[NETWORKANDCALLVIEW] == nullptr)
+        {
+            NetworkAndCallScrollView[NETWORKANDCALLVIEW] = new UIScrollView();
+            if (NetworkAndCallScrollView[NETWORKANDCALLVIEW] == nullptr)
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "LanguageSwitchView::NetworkAndCallScrollView[NETWORKANDCALLVIEW] new fail!");
+                return;
+            }
+            NetworkAndCallScrollView[NETWORKANDCALLVIEW]->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()-30);
+            NetworkAndCallScrollView[NETWORKANDCALLVIEW]->SetOnDragListener(presenter_);
+            NetworkAndCallScrollView[NETWORKANDCALLVIEW]->SetReboundSize(35);
+            NetworkAndCallScrollView[NETWORKANDCALLVIEW]->SetScrollBlankSize(30);
+            // NetworkAndCallScrollView[NETWORKANDCALLVIEW]->SetHorizontalScrollState(false);
+            NetworkAndCallScrollView[NETWORKANDCALLVIEW]->SetTouchable(true);
+            NetworkAndCallScrollView[NETWORKANDCALLVIEW]->SetDraggable(true);
+            /* ---------------------------------- Title --------------------------------- */
+            Title = new UILabelExt();
+            if (Title == nullptr)
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "LanguageSwitchView::Title is nullptr!");
+                return;
+            }
+            Title->SetPosition(83, 50, 300, 40);
+            Title->SetStyle(STYLE_TEXT_FONT, 30);
+            Title->SetStyle(STYLE_LINE_HEIGHT, 35);
+            Title->SetTextId(STR_NETWORKANDCALL); // 网络与通话
+            Title->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION);
+            Title->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+            Title->SetRollSpeed(23);
+            Title->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
+            /* -------------------------------------------------------------------------- */
+            int positionY_Img = 120;
+            // const char *text[] = {"4G能力", "VoLTE 通话", "移动数据选项"};
+            const UIResourceTextId textId[] = {STR_4G_CAPABILITY, STR_VOLTE_CALL, STR_MOBILE_DATA_OPTION};
+            for (int i = 0; i < ITEM_NUM; i++)
+            {
+                NetworkAndCallImage[i] = new UIImageView(); // Create a new UIImageView for each iteration
+                if (NetworkAndCallImage[i] == nullptr)
+                {
+                    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "LanguageSwitchView::NetworkAndCallImage[%d] is nullptr!", i);
+                    return;
+                }
+                NetworkAndCallImage[i]->SetPosition(43, positionY_Img + (i * 120), 380, 100); // Adjust Y position based on iteration
+                NetworkAndCallImage[i]->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);
+                NetworkAndCallImage[i]->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
+                NetworkAndCallImage[i]->SetStyle(STYLE_BORDER_RADIUS, 100);
+                /* -------------------------------------------------------------------------- */
+                NetworkAndCallLabel[i] = new UILabelExt(); // Create a new UILabel for each iteration
+                if (NetworkAndCallLabel[i] == nullptr)
+                {
+                    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "LanguageSwitchView::NetworkAndCallLabel[%d] is nullptr!", i);
+                    return;
+                }
+                NetworkAndCallLabel[i]->SetPosition(90, 153 + (i * 120), 180, 40); // Adjust Y position based on iteration
+                NetworkAndCallLabel[i]->SetStyle(STYLE_TEXT_FONT, 30);
+                NetworkAndCallLabel[i]->SetStyle(STYLE_LINE_HEIGHT, 35);
+                NetworkAndCallLabel[i]->SetTextId(textId[i]);
+                NetworkAndCallLabel[i]->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION);
+                NetworkAndCallLabel[i]->SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_CENTER);
+                NetworkAndCallLabel[i]->SetRollSpeed(23);
+                NetworkAndCallLabel[i]->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
+            }
+            /* -------------------------------------------------------------------------- */
+#if defined(SUPPORT_CHINA_MOBILE_DMP)
+            if (VoLTE_toggleButton == nullptr)
+            {
+                VoLTE_toggleButton = new UIToggleButton();
+                if (VoLTE_toggleButton == nullptr)
+                {
+                    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "LanguageSwitchView::VoLTE_toggleButton is nullptr!");
+                    return;
+                }
+            }
+            VoLTE_toggleButton->SetPosition(298, 145, 100, 50);
+            VoLTE_toggleButton->SetStyle(STYLE_BACKGROUND_OPA, 0x00);
+            VoLTE_toggleButton->SetImages(PNG_TOGGLEBUTTON_ON_IMAGE, PNG_TOGGLEBUTTON_OFF_IMAGE);
+            VoLTE_toggleButton->SetOnClickListener(presenter_);
+#endif
+            /* --------------------------------- 移动数据开关 --------------------------------- */
+            if (MobileData_toggleButton == nullptr)
+            {
+                MobileData_toggleButton = new UIToggleButton();
+                if (MobileData_toggleButton == nullptr)
+                {
+                    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "LanguageSwitchView::MobileData_toggleButton is nullptr!");
+                    return;
+                }
+            }
+            if (VoLTE_toggleButton != nullptr)
+            {
+                MobileData_toggleButton->SetPosition(298, VoLTE_toggleButton->GetY() + 120, 100, 50);
+            }
+            else
+            {
+                MobileData_toggleButton->SetPosition(298, 145, 100, 50);
+            }
+            #ifdef FD230_650
+            MobileData_toggleButton->SetState(uapi_cat1_get_power_stat());
+            #endif
+            MobileData_toggleButton->SetStyle(STYLE_BACKGROUND_OPA, 0x00);
+            MobileData_toggleButton->SetImages(PNG_TOGGLEBUTTON_ON_IMAGE, PNG_TOGGLEBUTTON_OFF_IMAGE);
+            MobileData_toggleButton->SetOnClickListener(presenter_);
+            /* -------------------------------------------------------------------------- */
+            if (note == nullptr)
+            {
+                note = new UILabelExt(); // Create a new UILabel for each iteration
+                if (note == nullptr)
+                {
+                    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "note is nullptr!");
+                    return;
+                }
+            }
+            if (VoLTE_toggleButton != nullptr)
+            {
+                note->SetPosition(63, NetworkAndCallImage[1]->GetY() + NetworkAndCallImage[1]->GetHeight() + 20, 340, 80);
+            }
+            else
+            {
+                note->SetPosition(63, NetworkAndCallImage[0]->GetY() + NetworkAndCallImage[0]->GetHeight() + 20, 340, 80);
+            }
+            note->SetStyle(STYLE_TEXT_FONT, 20);
+            note->SetStyle(STYLE_LINE_HEIGHT, 40);
+            note->SetTextId(STR_4G_NOTE);//开启此功能后,手表可以4G SIM卡拨打电话,耗电会增加。
+            note->SetTextColor(Color::GetColorFromRGBA(0x99, 0x99, 0x99, 0xff));
+            note->SetLineBreakMode(UILabel::LINE_BREAK_WRAP);
+            note->SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_CENTER);
+            note->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20);
+        }
+    }
+
+    void NetworkAndCallView::OnStart()
+    {
+        View<NetworkAndCallPresenter>::OnStart();
+        NetworkAndCallViewInit();
+        NetworkAndCallScrollView[NETWORKANDCALLVIEW]->Add(Title);
+        for (int i = 0; i < ITEM_NUM; i++)
+        {
+            NetworkAndCallScrollView[NETWORKANDCALLVIEW]->Add(NetworkAndCallImage[i]);
+            NetworkAndCallScrollView[NETWORKANDCALLVIEW]->Add(NetworkAndCallLabel[i]);
+        }
+#if defined(SUPPORT_CHINA_MOBILE_DMP)
+        if (MobileData_toggleButton != nullptr)
+        {
+            VoLTE_toggleButton->SetState(MobileData_toggleButton->GetState() == true && ConfigModel::GetInstance()->GetVoLTE_Call());
+        }
+        NetworkAndCallScrollView[NETWORKANDCALLVIEW]->Add(VoLTE_toggleButton);
+#endif
+        NetworkAndCallScrollView[NETWORKANDCALLVIEW]->Add(MobileData_toggleButton);
+        NetworkAndCallScrollView[NETWORKANDCALLVIEW]->Add(note);
+        AddViewToRootContainer(NetworkAndCallScrollView[NETWORKANDCALLVIEW]);
+        RootView::GetInstance()->SetOnKeyActListener(presenter_);
+    }
+
+
+
+    
+
+    // 获取VOLTE button
+    UIToggleButton *NetworkAndCallView::GetVoLTEToggleButton(void)
+    {
+        return VoLTE_toggleButton;
+    }
+
+    // 获取移动数据 button
+    UIToggleButton *NetworkAndCallView::GetMobileDataToggleButton(void)
+    {
+        return MobileData_toggleButton;
+    }
+
+    UIImageView *NetworkAndCallView::GetNetworkAndCallImage(int index)
+    {
+        return NetworkAndCallImage[index];
+    }
+
+    MobileDataOptionsView *NetworkAndCallView::GetMobileDataOptionsView(void)
+    {
+        return mobileDataOptionsView;
+    }
+
+    // 切换到网络与通话视图
+    bool NetworkAndCallView::ChangeNetworkAndCallView(int16_t thisView)
+    {
+        if (NetworkAndCallScrollView[thisView] == nullptr)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "NetworkAndCallView::ChangeNetworkAndCallView");
+            RootView::GetInstance()->Add(NetworkAndCallScrollView[thisView]);
+        }
+        return true;
+    }
+
+    // 切换到数据选项视图
+    bool NetworkAndCallView::ChangeMobileDataOptionsView(int16_t thisView)
+    {
+        if (NetworkAndCallScrollView[thisView] == nullptr)
+        {
+            WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "DisplayBrightnessView::ChangeScreenDurationView");
+            mobileDataOptionsView = new MobileDataOptionsView();
+            if (mobileDataOptionsView == nullptr)
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DisplayBrightnessView:: new scrollView[%d] fail", thisView);
+                return false;
+            }
+            NetworkAndCallScrollView[thisView] = mobileDataOptionsView->MobileDataOptionsViewInit();
+            RootView::GetInstance()->Add(NetworkAndCallScrollView[thisView]);
+        }
+        return true;
+    }
+
+    struct NetworkAndCallViewMapper
+    {
+        const int16_t viewId;
+        bool (NetworkAndCallView::*func)(int16_t thisView);
+    };
+
+    static const NetworkAndCallViewMapper ViewMapper[] = {
+        {NETWORKANDCALLVIEW, &NetworkAndCallView::ChangeNetworkAndCallView},
+        {MOBILEDATAOPTIONSVIEW, &NetworkAndCallView::ChangeMobileDataOptionsView},
+    };
+
+    bool NetworkAndCallView::ClickFunc(int16_t interface)
+    {
+        int funcSize = sizeof(ViewMapper) / sizeof(ViewMapper[0]);
+        for (int i = 0; i < funcSize; i++)
+        {
+            if (interface == ViewMapper[i].viewId)
+            {
+                bool jug = (this->*(ViewMapper[i].func))(interface);
+                if (jug == false)
+                {
+                    return false;
+                }
+                return true;
+            }
+        }
+        return false;
+    }
+
+    void NetworkAndCallView::ChangeView(int16_t hideView, int16_t showView)
+    {
+        if (hideView > MAX_NETWORKANDCALLVIEWID)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "NetworkAndCallView::ViewId Overstep ones bounds");
+            return;
+        }
+        NetworkAndCallScrollView[hideView]->SetVisible(false);
+        ClickFunc(showView);
+        NetworkAndCallScrollView[showView]->SetVisible(true);
+        Draw();
+    }
+}
\ No newline at end of file
index 6708317..41b3201 100644 (file)
@@ -1094,9 +1094,11 @@ namespace OHOS
     void ConfigModel::SetVoLTE_Call(bool state)
     {
         set_condigData_Bool(CONFIGMODEL_ITEM_VOLTE_CALL,state);
+     #ifdef FD230_650
      #ifdef SUPPORT_CAT1_SERVICE
         send_volte_switch_toCat1();
      #endif
+     #endif
     }
 
     /*