将快速访问Slice改成辅助功能的subview
authorluozheng <1732036298@qq.com>
Tue, 27 Feb 2024 09:54:23 +0000 (17:54 +0800)
committerluozheng <1732036298@qq.com>
Tue, 27 Feb 2024 09:54:23 +0000 (17:54 +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/secondaryfunction/include/QuickAccessPresenter.h [deleted file]
code/sdk/application/wearable/fd230app/nativeui/secondaryfunction/include/QuickAccessView.h
code/sdk/application/wearable/fd230app/nativeui/secondaryfunction/include/SecondaryFunctionPresenter.h
code/sdk/application/wearable/fd230app/nativeui/secondaryfunction/include/SecondaryFunctionView.h
code/sdk/application/wearable/fd230app/nativeui/secondaryfunction/src/QuickAccessPresenter.cpp [deleted file]
code/sdk/application/wearable/fd230app/nativeui/secondaryfunction/src/QuickAccessView.cpp
code/sdk/application/wearable/fd230app/nativeui/secondaryfunction/src/SecondaryFunctionPresenter.cpp
code/sdk/application/wearable/fd230app/nativeui/secondaryfunction/src/SecondaryFunctionView.cpp

index d6b10dc..d9eca50 100644 (file)
@@ -284,8 +284,7 @@ set(SOURCES
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/secondaryfunction/src/FastTrainingAttentionPresenter.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/secondaryfunction/src/FastTrainingAttentionView.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/secondaryfunction/src/FastTrainingPresenter.cpp
-    ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/secondaryfunction/src/FastTrainingView.cpp
-    ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/secondaryfunction/src/QuickAccessPresenter.cpp            
+    ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/secondaryfunction/src/FastTrainingView.cpp         
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/secondaryfunction/src/QuickAccessView.cpp    
 
     #指南针
index 9b8eef2..dd0ba2c 100644 (file)
@@ -52,7 +52,6 @@ typedef enum : uint16_t
     VIEW_MEDIA_VOLUME,            // 媒体音量
     VIEW_DISPLAY_BRIGHTNESS,      // 屏幕与亮度
     VIEW_SECONDARY_FUNCTION,      // 辅助功能
-    VIEW_QUICK_ACCESS,            // 快速访问
     VIEW_FAST_TRAINING,           // 快速训练
     VIEW_FAST_TRAINING_ATTENTION, // 快速训练项目选择超出提示
     /* ----------------------------------- 录音 ----------------------------------- */
index 24090b0..538454c 100644 (file)
@@ -60,7 +60,6 @@ namespace OHOS
         void InitDialUpdateSlice(void);
         /* -------------------------------------------------------------------------- */
         void InitSecondaryFunction(void);
-        void InitQuickAccessSlice(void);
         void InitFastTrainingSlice(void);
         void InitFastTrainingAttentionSlice(void);
 
index 1578992..ad5a1c7 100644 (file)
@@ -92,8 +92,6 @@
 #include "secondaryfunction/include/FastTrainingView.h"
 #include "secondaryfunction/include/FastTrainingAttentionPresenter.h"
 #include "secondaryfunction/include/FastTrainingAttentionView.h"
-#include "secondaryfunction/include/QuickAccessPresenter.h"
-#include "secondaryfunction/include/QuickAccessView.h"
 
 #include "classicbluetooth/include/ClassicBlueToothPresenter.h"
 #include "classicbluetooth/include/ClassicBlueToothView.h"
@@ -164,7 +162,6 @@ namespace OHOS
         {VIEW_CLASSIC_BLUETOOTH, &NativeLauncher::InitClassicBluetoothSlice},         // 经典蓝牙slice
         {VIEW_DISPLAY_BRIGHTNESS, &NativeLauncher::InitDisplayBrightnessSlice},       // 显示与亮度的实例化地址
         {VIEW_SECONDARY_FUNCTION, &NativeLauncher::InitSecondaryFunction},
-        {VIEW_QUICK_ACCESS, &NativeLauncher::InitQuickAccessSlice}, // 快速访问实例化地址
         {VIEW_FAST_TRAINING, &NativeLauncher::InitFastTrainingSlice},
         {VIEW_FAST_TRAINING_ATTENTION, &NativeLauncher::InitFastTrainingAttentionSlice},
 
@@ -584,16 +581,6 @@ namespace OHOS
         NativeAbility::GetInstance().AddSliceProxy(VIEW_SECONDARY_FUNCTION, secondaryfunction);
     }
 
-    void NativeLauncher::InitQuickAccessSlice(void) // 快速访问
-    {
-        SliceProxy *QuickAccess = new AbilitySliceProxy<QuickAccessView, QuickAccessPresenter>;
-        if (QuickAccess == nullptr)
-        {
-            return;
-        }
-        NativeAbility::GetInstance().AddSliceProxy(VIEW_QUICK_ACCESS, QuickAccess);
-    }
-
     void NativeLauncher::InitFastTrainingSlice(void)
     {
         SliceProxy *fasttraining = new AbilitySliceProxy<FastTrainingView, FastTrainingPresenter>;
diff --git a/code/sdk/application/wearable/fd230app/nativeui/secondaryfunction/include/QuickAccessPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/secondaryfunction/include/QuickAccessPresenter.h
deleted file mode 100644 (file)
index 100e173..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-#ifndef QUICK_ACCESS_PRESENTER_H\r
-#define QUICK_ACCESS_PRESENTER_H\r
-\r
-#include "Presenter.h"\r
- \r
-#include "QuickAccessView.h"\r
- \r
-namespace OHOS\r
-{\r
-    class QuickAccessView;\r
-       \r
-    class QuickAccessPresenter : public Presenter<QuickAccessView>,\r
-                                 public UIView::OnClickListener,\r
-                                 public UIView::OnDragListener\r
-    {\r
-    public:\r
-        QuickAccessPresenter();\r
-        virtual ~QuickAccessPresenter();\r
- \r
-        void OnStart() override;  \r
-        void OnPause() override;  \r
-        void OnResume() override; \r
-        void OnStop() override;   \r
- \r
-        static QuickAccessPresenter *GetInstance();     \r
- \r
-    private:\r
-        //因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承;\r
-        bool OnClick(UIView &view, const ClickEvent &event) override; \r
-        bool OnDrag(UIView &view, const DragEvent &event) override;   \r
-    };\r
-} //namespace OHOS\r
-\r
-\r
-\r
-\r
-\r
-\r
-#endif
\ No newline at end of file
index 4a9dc39..937315e 100644 (file)
@@ -3,48 +3,68 @@
 \r
 #include "BaseView.h"\r
 #include "View.h"\r
-\r
-#include "components/ui_view_group.h"\r
 #include "components/ui_scroll_view.h"\r
 #include "components/ui_image_view.h"\r
 #include "components/ui_label.h"\r
-#include "components/ui_checkbox.h"\r
+#include "components/ui_radio_button.h"\r
+#include "wearable_log.h"\r
 namespace OHOS\r
 {\r
-    static const char *HEART_RATE_DETECTION = "HeartRateDetectionCheckBox";     //心率检测\r
-    static const char *BLOOD_OXYGEN_MONITOR = "BloodOxygenMonitoringCheckBox";  //血氧检测\r
+    static const char *HEART_RATE_DETECTION = "HeartRateDetectionCheckBox";    // 心率检测\r
+    static const char *BLOOD_OXYGEN_MONITOR = "BloodOxygenMonitoringCheckBox"; // 血氧检测\r
 \r
-    class QuickAccessPresenter;\r
-    class QuickAccessView : public View<QuickAccessPresenter>\r
+    class QuickAccessView\r
     {\r
-\r
     public:\r
+        struct ImageConfig\r
+        {\r
+            int16_t x;\r
+            int16_t y;\r
+            int16_t w;\r
+            int16_t h;\r
+            const char *ImageSrc;\r
+        };\r
+        struct LabelConfig\r
+        {\r
+            int16_t left;\r
+            int16_t top;\r
+            int16_t width;\r
+            int16_t height;\r
+            int16_t fontSize;      // 字体大小\r
+            int16_t lineHeigh;     // 行高\r
+            const char *text;      // 文本\r
+            uint8_t lineBreakMode; // 断行模式。\r
+        };\r
+        struct RadioButtonConfig\r
+        {\r
+            int16_t x;\r
+            int16_t y;\r
+            int16_t w;\r
+            int16_t h;\r
+            const char *viewId;\r
+            const char *select;\r
+            const char *unselect;\r
+        };\r
         QuickAccessView();\r
         virtual ~QuickAccessView();\r
         static QuickAccessView *GetInstance(void);\r
-\r
-        void OnStart() override;\r
-        void OnSetUpView() override;\r
-        void OnTearDownView() override;\r
-        void OnStop() override;\r
-\r
-    private:\r
-        void InitView(void);\r
-        void DeInitView(void);\r
-\r
+        UIScrollView *QuickAccessViewInit(void);\r
+        void ClearAll(void);\r
+        UIRadioButton * GetRadioButton(int i);\r
     private:\r
-        UIViewGroup *container_ = nullptr;\r
+        bool QuickAccessScrollViewInit(void);\r
+        bool QuickAccessLabelInit(void);\r
+        bool QuickAccessImageViewInit(void);\r
+        bool QuickAccessRadioButtonInit(void);\r
+        UIImageView *SetUpImageView(ImageConfig &imageconfig);                 // 设置图片\r
+        UILabel *SetUpLabel(LabelConfig &labelconfig);                         // 设置标签\r
+        UIRadioButton *SetUpRadioButton(RadioButtonConfig &radiobuttonconfig); // 设置单选框\r
         UIScrollView *QuickAccessScrollView = nullptr;\r
-        UIImageView *image1 = nullptr;\r
-        UILabel *QuickAccessLabel = nullptr;\r
-        UIImageView *image2 = nullptr;\r
-        UILabel *label = nullptr;\r
-        UIImageView *HeartRateDetectionImage = nullptr;\r
-        UICheckBox *HeartRateDetectionCheckBox = nullptr;\r
-        UILabel *HeartRateDetectionLabel = nullptr;\r
-        UIImageView *BloodOxygenMonitoringImage = nullptr;\r
-        UICheckBox *BloodOxygenMonitoringCheckBox = nullptr;\r
-        UILabel *BloodOxygenMonitoringLabel = nullptr;\r
+        UILabel *QuickAccessLabel[4]{nullptr};\r
+        UIImageView *QuickAccessImageView[2]{nullptr};\r
+        UIRadioButton *QuickAccessRadioButton[2]{nullptr};\r
+        UICheckBox::OnChangeListener *ChangeLister[2]{nullptr};\r
+        bool initViewStatus{false};\r
     };\r
 } // namespace OHOS\r
 \r
index 47e3673..d424753 100644 (file)
@@ -2,14 +2,36 @@
 #define SECONDARY_FUNCTION_PRESENTER_H\r
 \r
 #include "Presenter.h"\r
-\r
 #include "SecondaryFunctionView.h"\r
-\r
 namespace OHOS\r
 {\r
 \r
+    typedef enum\r
+    {\r
+        SECONDARYFUNCTIONVIEW = 0, // 辅助功能视图(slice)\r
+        QUICKACCESSVIEW,           // 快速访问视图(subView)\r
+        // FASTTRAININGVIEW,      // 快速训练视图(subView)\r
+        MAX_SECONDARYFUNCTIONVIEWID,\r
+    } SECONDARYFUNCTIONVIEWID;\r
+\r
     static const char *SECONDARY_FUNCTION_QUICK_ACCESS_BUTTON = "SECONDARY_FUNCTION_QUICK_ACCESS_BUTTON";   // 快速访问\r
     static const char *SECONDARY_FUNCTION_FAST_TRAINING_BUTTON = "SECONDARY_FUNCTION_FAST_TRAINING_BUTTON"; // 快速训练\r
+\r
+    class QuickAccessRadioButtonChangeLister : public UICheckBox::OnChangeListener\r
+    {\r
+    public:\r
+        QuickAccessRadioButtonChangeLister(UIView *view)\r
+        {\r
+            m_view = view;\r
+        }\r
+        ~QuickAccessRadioButtonChangeLister() {}\r
+\r
+        bool OnChange(UICheckBox::UICheckBoxState state) override;\r
+\r
+    private:\r
+        UIView *m_view{nullptr};\r
+    };\r
+\r
     class SecondaryFunctionView;\r
     class SecondaryFunctionPresenter : public Presenter<SecondaryFunctionView>,\r
                                        public UIView::OnClickListener,\r
index 7fd4473..84678ee 100644 (file)
@@ -8,6 +8,7 @@
 #include "components/ui_image_view.h"\r
 #include "components/ui_button.h"\r
 #include "wearable_log.h"\r
+#include "secondaryfunction/include/QuickAccessView.h"\r
 namespace OHOS\r
 {\r
     class SecondaryFunctionPresenter;\r
@@ -37,6 +38,12 @@ namespace OHOS
         SecondaryFunctionView();\r
         virtual ~SecondaryFunctionView();\r
         static SecondaryFunctionView *GetInstance(void);\r
+        bool ChangeSecondaryFunctionView(int16_t thisView);\r
+        bool ChangeQuickAccessView(int16_t thisView);\r
+        bool ClickFunc(int16_t interface);\r
+        void ChangeView(int16_t hideView, int16_t showView);\r
+        QuickAccessView *GetQuickAccessView(void);\r
+        UIScrollView *GetSecondaryFunctionScrollView(int i);\r
 \r
         void OnStart() override;\r
         void OnSetUpView() override;\r
@@ -52,13 +59,14 @@ namespace OHOS
         bool SecondaryFunctionScrollImageInit(void);\r
         UIImageView *SetUpImageView(ImageConfig &imageconfig); // 设置图片\r
         UILabel *SetUpLabel(LabelConfig &labelconfig);         // 设置标签\r
-        UIScrollView *SecondaryFunctionScrollView{nullptr};\r
+        UIScrollView *SecondaryFunctionScrollView[2]{nullptr};\r
         UILabel *SecondaryFunctionScrollTitleLabel{nullptr}; // 标题\r
         UILabel *QuickAccessLabel{nullptr};                  // 快速访问\r
         UILabel *FastTrainingLabel{nullptr};                 // 快速训练\r
         UIButton *QuickAccessButton{nullptr};\r
         UIButton *FastTrainingButton{nullptr};\r
         UIImageView *Image[2]{nullptr};\r
+        QuickAccessView *p_QuickAccessView{nullptr};\r
         bool initViewStatus{false};\r
     };\r
 } // namespace OHOS\r
diff --git a/code/sdk/application/wearable/fd230app/nativeui/secondaryfunction/src/QuickAccessPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/secondaryfunction/src/QuickAccessPresenter.cpp
deleted file mode 100644 (file)
index c2b25c1..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-#include "AppViewIDs.h"\r
-#include "NativeAbility.h"\r
-#include "graphic_math.h"\r
-#include "string.h"\r
-\r
-#include "secondaryfunction/include/QuickAccessPresenter.h"\r
-\r
-namespace OHOS\r
-{\r
-\r
-    // 当前Presenter属性实例化的内存指针\r
-    static QuickAccessPresenter *g_pQuickAccessPresenter = nullptr;\r
-\r
-    QuickAccessPresenter::QuickAccessPresenter()\r
-    {\r
-\r
-        g_pQuickAccessPresenter = this;\r
-    }\r
-\r
-    QuickAccessPresenter::~QuickAccessPresenter()\r
-    {\r
-\r
-        g_pQuickAccessPresenter = nullptr;\r
-    }\r
-\r
-    QuickAccessPresenter *QuickAccessPresenter::GetInstance()\r
-    {\r
-\r
-        return g_pQuickAccessPresenter;\r
-    }\r
-\r
-    void QuickAccessPresenter::OnStart()\r
-    {\r
-\r
-        Presenter<QuickAccessView>::OnStart();\r
-    }\r
-\r
-    void QuickAccessPresenter::OnPause(void)\r
-    {\r
-\r
-        Presenter<QuickAccessView>::OnPause();\r
-    }\r
-\r
-    void QuickAccessPresenter::OnResume(void)\r
-    {\r
-\r
-        Presenter<QuickAccessView>::OnResume();\r
-    }\r
-\r
-    void QuickAccessPresenter::OnStop(void)\r
-    {\r
-\r
-        Presenter<QuickAccessView>::OnStop();\r
-    }\r
-\r
-    bool QuickAccessPresenter::OnDrag(UIView &view, const DragEvent &event)\r
-    {\r
-        UNUSED(view);\r
-        if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT &&\r
-            (event.GetDeltaX() > 20) && (event.GetDeltaX() > (2 * MATH_ABS(event.GetDeltaY()))))\r
-        {\r
-            NativeAbility::GetInstance().ChangeSlice(VIEW_SECONDARY_FUNCTION);\r
-            return true;\r
-        }\r
-        return false;\r
-    }\r
-\r
-    bool QuickAccessPresenter::OnClick(UIView &view, const ClickEvent &event)\r
-    {\r
-        UNUSED(event);\r
-        // 根据控件id查找是哪个控件触发了点击回调\r
-        if (strcmp(view.GetViewId(), HEART_RATE_DETECTION) == 0)\r
-        {\r
-            \r
-            return true;\r
-        }\r
-        else if(strcmp(view.GetViewId(), BLOOD_OXYGEN_MONITOR) == 0)\r
-        {\r
-            \r
-            return true;\r
-        }\r
-        return false;\r
-    }\r
-}
\ No newline at end of file
index d2c7e2f..9d38d76 100644 (file)
@@ -1,7 +1,5 @@
-#include "UiConfig.h"\r
-\r
 #include "secondaryfunction/include/QuickAccessView.h"\r
-#include "secondaryfunction/include/QuickAccessPresenter.h"\r
+#include "secondaryfunction/include/SecondaryFunctionPresenter.h"\r
 namespace OHOS\r
 {\r
 \r
@@ -9,314 +7,234 @@ namespace OHOS
 \r
     QuickAccessView::QuickAccessView()\r
     {\r
-\r
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "QuickAccessView::QuickAccessView");\r
         g_pQuickAccessView = this;\r
     }\r
 \r
     QuickAccessView::~QuickAccessView()\r
     {\r
-        DeInitView();\r
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "QuickAccessView::~QuickAccessView");\r
+        ClearAll();\r
         g_pQuickAccessView = nullptr;\r
     }\r
 \r
     QuickAccessView *QuickAccessView::GetInstance()\r
     {\r
-\r
         return g_pQuickAccessView;\r
     }\r
 \r
