增加睡眠弹窗 睡眠开启勿扰模式
authorCaisking <3449750381@qq.com>
Tue, 2 Jul 2024 07:55:58 +0000 (15:55 +0800)
committerCaisking <3449750381@qq.com>
Tue, 2 Jul 2024 07:55:58 +0000 (15:55 +0800)
code/sdk/application/wearable/fd230app/nativeui/sleep/include/SleepModel.h
code/sdk/application/wearable/fd230app/nativeui/sleep/src/SleepModel.cpp
code/sdk/application/wearable/service/msg_center/src/notify/sleep_notification.cpp

index 8651b3d..9784305 100644 (file)
@@ -109,6 +109,7 @@ namespace OHOS
         std::string sleepStr{"--"};
         std::string walkStr{"--"};
         std::string goalStr{"--"};
+
         std::string goalnotifyStr{"--"};
         std::string goalsleepStr{"--"};
         std::string goalwalkStr{"--"};
index 2c1731a..843d782 100644 (file)
@@ -239,8 +239,8 @@ namespace OHOS
     void SleepModel::set_sleep_goal()
     {
         // 将原3个字符串清空
-        goalsleepStr.clear();
         goalnotifyStr.clear();
+        goalsleepStr.clear();
         goalwalkStr.clear();
 
         int goal_sleep = get_sleep_time_from_config_model();
@@ -306,32 +306,33 @@ namespace OHOS
     {
         return sleep_total_time;
     }
-    // è\8e·å\8f\96å\85¥ç\9d¡æ\97¶é\97´
+    // è\8e·å\8f\96å®\9eé\99\85å\85¥ç\9d¡æ\97¶é\97´str
     std::string SleepModel::get_rest_str()
     {
         return sleepStr;
     }
-    // 获取醒来时间
+    // 获取实际醒来时间str
     std::string SleepModel::get_walk_str()
     {
         return walkStr;
     }
-    // 获取目标休息时间
+    // 获取目标休息时间str
     std::string SleepModel::get_goal_str()
     {
         return goalStr;
     }
-    // 获取提醒时间
-    std::string SleepModel::get_sleep_notifiy()
-    {
-        return goalsleepStr;
-    }
-    // 获取睡眠时间
+    // 获取 目标睡眠提醒 时间点str
     std::string SleepModel::get_notifiy()
     {
         return goalnotifyStr;
     }
-    // 获取起床时间
+    // 获取 目标睡眠 时间点str
+    std::string SleepModel::get_sleep_notifiy()
+    {
+        return goalsleepStr;
+    }
+
+    // 获取 目标起床 时间点str
     std::string SleepModel::get_walk_notifiy()
     {
         return goalwalkStr;
index c1f4af6..e13c539 100644 (file)
@@ -102,11 +102,13 @@ namespace OHOS
             textId = STR_DISTURB; // 即将开启勿扰
             break;
         case SLEEPSTATE::SLEPP:
-            titleStr = SleepModel::GetInstance().get_rest_str();
+            titleStr = SleepModel::GetInstance().get_sleep_notifiy();
             textId = STR_DISTURBNOTE; // 开启勿扰
+            ConfigModel::GetInstance()->SetDnotdisturb(true);
             break;
         case SLEEPSTATE::WALK:
-            titleStr = SleepModel::GetInstance().get_walk_str();
+            titleStr = SleepModel::GetInstance().get_walk_notifiy();
+            ConfigModel::GetInstance()->SetDnotdisturb(false); // 关闭勿扰
             break;
         default:
             break;
@@ -122,10 +124,10 @@ namespace OHOS
         }
         sleeptitle->SetPosition(83, 60, 300, 35);
         sleeptitle->SetText(titleStr.c_str());
-        sleeptitle->SetStyle(STYLE_TEXT_FONT, 30);
+        sleeptitle->SetStyle(STYLE_TEXT_FONT, 40);
         sleeptitle->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS);
         sleeptitle->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
-        sleeptitle->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
+        sleeptitle->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 40);
         sleeptitle->SetVisible(true);
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "sleeptitle is ok!");
         /* -------------------------------------------------------------------------- */
@@ -142,7 +144,7 @@ namespace OHOS
         }
         sleepnotifylabel->SetPosition(53, 220, 360, 144);
         sleepnotifylabel->SetViewId("sleepnotifylabel");
-        sleepnotifylabel->SetTextId(textId); // 将开启勿扰模式
+        sleepnotifylabel->SetTextId(textId);
         sleepnotifylabel->SetTextColor(Color::Gray());
         sleepnotifylabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
         sleepnotifylabel->SetLineBreakMode(UILabel::LINE_BREAK_CLIP);             // 换行裁剪