From: Caisking <3449750381@qq.com> Date: Mon, 12 Aug 2024 07:36:03 +0000 (+0800) Subject: 增加主表盘勿扰状态以及未读消息图标显示 X-Git-Tag: release_V1.2.70_20241020_135402~679^2~5 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=d4c5564c6cc9e7c1e524bd133cba741ec4b4705e;p=mirrors%2FFD230.git 增加主表盘勿扰状态以及未读消息图标显示 --- 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 5b584edb3..b37b1e4a8 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/dnotdisturb/src/DnotDisturbModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/dnotdisturb/src/DnotDisturbModel.cpp @@ -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; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/main/include/MainViewSample.h b/code/sdk/application/wearable/fd230app/nativeui/main/include/MainViewSample.h index 805270e12..e1bcd3d28 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/main/include/MainViewSample.h +++ b/code/sdk/application/wearable/fd230app/nativeui/main/include/MainViewSample.h @@ -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}; 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 8dbe6a99c..6e235a797 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/main/src/MainPresenterSample.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/main/src/MainPresenterSample.cpp @@ -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", // 低电量图片路径 diff --git a/code/sdk/application/wearable/fd230app/nativeui/main/src/MainViewSample.cpp b/code/sdk/application/wearable/fd230app/nativeui/main/src/MainViewSample.cpp index f75f9cee3..2b89e1b02 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/main/src/MainViewSample.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/main/src/MainViewSample.cpp @@ -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; } // 指南针卡片 diff --git a/code/sdk/application/wearable/fd230app/nativeui/message/include/MessageItemView.h b/code/sdk/application/wearable/fd230app/nativeui/message/include/MessageItemView.h index 51330cb59..7e17347a8 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/message/include/MessageItemView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/message/include/MessageItemView.h @@ -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 diff --git a/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageItemView.cpp b/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageItemView.cpp index c7b85fd17..de33f15ad 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageItemView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageItemView.cpp @@ -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; diff --git a/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageModel.cpp index cd7166094..12b4ad39b 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageModel.cpp @@ -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 index 000000000..0715547c7 --- /dev/null +++ b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/users/dial_status/disturbicon.bin @@ -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 index 000000000..9a185edd5 --- /dev/null +++ b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/users/dial_status/unread.bin @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ca4cc5c3350103faaeb84dba3ff95e2b040ba71960bfda15d4e4f5b636936559 +size 344 diff --git a/code/sdk/drivers/peripheral/config/include/ConfigModel.h b/code/sdk/drivers/peripheral/config/include/ConfigModel.h index abe959d85..29bb52f33 100644 --- a/code/sdk/drivers/peripheral/config/include/ConfigModel.h +++ b/code/sdk/drivers/peripheral/config/include/ConfigModel.h @@ -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 index 000000000..fea740dc9 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 index 000000000..ef108bcf1 Binary files /dev/null and b/tools/image_converter_tool/test/hert/users/dial_status/unread.png differ