增加主表盘勿扰状态以及未读消息图标显示
authorCaisking <3449750381@qq.com>
Mon, 12 Aug 2024 07:36:03 +0000 (15:36 +0800)
committerCaisking <3449750381@qq.com>
Mon, 12 Aug 2024 07:36:03 +0000 (15:36 +0800)
12 files changed:
code/sdk/application/wearable/fd230app/nativeui/dnotdisturb/src/DnotDisturbModel.cpp
code/sdk/application/wearable/fd230app/nativeui/main/include/MainViewSample.h
code/sdk/application/wearable/fd230app/nativeui/main/src/MainPresenterSample.cpp
code/sdk/application/wearable/fd230app/nativeui/main/src/MainViewSample.cpp
code/sdk/application/wearable/fd230app/nativeui/message/include/MessageItemView.h
code/sdk/application/wearable/fd230app/nativeui/message/src/MessageItemView.cpp
code/sdk/application/wearable/fd230app/nativeui/message/src/MessageModel.cpp
code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/users/dial_status/disturbicon.bin [new file with mode: 0644]
code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/users/dial_status/unread.bin [new file with mode: 0644]
code/sdk/drivers/peripheral/config/include/ConfigModel.h
tools/image_converter_tool/test/hert/users/dial_status/disturbicon.png [new file with mode: 0644]
tools/image_converter_tool/test/hert/users/dial_status/unread.png [new file with mode: 0644]

index 5b584ed..b37b1e4 100644 (file)
@@ -1,12 +1,6 @@
-/*
- * @Author: luozheng 1732036298@qq.com
- * @Date: 2024-04-10 16:38:52
- * @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-08-10 10:25:37
- * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/dnotdisturb/src/DnotDisturbModel.cpp
- */
 #include "dnotdisturb/include/DnotDisturbModel.h"
 #include "main/include/PullUpDownView.h"
+#include "main/include/MainViewSample.h"
 #include "ConfigModel.h"
 namespace OHOS
 {
@@ -38,7 +32,10 @@ namespace OHOS
     {
         if (PullUpDownView::GetInstance() != nullptr)
         {
+            /*更新主界面下拉界面配置*/
             PullUpDownView::GetInstance()->UpdateDnotDisturbStatus(GetDoNotDisturbModeEnabled());
+            /*更新主界面配置*/
+            MainViewSample::GetInstance()->DisturbIcon()->SetVisible(GetDoNotDisturbModeEnabled());
         }
         return;
     }
index 805270e..e1bcd3d 100644 (file)
@@ -63,7 +63,7 @@ namespace OHOS
         UICardPage *InitBloodOxygenPage(void);
         UICardPage *InitWeatherPage(void);
         UICardPage *InitGoalPage(void);
-        
+
         UICardPage *InitSleepPage(void);
         UICardPage *InitTrainingPage(void);
         UICardPage *InitApplistPage(void);
@@ -85,7 +85,11 @@ namespace OHOS
         {
             return recordCard[id];
         }
-
+        /*获取勿扰图标image*/
+        UIImageView *DisturbIcon() const
+        {
+            return disturbanceicon_;
+        }
         void SwitchToClockPage(void)
         {
             if (mainClockView != nullptr)
@@ -119,7 +123,8 @@ namespace OHOS
         goalControlView *GoalControlView{nullptr};
         // ApplistCardView *applistCardView{nullptr};
         UIButton *changebut{nullptr};
-        UIImageView *disturbIcon{nullptr}; // 勿扰图标
+        UIImageView *disturbanceicon_{nullptr}; // 勿扰图标
+        UIImageView *messageicon_{nullptr};     // 未读图标
         /* -------------------------------------------------------------------------- */
         UICardPage *recordCard[MAX_CARD]{nullptr};
         bool pageStatus[MAX_CARD]{false};
index 8dbe6a9..6e235a7 100644 (file)
@@ -45,11 +45,11 @@ namespace OHOS
         {DROPDOWN_CLICK_BLUETOOTH, VIEW_CLASSIC_BLUETOOTH}, // 蓝牙
         {DROPDOWN_CLICK_DNOTDISTURB, VIEW_DNOTDISTURB},     // 勿扰
 #ifdef SUPPORT_ALIPAY_SEC
-        {DROPDOWN_CLICK_SAVEELE, VIEW_MAIN_ALIPAY},         // 支付宝
+        {DROPDOWN_CLICK_SAVEELE, VIEW_MAIN_ALIPAY}, // 支付宝
 #endif
-        {DROPDOWN_CLICK_FINDMYPHONE, VIEW_NETWORKANDCALL},  // 4G
-        {MAIN_CLICK_BLOOD, VIEW_BLOOD_CHECK},               // 血氧检查
-        {MAIN_CLICK_SETCARD, VIEW_ADD_CARD},                // 卡片管理
+        {DROPDOWN_CLICK_FINDMYPHONE, VIEW_NETWORKANDCALL}, // 4G
+        {MAIN_CLICK_BLOOD, VIEW_BLOOD_CHECK},              // 血氧检查
+        {MAIN_CLICK_SETCARD, VIEW_ADD_CARD},               // 卡片管理
     };
 
     static MainPresenterSample *g_pMainPresenterSample = nullptr;
@@ -185,6 +185,8 @@ namespace OHOS
         {
             PullUpDownView::GetInstance()->UpdateDnotDisturbStatus(false);
             DnotDisturbModel::GetInstance().SetDoNotDisturbModeEnabled(false);
+            /*更新表盘勿扰图标显示*/
+            MainViewSample::GetInstance()->DisturbIcon()->SetVisible(false);
             return true;
         }
 
@@ -496,7 +498,7 @@ namespace OHOS
         float voltage = 0.0F;
         uint8_t value = 0;
         value = battery_get_voltage(&voltage);
-        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "battery_get_voltage = %d",value);
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "battery_get_voltage = %d", value);
         // 更新电池信息
         // const char *progressImages[3] = {
         //     "/user/res/Battery/Battery_Limit.bin", // 低电量图片路径
