From d4c5564c6cc9e7c1e524bd133cba741ec4b4705e Mon Sep 17 00:00:00 2001 From: Caisking <3449750381@qq.com> Date: Mon, 12 Aug 2024 15:36:03 +0800 Subject: [PATCH] =?utf8?q?=E5=A2=9E=E5=8A=A0=E4=B8=BB=E8=A1=A8=E7=9B=98?= =?utf8?q?=E5=8B=BF=E6=89=B0=E7=8A=B6=E6=80=81=E4=BB=A5=E5=8F=8A=E6=9C=AA?= =?utf8?q?=E8=AF=BB=E6=B6=88=E6=81=AF=E5=9B=BE=E6=A0=87=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../dnotdisturb/src/DnotDisturbModel.cpp | 11 ++-- .../nativeui/main/include/MainViewSample.h | 11 ++-- .../nativeui/main/src/MainPresenterSample.cpp | 12 +++-- .../nativeui/main/src/MainViewSample.cpp | 47 ++++++++++++------ .../message/include/MessageItemView.h | 1 + .../nativeui/message/src/MessageItemView.cpp | 4 +- .../nativeui/message/src/MessageModel.cpp | 44 ++++++++++------ .../res/users/dial_status/disturbicon.bin | 3 ++ .../fs/user/res/users/dial_status/unread.bin | 3 ++ .../peripheral/config/include/ConfigModel.h | 2 + .../hert/users/dial_status/disturbicon.png | Bin 0 -> 1125 bytes .../test/hert/users/dial_status/unread.png | Bin 0 -> 428 bytes 12 files changed, 91 insertions(+), 47 deletions(-) create mode 100644 code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/users/dial_status/disturbicon.bin create mode 100644 code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/users/dial_status/unread.bin create mode 100644 tools/image_converter_tool/test/hert/users/dial_status/disturbicon.png create mode 100644 tools/image_converter_tool/test/hert/users/dial_status/unread.png 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 0000000000000000000000000000000000000000..fea740dc9d2466d613e6c67246e0060527f25ba2 GIT binary patch literal 1125 zcmV-r1e*JaP)nigv=a+L2VHC! zt+*fss3QRjel%I%+e;1zm)z|E!Efefa{F`p-M8<(d;1~~5|+7`kTALhM4tev z7$OMG6B}4`&q=>8?bXFjOObjrR!Xb8O zNMIr;QD1^db8*-}BnfTB{J@G9ndC&RQ8fu#X71%tsa6eSt7DcOAF0;wNzmES$P{%Z zP#4H7sdytw_-zGUe5CfFN%xPeA>VaMs?BeOqjqOOL4GHBJyk z6h=~Z+gSPDB}jH>lFT#o)5OVwf_$N^Y>)01ligYHA=lIzQCB6RjRIFXP9feCRo5Y* zV(u<4xauwX&Fp^`Lwo;OOy2*F_2q(UyE)W|-p3c!qqa5*IMc{4An|2-6SL`ccbqOr z#b#Eq!C|S?^TqUNo(LFt_~x=AxxFEAwevLIJ^2ZHZrdGa_D0cl@4P!M97%)YucZ`B znMW5Xk$@)J`_CaTNwUN4f%D3dbiwJIAvA+BZ|#{qi}{gsY*V16<1}al_{ zt~2RM=fQ>iNUkpIpr!K^^dY*4pfGi&aJ=(EEs`sWpuU3qSPs-$d0s6gs*z-Z@!n7Y zJZ5N4@KwT#WNv;(wTE#OCYTR8*bJybCCU8qU;4^OG`BWD6M1%$bsPgKN#^FZ5WT3k zVSF-VC&>n#u(I$+DG`R`TlyU4=C`2(GKic}gvBU4Tm))3-Y$sYZH7UnQg_D@zhN*Pa!%5r|VSx(Rd zV;9m++VM7JwPcKGga8x!IJ!pL7{T25hEjHp6y|$w-6CM$VL(ql1bV!hZlRjac^eLH=#*HWn>t1nuJk zSH%jc@|{bN^M3)E!U>~Pud&Pb`$GG3J5Jji&S8!QGF@3r^89*J*x~bW0(FJVQdqfB z+3NXmBoDgF6Hq_Qa`DKkqh|h7AJ3L)Qm$%=uV#9|6UpV--EAB_*eOS9kz@GgKNOE9 zXv;}{If)~KOmiT1oU%4_i|D3Pg%EwvKTGEwV#P79LS;4R=int+=C=eD%Mztyt4SB1 r4&A>YoJ3e;Ih~`I%3Aid3_{=^J>r%?O&4na00000NkvXXu0mjf(lrKe literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..ef108bcf1ffe1b3abe0cb21efdd53e3e2dc4a468 GIT binary patch literal 428 zcmV;d0aN~oP)Hi;QA zd<^9MiezRt`Mrp6#4;Bw~s)23f z;^4nnt$fpIJ;K8CPFX$`8;XY9zI<2>|H`_qB>Ff6PM>HzyDx>@Zuv4A>cF_6@oSU| zJMLSygnGs$KEE!GirM+74V}QEcco<>Ou_0}s(cPpC^SXrz#O)MVMMrqF*p%n0#l^4 zP`b;fFoohs;rKhunzBA~8pWZaFj<1BhuUx;&#cOF26bS7LrK#>W>*R`=_tO_uK@eP zJfO*}UwSI}u0Go!xytOVBGUVwQZHZKpYX