增加息屏显示slice 1902/1 1902/head 1905/target/1
authorxue <2144439972@qq.com>
Mon, 30 Jun 2025 02:03:36 +0000 (10:03 +0800)
committerxue <2144439972@qq.com>
Mon, 30 Jun 2025 02:03:36 +0000 (10:03 +0800)
code/sdk/application/wearable/fd230/nativeapp/CMakeLists.txt
code/sdk/application/wearable/fd230/nativeapp/nativelauncher/include/AppViewIDs.h
code/sdk/application/wearable/fd230/nativeapp/nativeui/set_aod/include/SetAodDialPresenter.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/set_aod/include/SetAodDialView.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/set_aod/src/SetAodDialPresenter.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/set_aod/src/SetAodDialView.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/set_dial_style/src/SetDialStyleView.cpp
code/sdk/application/wearable/fd230/nativeapp/nativeui/settings/src/SettingModel.cpp

index 4c110e3..caf3b33 100644 (file)
@@ -37,6 +37,7 @@ set(PRIVATE_HEADER
     ${NativeApp}/nativeui/add_card/include
     ${NativeApp}/nativeui/set_dial/include
     ${NativeApp}/nativeui/set_dial_style/include
+    ${NativeApp}/nativeui/set_aod/include
     ${NativeApp}/nativeui/key/include
     ${NativeApp}/nativeui/player/include
     ${NativeApp}/nativeui/applist/include
index 96c027d..113ef87 100644 (file)
@@ -55,6 +55,7 @@ typedef enum : uint16_t
   VIEW_BRIGHTNESSLEVEL,           // 亮度调节
   VIEW_NETWORKANDCALL,            // 网络与通话
   VIEW_MOTION_RECOGNITION,        // 运动识别
+  VIEW_SET_AODDIAL,               // 息屏显示
   VIEW_SYSTEM_UPDATE,             // 系统更新
   VIEW_WATCH_QR_CODE,             // 手表二维码
   VIEW_RESPIRATORY_TRAINING,      // 呼吸训练
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/set_aod/include/SetAodDialPresenter.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/set_aod/include/SetAodDialPresenter.h
new file mode 100644 (file)
index 0000000..4192e0e
--- /dev/null
@@ -0,0 +1,38 @@
+#ifndef SET_DIAL_AOD_PRESENTER_H
+#define SET_DIAL_AOD_PRESENTER_H
+
+#include "Presenter.h"
+#include "View.h"
+#include "components/ui_toggle_button.h"
+
+namespace OHOS
+{
+    class SetAodDialView;
+    class SetAodDialPresenter : public Presenter<SetAodDialView>,
+                                public UIView::OnClickListener,
+                                public RootView::OnKeyActListener,
+                                public UICheckBox::OnChangeListener,
+                                public UIView::OnDragListener
+    {
+    public:
+        SetAodDialPresenter();
+        virtual ~SetAodDialPresenter();
+
+        void OnStart() override;
+        void OnPause() override;
+        void OnResume() override;
+        void OnStop() override;
+
+        static SetAodDialPresenter *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; // 增加按键事件
+        bool OnChange(UICheckBox::UICheckBoxState state);
+        bool X_DRAG_FLAG { false };
+    };
+}
+
+#endif
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/set_aod/include/SetAodDialView.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/set_aod/include/SetAodDialView.h
new file mode 100644 (file)
index 0000000..a65cdc1
--- /dev/null
@@ -0,0 +1,34 @@
+#ifndef SET_DIAL_AOD_VIEW_H
+#define SET_DIAL_AOD_VIEW_H
+
+#include "View.h"
+
+#include "components/ui_scroll_view.h"
+#include "components/ui_label_ext.h"
+#include "components/ui_image_view.h"
+#include "components/ui_toggle_button.h"
+namespace OHOS
+{
+    class SetAodDialPresenter;
+    class SetAodDialView : public View<SetAodDialPresenter>
+    {
+
+    public:
+        SetAodDialView();
+        virtual ~SetAodDialView();
+        static SetAodDialView *GetInstance(void);
+        void OnStart() override;
+
+    private :
+        void SetAodDialViewInit(void);
+        void ClearAll(void);
+        UIScrollView *scrollView = nullptr;
+        UILabelExt *Title = nullptr;
+        UIImageView *SetAodDialImage = nullptr;
+        UILabelExt *SetAodDialLabel = nullptr;
+        UIToggleButton *SetAodDialToggleButton = nullptr;
+        UILabelExt *note{nullptr};
+        bool viewInitStatus{false};
+    };
+}
+#endif
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/set_aod/src/SetAodDialPresenter.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/set_aod/src/SetAodDialPresenter.cpp
new file mode 100644 (file)
index 0000000..d846656
--- /dev/null
@@ -0,0 +1,119 @@
+#include "AppViewIDs.h"
+#include "NativeAbility.h"
+#include "set_aod/include/SetAodDialPresenter.h"
+#include "set_aod/include/SetAodDialView.h"
+#include "common/key_code.h"
+#include <custom_utils.h>
+#include "ConfigModel.h"
+#include <UiConfig.h>
+#include "custom_runtime.h"
+
+#include "NativeRegisterManager.h"
+#include "MainModel.h"
+
+namespace OHOS
+{
+
+    REGIST_SLICE(VIEW_SET_AODDIAL, SetAodDialView, SetAodDialPresenter);
+
+    // 当前Presenter属性实例化的内存指针
+    static SetAodDialPresenter *g_pSetAodDialPresenter = nullptr;
+
+    SetAodDialPresenter::SetAodDialPresenter()
+    {
+        g_pSetAodDialPresenter = this;
+    }
+
+    SetAodDialPresenter::~SetAodDialPresenter()
+    {
+        g_pSetAodDialPresenter = nullptr;
+    }
+
+    SetAodDialPresenter *SetAodDialPresenter::GetInstance()
+    {
+        return g_pSetAodDialPresenter;
+    }
+
+    void SetAodDialPresenter::OnStart()
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetAodDialView::OnStart");
+        Presenter<SetAodDialView>::OnStart();
+    }
+
+    void SetAodDialPresenter::OnPause(void)
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetAodDialView::OnPause");
+        Presenter<SetAodDialView>::OnPause();
+    }
+
+    void SetAodDialPresenter::OnResume(void)
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetAodDialView::OnResume");
+        Presenter<SetAodDialView>::OnResume();
+    }
+
+    void SetAodDialPresenter::OnStop(void)
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetAodDialView::OnStop");
+        Presenter<SetAodDialView>::OnStop();
+    }
+
+    bool SetAodDialPresenter::OnClick(UIView &view, const ClickEvent &event)
+    {
+        UNUSED(view);
+        UNUSED(event);
+        return true;
+    }
+    bool SetAodDialPresenter::OnChange(UICheckBox::UICheckBoxState state)
+    {
+        switch (state)
+        {
+        case UICheckBox::SELECTED:
+            MainModel::GetInstance().EnableAod(true);
+            break;
+        case UICheckBox::UNSELECTED:
+            MainModel::GetInstance().EnableAod(false);
+            break;
+        default:
+            break;
+        }
+        return true;
+    }
+
+    bool SetAodDialPresenter::OnDrag(UIView &view, const DragEvent &event)
+    {
+        UNUSED(view);
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetAodDialPresenter::OnDrag");
+        if ((event.GetDeltaX() > X_DRAG_OFFSET) && (event.GetDeltaX() > (DOUBLES * MATH_ABS(event.GetDeltaY())))) // 拖动过程中判断是否是水平滑动
+        {
+            X_DRAG_FLAG = true;
+        }
+        return true;
+    }
+
+    bool SetAodDialPresenter::OnDragEnd(UIView &view, const DragEvent &event)
+    {
+        UNUSED(view);
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetAodDialPresenter::OnDragEnd");
+        if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && X_DRAG_FLAG)
+        {
+            NativeAbility::GetInstance().Back();
+            X_DRAG_FLAG = false;
+        }
+        return true;
+    }
+
+    bool SetAodDialPresenter::OnKeyAct(UIView &view, const KeyEvent &event) // 增加按键事件
+    {
+        UNUSED(view);
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetAodDialPresenter::OnKeyAct");
+        unsigned short keyID = event.GetKeyId();
+        unsigned short 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;
+    }
+}
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/set_aod/src/SetAodDialView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/set_aod/src/SetAodDialView.cpp
new file mode 100644 (file)
index 0000000..79e665d
--- /dev/null
@@ -0,0 +1,182 @@
+#include "set_aod/include/SetAodDialPresenter.h"
+#include "set_aod/include/SetAodDialView.h"
+#include "wearable_log.h"
+#include "ConfigModel.h"
+#include <ui_resource_string.h>
+#include <UiConfig.h>
+#include "MainModel.h"
+namespace OHOS
+{
+
+    static SetAodDialView *g_pSetAodDialView{nullptr};
+
+    SetAodDialView::SetAodDialView()
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetAodDialView::SetAodDialView");
+        g_pSetAodDialView = this;
+    }
+
+    SetAodDialView::~SetAodDialView()
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetAodDialView::~SetAodDialView");
+
+        g_pSetAodDialView = nullptr;
+    }
+
+    SetAodDialView *SetAodDialView::GetInstance()
+    {
+        return g_pSetAodDialView;
+    }
+
+    void SetAodDialView::ClearAll(void)
+    {
+        if (scrollView != nullptr)
+        {
+            scrollView->RemoveAll();
+
+            if (Title != nullptr)
+            {
+                delete Title;
+                Title = nullptr;
+            }
+
+            if (SetAodDialImage != nullptr)
+            {
+                delete SetAodDialImage;
+                SetAodDialImage = nullptr;
+            }
+            if (SetAodDialLabel != nullptr)
+            {
+                delete SetAodDialLabel;
+                SetAodDialLabel = nullptr;
+            }
+
+            if (SetAodDialToggleButton != nullptr)
+            {
+                delete SetAodDialToggleButton;
+                SetAodDialToggleButton = nullptr;
+            }
+            if (note != nullptr)
+            {
+                delete note;
+                note = nullptr;
+            }
+
+            scrollView->ClearFocus();
+            delete scrollView;
+            scrollView = nullptr;
+        }
+    }
+
+    void SetAodDialView::SetAodDialViewInit(void)
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetAodDialView::SetAodDialViewInit");
+        if (scrollView == nullptr)
+        {
+            scrollView = new UIScrollView();
+            scrollView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());
+            scrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
+            scrollView->SetScrollBlankSize(50);
+            scrollView->SetHorizontalScrollState(false);
+            scrollView->SetReboundSize(35);
+            scrollView->SetOnDragListener(presenter_);
+            scrollView->RequestFocus();
+            scrollView->SetRotateFactor(1.0);
+            /* -------------------------------------------------------------------------- */
+            Title = new UILabelExt();
+            if (Title == nullptr)
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SetAodDialView::Title can not be nullptr!");
+                return;
+            }
+            Title->SetPosition(83, 50, 300, 40);
+            Title->SetStyle(STYLE_TEXT_FONT, 30);
+            Title->SetStyle(STYLE_LINE_HEIGHT, 35);
+            Title->SetText("AOD表盘"); /*AOD表盘*/
+            Title->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION);
+            Title->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+            Title->SetRollSpeed(23);
+            Title->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
+            Title->SetVisible(true);
+            /* -------------------------------------------------------------------------- */
+            if (SetAodDialImage == nullptr)
+            {
+                SetAodDialImage = new UIImageView();
+            }
+            SetAodDialImage->SetPosition(43, 120, 380, 100);
+            SetAodDialImage->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);
+            SetAodDialImage->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
+            SetAodDialImage->SetStyle(STYLE_BORDER_RADIUS, 100);
+            /* -------------------------------------------------------------------------- */
+            SetAodDialLabel = new UILabelExt();
+            if (SetAodDialLabel == nullptr)
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SetAodDialView::SetAodDialLabel can not be nullptr!");
+                return;
+            }
+            SetAodDialLabel->SetPosition(90, 153, 180, 40);
+            SetAodDialLabel->SetStyle(STYLE_TEXT_FONT, 30);
+            SetAodDialLabel->SetStyle(STYLE_LINE_HEIGHT, 35);
+            SetAodDialLabel->SetText("息屏显示"); /*息屏显示*/
+            SetAodDialLabel->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE);
+            SetAodDialLabel->SetRollSpeed(23);
+            SetAodDialLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
+            /* -------------------------------------------------------------------------- */
+            SetAodDialToggleButton = new UIToggleButton();
+            if (SetAodDialToggleButton == nullptr)
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "LanguageSwitchView::SetAodDialToggleButton is nullptr!");
+                return;
+            }
+            SetAodDialToggleButton->SetPosition(298, 145, 100, 50);
+            SetAodDialToggleButton->SetStyle(STYLE_BACKGROUND_OPA, 0x00);
+            SetAodDialToggleButton->SetImages(PNG_TOGGLEBUTTON_ON_IMAGE, PNG_TOGGLEBUTTON_OFF_IMAGE);
+            SetAodDialToggleButton->SetState(MainModel::GetInstance().IsAodEnabled());
+            /* ----------------------------- onclickListener ---------------------------- */
+            SetAodDialToggleButton->SetOnChangeListener(presenter_);
+            /* -------------------------------------------------------------------------- */
+            if (note == nullptr)
+            {
+                note = new UILabelExt();
+                if (note == nullptr)
+                {
+                    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SetAodDialView::note can not be nullptr!");
+                    return;
+                }
+            }
+            note->SetPosition(63, SetAodDialImage->GetY() + SetAodDialImage->GetHeight() + 20, 340, 80);
+            note->SetStyle(STYLE_TEXT_FONT, 20);
+            note->SetStyle(STYLE_LINE_HEIGHT, 40);
+            note->SetTextColor(Color::GetColorFromRGBA(0x99, 0x99, 0x99, 0xff));
+            note->SetText("开启后,手表在在息屏状态下也会显示时间等信息,但同时会增加耗电"); // 开启后,手表在在息屏状态下也会显示时间等信息。
+            note->SetLineBreakMode(UILabel::LINE_BREAK_WRAP);
+            note->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20);
+            /* -------------------------------------------------------------------------- */
+
+            viewInitStatus = true;
+            /* -------------------------------------------------------------------------- */
+        }
+    }
+
+    void SetAodDialView::OnStart()
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetAodDialView::OnStart");
+        View<SetAodDialPresenter>::OnStart();
+
+        if (!viewInitStatus)
+        {
+            SetAodDialViewInit();
+        }
+
+        // 增加按键监听
+        // GetRootContainer()->SetOnKeyActListener(presenter_);
+
+        scrollView->Add(Title);
+        scrollView->Add(SetAodDialImage);
+        scrollView->Add(SetAodDialLabel);
+        scrollView->Add(SetAodDialToggleButton);
+        scrollView->Add(note);
+        AddViewToRootContainer(scrollView);
+        RootView::GetInstance()->SetOnKeyActListener(presenter_);
+    }
+}
\ No newline at end of file
index 7d786aa..54c08a7 100644 (file)
@@ -40,22 +40,15 @@ void SetDialStyleView::OnStart()
     labelCover_.SetText("Coverflow");
     AddViewToRootContainer(&labelCover_);
 
