From 978f6c0f3ac1482125d85a149b1e55ce9c810c8d Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E7=BD=97=E6=AD=A3?= <1732036298@qq.com> Date: Wed, 11 Sep 2024 05:13:13 +0000 Subject: [PATCH] Merge #938 into sdk602patch0626 from refs/changes/938/head MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Code review from 罗正 * refs/changes/938/head: (3 commits squashed) - 闹钟UI优化: 1.#636,解决,手表,闹钟只响铃3次bug 2.闹钟编辑界面优化 3.闹钟界面中星期缩写中文为:一,二...日,其他语言为:Mon,Tue...Sun - Merge branch 'sdk602patch0626' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0626 - #534,解决闹钟设置多个闹钟,只响第一个,后续的没有提示闹钟bug Signed-off-by: 罗正 <1732036298@qq.com> Reviewed-by: snickersun@163.com Merged-by: snickersun@163.com CR-link: https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230/change/938 --- .../nativeui/alarm/include/AlarmClockModel.h | 1 + .../nativeui/alarm/include/AlarmConfigView.h | 31 +- .../nativeui/alarm/include/AlarmNewTimeView.h | 20 +- .../nativeui/alarm/include/AlarmPresenter.h | 14 +- .../nativeui/alarm/include/AlarmSetTimeView.h | 16 +- .../nativeui/alarm/include/MainAlarmView.h | 4 +- .../nativeui/alarm/src/AlarmClockModel.cpp | 18 +- .../nativeui/alarm/src/AlarmConfigView.cpp | 654 ++++++++++-------- .../nativeui/alarm/src/AlarmNewTimeView.cpp | 347 +++++----- .../nativeui/alarm/src/AlarmPresenter.cpp | 13 + .../nativeui/alarm/src/AlarmSetTimeView.cpp | 78 ++- .../nativeui/alarm/src/MainAlarmView.cpp | 88 ++- .../alarmclockmanage/src/AlarmClockManage.cpp | 4 +- .../obumessage/src/OBUMessageModel.cpp | 4 +- .../src/notify/alarm_notification.cpp | 8 +- 15 files changed, 719 insertions(+), 581 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 7666e1c21..6bb071bed 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/alarm/include/AlarmClockModel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/alarm/include/AlarmClockModel.h @@ -123,6 +123,7 @@ public: int InitAlarmData(void); void UpdateAlarmInfoByAppSet(void); + void CancelAlarmRing(); private: void SetAlarmId(uint8_t id); diff --git a/code/sdk/application/wearable/fd230app/nativeui/alarm/include/AlarmConfigView.h b/code/sdk/application/wearable/fd230app/nativeui/alarm/include/AlarmConfigView.h index 1187f4958..700111186 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/alarm/include/AlarmConfigView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/alarm/include/AlarmConfigView.h @@ -1,10 +1,12 @@ /* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: Alarm - * Author: - * Create: 2021-09-11 + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-09-02 20:04:12 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-09-10 16:31:01 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/alarm/include/AlarmConfigView.h */ + #ifndef ALARM_CONFIG_VIEW_H #define ALARM_CONFIG_VIEW_H @@ -21,6 +23,7 @@ #include "common/screen.h" #include "gfx_utils/graphic_log.h" #include "AlarmClockModel.h" +#include "components/ui_label_button_ext.h" namespace OHOS { class AlarmConfigView { @@ -31,22 +34,18 @@ public: static AlarmConfigView *GetInstance(void); void RefreshConfig(const uint32 time, uint8 week, uint16_t alarmNum); private: - // UILabelButton *deleteImage{nullptr}; - UIScrollView *configScroll{nullptr}; + void InitLabel(); + void InitButton(); UIScrollView *group{nullptr}; - UILabel *editLabel{nullptr}; - UIDigitalClock *labelTime{nullptr}; + UIScrollView *configScroll{nullptr}; + UILabelExt *editLabel{nullptr}; + UILabelButtonExt* button1{nullptr}; + UILabelButtonExt* button2{nullptr}; + UILabelExt *labelTime{nullptr}; UILabel *labelSetTime{nullptr}; UILabel *labelDay{nullptr}; UILabel *labelSetWeek{nullptr}; - // UILabel *labelChangeName{nullptr}; - // UILabel *labelSetName{nullptr}; - UIImageView *changeIcon1{nullptr}; - UIImageView *changeIcon2{nullptr}; - // UIImageView *changeIcon3{nullptr}; - UILabel *CreateConfigLabel(const char *buttonText, int16_t labelFont, int16_t x, int16_t y, int16_t width); - void CreateConfigButton(void); - void CreateChangeIcons(void); + char showtime[12]{0}; }; } // namespace OHOS #endif // ALARM_CONFIG_VIEW_H \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/alarm/include/AlarmNewTimeView.h b/code/sdk/application/wearable/fd230app/nativeui/alarm/include/AlarmNewTimeView.h index 47db9b853..ac5482d9c 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/alarm/include/AlarmNewTimeView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/alarm/include/AlarmNewTimeView.h @@ -1,21 +1,22 @@ /* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: Alarm - * Author: - * Create: 2021-09-11 + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-08-29 10:39:02 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-09-10 10:21:45 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/alarm/include/AlarmNewTimeView.h */ #ifndef ALARM_NEW_TIME_VIEW_H #define ALARM_NEW_TIME_VIEW_H -#include "components/ui_label_button.h" +#include "components/ui_label_button_ext.h" #include "components/ui_picker.h" #include "components/ui_scroll_view.h" #include "components/ui_time_picker.h" #include "View.h" #include "BaseView.h" -#include "AlarmPresenter.h" -#include "AlarmClockModel.h" +#include "alarm/include/AlarmPresenter.h" +#include "alarm/include/AlarmClockModel.h" namespace OHOS { class AlarmNewTimeView : public UITimePicker::SelectedListener { @@ -28,10 +29,9 @@ public: private: void CreateLabelTime(void); UIScrollView *group{nullptr}; - UILabel *title{nullptr}; + UILabelExt *title{nullptr}; UITimePicker *picker{nullptr}; - UILabelButton *labelButton{nullptr}; - UILabel *GetTitleLabel(const char *titleName); + UILabelButtonExt *labelButton{nullptr}; }; } // namespace OHOS #endif // ALARM_SET_TIME_VIEW_H \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/alarm/include/AlarmPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/alarm/include/AlarmPresenter.h index 3ce454670..12906bb74 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/alarm/include/AlarmPresenter.h +++ b/code/sdk/application/wearable/fd230app/nativeui/alarm/include/AlarmPresenter.h @@ -34,7 +34,7 @@ #include "common/key_code.h" namespace OHOS { -constexpr char* EVERY_DAY = (char *)"每天"; +constexpr char* EVERY_DAY = (char *)"每日"; constexpr char* DO_NOT_REPEAT = (char *)"不重复"; constexpr char* MON_DAY = (char *)"一 "; @@ -45,6 +45,17 @@ constexpr char* FRI_DAY = (char *)"五 "; constexpr char* SAT_DAY = (char *)"六 "; constexpr char* SUN_DAY = (char *)"日"; +constexpr char* EVERY_DAY_EN = (char *)"Everyday"; +constexpr char* DO_NOT_REPEAT_EN = (char *)"no-repeat"; + +constexpr char* MON_DAY_EN = (char *)"Mon "; +constexpr char* TUE_DAY_EN = (char *)"Tue "; +constexpr char* WED_DAY_EN = (char *)"Wed "; +constexpr char* THUR_DAY_EN = (char *)"Thu "; +constexpr char* FRI_DAY_EN = (char *)"Fri "; +constexpr char* SAT_DAY_EN = (char *)"Sat "; +constexpr char* SUN_DAY_EN = (char *)"Sun"; + constexpr char* SET_TIME = (char *)"settime"; constexpr char* SET_WEEK = (char *)"setweek"; constexpr char* ALARM_CLOCK_DELETE = (char *)"alarmclockdelete"; @@ -165,6 +176,7 @@ public: void ClickDeleteButtonAlarmClockDelete(uint16_t num); void UpdateAlarmInfoByAppSet(void); + void RefreshAlarmStatus(int i); private: uint32_t timeHour{0}; diff --git a/code/sdk/application/wearable/fd230app/nativeui/alarm/include/AlarmSetTimeView.h b/code/sdk/application/wearable/fd230app/nativeui/alarm/include/AlarmSetTimeView.h index eb668c522..0e8b814bb 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/alarm/include/AlarmSetTimeView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/alarm/include/AlarmSetTimeView.h @@ -1,14 +1,16 @@ /* - * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. - * Description: Alarm - * Author: - * Create: 2021-09-11 + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-09-02 20:04:12 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-09-10 10:59:27 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/alarm/include/AlarmSetTimeView.h */ + #ifndef ALARM_SET_TIME_VIEW_H #define ALARM_SET_TIME_VIEW_H -#include "components/ui_label_button.h" +#include "components/ui_label_button_ext.h" #include "components/ui_picker.h" #include "components/ui_scroll_view.h" #include "components/ui_time_picker.h" @@ -29,8 +31,8 @@ public: private: UIScrollView *group{nullptr}; // UILabelButton *timeImage{nullptr}; - UILabelButton * labelButton{nullptr}; - UILabel *title{nullptr}; + UILabelButtonExt * labelButton{nullptr}; + UILabelExt *title{nullptr}; UITimePicker *picker{nullptr}; UILabel *GetTitleLabel(const char *titleName); void SetLabelButton(void); 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 77b9a4e6d..8b8b1e02d 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/alarm/include/MainAlarmView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/alarm/include/MainAlarmView.h @@ -60,9 +60,9 @@ public: bool ChangeMaxClock(int16_t thisView); bool ClickFunc(int16_t interface); bool GetRefreshStatus(void); + void RefreshAlarmStatus(uint8_t alarmEnable, int16_t num); private: void LabelGetWeek(uint8_t week, int16_t alarmNum); - void RefreshAlarmStatus(uint8_t alarmEnable, int16_t num); void NewClockCtl(int16_t alarmNum); UIViewGroup * NewClockCtlExt(int16_t alarmNum, uint8_t index); void AlarmTitleCreate(void); @@ -82,7 +82,7 @@ private: UIToggleButton *statusButton[6]{nullptr}; // 6代表界面中最多存在六个按键 // UIImageView *addButton{nullptr}; UIDigitalClock *dClock[6]{nullptr}; // 6代表界面中最多存在六个闹钟 - UILabel *dLabel[6]{nullptr}; // 6代表界面中显示闹钟日期的控件个数 + UILabelExt *dLabel[6]{nullptr}; // 6代表界面中显示闹钟日期的控件个数 UIScrollView *container[7]{nullptr}; // 7代表容器存有主界面以及跳转的四个副界面,用于跳转后显示或隐藏界面 uint8_t alarmHour, alarmMin; int8_t dClockNum{-1}; 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 c7b6365e3..c0cb884fd 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/alarm/src/AlarmClockModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/alarm/src/AlarmClockModel.cpp @@ -721,7 +721,7 @@ void AlarmClockModel::ResetRingClockStatus() } if (currentAlarm[clockListener]->repeatPeriod == 0) { currentAlarm[clockListener]->alarmClockEnable = 0; - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AlarmClockModel::ResetRingClockStatus"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmClockModel::ResetRingClockStatus clockListener = %d",clockListener); } } @@ -1080,6 +1080,22 @@ void AlarmClockModel::UpdateAlarmInfoByAppSet(void) } } +void AlarmClockModel::CancelAlarmRing() +{ + bool alarmStatus; + uint8_t alarm = 0; + alarmStatus = AlarmClockModel::GetInstance()->GetListenClockId(&alarm); + if (!alarmStatus) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmPopUpPresenter::CancelAlarmRing get alarm Id false!"); + return; + } + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CancelAlarmRing alarm = %d",alarm); + AlarmClockModel::GetInstance()->ResetRingClockStatus(); + AlarmClockModel::GetInstance()->SetCancelAlarm(alarm); + if(AlarmPresenter::GetInstance()) { + AlarmPresenter::GetInstance()->RefreshAlarmStatus(clockListener); + } +} bool AlarmPlayerListener::IsPaused() { diff --git a/code/sdk/application/wearable/fd230app/nativeui/alarm/src/AlarmConfigView.cpp b/code/sdk/application/wearable/fd230app/nativeui/alarm/src/AlarmConfigView.cpp index ffc42d652..2799c227a 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/alarm/src/AlarmConfigView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/alarm/src/AlarmConfigView.cpp @@ -5,14 +5,16 @@ * Create: 2021-09-11 */ -#include "AlarmConfigView.h" +#include "alarm/include/AlarmConfigView.h" #include "UiConfig.h" #include -#include "AlarmPresenter.h" +#include "alarm/include/AlarmPresenter.h" #include #include "color.h" +#include "ConfigModel.h" -namespace OHOS { +namespace OHOS +{ #define SET_ALARM "编辑闹钟" #define TIME "9:00:00" #define SET_THIS_TIME "更改时间" @@ -24,333 +26,381 @@ namespace OHOS { #define EVERY_DAY "每天" #define DO_NOT_REPEAT "不重复" -static AlarmConfigView *g_pAlarmConfigView = nullptr; -constexpr int16_t CONTAINER_X = 0; -constexpr int16_t CONTAINER_Y = 0; -constexpr int16_t SET_ONE = 1; -constexpr int16_t SET_FOUR = 4; -constexpr int16_t TITLE_X_LEN = 100; -constexpr int16_t MAX_TITLE_X_LEN = 160; -constexpr int16_t MAX_TITLE_Y_LEN = 45; -constexpr int16_t MAX_DATA_X = 65; -constexpr int16_t CLOCK_X = 165; -constexpr int16_t LABEL_WID = 250; -constexpr int16_t MAX_LABEL_H_LEN = 80; -constexpr int16_t MAX_DATA_W_LEN = 275; -constexpr int16_t DIGITAL_CLOCK_FONT = 45; -constexpr int16_t MAX_LABEL_TIME_Y_LEN = 195 - 25; -constexpr int16_t LABEL_SET_TIME_Y = 245 - 25; -constexpr int16_t MAX_LABEL_DAY_Y_LEN = 320 - 30; -constexpr int16_t MAX_LABEL_SET_WEEK_Y_LEN = 380 - 30; -constexpr int16_t MAX_LABEL_LABEL_CHANGE_NAME_Y_LEN = 460; -constexpr int16_t MAX_LABEL_SET_NAME_Y_LEN = 505; -constexpr int16_t MAX_DEFAULT_FONT_LEN = 34; -constexpr int16_t LITTLE_LABEL_FONT = 30; -constexpr int16_t MAX_DEFAULT_FONT_2_LEN = 35; -constexpr int16_t MAX_DEFAULT_LIT_FONT2_LEN = 40; -constexpr int16_t MAX_BACK_BUTTON_HEIGHT_LEN = 64; -constexpr int16_t MAX_FONT_DEFAULT_SIZE_LEN = 24; -constexpr int16_t MAX_DELETE_BUTTON_W_LEN = 320; -constexpr int16_t LABEL_DAY_WIDTH = 320; -constexpr int16_t MAX_DELETE_BUTTON_H_LEN = 100; -constexpr int16_t MAX_DELETE_BUTTON_X_LEN = 63; -constexpr int16_t MAX_DELETE_BUTTON_Y_LEN = 365; -constexpr int16_t MAX_IMAGE_CHANGE_X_LEN = 370; -constexpr int16_t MAX_IMAGE_CHANGE1_Y_LEN = 210 - 25; -constexpr int16_t MAX_IMAGE_CHANGE2_Y_LEN = 350 - 30; -constexpr int16_t MAX_IMAGE_CHANGE3_Y_LEN = 470; -constexpr int16_t MAX_IMAGE_CHANGE_WIDTH = 50; -constexpr int16_t MAX_IMAGE_CHANGE_HEIGHT = 60; -constexpr int16_t CONFIG_SCROLL_SIZE = 50; -constexpr int16_t LABEL_SEMITRANSPARENT = 168; + static AlarmConfigView *g_pAlarmConfigView = nullptr; + constexpr int16_t CONTAINER_X = 0; + constexpr int16_t CONTAINER_Y = 0; + constexpr int16_t SET_ONE = 1; + constexpr int16_t SET_FOUR = 4; + constexpr int16_t TITLE_X_LEN = 100; + constexpr int16_t MAX_TITLE_X_LEN = 160; + constexpr int16_t MAX_TITLE_Y_LEN = 45; + constexpr int16_t MAX_DATA_X = 65; + constexpr int16_t CLOCK_X = 165; + constexpr int16_t LABEL_WID = 250; + constexpr int16_t MAX_LABEL_H_LEN = 80; + constexpr int16_t MAX_DATA_W_LEN = 275; + constexpr int16_t DIGITAL_CLOCK_FONT = 45; + constexpr int16_t MAX_LABEL_TIME_Y_LEN = 195 - 25; + constexpr int16_t LABEL_SET_TIME_Y = 245 - 25; + constexpr int16_t MAX_LABEL_DAY_Y_LEN = 320 - 30; + constexpr int16_t MAX_LABEL_SET_WEEK_Y_LEN = 380 - 30; + constexpr int16_t MAX_LABEL_LABEL_CHANGE_NAME_Y_LEN = 460; + constexpr int16_t MAX_LABEL_SET_NAME_Y_LEN = 505; + constexpr int16_t MAX_DEFAULT_FONT_LEN = 34; + constexpr int16_t LITTLE_LABEL_FONT = 30; + constexpr int16_t MAX_DEFAULT_FONT_2_LEN = 35; + constexpr int16_t MAX_DEFAULT_LIT_FONT2_LEN = 40; + constexpr int16_t MAX_BACK_BUTTON_HEIGHT_LEN = 64; + constexpr int16_t MAX_FONT_DEFAULT_SIZE_LEN = 24; + constexpr int16_t MAX_DELETE_BUTTON_W_LEN = 320; + constexpr int16_t LABEL_DAY_WIDTH = 320; + constexpr int16_t MAX_DELETE_BUTTON_H_LEN = 100; + constexpr int16_t MAX_DELETE_BUTTON_X_LEN = 63; + constexpr int16_t MAX_DELETE_BUTTON_Y_LEN = 365; + constexpr int16_t MAX_IMAGE_CHANGE_X_LEN = 370; + constexpr int16_t MAX_IMAGE_CHANGE1_Y_LEN = 210 - 25; + constexpr int16_t MAX_IMAGE_CHANGE2_Y_LEN = 350 - 30; + constexpr int16_t MAX_IMAGE_CHANGE3_Y_LEN = 470; + constexpr int16_t MAX_IMAGE_CHANGE_WIDTH = 50; + constexpr int16_t MAX_IMAGE_CHANGE_HEIGHT = 60; + constexpr int16_t CONFIG_SCROLL_SIZE = 50; + constexpr int16_t LABEL_SEMITRANSPARENT = 168; -AlarmConfigView::AlarmConfigView() -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AlarmConfigView::AlarmConfigView"); - g_pAlarmConfigView = this; -} + AlarmConfigView::AlarmConfigView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AlarmConfigView::AlarmConfigView"); + g_pAlarmConfigView = this; + } -AlarmConfigView::~AlarmConfigView() -{ - if(nullptr != group) + AlarmConfigView::~AlarmConfigView() { - group->RemoveAll(); + if (nullptr != group) + { + group->RemoveAll(); + if (nullptr != configScroll) + { + configScroll->RemoveAll(); + if (nullptr != editLabel) + { + delete editLabel; + editLabel = nullptr; + } + if (nullptr != labelTime) + { + delete labelTime; + labelTime = nullptr; + } + if (nullptr != labelSetTime) + { + delete labelSetTime; + labelSetTime = nullptr; + } + if (nullptr != labelDay) + { + delete labelDay; + labelDay = nullptr; + } + if (nullptr != labelSetWeek) + { + delete labelSetWeek; + labelSetWeek = nullptr; + } + if (nullptr != button1) + { + delete button1; + button1 = nullptr; + } + if (nullptr != button2) + { + delete button2; + button2 = nullptr; + } + delete configScroll; + configScroll = nullptr; + } + delete group; + group = nullptr; + } + g_pAlarmConfigView = nullptr; + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AlarmConfigView::~AlarmConfigView"); + } - if(nullptr != configScroll) + AlarmConfigView *AlarmConfigView::GetInstance(void) + { + return g_pAlarmConfigView; + } + void AlarmConfigView::InitLabel() + { + if (editLabel == nullptr) { - configScroll->RemoveAll(); - if(nullptr != editLabel) + editLabel = new UILabelExt(); + if (editLabel == nullptr) { - delete editLabel; - editLabel = nullptr; + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmNewTimeView:: new editLabel fail"); + return; } - // delete deleteImage; - // deleteImage = nullptr; - if(nullptr != labelTime) + } + editLabel->SetPosition(83, 50, 300, 35); + editLabel->SetText("编辑闹钟"); + editLabel->SetStyle(STYLE_TEXT_FONT, 30); + editLabel->SetStyle(STYLE_LINE_HEIGHT, 35); + editLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + editLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + editLabel->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION); + editLabel->SetRollSpeed(70); + /* -------------------------------------------------------------------------- */ + // if (labelTime == nullptr) + // { + // labelTime = new UIDigitalClock(); + // if (labelTime == nullptr) + // { + // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmConfigView:: new labelTime fail"); + // return; + // } + // } + // labelTime->SetPosition(93, (120 - 80) / 2, 150, 45); + // labelTime->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 45); + // labelTime->SetTouchable(true); + // labelTime->SetDisplayMode(UIDigitalClock::DISPLAY_24_HOUR_NO_SECONDS); + if (labelTime == nullptr) + { + labelTime = new UILabelExt(); + if (labelTime == nullptr) { - delete labelTime; - labelTime = nullptr; + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmNewTimeView:: new labelSetTime fail"); + return; } - if(nullptr != labelSetTime) + } + labelTime->SetPosition(93, 120 + 12, 250, 45); + labelTime->SetStyle(STYLE_TEXT_FONT, 40); + labelTime->SetStyle(STYLE_LINE_HEIGHT, 45); + labelTime->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 40); + labelTime->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION); + labelTime->SetRollSpeed(70); + /* -------------------------------------------------------------------------- */ + if (labelSetTime == nullptr) + { + labelSetTime = new UILabelExt(); + if (labelSetTime == nullptr) { - delete labelSetTime; - labelSetTime = nullptr; + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmNewTimeView:: new labelSetTime fail"); + return; } - if(nullptr != labelDay) + } + labelSetTime->SetPosition(93, labelTime->GetY() + labelTime->GetHeight(), 250, 35); + labelSetTime->SetText("更改时间"); + labelSetTime->SetStyle(STYLE_TEXT_FONT, 30); + labelSetTime->SetStyle(STYLE_LINE_HEIGHT, 35); + labelSetTime->SetTextColor(Color::GetColorFromRGBA(0x99, 0x99, 0x99, 0xff)); + labelSetTime->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + labelSetTime->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION); + labelSetTime->SetRollSpeed(70); + /* -------------------------------------------------------------------------- */ + if (labelDay == nullptr) + { + labelDay = new UILabelExt(); + if (labelDay == nullptr) { - delete labelDay; - labelDay = nullptr; + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmNewTimeView:: new labelDay fail"); + return; } - if(nullptr != labelSetWeek) + } + labelDay->SetPosition(93, 240 + 12, 250, 45); + labelDay->SetStyle(STYLE_TEXT_FONT, 40); + labelDay->SetStyle(STYLE_LINE_HEIGHT, 45); + labelDay->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 40); + labelDay->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION); + labelDay->SetRollSpeed(70); + /* -------------------------------------------------------------------------- */ + if (labelSetWeek == nullptr) + { + labelSetWeek = new UILabelExt(); + if (labelSetWeek == nullptr) { - delete labelSetWeek; - labelSetWeek = nullptr; + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmNewTimeView:: new labelSetWeek fail"); + return; } - // delete labelChangeName; - // labelChangeName = nullptr; - // delete labelSetName; - // labelSetName = nullptr; - if(nullptr != changeIcon1) + } + labelSetWeek->SetPosition(93, labelDay->GetY() + labelDay->GetHeight(), 250, 35); + labelSetWeek->SetText("更改星期"); + labelSetWeek->SetStyle(STYLE_TEXT_FONT, 30); + labelSetWeek->SetStyle(STYLE_LINE_HEIGHT, 35); + labelSetWeek->SetTextColor(Color::GetColorFromRGBA(0x99, 0x99, 0x99, 0xff)); + labelSetWeek->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + labelSetWeek->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION); + labelSetWeek->SetRollSpeed(70); + } + + void AlarmConfigView::InitButton() + { + UIView::OnClickListener *clickListener = (UIView::OnClickListener *)OHOS::AlarmPresenter::GetInstance(); + if (clickListener == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmConfigView::OnStart clickListener nullptr"); + return; + } + if (nullptr == button1) + { + button1 = new UILabelButtonExt(); + if (nullptr == button1) { - delete changeIcon1; - changeIcon1 = nullptr; + return; } - if(nullptr != changeIcon2) + } + button1->SetPosition(43, 120, 380, 100); + button1->SetViewId(SET_TIME); // 设置时间 + button1->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + button1->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + button1->SetStyle(STYLE_LINE_HEIGHT, 35); + button1->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff000000, UIButton::PRESSED); + button1->SetAlign(TEXT_ALIGNMENT_LEFT); + button1->SetLabelPosition(115, 0); + button1->SetImagePosition(326, 37); + button1->SetImageSrc(PNG_SETTING_NEXT_IMAGE, PNG_SETTING_NEXT_IMAGE); + button1->SetOnClickListener(clickListener); + /* -------------------------------------------------------------------------- */ + if (nullptr == button2) + { + button2 = new UILabelButtonExt(); + if (nullptr == button2) { - delete changeIcon2; - changeIcon2 = nullptr; + return; } - // delete changeIcon3; - // changeIcon3 = nullptr; - - delete configScroll; - configScroll = nullptr; } - delete group; - group = nullptr; + button2->SetPosition(43, 240, 380, 100); + button2->SetViewId(SET_WEEK); // 设置星期 + button2->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + button2->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + button2->SetStyle(STYLE_LINE_HEIGHT, 35); + button2->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff000000, UIButton::PRESSED); + button2->SetAlign(TEXT_ALIGNMENT_LEFT); + button2->SetLabelPosition(115, 0); + button2->SetImagePosition(326, 37); + button2->SetImageSrc(PNG_SETTING_NEXT_IMAGE, PNG_SETTING_NEXT_IMAGE); + button2->SetOnClickListener(clickListener); } - g_pAlarmConfigView = nullptr; - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AlarmConfigView::~AlarmConfigView"); -} -AlarmConfigView *AlarmConfigView::GetInstance(void) -{ - return g_pAlarmConfigView; -} - -UILabel *AlarmConfigView::CreateConfigLabel(const char *buttonText, int16_t labelFont, int16_t x, int16_t y, int16_t width) -{ - if (buttonText == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmConfigView:: buttonText nullptr!"); - return nullptr; - } - UILabel *label = nullptr; - label = new UILabel(); - if (label == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmConfigView:: CreateConfigLabel return nullptr"); - return nullptr; - } - label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, labelFont); - label->SetText(buttonText); - label->SetPosition(x, y, width, MAX_LABEL_H_LEN); - return label; -} - -void AlarmConfigView::CreateChangeIcons(void) -{ - changeIcon1 = new UIImageView(); - if (changeIcon1 == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmConfigView:: new changeIcon1 fail"); - return; - } - changeIcon1->SetPosition(MAX_IMAGE_CHANGE_X_LEN, MAX_IMAGE_CHANGE1_Y_LEN, MAX_IMAGE_CHANGE_WIDTH, MAX_IMAGE_CHANGE_HEIGHT); - changeIcon1->SetSrc(PNG_SETTTING_BUTTON_IMAGE); - configScroll->Add(changeIcon1); - - changeIcon2 = new UIImageView(); - if (changeIcon2 == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmConfigView:: new changeIcon2 fail"); - return; - } - changeIcon2->SetPosition(MAX_IMAGE_CHANGE_X_LEN, MAX_IMAGE_CHANGE2_Y_LEN, MAX_IMAGE_CHANGE_WIDTH, MAX_IMAGE_CHANGE_HEIGHT); - changeIcon2->SetSrc(PNG_SETTTING_BUTTON_IMAGE); - configScroll->Add(changeIcon2); - - // changeIcon3 = new UIImageView(); - // if (changeIcon3 == nullptr) { - // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmConfigView:: new changeIcon3 fail"); - // return; - // } - // changeIcon3->SetPosition(MAX_IMAGE_CHANGE_X_LEN, MAX_IMAGE_CHANGE3_Y_LEN, MAX_IMAGE_CHANGE_WIDTH, MAX_IMAGE_CHANGE_HEIGHT); - // changeIcon3->SetSrc(PNG_SETTTING_BUTTON_IMAGE); - // configScroll->Add(changeIcon3); - - UIView::OnDragListener *configDragListener = (UIView::OnDragListener *)OHOS::AlarmPresenter::GetInstance(); - if (configDragListener == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmConfigView:: new configDragListener fail"); - return; - } - group->SetOnDragListener(configDragListener); -} - -void AlarmConfigView::CreateConfigButton(void) -{ - // editLabel = CreateConfigLabel(SET_ALARM, MAX_DEFAULT_FONT_LEN, TITLE_X_LEN, MAX_TITLE_Y_LEN, LABEL_WID); - editLabel = CreateConfigLabel(SET_ALARM, 30, 83, 50, 300); - if (editLabel == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmConfigView:: new editLabel fail"); - return; - } - editLabel->SetAlign(UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER, UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER); - configScroll->Add(editLabel); - UIView::OnClickListener *clickListener = (UIView::OnClickListener *)OHOS::AlarmPresenter::GetInstance(); - if (clickListener == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmConfigView::OnStart clickListener nullptr"); - return; - } - labelTime = new UIDigitalClock(); - if (labelTime == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmConfigView:: new labelTime fail"); - return; - } - labelTime->SetViewId(SET_TIME); - labelTime->SetPosition(CLOCK_X, MAX_LABEL_TIME_Y_LEN, LABEL_WID, MAX_LABEL_H_LEN); - labelTime->SetFont(DEFAULT_VECTOR_FONT_FILENAME, DIGITAL_CLOCK_FONT); - labelTime->SetTouchable(true); - labelTime->SetDisplayMode(UIDigitalClock::DISPLAY_24_HOUR_NO_SECONDS); - labelTime->SetOnClickListener(clickListener); - configScroll->Add(labelTime); - - labelSetTime = CreateConfigLabel(SET_THIS_TIME, LITTLE_LABEL_FONT, MAX_TITLE_X_LEN, LABEL_SET_TIME_Y, LABEL_WID); - if (labelSetTime == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmConfigView:: new labelSetTime fail"); - return; - } - labelSetTime->SetStyle(STYLE_TEXT_OPA, LABEL_SEMITRANSPARENT); - configScroll->Add(labelSetTime); - labelDay = CreateConfigLabel(WEEK_MON_TUE, MAX_DEFAULT_FONT_LEN, MAX_DATA_X, MAX_LABEL_DAY_Y_LEN, LABEL_DAY_WIDTH); - if (labelDay == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmConfigView:: new labelDay fail"); - return; - } - labelDay->SetAlign(UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER, UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER); - configScroll->Add(labelDay); - labelDay->SetViewId(SET_WEEK); - labelDay->SetTouchable(true); - labelDay->SetOnClickListener(clickListener); - labelSetWeek = CreateConfigLabel(SET_DATA, LITTLE_LABEL_FONT, MAX_TITLE_X_LEN, MAX_LABEL_SET_WEEK_Y_LEN, LABEL_WID); - if (labelSetWeek == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmConfigView:: new labelSetWeek fail"); - return; - } - labelSetWeek->SetStyle(STYLE_TEXT_OPA, LABEL_SEMITRANSPARENT); - configScroll->Add(labelSetWeek); -} - -UIScrollView *AlarmConfigView::InitConfigView(void) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AlarmConfigView::OnStart"); - group = new UIScrollView(); - if (group == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmSetWeekView:: new group fail"); - return nullptr; - } - group->SetPosition(CONTAINER_X, CONTAINER_Y, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); - - configScroll = new UIScrollView(); - if (configScroll == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmConfigView:: new configScroll fail"); - return nullptr; + UIScrollView *AlarmConfigView::InitConfigView(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AlarmConfigView::OnStart"); + if (group == nullptr) + { + group = new UIScrollView(); + if (group == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmSetWeekView:: new group fail"); + return nullptr; + } + group->SetPosition(CONTAINER_X, CONTAINER_Y, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); + UIView::OnDragListener *configDragListener = (UIView::OnDragListener *)OHOS::AlarmPresenter::GetInstance(); + if (configDragListener == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmConfigView:: new configDragListener fail"); + return nullptr; + } + group->SetOnDragListener(configDragListener); + /* -------------------------------------------------------------------------- */ + if (configScroll == nullptr) + { + configScroll = new UIScrollView(); + if (configScroll == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmConfigView:: new configScroll fail"); + return nullptr; + } + } + configScroll->SetPosition(CONTAINER_X, CONTAINER_Y, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); + configScroll->SetReboundSize(CONFIG_SCROLL_SIZE); + configScroll->SetHorizontalScrollState(false); + InitButton(); + InitLabel(); + /* ----------------------------------- Add ---------------------------------- */ + configScroll->Add(button1); + configScroll->Add(button2); + configScroll->Add(editLabel); + configScroll->Add(labelTime); + configScroll->Add(labelSetTime); + configScroll->Add(labelDay); + configScroll->Add(labelSetWeek); + group->Add(configScroll); + } + return group; } - configScroll->Resize(HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); - // configScroll->Resize(HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION - MAX_BACK_BUTTON_HEIGHT_LEN); - configScroll->SetReboundSize(CONFIG_SCROLL_SIZE); - configScroll->SetHorizontalScrollState(false); - CreateConfigButton(); - // labelChangeName = CreateConfigLabel(CHANGE_NAME, MAX_DEFAULT_FONT_LEN, MAX_TITLE_X_LEN, - // MAX_LABEL_LABEL_CHANGE_NAME_Y_LEN, LABEL_WID); - // if (labelChangeName == nullptr) { - // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmConfigView:: new labelChangeName fail"); - // return nullptr; - // } - // configScroll->Add(labelChangeName); - // labelSetName = CreateConfigLabel(SET_NAME, LITTLE_LABEL_FONT, MAX_TITLE_X_LEN, MAX_LABEL_SET_NAME_Y_LEN, LABEL_WID); - // if (labelSetName == nullptr) { - // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmConfigView:: new labelSetName fail"); - // return nullptr; - // } - // labelSetName->SetStyle(STYLE_TEXT_OPA, LABEL_SEMITRANSPARENT); - // configScroll->Add(labelSetName); - // deleteImage = new UILabelButton(); - // if (deleteImage == nullptr) { - // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmConfigView:: new deleteImage fail"); - // return nullptr; - // } - // deleteImage->SetPosition(MAX_DELETE_BUTTON_X_LEN, MAX_DELETE_BUTTON_Y_LEN, MAX_DELETE_BUTTON_W_LEN, MAX_DELETE_BUTTON_H_LEN); - // deleteImage->SetText(DELETE_INTERFACES); - // deleteImage->SetTouchable(true); - // deleteImage->SetViewId(ALARM_CLOCK_DELETE); - // deleteImage->SetTextColor(Color::Red()); - // deleteImage->SetFont(DEFAULT_VECTOR_FONT_FILENAME, MAX_DEFAULT_LIT_FONT2_LEN); - // UIView::OnClickListener *clickListener = (UIView::OnClickListener *)OHOS::AlarmPresenter::GetInstance(); - // deleteImage->SetOnClickListener(clickListener); - // deleteImage->SetImageSrc(PNG_NEW_DEVICE, PNG_NEW_DEVICE); - - CreateChangeIcons(); - group->Add(configScroll); - // group->Add(deleteImage); - return group; -} -void AlarmConfigView::RefreshConfig(const uint32_t time, uint8_t week, uint16_t alarmNum) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AlarmConfigView::RefreshStep"); - uint8_t hour = time >> 16; // 闹钟存储小时位需右移16位 - uint8_t min = time & 0x00FF; // 闹钟存储分钟的位数右边16位需要全部置0 - uint16_t ret; - std::string weekStr; - if (hour > 24) { // 小时数最大为24,加入判断若小时的参数超过24则错误 - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmConfigView::RefreshStep hour > 24 error!"); - return; - } - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AlarmConfigView::week = %u!", week); - if ((week & 0x7f) == 0x7f) { // 判断0~6位是否都为1,如若都为1,则一周7天闹钟都响应 - weekStr = EVERY_DAY; - } else if (week == 0) { // 判断0~6位是否都为0,如若都为0,则一周7天都不响应,闹钟为不重复开启 - weekStr = DO_NOT_REPEAT; - } else { - if ((week & 0x02) == 0x02) { // 判断第1位是否为1,如若为1,则星期一响应 - weekStr += MON_DAY; - } - if ((week & 0x04) == 0x04) { // 判断第2位是否为1,如若为1,则星期二响应 - weekStr += TUE_DAY; - } - if ((week & 0x08) == 0x08) { // 判断第3位是否为1,如若为1,则星期三响应 - weekStr += WED_DAY; + void AlarmConfigView::RefreshConfig(const uint32_t time, uint8_t week, uint16_t alarmNum) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AlarmConfigView::RefreshStep"); + uint8_t hour = time >> 16; // 闹钟存储小时位需右移16位 + uint8_t min = time & 0x00FF; // 闹钟存储分钟的位数右边16位需要全部置0 + uint16_t ret; + std::string weekStr; + std::string weekStr_en; + if (hour > 24) + { // 小时数最大为24,加入判断若小时的参数超过24则错误 + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmConfigView::RefreshStep hour > 24 error!"); + return; } - if ((week & 0x10) == 0x10) { // 判断第4位是否为1,如若为1,则星期四响应 - weekStr += THUR_DAY; + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AlarmConfigView::week = %u!", week); + if ((week & 0x7f) == 0x7f) + { // 判断0~6位是否都为1,如若都为1,则一周7天闹钟都响应 + weekStr = EVERY_DAY; + weekStr_en = EVERY_DAY_EN; } - if ((week & 0x20) == 0x20) { // 判断第5位是否为1,如若为1,则星期五响应 - weekStr += FRI_DAY; + else if (week == 0) + { // 判断0~6位是否都为0,如若都为0,则一周7天都不响应,闹钟为不重复开启 + weekStr = DO_NOT_REPEAT; + weekStr_en = DO_NOT_REPEAT_EN; } - if ((week & 0x40) == 0x40) { // 判断第6位是否为1,如若为1,则星期六响应 - weekStr += SAT_DAY; + else + { + if ((week & 0x02) == 0x02) + { // 判断第1位是否为1,如若为1,则星期一响应 + weekStr += MON_DAY; + weekStr_en += MON_DAY_EN; + } + if ((week & 0x04) == 0x04) + { // 判断第2位是否为1,如若为1,则星期二响应 + weekStr += TUE_DAY; + weekStr_en += TUE_DAY_EN; + } + if ((week & 0x08) == 0x08) + { // 判断第3位是否为1,如若为1,则星期三响应 + weekStr += WED_DAY; + weekStr_en += WED_DAY_EN; + } + if ((week & 0x10) == 0x10) + { // 判断第4位是否为1,如若为1,则星期四响应 + weekStr += THUR_DAY; + weekStr_en += THUR_DAY_EN; + } + if ((week & 0x20) == 0x20) + { // 判断第5位是否为1,如若为1,则星期五响应 + weekStr += FRI_DAY; + weekStr_en += FRI_DAY_EN; + } + if ((week & 0x40) == 0x40) + { // 判断第6位是否为1,如若为1,则星期六响应 + weekStr += SAT_DAY; + weekStr_en += SAT_DAY_EN; + } + if ((week & 0x01) == 0x01) + { // 判断第0位是否为1,如若为1,则星期日响应 + weekStr += SUN_DAY; + weekStr_en += SUN_DAY_EN; + } } - if ((week & 0x01) == 0x01) { // 判断第0位是否为1,如若为1,则星期日响应 - weekStr += SUN_DAY; + if (labelTime == nullptr || labelDay == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmConfigView::RefreshStep labelTime or labelDay error!"); + return; } + showtime[12] = {0}; + sprintf(showtime, "%02d:%02d", hour, min); + // labelTime->SetTime24Hour(hour, min, 0); + labelTime->SetText(showtime); + if (ConfigModel::GetInstance()->GetLanguage() == 0) + labelDay->SetText(weekStr.c_str()); + else + labelDay->SetText(weekStr_en.c_str()); } - if (labelTime == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmConfigView::RefreshStep labelTime error!"); - return; - } - // if (alarmNum == 0) { - // deleteImage->SetVisible(false); - // } else if (alarmNum >= SET_ONE && alarmNum <= SET_FOUR) { - // deleteImage->SetVisible(true); - // } - labelTime->SetTime24Hour(hour, min, 0); - labelDay->SetText(weekStr.c_str()); -} } \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/alarm/src/AlarmNewTimeView.cpp b/code/sdk/application/wearable/fd230app/nativeui/alarm/src/AlarmNewTimeView.cpp index 65faf0c2d..3ad1ac210 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/alarm/src/AlarmNewTimeView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/alarm/src/AlarmNewTimeView.cpp @@ -5,7 +5,7 @@ * Create: 2021-09-11 */ -#include "AlarmNewTimeView.h" +#include "alarm/include/AlarmNewTimeView.h" #include "common/screen.h" #include "components/ui_label.h" #include "components/ui_label_ext.h" @@ -13,195 +13,196 @@ #include #include #include - -namespace OHOS { +#include "ui_resource_string.h" +namespace OHOS +{ #ifndef NEW_TIME // #define NEW_TIME "设置时间" #define NEW_TIME "时间" #endif #define NEXT "下一步" -static AlarmNewTimeView *g_pAlarmNewTimeView = nullptr; -constexpr int16_t CONTAINER_X = 0; -constexpr int16_t CONTAINER_Y = 0; -constexpr int16_t TITLE_X = 153; -constexpr int16_t TITLE_Y = 30; -constexpr int16_t TIME_PICKER_X = 75; -constexpr int16_t TIME_PICKER_WIDTH = 250; -constexpr int16_t TIME_ITEM_HEIGHT = 80; -constexpr int16_t TIME_LABEL_BUTTON_X = 63; -constexpr int16_t TIME_LABEL_BUTTON_Y = 360; -constexpr int16_t LABEL_X = 0; -constexpr int16_t LABEL_Y = 45; -constexpr int16_t LABEL_BLANK = 38; -constexpr int16_t LIST_W = 300; -constexpr int16_t LIST_H = 260; -constexpr int16_t TITLE_LABEL_DEFAULT_HEIGHT = 50; -constexpr int16_t BUTTON_WIDHT3 = 324; -constexpr int16_t BUTTON_HEIGHT3 = 101; -constexpr int16_t PICKER_FONT_SIZE = 25; -constexpr uint8_t BACKGROUND_FONT = 40; -constexpr uint8_t HIGHTLIGHT_FONT = 50; -constexpr uint16_t LABEL_FONT = 40; - -AlarmNewTimeView::AlarmNewTimeView() -{ - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmNewTimeView::AlarmNewTimeView"); - g_pAlarmNewTimeView = this; -} - -AlarmNewTimeView::~AlarmNewTimeView() -{ - group->RemoveAll(); - delete labelButton; - labelButton = nullptr; - delete picker; - picker = nullptr; - delete title; - title = nullptr; - delete group; - group = nullptr; - g_pAlarmNewTimeView = nullptr; - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmNewTimeView::~AlarmNewTimeView"); -} - -AlarmNewTimeView *AlarmNewTimeView::GetInstance(void) -{ - return g_pAlarmNewTimeView; -} - -UILabel *AlarmNewTimeView::GetTitleLabel(const char *titleName) -{ - if (titleName == nullptr) { - return nullptr; - } - UILabel *label = new UILabel(); - if (label == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmNewTimeView:: new label fail"); - return nullptr; - } - // 2: half of screen width - label->SetPosition(LABEL_X, LABEL_Y, HORIZONTAL_RESOLUTION / 2, TITLE_LABEL_DEFAULT_HEIGHT); - label->SetText(titleName); - label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, LABEL_FONT); - return label; -} - -void AlarmNewTimeView::CreateLabelTime(void) -{ - title = GetTitleLabel(NEW_TIME); - if (title == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CreateLabelTime Set title fail"); - return; - } - group->Add(title); - // title->SetPosition(TITLE_X, TITLE_Y); // 672: x-coordinate - title->SetPosition(83, 50, 300, 35); - title->SetStyle(STYLE_TEXT_FONT, 30); - title->SetStyle(STYLE_LINE_HEIGHT, 35); - title->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - title->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); - - title->SetStyle(STYLE_BACKGROUND_OPA, OPA_OPAQUE); - picker = new UITimePicker(); - if (picker == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CreateLabelTime:: new picker fail"); - return; + static AlarmNewTimeView *g_pAlarmNewTimeView = nullptr; + constexpr int16_t CONTAINER_X = 0; + constexpr int16_t CONTAINER_Y = 0; + constexpr int16_t TITLE_X = 153; + constexpr int16_t TITLE_Y = 30; + constexpr int16_t TIME_PICKER_X = 75; + constexpr int16_t TIME_PICKER_WIDTH = 250; + constexpr int16_t TIME_ITEM_HEIGHT = 80; + constexpr int16_t TIME_LABEL_BUTTON_X = 63; + constexpr int16_t TIME_LABEL_BUTTON_Y = 360; + constexpr int16_t LABEL_X = 0; + constexpr int16_t LABEL_Y = 45; + constexpr int16_t LABEL_BLANK = 38; + constexpr int16_t LIST_W = 300; + constexpr int16_t LIST_H = 260; + constexpr int16_t TITLE_LABEL_DEFAULT_HEIGHT = 50; + constexpr int16_t BUTTON_WIDHT3 = 324; + constexpr int16_t BUTTON_HEIGHT3 = 101; + constexpr int16_t PICKER_FONT_SIZE = 25; + constexpr uint8_t BACKGROUND_FONT = 40; + constexpr uint8_t HIGHTLIGHT_FONT = 50; + constexpr uint16_t LABEL_FONT = 40; + + AlarmNewTimeView::AlarmNewTimeView() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmNewTimeView::AlarmNewTimeView"); + g_pAlarmNewTimeView = this; } - UITimePicker::SelectedListener *selectedListener = - (UITimePicker::SelectedListener *)OHOS::AlarmPresenter::GetInstance(); - if (selectedListener == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CreateLabelTime:: selectedListener is nullptr"); - return; + AlarmNewTimeView::~AlarmNewTimeView() + { + if (group) + { + group->RemoveAll(); + if (labelButton) + { + delete labelButton; + labelButton = nullptr; + } + if (picker) + { + delete picker; + picker = nullptr; + } + if (title) + { + delete title; + title = nullptr; + } + delete group; + group = nullptr; + } + g_pAlarmNewTimeView = nullptr; + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmNewTimeView::~AlarmNewTimeView"); } - picker->EnableSecond(false); - picker->SetPosition(TIME_PICKER_X, LABEL_Y + LABEL_BLANK, LIST_W, LIST_H); // 652: x-coordinate - picker->SetItemHeight(TIME_ITEM_HEIGHT); - picker->SetLoopState(0, true); - picker->SetLoopState(1, true); - // picker->SetBackgroundFont(DEFAULT_VECTOR_FONT_FILENAME, BACKGROUND_FONT); - // picker->SetHighlightFont(DEFAULT_VECTOR_FONT_FILENAME, HIGHTLIGHT_FONT); - picker->SetHighlightFont(GILROY_BOLD_FONT, 65); // 设置突出显示文本的字体名称和大小。 - picker->SetBackgroundFont(DEFAULT_VECTOR_FONT_FILENAME, 50); - picker->SetTextColor(Color::GetColorFromRGBA(0xcc, 0xcc, 0xcc, 0xff), Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0xff)); - picker->RegisterSelectedListener(selectedListener); - group->Add(picker); -} -UIScrollView *AlarmNewTimeView::InitNewTimeView(void) -{ - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmNewTimeView::OnStart"); - group = new UIScrollView(); - if (group == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmNewTimeView:: new group fail"); - return nullptr; + AlarmNewTimeView *AlarmNewTimeView::GetInstance(void) + { + return g_pAlarmNewTimeView; } - group->SetPosition(CONTAINER_X, CONTAINER_Y); - group->SetWidth(HORIZONTAL_RESOLUTION); - group->SetHeight(VERTICAL_RESOLUTION); - - CreateLabelTime(); - labelButton = new UILabelButton(); - if (labelButton == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmNewTimeView:: new labelButton fail"); - return group; + void AlarmNewTimeView::CreateLabelTime(void) + { + if (title == nullptr) + { + title = new UILabelExt(); + if (title == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmNewTimeView:: new title fail"); + return; + } + } + title->SetPosition(83, 50, 300, 35); + title->SetTextId(STR_TIME); + title->SetStyle(STYLE_TEXT_FONT, 30); + title->SetStyle(STYLE_LINE_HEIGHT, 35); + title->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + title->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + title->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION); + title->SetRollSpeed(70); + group->Add(title); + /* -------------------------------------------------------------------------- */ + if (picker == nullptr) + { + picker = new UITimePicker(); + if (picker == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CreateLabelTime:: new picker fail"); + return; + } + } + picker->EnableSecond(false); + picker->SetPosition(TIME_PICKER_X, LABEL_Y + LABEL_Y, LIST_W, LIST_H); + picker->SetItemHeight(TIME_ITEM_HEIGHT); + picker->SetLoopState(0, true); + picker->SetLoopState(1, true); + // picker->SetBackgroundFont(DEFAULT_VECTOR_FONT_FILENAME, BACKGROUND_FONT); + // picker->SetHighlightFont(DEFAULT_VECTOR_FONT_FILENAME, HIGHTLIGHT_FONT); + picker->SetHighlightFont(GILROY_BOLD_FONT, 65); // 设置突出显示文本的字体名称和大小。 + picker->SetBackgroundFont(DEFAULT_VECTOR_FONT_FILENAME, 50); + picker->SetTextColor(Color::GetColorFromRGBA(0xcc, 0xcc, 0xcc, 0xff), Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0xff)); + UITimePicker::SelectedListener *selectedListener = (UITimePicker::SelectedListener *)OHOS::AlarmPresenter::GetInstance(); + if (selectedListener == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CreateLabelTime:: selectedListener is nullptr"); + return; + } + picker->RegisterSelectedListener(selectedListener); + group->Add(picker); } - // labelButton->Resize(BUTTON_WIDHT3, BUTTON_HEIGHT3); - // labelButton->SetPosition(TIME_LABEL_BUTTON_X, TIME_LABEL_BUTTON_Y); - // labelButton->SetText(NEXT); - // labelButton->SetViewId(ALARM_NEXT); - // labelButton->SetTouchable(true); - // labelButton->SetImageSrc(PNG_NEW_DEVICE, PNG_NEW_DEVICE); - // labelButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, LABEL_FONT); - - labelButton->SetPosition(0, 366, 466, 100); - labelButton->SetViewId(ALARM_NEXT); - labelButton->SetText(NEXT); - labelButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); - labelButton->SetTextColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0xff)); - labelButton->SetImageSrc(PNG_BUTTON_466x100_IMAGE, PNG_BUTTON_466x100_IMAGE); - labelButton->SetStyleForState(STYLE_BACKGROUND_COLOR, 0x00, UIButton::PRESSED); - labelButton->SetTouchable(true); - if (OHOS::AlarmPresenter::GetInstance() == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmNewTimeView:: new ShadowBlue fail"); - return group; - } - // labelButton->SetTextColor(OHOS::AlarmPresenter::GetInstance()->ShadowBlue()); - UIView::OnClickListener *clickListener = (UIView::OnClickListener *)OHOS::AlarmPresenter::GetInstance(); - labelButton->SetOnClickListener(clickListener); - group->Add(labelButton); + UIScrollView *AlarmNewTimeView::InitNewTimeView(void) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmNewTimeView::InitNewTimeView"); + if (group == nullptr) + { + group = new UIScrollView(); + if (group == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmNewTimeView:: new group fail"); + return nullptr; + } + } + group->SetPosition(CONTAINER_X, CONTAINER_Y, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); + UIView::OnDragListener *newTimeDragListener = (UIView::OnDragListener *)OHOS::AlarmPresenter::GetInstance(); + if (newTimeDragListener == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmNewTimeView:: new newTimeDragListener fail"); + return group; + } + group->SetOnDragListener(newTimeDragListener); + /* -------------------------------------------------------------------------- */ + CreateLabelTime(); + if (labelButton == nullptr) + { + labelButton = new UILabelButtonExt(); + if (labelButton == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmNewTimeView:: new labelButton fail"); + return group; + } + } + labelButton->SetPosition(0, 366, 466, 100); + labelButton->SetViewId(ALARM_NEXT); + labelButton->SetTextId(STR_NEXT_STEP); // 下一步 + labelButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + labelButton->SetTextColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0xff)); + labelButton->SetImageSrc(PNG_BUTTON_466x100_IMAGE, PNG_BUTTON_466x100_IMAGE); + labelButton->SetStyleForState(STYLE_BACKGROUND_COLOR, 0x00, UIButton::PRESSED); + labelButton->SetTouchable(true); + UIView::OnClickListener *clickListener = (UIView::OnClickListener *)OHOS::AlarmPresenter::GetInstance(); + if (clickListener == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmNewTimeView:: new newTimeDragListener fail"); + return group; + } + labelButton->SetOnClickListener(clickListener); + group->Add(labelButton); - UIView::OnDragListener *newTimeDragListener = (UIView::OnDragListener *)OHOS::AlarmPresenter::GetInstance(); - if (newTimeDragListener == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmNewTimeView:: new newTimeDragListener fail"); return group; } - group->SetOnDragListener(newTimeDragListener); - - return group; -} -void AlarmNewTimeView::RefreshNewTime(void) -{ - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmNewTimeView::RefreshStep"); - struct tm local_time; - time_t seconds = time(nullptr); - if (localtime_r(&seconds, &local_time) == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmClockModel::AlarmGetClockNum get localtime error!"); - return; + void AlarmNewTimeView::RefreshNewTime(void) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmNewTimeView::RefreshStep"); + struct tm local_time; + time_t seconds = time(nullptr); + if (localtime_r(&seconds, &local_time) == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmClockModel::AlarmGetClockNum get localtime error!"); + return; + } + std::ostringstream ostrHour; + std::ostringstream ostMin; + ostrHour << local_time.tm_hour; + ostMin << local_time.tm_min; + std::string weekStr = ostrHour.str() + ":" + ostMin.str(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "time = %s!", weekStr.c_str()); + picker->SetSelected(weekStr.c_str()); // 添加的时间默认初始时间为0点 + uint32_t timeHour = stoi(ostrHour.str()); + uint32_t timeMin = stoi(ostMin.str()); + AlarmPresenter::GetInstance()->OnTimePickerInaction(timeHour, timeMin); } - std::ostringstream ostrHour; - std::ostringstream ostMin; - ostrHour << local_time.tm_hour; - ostMin << local_time.tm_min; - std::string weekStr = ostrHour.str() + ":" + ostMin.str(); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "time = %s!", weekStr.c_str()); - picker->SetSelected(weekStr.c_str()); // 添加的时间默认初始时间为0点 - uint32_t timeHour = stoi(ostrHour.str()); - uint32_t timeMin = stoi(ostMin.str()); - AlarmPresenter::GetInstance()->OnTimePickerInaction(timeHour, timeMin); -} } // namespace OHOS 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 a28756fd3..6e7abdeec 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/alarm/src/AlarmPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/alarm/src/AlarmPresenter.cpp @@ -555,4 +555,17 @@ void AlarmPresenter::UpdateAlarmInfoByAppSet(void) NativeAbility::GetInstance().Back(); } +void AlarmPresenter::RefreshAlarmStatus(int i) +{ + uint8_t alarmEnable = 0; + bool alarmStatus; + alarmStatus = AlarmClockModel::GetInstance()->GetClockStatus(i, &alarmEnable); + if (!alarmStatus) { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AlarmPresenter:: GetClockStatus fail! i = %d", i); + } + if( MainAlarmView::GetInstance()) + { + MainAlarmView::GetInstance()->RefreshAlarmStatus(alarmEnable, i); + } +} } \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/alarm/src/AlarmSetTimeView.cpp b/code/sdk/application/wearable/fd230app/nativeui/alarm/src/AlarmSetTimeView.cpp index 91fce4d83..b1266491b 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/alarm/src/AlarmSetTimeView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/alarm/src/AlarmSetTimeView.cpp @@ -5,13 +5,13 @@ * Create: 2021-09-11 */ -#include "AlarmSetTimeView.h" +#include "alarm/include/AlarmSetTimeView.h" #include "common/screen.h" #include "components/ui_label.h" #include "components/ui_label_ext.h" #include "components/ui_label_button.h" #include - +#include "ui_resource_string.h" namespace OHOS { #define SET_THIS_TIME "设置时间" #define SURE "确认" @@ -51,8 +51,6 @@ AlarmSetTimeView::~AlarmSetTimeView() if(nullptr != group) { group->RemoveAll(); - // delete timeImage; - // timeImage = nullptr; if(nullptr != labelButton) { delete labelButton; @@ -120,16 +118,17 @@ void AlarmSetTimeView::SetLabelButton(void) // timeImage->SetImageSrc(PNG_NEW_DEVICE, PNG_NEW_DEVICE); // group->Add(timeImage); - - labelButton = new UILabelButton(); if (labelButton == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmSetTimeView::SetLabelButton"); - return ; + labelButton = new UILabelButtonExt(); + if (labelButton == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmSetTimeView::SetLabelButton"); + return ; + } } - labelButton->SetPosition(0, 366, 466, 100); labelButton->SetViewId(ALARM_OK); - labelButton->SetText(SURE); + // labelButton->SetText(SURE); + labelButton->SetTextId(STR_OK);//确定 labelButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); labelButton->SetTextColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0xff)); labelButton->SetImageSrc(PNG_BUTTON_466x100_IMAGE, PNG_BUTTON_466x100_IMAGE); @@ -143,31 +142,48 @@ void AlarmSetTimeView::SetLabelButton(void) UIScrollView *AlarmSetTimeView::InitSetTimeView(void) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AlarmSetTimeView::OnStart"); - group = new UIScrollView(); if (group == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmSetTimeView:: new group fail"); - return nullptr; + group = new UIScrollView(); + if (group == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmSetTimeView:: new group fail"); + return nullptr; + } } - group->SetPosition(CONTAINER_X, CONTAINER_Y); - group->SetWidth(HORIZONTAL_RESOLUTION); - group->SetHeight(VERTICAL_RESOLUTION); - - title = GetTitleLabel(SET_THIS_TIME); - if (title == nullptr) { - return nullptr; + group->SetPosition(CONTAINER_X, CONTAINER_Y,Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); + group->SetTouchable(true); + group->SetDraggable(true); + UIView::OnDragListener *setTimeDragListener = (UIView::OnDragListener *)OHOS::AlarmPresenter::GetInstance(); + if (setTimeDragListener == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmSetTimeView:: setTimeDragListener is nullptr"); + return group; + } + group->SetOnDragListener(setTimeDragListener); + /* -------------------------------------------------------------------------- */ + if (title == nullptr) + { + title = new UILabelExt(); + if (title == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmNewTimeView:: new title fail"); + return group; + } } - group->Add(title); - // title->SetPosition(TITLE_X, TITLE_Y); // 672: x-coordinate title->SetPosition(83, 50, 300, 35); + title->SetTextId(STR_TIME); title->SetStyle(STYLE_TEXT_FONT, 30); title->SetStyle(STYLE_LINE_HEIGHT, 35); title->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); title->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); - title->SetStyle(STYLE_BACKGROUND_OPA, OPA_OPAQUE); - picker = new UITimePicker(); + title->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION); + title->SetRollSpeed(70); + group->Add(title); + /* -------------------------------------------------------------------------- */ if (picker == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmSetTimeView:: new picker fail"); - return nullptr; + picker = new UITimePicker(); + if (picker == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmSetTimeView:: new picker fail"); + return nullptr; + } } UITimePicker::SelectedListener *selectedListener = (UITimePicker::SelectedListener *)OHOS::AlarmPresenter::GetInstance(); @@ -176,7 +192,7 @@ UIScrollView *AlarmSetTimeView::InitSetTimeView(void) return nullptr; } picker->EnableSecond(false); - picker->SetPosition(TIME_PICKER_X, LABEL_Y + LABEL_BLANK, LIST_W, LIST_H); // 652: x-coordinate + picker->SetPosition(TIME_PICKER_X, LABEL_Y + LABEL_Y, LIST_W, LIST_H); // 652: x-coordinate picker->SetItemHeight(TIME_ITEM_HEIGHT); // picker->SetBackgroundFont(DEFAULT_VECTOR_FONT_FILENAME, BACKGROUND_FONT); // picker->SetHighlightFont(DEFAULT_VECTOR_FONT_FILENAME, HIGHTLIGHT_FONT); @@ -191,14 +207,6 @@ UIScrollView *AlarmSetTimeView::InitSetTimeView(void) SetLabelButton(); - group->SetTouchable(true); - group->SetDraggable(true); - UIView::OnDragListener *setTimeDragListener = (UIView::OnDragListener *)OHOS::AlarmPresenter::GetInstance(); - if (setTimeDragListener == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmSetTimeView:: setTimeDragListener is nullptr"); - return group; - } - group->SetOnDragListener(setTimeDragListener); return group; } 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 4adfe646b..86e00a1d1 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/alarm/src/MainAlarmView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/alarm/src/MainAlarmView.cpp @@ -10,6 +10,7 @@ #include "ui_label_button.h" #include "PhoneService.h" #include "ui_resource_string.h" +#include "ConfigModel.h" namespace OHOS { static MainAlarmView *g_MainAlarmView = nullptr; @@ -214,8 +215,26 @@ 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_) return; @@ -252,17 +271,20 @@ UIViewGroup * MainAlarmView::NewClockCtlExt(int16_t alarmNum, uint8_t index) dClock[alarmNum]->SetPosition(50, 10, 110, 50); dClock[alarmNum]->SetFont(DEFAULT_VECTOR_FONT_FILENAME, D_CLOCK_FONT_SIZE); dClock[alarmNum]->SetDisplayMode(UIDigitalClock::DISPLAY_24_HOUR_NO_SECONDS); - - dLabel[alarmNum] = new UILabel(); + /* -------------------------------------------------------------------------- */ + dLabel[alarmNum] = new UILabelExt(); if (dLabel[alarmNum] == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainAlarmView:: new dLabel fail"); return nullptr; } dLabel[alarmNum]->SetPosition(50, 60, 200, 35); + dLabel[alarmNum]->SetStyle(STYLE_TEXT_FONT, 30); + dLabel[alarmNum]->SetStyle(STYLE_LINE_HEIGHT, 35); + dLabel[alarmNum]->SetTextColor(Color::GetColorFromRGBA(0x99, 0x99, 0x99, 0xff)); dLabel[alarmNum]->SetFont(DEFAULT_VECTOR_FONT_FILENAME, D_CLOCK_LABEL_FONT); dLabel[alarmNum]->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION); dLabel[alarmNum]->SetRollSpeed(70); - + /* -------------------------------------------------------------------------- */ statusButton[alarmNum] = new UIToggleButton(); if (statusButton[alarmNum] == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainAlarmView:: new statusButton[alarmNum] fail"); @@ -281,7 +303,7 @@ UIViewGroup * MainAlarmView::NewClockCtlExt(int16_t alarmNum, uint8_t index) return nullptr; } statusButton[alarmNum]->SetOnChangeListener((UICheckBox::OnChangeListener *)statusListener); - + /* ----------------------------------- Add ---------------------------------- */ TempGroup_->Add(dClock[alarmNum]); TempGroup_->Add(dLabel[alarmNum]); TempGroup_->Add(statusButton[alarmNum]); @@ -354,36 +376,48 @@ void MainAlarmView::LabelGetWeek(uint8_t week, int16_t alarmNum) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainAlarmView::week = %u!", week); std::string weekStr; + std::string weekStr_en; if ((week & 0x7f) == 0x7f) { // 判断0~6位是否都为1,如若都为1,则一周7天闹钟都响应 weekStr = EVERY_DAY; + weekStr_en = EVERY_DAY_EN; } else if (week == 0) { // 判断0~6位是否都为0,如若都为0,则一周7天都不响应,闹钟为不重复开启 weekStr = DO_NOT_REPEAT; + weekStr_en = DO_NOT_REPEAT_EN; } else { if ((week & 0x02) == 0x02) { // 判断第1位是否为1,如若为1,则星期一响应 weekStr += MON_DAY; + weekStr_en += MON_DAY_EN; } if ((week & 0x04) == 0x04) { // 判断第2位是否为1,如若为1,则星期二响应 weekStr += TUE_DAY; + weekStr_en += TUE_DAY_EN; } if ((week & 0x08) == 0x08) { // 判断第3位是否为1,如若为1,则星期三响应 weekStr += WED_DAY; + weekStr_en += WED_DAY_EN; } if ((week & 0x10) == 0x10) { // 判断第4位是否为1,如若为1,则星期四响应 weekStr += THUR_DAY; + weekStr_en += THUR_DAY_EN; } if ((week & 0x20) == 0x20) { // 判断第5位是否为1,如若为1,则星期五响应 weekStr += FRI_DAY; + weekStr_en += FRI_DAY_EN; } if ((week & 0x40) == 0x40) { // 判断第6位是否为1,如若为1,则星期六响应 weekStr += SAT_DAY; + weekStr_en += SAT_DAY_EN; } if ((week & 0x01) == 0x01) { // 判断第0位是否为1,如若为1,则星期日响应 weekStr += SUN_DAY; + weekStr_en += SUN_DAY_EN; } } - dLabel[alarmNum]->SetFont(DEFAULT_VECTOR_FONT_FILENAME, D_CLOCK_LABEL_FONT); - dLabel[alarmNum]->SetText(weekStr.c_str()); - dLabel[alarmNum]->SetStyle(STYLE_TEXT_OPA, LABEL_SEMITRANSPARENT); + if(ConfigModel::GetInstance()->GetLanguage() == 0) + dLabel[alarmNum]->SetText(weekStr.c_str()); + else + dLabel[alarmNum]->SetText(weekStr_en.c_str()); + dLabel[alarmNum]->ForceResetText(); } bool MainAlarmView::GetRefreshStatus(void) @@ -393,17 +427,20 @@ bool MainAlarmView::GetRefreshStatus(void) void MainAlarmView::RefreshAlarmStatus(uint8_t alarmEnable, int16_t num) { - reflashStatus = true; - if (alarmEnable == 0) { - statusButton[num]->SetState(false); - } else if (alarmEnable == 1) { - statusButton[num]->SetState(true); - } - reflashStatus = false; - dClock[num]->SetVisible(true); - statusButton[num]->SetVisible(true); + if(statusButton[num] && dClock[num] && SwipeView_[num]) + { + reflashStatus = true; + if (alarmEnable == 0) { + statusButton[num]->SetState(false); + } else if (alarmEnable == 1) { + statusButton[num]->SetState(true); + } + reflashStatus = false; + dClock[num]->SetVisible(true); + statusButton[num]->SetVisible(true); - SwipeView_[num]->SetCurrentPage(0); + SwipeView_[num]->SetCurrentPage(0); + } } void MainAlarmView::OnStart() @@ -420,13 +457,16 @@ void MainAlarmView::OnStart() return; } // group->SetPosition(CONTAINER_X, CONTAINER_Y, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); - group->SetPosition(0, 30, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight() - 60); - + group->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); UIView::OnClickListener *clickListener = (UIView::OnClickListener *)OHOS::AlarmPresenter::GetInstance(); - // CreateImage(); - group->SetScrollBlankSize(30); + group->SetScrollBlankSize(50); + // 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); UIView::OnDragListener *alarmDragListener = (UIView::OnDragListener *)OHOS::AlarmPresenter::GetInstance(); if (alarmDragListener == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmSetWeekView:: new alarmDragListener fail"); @@ -521,13 +561,7 @@ void MainAlarmView::RefreshAlarm(void) { if(SwipeView_[dClockNum]) { - group->Remove(SwipeView_[dClockNum]); - group->Remove(SwipeView_[dClockNum]); - - // 0 group->Remove(SwipeView_[dClockNum]); - - // 0 SwipeView_[dClockNum]->RemoveAll(); // 0 if(SwipeViewItem_[dClockNum][0]) diff --git a/code/sdk/application/wearable/fd230app/nativeui/alarmclockmanage/src/AlarmClockManage.cpp b/code/sdk/application/wearable/fd230app/nativeui/alarmclockmanage/src/AlarmClockManage.cpp index 6342f9176..ce5948f36 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/alarmclockmanage/src/AlarmClockManage.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/alarmclockmanage/src/AlarmClockManage.cpp @@ -340,7 +340,7 @@ static int32 DeleteAndUpdataListAlarmToday(uint8 id) if (node == g_alarmTodayList.end() || id > EVENT_ALARM_CLOCK_MAX) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DeleteAndUpdataListAlarmToday id is invalid, id = %u!!", id); - return STATUS_ALARM_ID_INVALID; + // return STATUS_ALARM_ID_INVALID; } (void)SetFirstAlarmToday(TYPE_CUR_NODE_NO_SKIP); @@ -512,7 +512,7 @@ void AlmmgrAlarmClockEventProcess(const AlarmClockQueueMsg *alarmClockMsg) WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlmmgrAlarmClockEventProcess alarmClockMsg is invalid!!"); return; } - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AlmmgrAlarmClockEventProcess type = %lu ", alarmClockMsg->eventType); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlmmgrAlarmClockEventProcess type = %lu ", alarmClockMsg->eventType); switch (alarmClockMsg->eventType) { case EVENT_ALARM_RING: diff --git a/code/sdk/application/wearable/fd230app/nativeui/obumessage/src/OBUMessageModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/obumessage/src/OBUMessageModel.cpp index d5e915d76..b2b9f027f 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/obumessage/src/OBUMessageModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/obumessage/src/OBUMessageModel.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-07-27 11:22:17 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-09-07 17:14:44 + * @LastEditTime: 2024-09-10 19:57:44 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/obumessage/src/OBUMessageModel.cpp * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE */ @@ -298,7 +298,7 @@ namespace OHOS std::string strSongName = uri; std::string pureName = strSongName.substr(0, strSongName.rfind(".")); // 播放音乐的路径需要引用.号 - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PlayerInit, url:%s ", uri); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PlayerInit, url:%s ", uri.c_str()); //std::string strSrcMusic(APP_MUSIC_PATH); std::string strSrcMusic("/music/ring"); std::string tempStr("/"); diff --git a/code/sdk/application/wearable/service/msg_center/src/notify/alarm_notification.cpp b/code/sdk/application/wearable/service/msg_center/src/notify/alarm_notification.cpp index 42582948b..db4838da5 100755 --- a/code/sdk/application/wearable/service/msg_center/src/notify/alarm_notification.cpp +++ b/code/sdk/application/wearable/service/msg_center/src/notify/alarm_notification.cpp @@ -26,7 +26,7 @@ namespace OHOS constexpr int32_t NOTIFY_ONE_SECOND = 1000; constexpr int32_t NOTIFY_THIRTY_SECONDS = 30 * 1000; // 30秒 constexpr int32_t NOTIFY_ONE_MINUTE = 60 * 1000; - static int popalarm_time = 60; + static int popalarm_time = 50; constexpr int32_t NOTOFY_NO_OPERATE_TIME = 30 * 1000; // 无操作30s超时时间 osTimerId_t g_notifyStopHandle = nullptr; // timer of close view and alarm ring view osTimerId_t g_alarmRing = nullptr; // timer of alarm view @@ -101,6 +101,7 @@ namespace OHOS { DisableAlarmTimer(AlarmTimerType::NOTIFY_ALARM_RING); // AlarmPopUpPresenter::GetInstance()->CancelAlarmRing(); + AlarmClockModel::GetInstance()->CancelAlarmRing(); FindWatchViewEventListener::GetInstance().PopInterCancelMusic(); NotificationManager::GetInstance()->StopNotify(); } @@ -214,7 +215,7 @@ namespace OHOS return; } g_alarmRing = nullptr; - popalarm_time = 60; + popalarm_time = 50; } break; default: @@ -595,7 +596,7 @@ namespace OHOS if (strcmp(view.GetViewId(), ALARM_VIEW_POPUP) == 0) { DisableAlarmTimer(AlarmTimerType::NOTIFY_ALARM_RING); - // AlarmPopUpPresenter::GetInstance()->CancelAlarmRing(); + AlarmClockModel::GetInstance()->CancelAlarmRing(); FindWatchViewEventListener::GetInstance().PopInterCancelMusic(); NotificationManager::GetInstance()->StopNotify(); } @@ -636,6 +637,7 @@ namespace OHOS { DisableAlarmTimer(AlarmTimerType::NOTIFY_ALARM_RING); // AlarmPopUpPresenter::GetInstance()->CancelAlarmRing(); + AlarmClockModel::GetInstance()->CancelAlarmRing(); FindWatchViewEventListener::GetInstance().PopInterCancelMusic(); NotificationManager::GetInstance()->StopNotify(); } -- 2.17.1