From ccc3f8b4f41c83be59561cf0e91768eedca291a9 Mon Sep 17 00:00:00 2001 From: luozheng <1732036298@qq.com> Date: Fri, 23 Aug 2024 15:32:17 +0800 Subject: [PATCH] =?utf8?q?=E4=B8=8B=E6=8B=89=E7=95=8C=E9=9D=A2=E4=BC=98?= =?utf8?q?=E5=8C=96=E4=BF=AE=E6=94=B9=EF=BC=9A=E5=8B=BF=E6=89=B0=E6=A8=A1?= =?utf8?q?=E5=BC=8F=E9=9C=80=E5=BC=80=E5=90=AF=E8=BF=9B=E5=85=A5=E8=AF=A5S?= =?utf8?q?lice=EF=BC=8C=E5=85=B3=E9=97=AD=E5=88=99=E5=9C=A8=E4=B8=8B?= =?utf8?q?=E6=8B=89=E7=95=8C=E9=9D=A2=E5=BF=AB=E6=8D=B7=E5=85=B3=E9=97=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../dnotdisturb/src/DnotDisturbModel.cpp | 5 ++-- .../main/include/dropdown/DropDownCardPage1.h | 3 +- .../main/src/dropdown/DropDownCardPage1.cpp | 30 ++++++++++++++++--- 3 files changed, 31 insertions(+), 7 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/dnotdisturb/src/DnotDisturbModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/dnotdisturb/src/DnotDisturbModel.cpp index fd110dcfc..f186f5569 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/dnotdisturb/src/DnotDisturbModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/dnotdisturb/src/DnotDisturbModel.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-08-20 19:16:00 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-08-22 18:57:46 + * @LastEditTime: 2024-08-23 15:12:45 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/dnotdisturb/src/DnotDisturbModel.cpp */ #include "dnotdisturb/include/DnotDisturbModel.h" @@ -50,7 +50,8 @@ namespace OHOS /*更新主界面下拉界面配置*/ if(DropDownCardPage1::GetInstance() && DropDownCardPage1::GetInstance()->GetDropDownCardPage1_ToggleButton(DropDownCardPage1::toggleButton_DNOTDISTURB)) { - DropDownCardPage1::GetInstance()->GetDropDownCardPage1_ToggleButton(DropDownCardPage1::toggleButton_DNOTDISTURB)->SetState(GetDoNotDisturbModeEnabled()); + // DropDownCardPage1::GetInstance()->GetDropDownCardPage1_ToggleButton(DropDownCardPage1::toggleButton_DNOTDISTURB)->SetState(GetDoNotDisturbModeEnabled()); + DropDownCardPage1::GetInstance()->UpdateDnotdisturbState(GetDoNotDisturbModeEnabled()); } PullUpDownView::GetInstance()->UpdateDnotDisturbStatus(GetDoNotDisturbModeEnabled()); /*更新主界面配置*/ diff --git a/code/sdk/application/wearable/fd230app/nativeui/main/include/dropdown/DropDownCardPage1.h b/code/sdk/application/wearable/fd230app/nativeui/main/include/dropdown/DropDownCardPage1.h index 0b9fa6740..a424858d6 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/main/include/dropdown/DropDownCardPage1.h +++ b/code/sdk/application/wearable/fd230app/nativeui/main/include/dropdown/DropDownCardPage1.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-08-21 11:54:00 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-08-22 17:38:26 + * @LastEditTime: 2024-08-23 15:00:47 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/main/include/dropdown/DropDownCardPage1.h */ #ifndef __DROPDOWN_CARD_PAGE1_H__ @@ -49,6 +49,7 @@ namespace OHOS void ClearAll(); UIToggleButton *GetDropDownCardPage1_ToggleButton(int index); + void UpdateDnotdisturbState(bool state); private: UIToggleButton *ToggleButtonInit(ToggleButtonConfig &toggleButtonConfig); diff --git a/code/sdk/application/wearable/fd230app/nativeui/main/src/dropdown/DropDownCardPage1.cpp b/code/sdk/application/wearable/fd230app/nativeui/main/src/dropdown/DropDownCardPage1.cpp index cb118b07a..acf961624 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/main/src/dropdown/DropDownCardPage1.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/main/src/dropdown/DropDownCardPage1.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-08-21 11:54:00 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-08-22 18:54:22 + * @LastEditTime: 2024-08-23 15:26:00 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/main/src/dropdown/DropDownCardPage1.cpp */ #include "main/include/dropdown/DropDownCardPage1.h" @@ -122,8 +122,21 @@ namespace OHOS } else if (viewId == DROPDOWN_DNOTDISTURB_TOGGLEBUTTON_VIEWID) // 勿扰开关 { - state = toggleButton[DropDownCardPage1::toggleButton_DNOTDISTURB]->GetState(); - DnotDisturbModel::GetInstance().SetDoNotDisturbModeEnabled(state); + if (uapi_dev_runtime_get_sleep_monitoring_status()) + { + return true; + } + + if (DnotDisturbModel::GetInstance().GetDoNotDisturbModeEnabled() == false) + { + NativeAbility::GetInstance().EnterSlice(VIEW_DNOTDISTURB); + } + else + { + state = toggleButton[DropDownCardPage1::toggleButton_DNOTDISTURB]->GetState(); + UpdateDnotdisturbState(state); + DnotDisturbModel::GetInstance().SetDoNotDisturbModeEnabled(state); + } } else if (viewId == DROPDOWN_SETTING_TOGGLEBUTTON_VIEWID) // 设置 { @@ -181,7 +194,7 @@ namespace OHOS {220, 0, 100, 100, DROPDOWN_ALIPAY_TOGGLEBUTTON_VIEWID, DROPDOWN_ALIPAY_IMAGE, DROPDOWN_ALIPAY_IMAGE, true, true}, {330, 0, 100, 100, DROPDOWN_SAVEPOWER_TOGGLEBUTTON_VIEWID, state_savepower ? DROPDOWN_SAVEPOWER_ON_IMAGE : DROPDOWN_SAVEPOWER_OFF_IMAGE, state_savepower ? DROPDOWN_SAVEPOWER_ON_IMAGE : DROPDOWN_SAVEPOWER_OFF_IMAGE, true, state_savepower}, {55, 100, 100, 100, DROPDOWN_SLEEP_TOGGLEBUTTON_VIEWID, DROPDOWN_SLEEP_ON_IMAGE, DROPDOWN_SLEEP_OFF_IMAGE, true, state_sleep}, - {165, 100, 100, 100, DROPDOWN_DNOTDISTURB_TOGGLEBUTTON_VIEWID, DROPDOWN_DNOTDISTURB_ON_IMAGE, DROPDOWN_DNOTDISTURB_OFF_IMAGE, true, state_dnotdisturb}, + {165, 100, 100, 100, DROPDOWN_DNOTDISTURB_TOGGLEBUTTON_VIEWID, state_dnotdisturb ? DROPDOWN_DNOTDISTURB_ON_IMAGE : DROPDOWN_DNOTDISTURB_OFF_IMAGE, state_dnotdisturb ? DROPDOWN_DNOTDISTURB_ON_IMAGE : DROPDOWN_DNOTDISTURB_OFF_IMAGE, true, state_dnotdisturb}, {275, 100, 100, 100, DROPDOWN_SETTING_TOGGLEBUTTON_VIEWID, DROPDOWN_SETTING_IMAGE, DROPDOWN_SETTING_IMAGE, true, true}, }; @@ -217,4 +230,13 @@ namespace OHOS { return toggleButton[index]; } + + void DropDownCardPage1::UpdateDnotdisturbState(bool state) + { + if (toggleButton[DropDownCardPage1::toggleButton_DNOTDISTURB] != nullptr) + { + const char *ImageSrc = state ? DROPDOWN_DNOTDISTURB_ON_IMAGE : DROPDOWN_DNOTDISTURB_OFF_IMAGE; + toggleButton[DropDownCardPage1::toggleButton_DNOTDISTURB]->SetImages(ImageSrc, ImageSrc); + } + } } \ No newline at end of file -- 2.17.1