From: Caisking <3449750381@qq.com> Date: Tue, 16 Jul 2024 03:45:01 +0000 (+0800) Subject: 修复训练记录icon和title显示问题 X-Git-Tag: release_V1.2.70_20241020_135402~807^2~3 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=a7a3b7078b100f767c4d3fed3500239271c4874b;p=mirrors%2FFD230.git 修复训练记录icon和title显示问题 --- diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingModel.h b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingModel.h index 74609a866..766141caf 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingModel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingModel.h @@ -302,6 +302,8 @@ namespace OHOS void printf_data(SportData *data); /*获取协议Id*/ int GetBleSportId(Exercisetype sporttype, UIResourceTextId id); + /*获取训练类Id*/ + UIResourceTextId GetSportTypeId(Exercisetype type); private: TraingModel(const TraingModel &) = delete; diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingEnddataView.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingEnddataView.cpp index fb327fd80..4e4efdd16 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingEnddataView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingEnddataView.cpp @@ -83,7 +83,7 @@ namespace OHOS // 初始化Lable // 初始化标签 - InitLabel(labeltype, 188, 52, 90, 35, "label1", "健身类", DEFAULT_VECTOR_FONT_FILENAME, 30); + InitLabelExt(labeltype, 83, 50, 300, 35, "label1", STR_EXERCISE_LIST, DEFAULT_VECTOR_FONT_FILENAME, 30); InitLabel(labelsport, 147, 140, 240, 35, "label6", "健走", DEFAULT_VECTOR_FONT_FILENAME, 30); InitLabel(labelduration, 146, 179, 240, 40, "label7", "13:00:22-15:00:12", DEFAULT_VECTOR_FONT_FILENAME, 28); InitLabelExt(labelutag, 146, 252, 240, 40, "label8", STR_GOAL_ACCOMPLISHMENT_DEGREE, DEFAULT_VECTOR_FONT_FILENAME, 30); @@ -300,7 +300,6 @@ namespace OHOS printf("Enddata is nullptr. Exiting InitData()...\r\n"); return; } - // printf("Initializing TraingEnddataView data...\r\n"); // 训练图标Icon std::string imageStr = TraingModel::GetInstance()->GetSportType(enddata->sportType); if (!imageStr.empty()) @@ -312,6 +311,11 @@ namespace OHOS { printf("Failed to get image string. Skipping imageIcon update.\r\n"); } + + // 训练类 + UIResourceTextId typeId = TraingModel::GetInstance()->GetSportTypeId(enddata->sportType); + labeltype->SetTextId(typeId); + // 运动项目 labelsport->SetTextId(enddata->sportId); @@ -319,7 +323,6 @@ namespace OHOS std::string startTimeStr = enddata->start_time; std::string endTimeStr = enddata->end_time; std::string durationStr = startTimeStr + "-" + endTimeStr; - labelduration->SetText(durationStr.c_str()); // 运动目标 diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingModel.cpp index 71f876f24..80d2e8452 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingModel.cpp @@ -747,6 +747,43 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Not set Sport_Tag!"); return 0; // 添加默认返回值 } + /*获取训练类型Id*/ + UIResourceTextId TraingModel::GetSportTypeId(Exercisetype type) + { + // 根据设置的训练类型去对应相对的数据 + switch (type) + { + // 健身类 + case Exercisetype::FITNESS: + return STR_EXERCISE_LIST; + // 舞蹈类 + case Exercisetype::DANCE: + return STR_DANCING_LIST; + // 休闲运动 + case Exercisetype::LEISURE: + return STR_RECREATIONAL_LIST; + // 球类 + case Exercisetype::BALL: + return STR_BALL_LIST; + // 水上运动 + case Exercisetype::WATER: + return STR_WATER_LIST; + // 冰上运动 + case Exercisetype::ICE: + return STR_ICE_LIST; + // 极限运动 + case Exercisetype::EXTREME: + return STR_EXTREME_LIST; + // 其他 + case Exercisetype::OTHER: + return STR_OTHER_LIST; + default: + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Not ExerciseClass type!"); + break; + } + + return STR_EXERCISE_LIST; // 添加默认返回值[健身类] + } /*打印存储数据*/ void TraingModel::printTrainingData(const Trainingdata &data) { diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/Training/icon_54x79/Limit_54.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/Training/icon_54x79/Limit_54.bin new file mode 100644 index 000000000..261d59936 --- /dev/null +++ b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/Training/icon_54x79/Limit_54.bin @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cda2cd0eb89fe74de90765574b569df4465434848679df95671a7974ffcfeefc +size 2904 diff --git a/tools/image_converter_tool/test/hert/Training/icon_54x79/Limit_54.png b/tools/image_converter_tool/test/hert/Training/icon_54x79/Limit_54.png new file mode 100644 index 000000000..885d22d1c Binary files /dev/null and b/tools/image_converter_tool/test/hert/Training/icon_54x79/Limit_54.png differ