-    void QuickAccessView::InitView(void)\r
+    void QuickAccessView::ClearAll(void)\r
     {\r
-        if (container_ == nullptr)\r
+        if (initViewStatus == true)\r
         {\r
-            container_ = new UIViewGroup();\r
-            container_->SetPosition(0, 0, 466, 466);\r
-            container_->SetStyle(STYLE_BACKGROUND_OPA, 0);\r
-            UIView::OnDragListener *draglistener = static_cast<UIView::OnDragListener *>(QuickAccessPresenter::GetInstance());\r
-            if (draglistener == nullptr)\r
+            QuickAccessScrollView->RemoveAll();\r
+\r
+            // 循环删除 UILabel 指针数组\r
+            for (int i = 0; i < 4; i++)\r
             {\r
-                return;\r
+                delete QuickAccessLabel[i];\r
+                QuickAccessLabel[i] = nullptr;\r
             }\r
-            container_->SetOnDragListener(draglistener);\r
-            container_->SetTouchable(true);\r
-            container_->SetDraggable(true);\r
-        }\r
-        /***********************************************************************************************************/\r
-        // Add QuickAccessScrollView to App\r
-        if (QuickAccessScrollView == nullptr)\r
-        {\r
-            QuickAccessScrollView = new UIScrollView();\r
+\r
+            // 循环删除 UIImageView 和 UIRadioButton指针数组\r
+            for (int i = 0; i < 2; i++)\r
+            {\r
+                delete QuickAccessImageView[i];\r
+                QuickAccessImageView[i] = nullptr;\r
+\r
+                delete ChangeLister[i];\r
+                ChangeLister[i] = nullptr;\r
+\r
+                delete QuickAccessRadioButton[i];\r
+                QuickAccessRadioButton[i] = nullptr;\r
+            }\r
+\r
+            delete QuickAccessScrollView;\r
+            QuickAccessScrollView = nullptr;\r
         }\r
-        QuickAccessScrollView->SetPosition(0, 0);\r
-        QuickAccessScrollView->Resize(466, 466);\r
-        QuickAccessScrollView->SetViewId("QuickAccessScrollView");\r
-        QuickAccessScrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff);\r
-        // Add to rootView\r
-        container_->Add(QuickAccessScrollView);\r
-        QuickAccessScrollView->SetVisible(true);\r
-        /***********************************************************************************************************/\r
-        // Add Label to App\r
-        if (QuickAccessLabel == nullptr)\r
+    }\r
+\r
+    UIRadioButton *QuickAccessView::GetRadioButton(int i)\r
+    {\r
+        return QuickAccessRadioButton[i];\r
+    }\r
+\r
+    // 设置图片\r
+    UIImageView *QuickAccessView::SetUpImageView(ImageConfig &imageconfig)\r
+    {\r
+        UIImageView *Image = new UIImageView();\r
+        if (Image == nullptr)\r
         {\r
-            QuickAccessLabel = new UILabel();\r
+            return nullptr;\r
         }\r
-        QuickAccessLabel->SetPosition(173, 52);\r
-        QuickAccessLabel->Resize(120, 35);\r
-        QuickAccessLabel->SetViewId("QuickAccessLabel");\r
-        QuickAccessLabel->SetStyle(STYLE_TEXT_FONT, 30);\r
-        QuickAccessLabel->SetStyle(STYLE_LINE_HEIGHT, 35);\r
-        // Set additional property\r
-        QuickAccessLabel->SetText("快速访问");\r
-        QuickAccessLabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);\r
-        QuickAccessLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);\r
-        QuickAccessLabel->SetRollSpeed(6);\r
-        QuickAccessLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);\r
-        // Add to scrollView3\r
-        QuickAccessScrollView->Add(QuickAccessLabel);\r
-        QuickAccessLabel->SetVisible(true);\r
-        /***********************************************************************************************************/\r
-        // Add Label to App\r
+        Image->SetPosition(imageconfig.x, imageconfig.y, imageconfig.w, imageconfig.h);\r
+        Image->SetSrc(imageconfig.ImageSrc);\r
+        return Image;\r
+    }\r
+\r
+    // 设置标签\r
+    UILabel *QuickAccessView::SetUpLabel(LabelConfig &labelconfig)\r
+    {\r
+        UILabel *label = new UILabel();\r
         if (label == nullptr)\r
         {\r
-            label = new UILabel();\r
+            return nullptr;\r
         }\r
-        label->SetPosition(86, 126);\r
-        label->Resize(286, 60);\r
-        label->SetViewId("label");\r
-        label->SetStyle(STYLE_TEXT_FONT, 26);\r
-        label->SetStyle(STYLE_LINE_HEIGHT, 30);\r
-        // Set additional property\r
-        label->SetText("此功能可设置右下方按钮\n快速访问的APP");\r
-        label->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);\r
-        label->SetTextColor(Color::GetColorFromRGBA(0xbb, 0xbb, 0xbb, 0xff));\r
+        label->SetPosition(labelconfig.left, labelconfig.top, labelconfig.width, labelconfig.height); // 位置大小\r
+        label->SetStyle(STYLE_TEXT_FONT, labelconfig.fontSize);                                       // 字体大小\r
+        label->SetStyle(STYLE_LINE_HEIGHT, labelconfig.lineHeigh);                                    // 字体行高\r
+        label->SetText(labelconfig.text);                                                             // 内容\r
+        label->SetLineBreakMode(labelconfig.lineBreakMode);                                           // 断行模式。\r
         label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);\r