-    labelRoller_.SetPosition(ROLLER_X, Y2, LABEL_WIDTH, LABEL_HEIGHT);
+    labelRoller_.SetPosition(ENABLE_X, Y2, LABEL_WIDTH, LABEL_HEIGHT);
     labelRoller_.SetText("Roller");
     AddViewToRootContainer(&labelRoller_);
 
     btnCover_.SetPosition(COVER_X, Y1, BTN_WIDTH, BTN_HEIGHT);
     AddViewToRootContainer(&btnCover_);
-    btnRoller_.SetPosition(ROLLER_X, Y1, BTN_WIDTH, BTN_HEIGHT);
+    btnRoller_.SetPosition(ENABLE_X, Y1, BTN_WIDTH, BTN_HEIGHT);
     AddViewToRootContainer(&btnRoller_);
 
-    labelEnableAod_.SetPosition(ENABLE_X, Y2, LABEL_WIDTH, LABEL_HEIGHT);
-    labelEnableAod_.SetText("打开熄屏显示");
-    AddViewToRootContainer(&labelEnableAod_);
-    btnEnableAod_.SetPosition(ENABLE_X, Y1, BTN_WIDTH, BTN_HEIGHT);
-    AddViewToRootContainer(&btnEnableAod_);
-    btnEnableAod_.SetState(MainModel::GetInstance().IsAodEnabled());
-
     const DialStyle style = SetDialStyleModel::GetInstance().GetStyle();
     int len = sizeof(styleTable_) / sizeof(styleTable_[0]);
     for (int i = 0; i < len; ++i) {
@@ -68,7 +61,6 @@ void SetDialStyleView::OnStart()
 
     btnCover_.SetOnClickListener(presenter_);
     btnRoller_.SetOnClickListener(presenter_);
-    btnEnableAod_.SetOnClickListener(presenter_);
 }
 
 void SetDialStyleView::OnClick(UIView &view)