index f75f9ce..2b89e1b 100644 (file)
@@ -12,7 +12,8 @@
 extern DialInfo_1 dialInfo_1[MAX_DIALNUM_1];
 namespace OHOS
 {
-    static constexpr const char *DISTURBICON = "user/res/message/disturbicon.bin";
+    static constexpr const char *DISTURBICON = "user/res/users/dial_status/disturbicon.bin";
+    static constexpr const char *MESSAGEICON = "user/res/users/dial_status/unread.bin";
 
     static MainViewSample *g_pMainView = nullptr;
     static constexpr uint16_t MESLABLE_X_TMP = 177;
@@ -22,6 +23,8 @@ namespace OHOS
     static constexpr uint8_t FONT_SIZE_TMP = 24;
     static constexpr uint8_t PULL_MIDDLE_VIEW_OPA = 0;
 
+#define DIALSTATE 1
+
     struct MainViewMapper
     {
         CardId id;
@@ -107,11 +110,17 @@ namespace OHOS
             delete MessageLable;
             MessageLable = nullptr;
         }
-        if (disturbIcon != nullptr)
+        if (disturbanceicon_ != nullptr)
+        {
+            mainClockView->Remove(disturbanceicon_);
+            delete disturbanceicon_;
+            disturbanceicon_ = nullptr;
+        }
+        if (messageicon_ != nullptr)
         {
-            mainClockView->Remove(disturbIcon);
-            delete disturbIcon;
-            disturbIcon = nullptr;
+            mainClockView->Remove(messageicon_);
+            delete messageicon_;
+            messageicon_ = nullptr;
         }
         if (compassControlView != nullptr)
         {
@@ -218,7 +227,6 @@ namespace OHOS
         mainSwipeGroup->SetLoopState(false);             // 主界面循环
         mainSwipeGroup->EnableScreenCap(true);           // 主界面截屏滑动
         mainSwipeGroup->RegisterSwipeCallback(callback); // 主界面动画回调
-
         // 判断是否为从主界面前往的其他Slice
         if (presenter_->IsFromSetCardView())
         {
@@ -232,6 +240,24 @@ namespace OHOS
             // 回到表盘
             SwitchToClockPage();
         }
+#if DIALSTATE
+        /*增加勿扰图标*/
+        InitImageView(disturbanceicon_, 213, 0, 40, 40, "disturbIcon", DISTURBICON);
+        /*增加未读图标*/
+        InitImageView(messageicon_, 223, 446, 40, 40, "messageicon_", MESSAGEICON);
+
+        /*获取勿扰状态*/
+        bool disturb_state = ConfigModel::GetInstance()->get_configData_bool(ConfigModel::CONFIGMODEL_ITEM_DNOTDISTURB);
+        disturbanceicon_->SetVisible(disturb_state);
+        /*获取未读状态*/
+        bool unread_state = ConfigModel::GetInstance()->get_configData_bool(ConfigModel::CONFIGMODEL_ITEM_MESSAGE_UNREAD);
+        messageicon_->SetVisible(unread_state);
+
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[disturb_state:%d unread_state:%d]\r\n", disturb_state, unread_state);
+
+        mainClockView->Add(disturbanceicon_);
+        mainClockView->Add(messageicon_);
+#endif
         SetContainerView(mainSwipeGroup);
     }
 
@@ -388,15 +414,6 @@ namespace OHOS
             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainClockView new fail");
             return nullptr;
         }