-        label->SetRollSpeed(6);\r
-        label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 26);\r
-        // Add to scrollView3\r
-        QuickAccessScrollView->Add(label);\r
-        label->SetVisible(true);\r
-        /***********************************************************************************************************/\r
-        // Add ImageView to App\r
-        if (HeartRateDetectionImage == nullptr)\r
-        {\r
-            HeartRateDetectionImage = new UIImageView();\r
-        }\r
-        HeartRateDetectionImage->SetPosition(43, 220);                 // widget's left position and top position\r
-        HeartRateDetectionImage->Resize(380, 100);                     // widget's width and height\r
-        HeartRateDetectionImage->SetViewId("HeartRateDetectionImage"); // Set style\r
-        HeartRateDetectionImage->SetStyle(STYLE_BORDER_RADIUS, 50);\r
-        HeartRateDetectionImage->SetSrc(PNG_SETTING_BACKGROUND_IMAGE);\r
-        // Add to scrollView3\r
-        QuickAccessScrollView->Add(HeartRateDetectionImage);\r
-        HeartRateDetectionImage->SetVisible(true);\r
-        /***********************************************************************************************************/\r
-        // Add Label to App\r
-        if (HeartRateDetectionLabel == nullptr)\r
-        {\r
-            HeartRateDetectionLabel = new UILabel();\r
-        }\r
-        HeartRateDetectionLabel->SetPosition(103, 253);\r
-        HeartRateDetectionLabel->Resize(120, 35);\r
-        HeartRateDetectionLabel->SetViewId("HeartRateDetectionLabel");\r
-        HeartRateDetectionLabel->SetStyle(STYLE_TEXT_FONT, 30);\r
-        HeartRateDetectionLabel->SetStyle(STYLE_LINE_HEIGHT, 35);\r
-        // Set additional property\r
-        HeartRateDetectionLabel->SetText("心率监测");\r
-        HeartRateDetectionLabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);\r
-        HeartRateDetectionLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);\r
-        HeartRateDetectionLabel->SetRollSpeed(6);\r
-        HeartRateDetectionLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);\r
-        // Add to scrollView3\r
-        QuickAccessScrollView->Add(HeartRateDetectionLabel);\r
-        HeartRateDetectionLabel->SetVisible(true);\r
-        /***********************************************************************************************************/\r
-        // Add CheckBox to App\r
-        if (HeartRateDetectionCheckBox == nullptr)\r
-        {\r
-            HeartRateDetectionCheckBox = new UICheckBox();\r
-        }\r
-        HeartRateDetectionCheckBox->SetPosition(343, 250);\r
-        HeartRateDetectionCheckBox->Resize(40, 40);\r
-        HeartRateDetectionCheckBox->SetViewId(HEART_RATE_DETECTION);\r
-        HeartRateDetectionCheckBox->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);\r
-        HeartRateDetectionCheckBox->SetStyle(STYLE_BACKGROUND_OPA, 0xff);\r
-        // Set additional property\r
-        HeartRateDetectionCheckBox->SetImages(PNG_CHECKBOX_ON_IMAGE, PNG_CHECKBOX_OFF_IMAGE);\r
-        // Add the CallBack about events\r
-        UIView::OnClickListener *HeartRateDetectionCheckBoxClick = static_cast<UIView::OnClickListener *>(QuickAccessPresenter::GetInstance());\r
-        HeartRateDetectionCheckBox->SetOnClickListener(HeartRateDetectionCheckBoxClick);\r
-        // Add to scrollView3\r
-        QuickAccessScrollView->Add(HeartRateDetectionCheckBox);\r
-        HeartRateDetectionCheckBox->SetVisible(true);\r
-        /***********************************************************************************************************/\r
-        // Add ImageView to App\r
-        if (BloodOxygenMonitoringImage == nullptr)\r
-        {\r
-            BloodOxygenMonitoringImage = new UIImageView();\r
-        }\r
-        BloodOxygenMonitoringImage->SetPosition(43, 340);\r
-        BloodOxygenMonitoringImage->Resize(380, 100);\r
-        BloodOxygenMonitoringImage->SetViewId("BloodOxygenMonitoringImage");\r
-        BloodOxygenMonitoringImage->SetStyle(STYLE_BORDER_RADIUS, 50);\r
-        // Set additional property\r
-        BloodOxygenMonitoringImage->SetSrc(PNG_SETTING_BACKGROUND_IMAGE);\r
-        // Add to scrollView3\r
-        QuickAccessScrollView->Add(BloodOxygenMonitoringImage);\r
-        BloodOxygenMonitoringImage->SetVisible(true);\r
-        /***********************************************************************************************************/\r
-        // Add CheckBox to App\r
-        if (BloodOxygenMonitoringCheckBox == nullptr)\r
-        {\r
-            BloodOxygenMonitoringCheckBox = new UICheckBox();\r
-        }\r
-        BloodOxygenMonitoringCheckBox->SetPosition(343, 370);\r
-        BloodOxygenMonitoringCheckBox->Resize(50, 50);\r
-        BloodOxygenMonitoringCheckBox->SetViewId(BLOOD_OXYGEN_MONITOR);\r
-        BloodOxygenMonitoringCheckBox->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);\r
-        BloodOxygenMonitoringCheckBox->SetStyle(STYLE_BACKGROUND_OPA, 0xff);\r
-        BloodOxygenMonitoringCheckBox->SetImages(PNG_CHECKBOX_ON_IMAGE, PNG_CHECKBOX_OFF_IMAGE);\r
-        // Add the CallBack about events\r
-        UIView::OnClickListener *BloodOxygenMonitoringCheckBoxClick = static_cast<UIView::OnClickListener *>(QuickAccessPresenter::GetInstance());\r
-        BloodOxygenMonitoringCheckBox->SetOnClickListener(BloodOxygenMonitoringCheckBoxClick);\r
-        // Add to scrollView3\r
-        QuickAccessScrollView->Add(BloodOxygenMonitoringCheckBox);\r
-        BloodOxygenMonitoringCheckBox->SetVisible(true);\r
-        /***********************************************************************************************************/\r
-        // Add Label to App\r
-        if (BloodOxygenMonitoringLabel == nullptr)\r
-        {\r
-            BloodOxygenMonitoringLabel = new UILabel();\r
-        }\r
-        BloodOxygenMonitoringLabel->SetPosition(103, 373);\r
-        BloodOxygenMonitoringLabel->Resize(120, 35);\r
-        BloodOxygenMonitoringLabel->SetViewId("BloodOxygenMonitoringLabel");\r
-        BloodOxygenMonitoringLabel->SetStyle(STYLE_TEXT_FONT, 30);\r
-        BloodOxygenMonitoringLabel->SetStyle(STYLE_LINE_HEIGHT, 35);\r
-        // Set additional property\r
-        BloodOxygenMonitoringLabel->SetText("血氧监测");\r
-        BloodOxygenMonitoringLabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);\r
-        BloodOxygenMonitoringLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);\r
-        BloodOxygenMonitoringLabel->SetRollSpeed(6);\r
-        BloodOxygenMonitoringLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);\r
-        // Add to scrollView3\r
-        QuickAccessScrollView->Add(BloodOxygenMonitoringLabel);\r
-        BloodOxygenMonitoringLabel->SetVisible(true);\r
-        /***********************************************************************************************************/\r
-        // Add ImageView to App\r
-        if (image1 == nullptr)\r
-        {\r
-            image1 = new UIImageView();\r
-        }\r
-        image1->SetPosition(183, 23);\r
-        image1->Resize(100, 100);\r
-        image1->SetViewId("image1");\r
+        label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, labelconfig.fontSize);\r
+        return label;\r
+    }\r
 \r
