From 4add8327d973703f2d3ea0c25da2406508242e5d Mon Sep 17 00:00:00 2001 From: luozheng <1732036298@qq.com> Date: Thu, 29 Aug 2024 17:54:15 +0800 Subject: [PATCH] =?utf8?q?=E9=95=BF=E6=8C=89=E5=85=B3=E6=9C=BAsos=E6=A0=B9?= =?utf8?q?=E6=8D=AEfigma=E4=B8=8A=E8=AE=BE=E8=AE=A1=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../nativelauncher/include/UiConfig.h | 2 +- .../include/RebootAndShutdownPresenter.h | 3 +- .../include/RebootAndShutdownView.h | 42 ++- .../src/RebootAndShutdownModel.cpp | 4 +- .../src/RebootAndShutdownPresenter.cpp | 130 ++++--- .../src/RebootAndShutdownView.cpp | 341 +++++++++++++----- 6 files changed, 357 insertions(+), 165 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativelauncher/include/UiConfig.h b/code/sdk/application/wearable/fd230app/nativelauncher/include/UiConfig.h index e5a5847be..2005915b5 100644 --- a/code/sdk/application/wearable/fd230app/nativelauncher/include/UiConfig.h +++ b/code/sdk/application/wearable/fd230app/nativelauncher/include/UiConfig.h @@ -356,7 +356,7 @@ namespace OHOS static constexpr const char *PNG_SETTINGS_SHUTDOWN_AND_RESTART = APP_RES_PATH "/settings/SETTINGS_SHUTDOWN_AND_RESTART.bin"; // 关机和重启 static constexpr const char *PNG_SETTINGS_SETTTING_SHUTDOWN = APP_RES_PATH "/settings/SETTTING_SHUTDOWN.bin"; // 关机 static constexpr const char *PNG_SETTINGS_SETTTING_REBOOT = APP_RES_PATH "/settings/SETTTING_REBOOT.bin"; - static constexpr const char *PNG_SETTINGS_SETTTING_SOS = APP_RES_PATH "/settings/SOS.bin"; // 重启 + static constexpr const char *PNG_SETTINGS_SETTTING_SOS = APP_RES_PATH "/settings/SOS.bin"; static constexpr const char *PNG_SETTINGS_SETTTING_SHUTDOWN_1 = APP_RES_PATH "/settings/shutdown.bin"; /* ---------------------------------- 消息中心 ---------------------------------- */ static constexpr const char *PNG_Message_System = APP_RES_PATH "/message/system-icon.bin"; // 系统消息 diff --git a/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/include/RebootAndShutdownPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/include/RebootAndShutdownPresenter.h index 69347cef9..913f1c20c 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/include/RebootAndShutdownPresenter.h +++ b/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/include/RebootAndShutdownPresenter.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-07-18 14:26:31 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-07-31 10:43:04 + * @LastEditTime: 2024-08-29 17:05:11 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/include/RebootAndShutdownPresenter.h */ @@ -29,7 +29,6 @@ namespace OHOS RebootAndShutdownPresenter(); virtual ~RebootAndShutdownPresenter(); static RebootAndShutdownPresenter *GetInstance(); - bool GetIsShutDownImageAnimator(void); void OnStart() override; void OnResume() override; diff --git a/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/include/RebootAndShutdownView.h b/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/include/RebootAndShutdownView.h index 75e446851..29a6067b6 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/include/RebootAndShutdownView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/include/RebootAndShutdownView.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-07-18 14:25:53 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-07-31 09:48:48 + * @LastEditTime: 2024-08-29 17:11:51 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/include/RebootAndShutdownView.h */ #ifndef REBOOT_AND_SHUTDOWN_VIEW_H @@ -16,18 +16,20 @@ #include "components/ui_view_group.h" #include "rebootandshutdown/include/ShutDownImageAnimatorView.h" #include "rebootandshutdown/include/FactoryResetView.h" +#define IS_SLIDER_TO_SHUTDOWN 0 namespace OHOS { typedef enum : uint8_t { - REBOOTANDSHUTDOWN = 0, - SHUTDOWNANIMATOR, /*关机动画view*/ - FACTORYRESET, /*恢复出厂设置view*/ + REBOOTANDSHUTDOWN = 0, // 关机和SOS(Slice) + SHUTDOWNANIMATOR, // 关机动画视图(subview) + SHUTDOWNTIPVIEW, // 关机提示视图(subview) + FACTORYRESET, // 恢复出厂设置视图(subview) REBOOTANDSHUTDOWN_MAX, } REBOOTANDSHUTDOWNVIEWID; - static constexpr const char *SHUTDOWN_SLIDER_VIEWID = "shutdown_slider_viewid"; - static constexpr const char *REBOOT_SLIDER_VIEWID = "reboot_slider_viewid"; + static constexpr const char *SHUTDOWN_BUTTON_VIEWID = "shutdown_button_viewid"; + static constexpr const char *SOS_BUTTON_VIEWID = "sos_button_viewid"; static constexpr const char *FACTORYRESET_LABEL_VIEWID = "factoryreset_label_viewid"; static constexpr const char *REBOOT_AND_SHUTDOWN_GROUPVIEW = "reboot_and_shutdown_groupview"; @@ -39,10 +41,12 @@ namespace OHOS RebootAndShutdownView(); ~RebootAndShutdownView(); static RebootAndShutdownView *GetInstance(void); - UISlider *GetShutdownSlider(void); - UISlider *GetRebootSlider(void); + UIButton *GetButtonEnsure(); + UIButton *GetButtonCancel(); + UIScrollView *GetSystemShutdownScrollView(void); bool ChangeToRebootAndShutdownView(int16_t thisView); + bool ChangeToShutdownTipView(int16_t thisView); bool ChangeToShutDownAnimatorView(int16_t thisView); bool ChangeToFactoryResetView(int16_t thisView); void ChangeView(int16_t hideView, int16_t showView); @@ -79,6 +83,7 @@ namespace OHOS bool CreateRebootAndShutdownSlider(void); bool CreateRebootAndShutdownScrollView(void); bool CreateRebootAndShutdownGroupView(void); + bool CreateRebootAndShutdownButton(void); void CreateRebootAndShutdownView(void); void ClearAll(void); @@ -87,6 +92,7 @@ namespace OHOS UILabelExt *title{nullptr}; UILabelExt *factoryResetLabel{nullptr}; /*恢复出厂设置*/ +#if IS_SLIDER_TO_SHUTDOWN /*关机*/ UILabelExt *shutdownLabel{nullptr}; UISlider *shutdownSlider{nullptr}; @@ -96,7 +102,25 @@ namespace OHOS UILabelExt *rebootLabel{nullptr}; UISlider *rebootSlider{nullptr}; UIScrollView *rebootScrollView{nullptr}; - +#else + // 关机 + UILabelExt *shutdownLabel{nullptr}; + UIButton *shutdownButton{nullptr}; + /* -------------------------------------------------------------------------- */ + UIScrollView *SystemShutdownScrollView = nullptr; + UILabelExt *shutdowntitle{nullptr}; + UILabelExt *note{nullptr}; + UIImageView *image = nullptr; + UIButton *button_ensure = nullptr; + UIButton *button_cancel = nullptr; + UIViewGroup *ShutdownViewInit(void); + void ClearAllShutdownView(void); + /* -------------------------------------------------------------------------- */ + + // SOS + UILabelExt *sosLabel{nullptr}; + UIButton *sosButton{nullptr}; +#endif bool viewInitStatus{false}; }; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/RebootAndShutdownModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/RebootAndShutdownModel.cpp index 0f11bd09c..d320562e6 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/RebootAndShutdownModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/RebootAndShutdownModel.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-07-18 14:55:27 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-08-28 20:23:14 + * @LastEditTime: 2024-08-29 17:20:33 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/RebootAndShutdownModel.cpp */ @@ -92,7 +92,7 @@ namespace OHOS } // 切换到关机/重启卡片 - NativeAbility::GetInstance().EnterSlice(VIEW_SHUTDOWN_OR_REBOOT); + NativeAbility::GetInstance().EnterSlice(VIEW_REBOOTANDSHUTDOWN); } static void HandlePowerKeyLongPress(void) diff --git a/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/RebootAndShutdownPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/RebootAndShutdownPresenter.cpp index edffae194..d1263a9af 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/RebootAndShutdownPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/RebootAndShutdownPresenter.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-06-20 15:11:17 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-07-31 10:43:30 + * @LastEditTime: 2024-08-29 17:39:15 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/RebootAndShutdownPresenter.cpp */ #include "AppViewIDs.h" @@ -13,7 +13,7 @@ #include "rebootandshutdown/include/RebootAndShutdownPresenter.h" #include "rebootandshutdown/include/RebootAndShutdownView.h" #include "rebootandshutdown/include/RebootAndShutdownModel.h" - +#include "dial_sos_c.h" namespace OHOS { @@ -76,7 +76,7 @@ namespace OHOS WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownPresenter::OnClick"); if (strcmp(view.GetViewId(), FACTORYRESET_LABEL_VIEWID) == 0) // 进入出厂设置界面 { - RebootAndShutdownView::GetInstance()->ChangeView(REBOOTANDSHUTDOWN, FACTORYRESET); + view_->ChangeView(REBOOTANDSHUTDOWN, FACTORYRESET); return true; } else if (strcmp(view.GetViewId(), FACTORY_RESET_BUTTON_CHECK_ON) == 0) // 恢复出厂设置确认 @@ -86,24 +86,30 @@ namespace OHOS } else if (strcmp(view.GetViewId(), FACTORY_RESET_BUTTON_CHECK_OFF) == 0) // 恢复出厂设置取消 { - RebootAndShutdownView::GetInstance()->ChangeView(FACTORYRESET, REBOOTANDSHUTDOWN); + view_->ChangeView(FACTORYRESET, REBOOTANDSHUTDOWN); } - else if (strcmp(view.GetViewId(), SHUTDOWN_SLIDER_VIEWID) == 0) + else if (strcmp(view.GetViewId(), SHUTDOWN_BUTTON_VIEWID) == 0) // 进入关机提示视图 { - auto shutdownSlider = view_->GetShutdownSlider(); - if (shutdownSlider != nullptr) - { - shutdownSlider->SetValue(SLIDER_VALUE_MIN); - } + view_->ChangeView(REBOOTANDSHUTDOWN, SHUTDOWNTIPVIEW); } - else if (strcmp(view.GetViewId(), REBOOT_SLIDER_VIEWID) == 0) + else if (&view == view_->GetButtonEnsure()) // 关机确认 { - auto rebootSlider = view_->GetRebootSlider(); - if (rebootSlider != nullptr) - { - rebootSlider->SetValue(SLIDER_VALUE_MIN); - } + view_->ChangeView(SHUTDOWNTIPVIEW, SHUTDOWNANIMATOR); + start_shutdown_or_reboot(); + shutdown_reboot_prejobs(); + + ShutDownImageAnimatorView::GetInstance()->ShutDownImageAnimator_Start(true); + isShutDownImageAnimatorStart = true; + } + else if (&view == view_->GetButtonCancel()) // 关机取消 + { + view_->ChangeView(SHUTDOWNTIPVIEW, REBOOTANDSHUTDOWN); } + else if (strcmp(view.GetViewId(), SOS_BUTTON_VIEWID) == 0) + { + start_SOS_phone_dail(); + } + return true; } @@ -121,29 +127,22 @@ namespace OHOS bool RebootAndShutdownPresenter::OnDragEnd(UIView &view, const DragEvent &event) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownPresenter::OnDragEnd"); - UISlider *slider = dynamic_cast(&view); - if (slider != nullptr) + if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && RebootAndShutdownPresenter::X_DRAG_FLAG) { - if (slider == view_->GetRebootSlider() || slider == view_->GetShutdownSlider()) + if (strcmp(view.GetViewId(), REBOOT_AND_SHUTDOWN_GROUPVIEW) == 0) { - return true; + NativeAbility::GetInstance().Back(TransitionType::TRANSITION_BACK_TO_HEXAGONS); } - } - else - { - if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && RebootAndShutdownPresenter::X_DRAG_FLAG) + else if (strcmp(view.GetViewId(), FACTORY_RESET_GROUPVIEW) == 0) + { + view_->ChangeView(FACTORYRESET, REBOOTANDSHUTDOWN); + } + else if (&view == view_->GetSystemShutdownScrollView()) { - if (strcmp(view.GetViewId(), REBOOT_AND_SHUTDOWN_GROUPVIEW) == 0) - { - NativeAbility::GetInstance().Back(TransitionType::TRANSITION_BACK_TO_HEXAGONS); - } - else if (strcmp(view.GetViewId(), FACTORY_RESET_GROUPVIEW) == 0) - { - RebootAndShutdownView::GetInstance()->ChangeView(FACTORYRESET, REBOOTANDSHUTDOWN); - } - RebootAndShutdownPresenter::X_DRAG_FLAG = false; - return true; + view_->ChangeView(SHUTDOWNTIPVIEW, REBOOTANDSHUTDOWN); } + RebootAndShutdownPresenter::X_DRAG_FLAG = false; + return true; } return false; } @@ -169,40 +168,40 @@ namespace OHOS void RebootAndShutdownPresenter::OnRelease(int32_t value) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownPresenter::OnRelease,value = %d", value); - auto shutdownSlider = view_->GetShutdownSlider(); - auto rebootSlider = view_->GetRebootSlider(); + // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownPresenter::OnRelease,value = %d", value); + // auto shutdownSlider = view_->GetShutdownSlider(); + // auto rebootSlider = view_->GetRebootSlider(); - handleSlider(shutdownSlider, true); - handleSlider(rebootSlider, false); + // handleSlider(shutdownSlider, true); + // handleSlider(rebootSlider, false); } void RebootAndShutdownPresenter::handleSlider(UISlider *slider, bool isShutdown) { - if (!slider) - { - return; - } - - if (slider->GetValue() < SLIDER_VALUE_MAX) - { - slider->SetValue(SLIDER_VALUE_MIN); - } - else - { - slider->SetValue(SLIDER_VALUE_MAX); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s!!", isShutdown ? "关机" : "重启"); - view_->ChangeView(REBOOTANDSHUTDOWN, SHUTDOWNANIMATOR); - start_shutdown_or_reboot(); - shutdown_reboot_prejobs(); - - if (ShutDownImageAnimatorView::GetInstance() != nullptr && ShutDownImageAnimatorView::GetInstance()->GeShutDownImageAnimatorView() != nullptr) - { - ShutDownImageAnimatorView::GetInstance()->GeShutDownImageAnimatorView()->Start(); - isShutDownImageAnimatorStart = true; - } - isShutDownOperation = isShutdown; - } + // if (!slider) + // { + // return; + // } + + // if (slider->GetValue() < SLIDER_VALUE_MAX) + // { + // slider->SetValue(SLIDER_VALUE_MIN); + // } + // else + // { + // slider->SetValue(SLIDER_VALUE_MAX); + // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s!!", isShutdown ? "关机" : "重启"); + // view_->ChangeView(REBOOTANDSHUTDOWN, SHUTDOWNANIMATOR); + // start_shutdown_or_reboot(); + // shutdown_reboot_prejobs(); + + // if (ShutDownImageAnimatorView::GetInstance() != nullptr && ShutDownImageAnimatorView::GetInstance()->GeShutDownImageAnimatorView() != nullptr) + // { + // ShutDownImageAnimatorView::GetInstance()->GeShutDownImageAnimatorView()->Start(); + // isShutDownImageAnimatorStart = true; + // } + // isShutDownOperation = isShutdown; + // } } bool RebootAndShutdownPresenter::OnKeyAct(UIView &view, const KeyEvent &event) // 增加按键事件 @@ -221,9 +220,4 @@ namespace OHOS } return true; } - - bool RebootAndShutdownPresenter::GetIsShutDownImageAnimator(void) - { - return isShutDownImageAnimatorStart; - } } \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/RebootAndShutdownView.cpp b/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/RebootAndShutdownView.cpp index 00cdb9064..07cb13ab2 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/RebootAndShutdownView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/RebootAndShutdownView.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-07-18 14:26:08 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-07-31 10:08:26 + * @LastEditTime: 2024-08-29 17:14:57 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/RebootAndShutdownView.cpp */ @@ -34,18 +34,6 @@ namespace OHOS return g_pRebootAndShutdownView; } - /*获取关机滑动条*/ - UISlider *RebootAndShutdownView::GetShutdownSlider(void) - { - return shutdownSlider; - } - - /*获取重启滑动条*/ - UISlider *RebootAndShutdownView::GetRebootSlider(void) - { - return rebootSlider; - } - void RebootAndShutdownView::ClearAll(void) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownView::ClearAll"); @@ -57,7 +45,6 @@ namespace OHOS delete container_; container_ = nullptr; } - if (rebootAndShutdownGroupView[REBOOTANDSHUTDOWN] != nullptr) { rebootAndShutdownGroupView[REBOOTANDSHUTDOWN]->RemoveAll(); @@ -71,59 +58,44 @@ namespace OHOS delete factoryResetLabel; factoryResetLabel = nullptr; } - if (shutdownScrollView != nullptr) + if (shutdownLabel) { - shutdownScrollView->RemoveAll(); - - if (shutdownLabel != nullptr) - { - delete shutdownLabel; - shutdownLabel = nullptr; - } - - if (shutdownSlider != nullptr) - { - delete shutdownSlider; - shutdownSlider = nullptr; - } - - delete shutdownScrollView; - shutdownScrollView = nullptr; + delete shutdownLabel; + shutdownLabel = nullptr; } - if (rebootScrollView != nullptr) + if (shutdownButton) { - rebootScrollView->RemoveAll(); - - if (rebootSlider != nullptr) - { - delete rebootSlider; - rebootSlider = nullptr; - } - - if (rebootLabel != nullptr) - { - delete rebootLabel; - rebootLabel = nullptr; - } - - delete rebootScrollView; - rebootScrollView = nullptr; + delete shutdownButton; + shutdownButton = nullptr; + } + if (sosLabel) + { + delete sosLabel; + sosLabel = nullptr; + } + if (sosButton) + { + delete sosButton; + sosButton = nullptr; } delete rebootAndShutdownGroupView[REBOOTANDSHUTDOWN]; rebootAndShutdownGroupView[REBOOTANDSHUTDOWN] = nullptr; } - + ClearAllShutdownView(); if (shutDownImageAnimatorView != nullptr) { delete shutDownImageAnimatorView; shutDownImageAnimatorView = nullptr; } - if (factoryResetView != nullptr) { delete factoryResetView; factoryResetView = nullptr; } + for (int i = REBOOTANDSHUTDOWN; i < REBOOTANDSHUTDOWN_MAX; i++) + { + rebootAndShutdownGroupView[i] = nullptr; + } } } @@ -137,14 +109,7 @@ namespace OHOS label->SetPosition(labelconfig.left, labelconfig.top, labelconfig.width, labelconfig.height); label->SetStyle(STYLE_TEXT_FONT, labelconfig.fontSize); label->SetStyle(STYLE_LINE_HEIGHT, labelconfig.lineHeigh); - if (true == ConfigModel::GetInstance()->GetisFirstTimeStart() && ConfigModel::GetInstance()->GetLanguage() == -1) - { - label->SetText(labelconfig.text); - } - else - { - label->SetTextId(labelconfig.textId); - } + label->SetTextId(labelconfig.textId); label->SetLineBreakMode(labelconfig.lineBreakMode); label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); label->SetRollSpeed(70); @@ -162,7 +127,7 @@ namespace OHOS .height = 35, .fontSize = 30, .lineHeigh = 35, - .textId = STR_SHUTDOWN_AND_RESTART, /*关机和重启*/ + .textId = STR_SYSTEM, /*系统*/ .lineBreakMode = UILabel::LINE_BREAK_OSCILLATION, }; title = RebootAndShutdownLabelInit(labelConfig); @@ -173,14 +138,14 @@ namespace OHOS } /* -------------------------------------------------------------------------- */ labelConfig = { - .left = 110, - .top = 33, - .width = 240, + .left = 113, + .top = 271, + .width = 60, .height = 35, .fontSize = 30, .lineHeigh = 35, - .textId = STR_SLIDE_TO_SHUTDOWN, /*滑动关机 >>*/ - .text = "Slide to shutdown", + .textId = STR_SHUTDOWN, /*关机*/ + .text = "shutdown", .lineBreakMode = UILabel::LINE_BREAK_OSCILLATION, }; shutdownLabel = RebootAndShutdownLabelInit(labelConfig); @@ -192,16 +157,21 @@ namespace OHOS shutdownLabel->SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_CENTER); shutdownLabel->SetTextColor(Color::GetColorFromRGBA(0x66, 0x66, 0x66, 0xff)); /* -------------------------------------------------------------------------- */ - labelConfig.textId = STR_SLIDE_TO_REBOOT; /*滑动重启 >>*/ - labelConfig.text = "Slide to reboot"; - rebootLabel = RebootAndShutdownLabelInit(labelConfig); - if (rebootLabel == nullptr) + sosLabel = new UILabelExt(); + if (sosLabel == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "rebootLabel new fail!"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "sosLabel new fail!"); return false; } - rebootLabel->SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_CENTER); - rebootLabel->SetTextColor(Color::GetColorFromRGBA(0x66, 0x66, 0x66, 0xff)); + sosLabel->SetPosition(294, 271, 58, 35); + sosLabel->SetStyle(STYLE_TEXT_FONT, 30); + sosLabel->SetStyle(STYLE_LINE_HEIGHT, 35); + sosLabel->SetText("SOS"); + sosLabel->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION); + sosLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + sosLabel->SetRollSpeed(70); + sosLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + sosLabel->SetTextColor(Color::GetColorFromRGBA(0x66, 0x66, 0x66, 0xff)); /* -------------------------------------------------------------------------- */ labelConfig = { .left = 83, @@ -229,6 +199,7 @@ namespace OHOS bool RebootAndShutdownView::CreateRebootAndShutdownSlider(void) { +#if IS_SLIDER_TO_SHUTDOWN if (shutdownSlider == nullptr) { shutdownSlider = new UISlider(); @@ -285,13 +256,14 @@ namespace OHOS rebootSlider->SetOnClickListener(presenter_); rebootSlider->SetOnDragListener(presenter_); rebootSlider->SetSliderEventListener(presenter_); - +#endif return true; } bool RebootAndShutdownView::CreateRebootAndShutdownScrollView(void) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownView::CreateRebootAndShutdownScrollView"); +#if IS_SLIDER_TO_SHUTDOWN if (shutdownScrollView == nullptr) { shutdownScrollView = new UIScrollView(); @@ -326,7 +298,46 @@ namespace OHOS rebootScrollView->SetDraggable(true); rebootScrollView->SetIntercept(true); } +#endif + return true; + } + bool RebootAndShutdownView::CreateRebootAndShutdownButton(void) + { + if (shutdownButton == nullptr) + { + shutdownButton = new UIButton(); + if (shutdownButton == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "rebootAndShutdownGroupView[REBOOTANDSHUTDOWN] is new fail!!"); + return false; + } + shutdownButton->SetPosition(93, 160); + shutdownButton->Resize(100, 100); + shutdownButton->SetViewId(SHUTDOWN_BUTTON_VIEWID); + shutdownButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + shutdownButton->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + shutdownButton->SetImageSrc(PNG_SETTINGS_SETTTING_SHUTDOWN_1, PNG_SETTINGS_SETTTING_SHUTDOWN_1); + shutdownButton->SetStyleForState(STYLE_BACKGROUND_OPA, 0x00, UIButton::PRESSED); + shutdownButton->SetOnClickListener(presenter_); + } + if (sosButton == nullptr) + { + sosButton = new UIButton(); + if (sosButton == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "rebootAndShutdownGroupView[REBOOTANDSHUTDOWN] is new fail!!"); + return false; + } + sosButton->SetPosition(273, 160); + sosButton->Resize(100, 100); + sosButton->SetViewId(SOS_BUTTON_VIEWID); + sosButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + sosButton->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + sosButton->SetImageSrc(PNG_SETTINGS_SETTTING_SOS, PNG_SETTINGS_SETTTING_SOS); + sosButton->SetStyleForState(STYLE_BACKGROUND_OPA, 0x00, UIButton::PRESSED); + sosButton->SetOnClickListener(presenter_); + } return true; } @@ -354,22 +365,17 @@ namespace OHOS void RebootAndShutdownView::CreateRebootAndShutdownView(void) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownView::CreateRebootAndShutdownView"); - if (!CreateRebootAndShutdownGroupView() || !CreateRebootAndShutdownScrollView() || - !CreateRebootAndShutdownLabel() || !CreateRebootAndShutdownSlider()) + if (!CreateRebootAndShutdownGroupView() || !CreateRebootAndShutdownButton() || !CreateRebootAndShutdownLabel()) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownView::CreateRebootAndShutdownView fail!"); return; } rebootAndShutdownGroupView[REBOOTANDSHUTDOWN]->Add(title); - shutdownScrollView->Add(shutdownLabel); - shutdownScrollView->Add(shutdownSlider); - rebootAndShutdownGroupView[REBOOTANDSHUTDOWN]->Add(shutdownScrollView); - - rebootScrollView->Add(rebootLabel); - rebootScrollView->Add(rebootSlider); - rebootAndShutdownGroupView[REBOOTANDSHUTDOWN]->Add(rebootScrollView); + rebootAndShutdownGroupView[REBOOTANDSHUTDOWN]->Add(shutdownButton); + rebootAndShutdownGroupView[REBOOTANDSHUTDOWN]->Add(shutdownLabel); + rebootAndShutdownGroupView[REBOOTANDSHUTDOWN]->Add(sosButton); + rebootAndShutdownGroupView[REBOOTANDSHUTDOWN]->Add(sosLabel); rebootAndShutdownGroupView[REBOOTANDSHUTDOWN]->Add(factoryResetLabel); - container_->Add(rebootAndShutdownGroupView[REBOOTANDSHUTDOWN]); } @@ -430,6 +436,25 @@ namespace OHOS return true; } + // 切换到关机提示视图 + bool RebootAndShutdownView::ChangeToShutdownTipView(int16_t thisView) + { + if (rebootAndShutdownGroupView[thisView] == nullptr) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownView::ChangeToShutdownTipView"); + UIViewGroup *group = ShutdownViewInit(); + if (group == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group nullptr fail"); + return false; + } + rebootAndShutdownGroupView[thisView] = group; + container_->Add(rebootAndShutdownGroupView[thisView]); + } + return true; + } + + // 切换到关机动画视图 bool RebootAndShutdownView::ChangeToShutDownAnimatorView(int16_t thisView) { if (rebootAndShutdownGroupView[thisView] == nullptr) @@ -453,6 +478,7 @@ namespace OHOS return true; } + // 切换到恢复出厂设置视图 bool RebootAndShutdownView::ChangeToFactoryResetView(int16_t thisView) { if (rebootAndShutdownGroupView[thisView] == nullptr) @@ -485,8 +511,9 @@ namespace OHOS static const RebootAndShutdownViewMapper ViewMapper[] = { {REBOOTANDSHUTDOWN, &RebootAndShutdownView::ChangeToRebootAndShutdownView}, - {FACTORYRESET, &RebootAndShutdownView::ChangeToFactoryResetView}, + {SHUTDOWNTIPVIEW, &RebootAndShutdownView::ChangeToShutdownTipView}, {SHUTDOWNANIMATOR, &RebootAndShutdownView::ChangeToShutDownAnimatorView}, + {FACTORYRESET, &RebootAndShutdownView::ChangeToFactoryResetView}, }; bool RebootAndShutdownView::ClickFunc(int16_t interface) @@ -539,4 +566,152 @@ namespace OHOS rebootAndShutdownGroupView[showView]->SetVisible(true); Draw(); } + + UIButton *RebootAndShutdownView::GetButtonEnsure() + { + return button_ensure; + } + UIButton *RebootAndShutdownView::GetButtonCancel() + { + return button_cancel; + } + UIScrollView *RebootAndShutdownView::GetSystemShutdownScrollView(void) + { + return SystemShutdownScrollView; + } + + UIViewGroup *RebootAndShutdownView::ShutdownViewInit(void) + { + if (SystemShutdownScrollView == nullptr) + { + SystemShutdownScrollView = new UIScrollView(); + if (SystemShutdownScrollView == nullptr) + { + return nullptr; + } + SystemShutdownScrollView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); + SystemShutdownScrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + SystemShutdownScrollView->SetOnDragListener(presenter_); + SystemShutdownScrollView->SetTouchable(true); + SystemShutdownScrollView->SetDraggable(true); + /* -------------------------------------------------------------------------- */ + if (shutdowntitle == nullptr) + { + shutdowntitle = new UILabelExt(); + if (shutdowntitle == nullptr) + { + return nullptr; + } + shutdowntitle->SetPosition(83, 50, 300, 35); // 位置 + shutdowntitle->SetStyle(STYLE_TEXT_FONT, 30); // 字体大小 + shutdowntitle->SetStyle(STYLE_LINE_HEIGHT, 35); // 字体行高 + shutdowntitle->SetTextId(STR_SHUTDOWN); // 内容 + shutdowntitle->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION); + shutdowntitle->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + shutdowntitle->SetRollSpeed(70); + shutdowntitle->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + SystemShutdownScrollView->Add(shutdowntitle); + } + /* -------------------------------------------------------------------------- */ + if (image == nullptr) + { + image = new UIImageView(); + if (image == nullptr) + { + return nullptr; + } + image->SetPosition(196, 120, 74, 80); + image->SetSrc("/user/res/settings/SETTTING_SHUTDOWN.bin"); + } + SystemShutdownScrollView->Add(image); + /* -------------------------------------------------------------------------- */ + if (note == nullptr) + { + note = new UILabelExt(); + if (note == nullptr) + { + return nullptr; + } + note->SetPosition(53, 232, 360, 35); // 位置 + note->SetStyle(STYLE_TEXT_FONT, 30); // 字体大小 + note->SetStyle(STYLE_LINE_HEIGHT, 35); // 字体行高 + note->SetTextId(STR_SHUTDOWN_CONFIRM); + note->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION); + note->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + note->SetRollSpeed(70); + note->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + SystemShutdownScrollView->Add(note); + } + /* -------------------------------------------------------------------------- */ + button_cancel = new UIButton(); + if (button_cancel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemShutdown::new button_cancel fail!"); + return nullptr; + } + button_cancel->SetPosition(97, 299, 130, 130); + button_cancel->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); + button_cancel->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + button_cancel->SetImagePosition(15, 15); + button_cancel->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff191919, UIButton::PRESSED); + button_cancel->SetStyleForState(STYLE_BACKGROUND_OPA, 0x00, UIButton::PRESSED); + button_cancel->SetImageSrc(PNG_SYSTEM_CHECK_OFF_IMAGE, PNG_SYSTEM_CHECK_OFF_IMAGE); + SystemShutdownScrollView->Add(button_cancel); + /* ------------------------ button_ensure ----------------------- */ + button_ensure = new UIButton(); + if (button_ensure == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemShutdown::new button_ensure fail!"); + return nullptr; + } + button_ensure->SetPosition(240, 299, 130, 130); + button_ensure->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); + button_ensure->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + button_ensure->SetImagePosition(15, 15); + button_ensure->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff191919, UIButton::PRESSED); + button_ensure->SetStyleForState(STYLE_BACKGROUND_OPA, 0x00, UIButton::PRESSED); + button_ensure->SetImageSrc(PNG_SYSTEM_CHECK_ON_IMAGE, PNG_SYSTEM_CHECK_ON_IMAGE); + SystemShutdownScrollView->Add(button_ensure); + button_cancel->SetOnClickListener(presenter_); + button_ensure->SetOnClickListener(presenter_); + } + return SystemShutdownScrollView; + } + + void RebootAndShutdownView::ClearAllShutdownView(void) + { + if (SystemShutdownScrollView) + { + SystemShutdownScrollView->RemoveAll(); + + if (title) + { + delete title; + title = nullptr; + } + if (note) + { + delete note; + note = nullptr; + } + if (image) + { + delete image; + image = nullptr; + } + if (button_ensure) + { + delete button_ensure; + button_ensure = nullptr; + } + if (button_cancel) + { + delete button_cancel; + button_cancel = nullptr; + } + delete SystemShutdownScrollView; + SystemShutdownScrollView = nullptr; + } + } + } \ No newline at end of file -- 2.17.1