@@ -77,10 +69,6 @@ void SetDialStyleView::OnClick(UIView &view)
     if (ptr == nullptr) {
         return;
     }
-    if (ptr == &btnEnableAod_) {
-        MainModel::GetInstance().EnableAod(ptr->GetState());
-        return;
-    }
     int len = sizeof(styleTable_) / sizeof(styleTable_[0]);
     for (int i = 0; i < len; ++i) {
         if (ptr == styleTable_[i].btn) {
index 2767889..ccc559b 100644 (file)
@@ -41,6 +41,7 @@ namespace OHOS
         settings[index++] = {VIEW_SOUND_VIBRATION, PNG_SETTINGS_SOUND_VIBRATION, STR_SOUND_AND_VIBRATION, true};
         settings[index++] = {VIEW_THEME_STYLE, PNG_SETTINGS_DISPLAY_MODE, STR_DISPLAY_MODE, true};
         settings[index++] = {VIEW_MOTION_RECOGNITION, PNG_SETTINGS_MOTION_RECOGNITION, STR_MOTION_RECOGNITION, true};
+        settings[index++] = {VIEW_SET_AODDIAL, PNG_SETTINGS_MOTION_RECOGNITION, STR_MOTION_RECOGNITION, true};
         settings[index++] = {VIEW_DNOTDISTURB, PNG_SETTINGS_DISTURB_IMAGE, STR_DO_NOT_DISTURB, true};
         settings[index++] = {VIEW_ADD_CARD, PNG_SETTINGS_CARDSET_IMAGE, STR_CARD_MANAGEMENT, true};
         settings[index++] = {VIEW_SET_DIAL_STYLE, PNG_SETTINGS_CHANGEDIAL_IMAGE, STR_DIAL_BROWSING_SPECIAL_EFFECTS, true};