-        QuickAccessScrollView->Add(image1);\r
-        image1->SetVisible(true);\r
-        /***********************************************************************************************************/\r
-        // Add ImageView to App\r
-        if (image2 == nullptr)\r
+    // 设置单选框\r
+    UIRadioButton *QuickAccessView::SetUpRadioButton(RadioButtonConfig &radiobuttonconfig)\r
+    {\r
+        UIRadioButton *radiobutton = new UIRadioButton("QuickAccess");\r
+        if (nullptr == radiobutton)\r
         {\r
-            image2 = new UIImageView();\r
+            return nullptr;\r
         }\r
-        image2->SetPosition(183, 423);\r
-        image2->Resize(100, 100);\r
-        image2->SetViewId("image2");\r
-        QuickAccessScrollView->Add(image2);\r
-        image2->SetVisible(true);\r
+        radiobutton->SetPosition(radiobuttonconfig.x, radiobuttonconfig.y, radiobuttonconfig.w, radiobuttonconfig.h);\r
+        radiobutton->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff);\r
+        radiobutton->SetImages(radiobuttonconfig.select, radiobuttonconfig.unselect);\r
+        return radiobutton;\r
     }\r
 \r
-    void QuickAccessView::DeInitView(void)\r
+    bool QuickAccessView::QuickAccessScrollViewInit(void)\r
     {\r
-        if (container_ != nullptr)\r
-        {\r
-            container_->RemoveAll();\r
-            delete container_;\r
-            container_ = nullptr;\r
-        }\r
-        if (QuickAccessScrollView != nullptr)\r
-        {\r
-            delete QuickAccessScrollView;\r
-            QuickAccessScrollView = nullptr;\r
-        }\r
-        if (image1 != nullptr)\r
-        {\r
-            delete image1;\r
-            image1 = nullptr;\r
-        }\r
-        if (QuickAccessLabel != nullptr)\r
-        {\r
-            delete QuickAccessLabel;\r
-            QuickAccessLabel = nullptr;\r
-        }\r
-        if (image2 != nullptr)\r
-        {\r
-            delete image2;\r
-            image2 = nullptr;\r
-        }\r
-        if (label != nullptr)\r
-        {\r
-            delete label;\r
-            label = nullptr;\r
-        }\r
-        if (HeartRateDetectionImage != nullptr)\r
-        {\r
-            delete HeartRateDetectionImage;\r
-            HeartRateDetectionImage = nullptr;\r
-        }\r
-        if (HeartRateDetectionCheckBox != nullptr)\r
-        {\r
-            delete HeartRateDetectionCheckBox;\r
-            HeartRateDetectionCheckBox = nullptr;\r
-        }\r
-        if (HeartRateDetectionLabel != nullptr)\r
-        {\r
-            delete HeartRateDetectionLabel;\r
-            HeartRateDetectionLabel = nullptr;\r
-        }\r
-        if (BloodOxygenMonitoringImage != nullptr)\r
-        {\r
-            delete BloodOxygenMonitoringImage;\r
-            BloodOxygenMonitoringImage = nullptr;\r
-        }\r
-        if (BloodOxygenMonitoringCheckBox != nullptr)\r
+        QuickAccessScrollView = new UIScrollView();\r
+        if (QuickAccessScrollView == nullptr)\r
         {\r
-            delete BloodOxygenMonitoringCheckBox;\r
-            BloodOxygenMonitoringCheckBox = nullptr;\r
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "QuickAccessView::QuickAccessScrollView new fail!");\r
+            return false;\r
         }\r