-
-        /*增加勿扰图标*/
-        InitImageView(disturbIcon, 213, 0, 40, 40, "disturbIcon", DISTURBICON);
-        /*获取勿扰状态*/
-        bool state = ConfigModel::GetInstance()->get_configData_bool(ConfigModel::CONFIGMODEL_ITEM_DNOTDISTURB);
-        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "disturb:state[%d]\r\n", state);
-        disturbIcon->SetVisible(state);
-        mainClockView->Add(disturbIcon);
-
         return mainClockView;
     }
     // 指南针卡片
index 51330cb..7e17347 100644 (file)
@@ -43,6 +43,7 @@ namespace OHOS
         UILabelButton sLabelButton; // 按键
         MessageListItem sItemInfo = {0, false, nullptr, nullptr, nullptr};
         bool isSetupChild{false};
+        bool unread_state = false;
     };
 }
 #endif
\ No newline at end of file
index c7b85fd..de33f15 100644 (file)
@@ -1,11 +1,11 @@
 #include "message/include/MessageItemView.h"
 #include "message/include/MessageModel.h"
+#include "ConfigModel.h"
 namespace OHOS
 {
     static constexpr const char *ICON_IMAGE = "user/res/message/Icon.bin";
 
 #define SELF_ADAPTION 1
-
 #define RECTANGLE_WIDTH 380
 
 // 定义不同大小背景矩形的长度常量
@@ -31,7 +31,6 @@ namespace OHOS
     MessageItemView::MessageItemView()
     {
         SetPosition(0, 0, RECTANGLE_WIDTH, item_length);
-        // SetStyle(STYLE_BACKGROUND_COLOR, 0xff303030);
         SetStyle(STYLE_BACKGROUND_OPA, 255);
         SetStyle(STYLE_BORDER_RADIUS, 20);
         SetTouchable(true);
@@ -48,6 +47,7 @@ namespace OHOS
 #if SELF_ADAPTION
         // 根据 labeldetails 的大小设置矩形和标签的长度
         printf("itemInfo.labeldetails.size():%d\r\n", itemInfo.labeldetails.size());
+
         if (itemInfo.labeldetails.size() <= 30) // 一行
         {
             item_length = SMALL_RECTANGLE_LENGTH;
index cd71660..12b4ad3 100644 (file)
@@ -32,6 +32,7 @@
 #include "AppViewIDs.h"
 #include "NativeAbility.h"
 #include "MainModel.h"
+#include "ConfigModel.h"
 #include "MainViewSample.h"
 #include "message/include/MessageCardView.h"
 #include "message/include/MessageView.h"
@@ -296,22 +297,26 @@ namespace OHOS
     // 初始化列表
     void MessageModel::InitMessageListItems()
     {
-        // 读取数组数据
-        if (!MessageVector.empty())
+        bool unread_state = false;            // 初始化未读状态
+        numberOfItems = MessageVector.size(); // 获取 MessageVector 的大小
+
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "当前的项数是 %d", numberOfItems);
+
+        // 从 MessageVector 的末尾开始迭代
+        for (int i = numberOfItems - 1, count = 0; i >= 0 && count < MaxMessageListCount; i--, count++)
         {
-            numberOfItems = MessageVector.size();
-            WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "the numberOfItems is %d", numberOfItems);
-            for (int i = numberOfItems - 1, count = 0; i >= 0 && count < MaxMessageListCount; i--, count++)
-            {
-                MessageData messageData;
-                messageData.isRead = MessageVector[i].isRead;
-                messageData.labelTitle = MessageVector[i].labelTitle;
-                messageData.labelDetails = MessageVector[i].labelDetails;
-                messageData.labelTime = MessageVector[i].labelTime;
-                // 获取是否读取 来信 信息内容 时间
-                Messages[count] = {count, messageData.isRead, messageData.labelTitle, messageData.labelDetails, messageData.labelTime};
-            }
+            const auto &msg = MessageVector[i]; // 使用引用避免复制
+
+            // 检查消息是否已读
+            if (!msg.isRead)
+                unread_state = true;
+
+            // 填充 Messages 数组
+            Messages[count] = {count, msg.isRead, msg.labelTitle, msg.labelDetails, msg.labelTime};
         }
+
+        // 更新未读状态
+        ConfigModel::GetInstance()->set_condigData_Bool(ConfigModel::CONFIGMODEL_ITEM_MESSAGE_UNREAD, unread_state);
     }
     // 设置当前项[数组下标]
     void MessageModel::SetCurrentIndex(uint8_t index)
@@ -416,7 +421,16 @@ namespace OHOS
     // 判断数组是否存在数据
     bool MessageModel::HasDataVector()
     {
-        return !MessageVector.empty();
+        // 检查 MessageVector 是否为空
+        bool hasData = !MessageVector.empty();
+
+        // 如果没有数据,更新未读状态为 false
+        if (!hasData)
+        {
+            ConfigModel::GetInstance()->set_condigData_Bool(ConfigModel::CONFIGMODEL_ITEM_MESSAGE_UNREAD, false);
+        }
+
+        return hasData; // 返回是否有数据
     }
 
     // 设置弹窗状态
diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/users/dial_status/disturbicon.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/users/dial_status/disturbicon.bin
new file mode 100644 (file)
index 0000000..0715547
--- /dev/null
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:8c2c13dff2a76470651bfa45f016cbfab26f1ec85a130df152acd94acfaabc8c
+size 1144
diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/users/dial_status/unread.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/users/dial_status/unread.bin
new file mode 100644 (file)
index 0000000..9a185ed
--- /dev/null
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:ca4cc5c3350103faaeb84dba3ff95e2b040ba71960bfda15d4e4f5b636936559
+size 344
index abe959d..29bb52f 100644 (file)
@@ -70,6 +70,7 @@ namespace OHOS
             CONFIGMODEL_ITEM_SPORTS_GOAL_DURATION,    //运动目标时长
             CONFIGMODEL_ITEM_SPORTS_GOAL_DISTANCE,    //运动目标距离
             CONFIGMODEL_ITEM_DNOTDISTURB,//勿扰模式
+            CONFIGMODEL_ITEM_MESSAGE_UNREAD,//未读状态
             CONFIGMODEL_ITEM_SYSTEM_VOLUME,//系统音量
             CONFIGMODEL_ITEM_CALL_VOLUME,//通话音量
             CONFIGMODEL_ITEM_VOLTE_CALL,//VoLTE通话
@@ -321,6 +322,7 @@ namespace OHOS
             {ConfigDataType::DATATYPE_INT,     "goal_duration",             "30"    },// CONFIGMODEL_ITEM_SPORTS_GOAL_DURATION,    //运动目标时长   30(分钟)
             {ConfigDataType::DATATYPE_INT,     "goal_distance",             "8"   },// CONFIGMODEL_ITEM_SPORTS_GOAL_DISTANCE,    //运动目标距离   8.0(km)
             {ConfigDataType::DATATYPE_BOOL,    "dnotdisturb",              "false" },// CONFIGMODEL_ITEM_DNOTDISTURB //勿扰模式默认关闭
+            {ConfigDataType::DATATYPE_BOOL,    "unread",              "false"},//CONFIGMODEL_ITEM_MESSAGE_UNREAD//未读状态默认未读
             {ConfigDataType::DATATYPE_INT,     "system_volume",             "100"  },// CONFIGMODEL_ITEM_SYSTEM_VOLUME //
             {ConfigDataType::DATATYPE_INT,     "call_volume",               "100"  },// CONFIGMODEL_ITEM_CALL_VOLUME //
             {ConfigDataType::DATATYPE_BOOL,    "voltecall",                "true" },// CONFIGMODEL_ITEM_VOLTE_CALL #默认是开启VOLTE
diff --git a/tools/image_converter_tool/test/hert/users/dial_status/disturbicon.png b/tools/image_converter_tool/test/hert/users/dial_status/disturbicon.png
new file mode 100644 (file)
index 0000000..fea740d
Binary files /dev/null and b/tools/image_converter_tool/test/hert/users/dial_status/disturbicon.png differ
diff --git a/tools/image_converter_tool/test/hert/users/dial_status/unread.png b/tools/image_converter_tool/test/hert/users/dial_status/unread.png
new file mode 100644 (file)
index 0000000..ef108bc
Binary files /dev/null and b/tools/image_converter_tool/test/hert/users/dial_status/unread.png differ