From bb83ea3cd8e39e503eb48edab7f46de711c9ab68 Mon Sep 17 00:00:00 2001 From: Caisking Date: Fri, 25 Apr 2025 18:13:51 +0800 Subject: [PATCH] =?utf8?q?=E5=90=88=E5=B9=B6=E4=B8=BB=E7=95=8C=E9=9D=A2UI?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../nativeui/main/include/MainViewSample.h | 8 +- .../nativeapp/nativeui/main/src/MainModel.cpp | 82 +++++++------- .../nativeui/main/src/MainPresenterSample.cpp | 104 +++++++++--------- .../nativeui/main/src/MainViewSample.cpp | 50 +++++---- 4 files changed, 127 insertions(+), 117 deletions(-) diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/MainViewSample.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/MainViewSample.h index 3442b8090..80269cfbb 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/MainViewSample.h +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/MainViewSample.h @@ -32,13 +32,13 @@ #include "SetCardModel.h" #include "heart_blood/BloodCardView.h" -// #include "traing/training_card/include/Training_CardView.h" +#include "traing/training_card/include/Training_CardView.h" // #include "ApplistCardView.h" #include "weather/include/WeatherControlView.h" #include "goal/include/goalControlView.h" #include "message/include/MessageControlView.h" -// #include "sleep/include/SleepCardView.h" +#include "sleep/include/SleepCardView.h" #include "set_card/include/SetMainView.h" #include "heartrate/include/HeartRateCardView.h" namespace OHOS @@ -109,8 +109,8 @@ namespace OHOS HeartRateCardView *heartRateView{nullptr}; BloodCardView *bloodView{nullptr}; - // SleepCardView *sleepView{nullptr}; - // Training_CardView *traingView{nullptr}; + SleepCardView *sleepView{nullptr}; + Training_CardView *traingView{nullptr}; MessageControlView *messageView{nullptr}; SetMainView *setmainView{nullptr}; diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/MainModel.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/MainModel.cpp index 2143ad581..c39fb43da 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/MainModel.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/MainModel.cpp @@ -102,19 +102,19 @@ namespace OHOS void MainModel::printCardSettings(void) { uint8_t i; - WEARABLE_LOGD(WEARABL_LOG_MODULE_APP, "_____________________________________________________\r\n"); + WEARABLE_LOGE(WEARABL_LOG_MODULE_APP, "_____________________________________________________\r\n"); for (i = 0; i < cardSettingCount; i++) { uint8_t cardId = cardSettings[i]; const char *cardname = getCardNameFromMap(cardId); - WEARABLE_LOGD(WEARABL_LOG_MODULE_APP, "cardSettings[%d]:Id: %d, CardName: %s\r\n", i, cardId, cardname); + WEARABLE_LOGE(WEARABL_LOG_MODULE_APP, "cardSettings[%d]:Id: %d, CardName: %s\r\n", i, cardId, cardname); } for (uint8_t m = 0; m < (sizeof(cardInfoSet) / sizeof(cardInfoSet[0])); m++) { - WEARABLE_LOGD(WEARABL_LOG_MODULE_APP, "cardInfoSet[%d]:Id %d, Visible: %s\n", m, cardInfoSet[m].id, cardInfoSet[m].isVisible ? "true" : "false"); + WEARABLE_LOGE(WEARABL_LOG_MODULE_APP, "cardInfoSet[%d]:Id %d, Visible: %s\n", m, cardInfoSet[m].id, cardInfoSet[m].isVisible ? "true" : "false"); } - WEARABLE_LOGD(WEARABL_LOG_MODULE_APP, "_____________________________________________________\r\n"); + WEARABLE_LOGE(WEARABL_LOG_MODULE_APP, "_____________________________________________________\r\n"); } const char *MainModel::getCardNameFromMap(uint8_t cardId) const @@ -134,7 +134,7 @@ namespace OHOS { if (card == cardInfoMap[i].id) { - WEARABLE_LOGD(WEARABL_LOG_MODULE_APP, "cardInfoMap[%d]:%d\n", i, cardInfoMap[i].id); + WEARABLE_LOGE(WEARABL_LOG_MODULE_APP, "cardInfoMap[%d]:%d\n", i, cardInfoMap[i].id); return &cardInfoMap[i]; } } @@ -147,7 +147,7 @@ namespace OHOS /*初始化卡片设置*/ void MainModel::InitCardSettings(void) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "InitCardSettings"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitCardSettings"); char temp[CARD_SETTING_VALUE_LEN] = {0}; int len; int index = 0; @@ -179,7 +179,7 @@ namespace OHOS { if (cardInfoSet[i].id == cardSettings[j]) { - // WEARABLE_LOGD(WEARABL_LOG_MODULE_APP, "CardSettings:cardInfoSet[%d] is set cardSettings[%d]\r\n", i, j); + // WEARABLE_LOGE(WEARABL_LOG_MODULE_APP, "CardSettings:cardInfoSet[%d] is set cardSettings[%d]\r\n", i, j); visible = true; break; } @@ -211,12 +211,12 @@ namespace OHOS } // printCardSettings(); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "InitCardSettings"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitCardSettings"); } void MainModel::DeleteCardSetting(uint8_t index) { /*设置卡片类型为false cardsetting 重新遍历map里面为ture的卡片{表盘必须存在}*/ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "DeleteCardSetting"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DeleteCardSetting"); if (cardSettingCount > CARD_SETTING_COUNT_MAX) { @@ -234,7 +234,7 @@ namespace OHOS cardInfoSet[index].isVisible = false; #if 0 int count = sizeof(cardInfoSet) / sizeof(cardInfoSet[0]); - WEARABLE_LOGD(WEARABL_LOG_MODULE_APP, "count:%d\r\n", count); + WEARABLE_LOGE(WEARABL_LOG_MODULE_APP, "count:%d\r\n", count); // 设置map里面的属性 for (uint8_t i = 0; i < count; i++) { @@ -242,10 +242,10 @@ namespace OHOS if (cardInfoMap[index].id == cardInfoSet[i].id) { cardInfoSet[i].isVisible = false; - WEARABLE_LOGD(WEARABL_LOG_MODULE_APP, "删除卡片:cardSettings[%d] is %d \r\n", index + 1, cardSettings[index + 1]); - WEARABLE_LOGD(WEARABL_LOG_MODULE_APP, "设置删除卡片属性:cardInfoSet[%d] is %d \r\n", i, cardInfoSet[i].isVisible); + WEARABLE_LOGE(WEARABL_LOG_MODULE_APP, "删除卡片:cardSettings[%d] is %d \r\n", index + 1, cardSettings[index + 1]); + WEARABLE_LOGE(WEARABL_LOG_MODULE_APP, "设置删除卡片属性:cardInfoSet[%d] is %d \r\n", i, cardInfoSet[i].isVisible); } - WEARABLE_LOGD(WEARABL_LOG_MODULE_APP, "cardInfoSet[%d]:id%d\r\n", i, cardInfoSet[i].id); + WEARABLE_LOGE(WEARABL_LOG_MODULE_APP, "cardInfoSet[%d]:id%d\r\n", i, cardInfoSet[i].id); } #endif int mapindex = 0; @@ -265,7 +265,7 @@ namespace OHOS // 设置其他卡片 if (cardInfoSet[i].isVisible) { - // WEARABLE_LOGD(WEARABL_LOG_MODULE_APP, "cardSettings[%d]\r\n", i); + // WEARABLE_LOGE(WEARABL_LOG_MODULE_APP, "cardSettings[%d]\r\n", i); cardSettings[mapindex++] = cardInfoSet[i].id; } } @@ -283,13 +283,13 @@ namespace OHOS (void)UtilsSetValue("card_setting", temp); // printCardSettings(); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "DeleteCardSetting"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DeleteCardSetting"); } void MainModel::AddCardSetting(uint8_t index) { /*设置卡片类型为ture cardsetting 重新遍历map里面为ture的卡片{表盘必须存在}*/ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AddCardSetting"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AddCardSetting"); if (cardSettingCount > CARD_SETTING_COUNT_MAX) { @@ -334,7 +334,7 @@ namespace OHOS if (cardInfoSet[i].isVisible) { cardSettings[mapindex++] = cardInfoSet[i].id; - WEARABLE_LOGD(WEARABL_LOG_MODULE_APP, "set cardInfoSet[%d]\r\n", i); + WEARABLE_LOGE(WEARABL_LOG_MODULE_APP, "set cardInfoSet[%d]\r\n", i); } } /*设置卡片[不被卡片管理,必须设置] */ @@ -351,7 +351,7 @@ namespace OHOS (void)UtilsSetValue("card_setting", temp); // printCardSettings(); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AddCardSetting"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AddCardSetting"); } uint8_t MainModel::GetCardSettingCount(void) { @@ -415,7 +415,7 @@ namespace OHOS if (id < DIAL_CLOCK || id >= DIAL_MAX) id = DIAL_CLOCK; - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "InitDialSettingDefault"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitDialSettingDefault"); dialSetting.dialFlag = 0; dialSetting.dialId = id; dialSetting.dialFullName.clear(); // 用 clear() 替代空字符串 @@ -426,7 +426,13 @@ namespace OHOS { std::string tmp = std::to_string(setting.dialFlag) + "," + std::to_string(setting.dialId) + "," + setting.dialFullName + ","; + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Updating dial settings: %s\r\n", tmp.c_str()); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Dial settings updated id %d\r\n",id); + + // 存储表盘配置 (void)UtilsSetValue("dial_setting", tmp.c_str()); // 存储表盘配置 + + // 存储当前表盘Id (void)UtilsSetValue("dial_id", std::to_string(id).c_str()); // 存储当前表盘Id } @@ -435,7 +441,7 @@ namespace OHOS { char temp[DIAL_SETTING_VALUE_LEN] = {0}; // 创建一个临时字符数组用于存储拨号设置的字符串 int len = UtilsGetValue("dial_setting", temp, DIAL_SETTING_VALUE_LEN); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Attempting to load dial settings from kvstore. Length: %d\r\n", len); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Attempting to load dial settings from kvstore. Length: %d\r\n", len); if (len < 0) { @@ -461,7 +467,7 @@ namespace OHOS if (setValue) { dialSetting.dialFlag = atoi(setValue); // 将字符串转换为整数 - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Dial flag loaded: %d\r\n", dialSetting.dialFlag); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Dial flag loaded: %d\r\n", dialSetting.dialFlag); } else { @@ -483,7 +489,7 @@ namespace OHOS if (setValue) { dialSetting.dialId = atoi(setValue); // 将字符串转换为整数 - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Dial ID loaded: %d\r\n", dialSetting.dialId); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Dial ID loaded: %d\r\n", dialSetting.dialId); } else { @@ -505,17 +511,17 @@ namespace OHOS if (setValue) { dialSetting.dialFullName = setValue; // 将完整名称赋值 - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Dial full name loaded: %s\r\n", dialSetting.dialFullName.c_str()); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Dial full name loaded: %s\r\n", dialSetting.dialFullName.c_str()); if (dialSetting.dialFullName.empty() || access(dialSetting.dialFullName.c_str(), F_OK) != 0) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Error: Dial full name is invalid or file does not exist. Initializing to default settings.\r\n"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Error: Dial full name is invalid or file does not exist. Initializing to default settings.\r\n"); InitDialSettingDefault(dialSetting.dialId); } } else { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Error: Third value is empty. Initializing to default settings.\r\n"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Error: Third value is empty. Initializing to default settings.\r\n"); InitDialSettingDefault(dialSetting.dialId); } } @@ -539,11 +545,11 @@ namespace OHOS void MainModel::InitDialState(void) { // 获取加锁状态 int lockstate = OHOS::ConfigModel::GetInstance()->get_configData_int(OHOS::ConfigModel::CONFIGMODEL_ITEM_PASSWORD_SWITCH); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "lockstate = %d", lockstate); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "lockstate = %d", lockstate); // 判断加锁状态 if (lockstate == 1) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Device is locked (lock state == 1)"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Device is locked (lock state == 1)"); uapi_dev_runtime_set_lock_status(1); // 上锁 dialstateInfo[static_cast(DialState::LOCK)].active = true; // 设置锁定状态为真 } @@ -565,17 +571,17 @@ namespace OHOS // if (dialstateInfo[stateIndex].active != value) // { // dialstateInfo[stateIndex].active = value; // 使用转换后的索引 - // WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Set dialstateInfo[%d].active = %d", stateIndex, value); + // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Set dialstateInfo[%d].active = %d", stateIndex, value); // SendMsgToUIService(UI_UPDATE_DIALSTATE_DATA, 0, nullptr, 0); // 发送更新消息 // } // else // { - // WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "State %d is unchanged, no update needed.", stateIndex); + // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "State %d is unchanged, no update needed.", stateIndex); // } // } // else // { - // WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "state %d is error", stateIndex); + // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "state %d is error", stateIndex); // } } @@ -586,11 +592,11 @@ namespace OHOS { if (dialstateInfo[i].active) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "high dialstateInfo[%d].active", i); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "high dialstateInfo[%d].active", i); return dialstateInfo[i].state; // 返回活跃状态中优先级最高的 } } - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "no have high dialstateInfo.active"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "no have high dialstateInfo.active"); return DialState::INVALID; // 如果没有找到活跃状态,返回无效状态 } @@ -633,7 +639,7 @@ namespace OHOS { if (i == index + 1) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "i:%d index:%d", i, index); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "i:%d index:%d", i, index); uint8_t j = i; for (; j < cardSettingCount - 1; j++) { @@ -646,14 +652,14 @@ namespace OHOS for (uint8_t i = 0; i < cardSettingCount; i++) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "cardSettings[%d] = %d", i, cardSettings[i]); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "cardSettings[%d] = %d", i, cardSettings[i]); (void)sprintf_s(temp + strlen(temp), CARD_SETTING_VALUE_LEN, "%d,", cardSettings[i]); } (void)UtilsSetValue("card_setting", temp); - WEARABLE_LOGD(WEARABL_LOG_MODULE_APP, "\r\n***************DeleteCardSetting********************\r\n"); + WEARABLE_LOGE(WEARABL_LOG_MODULE_APP, "\r\n***************DeleteCardSetting********************\r\n"); printCardSettings(); - WEARABLE_LOGD(WEARABL_LOG_MODULE_APP, "\r\n_____________________________________________________\r\n"); + WEARABLE_LOGE(WEARABL_LOG_MODULE_APP, "\r\n_____________________________________________________\r\n"); } void MainModel::AddCardSetting(uint8_t index) @@ -673,12 +679,12 @@ namespace OHOS cardSettings[cardSettingCount++] = cardInfoMap[index].id; for (uint8_t i = 0; i < cardSettingCount; i++) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "cardSettings[%d] = %d", i, cardSettings[i]); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "cardSettings[%d] = %d", i, cardSettings[i]); (void)sprintf_s(temp + strlen(temp), CARD_SETTING_VALUE_LEN, "%d,", cardSettings[i]); } (void)UtilsSetValue("card_setting", temp); - WEARABLE_LOGD(WEARABL_LOG_MODULE_APP, "\r\n***************AddCardSetting********************\r\n"); + WEARABLE_LOGE(WEARABL_LOG_MODULE_APP, "\r\n***************AddCardSetting********************\r\n"); printCardSettings(); else { diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/MainPresenterSample.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/MainPresenterSample.cpp index 17021a1d7..f5f408c24 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/MainPresenterSample.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/MainPresenterSample.cpp @@ -29,10 +29,10 @@ // #include "traing/training_card/include/Training_CardView.h" // #include "dnotdisturb/include/DnotDisturbModel.h" #include "weather/include/WeatherModel.h" -// #include "heart_blood/health_service/health_service.h" -// #include "sleep/include/SleepControlView.h" -// #include "sleep/include/SleepCardView.h" -// #include "sleep/include/SleepModel.h" +#include "heart_blood/health_service/health_service.h" +#include "sleep/include/SleepControlView.h" +#include "sleep/include/SleepCardView.h" +#include "sleep/include/SleepModel.h" #include "MainModel.h" // #include "../../../../../../../drivers/peripheral/utils/custom_runtime.h" // #include "rebootandshutdown/include/RebootAndShutdownModelC.h" @@ -77,10 +77,10 @@ REGIST_SLICE(VIEW_MAIN, MainViewSample, MainPresenterSample); { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "~MainPresenterSample"); g_pMainPresenterSample = nullptr; - // /*从主界面退出,关闭心率检测*/ - // HeartModel::GetInstance()->Heart_Stop(); - // HeartModel::GetInstance()->Heart_Control(HeartState::End, - // HeartCheck::CARDCHECK); + /*从主界面退出,关闭心率检测*/ + HeartModel::GetInstance()->Heart_Stop(); + HeartModel::GetInstance()->Heart_Control(HeartState::End, + HeartCheck::CARDCHECK); } MainPresenterSample *MainPresenterSample::GetInstance(void) @@ -160,12 +160,12 @@ if (ConfigModel::GetInstance()->GetisFirstTimeStart() == true) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "StatusButtonClickListener: %s", view.GetViewId()); std::string curViewId = view.GetViewId(); - // UIImageView *imgView = static_cast(&view); - // if (HealthModel::GetInstance() == nullptr) - // { - // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "health model nullptr"); - // return false; - // } + UIImageView *imgView = static_cast(&view); + if (HealthModel::GetInstance() == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "health model nullptr"); + return false; + } // /*发生点击进入密码锁*/ // if (uapi_dev_runtime_get_lock_status()) @@ -175,32 +175,32 @@ if (ConfigModel::GetInstance()->GetisFirstTimeStart() == true) { // return true; // } - // if (curViewId == CONNECTEDSTATUSBACKGROUNDBUTTON) - // { - // PullUpDownView::GetInstance()->ChangeView(DROPDOWNVIEW, CONNECTEDSTATUSVIEW); - // PullUpDown_StopTimer(); // 切换到连接状态视图时停止定时器 - // return true; - // } - // else if (curViewId == CONNECTEDSTATUSVIEWCLOSEBUTTON) - // { - // PullUpDownView::GetInstance()->ChangeView(CONNECTEDSTATUSVIEW, DROPDOWNVIEW); - // PullUpDown_StartTimer(1000); // 切回下拉控制中心视图开启定时器 - // return true; - // } - // // 设置血氧进入 - // else if (curViewId == MAIN_CLICK_BLOOD) - // { - // MainModel::GetInstance().SetFromSetCardView(true); - // MainModel::GetInstance().SetFromCardId(BLOODOXGEN); - // // 如果正在充电进入提醒界面 - // if (get_charge_stat()) - // { - // HealthState highHealthState; - // highHealthState.checkType = CHARGE; - // HealthService::GetInstance()->SetHealthCurrent(highHealthState); - // NativeAbility::GetInstance().ChangeSlice(VIEW_CHECK_INVALID, TransitionType::TRANSITION_ZOOM); - // } - // } + if (curViewId == CONNECTEDSTATUSBACKGROUNDBUTTON) + { + PullUpDownView::GetInstance()->ChangeView(DROPDOWNVIEW, CONNECTEDSTATUSVIEW); + PullUpDown_StopTimer(); // 切换到连接状态视图时停止定时器 + return true; + } + else if (curViewId == CONNECTEDSTATUSVIEWCLOSEBUTTON) + { + PullUpDownView::GetInstance()->ChangeView(CONNECTEDSTATUSVIEW, DROPDOWNVIEW); + PullUpDown_StartTimer(1000); // 切回下拉控制中心视图开启定时器 + return true; + } + // 设置血氧进入 + else if (curViewId == MAIN_CLICK_BLOOD) + { + MainModel::GetInstance().SetFromSetCardView(true); + MainModel::GetInstance().SetFromCardId(BLOODOXGEN); + // 如果正在充电进入提醒界面 + // if (get_charge_stat()) + // { + // HealthState highHealthState; + // highHealthState.checkType = CHARGE; + // HealthService::GetInstance()->SetHealthCurrent(highHealthState); + // NativeAbility::GetInstance().ChangeSlice(VIEW_CHECK_INVALID, TransitionType::TRANSITION_ZOOM); + // } + } // 设置卡片管理进入 if (curViewId == MAIN_CLICK_SETCARD) { @@ -430,8 +430,8 @@ if (ConfigModel::GetInstance()->GetisFirstTimeStart() == true) { if (previousCardId == HEART_RATE && currentCardId != HEART_RATE) { LogCardTransition(previousCardId, currentCardId); - // HeartModel::GetInstance()->Heart_Stop(); - // HeartModel::GetInstance()->Heart_Control(HeartState::End,HeartCheck::CARDCHECK); //主动检测心率 + HeartModel::GetInstance()->Heart_Stop(); + HeartModel::GetInstance()->Heart_Control(HeartState::End,HeartCheck::CARDCHECK); //主动检测心率 } // 从指南针卡片跳转到其他卡片时切换到关闭长亮屏 if (previousCardId == COMPASS && currentCardId != COMPASS) @@ -501,16 +501,16 @@ if (ConfigModel::GetInstance()->GetisFirstTimeStart() == true) { /*睡眠卡片*/ void MainPresenterSample::ResetSleepCardView() { - // if (SleepCardView::GetInstance() != nullptr) - // { - // auto sleepCardView = SleepCardView::GetInstance()->GetSleepCardView(); - // if (sleepCardView->GetCurrentPage() != 0) - // { - // sleepCardView->SetCurrentPage(0); - // } - // } + if (SleepCardView::GetInstance() != nullptr) + { + auto sleepCardView = SleepCardView::GetInstance()->GetSleepCardView(); + if (sleepCardView->GetCurrentPage() != 0) + { + sleepCardView->SetCurrentPage(0); + } + } - // SleepModel::GetInstance().msg_save_sleep_data(); + SleepModel::GetInstance().msg_save_sleep_data(); } /*天气卡片*/ void MainPresenterSample::ResetWeatherCardView() @@ -529,7 +529,7 @@ if (ConfigModel::GetInstance()->GetisFirstTimeStart() == true) { /*心率卡片*/ void MainPresenterSample::StartHeartRateDetection() { - // HeartModel::GetInstance()->Heart_Control(HeartState::End, HeartCheck::PASSIVITY); + // HeartModel::GetInstance()->Heart_Control(HeartState::End, HeartCheck::PASSIVITY); #if HEART_RATE_CHECK_TIMEOUT HeartModel::GetInstance()->Heart_Control(HeartState::Start,HeartCheck::CARDCHECK); #else diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/MainViewSample.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/MainViewSample.cpp index 44592f828..bbeca06ec 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/MainViewSample.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/MainViewSample.cpp @@ -36,9 +36,9 @@ namespace OHOS static const MainViewMapper CardMapper[] = { {WATCH_FACE, &MainViewSample::InitWatchFacePage}, {HEART_RATE, &MainViewSample::InitHeartRatePage}, - // {TRAINING, &MainViewSample::InitTrainingPage}, + {TRAINING, &MainViewSample::InitTrainingPage}, {COMPASS, &MainViewSample::InitCompassPage}, - // {SLEEP, &MainViewSample::InitSleepPage}, + {SLEEP, &MainViewSample::InitSleepPage}, {BLOODOXGEN, &MainViewSample::InitBloodOxygenPage}, {GOAL, &MainViewSample::InitGoalPage}, {WEATHER, &MainViewSample::InitWeatherPage}, @@ -281,12 +281,11 @@ namespace OHOS { if (cardSettings[i] == CardMapper[j].id) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainViewSample:: recordCard[%d]:%p", j, recordCard[j]); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainViewSample:: recordCard[%d]", j); recordCard[j] = (this->*(CardMapper[j].func))(); if (recordCard[j] == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, - "MainViewSample:: recordCard %d error", j); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainViewSample:: recordCard %d error", j); return false; } WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, @@ -316,6 +315,12 @@ namespace OHOS WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainViewSample:: HorViewLoad cardid = %d ViewIndex = %d", cardId, recordCard[cardId]->GetViewIndex()); } + else + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainViewSample:: HorViewLoad cardid = %d error", + cardId); + // continue; + } } } @@ -389,6 +394,7 @@ namespace OHOS { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainViewSample::InitWatchFacePage"); DialSetting &setting = presenter_->GetDialSetting(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainViewSample::InitWatchFacePage dialFlag = %d", setting.dialFlag); if (setting.dialFlag) { mainClockView = InitWatchOffDial(setting); @@ -447,15 +453,14 @@ namespace OHOS // 主界面训练卡片 UICardPage *MainViewSample::InitTrainingPage(void) { - // WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainViewSample::InitTrainingPage"); - // traingView = new Training_CardView(); - // if (traingView == nullptr) - // { - // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "traingView new fail"); - // return nullptr; - // } - // return traingView; - return nullptr; + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainViewSample::InitTrainingPage"); + traingView = new Training_CardView(); + if (traingView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "traingView new fail"); + return nullptr; + } + return traingView; } // 主界面天气卡片 @@ -525,15 +530,14 @@ namespace OHOS /*主界面睡眠卡片*/ UICardPage *MainViewSample::InitSleepPage(void) { - // WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainViewSample::InitSetMainPage"); - // sleepView = new SleepCardView(); - // if (sleepView == nullptr) - // { - // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "sleepView new fail"); - // return nullptr; - // } - // return sleepView; - return nullptr; + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainViewSample::InitSetMainPage"); + sleepView = new SleepCardView(); + if (sleepView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "sleepView new fail"); + return nullptr; + } + return sleepView; } void MainViewSample::SetPage(int16_t page, bool loadAdjacent) -- 2.17.1