-        if (BloodOxygenMonitoringLabel != nullptr)\r
+        QuickAccessScrollView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());\r
+        QuickAccessScrollView->SetScrollBlankSize(35);\r
+        QuickAccessScrollView->SetReboundSize(50);\r
+        QuickAccessScrollView->SetDirection(1);\r
+        UIView::OnDragListener *draglistener = static_cast<UIView::OnDragListener *>(SecondaryFunctionPresenter::GetInstance());\r
+        if (draglistener == nullptr)\r
         {\r
-            delete BloodOxygenMonitoringLabel;\r
-            BloodOxygenMonitoringLabel = nullptr;\r
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "QuickAccessView::draglistener can not be nullptr!");\r
+            return false;\r
         }\r
+        QuickAccessScrollView->SetOnDragListener(draglistener);\r
+        QuickAccessScrollView->SetTouchable(true);\r
+        QuickAccessScrollView->SetDraggable(true);\r
+        return true;\r
     }\r
 \r
-    void QuickAccessView::OnStart()\r
+    bool QuickAccessView::QuickAccessLabelInit(void)\r
     {\r
-        View<QuickAccessPresenter>::OnStart();\r
-        InitView();\r
-        RootView::GetInstance()->Add(container_);\r
+        LabelConfig labelInfos[] = {\r
+            {173, 52, 120, 35, 30, 35, "快速访问", UILabel::LINE_BREAK_ADAPT},\r
+            {86, 126, 286, 60, 26, 30, "此功能可设置右下方按钮\n快速访问的APP", UILabel::LINE_BREAK_ADAPT},\r
+            {103, 253, 120, 35, 30, 35, "心率监测", UILabel::LINE_BREAK_ADAPT},\r
+            {103, 373, 120, 35, 30, 35, "血氧监测", UILabel::LINE_BREAK_ADAPT}};\r
+\r
+        for (int i = 0; i < 4; i++)\r
+        {\r
+            LabelConfig labelconfig = {\r
+                .left = labelInfos[i].left,\r
+                .top = labelInfos[i].top,\r
+                .width = labelInfos[i].width,\r
+                .height = labelInfos[i].height,\r
+                .fontSize = labelInfos[i].fontSize,\r
+                .lineHeigh = labelInfos[i].lineHeigh,\r
+                .text = labelInfos[i].text,\r
+                .lineBreakMode = labelInfos[i].lineBreakMode};\r
+\r
+            QuickAccessLabel[i] = SetUpLabel(labelconfig);\r
+            if (nullptr == QuickAccessLabel[i])\r
+            {\r
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "QuickAccessView::QuickAccessLabel[%d] is nullptr!", i);\r
+                return false;\r
+            }\r
+            QuickAccessScrollView->Add(QuickAccessLabel[i]);\r
+        }\r
+\r
+        return true;\r
     }\r
 \r
