From: luozheng <1732036298@qq.com> Date: Thu, 4 Apr 2024 08:16:34 +0000 (+0800) Subject: 1.添加秒表视图 X-Git-Tag: release_V1.2.70_20241020_135402~1232 X-Git-Url: http://git.snicker.com.cn/?a=commitdiff_plain;h=d1ae9a8123825aa7111d9b6fbefd9ea0efc5fb07;p=mirrors%2FFD230.git 1.添加秒表视图 2.添加倒计时和秒表图片资源 --- diff --git a/code/sdk/application/wearable/fd230app/CMakeLists.txt b/code/sdk/application/wearable/fd230app/CMakeLists.txt index ef3aae1fe..e2ff02ffd 100644 --- a/code/sdk/application/wearable/fd230app/CMakeLists.txt +++ b/code/sdk/application/wearable/fd230app/CMakeLists.txt @@ -252,12 +252,20 @@ set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/heart_blood/src/HeartCardView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/heart_blood/health_service/health_service.cpp + # 语言切换 ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/language/src/LanguageSwitchListAdapter.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/language/src/LanguageSwitchListitemView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/language/src/LanguageSwitchPresenter.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/language/src/LanguageSwitchView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/language/src/LanguageSwitchModel.cpp + #秒表 + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/stopwatch/src/MainStopWatchPresenter.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/stopwatch/src/MainStopWatchView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/stopwatch/src/StopWatchModel.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/stopwatch/src/StopWatchRecordCycleToLimitView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/stopwatch/src/StopWatchRecordTimeToLimitView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/language/LanguageInit.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/config/src/ConfigModel.cpp diff --git a/code/sdk/application/wearable/fd230app/nativelauncher/include/AppViewIDs.h b/code/sdk/application/wearable/fd230app/nativelauncher/include/AppViewIDs.h index 83875d21e..113b71df6 100644 --- a/code/sdk/application/wearable/fd230app/nativelauncher/include/AppViewIDs.h +++ b/code/sdk/application/wearable/fd230app/nativelauncher/include/AppViewIDs.h @@ -56,6 +56,7 @@ typedef enum : uint16_t VIEW_FAST_TRAINING_ATTENTION, // 快速训练项目选择超出提示 VIEW_FIND_PHONE, // 查找手机 VIEW_LANGUAGE_SWITCH, // 语言切换 + VIEW_MAIN_STOPWATCH, // 秒表 /* ----------------------------------- 录音 ----------------------------------- */ VIEW_RECORD, /* ---------------------------------- 界面 ---------------------------------- */ diff --git a/code/sdk/application/wearable/fd230app/nativelauncher/include/NativeLauncher.h b/code/sdk/application/wearable/fd230app/nativelauncher/include/NativeLauncher.h index 59c4144f4..830bad2a0 100644 --- a/code/sdk/application/wearable/fd230app/nativelauncher/include/NativeLauncher.h +++ b/code/sdk/application/wearable/fd230app/nativelauncher/include/NativeLauncher.h @@ -45,6 +45,7 @@ namespace OHOS void InitClassicBluetoothSlice(void); void InitFindPhoneSlice(void); void InitLanguageSwitchSlice(void); + void InitMainStopWatchSlice(void); /* --------------------------------界面------------------------------------ */ void InitRotateSlice(void); void InitBloodSlice(void); diff --git a/code/sdk/application/wearable/fd230app/nativelauncher/include/UiConfig.h b/code/sdk/application/wearable/fd230app/nativelauncher/include/UiConfig.h index 85a4d8b5a..757e573d4 100644 --- a/code/sdk/application/wearable/fd230app/nativelauncher/include/UiConfig.h +++ b/code/sdk/application/wearable/fd230app/nativelauncher/include/UiConfig.h @@ -219,6 +219,7 @@ namespace OHOS static constexpr const char *PNG_APPLIST_RECORD_IMAGE = APP_RES_PATH "/APPLIST_RECORD_IMAGE.bin"; // 录音 static constexpr const char *PNG_APPLIST_TRAINING_IMAGE = APP_RES_PATH "/APPLIST_TRAINING.bin"; // 训练 static constexpr const char *PNG_APPLIST_TRAINING_RECORD_IMAGE = APP_RES_PATH "/APPLIST_TRAINING_RECORD.bin"; // 训练记录 + static constexpr const char *PNG_APPLIST_STOPWATCH_IMAGE = APP_RES_PATH "/APPLIST_STOPWATCH.bin"; // 秒表 /* ---------------------------------- 快速训练 ---------------------------------- */ static constexpr const char *PNG_TRAING_BOUTTONMORE_IMAGE = APP_RES_PATH "/Training/More.bin"; static constexpr const char *PNG_TRAING_BUTTONGRONG_IMAGE = APP_RES_PATH "/Training/Bouttonground.bin"; diff --git a/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp b/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp index 6ed5ba071..ae32d0041 100644 --- a/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp +++ b/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp @@ -143,6 +143,9 @@ #include "language/include/LanguageSwitchPresenter.h" #include "language/include/LanguageSwitchView.h" + +#include "stopwatch/include/MainStopWatchPresenter.h" +#include "stopwatch/include/MainStopWatchView.h" /* -------------------------------------------------------------------------- */ #include "traing/include/TraingView.h" #include "traing/include/TraingPresenter.h" @@ -260,7 +263,8 @@ namespace OHOS {VIEW_RECORD, &NativeLauncher::InitRecordingSlice}, // 录音实例化地址 {VIEW_FIND_PHONE, &NativeLauncher::InitFindPhoneSlice}, - {VIEW_LANGUAGE_SWITCH,&NativeLauncher::InitLanguageSwitchSlice}, + {VIEW_LANGUAGE_SWITCH, &NativeLauncher::InitLanguageSwitchSlice}, + {VIEW_MAIN_STOPWATCH, &NativeLauncher::InitMainStopWatchSlice}, {VIEW_MESSAGE, &NativeLauncher::InitMessageSlice}, {VIEW_ROTATE, &NativeLauncher::InitRotateSlice}, {VIEW_DIALUPDATE, &NativeLauncher::InitDialUpdateSlice}, @@ -1088,7 +1092,7 @@ namespace OHOS NativeAbility::GetInstance().AddSliceProxy(VIEW_FIND_PHONE, findphoneview); } - //语言切换 + // 语言切换 void NativeLauncher::InitLanguageSwitchSlice(void) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitLanguageSwitchSlice"); @@ -1100,5 +1104,16 @@ namespace OHOS } NativeAbility::GetInstance().AddSliceProxy(VIEW_LANGUAGE_SWITCH, languageswitchview); } + + /*秒表*/ + void NativeLauncher::InitMainStopWatchSlice(void) + { + SliceProxy *mainstopwatch = new AbilitySliceProxy; + if (mainstopwatch == nullptr) + { + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_MAIN_STOPWATCH, mainstopwatch); + } } diff --git a/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistModel.cpp index 01bb17e1b..5cfe6b578 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistModel.cpp @@ -36,7 +36,8 @@ namespace OHOS {VIEW_RECORD, PNG_APPLIST_RECORD_IMAGE, PNG_APPLIST_RECORD_IMAGE, "录音", nullptr}, {VIEW_CALLER_LOG, PNG_APPLIST_CALLLOG_IMAGE, PNG_APPLIST_CALLLOG_IMAGE, "通话记录", nullptr}, {VIEW_PHONE, PNG_APPLIST_CALLER_IMAGE, PNG_APPLIST_CALLER_IMAGE, "电话", nullptr}, - {VIEW_CONNECT_PHONE, PNG_CONNECT_PHONE_IMAGE, PNG_CONNECT_PHONE_IMAGE, "连接手机", nullptr}, + {VIEW_MAIN_STOPWATCH, PNG_APPLIST_STOPWATCH_IMAGE, PNG_APPLIST_STOPWATCH_IMAGE, "秒表", nullptr}, + //{VIEW_CONNECT_PHONE, PNG_CONNECT_PHONE_IMAGE, PNG_CONNECT_PHONE_IMAGE, "连接手机", nullptr}, //{VIEW_LANGUAGE_SWITCH, PNG_CONNECT_PHONE_IMAGE, PNG_CONNECT_PHONE_IMAGE, "语言切换", nullptr}, #ifdef SUPPORT_ALIPAY_SEC {VIEW_MAIN_ALIPAY, PNG_APPLIST_ALIPAY_IMAGE, PNG_APPLIST_ALIPAY_IMAGE, "支付宝", nullptr}, diff --git a/code/sdk/application/wearable/fd230app/nativeui/compass/src/CompassModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/compass/src/CompassModel.cpp index d789e6d0d..06f069be3 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/compass/src/CompassModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/compass/src/CompassModel.cpp @@ -51,7 +51,7 @@ uint8_t CompassModel::GetCalibrationStatus(void) } /* - * @brief 设置显示的角度 + * @brief 设置显示的角度,通常表示为从地磁北方向到设备当前朝向的角度。 */ void CompassModel::SetDisplayAngle(uint16_t angle) { diff --git a/code/sdk/application/wearable/fd230app/nativeui/settings/src/SettingView.cpp b/code/sdk/application/wearable/fd230app/nativeui/settings/src/SettingView.cpp index 6059b6e1b..a76060ef1 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/settings/src/SettingView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/settings/src/SettingView.cpp @@ -101,7 +101,7 @@ namespace OHOS contentList->SetScrollBlankSize(SETTING_SCROLLBLANKSIZE); contentList->SetSelectPosition(HORIZONTAL_RESOLUTION / SNUM_2); // middle position contentList->SetDraggable(true); - contentList->SetThrowDrag(false); + contentList->SetThrowDrag(true); contentList->EnableAutoAlign(true); contentList->SetReboundSize(REBOUNDSIZE); contentList->SetMaxScrollDistance(MAX_SCR_DIS / SNUM_2); diff --git a/code/sdk/application/wearable/fd230app/nativeui/stopwatch/include/MainStopWatchPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/stopwatch/include/MainStopWatchPresenter.h new file mode 100644 index 000000000..ccb4d9e7c --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/stopwatch/include/MainStopWatchPresenter.h @@ -0,0 +1,65 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-04-04 15:13:51 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-04-04 16:05:17 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/stopwatch/include/MainStopWatchPresenter.h + */ +#ifndef MAIN_STOPWATCH_PRESENTER_H +#define MAIN_STOPWATCH_PRESENTER_H + +#include "Presenter.h" +#include "View.h" +#include "MainStopWatchView.h" +#include +/*秒表主视图*/ +namespace OHOS +{ + typedef enum + { + MAIN_STOPWATCH = 0, // 秒表主视图 + STOPWATCH_RECORD_CYCLE_TO_LIMIT, // 到达秒表计时的最高记录圈数后弹出视图 + STOPWATCH_RECORD_TIME_TO_LIMIT, // 到达秒表最大的记录时间后弹出该视图 + STOPWATCH_MAXVIEWID, // 秒表的视图id数量 + } StopWatchViewId; + class MainStopWatchView; + class MainStopWatchPresenter : public Presenter, + public UIView::OnClickListener, + public UIView::OnDragListener, + public RootView::OnKeyActListener, + public UICheckBox::OnChangeListener + { + public: + MainStopWatchPresenter(); + virtual ~MainStopWatchPresenter(); + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + static MainStopWatchPresenter *GetInstance(); + void SetCheckBoxAndButton(UICheckBox *checkbox, UIButton *button); + void SetLable(UILabel *label1, UILabel *label2); + void SetShowTimeLableStyle(UILabel *label, int x, int y, int TextFont, int LineHeight); + void SetList(UIList *list, TextAdapter *listadapter, List *listdata); + void SetImage(UIImageView *image); + private: + // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; + bool OnClick(UIView &view, const ClickEvent &event) override; + bool OnDrag(UIView &view, const DragEvent &event) override; + bool OnChange(UICheckBox::UICheckBoxState state) override; + bool OnKeyAct(UIView &view, const KeyEvent &event) override; // 增加按键事件 + private: + UICheckBox *m_checkbox{nullptr}; + UIButton *m_button{nullptr}; + UILabel *m_stopWatchlabel{nullptr}; + UILabel *m_showTimelabel{nullptr}; + UIImageView *m_image{nullptr}; + UIList *m_list = nullptr; + TextAdapter *m_listadapter = nullptr; + List *m_listdata = nullptr; + int RecordCycleNumber{0}; // 用来记录点击计时按钮("Mark")的次数 + std::string RecordMaxTime{"99:59.59"}; // 计时时间最高为99:59.59 + }; +} // namespace OHOS + +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/stopwatch/include/MainStopWatchView.h b/code/sdk/application/wearable/fd230app/nativeui/stopwatch/include/MainStopWatchView.h new file mode 100644 index 000000000..3af8a0e0b --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/stopwatch/include/MainStopWatchView.h @@ -0,0 +1,76 @@ +#ifndef MAIN_STOPWATCH_VIEW_H +#define MAIN_STOPWATCH_VIEW_H + +#include "BaseView.h" +#include "View.h" +#include "components/ui_view_group.h" +#include "components/ui_scroll_view.h" +#include "components/ui_label.h" +#include "components/ui_checkbox.h" +#include "components/ui_button.h" +#include "components/ui_list.h" +#include "components/text_adapter.h" +#include "stopwatch/include/StopWatchRecordCycleToLimitView.h" +#include "stopwatch/include/StopWatchRecordTimeToLimitView.h" +/*秒表主视图*/ +namespace OHOS +{ + + static const char *checkBox1selectedImg = "/user/res/countdown/COUNTDOWM_PLAY.bin"; // 播放 + static const char *checkBox1unSelectedImg = "/user/res/countdown/COUNTDOWM_PAUSE.bin"; // 暂停 + static const char *ResetOrMarkButtonImg_Reset1 = "/user/res/stopwatch/STOPWATH_RESET1.bin"; // 重置_灰色 图片 + static const char *ResetOrMarkButtonImg_Reset2 = "/user/res/stopwatch/STOPWATH_RESET2.bin"; // 重置_白色 图片 + static const char *ResetOrMarkButtonImg_Mark = "/user/res/stopwatch/STOPWATCH_MARK.bin"; // 标记 图片 + static const char *PlayOrPausecheckBoxVIEWID = "PlayOrPausecheckBox"; // 播放或暂停复选框视图ID + static const char *ResetOrMarkButton_RESET1_VIEWID = "ResetOrMarkButtonReset1"; // ResetOrMarkButtonReset1 + static const char *ResetOrMarkButton_RESET2_VIEWID = "ResetOrMarkButtonReset2"; // ResetOrMarkButtonReset2 + static const char *ResetOrMarkButton_MARK_VIEWID = "ResetOrMarkButtonMark"; // ResetOrMarkButtonMark + static const char *CycleToLimitReturnButton_VIEWID = "CycleToLimitReturnButton"; // CycleToLimitReturnButton + static const char *TimeToLimitReturnButton_VIEWID = "TimeToLimitReturnButton"; // TimeToLimitReturnButton + class MainStopWatchPresenter; + class MainStopWatchView : public View + { + + public: + MainStopWatchView(); + virtual ~MainStopWatchView(); + static MainStopWatchView *GetInstance(void); + + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStop() override; + void SetViewIsVisible(UIView *view, bool status); + bool ClickFunc(int16_t interface); + void ChangeView(int16_t hideView, int16_t showView); + bool ChangeMainStopWatch(int16_t thisView); + bool ChangeStopWatchRecordCycleLimit(int16_t thisView); + bool ChangeMainStopWatchRecordTimeLimit(int16_t thisView); + + private: + void InitMainStopWatchView(void); + void DeInitView(void); + void PreLoad(void); + + private: + StopWatchRecordCycleToLimitView *p_StopWatchRecordCycleToLimitView{nullptr}; // 圈数到达上限后弹出该视图 + StopWatchRecordTimeToLimitView *p_StopWatchRecordTimeToLimitView{nullptr}; // 计时时间到达上限后弹出该视图 + + private: + UIViewGroup *container_ = nullptr; + UIScrollView *scrollView[3] = {nullptr}; + UILabel *stopWatchlabel = nullptr; // 内容为“秒表”的标签 + UILabel *showTimelabel = nullptr; // 用来显示计时时间 + UICheckBox *PlayOrPausecheckBox = nullptr; // 播放或暂停复选框 + UIButton *ResetOrMarkbutton = nullptr; // 重置或标记按钮 + UIImageView *LineImage{nullptr}; + UIList *list = nullptr; + TextAdapter *listadapter = nullptr; + List *listdata = nullptr; + UIView::OnDragListener *draglistener{nullptr}; + UICheckBox::OnChangeListener *PlayOrPausecheckBoxChangeListener{nullptr}; + UIView::OnClickListener *ResetOrMarkbuttonClick{nullptr}; + bool viewInitStatus{false}; + }; +} // namespace OHOS +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/stopwatch/include/StopWatchModel.h b/code/sdk/application/wearable/fd230app/nativeui/stopwatch/include/StopWatchModel.h new file mode 100644 index 000000000..66baa6de1 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/stopwatch/include/StopWatchModel.h @@ -0,0 +1,31 @@ +#ifndef STOP_WATCH_MODEL_H +#define STOP_WATCH_MODEL_H + +#include +#include +#include + +namespace OHOS +{ + class StopWatchModel + { + public: + static std::shared_ptr GetInstance(); // shared_ptr:当没有引用指向这个实例时会自动释放内存 + ~StopWatchModel() {} + char *DisplayMotionDuration(); + + private: + // 将构造函数、拷贝构造函数和赋值操作符私有化 + StopWatchModel() = default; + StopWatchModel(const StopWatchModel &) = delete; + StopWatchModel &operator=(const StopWatchModel &) = delete; + + private: + static int oneDaySec; // 一天的秒数 + static int oneHourSec; // 一个小时的秒数 + static int oneMinuteSec; // 一分钟秒数 + }; + +} + +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/stopwatch/include/StopWatchRecordCycleToLimitView.h b/code/sdk/application/wearable/fd230app/nativeui/stopwatch/include/StopWatchRecordCycleToLimitView.h new file mode 100644 index 000000000..390fa0c36 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/stopwatch/include/StopWatchRecordCycleToLimitView.h @@ -0,0 +1,34 @@ +#ifndef STOPWATCH_RECORD_CYCLE_TO_LIMIT_VIEW_H +#define STOPWATCH_RECORD_CYCLE_TO_LIMIT_VIEW_H + +#include "BaseView.h" +#include "View.h" +#include "components/ui_view_group.h" +#include "components/ui_scroll_view.h" +#include "components/ui_label.h" +#include "components/ui_image_view.h" +#include "components/ui_button.h" +/*弹窗视图:到达最高圈数99时弹出*/ +namespace OHOS +{ + class StopWatchRecordCycleToLimitView + { + + public: + StopWatchRecordCycleToLimitView(); + void DeInitView(void); + virtual ~StopWatchRecordCycleToLimitView(); + static StopWatchRecordCycleToLimitView *GetInstance(void); + UIScrollView *InitStopWatchRecordCycleToLimitView(void); + + private: + UIViewGroup *container_ = nullptr; + UIScrollView *scrollView1_ = nullptr; + UILabel *label1_ = nullptr; + UIImageView *image1_ = nullptr; + UILabel *label3_ = nullptr; + UIButton *button1_ = nullptr; + bool viewInitStatus{false}; + }; +} // namespace OHOS +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/stopwatch/include/StopWatchRecordTimeToLimitView.h b/code/sdk/application/wearable/fd230app/nativeui/stopwatch/include/StopWatchRecordTimeToLimitView.h new file mode 100644 index 000000000..22495f27c --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/stopwatch/include/StopWatchRecordTimeToLimitView.h @@ -0,0 +1,32 @@ +#ifndef STOPWATCH_RECORD_TIME_TO_LIMIT_VIEW_H +#define STOPWATCH_RECORD_TIME_TO_LIMIT_VIEW_H + +#include "BaseView.h" +#include "View.h" +#include "components/ui_view_group.h" +#include "components/ui_scroll_view.h" +#include "components/ui_label.h" +#include "components/ui_image_view.h" +#include "components/ui_button.h" +/*弹窗视图:到达最高时间99:59.99时弹出*/ +namespace OHOS +{ + class StopWatchRecordTimeToLimitView + { + public: + StopWatchRecordTimeToLimitView(); + virtual ~StopWatchRecordTimeToLimitView(); + static StopWatchRecordTimeToLimitView *GetInstance(void); + UIScrollView *InitStopWatchRecordTimeToLimitView(void); + void DeInitView(void); + + private: + UIScrollView *scrollView1_ = nullptr; + UILabel *label1_ = nullptr; + UIImageView *image1_ = nullptr; + UILabel *label3_ = nullptr; + UIButton *button1_ = nullptr; + bool viewInitStatus{false}; + }; +} // namespace OHOS +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/stopwatch/src/MainStopWatchPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/stopwatch/src/MainStopWatchPresenter.cpp new file mode 100644 index 000000000..4c5e74255 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/stopwatch/src/MainStopWatchPresenter.cpp @@ -0,0 +1,207 @@ +#include "AppViewIDs.h" +#include "NativeAbility.h" +#include "stopwatch/include/MainStopWatchPresenter.h" +#include "common/key_code.h" +#include +/*秒表主视图*/ +namespace OHOS +{ + + // 当前Presenter属性实例化的内存指针 + static MainStopWatchPresenter *g_pMainStopWatchPresenter = nullptr; + + MainStopWatchPresenter::MainStopWatchPresenter() + { + + g_pMainStopWatchPresenter = this; + } + + MainStopWatchPresenter::~MainStopWatchPresenter() + { + + g_pMainStopWatchPresenter = nullptr; + } + + MainStopWatchPresenter *MainStopWatchPresenter::GetInstance() + { + + return g_pMainStopWatchPresenter; + } + + void MainStopWatchPresenter::OnStart() + { + + Presenter::OnStart(); + } + + void MainStopWatchPresenter::OnPause(void) + { + + Presenter::OnPause(); + } + + void MainStopWatchPresenter::OnResume(void) + { + + Presenter::OnResume(); + } + + void MainStopWatchPresenter::OnStop(void) + { + + Presenter::OnStop(); + } + + /// @brief 设置复选框和按钮 + /// @param checkbox + /// @param button + void MainStopWatchPresenter::SetCheckBoxAndButton(UICheckBox *checkbox, UIButton *button) + { + m_checkbox = checkbox; + m_button = button; + } + + /// @brief 设置标签 + /// @param label1 + /// @param label2 + void MainStopWatchPresenter::SetLable(UILabel *label1, UILabel *label2) + { + m_stopWatchlabel = label1; + m_showTimelabel = label2; + } + + /// @brief 设置显示时间的标签样式 + /// @param label + /// @param x + /// @param y + /// @param TextFont + /// @param LineHeight + void MainStopWatchPresenter::SetShowTimeLableStyle(UILabel *label, int x, int y, int TextFont, int LineHeight) + { + label->SetPosition(x, y); + label->SetStyle(STYLE_TEXT_FONT, TextFont); + label->SetStyle(STYLE_LINE_HEIGHT, LineHeight); + label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, TextFont); + label->Invalidate(); + } + + void MainStopWatchPresenter::SetList(UIList *list, TextAdapter *listadapter, List *listdata) + { + m_list = list; + m_listadapter = listadapter; + m_listdata = listdata; + } + + void MainStopWatchPresenter::SetImage(UIImageView *image) + { + m_image = image; + } + + bool MainStopWatchPresenter::OnDrag(UIView &view, const DragEvent &event) + { + UNUSED(view); + if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && + (event.GetDeltaX() > 20) && (event.GetDeltaX() > (2 * MATH_ABS(event.GetDeltaY())))) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST); + } + return true; + } + + bool MainStopWatchPresenter::OnClick(UIView &view, const ClickEvent &event) + { + UNUSED(view); + MainStopWatchView *mainStopWatchView = MainStopWatchView::GetInstance(); + const char *clickedViewId = view.GetViewId(); + if (strcmp(clickedViewId, ResetOrMarkButton_MARK_VIEWID) == 0) + { + RecordCycleNumber += 1; + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RecordCycleNumber:%d\n",RecordCycleNumber); + if (RecordCycleNumber >= 99) + { + mainStopWatchView->ChangeView(MAIN_STOPWATCH, STOPWATCH_RECORD_CYCLE_TO_LIMIT); + return true; + } + else + { + mainStopWatchView->SetViewIsVisible(m_stopWatchlabel, false); + SetShowTimeLableStyle(m_showTimelabel, 93, 60, 65, 78); + mainStopWatchView->SetViewIsVisible(m_list, true); + mainStopWatchView->SetViewIsVisible(m_image, true); + } + char *PickerData = (char *)malloc(128); + sprintf(PickerData, "0%d %s %s", RecordCycleNumber, "00:08:09", "+00:08:09"); + m_listdata->PushFront(static_cast(PickerData)); + m_listadapter->SetData(m_listdata); + m_list->SetAdapter(m_listadapter); + m_list->SetStartIndex(RecordCycleNumber - 1); + m_list->SetSelectPosition(RecordCycleNumber); + m_list->RefreshList(); + return true; + } + else if (strcmp(clickedViewId, ResetOrMarkButton_RESET2_VIEWID) == 0) + { + m_button->SetViewId(ResetOrMarkButton_RESET1_VIEWID); + m_button->SetImageSrc(ResetOrMarkButtonImg_Reset1, ResetOrMarkButtonImg_Reset1); + m_button->Invalidate(); + + mainStopWatchView->SetViewIsVisible(m_stopWatchlabel, true); + SetShowTimeLableStyle(m_showTimelabel, 63, 160, 80, 94); + mainStopWatchView->SetViewIsVisible(m_image, false); + if (m_listdata != nullptr) + { + for (int i = 0; i < m_listdata->Size(); i++) + { + char *p = (char *)(m_listdata->Tail()->data_); + free(p); + } + m_listdata->Clear(); + } + mainStopWatchView->SetViewIsVisible(m_list, false); + m_list->Invalidate(); + RecordCycleNumber = 0; + } + else if (strcmp(clickedViewId, CycleToLimitReturnButton_VIEWID) == 0) + { + mainStopWatchView->ChangeView(STOPWATCH_RECORD_CYCLE_TO_LIMIT, MAIN_STOPWATCH); + } + else if (strcmp(clickedViewId, TimeToLimitReturnButton_VIEWID) == 0) + { + mainStopWatchView->ChangeView(STOPWATCH_RECORD_TIME_TO_LIMIT, MAIN_STOPWATCH); + } + return true; + } + + bool MainStopWatchPresenter::OnChange(UICheckBox::UICheckBoxState state) + { + if (state == UICheckBox::UICheckBoxState::SELECTED) + { + m_button->SetViewId(ResetOrMarkButton_MARK_VIEWID); + m_button->SetImageSrc(ResetOrMarkButtonImg_Mark, nullptr); + m_button->Invalidate(); // 图片重新赋值要刷新该区域 + } + else + { + m_button->SetViewId(ResetOrMarkButton_RESET2_VIEWID); + m_button->SetImageSrc(ResetOrMarkButtonImg_Reset2, nullptr); + m_button->Invalidate(); + } + return true; + } + + // 增加按键事件 + bool MainStopWatchPresenter::OnKeyAct(UIView &view, const KeyEvent &event) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainStopWatchPresenter::OnKeyAct"); + uint16_t keyID = event.GetKeyId(); + uint16_t keyState = event.GetState(); + // 如果是power键就返回上一级 + if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 0 && uapi_get_screen_state() == 0) + { + uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId(); + NativeAbility::GetInstance().ChangeSlice(preSlice); + } + return true; + } + +} \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/stopwatch/src/MainStopWatchView.cpp b/code/sdk/application/wearable/fd230app/nativeui/stopwatch/src/MainStopWatchView.cpp new file mode 100644 index 000000000..6c31fdcf8 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/stopwatch/src/MainStopWatchView.cpp @@ -0,0 +1,385 @@ +#include "stopwatch/include/MainStopWatchView.h" +#include "stopwatch/include/MainStopWatchPresenter.h" +#include "UiConfig.h" +#include "NativeAbility.h" +#include "AppViewIDs.h" +/*秒表主视图*/ +namespace OHOS +{ + + static MainStopWatchView *g_pMainStopWatchView{nullptr}; + + MainStopWatchView::MainStopWatchView() + { + + g_pMainStopWatchView = this; + } + + MainStopWatchView::~MainStopWatchView() + { + if (viewInitStatus == true) + { + DeInitView(); + } + g_pMainStopWatchView = nullptr; + } + + MainStopWatchView *MainStopWatchView::GetInstance() + { + + return g_pMainStopWatchView; + } + + /// @brief 设置视图是否可见 + /// @param view 具体视图 + /// @param status true 可见 false 不可见 + void MainStopWatchView::SetViewIsVisible(UIView *view, bool status) + { + if (status == true) + { + view->SetVisible(true); + } + else + { + view->SetVisible(false); + } + view->Invalidate(); + } + + // 切换到秒表主视图 + bool MainStopWatchView::ChangeMainStopWatch(int16_t thisView) + { + container_->Add(scrollView[thisView]); + return true; + } + + // 切换到秒表到达最高圈数视图 + bool MainStopWatchView::ChangeStopWatchRecordCycleLimit(int16_t thisView) + { + if (scrollView[thisView] == nullptr) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainAlarmView::StopWatchRecordCycleToLimitView"); + p_StopWatchRecordCycleToLimitView = new StopWatchRecordCycleToLimitView(); + if (p_StopWatchRecordCycleToLimitView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainStopWatchView:: new scrollView[%d] fail", thisView); + return false; + } + scrollView[thisView] = p_StopWatchRecordCycleToLimitView->InitStopWatchRecordCycleToLimitView(); + container_->Add(scrollView[thisView]); + } + return true; + } + + // 切换到秒表到达最大时间计时视图 + bool MainStopWatchView::ChangeMainStopWatchRecordTimeLimit(int16_t thisView) + { + if (scrollView[thisView] == nullptr) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainAlarmView::ChangeMainStopWatchRecordTimeLimit"); + p_StopWatchRecordTimeToLimitView = new StopWatchRecordTimeToLimitView(); + if (p_StopWatchRecordTimeToLimitView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainStopWatchView:: new scrollView[%d] fail", thisView); + return false; + } + scrollView[thisView] = p_StopWatchRecordTimeToLimitView->InitStopWatchRecordTimeToLimitView(); + container_->Add(scrollView[thisView]); + } + return true; + } + /* -------------------------------------------------------------------------- */ + // 1.MainStopWatchViewMapper:结构体定义了一个将视图ID映射到特定成员函数指针的映射表。 + struct MainStopWatchViewMapper + { + const int16_t viewId; + bool (MainStopWatchView::*func)(int16_t thisView); + }; + + // 2.ViewMapper[] 是一个静态的视图映射数组,将视图ID与MainStopWatchView类中的特定成员函数指针进行了绑定。 + static const MainStopWatchViewMapper ViewMapper[] = + { + {MAIN_STOPWATCH, &MainStopWatchView::ChangeMainStopWatch}, + {STOPWATCH_RECORD_CYCLE_TO_LIMIT, &MainStopWatchView::ChangeStopWatchRecordCycleLimit}, + {STOPWATCH_RECORD_TIME_TO_LIMIT, &MainStopWatchView::ChangeMainStopWatchRecordTimeLimit}}; + + // 3.根据传入的interface参数执行相应视图ID关联的成员函数。 + bool MainStopWatchView::ClickFunc(int16_t interface) + { + int funcSize = sizeof(ViewMapper) / sizeof(ViewMapper[0]); + for (int i = 0; i < funcSize; i++) + { + if (interface == ViewMapper[i].viewId) + { + bool jug = (this->*(ViewMapper[i].func))(interface); + if (jug == false) + { + return false; + } + return true; + } + } + return false; + } + + // 4.切换视图 + void MainStopWatchView::ChangeView(int16_t hideView, int16_t showView) + { + if (hideView > STOPWATCH_MAXVIEWID) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainStopWatchView:: StopWatchViewId Overstep ones bounds"); + return; + } + scrollView[hideView]->SetVisible(false); + ClickFunc(showView); + scrollView[showView]->SetVisible(true); + Draw(); + } + /* -------------------------------------------------------------------------- */ + // 初始化秒表主视图 + void MainStopWatchView::InitMainStopWatchView() + { + if (scrollView[MAIN_STOPWATCH] == nullptr) + { + scrollView[MAIN_STOPWATCH] = new UIScrollView(); + } + scrollView[MAIN_STOPWATCH]->SetPosition(0, 0); + scrollView[MAIN_STOPWATCH]->Resize(466, 466); + scrollView[MAIN_STOPWATCH]->SetViewId("scrollView1"); + scrollView[MAIN_STOPWATCH]->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + container_->Add(scrollView[MAIN_STOPWATCH]); + scrollView[MAIN_STOPWATCH]->SetVisible(true); + /* -------------------------------------------------------------------------- */ + if (stopWatchlabel == nullptr) + { + stopWatchlabel = new UILabel(); + } + stopWatchlabel->SetPosition(203, 52); + stopWatchlabel->Resize(60, 35); + stopWatchlabel->SetViewId("label1"); + stopWatchlabel->SetStyle(STYLE_TEXT_FONT, 30); + stopWatchlabel->SetStyle(STYLE_LINE_HEIGHT, 35); + stopWatchlabel->SetText("秒表"); + stopWatchlabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + stopWatchlabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + stopWatchlabel->SetRollSpeed(0); + stopWatchlabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + scrollView[MAIN_STOPWATCH]->Add(stopWatchlabel); + stopWatchlabel->SetVisible(true); + /* -------------------------------------------------------------------------- */ + if (showTimelabel == nullptr) + { + showTimelabel = new UILabel(); + } + showTimelabel->SetPosition(63, 160); + showTimelabel->Resize(200, 60); + showTimelabel->SetViewId("showTimelabel"); + showTimelabel->SetStyle(STYLE_TEXT_FONT, 80); + showTimelabel->SetStyle(STYLE_LINE_HEIGHT, 94); + showTimelabel->SetText("00:00.00"); + showTimelabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + showTimelabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + showTimelabel->SetRollSpeed(0); + showTimelabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 80); + scrollView[MAIN_STOPWATCH]->Add(showTimelabel); + showTimelabel->SetVisible(true); + /* -------------------------------------------------------------------------- */ + if (LineImage == nullptr) + { + LineImage = new UIImageView(); + } + LineImage->SetPosition(53, 150); + char *imageimagesPath = "/user/res/stopwatch/STOPWATCH_LINE.bin"; + LineImage->SetSrc(imageimagesPath); + scrollView[MAIN_STOPWATCH]->Add(LineImage); + LineImage->SetVisible(false); + /* -------------------------------------------------------------------------- */ + if (list == nullptr) + { + list = new UIList(); + } + list->SetPosition(56, 170, 360, 100); + list->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); + list->SetReboundSize(30); + if (listadapter == nullptr) + { + listadapter = new TextAdapter(); + } + listadapter->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 28); + if (listdata == nullptr) + { + listdata = new List(); + } + scrollView[MAIN_STOPWATCH]->Add(list); + list->SetVisible(false); + /* -------------------------------------------------------------------------- */ + // Add CheckBox to App + if (PlayOrPausecheckBox == nullptr) + { + PlayOrPausecheckBox = new UICheckBox(); + } + PlayOrPausecheckBox->SetPosition(118, 321); + PlayOrPausecheckBox->Resize(120, 120); + PlayOrPausecheckBox->SetViewId(PlayOrPausecheckBoxVIEWID); + PlayOrPausecheckBox->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); + PlayOrPausecheckBox->SetStyle(STYLE_BORDER_RADIUS, 51); + PlayOrPausecheckBox->SetImages(checkBox1selectedImg, checkBox1unSelectedImg); + // Add to scrollView1 + scrollView[MAIN_STOPWATCH]->Add(PlayOrPausecheckBox); + PlayOrPausecheckBox->SetVisible(true); + /* -------------------------------------------------------------------------- */ + // Add Button to App + if (ResetOrMarkbutton == nullptr) + { + ResetOrMarkbutton = new UIButton(); + } + ResetOrMarkbutton->SetPosition(256, 333); + ResetOrMarkbutton->Resize(100, 100); + ResetOrMarkbutton->SetViewId(ResetOrMarkButton_RESET1_VIEWID); + ResetOrMarkbutton->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); + ResetOrMarkbutton->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + ResetOrMarkbutton->SetImageSrc(ResetOrMarkButtonImg_Reset1, nullptr); + ResetOrMarkbutton->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xfffbfbfb, UIButton::PRESSED); + ResetOrMarkbutton->SetStyleForState(STYLE_BACKGROUND_OPA, 0x00, UIButton::PRESSED); + ResetOrMarkbutton->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + scrollView[MAIN_STOPWATCH]->Add(ResetOrMarkbutton); + ResetOrMarkbutton->SetVisible(true); + /* -------------------------------------------------------------------------- */ + MainStopWatchPresenter::GetInstance()->SetCheckBoxAndButton(PlayOrPausecheckBox, ResetOrMarkbutton); + MainStopWatchPresenter::GetInstance()->SetLable(stopWatchlabel, showTimelabel); + MainStopWatchPresenter::GetInstance()->SetImage(LineImage); + MainStopWatchPresenter::GetInstance()->SetList(list, listadapter, listdata); + // Add the CallBack about events + PlayOrPausecheckBoxChangeListener = static_cast(MainStopWatchPresenter::GetInstance()); + PlayOrPausecheckBox->SetOnChangeListener(PlayOrPausecheckBoxChangeListener); + ResetOrMarkbuttonClick = static_cast(MainStopWatchPresenter::GetInstance()); + ResetOrMarkbutton->SetOnClickListener(ResetOrMarkbuttonClick); + } + + void MainStopWatchView::DeInitView() + { + if (stopWatchlabel != nullptr) + { + delete stopWatchlabel; + stopWatchlabel = nullptr; + } + if (showTimelabel != nullptr) + { + delete showTimelabel; + showTimelabel = nullptr; + } + if (PlayOrPausecheckBox != nullptr) + { + delete PlayOrPausecheckBox; + PlayOrPausecheckBox = nullptr; + } + if (ResetOrMarkbutton != nullptr) + { + delete ResetOrMarkbutton; + ResetOrMarkbutton = nullptr; + } + if (LineImage != nullptr) + { + delete LineImage; + LineImage = nullptr; + } + if (list != nullptr) + { + delete list; + list = nullptr; + } + if (listadapter != nullptr) + { + delete listadapter; + listadapter = nullptr; + } + if (listdata != nullptr) + { + listdata->Clear(); + delete listdata; + listdata = nullptr; + } + if (draglistener != nullptr) + { + delete draglistener; + draglistener = nullptr; + } + if (PlayOrPausecheckBoxChangeListener != nullptr) + { + delete PlayOrPausecheckBoxChangeListener; + PlayOrPausecheckBoxChangeListener = nullptr; + } + if (ResetOrMarkbuttonClick != nullptr) + { + delete ResetOrMarkbuttonClick; + ResetOrMarkbuttonClick = nullptr; + } + if (scrollView[MAIN_STOPWATCH] != nullptr) + { + delete scrollView[MAIN_STOPWATCH]; + scrollView[MAIN_STOPWATCH] = nullptr; + } + if (container_ != nullptr) + { + container_->RemoveAll(); + delete container_; + container_ = nullptr; + } + } + void MainStopWatchView::PreLoad(void) + { + if (!viewInitStatus) + { + InitMainStopWatchView(); + viewInitStatus = true; + } + } + void MainStopWatchView::OnStart() + { + // container_容器属性 new + container_ = new UIViewGroup(); + if (container_ == nullptr) + { + return; + } + // container_容器属性 扩展 + container_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); + draglistener = static_cast(MainStopWatchPresenter::GetInstance()); + if (draglistener == nullptr) + { + return; + } + container_->SetOnDragListener(draglistener); + container_->SetTouchable(true); + container_->SetDraggable(true); + PreLoad(); + RootView::GetInstance()->Add(container_); + // 增加按键监听 + RootView::OnKeyActListener *keyactListener = (RootView::OnKeyActListener *)OHOS::MainStopWatchPresenter::GetInstance(); + RootView::GetInstance()->SetOnKeyActListener(keyactListener); + RootView::GetInstance()->SetIntercept(true); + } + + void MainStopWatchView::OnSetUpView() + { + + View::OnSetUpView(); + Draw(); + } + + void MainStopWatchView::OnTearDownView() + { + + View::OnTearDownView(); + return; + } + + void MainStopWatchView::OnStop() + { + + View::OnStop(); + RootView::GetInstance()->ClearOnKeyActListener(); + RootView::GetInstance()->RemoveAll(); + return; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/stopwatch/src/StopWatchModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/stopwatch/src/StopWatchModel.cpp new file mode 100644 index 000000000..bb4f2be89 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/stopwatch/src/StopWatchModel.cpp @@ -0,0 +1,21 @@ +#include "stopwatch/include/StopWatchModel.h" +#include "cmsis_os2.h" +#include "cmsis_os.h" + +namespace OHOS +{ + int StopWatchModel::oneDaySec = 86400; // 一天的秒数 + int StopWatchModel::oneHourSec = 3600; // 一个小时的秒数 + int StopWatchModel::oneMinuteSec = 60; // 一分钟秒数 + + std::shared_ptr StopWatchModel::GetInstance() // shared_ptr:当没有引用指向这个实例时会自动释放内存 + { + static std::shared_ptr instance(new StopWatchModel()); + return instance; + } + + /* 时间显示 */ + char *StopWatchModel::DisplayMotionDuration() + { + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/stopwatch/src/StopWatchRecordCycleToLimitView.cpp b/code/sdk/application/wearable/fd230app/nativeui/stopwatch/src/StopWatchRecordCycleToLimitView.cpp new file mode 100644 index 000000000..24318e8e0 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/stopwatch/src/StopWatchRecordCycleToLimitView.cpp @@ -0,0 +1,146 @@ +#include "stopwatch/include/StopWatchRecordCycleToLimitView.h" +#include "stopwatch/include/MainStopWatchPresenter.h" +/*弹窗视图:到达最高圈数99时弹出*/ +namespace OHOS +{ + + static StopWatchRecordCycleToLimitView *g_pStopWatchRecordCycleToLimitView{nullptr}; + + StopWatchRecordCycleToLimitView::StopWatchRecordCycleToLimitView() + { + + g_pStopWatchRecordCycleToLimitView = this; + } + + StopWatchRecordCycleToLimitView::~StopWatchRecordCycleToLimitView() + { + if (viewInitStatus == true) + { + DeInitView(); + } + g_pStopWatchRecordCycleToLimitView = nullptr; + } + + StopWatchRecordCycleToLimitView *StopWatchRecordCycleToLimitView::GetInstance() + { + + return g_pStopWatchRecordCycleToLimitView; + } + // 初始化秒表到达最高圈数时弹出的视图 + UIScrollView *StopWatchRecordCycleToLimitView::InitStopWatchRecordCycleToLimitView() + { + if (scrollView1_ == nullptr) + { + scrollView1_ = new UIScrollView(); + } + scrollView1_->SetPosition(0, 0); + scrollView1_->Resize(466, 466); + scrollView1_->SetViewId("scrollView1"); + scrollView1_->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + scrollView1_->SetVisible(true); + /* -------------------------------------------------------------------------- */ + if (label1_ == nullptr) + { + label1_ = new UILabel(); + } + label1_->SetPosition(203, 52); + label1_->Resize(60, 35); + label1_->SetViewId("label1"); + label1_->SetStyle(STYLE_TEXT_FONT, 30); + label1_->SetStyle(STYLE_LINE_HEIGHT, 35); + label1_->SetText("秒表"); + label1_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label1_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label1_->SetRollSpeed(0); + label1_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + scrollView1_->Add(label1_); + label1_->SetVisible(true); + /* -------------------------------------------------------------------------- */ + if (image1_ == nullptr) + { + image1_ = new UIImageView(); + } + image1_->SetPosition(193, 121); + image1_->Resize(100, 100); + image1_->SetViewId("image1"); + image1_->SetStyle(STYLE_BORDER_RADIUS, 100); + char *image1imagesPath = "/user/res/countdown/COUNTDOWN_ATTENTION.bin"; + image1_->SetSrc(image1imagesPath); + scrollView1_->Add(image1_); + image1_->SetVisible(true); + /* -------------------------------------------------------------------------- */ + // Add Label to App + if (label3_ == nullptr) + { + label3_ = new UILabel(); + } + label3_->SetPosition(83, 253); + label3_->Resize(300, 35); + label3_->SetViewId("label3"); + label3_->SetStyle(STYLE_TEXT_FONT, 30); + label3_->SetStyle(STYLE_LINE_HEIGHT, 35); + label3_->SetText("当前已达到了最高圈数"); + label3_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label3_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label3_->SetRollSpeed(0); + label3_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + // Add to scrollView1 + scrollView1_->Add(label3_); + label3_->SetVisible(true); + /* -------------------------------------------------------------------------- */ + // Add Button to App + if (button1_ == nullptr) + { + button1_ = new UIButton(); + } + button1_->SetPosition(0, 366); + button1_->Resize(466, 100); + button1_->SetViewId(CycleToLimitReturnButton_VIEWID); + button1_->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); + button1_->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + char *button1defaultImgSrc = "/user/res/countdown/COUNTDOWN_BUTTON.bin"; + button1_->SetImageSrc(button1defaultImgSrc, nullptr); + button1_->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xfffbfbfb, UIButton::PRESSED); + button1_->SetStyleForState(STYLE_BACKGROUND_OPA, 0x00, UIButton::PRESSED); + button1_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + + // Add the CallBack about events + UIView::OnClickListener *button1Click = static_cast(MainStopWatchPresenter::GetInstance()); + button1_->SetOnClickListener(button1Click); + // Add to scrollView1 + scrollView1_->Add(button1_); + button1_->SetVisible(true); + viewInitStatus == true; + return scrollView1_; + } + + void StopWatchRecordCycleToLimitView::DeInitView() + { + if (scrollView1_ != nullptr) + { + scrollView1_->RemoveAll(); + delete scrollView1_; + scrollView1_ = nullptr; + } + if (label1_ != nullptr) + { + delete label1_; + label1_ = nullptr; + } + if (image1_ != nullptr) + { + delete image1_; + image1_ = nullptr; + } + if (label3_ != nullptr) + { + delete label3_; + label3_ = nullptr; + } + if (button1_ != nullptr) + { + delete button1_; + button1_ = nullptr; + } + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/stopwatch/src/StopWatchRecordTimeToLimitView.cpp b/code/sdk/application/wearable/fd230app/nativeui/stopwatch/src/StopWatchRecordTimeToLimitView.cpp new file mode 100644 index 000000000..eaf3cb638 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/stopwatch/src/StopWatchRecordTimeToLimitView.cpp @@ -0,0 +1,147 @@ +#include "stopwatch/include/StopWatchRecordTimeToLimitView.h" +#include "stopwatch/include/MainStopWatchPresenter.h" +#include "UiConfig.h" + +/*弹窗视图:到达最高时间99:59.99时弹出*/ +namespace OHOS +{ + + static StopWatchRecordTimeToLimitView *g_pStopWatchRecordTimeToLimitView{nullptr}; + + StopWatchRecordTimeToLimitView::StopWatchRecordTimeToLimitView() + { + + g_pStopWatchRecordTimeToLimitView = this; + } + + StopWatchRecordTimeToLimitView::~StopWatchRecordTimeToLimitView() + { + if (viewInitStatus == true) + { + DeInitView(); + } + g_pStopWatchRecordTimeToLimitView = nullptr; + } + + StopWatchRecordTimeToLimitView *StopWatchRecordTimeToLimitView::GetInstance() + { + + return g_pStopWatchRecordTimeToLimitView; + } + + UIScrollView *StopWatchRecordTimeToLimitView::InitStopWatchRecordTimeToLimitView() + { + if (scrollView1_ == nullptr) + { + scrollView1_ = new UIScrollView(); + } + scrollView1_->SetPosition(0, 0); + scrollView1_->Resize(466, 466); + scrollView1_->SetViewId("scrollView1"); + scrollView1_->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + scrollView1_->SetVisible(true); + /* -------------------------------------------------------------------------- */ + if (label1_ == nullptr) + { + label1_ = new UILabel(); + } + label1_->SetPosition(203, 52); + label1_->Resize(60, 35); + label1_->SetViewId("label1"); + label1_->SetStyle(STYLE_TEXT_FONT, 30); + label1_->SetStyle(STYLE_LINE_HEIGHT, 35); + label1_->SetText("秒表"); + label1_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label1_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label1_->SetRollSpeed(0); + label1_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + scrollView1_->Add(label1_); + label1_->SetVisible(true); + /* -------------------------------------------------------------------------- */ + if (image1_ == nullptr) + { + image1_ = new UIImageView(); + } + image1_->SetPosition(193, 121); + image1_->Resize(100, 100); + image1_->SetViewId("image1"); + image1_->SetStyle(STYLE_BORDER_RADIUS, 100); + char *image1imagesPath = "/user/res/countdown/COUNTDOWN_ATTENTION.bin"; + image1_->SetSrc(image1imagesPath); + scrollView1_->Add(image1_); + image1_->SetVisible(true); + /* -------------------------------------------------------------------------- */ + // Add Label to App + if (label3_ == nullptr) + { + label3_ = new UILabel(); + } + label3_->SetPosition(53, 235); + label3_->Resize(300, 35); + label3_->SetViewId("label3"); + label3_->SetStyle(STYLE_TEXT_FONT, 30); + label3_->SetStyle(STYLE_LINE_HEIGHT, 35); + label3_->SetText("当前已达到了最长时间\n表秒自动暂停,请重新开始"); + label3_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label3_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label3_->SetRollSpeed(0); + label3_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + // Add to scrollView1 + scrollView1_->Add(label3_); + label3_->SetVisible(true); + /* -------------------------------------------------------------------------- */ + // Add Button to App + if (button1_ == nullptr) + { + button1_ = new UIButton(); + } + button1_->SetPosition(0, 366); + button1_->Resize(466, 100); + button1_->SetViewId(TimeToLimitReturnButton_VIEWID); + button1_->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); + button1_->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + char *button1defaultImgSrc = "/user/res/countdown/COUNTDOWN_BUTTON.bin"; + button1_->SetImageSrc(button1defaultImgSrc, nullptr); + button1_->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xfffbfbfb, UIButton::PRESSED); + button1_->SetStyleForState(STYLE_BACKGROUND_OPA, 0x00, UIButton::PRESSED); + button1_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + // Add the CallBack about events + UIView::OnClickListener *button1Click = static_cast(MainStopWatchPresenter::GetInstance()); + button1_->SetOnClickListener(button1Click); + // Add to scrollView1 + scrollView1_->Add(button1_); + button1_->SetVisible(true); + viewInitStatus = true; + return scrollView1_; + } + + void StopWatchRecordTimeToLimitView::DeInitView() + { + if (scrollView1_ != nullptr) + { + scrollView1_->RemoveAll(); + delete scrollView1_; + scrollView1_ = nullptr; + } + if (label1_ != nullptr) + { + delete label1_; + label1_ = nullptr; + } + if (image1_ != nullptr) + { + delete image1_; + image1_ = nullptr; + } + if (label3_ != nullptr) + { + delete label3_; + label3_ = nullptr; + } + if (button1_ != nullptr) + { + delete button1_; + button1_ = nullptr; + } + } +} \ No newline at end of file diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/countdown/COUNTDOWM_END.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/countdown/COUNTDOWM_END.bin new file mode 100644 index 000000000..85ed573cf Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/countdown/COUNTDOWM_END.bin differ diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/countdown/COUNTDOWM_FIVE_MINUTE.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/countdown/COUNTDOWM_FIVE_MINUTE.bin new file mode 100644 index 000000000..7dd2cf845 Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/countdown/COUNTDOWM_FIVE_MINUTE.bin differ diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/countdown/COUNTDOWM_ONE_MINUTE.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/countdown/COUNTDOWM_ONE_MINUTE.bin new file mode 100644 index 000000000..d0efbc507 Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/countdown/COUNTDOWM_ONE_MINUTE.bin differ diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/countdown/COUNTDOWM_PAUSE.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/countdown/COUNTDOWM_PAUSE.bin new file mode 100644 index 000000000..87c18748a Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/countdown/COUNTDOWM_PAUSE.bin differ diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/countdown/COUNTDOWM_PLAY.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/countdown/COUNTDOWM_PLAY.bin new file mode 100644 index 000000000..97b64f812 Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/countdown/COUNTDOWM_PLAY.bin differ diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/countdown/COUNTDOWM_RESET.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/countdown/COUNTDOWM_RESET.bin new file mode 100644 index 000000000..2d3105e7d Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/countdown/COUNTDOWM_RESET.bin differ diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/countdown/COUNTDOWM_TEN_MINUTE.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/countdown/COUNTDOWM_TEN_MINUTE.bin new file mode 100644 index 000000000..7a2e1029f Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/countdown/COUNTDOWM_TEN_MINUTE.bin differ diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/countdown/COUNTDOWM_THIRTY_MINUTE.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/countdown/COUNTDOWM_THIRTY_MINUTE.bin new file mode 100644 index 000000000..ba69e921b Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/countdown/COUNTDOWM_THIRTY_MINUTE.bin differ diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/countdown/COUNTDOWM_VECTOR.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/countdown/COUNTDOWM_VECTOR.bin new file mode 100644 index 000000000..40be9d194 Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/countdown/COUNTDOWM_VECTOR.bin differ diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/countdown/COUNTDOWN_ATTENTION.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/countdown/COUNTDOWN_ATTENTION.bin new file mode 100644 index 000000000..b8120b857 Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/countdown/COUNTDOWN_ATTENTION.bin differ diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/countdown/COUNTDOWN_BUTTON.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/countdown/COUNTDOWN_BUTTON.bin new file mode 100644 index 000000000..5f89b6371 Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/countdown/COUNTDOWN_BUTTON.bin differ diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/countdown/COUNTDOWN_COLONE.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/countdown/COUNTDOWN_COLONE.bin new file mode 100644 index 000000000..f3d90d91f Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/countdown/COUNTDOWN_COLONE.bin differ diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/stopwatch/STOPWATCH_LINE.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/stopwatch/STOPWATCH_LINE.bin new file mode 100644 index 000000000..28019b06d Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/stopwatch/STOPWATCH_LINE.bin differ diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/stopwatch/STOPWATCH_MARK.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/stopwatch/STOPWATCH_MARK.bin new file mode 100644 index 000000000..482ef15ca Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/stopwatch/STOPWATCH_MARK.bin differ diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/stopwatch/STOPWATH_RESET1.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/stopwatch/STOPWATH_RESET1.bin new file mode 100644 index 000000000..66a43d7fd Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/stopwatch/STOPWATH_RESET1.bin differ diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/stopwatch/STOPWATH_RESET2.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/stopwatch/STOPWATH_RESET2.bin new file mode 100644 index 000000000..2730fd954 Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/stopwatch/STOPWATH_RESET2.bin differ