From: luozheng <1732036298@qq.com> Date: Tue, 16 Apr 2024 03:44:29 +0000 (+0800) Subject: 优化勿扰模式,用ConfigModel保存勿扰模式状态 X-Git-Tag: release_V1.2.70_20241020_135402~1185^2~5 X-Git-Url: http://git.snicker.com.cn/?a=commitdiff_plain;h=3b6ed149ed67bbe01fe2f488c59c631b7913861c;p=mirrors%2FFD230.git 优化勿扰模式,用ConfigModel保存勿扰模式状态 --- diff --git a/code/sdk/application/wearable/fd230app/nativeui/config/include/ConfigModel.h b/code/sdk/application/wearable/fd230app/nativeui/config/include/ConfigModel.h index 23514d196..ec34b9e1e 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/config/include/ConfigModel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/config/include/ConfigModel.h @@ -63,6 +63,7 @@ namespace OHOS CONFIGMODEL_ITEM_SPORTS_GOAL_STANDUP_TIMES, //运动目标站立次数 CONFIGMODEL_ITEM_SPORTS_GOAL_DURATION, //运动目标时长 CONFIGMODEL_ITEM_SPORTS_GOAL_DISTANCE, //运动目标距离 + CONFIGMODEL_ITEM_DNOTDISTURB,//勿扰模式 CONFIGMODEL_ITEM_MAX, } ; @@ -134,6 +135,9 @@ namespace OHOS void SetCat1_4Gability(bool state); bool GetCat1_4Gability(); + + void SetDnotdisturb(bool state); + bool GetDnotdisturb(void); // -------------------------------------------------------------------------- */ private: @@ -169,6 +173,7 @@ namespace OHOS {ConfigDataType::DATATYPE_INT, "GoalStandupTimes", "10" },// CONFIGMODEL_ITEM_SPORTS_GOAL_STANDUP_TIMES, //运动目标站立次数 10 {ConfigDataType::DATATYPE_INT, "GoalDuration", "30" },// CONFIGMODEL_ITEM_SPORTS_GOAL_DURATION, //运动目标时长 30(分钟) {ConfigDataType::DATATYPE_DOUBLE, "GoalDistance", "8.0" },// CONFIGMODEL_ITEM_SPORTS_GOAL_DISTANCE, //运动目标距离 8.0(km) + {ConfigDataType::DATATYPE_BOOL, "Dnotdisturb", "false" },// CONFIGMODEL_ITEM_DNOTDISTURB //勿扰模式默认关闭 }; ConfigModel(); // 私有构造函数,确保无法在外部实例化 ConfigModel(const ConfigModel &) = delete; // 禁止拷贝构造 diff --git a/code/sdk/application/wearable/fd230app/nativeui/config/src/ConfigModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/config/src/ConfigModel.cpp index e64594fb3..7c2d619ca 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/config/src/ConfigModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/config/src/ConfigModel.cpp @@ -609,6 +609,18 @@ namespace OHOS return get_configData_bool(CONFIGMODEL_ITEM_CAT1_SERVICE_ON); } + /*设置勿扰模式是否开启*/ + void ConfigModel::SetDnotdisturb(bool state) + { + set_condigData_Bool(CONFIGMODEL_ITEM_DNOTDISTURB,state); + } + + /*获取勿扰模式是否开启*/ + bool ConfigModel::GetDnotdisturb(void) + { + return get_configData_bool(CONFIGMODEL_ITEM_DNOTDISTURB); + } + /* ---------------------------------------------------------------------------- */ int ConfigModel::get_configData_int(ConfigItem item) { diff --git a/code/sdk/application/wearable/fd230app/nativeui/dnotdisturb/include/DnotDisturbModel.h b/code/sdk/application/wearable/fd230app/nativeui/dnotdisturb/include/DnotDisturbModel.h index 749756079..311041d84 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/dnotdisturb/include/DnotDisturbModel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/dnotdisturb/include/DnotDisturbModel.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-04-10 16:38:44 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-04-10 16:44:52 + * @LastEditTime: 2024-04-16 11:40:33 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/dnotdisturb/include/DnotDisturbModel.h */ #ifndef DNOTDISTURB_MODEL_H @@ -23,7 +23,7 @@ namespace OHOS DnotDisturbModel &operator=(const DnotDisturbModel &) = delete; virtual ~DnotDisturbModel(); - bool isDoNotDisturbModeEnabled = false; // 默认勿扰模式未开启 + //bool isDoNotDisturbModeEnabled = false; // 默认勿扰模式未开启 }; } 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 d0711a63a..480ebf51d 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/dnotdisturb/src/DnotDisturbModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/dnotdisturb/src/DnotDisturbModel.cpp @@ -1,5 +1,12 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-04-10 16:38:52 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-04-16 11:37:40 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/dnotdisturb/src/DnotDisturbModel.cpp + */ #include "dnotdisturb/include/DnotDisturbModel.h" - +#include "config/include/ConfigModel.h" namespace OHOS { @@ -15,11 +22,13 @@ namespace OHOS void DnotDisturbModel::SetDoNotDisturbModeEnabled(bool enabled) { - isDoNotDisturbModeEnabled = enabled; + //isDoNotDisturbModeEnabled = enabled; + ConfigModel::GetInstance()->SetDnotdisturb(enabled); } bool DnotDisturbModel::GetDoNotDisturbModeEnabled() const { - return isDoNotDisturbModeEnabled; + //return isDoNotDisturbModeEnabled; + return ConfigModel::GetInstance()->GetDnotdisturb(); } } \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/dnotdisturb/src/DnotDisturbPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/dnotdisturb/src/DnotDisturbPresenter.cpp index 5c21d5f7e..8148416ad 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/dnotdisturb/src/DnotDisturbPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/dnotdisturb/src/DnotDisturbPresenter.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-04-10 11:58:37 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-04-10 16:45:23 + * @LastEditTime: 2024-04-16 11:09:23 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/dnotdisturb/src/DnotDisturbPresenter.cpp */ #include "AppViewIDs.h" @@ -76,7 +76,7 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DnotDisturbView::GetInstance fail!!"); return false; } - if (&view == p_DnotDisturbView->GetButtonOn()) + if (&view == p_DnotDisturbView->GetButtonOn())//开启勿扰模式 { DnotDisturbModel::GetInstance().SetDoNotDisturbModeEnabled(true); uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId(); @@ -84,7 +84,7 @@ namespace OHOS } else if (&view == p_DnotDisturbView->GetButtonOff()) { - DnotDisturbModel::GetInstance().SetDoNotDisturbModeEnabled(false); + //DnotDisturbModel::GetInstance().SetDoNotDisturbModeEnabled(false); uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId(); NativeAbility::GetInstance().ChangeSlice(preSlice); } diff --git a/code/sdk/application/wearable/fd230app/nativeui/main/include/PullUpDownView.h b/code/sdk/application/wearable/fd230app/nativeui/main/include/PullUpDownView.h index 95bc5b842..b065eda3e 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/main/include/PullUpDownView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/main/include/PullUpDownView.h @@ -70,7 +70,7 @@ namespace OHOS bool InitView(); void PreLoad(void) override; void UpdateBlueToothStatus(int status); - + void UpdateDnotDisturbStatus(int status); private: UIImageView *dropSetting{nullptr}; // 设置 UIImageView *dropLighting{nullptr}; // 亮屏 diff --git a/code/sdk/application/wearable/fd230app/nativeui/main/src/MainPresenterSample.cpp b/code/sdk/application/wearable/fd230app/nativeui/main/src/MainPresenterSample.cpp index b2574e17d..570a00ea2 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/main/src/MainPresenterSample.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/main/src/MainPresenterSample.cpp @@ -26,6 +26,7 @@ #include "DialModelPower.h" #include "gfx_utils/mem_check.h" #include "traing/training_card/include/Training_CardView.h" +#include "dnotdisturb/include/DnotDisturbModel.h" #if USE_OFFLINE_DIAL #include "DialViewGroup.h" #endif @@ -136,6 +137,14 @@ namespace OHOS #endif } + //如果勿扰模式是开启状态,在下拉界面点击勿扰快捷入口会关闭勿扰模式不进入勿扰视图 + if(g_jumpView[curViewId] == VIEW_DNOTDISTURB && DnotDisturbModel::GetInstance().GetDoNotDisturbModeEnabled() == true) + { + PullUpDownView::GetInstance()->UpdateDnotDisturbStatus(false); + DnotDisturbModel::GetInstance().SetDoNotDisturbModeEnabled(false); + return true; + } + if (g_jumpView.count(curViewId) != 0) { NativeAbility::GetInstance().ChangeSlice(g_jumpView[curViewId]); diff --git a/code/sdk/application/wearable/fd230app/nativeui/main/src/PullUpDownView.cpp b/code/sdk/application/wearable/fd230app/nativeui/main/src/PullUpDownView.cpp index ce32050d9..54da4875f 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/main/src/PullUpDownView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/main/src/PullUpDownView.cpp @@ -489,4 +489,26 @@ namespace OHOS return; } + /*更新勿扰模式状态*/ + void PullUpDownView::UpdateDnotDisturbStatus(int status) + { + if (dropIconBackground[DNOTDISTURB_INDEX] != nullptr) + { + if (status) + { + ScreenModels::GetInstance()->LoadAppImages(DROPDOWN_IAMGES, dropIconBackground[DNOTDISTURB_INDEX], DROPDOWN_ICONELLIPSEPURPLE); + } + else + { + ScreenModels::GetInstance()->LoadAppImages(DROPDOWN_IAMGES, dropIconBackground[DNOTDISTURB_INDEX], DROPDOWN_ICONELLIPSEBLACK); + } + dropIconBackground[DNOTDISTURB_INDEX]->Invalidate(); + } + else + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "dropIconBackground[DNOTDISTURB_INDEX] is nullptr"); + return; + } + } + }