-    void QuickAccessView::OnSetUpView()\r
+    bool QuickAccessView::QuickAccessImageViewInit(void)\r
     {\r
-\r
-        View<QuickAccessPresenter>::OnSetUpView();\r
-        Draw();\r
+        ImageConfig imageconfig = {\r
+            .x = 43,\r
+            .y = 220,\r
+            .w = 380,\r
+            .h = 100,\r
+            .ImageSrc = "/user/res/SETTING_BACKGROUND.bin",\r
+        };\r
+\r
+        for (int i = 0; i < 2; i++)\r
+        {\r
+            imageconfig.y = 220 + (i * 120);\r
+            QuickAccessImageView[i] = SetUpImageView(imageconfig);\r
+            if (QuickAccessImageView[i] == nullptr)\r
+            {\r
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "QuickAccessView::QuickAccessImageView[%d] is nullptr!", i);\r
+                return false;\r
+            }\r
+            QuickAccessScrollView->Add(QuickAccessImageView[i]);\r
+        }\r
+        return true;\r
     }\r
 \r
-    void QuickAccessView::OnTearDownView()\r
+    bool QuickAccessView::QuickAccessRadioButtonInit(void)\r
     {\r
-\r
-        View<QuickAccessPresenter>::OnTearDownView();\r
-        return;\r
+        RadioButtonConfig radiobuttonconfig = {\r
+            .x = 300,\r
+            .y = 230,\r
+            .w = 80,\r
+            .h = 80,\r
+            .select = "/user/res/CHECKBOX_ON.bin",\r
+            .unselect = "/user/res/CHECKBOX_OFF.bin",\r
+        };\r
+\r
+        for (int i = 0; i < 2; i++)\r
+        {\r
+            radiobuttonconfig.y = 230 + (i * 120);\r
+            QuickAccessRadioButton[i] = SetUpRadioButton(radiobuttonconfig);\r
+            if (QuickAccessRadioButton[i] == nullptr)\r
+            {\r
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "QuickAccessView::QuickAccessRadioButton[%d] is nullptr!", i);\r
+                return false;\r
+            }\r
+            ChangeLister[i] = static_cast<UICheckBox::OnChangeListener *>(new QuickAccessRadioButtonChangeLister(QuickAccessRadioButton[i]));\r
+            QuickAccessRadioButton[i]->SetOnChangeListener(ChangeLister[i]);\r
+            QuickAccessScrollView->Add(QuickAccessRadioButton[i]);\r
+        }\r
+        return true;\r
     }\r
 \r
-    void QuickAccessView::OnStop()\r
+    UIScrollView *QuickAccessView::QuickAccessViewInit(void)\r
     {\r
+        if (!QuickAccessScrollViewInit())\r
+        {\r
+            return nullptr;\r
+        }\r
 \r
-        View<QuickAccessPresenter>::OnStop();\r
-        RootView::GetInstance()->RemoveAll();\r
-        return;\r
+        if (!QuickAccessImageViewInit())\r
+        {\r
+            return nullptr;\r
+        }\r
+\r
+        if (!QuickAccessLabelInit())\r
+        {\r
+            return nullptr;\r
+        }\r
+\r
+        if (!QuickAccessRadioButtonInit())\r
+        {\r
+            return nullptr;\r
+        }\r
+\r
+        initViewStatus = true;\r
+        return QuickAccessScrollView;\r
     }\r
