${ROOT_DIR}/open_source/openharmony/utils/native/lite/kv_store/innerkits
${CMAKE_CURRENT_SOURCE_DIR}/nativeui/schedule/include
+ ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/sleepmode/include
)
set(SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/nativeui/schedule/src/ScheduleModel.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nativeui/schedule/src/ScheduleListAdapter.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nativeui/schedule/src/ScheduleListItem.cpp
+ #sleep mode
+ ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/sleepmode/src/SleepModeView.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/sleepmode/src/SleepModePresenter.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/sleepmode/src/SleepModeModel.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nativeui/calculator/src/CalculatorView.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nativeui/calculator/src/CalculatorPresenter.cpp
VIEW_GOAL, // 每日目标
VIEW_CALCULATOR, // 计算器
VIEW_SCHEDULE, // schedule
+ VIEW_SLEEPMODE, // sleep mode
/*屏蔽Slice*/
VIEW_PHONERING, // 拨号界面
VIEW_PHONECALLING, // 来电
/* -------------------------------------------------------------------------- */
void InitCalculatorSlice(void);
void InitScheduleSlice(void);
+ void InitSleepModeSlice(void);
void InittestSlice(void);
private:
-/*\r
-* Copyright (c) xxxxxxxx Technologies Co., Ltd. 2021-2021. All rights reserved.\r
-* Description: language\r
-* Author: Graphic develop team\r
-* Create: 2021-07-06\r
-*/\r
-\r
-#ifndef UI_RESOURCE_STRING_H\r
-#define UI_RESOURCE_STRING_H\r
-#include <cstdint>\r
-namespace OHOS {\r
-enum UIResourceTextId : uint16_t {\r
+/*
+* Copyright (c) xxxxxxxx Technologies Co., Ltd. 2021-2021. All rights reserved.
+* Description: language
+* Author: Graphic develop team
+* Create: 2021-07-06
+*/
+
+#ifndef UI_RESOURCE_STRING_H
+#define UI_RESOURCE_STRING_H
+#include <cstdint>
+namespace OHOS {
+enum UIResourceTextId : uint16_t {
STR_EXERCISE_OUTDOORWALKING = 0,\r
STR_EXERCISE_OUTDOORRUNNING = 1,\r
STR_EXERCISE_OUTDOORBIKING = 2,\r
STR_SLEEP_MODE_PROMPT_ON = 547,\r
STR_MAX_ID = 548,\r
}; // UIResourceTextId\r
-\r
-enum FontLanguageId : uint8_t {\r
+
+enum FontLanguageId : uint8_t {
LANGUAGE_ID_ZH,\r
LANGUAGE_ID_EN,\r
LANGUAGE_ID_MAX\r
/* -------------------------------------------------------------------------- */
#include "schedule/include/SchedulePresenter.h"
#include "schedule/include/ScheduleData.h"
+#include "sleepmode/include/SleepModePresenter.h"
#ifdef SUPPORT_ALIPAY_SEC
#include "AlipayMainView.h"
#include "product_adapter.h"
#endif
#include "bleEvent.h"
+#include "../../../../../../drivers/peripheral/config/include/ConfigModelC.h"
namespace OHOS
{
/*智能助手*/
{VIEW_OFFLINEVOICE, &NativeLauncher::InitOfflineVoice},
{VIEW_SCHEDULE, &NativeLauncher::InitScheduleSlice},
+ {VIEW_SLEEPMODE, &NativeLauncher::InitSleepModeSlice},
#ifdef SUPPORT_ALIPAY_SEC
{VIEW_MAIN_ALIPAY, &NativeLauncher::InitMainAlipaySlice},
read_jsonHistory_weather();
C_ScheduleDataReadFromFile();
+ mmi_sleep_mode_switch_read();
}
void NativeLauncher::InitAllNativeSlices(void)
NativeAbility::GetInstance().AddSliceProxy(VIEW_SCHEDULE, t_View);
}
+ void NativeLauncher::InitSleepModeSlice(void)
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitSleepModeSlice");
+ SliceProxy *t_View = new AbilitySliceProxy<SleepModeView, SleepModePresenter>;
+ if (nullptr == t_View)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "View is nullptr");
+ return;
+ }
+ NativeAbility::GetInstance().AddSliceProxy(VIEW_SLEEPMODE, t_View);
+ }
+
}
#include "ui_service.h"
#include "notification_manager.h"
#include "../../../../../../../drivers/peripheral/config/include/ConfigModel.h"
-#include "../../../../../../../drivers/peripheral/utils/custom_runtime.h"
+#include "custom_runtime.h"
#ifdef __cplusplus
extern "C" {
void AlarmClockModel::PopInterPlayMusic()
{
- if(true == ConfigModel::GetInstance()->GetDnotdisturb() && (0 == uapi_dev_runtime_get_sleep_monitoring_status()))
+ if(true == ConfigModel::GetInstance()->GetDnotdisturb() || (uapi_sleep_mode_flag_get()))
{
return;
}
HealthService::GetInstance()->SetHealthCurrent(highHealthState);
viewId = VIEW_CHECK_INVALID;
}
- if(uapi_dev_runtime_get_sleep_monitoring_status())
+ if(uapi_sleep_mode_flag_get())
{
if(VIEW_DNOTDISTURB == viewId)
return false;
#include <cmsis_os.h>\r
#include "ConfigModel.h"\r
#include "ui_resource_string.h"\r
+#include "custom_runtime.h"\r
namespace OHOS\r
{\r
/* -------------------------------------------------------------------------- */\r
/*触发铃声的开始*/\r
void CountDownModel::RequestStartRingtone(void)\r
{\r
+ if(uapi_sleep_mode_flag_get())\r
+ {\r
+ return;\r
+ }\r
if (true != ConfigModel::GetInstance()->GetDnotdisturb())\r
{\r
PostRingtoneEvent(&CountDownModel::StartRingtonePlayback);\r
return false;
}
bool t_value = mmi_flip_wrist_switch_get();
- if(uapi_dev_runtime_get_sleep_monitoring_status())
+ if(uapi_sleep_mode_flag_get())
{
t_value = false;
}
}\r
if (strcmp(view.GetViewId(), BRINGHTNESSCONTROLBUTTON_VIEW) == 0)\r
{\r
- if(uapi_dev_runtime_get_sleep_monitoring_status())\r
+ if(uapi_sleep_mode_flag_get())\r
{\r
return false;\r
}\r
DisplayBrightnessScrollView[DISPLAYBRIGHTNESSVIEW]->Add(RaiseToBrightnessLabel);\r
DisplayBrightnessScrollView[DISPLAYBRIGHTNESSVIEW]->Add(RaiseToBrightnessCheckBoxButton);\r
\r
- if(uapi_dev_runtime_get_sleep_monitoring_status())\r
+ if(uapi_sleep_mode_flag_get())\r
{\r
RaiseToBrightnessCheckBoxButton->SetTouchable(false);\r
}\r
bool DnotDisturbModel::GetDoNotDisturbModeEnabled() const
{
- if(uapi_dev_runtime_get_sleep_monitoring_status())
+ if(uapi_sleep_mode_flag_get())
{
return true;
}
#include "heart_blood/CheckAbnormalView.h"
#include "vibrator_service.h"
+#include "custom_runtime.h"
namespace OHOS
{
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CheckAbnormalView::InitBloodView fail");
}
- if(true != OHOS::ConfigModel::GetInstance()->GetDnotdisturb())
+ if(true != OHOS::ConfigModel::GetInstance()->GetDnotdisturb() && (!uapi_sleep_mode_flag_get()))
{
ui_api_vibrate_once_func();
}
#include "heart_blood/health_service/health_service.h"
#include "vibrator_service.h"
+#include "custom_runtime.h"
namespace OHOS
{
}
SetViewData();
- if(true != OHOS::ConfigModel::GetInstance()->GetDnotdisturb())
+ if(true != OHOS::ConfigModel::GetInstance()->GetDnotdisturb() && (!uapi_sleep_mode_flag_get()))
{
// 震动提醒
ui_api_vibrate_once_func();
return true;
}
- if (uapi_dev_runtime_get_sleep_monitoring_status())
+ if (uapi_sleep_mode_flag_get())
{
if (VIEW_DNOTDISTURB == g_jumpView[curViewId])
{
#include "AppViewIDs.h"
#include "NativeAbility.h"
#include "dnotdisturb/include/DnotDisturbModel.h"
+#include "sleepmode/include/SleepModeModel.h"
#include "main/include/MainModel.h"
#include <custom_runtime.h>
#include "ConfigModel.h"
}
else if (viewId == DROPDOWN_SLEEP_TOGGLEBUTTON_VIEWID) // 睡眠开关
{
- state = toggleButton[DropDownCardPage1::toggleButton_SLEEP]->GetState();
+ if (uapi_sleep_mode_flag_get())
+ {
+ state = toggleButton[DropDownCardPage1::toggleButton_SLEEP]->GetState();
+ UpdateSleepModelState(state);
+ SleepModeModel::GetInstance().SetSleepModeDisabled();
+ // state = toggleButton[DropDownCardPage1::toggleButton_DNOTDISTURB]->GetState();
+ UpdateDnotdisturbState(DnotDisturbModel::GetInstance().GetDoNotDisturbModeEnabled());
+ }
+ else
+ {
+ NativeAbility::GetInstance().EnterSlice(VIEW_SLEEPMODE);
+ }
}
else if (viewId == DROPDOWN_DNOTDISTURB_TOGGLEBUTTON_VIEWID) // 勿扰开关
{
- if (uapi_dev_runtime_get_sleep_monitoring_status())
+ if (uapi_sleep_mode_flag_get())
{
return true;
}
bool state_bt = ConfigModel::GetInstance()->GetClassicBlueToothState(); // 传统蓝牙开关
bool state_4g = uapi_cat1_get_power_stat();
bool state_savepower = uapi_dev_runtime_get_saveele_status();
- bool state_sleep = uapi_dev_runtime_get_sleep_monitoring_status();
+ bool state_sleep = uapi_sleep_mode_flag_get();
bool state_dnotdisturb = DnotDisturbModel::GetInstance().GetDoNotDisturbModeEnabled();
ToggleButtonConfig toggleButtonConfig[] = {
--- /dev/null
+
+#ifndef __SLEEPMODEMODEL_H__
+#define __SLEEPMODEMODEL_H__
+
+
+namespace OHOS
+{
+ class SleepModeModel
+ {
+ public:
+ static SleepModeModel &GetInstance(void);
+ // void UpdateSleepMode(void);
+ void SetSleepModeEnabled(void);
+ void SetSleepModeDisabled(void);
+
+ private:
+ SleepModeModel();
+ SleepModeModel(const SleepModeModel &) = delete;
+ SleepModeModel &operator=(const SleepModeModel &) = delete;
+ virtual ~SleepModeModel();
+
+ };
+}
+
+#endif
\ No newline at end of file
--- /dev/null
+
+#ifndef __SLEEPMODEPRESENTER_H__
+#define __SLEEPMODEPRESENTER_H__
+
+#include "Presenter.h"
+#include "View.h"
+#include "sleepmode/include/SleepModeView.h"
+#include "sleepmode/include/SleepModeModel.h"
+
+
+namespace OHOS
+{
+ class SleepModeView;
+ class SleepModePresenter : public Presenter<SleepModeView>,
+ public UIView::OnClickListener,
+ public RootView::OnKeyActListener,
+ public UIView::OnDragListener
+ {
+ public:
+ SleepModePresenter();
+ virtual ~SleepModePresenter();
+
+ void OnStart() override;
+ void OnPause() override;
+ void OnResume() override;
+ void OnStop() override;
+
+ static SleepModePresenter *GetInstance();
+ // virtual void Notify() override;
+
+ 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 X_DRAG_FLAG{false};
+
+ SleepModeModel * SleepModeModel_{nullptr};
+ };
+}
+
+#endif
\ No newline at end of file
--- /dev/null
+
+#ifndef __SLEEPMODEVIEW_H__
+#define __SLEEPMODEVIEW_H__
+
+#include "BaseView.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_label_button_ext.h"
+
+
+namespace OHOS
+{
+ #define SLEEPMODE_ViewId_OKButton_ "SLEEPMODE_ViewId_OKButton_"
+
+ class SleepModePresenter;
+ class SleepModeView : public View<SleepModePresenter>
+ {
+ public:
+ SleepModeView();
+ virtual ~SleepModeView();
+ static SleepModeView * GetInstance(void);
+
+ void OnStart() override;
+ void OnSetUpView() override;
+ void OnTearDownView() override;
+ void OnStop() override;
+
+ private:
+ UIScrollView * InitScreen(void);
+ void DeinitScreen(void);
+
+ UIScrollView * ScrollView_{nullptr};
+ UILabelExt * TitleLabelExt_{nullptr};
+ UIImageView * PromptImage_{nullptr};
+ UILabelExt * PromptLabelExt_{nullptr};
+ UILabelButtonExt * CancelButton_{nullptr};
+ UILabelButtonExt * OKButton_{nullptr};
+
+
+ #define SCREEN_WIDTH (Screen::GetInstance().GetWidth())
+ #define SCREEN_HEIGHT (Screen::GetInstance().GetHeight())
+
+ #define SLEEP_MODE_PROMPT_IMAGE "/user/res/Sleepmode/sleepmode.bin"
+ };
+}
+#endif
\ No newline at end of file
--- /dev/null
+
+#include "sleepmode/include/SleepModeModel.h"
+#include "main/include/MainViewSample.h"
+#include "MainModel.h"
+#include "ConfigModel.h"
+#include "custom_runtime.h"
+#include "custom_utils.h"
+#include "ui_service.h"
+#include "ConfigModelC.h"
+#include "power_display_service.h"
+
+
+namespace OHOS
+{
+ SleepModeModel::SleepModeModel() {}
+
+ SleepModeModel::~SleepModeModel() {}
+
+ SleepModeModel &SleepModeModel::GetInstance()
+ {
+ static SleepModeModel instance;
+ return instance;
+ }
+
+ void SleepModeModel::SetSleepModeEnabled(void)
+ {
+ uapi_sleep_mode_flag_set(1);
+
+ // update donotdisturb
+ // SendMsgToUIService(UI_UPDATE_DNOTDISTURB_MODE, 0, nullptr, 0);
+
+ /*更新主界面配置*/
+ MainModel::GetInstance().setDialState(DialState::SLEEP, true);
+
+ // disable flip wrist
+ uapi_take_to_wake(0);
+
+ // turn down brightness
+ const power_display_svr_api_t *display_api = power_display_svr_get_api();
+ display_api->set_brightness(51);
+ }
+
+ void SleepModeModel::SetSleepModeDisabled(void)
+ {
+ uapi_sleep_mode_flag_set(0);
+
+ // update donotdisturb
+ // SendMsgToUIService(UI_UPDATE_DNOTDISTURB_MODE, 0, nullptr, 0);
+
+ /*更新主界面配置*/
+ MainModel::GetInstance().setDialState(DialState::SLEEP, false);
+
+ // enable flip wrist
+ if(true == mmi_flip_wrist_switch_get())
+ {
+ uapi_take_to_wake(1);
+ }
+
+ // reset brightness
+ const power_display_svr_api_t *display_api = power_display_svr_get_api();
+ display_api->set_brightness(OHOS::ConfigModel::GetInstance()->GetBrightness());
+ }
+
+ // /*更新勿扰模式*/
+ // void SleepModeModel::UpdateSleepMode(void)
+ // {
+ // if (PullUpDownView::GetInstance() != nullptr)
+ // {
+ // /*更新主界面下拉界面配置*/
+ // if(DropDownCardPage1::GetInstance() && DropDownCardPage1::GetInstance()->GetDropDownCardPage1_ToggleButton(DropDownCardPage1::toggleButton_DNOTDISTURB))
+ // {
+ // DropDownCardPage1::GetInstance()->GetDropDownCardPage1_ToggleButton(DropDownCardPage1::toggleButton_DNOTDISTURB)->SetState(GetSleepModeEnabled());
+ // }
+ // PullUpDownView::GetInstance()->UpdateSleepModeStatus(GetSleepModeEnabled());
+ // /*更新主界面配置*/
+ // MainModel::GetInstance().setDialState(DialState::DO_NOT_DISTURB, GetSleepModeEnabled());
+ // }
+ // return;
+ // }
+}
\ No newline at end of file
--- /dev/null
+
+#include "AppViewIDs.h"
+#include "NativeAbility.h"
+#include "UiConfig.h"
+#include "sleepmode/include/SleepModePresenter.h"
+#include "common/key_code.h"
+#include <custom_utils.h>
+
+
+namespace OHOS
+{
+ static SleepModePresenter * p_SleepModePresenterInstance = nullptr;
+
+ SleepModePresenter::SleepModePresenter()
+ {
+ SleepModeModel_ = &SleepModeModel::GetInstance();
+ p_SleepModePresenterInstance = this;
+ }
+
+ SleepModePresenter::~SleepModePresenter()
+ {
+ p_SleepModePresenterInstance = nullptr;
+ }
+
+ SleepModePresenter * SleepModePresenter::GetInstance()
+ {
+ return p_SleepModePresenterInstance;
+ }
+
+ void SleepModePresenter::OnStart()
+ {
+ Presenter<SleepModeView>::OnStart();
+ }
+
+ void SleepModePresenter::OnPause(void)
+ {
+ Presenter<SleepModeView>::OnPause();
+ }
+
+ void SleepModePresenter::OnResume(void)
+ {
+ Presenter<SleepModeView>::OnResume();
+ }
+
+ void SleepModePresenter::OnStop(void)
+ {
+ Presenter<SleepModeView>::OnStop();
+ }
+
+ bool SleepModePresenter::OnDrag(UIView &view, const DragEvent &event)
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SleepModePresenter::OnDrag");
+ UNUSED(view);
+ if ((event.GetDeltaX() > X_DRAG_OFFSET) && (event.GetDeltaX() > (DOUBLES * MATH_ABS(event.GetDeltaY())))) // 拖动过程中判断是否是水平滑动
+ {
+ SleepModePresenter::X_DRAG_FLAG = true;
+ }
+ return true;
+ }
+
+ bool SleepModePresenter::OnDragEnd(UIView &view, const DragEvent &event)
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SleepModePresenter::OnDragEnd");
+ UNUSED(event);
+ if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && SleepModePresenter::X_DRAG_FLAG)
+ {
+ NativeAbility::GetInstance().Back(TransitionType::TRANSITION_BACK_TO_HEXAGONS);
+ SleepModePresenter::X_DRAG_FLAG = false;
+ }
+ return true;
+ }
+
+ bool SleepModePresenter::OnClick(UIView &view, const ClickEvent &event)
+ {
+ UNUSED(event);
+
+ if(0 == strcmp(view.GetViewId(), SLEEPMODE_ViewId_OKButton_))
+ {
+ SleepModeModel_->SetSleepModeEnabled();
+ }
+
+ NativeAbility::GetInstance().Back(TransitionType::TRANSITION_BACK_TO_HEXAGONS);
+ return true;
+ }
+
+ // 增加按键事件
+ bool SleepModePresenter::OnKeyAct(UIView &view, const KeyEvent &event)
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SleepModePresenter::OnKeyAct");
+ uint16_t keyID = event.GetKeyId();
+ uint16_t keyState = event.GetState();
+ // 如果是power键就返回上一级
+ if (keyID == static_cast<uint16_t>(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 1 && uapi_get_screen_state() == 0)
+ {
+ NativeAbility::GetInstance().Back(TransitionType::TRANSITION_BACK_TO_HEXAGONS);
+ }
+ return true;
+ }
+
+ // void SleepModePresenter::Notify()
+ // {
+ // // SleepModeView::GetInstance()->UpdataTime();
+ // }
+}
\ No newline at end of file
--- /dev/null
+
+#include "sleepmode/include/SleepModeView.h"
+#include "sleepmode/include/SleepModePresenter.h"
+#include "sleepmode/include/SleepModeModel.h"
+#include "wearable_log.h"
+#include "UiConfig.h"
+#include "ui_resource_image.h"
+#include "uicomponents/UIComponents.h"
+#include "ui_resource_string.h"
+
+
+namespace OHOS
+{
+ static SleepModeView * p_SleepModeViewInstance = nullptr;
+
+ SleepModeView::SleepModeView()
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SleepModeView::SleepModeView");
+ p_SleepModeViewInstance = this;
+ }
+
+ SleepModeView::~SleepModeView()
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SleepModeView::~SleepModeView");
+ p_SleepModeViewInstance = nullptr;
+ }
+
+ SleepModeView * SleepModeView::GetInstance()
+ {
+ return p_SleepModeViewInstance;
+ }
+
+ void SleepModeView::OnStart()
+ {
+ View<SleepModePresenter>::OnStart();
+
+ SetContainerView(new UIViewGroup());
+ if (nullptr == GetContainer())
+ {
+ // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[%d]", __LINE__);
+ return;
+ }
+ container_->SetPosition(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
+ container_->SetTouchable(true);
+ container_->SetDraggable(true);
+
+ ScrollView_ = InitScreen();
+
+ container_->Add(ScrollView_);
+
+ RootView::GetInstance()->SetOnKeyActListener(presenter_);
+ }
+
+ void SleepModeView::OnSetUpView()
+ {
+ View<SleepModePresenter>::OnSetUpView();
+
+ Draw();
+ }
+
+ void SleepModeView::OnTearDownView()
+ {
+ View<SleepModePresenter>::OnTearDownView();
+ }
+
+ void SleepModeView::OnStop()
+ {
+ View<SleepModePresenter>::OnStop();
+ RootView::GetInstance()->ClearOnKeyActListener();
+
+ if (nullptr != container_)
+ {
+ container_->RemoveAll();
+
+ DeinitScreen();
+
+ delete container_;
+ container_ = nullptr;
+ }
+
+ return;
+ }
+
+ void SleepModeView::DeinitScreen()
+ {
+ if(nullptr != ScrollView_)
+ {
+ ScrollView_->RemoveAll();
+ if(nullptr != TitleLabelExt_)
+ {
+ delete TitleLabelExt_;
+ TitleLabelExt_ = nullptr;
+ }
+ if(nullptr != PromptImage_)
+ {
+ delete PromptImage_;
+ PromptImage_ = nullptr;
+ }
+ if(nullptr != PromptLabelExt_)
+ {
+ delete PromptLabelExt_;
+ PromptLabelExt_ = nullptr;
+ }
+ if(nullptr != CancelButton_)
+ {
+ delete CancelButton_;
+ CancelButton_ = nullptr;
+ }
+ if(nullptr != OKButton_)
+ {
+ delete OKButton_;
+ OKButton_ = nullptr;
+ }
+
+ delete ScrollView_;
+ ScrollView_ = nullptr;
+ }
+ }
+
+ UIScrollView * SleepModeView::InitScreen(void)
+ {
+ if (nullptr == ScrollView_)
+ {
+ ScrollView_ = new UIScrollView();
+ if (nullptr == ScrollView_)
+ return nullptr;
+
+ ScrollView_->SetPosition(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
+ // ScrollView_->SetViewId();
+ ScrollView_->SetStyle(STYLE_BACKGROUND_OPA, OPA_OPAQUE);
+ ScrollView_->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full);
+ ScrollView_->SetOnDragListener(presenter_);
+ ScrollView_->SetTouchable(true);
+ ScrollView_->SetDraggable(true);
+
+ if (nullptr == TitleLabelExt_)
+ {
+ TitleLabelExt_ = new UILabelExt();
+ if (nullptr == TitleLabelExt_)
+ return nullptr;
+
+ TitleLabelExt_->SetPosition(83, 50, 300, 35);
+ TitleLabelExt_->SetStyle(STYLE_TEXT_FONT, 30);
+ TitleLabelExt_->SetStyle(STYLE_LINE_HEIGHT, 35);
+ TitleLabelExt_->SetTextId(STR_SLEEPMODE);
+ TitleLabelExt_->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION);
+ TitleLabelExt_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+ TitleLabelExt_->SetRollSpeed(70);
+ TitleLabelExt_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
+ // TitleLabelExt_->SetStyle(STYLE_TEXT_COLOR, 0xffff5a36);
+ }
+
+ if (nullptr == PromptImage_)
+ {
+ PromptImage_ = new UIImageView();
+ if (nullptr == PromptImage_)
+ return nullptr;
+
+ PromptImage_->SetPosition(183, 107);
+ // PromptImage_->Resize(94, 94);
+ // PromptImage_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff8120e2);
+ // PromptImage_->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
+ // PromptImage_->SetStyle(STYLE_BORDER_RADIUS, 100);
+ // PromptImage_->SetAutoEnable(false);
+ // PromptImage_->SetResizeMode(UIImageView::CENTER);
+ PromptImage_->SetSrc(SLEEP_MODE_PROMPT_IMAGE);
+ }
+
+ if (nullptr == PromptLabelExt_)
+ {
+ PromptLabelExt_ = new UILabelExt();
+ if (nullptr == PromptLabelExt_)
+ return nullptr;
+
+ PromptLabelExt_->SetPosition(53, 230, 360, 70);
+ PromptLabelExt_->SetStyle(STYLE_TEXT_FONT, 30);
+ PromptLabelExt_->SetStyle(STYLE_LINE_HEIGHT, 35);
+ PromptLabelExt_->SetTextId(STR_SLEEP_MODE_PROMPT_ON);
+ PromptLabelExt_->SetLineBreakMode(UILabel::LINE_BREAK_WRAP);
+ PromptLabelExt_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+ PromptLabelExt_->SetRollSpeed(70);
+ PromptLabelExt_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
+ PromptLabelExt_->SetStyle(STYLE_TEXT_COLOR, 0Xff999999);
+ }
+
+ if (nullptr == CancelButton_)
+ {
+ CancelButton_ = new UILabelButtonExt();
+ if (nullptr == CancelButton_)
+ return nullptr;
+
+ CancelButton_->SetPosition(111, 320, 100, 100);
+ // CancelButton_->SetViewId(SCHEDULE_ViewId_DeleteCancelButton_);
+ CancelButton_->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff);
+ CancelButton_->SetStyle(STYLE_BACKGROUND_OPA, 25); // 10%
+ CancelButton_->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xffffffff, UIButton::PRESSED);
+ CancelButton_->SetStyleForState(STYLE_BACKGROUND_OPA, 25, UIButton::PRESSED);
+ CancelButton_->SetStyle(STYLE_BORDER_RADIUS, 100);
+ CancelButton_->SetImagePosition(0, 0);
+ CancelButton_->SetImageSrc(PNG_SYSTEM_CHECK_OFF_IMAGE, PNG_SYSTEM_CHECK_OFF_IMAGE);
+ CancelButton_->SetOnClickListener(presenter_);
+ }
+
+ if (nullptr == OKButton_)
+ {
+ OKButton_ = new UILabelButtonExt();
+ if (nullptr == OKButton_)
+ return nullptr;
+
+ OKButton_->SetPosition(256, 320, 100, 100);
+ OKButton_->SetViewId(SLEEPMODE_ViewId_OKButton_);
+ OKButton_->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff);
+ OKButton_->SetStyle(STYLE_BACKGROUND_OPA, 25); // 10%
+ OKButton_->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xffffffff, UIButton::PRESSED);
+ OKButton_->SetStyleForState(STYLE_BACKGROUND_OPA, 25, UIButton::PRESSED);
+ OKButton_->SetStyle(STYLE_BORDER_RADIUS, 100);
+ OKButton_->SetImagePosition(0, 0);
+ OKButton_->SetImageSrc(PNG_SYSTEM_CHECK_ON_IMAGE, PNG_SYSTEM_CHECK_ON_IMAGE);
+ OKButton_->SetOnClickListener(presenter_);
+ }
+
+ ScrollView_->Add(TitleLabelExt_);
+ ScrollView_->Add(PromptImage_);
+ ScrollView_->Add(PromptLabelExt_);
+ ScrollView_->Add(CancelButton_);
+ ScrollView_->Add(OKButton_);
+ }
+
+ return ScrollView_;
+ }
+}
\ No newline at end of file
if (sportdata->heart >= maxHeartRate)
{
uapi_set_screen_on_api(); // 亮屏检测
- if (true != OHOS::ConfigModel::GetInstance()->GetDnotdisturb())
+ if (true != OHOS::ConfigModel::GetInstance()->GetDnotdisturb() && (!uapi_sleep_mode_flag_get()))
{
ui_api_vibrate_once_func();
}
}
void Set_RaiseToWake(bool value) //抬婉亮屏开关
{
- if(uapi_dev_runtime_get_sleep_monitoring_status())
+ if(uapi_sleep_mode_flag_get())
{
return;
}
}
display_api->set_screen_set_keepon_timeout(10);
- if(true != ConfigModel::GetInstance()->GetDnotdisturb())
+ if(true != ConfigModel::GetInstance()->GetDnotdisturb() && (!uapi_sleep_mode_flag_get()))
{
AlarmClockModel::GetInstance()->AlarmPlayerStart();
}
#include <power_display_service.h>
#include <custom_utils.h>
#include "vibrator_service.h"
+#include "../../../../../../../drivers/peripheral/utils/custom_runtime.h"
namespace OHOS
{
{
/*亮屏加震动*/
uapi_set_screen_on_api();
- if(true != ConfigModel::GetInstance()->GetDnotdisturb())
+ if(true != ConfigModel::GetInstance()->GetDnotdisturb() && (!uapi_sleep_mode_flag_get()))
{
// uapi_vibrationModeSet(ConfigModel::GetInstance()->GetVibrationReminder());
ui_api_vibrate_once_func();
#include <cmsis_os2.h>
#include <cmsis_os.h>
#include "vibrator_service.h"
+#include "../../../../../../../drivers/peripheral/utils/custom_runtime.h"
namespace OHOS
{
void FindWatchViewEventListener::SetVibration(void)
{
- if(true == ConfigModel::GetInstance()->GetDnotdisturb())
+ if(true == ConfigModel::GetInstance()->GetDnotdisturb() || (uapi_sleep_mode_flag_get()))
{
return;
}
{
ScreenTurnOn(-1); // 亮屏操作
- if(true == ConfigModel::GetInstance()->GetDnotdisturb())
+ if(true == ConfigModel::GetInstance()->GetDnotdisturb() || (uapi_sleep_mode_flag_get()))
{
return;
}
#include "string"
#include "vibrator_service.h"
#include "../../../../../../../drivers/peripheral/config/include/ConfigModel.h"
+#include "../../../../../../../drivers/peripheral/utils/custom_runtime.h"
namespace OHOS
{
MessageGroupView->Add(messageLabel);
MessageGroupView->Add(deleteButton);
- if (true != OHOS::ConfigModel::GetInstance()->GetDnotdisturb())
+ if (true != OHOS::ConfigModel::GetInstance()->GetDnotdisturb() && (!uapi_sleep_mode_flag_get()))
{
// 震动提醒
ui_api_vibrate_once_func();
#include "UiConfig.h"
#include "ConfigModel.h"
#include "alarm/include/AlarmClockModel.h"
+#include "../../../../../../../drivers/peripheral/utils/custom_runtime.h"
namespace OHOS
{
WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Create SleepGroupView succeed!!");
- if (true != OHOS::ConfigModel::GetInstance()->GetDnotdisturb())
+ if (true != OHOS::ConfigModel::GetInstance()->GetDnotdisturb() && (!uapi_sleep_mode_flag_get()))
{
ui_api_vibrate_once_func();
}
SleepGroupView->Add(closebutton);
WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Create SleepGroupView succeed!!");
- if (true != OHOS::ConfigModel::GetInstance()->GetDnotdisturb())
+ if (true != OHOS::ConfigModel::GetInstance()->GetDnotdisturb() && (!uapi_sleep_mode_flag_get()))
{
ui_api_vibrate_once_func();
}
static errcode_t power_display_set_brightness(uint8_t brightness)
{
+ if(uapi_sleep_mode_flag_get()) // in sleep mode, cannot change brightness
+ {
+ brightness = 51;
+ }
+
message_type_t mt = SET_BRIGHTNESS_CMD;
uint32_t event_info = brightness;
#ifndef SUPPORT_AT_OHOSFWK
-/*\r
-* Copyright (c) xxxxxxxx Technologies Co., Ltd. 2021-2021. All rights reserved.\r
-* Description: language\r
-* Author: Graphic develop team\r
-* Create: 2021-07-06\r
-*/\r
-\r
-#ifndef UI_RESOURCE_STRING_H\r
-#define UI_RESOURCE_STRING_H\r
-#include <cstdint>\r
-namespace OHOS {\r
-enum UIResourceTextId : uint16_t {\r
+/*
+* Copyright (c) xxxxxxxx Technologies Co., Ltd. 2021-2021. All rights reserved.
+* Description: language
+* Author: Graphic develop team
+* Create: 2021-07-06
+*/
+
+#ifndef UI_RESOURCE_STRING_H
+#define UI_RESOURCE_STRING_H
+#include <cstdint>
+namespace OHOS {
+enum UIResourceTextId : uint16_t {
STR_EXERCISE_OUTDOORWALKING = 0,\r
STR_EXERCISE_OUTDOORRUNNING = 1,\r
STR_EXERCISE_OUTDOORBIKING = 2,\r
STR_SLEEP_MODE_PROMPT_ON = 547,\r
STR_MAX_ID = 548,\r
}; // UIResourceTextId\r
-\r
-enum FontLanguageId : uint8_t {\r
+
+enum FontLanguageId : uint8_t {
LANGUAGE_ID_ZH,\r
LANGUAGE_ID_EN,\r
LANGUAGE_ID_MAX\r
#define CONFIG_DEBUG
#endif
#include "../../../../../drivers/peripheral/vibrator/service/vibrator_service.h"
+#include "../../../../../application/wearable/fd230app/nativeui/sleepmode/include/SleepModeModel.h"
// #define DEBUG_LINE() printf("%s %d\n",__func__,__LINE__)
namespace OHOS
{
uint8_t flag = (OHOS::ConfigModel::GetInstance()->get_configData_int(OHOS::ConfigModel::CONFIGMODEL_ITEM_SLEEP_MODE_SWITCH));
uapi_sleep_mode_flag_set(flag);
+ if(flag)
+ {
+ OHOS::SleepModeModel::GetInstance().SetSleepModeEnabled();
+ }
}
// sleep mode switch set
// play audio judgement
bool mmi_play_audio_is_permitted(void)
{
+ if(uapi_sleep_mode_flag_get())
+ {
+ return false;
+ }
if(true == (OHOS::ConfigModel::GetInstance()->GetDnotdisturb()))
{
return false;
// play vibrate judgement
bool mmi_play_vibrate_is_permitted(void)
{
+ if(uapi_sleep_mode_flag_get())
+ {
+ return false;
+ }
if(true == (OHOS::ConfigModel::GetInstance()->GetDnotdisturb()))
{
return false;
void shutdown_reboot_prejobs_task(void)
{
C_ScheduleDataWriteToFile();
+ mmi_sleep_mode_switch_write();
uapi_save_time_of_day();
//保存步数
-/*\r
-* Copyright (c) xxxxxxxx Technologies Co., Ltd. 2021-2021. All rights reserved.\r
-* Description: language\r
-* Author: Graphic develop team\r
-* Create: 2021-07-06\r
-*/\r
-\r
-#ifndef UI_RESOURCE_STRING_H\r
-#define UI_RESOURCE_STRING_H\r
-#include <cstdint>\r
-namespace OHOS {\r
-enum UIResourceTextId : uint16_t {\r
+/*
+* Copyright (c) xxxxxxxx Technologies Co., Ltd. 2021-2021. All rights reserved.
+* Description: language
+* Author: Graphic develop team
+* Create: 2021-07-06
+*/
+
+#ifndef UI_RESOURCE_STRING_H
+#define UI_RESOURCE_STRING_H
+#include <cstdint>
+namespace OHOS {
+enum UIResourceTextId : uint16_t {
STR_EXERCISE_OUTDOORWALKING = 0,\r
STR_EXERCISE_OUTDOORRUNNING = 1,\r
STR_EXERCISE_OUTDOORBIKING = 2,\r
STR_SLEEP_MODE_PROMPT_ON = 547,\r
STR_MAX_ID = 548,\r
}; // UIResourceTextId\r
-\r
-enum FontLanguageId : uint8_t {\r
+
+enum FontLanguageId : uint8_t {
LANGUAGE_ID_ZH,\r
LANGUAGE_ID_EN,\r
LANGUAGE_ID_MAX\r