From b43ca3da72a24562a1d62ee5e0746e55c3fa8607 Mon Sep 17 00:00:00 2001 From: luozheng <1732036298@qq.com> Date: Thu, 24 Oct 2024 14:27:13 +0800 Subject: [PATCH] =?utf8?q?#1066=EF=BC=8C=E8=A7=A3=E5=86=B3=EF=BC=8C?= =?utf8?q?=E6=89=8B=E8=A1=A8=E7=AB=AF=E8=BF=9E=E7=BB=AD=E5=88=9B=E5=BB=BA?= =?utf8?q?=E4=B8=89=E4=B8=AA=E9=97=B9=E9=92=9F=EF=BC=8C=E5=86=8D=E6=8E=A5?= =?utf8?q?=E7=9D=80=E5=88=A0=E9=99=A4=E7=AC=AC=E4=BA=8C=E4=B8=AA=E9=97=B9?= =?utf8?q?=E9=92=9F=EF=BC=8C=E5=90=8C=E6=AD=A5IOS=20APP=E6=88=90=E5=8A=9F?= =?utf8?q?=EF=BC=8CAPP=E9=97=B9=E9=92=9F=E7=95=8C=E9=9D=A2=E7=AC=AC?= =?utf8?q?=E4=B8=89=E4=B8=AA=E9=97=B9=E9=92=9F=E6=98=BE=E7=A4=BA=E4=B8=BA0?= =?utf8?q?0=EF=BC=9A00=EF=BC=88=E5=BF=85=E7=8E=B0=EF=BC=89=20bug=20#1065?= =?utf8?q?=EF=BC=8C=E8=A7=A3=E5=86=B3APP=E5=88=9B=E5=BB=BA5=E4=B8=AA?= =?utf8?q?=E9=97=B9=E9=92=9F=E5=90=8E=E5=86=8D=E5=88=A0=E9=99=A4=E4=B8=80?= =?utf8?q?=E4=B8=AA=EF=BC=8C=E5=90=8C=E6=AD=A5=E6=89=8B=E8=A1=A8=E6=88=90?= =?utf8?q?=E5=8A=9F=EF=BC=8C=E6=89=8B=E8=A1=A8=E7=AB=AF=E6=97=A0=E6=B3=95?= =?utf8?q?=E5=86=8D=E6=96=B0=E5=A2=9E=E9=97=B9=E9=92=9F=EF=BC=88=E5=BF=85?= =?utf8?q?=E7=8E=B0=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../nativeui/alarm/include/AlarmClockModel.h | 2 +- .../nativeui/alarm/include/AlarmClockModelC.h | 5 +- .../nativeui/alarm/include/MainAlarmView.h | 1 + .../nativeui/alarm/src/AlarmClockModel.cpp | 49 ++++++------------- .../nativeui/alarm/src/AlarmPresenter.cpp | 5 +- .../nativeui/alarm/src/MainAlarmView.cpp | 29 ++--------- .../calculator/src/CalculatorView.cpp | 21 ++++++-- .../service/ble_service/blemoder/bletest.cpp | 1 + 8 files changed, 47 insertions(+), 66 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/alarm/include/AlarmClockModel.h b/code/sdk/application/wearable/fd230app/nativeui/alarm/include/AlarmClockModel.h index d72bf6585..59177efe9 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/alarm/include/AlarmClockModel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/alarm/include/AlarmClockModel.h @@ -127,9 +127,9 @@ public: void CancelAlarmRing(); void DelayAlarmRing(); void SetAlarmId(uint8_t id); + void DeleteAlarmId(uint8_t id); private: - void DeleteAlarmId(uint8_t id); // void NewFirstTime(void); uint8_t GetAlarmId(void); // int32_t SaveGlobalAlarmToFile(void); diff --git a/code/sdk/application/wearable/fd230app/nativeui/alarm/include/AlarmClockModelC.h b/code/sdk/application/wearable/fd230app/nativeui/alarm/include/AlarmClockModelC.h index 9478284fd..44853c1c3 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/alarm/include/AlarmClockModelC.h +++ b/code/sdk/application/wearable/fd230app/nativeui/alarm/include/AlarmClockModelC.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-09-25 16:48:17 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-09-25 16:52:11 + * @LastEditTime: 2024-10-24 14:14:08 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/alarm/include/AlarmClockModelC.h */ @@ -16,6 +16,9 @@ extern "C" #endif #endif #include + + void delete_alarm_id(uint8_t id); + void set_alarm_id(uint8_t id); int testPlayerStart_(char *); diff --git a/code/sdk/application/wearable/fd230app/nativeui/alarm/include/MainAlarmView.h b/code/sdk/application/wearable/fd230app/nativeui/alarm/include/MainAlarmView.h index 3cb345791..3bd0e33c5 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/alarm/include/MainAlarmView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/alarm/include/MainAlarmView.h @@ -94,6 +94,7 @@ private: UILabelExt * TitleLabelExt_{nullptr}; UILabelButtonExt * AddButton_{nullptr}; UICheckBox::OnChangeListener *statusListener{nullptr}; + bool viewInitstatus_{false}; #define ALARM_DELETE_IMAGE "/user/res/Alarm/alarm_delete.bin" }; diff --git a/code/sdk/application/wearable/fd230app/nativeui/alarm/src/AlarmClockModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/alarm/src/AlarmClockModel.cpp index 09f26ef68..491f4761a 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/alarm/src/AlarmClockModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/alarm/src/AlarmClockModel.cpp @@ -336,6 +336,9 @@ bool AlarmClockModel::JudgeClockModel(uint16_t num) //获取一个可用的闹钟 ID uint8_t AlarmClockModel::GetAlarmId(void) { + for (int num = 0; num < CLOCK_MAX; num++) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmClockModel::GetAlarmId alarmId[%d] = %d", num, alarmId[num]); + } for (int num = 0; num < CLOCK_MAX; num++) { if (alarmId[num] == 0) { //如果某个元素的值为 0,表示这个 ID 尚未被使用 return num; @@ -371,6 +374,10 @@ void set_alarm_id(uint8_t id) AlarmClockModel::GetInstance()->SetAlarmId(id); } +void delete_alarm_id(uint8_t id) +{ + AlarmClockModel::GetInstance()->DeleteAlarmId(id); +} // void AlarmClockModel::NewFirstTime(void) // { // uint32_t timeTem = FIRST_CLOCK_HOUR; @@ -405,7 +412,7 @@ void set_alarm_id(uint8_t id) // SetAlarmId(currentAlarm[0]->alarmClockId); // return; // } -#if 0 +#if 1 void AlarmClockModel::DeleteClockModel(uint16_t num) { // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmClockModel::DeleteClockModel num=%d", num); @@ -424,33 +431,9 @@ void AlarmClockModel::DeleteClockModel(uint16_t num) currentAlarm[num]->alarmClockId); DeleteAlarmId(clockId); WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmClockModel::DeleteClockModel alarmSerial = %u!", alarmSerial); - // for (; num < alarmSerial; num++) { - // AlarmClockInfo *tempAlarm = currentAlarm[num]; - // tempAlarm->index = currentAlarm[num]->index; - // currentAlarm[num] = currentAlarm[num + 1]; - // currentAlarm[num]->index = num; - // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmClockModel::UpdataAlarmClock index = %u!", - // currentAlarm[num]->index); - // if (currentAlarm[num + 1] == nullptr || currentAlarm[num + 1]->alarmType == TYPE_INVALID_ALARM_CLOCK) { - // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmClockModel::DeleteClockModel fail"); - // currentAlarm[num] = tempAlarm; - // return; - // } - // int ret = UpdataAlarmClock(currentAlarm[num]); - // if (ret != 0) { - // currentAlarm[num] = tempAlarm; - // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmClockModel::DeleteClockModel [%d]", __LINE__); - // return; - // } - // } - // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmClockModel::DeleteClockModel [%d]", __LINE__); - // currentAlarm[alarmSerial] = nullptr; - for (; num < alarmSerial - 1; num++) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmClockModel::DeleteClockModel. current_index = %u!", currentAlarm[num]->index); - if (currentAlarm[num + 1] == nullptr || currentAlarm[num + 1]->alarmType == TYPE_INVALID_ALARM_CLOCK) - { + for (; num < alarmSerial - 1; num ++) { + if (currentAlarm[num + 1] == nullptr || currentAlarm[num + 1]->alarmType == TYPE_INVALID_ALARM_CLOCK) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmClockModel::DeleteClockModel fail"); break; } @@ -468,7 +451,7 @@ void AlarmClockModel::DeleteClockModel(uint16_t num) } currentAlarm[alarmSerial - 1] = nullptr; } -#endif +#else //删除闹钟信息 void AlarmClockModel::DeleteClockModel(uint16_t id) @@ -537,7 +520,7 @@ void AlarmClockModel::DeleteClockModel(uint16_t id) } } } - +#endif //切换特定闹钟的启用状态 bool AlarmClockModel::ButtonStatusRing(int16_t num, bool alarmStatus) { @@ -679,7 +662,7 @@ void AlarmClockModel::SetAlarmInfo(uint32_t time_hour, uint32_t time_min, uint8_ if (currentAlarm[alarmListener] == nullptr || (currentAlarm[alarmListener]->alarmType == TYPE_INVALID_ALARM_CLOCK && currentAlarm[alarmListener] != nullptr)) { currentAlarm[alarmListener] = new AlarmClockInfo(); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmClcokModel::SetAlarmTime new alarm!"); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AlarmClcokModel::SetAlarmTime new alarm!"); } WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "hour = %u, minute = %u", time_hour, time_min); currentAlarm[alarmListener]->alarmTime = ((time_hour << 16) | time_min); // 闹钟时间数据:小时存储在高 16 位,分钟存储在低 16 位 @@ -696,10 +679,10 @@ void AlarmClockModel::SetAlarmInfo(uint32_t time_hour, uint32_t time_min, uint8_ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmClockModel::SetAlarmInfo copy alarmname error!"); return; } - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AlarmClockModel::NewAlarmTime clock name = %s, id = %u", + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmClockModel::NewAlarmTime clock name = %s, id = %u", currentAlarm[alarmListener]->alarmClockName, currentAlarm[alarmListener]->alarmClockId); if (setListener == NEW_TIME_LISTENER) { //表示新建闹钟 - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AlarmClockModel::SetAlarmWeek new time!"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmClockModel::SetAlarmWeek new time!"); int ret = AddAlarmClock(currentAlarm[alarmListener]); if (ret != 0) { if (currentAlarm[alarmListener] != nullptr) { @@ -710,7 +693,7 @@ void AlarmClockModel::SetAlarmInfo(uint32_t time_hour, uint32_t time_min, uint8_ } SetAlarmId(currentAlarm[alarmListener]->alarmClockId); } else { //表示修改闹钟 - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AlarmClockModel::SetAlarmWeek modify time!"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmClockModel::SetAlarmWeek modify time!"); UpdataAlarmClock(currentAlarm[alarmListener]); } } diff --git a/code/sdk/application/wearable/fd230app/nativeui/alarm/src/AlarmPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/alarm/src/AlarmPresenter.cpp index 0b36bf50b..bc3397dab 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/alarm/src/AlarmPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/alarm/src/AlarmPresenter.cpp @@ -190,7 +190,10 @@ void AlarmPresenter::ClickJudgeTrue(uint16_t num) clockQty--; AlarmClockModel::GetInstance()->SetSerialRdc(); MainAlarmView::GetInstance()->RefreshAlarm(); - MainAlarmView::GetInstance()->ChangeView(CHANGE_INTERFACE_JUDGE, MAIN_INTERFACE); + // MainAlarmView::GetInstance()->ChangeView(CHANGE_INTERFACE_JUDGE, MAIN_INTERFACE); + NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN_ALARM); + + // MainAlarmView::GetInstance()->RefreshAlarm(); // clockQty--; diff --git a/code/sdk/application/wearable/fd230app/nativeui/alarm/src/MainAlarmView.cpp b/code/sdk/application/wearable/fd230app/nativeui/alarm/src/MainAlarmView.cpp index c65dc36ef..8f3401b2a 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/alarm/src/MainAlarmView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/alarm/src/MainAlarmView.cpp @@ -230,23 +230,6 @@ void MainAlarmView::AlarmAddButtonCreate(void) //更新闹钟添加按钮的位置 void MainAlarmView::AlarmAddButtonUpdate(uint8_t count) { - // if(nullptr == AddButton_|| group == nullptr) - // { - // return; - // } - // int y = 120; - // int bef_y = 0; - // int aft_y = 0; - // bef_y = AddButton_->GetY(); - // AddButton_->SetY((0 == count) ? (y) : (y * (count + 1))); - // aft_y = AddButton_->GetY(); - // bool is_up_drag = bef_y- aft_y > 0 ? false:true; - - // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[%d]: AddButton_before = %d", __LINE__, bef_y); - // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[%d]: AddButton_after = %d", __LINE__, aft_y); - // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[%d]: is_up_drag = %d", __LINE__, is_up_drag); - // // group->ScrollBy(0, is_up_drag ? - 120 : 120); - // group->Invalidate(); if(nullptr == AddButton_ || TitleLabelExt_ == nullptr) return; int bef_y = 0; @@ -268,7 +251,8 @@ void MainAlarmView::AlarmAddButtonUpdate(uint8_t count) aft_y = AddButton_->GetY(); bool is_up_drag = bef_y- aft_y > 0 ? false:true; if(group) { - group->ScrollBy(0, is_up_drag ? - 120 : 120); + if(viewInitstatus_) + group->ScrollBy(0, is_up_drag ? - 120 : 120); } RootView::GetInstance()->Invalidate(); } @@ -487,13 +471,8 @@ void MainAlarmView::OnStart() return; } } - // group->SetPosition(CONTAINER_X, CONTAINER_Y, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); group->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); group->SetScrollBlankSize(75); - // group->SetMaxScrollDistance(1000); // 1000: max scroll distance - // group->SetSwipeACCLevel(800); // 800: compensation distance - // group->SetDragACCLevel(5); // 5: drag acceleration - // group->SetThrowDrag(true); group->SetTouchable(true); group->SetDraggable(true); group->SetDirection(UIScrollView::VERTICAL); @@ -515,15 +494,13 @@ void MainAlarmView::OnSetUpView() AlarmTitleCreate(); AlarmAddButtonCreate(); - // OHOS::AlarmClockModel::GetInstance()->InitAlarmData(); RefreshAlarm(); if (group != nullptr) { container[0] = group; RootView::GetInstance()->Add(container[0]); container_ = group; } - - // show timerView + viewInitstatus_ = true; Draw(); } diff --git a/code/sdk/application/wearable/fd230app/nativeui/calculator/src/CalculatorView.cpp b/code/sdk/application/wearable/fd230app/nativeui/calculator/src/CalculatorView.cpp index 345e5573a..7f5880616 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/calculator/src/CalculatorView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/calculator/src/CalculatorView.cpp @@ -621,6 +621,16 @@ void CalculatorView::OnStart() WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CalculatorView::OnStart"); View::OnStart(); + SetContainerView(new UIViewGroup()); + if (GetContainer() == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "container_ new fail!!"); + return; + } + container_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); + container_->SetTouchable(true); + container_->SetDraggable(true); + RootView::OnKeyActListener *keyactListener = (RootView::OnKeyActListener *)OHOS::CalculatorPresenter::GetInstance(); RootView::GetInstance()->SetOnKeyActListener(keyactListener); @@ -640,9 +650,7 @@ void CalculatorView::OnStart() return; } group->SetOnDragListener(dragListener); - - RootView::GetInstance()->Add(group); - container_ = group; + container_ ->Add(group); if(!button_init()) { @@ -680,7 +688,12 @@ void CalculatorView::OnStop() { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CalculatorView::~OnStop"); View::OnStop(); - + if(container_!=nullptr) + { + container_->RemoveAll(); + delete container_; + container_=nullptr; + } RootView::GetInstance()->ClearOnKeyActListener(); RootView::GetInstance()->RemoveAll(); return; diff --git a/code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp b/code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp index 653ca3b79..358675cd4 100644 --- a/code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp +++ b/code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp @@ -1464,6 +1464,7 @@ void ble_delet_all_AlarmInfo(void) for(int i=0;i