+\r
 }
\ No newline at end of file
index fe06f7d..5421a88 100644 (file)
@@ -60,19 +60,48 @@ namespace OHOS
 \r
     bool SecondaryFunctionPresenter::OnDragEnd(UIView &view, const DragEvent &event)\r
     {\r
+        SecondaryFunctionView *p_SecondaryFunctionView = SecondaryFunctionView::GetInstance();\r
+        if (p_SecondaryFunctionView == nullptr)\r
+        {\r
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SecondaryFunctionView GetInstance fail");\r
+            return false;\r
+        }\r
         if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT)\r
         {\r
-            NativeAbility::GetInstance().ChangeSlice(VIEW_SETTING);\r
+            for (int i = 0; i < MAX_SECONDARYFUNCTIONVIEWID; i++)\r
+            {\r
+                if (p_SecondaryFunctionView->GetSecondaryFunctionScrollView(i) != nullptr &&\r
+                    p_SecondaryFunctionView->GetSecondaryFunctionScrollView(i)->IsVisible() == true)\r
+                {\r
+                    if (i == SECONDARYFUNCTIONVIEW)\r
+                    {\r
+                        NativeAbility::GetInstance().ChangeSlice(VIEW_SETTING);\r
+                    }\r
+                    else\r
+                    {\r
+                        p_SecondaryFunctionView->ChangeView(i, SECONDARYFUNCTIONVIEW);\r
+                    }\r
+                    break;\r
+                }\r
+            }\r
+            return true;\r
         }\r
-        return true;\r
+        return false;\r
     }\r
 \r
     bool SecondaryFunctionPresenter::OnClick(UIView &view, const ClickEvent &event)\r
     {\r
         UNUSED(event);\r
+        SecondaryFunctionView *p_SecondaryFunctionView = SecondaryFunctionView::GetInstance();\r
+        if (p_SecondaryFunctionView == nullptr)\r
+        {\r
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SecondaryFunctionView GetInstance fail");\r
+            return false;\r
+        }\r
+\r
         if (strcmp(view.GetViewId(), SECONDARY_FUNCTION_QUICK_ACCESS_BUTTON) == 0)\r
         {\r
-            NativeAbility::GetInstance().ChangeSlice(VIEW_QUICK_ACCESS);\r
+            p_SecondaryFunctionView->ChangeView(SECONDARYFUNCTIONVIEW, QUICKACCESSVIEW);\r
         }\r
         else if (strcmp(view.GetViewId(), SECONDARY_FUNCTION_FAST_TRAINING_BUTTON) == 0)\r
         {\r
@@ -80,4 +109,37 @@ namespace OHOS
         }\r
         return true;\r
     }\r
+\r
+    bool QuickAccessRadioButtonChangeLister::OnChange(UICheckBox::UICheckBoxState state)\r
+    {\r
+        SecondaryFunctionView *p_SecondaryFunctionView = SecondaryFunctionView::GetInstance();\r
+        if (p_SecondaryFunctionView == nullptr)\r
+        {\r
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SecondaryFunctionView GetInstance fail");\r
+            return false;\r
+        }\r
+        switch (state)\r
+        {\r
+        case UICheckBox::SELECTED:\r
+            if (p_SecondaryFunctionView->GetQuickAccessView() != nullptr)\r
+            {\r
+                if (p_SecondaryFunctionView->GetQuickAccessView()->GetRadioButton(0) == (UIView *)m_view)\r
+                {\r
+                    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Switched to heart rate monitoring app");\r
+                    return true;\r
+                }\r
+                else if (p_SecondaryFunctionView->GetQuickAccessView()->GetRadioButton(1) == (UIView *)m_view)\r
+                {\r
+                    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Switched to blood oxygen monitoring app");\r
+                    return true;\r
+                }\r
+            }\r
+            break;\r
+        case UICheckBox::UNSELECTED:\r
+            break;\r
+        default:\r
+            break;\r
+        }\r
+        return false;\r
+    }\r
 }
\ No newline at end of file
index c09f821..e76738b 100644 (file)
@@ -28,7 +28,7 @@ namespace OHOS
     {\r
         if (initViewStatus == true)\r
         {\r
-            SecondaryFunctionScrollView->RemoveAll();\r
+            SecondaryFunctionScrollView[SECONDARYFUNCTIONVIEW]->RemoveAll();\r
 \r
             delete SecondaryFunctionScrollTitleLabel;\r
             SecondaryFunctionScrollTitleLabel = nullptr;\r
@@ -51,8 +51,11 @@ namespace OHOS
                 Image[i] = nullptr;\r
             }\r
 \r
-            delete SecondaryFunctionScrollView;\r
-            SecondaryFunctionScrollView = nullptr;\r
+            delete p_QuickAccessView;\r
+            p_QuickAccessView = nullptr;\r
+\r
+            delete SecondaryFunctionScrollView[SECONDARYFUNCTIONVIEW];\r
+            SecondaryFunctionScrollView[SECONDARYFUNCTIONVIEW] = nullptr;\r
         }\r
     }\r
 \r
@@ -89,22 +92,25 @@ namespace OHOS
 \r
     bool SecondaryFunctionView::SecondaryFunctionScrollViewInit(void)\r
     {\r
-        SecondaryFunctionScrollView = new UIScrollView();\r
-        if (SecondaryFunctionScrollView == nullptr)\r
+        SecondaryFunctionScrollView[SECONDARYFUNCTIONVIEW] = new UIScrollView();\r
+        if (SecondaryFunctionScrollView[SECONDARYFUNCTIONVIEW] == nullptr)\r
         {\r
             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SecondaryFunctionView::SecondaryFunctionScrollView new fail!");\r
             return false;\r
         }\r
-        SecondaryFunctionScrollView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());\r
+        SecondaryFunctionScrollView[SECONDARYFUNCTIONVIEW]->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());\r
+        SecondaryFunctionScrollView[SECONDARYFUNCTIONVIEW]->SetScrollBlankSize(35);\r
+        SecondaryFunctionScrollView[SECONDARYFUNCTIONVIEW]->SetReboundSize(50);\r
+        SecondaryFunctionScrollView[SECONDARYFUNCTIONVIEW]->SetDirection(1);\r
         UIView::OnDragListener *draglistener = static_cast<UIView::OnDragListener *>(SecondaryFunctionPresenter::GetInstance());\r
         if (draglistener == nullptr)\r
         {\r
             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SecondaryFunctionView::draglistener can not be nullptr!");\r
             return false;\r
         }\r
-        SecondaryFunctionScrollView->SetOnDragListener(draglistener);\r
-        SecondaryFunctionScrollView->SetTouchable(true);\r
-        SecondaryFunctionScrollView->SetDraggable(true);\r
+        SecondaryFunctionScrollView[SECONDARYFUNCTIONVIEW]->SetOnDragListener(draglistener);\r
+        SecondaryFunctionScrollView[SECONDARYFUNCTIONVIEW]->SetTouchable(true);\r
+        SecondaryFunctionScrollView[SECONDARYFUNCTIONVIEW]->SetDraggable(true);\r
         return true;\r
     }\r
 \r
@@ -145,7 +151,6 @@ namespace OHOS
 \r
     bool SecondaryFunctionView::SecondaryFunctionScrollLabelInit(void)\r
     {\r
-        // 创建ScreenDurationTitleLabel\r
         LabelConfig labelconfig = {\r
             .left = 173,\r
             .top = 52,\r
@@ -234,6 +239,93 @@ namespace OHOS
         initViewStatus = true;\r
     }\r
 \r
+    QuickAccessView *SecondaryFunctionView::GetQuickAccessView(void)\r
+    {\r
+        return p_QuickAccessView;\r
+    }\r
+\r
+    UIScrollView *SecondaryFunctionView::GetSecondaryFunctionScrollView(int i)\r
+    {\r
+        return SecondaryFunctionScrollView[i];\r
+    }\r
+\r
+    // 切换到辅助功能视图\r
+    bool SecondaryFunctionView::ChangeSecondaryFunctionView(int16_t thisView)\r
+    {\r
+        if (SecondaryFunctionScrollView[thisView] == nullptr)\r
+        {\r
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SecondaryFunctionView::ChangeSecondaryFunctionView");\r
+            RootView::GetInstance()->Add(SecondaryFunctionScrollView[thisView]);\r
+        }\r
+        return true;\r
+    }\r
+\r
+    // 切换到快速访问视图\r
+    bool SecondaryFunctionView::ChangeQuickAccessView(int16_t thisView)\r
+    {\r
+        if (SecondaryFunctionScrollView[thisView] == nullptr)\r
+        {\r
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SecondaryFunctionView::ChangeQuickAccessView");\r
+            p_QuickAccessView = new QuickAccessView();\r
+            if (p_QuickAccessView == nullptr)\r
+            {\r
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SecondaryFunctionView:: new scrollView[%d] fail", thisView);\r
+                return false;\r
+            }\r
+            SecondaryFunctionScrollView[thisView] = p_QuickAccessView->QuickAccessViewInit();\r
+            RootView::GetInstance()->Add(SecondaryFunctionScrollView[thisView]);\r
+        }\r
+        return true;\r
+    }\r
+\r
+    /* -------------------------------------------------------------------------- */\r
+    // 1.SecondaryFunctionViewMapper:结构体定义了一个将视图ID映射到特定成员函数指针的映射表。\r
+    struct SecondaryFunctionViewMapper\r
+    {\r
+        const int16_t viewId;\r
+        bool (SecondaryFunctionView::*func)(int16_t thisView);\r
+    };\r
+\r
+    // 2.ViewMapper[] 是一个静态的视图映射数组,将视图ID与SecondaryFunctionView类中的特定成员函数指针进行了绑定。\r
+    static const SecondaryFunctionViewMapper ViewMapper[] = {\r
+        {SECONDARYFUNCTIONVIEW, &SecondaryFunctionView::ChangeSecondaryFunctionView},\r
+        {QUICKACCESSVIEW, &SecondaryFunctionView::ChangeQuickAccessView},\r
+    };\r
+\r
+    // 3.根据传入的interface参数执行相应视图ID关联的成员函数。\r
+    bool SecondaryFunctionView::ClickFunc(int16_t interface)\r
+    {\r
+        int funcSize = sizeof(ViewMapper) / sizeof(ViewMapper[0]);\r
+        for (int i = 0; i < funcSize; i++)\r
+        {\r
+            if (interface == ViewMapper[i].viewId)\r
+            {\r
+                bool jug = (this->*(ViewMapper[i].func))(interface);\r
+                if (jug == false)\r
+                {\r
+                    return false;\r
+                }\r
+                return true;\r
+            }\r
+        }\r
+        return false;\r
+    }\r
+\r
+    // 4.切换视图\r
+    void SecondaryFunctionView::ChangeView(int16_t hideView, int16_t showView)\r
+    {\r
+        if (hideView > MAX_SECONDARYFUNCTIONVIEWID)\r
+        {\r
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SecondaryFunctionView:: SECONDARYFUNCTIONVIEWID Overstep ones bounds");\r
+            return;\r
+        }\r
+        SecondaryFunctionScrollView[hideView]->SetVisible(false);\r
+        ClickFunc(showView);\r
+        SecondaryFunctionScrollView[showView]->SetVisible(true);\r
+        Draw();\r
+    }\r
+    /* -------------------------------------------------------------------------- */\r
+\r
     void SecondaryFunctionView::OnStart()\r
     {\r
         View<SecondaryFunctionPresenter>::OnStart();\r
@@ -243,14 +335,14 @@ namespace OHOS
     void SecondaryFunctionView::OnSetUpView()\r
     {\r
         View<SecondaryFunctionPresenter>::OnSetUpView();\r
-        SecondaryFunctionScrollView->Add(SecondaryFunctionScrollTitleLabel);\r
-        SecondaryFunctionScrollView->Add(QuickAccessButton);\r
-        SecondaryFunctionScrollView->Add(FastTrainingButton);\r
-        SecondaryFunctionScrollView->Add(QuickAccessLabel);\r
-        SecondaryFunctionScrollView->Add(FastTrainingLabel);\r
-        SecondaryFunctionScrollView->Add(Image[0]);\r
-        SecondaryFunctionScrollView->Add(Image[1]);\r
-        RootView::GetInstance()->Add(SecondaryFunctionScrollView);\r
+        SecondaryFunctionScrollView[SECONDARYFUNCTIONVIEW]->Add(SecondaryFunctionScrollTitleLabel);\r
+        SecondaryFunctionScrollView[SECONDARYFUNCTIONVIEW]->Add(QuickAccessButton);\r
+        SecondaryFunctionScrollView[SECONDARYFUNCTIONVIEW]->Add(FastTrainingButton);\r
+        SecondaryFunctionScrollView[SECONDARYFUNCTIONVIEW]->Add(QuickAccessLabel);\r
+        SecondaryFunctionScrollView[SECONDARYFUNCTIONVIEW]->Add(FastTrainingLabel);\r
+        SecondaryFunctionScrollView[SECONDARYFUNCTIONVIEW]->Add(Image[0]);\r
+        SecondaryFunctionScrollView[SECONDARYFUNCTIONVIEW]->Add(Image[1]);\r
+        RootView::GetInstance()->Add(SecondaryFunctionScrollView[SECONDARYFUNCTIONVIEW]);\r
         Draw();\r
     }\r
 \r