From: 罗正yun <1732036298@qq.com> Date: Wed, 13 Dec 2023 12:13:53 +0000 (+0800) Subject: 秒表视图修改提交 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=e1a0623555283d5d1de57cdf09b0aa49f8412d90;p=mirrors%2FFD230.git 秒表视图修改提交 --- diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 000000000..011a1a684 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,9 @@ +{ + "files.associations": { + "*.def": "cpp", + "limits": "cpp", + "*.tcc": "cpp", + "type_traits": "cpp", + "iterator": "cpp" + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/CMakeLists.txt b/code/sdk/application/wearable/nativeapp/CMakeLists.txt index cf7b6947c..58e40e137 100755 --- a/code/sdk/application/wearable/nativeapp/CMakeLists.txt +++ b/code/sdk/application/wearable/nativeapp/CMakeLists.txt @@ -342,9 +342,7 @@ set(SOURCES ${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/StopWatchRecordCycleToLimitPresenter.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/stopwatch/src/StopWatchRecordCycleToLimitView.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/stopwatch/src/StopWatchRecordTimeToLimitPresenter.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/stopwatch/src/StopWatchRecordTimeToLimitView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/displaybrightness/src/DisplayBrightnessModel.cpp diff --git a/code/sdk/application/wearable/nativeapp/nativelauncher/include/AppViewIDs.h b/code/sdk/application/wearable/nativeapp/nativelauncher/include/AppViewIDs.h index c1b85fd6e..ceb8399f7 100755 --- a/code/sdk/application/wearable/nativeapp/nativelauncher/include/AppViewIDs.h +++ b/code/sdk/application/wearable/nativeapp/nativelauncher/include/AppViewIDs.h @@ -117,8 +117,6 @@ typedef enum : uint16_t VIEW_PHONECALLUP, // 通话界面 VIEW_PHONEDIR, // 电话簿 VIEW_MAIN_STOPWATCH,// 秒表主视图 - VIEW_STOPWATCH_RECORD_CYCLE_TO_LIMIT, //秒表记录圈速到达上限 - VIEW_STOPWATCH_RECORD_TIME_TO_LIMIT, //秒表记录时间到达上限 VIEW_MAIN_COUNTDOWN,// 倒计时主视图 VIEW_COUNTDOWN_TIME_CONFIG,//倒计时时间配置 VIEW_START_COUNTDOWN,//开始倒计时 diff --git a/code/sdk/application/wearable/nativeapp/nativelauncher/include/NativeLauncher.h b/code/sdk/application/wearable/nativeapp/nativelauncher/include/NativeLauncher.h index 3684c83d9..7f914abeb 100755 --- a/code/sdk/application/wearable/nativeapp/nativelauncher/include/NativeLauncher.h +++ b/code/sdk/application/wearable/nativeapp/nativelauncher/include/NativeLauncher.h @@ -121,8 +121,6 @@ public: void InitStartCountDownSlice(void); void InitCountDownTimeNotNullSlice(void); void InitMainStopWatchSlice(void); - void InitStopWatchRecordCycleToLimitSlice(void); - void InitStopWatchRecordTimeToLimitSlice(void); private: void InitAllNativeSlices(void); diff --git a/code/sdk/application/wearable/nativeapp/nativelauncher/src/NativeLauncher.cpp b/code/sdk/application/wearable/nativeapp/nativelauncher/src/NativeLauncher.cpp index d211d9967..4e87e7e0e 100755 --- a/code/sdk/application/wearable/nativeapp/nativelauncher/src/NativeLauncher.cpp +++ b/code/sdk/application/wearable/nativeapp/nativelauncher/src/NativeLauncher.cpp @@ -219,10 +219,6 @@ #include "countdown/include/CountDownTimeNotNullView.h" #include "stopwatch/include/MainStopWatchPresenter.h" #include "stopwatch/include/MainStopWatchView.h" -#include "stopwatch/include/StopWatchRecordCycleToLimitPresenter.h" -#include "stopwatch/include/StopWatchRecordCycleToLimitView.h" -#include "stopwatch/include/StopWatchRecordTimeToLimitPresenter.h" -#include "stopwatch/include/StopWatchRecordTimeToLimitView.h" namespace OHOS { struct AppViewMapper @@ -335,8 +331,6 @@ static const AppViewMapper SLICE_MAPPER[] = { {VIEW_START_COUNTDOWN,&NativeLauncher::InitStartCountDownSlice}, //开始倒计时 {VIEW_COUNTDOWN_TIME_NOT_NULL,&NativeLauncher::InitCountDownTimeNotNullSlice}, //倒计时不能为0 {VIEW_MAIN_STOPWATCH,&NativeLauncher::InitMainStopWatchSlice}, //秒表主视图 - {VIEW_STOPWATCH_RECORD_CYCLE_TO_LIMIT,&NativeLauncher::InitStopWatchRecordCycleToLimitSlice}, - {VIEW_STOPWATCH_RECORD_TIME_TO_LIMIT,&NativeLauncher::InitStopWatchRecordTimeToLimitSlice}, {VIEW_UISAMPLE, &NativeLauncher::InitUISampleSlice} }; @@ -398,9 +392,7 @@ static const ViewIdToString VIEW_MAPPER[] = { {VIEW_COUNTDOWN_TIME_CONFIG,"CountDownTimeConfig"}, {VIEW_START_COUNTDOWN,"StartCountDown"}, {VIEW_COUNTDOWN_TIME_NOT_NULL,"CountDownTimeNotNull"}, - {VIEW_MAIN_STOPWATCH,"MainStopWatch"}, - {VIEW_STOPWATCH_RECORD_CYCLE_TO_LIMIT,"StopWatchRecordCycleToLimit"}, - {VIEW_STOPWATCH_RECORD_TIME_TO_LIMIT,"StopWatchRecordTimeToLimit"}, + {VIEW_MAIN_STOPWATCH,"MainStopWatch"}, {VIEW_UISAMPLE, "UISample"} }; @@ -1319,22 +1311,4 @@ void NativeLauncher::InitMainStopWatchSlice(void) //倒计时时间不能为0 } NativeAbility::GetInstance().AddSliceProxy(VIEW_MAIN_STOPWATCH, mainstopwatch); } - -void NativeLauncher::InitStopWatchRecordCycleToLimitSlice(void) -{ - SliceProxy *stopwatchrecordcycletolimit = new AbilitySliceProxy; - if (stopwatchrecordcycletolimit == nullptr) { - return; - } - NativeAbility::GetInstance().AddSliceProxy(VIEW_STOPWATCH_RECORD_CYCLE_TO_LIMIT, stopwatchrecordcycletolimit); -} - -void NativeLauncher::InitStopWatchRecordTimeToLimitSlice(void) -{ - SliceProxy *stopwatchrecordtimetolimit = new AbilitySliceProxy; - if (stopwatchrecordtimetolimit == nullptr) { - return; - } - NativeAbility::GetInstance().AddSliceProxy(VIEW_STOPWATCH_RECORD_TIME_TO_LIMIT, stopwatchrecordtimetolimit); -} } diff --git a/code/sdk/application/wearable/nativeapp/nativeui/screensetting/include/ScreenModels.h b/code/sdk/application/wearable/nativeapp/nativeui/screensetting/include/ScreenModels.h index 3553965f4..bf5d0c813 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/screensetting/include/ScreenModels.h +++ b/code/sdk/application/wearable/nativeapp/nativeui/screensetting/include/ScreenModels.h @@ -13,11 +13,11 @@ namespace OHOS { typedef enum { - MUSIC_PLAYER = 0, + WATCH_FACE = 0, HEART_RATE, COMPASS, ACTIVITY, - WATCH_FACE, + MUSIC_PLAYER , MAX_CARD, } CardId; diff --git a/code/sdk/application/wearable/nativeapp/nativeui/stopwatch/include/MainStopWatchPresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/stopwatch/include/MainStopWatchPresenter.h index bdfbb26a6..e355ed6e9 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/stopwatch/include/MainStopWatchPresenter.h +++ b/code/sdk/application/wearable/nativeapp/nativeui/stopwatch/include/MainStopWatchPresenter.h @@ -4,13 +4,24 @@ #include "Presenter.h" #include "MainStopWatchView.h" #include "components/ui_checkbox.h" +#include "components/ui_button.h" +#include "components/ui_label.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 UIView::OnDragListener, + public UICheckBox::OnChangeListener { public: MainStopWatchPresenter(); @@ -20,11 +31,23 @@ namespace OHOS 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); 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; + + private: + UICheckBox *m_checkbox{nullptr}; + UIButton *m_button{nullptr}; + UILabel *m_stopWatchlabel{nullptr}; + UILabel *m_showTimelabel{nullptr}; + int RecordCycleNumber{0}; // 用来记录点击计时按钮("Mark")的次数 + std::string RecordMaxTime{"99:59.59"}; // 计时时间最高为99:59.59 }; } // namespace OHOS diff --git a/code/sdk/application/wearable/nativeapp/nativeui/stopwatch/include/MainStopWatchView.h b/code/sdk/application/wearable/nativeapp/nativeui/stopwatch/include/MainStopWatchView.h index 2d6176c69..9429c9b7b 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/stopwatch/include/MainStopWatchView.h +++ b/code/sdk/application/wearable/nativeapp/nativeui/stopwatch/include/MainStopWatchView.h @@ -8,6 +8,8 @@ #include "components/ui_label.h" #include "components/ui_checkbox.h" #include "components/ui_button.h" +#include "stopwatch/include/StopWatchRecordCycleToLimitView.h" +#include "stopwatch/include/StopWatchRecordTimeToLimitView.h" /*秒表主视图*/ namespace OHOS { @@ -34,16 +36,26 @@ namespace OHOS 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 InitView(void); + void InitMainStopWatchView(void); void DeInitView(void); void PreLoad(void); + private: + StopWatchRecordCycleToLimitView *p_StopWatchRecordCycleToLimitView{nullptr}; // 圈数到达上限后弹出该视图 + StopWatchRecordTimeToLimitView *p_StopWatchRecordTimeToLimitView{nullptr}; // 计时时间到达上限后弹出该视图 + private: UIViewGroup *container_ = nullptr; - UIScrollView *scrollView1_ = nullptr; - UILabel *label1_ = nullptr; + UIScrollView *scrollView[3] = {nullptr}; + UILabel *stopWatchlabel = nullptr; // 内容为“秒表”的标签 UILabel *showTimelabel = nullptr; // 用来显示计时时间 UICheckBox *PlayOrPausecheckBox = nullptr; // 播放或暂停复选框 UIButton *ResetOrMarkbutton = nullptr; // 重置或标记按钮 diff --git a/code/sdk/application/wearable/nativeapp/nativeui/stopwatch/include/StopWatchRecordCycleToLimitPresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/stopwatch/include/StopWatchRecordCycleToLimitPresenter.h deleted file mode 100755 index 0d548cdad..000000000 --- a/code/sdk/application/wearable/nativeapp/nativeui/stopwatch/include/StopWatchRecordCycleToLimitPresenter.h +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef STOPWATCH_RECORD_CYCLE_TO_LIMIT_PRESENTER_H -#define STOPWATCH_RECORD_CYCLE_TO_LIMIT_PRESENTER_H - -#include "Presenter.h" -#include "StopWatchRecordCycleToLimitView.h" - -/*弹窗视图:到达最高圈数99时弹出*/ -namespace OHOS -{ - class StopWatchRecordCycleToLimitView; - - class StopWatchRecordCycleToLimitPresenter : public Presenter, - public UIView::OnClickListener, - public UIView::OnDragListener - { - public: - StopWatchRecordCycleToLimitPresenter(); - virtual ~StopWatchRecordCycleToLimitPresenter(); - - void OnStart() override; - void OnPause() override; - void OnResume() override; - void OnStop() override; - - static StopWatchRecordCycleToLimitPresenter *GetInstance(); - - private: - // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; - bool OnClick(UIView &view, const ClickEvent &event) override; - bool OnDrag(UIView &view, const DragEvent &event) override; - }; -} // namespace OHOS - -#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/stopwatch/include/StopWatchRecordCycleToLimitView.h b/code/sdk/application/wearable/nativeapp/nativeui/stopwatch/include/StopWatchRecordCycleToLimitView.h index f69f36111..390fa0c36 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/stopwatch/include/StopWatchRecordCycleToLimitView.h +++ b/code/sdk/application/wearable/nativeapp/nativeui/stopwatch/include/StopWatchRecordCycleToLimitView.h @@ -11,24 +11,15 @@ /*弹窗视图:到达最高圈数99时弹出*/ namespace OHOS { - class StopWatchRecordCycleToLimitPresenter; - class StopWatchRecordCycleToLimitView : public View + class StopWatchRecordCycleToLimitView { public: StopWatchRecordCycleToLimitView(); + void DeInitView(void); virtual ~StopWatchRecordCycleToLimitView(); static StopWatchRecordCycleToLimitView *GetInstance(void); - - void OnStart() override; - void OnSetUpView() override; - void OnTearDownView() override; - void OnStop() override; - - private: - void InitView(void); - void DeInitView(void); - void PreLoad(void); + UIScrollView *InitStopWatchRecordCycleToLimitView(void); private: UIViewGroup *container_ = nullptr; diff --git a/code/sdk/application/wearable/nativeapp/nativeui/stopwatch/include/StopWatchRecordTimeToLimitPresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/stopwatch/include/StopWatchRecordTimeToLimitPresenter.h deleted file mode 100755 index 6a158dda9..000000000 --- a/code/sdk/application/wearable/nativeapp/nativeui/stopwatch/include/StopWatchRecordTimeToLimitPresenter.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef STOPWATCH_RECORD_TIME_TO_LIMIT_PRESENTER_H -#define STOPWATCH_RECORD_TIME_TO_LIMIT_PRESENTER_H - -#include "Presenter.h" -#include "StopWatchRecordTimeToLimitView.h" -/*弹窗视图:到达最高时间99:59.99时弹出*/ -namespace OHOS -{ - class StopWatchRecordTimeToLimitView; - class StopWatchRecordTimeToLimitPresenter : public Presenter, - public UIView::OnClickListener, - public UIView::OnDragListener - { - public: - StopWatchRecordTimeToLimitPresenter(); - virtual ~StopWatchRecordTimeToLimitPresenter(); - - void OnStart() override; - void OnPause() override; - void OnResume() override; - void OnStop() override; - - static StopWatchRecordTimeToLimitPresenter *GetInstance(); - - private: - // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; - bool OnClick(UIView &view, const ClickEvent &event) override; - bool OnDrag(UIView &view, const DragEvent &event) override; - }; -} // namespace OHOS - -#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/stopwatch/include/StopWatchRecordTimeToLimitView.h b/code/sdk/application/wearable/nativeapp/nativeui/stopwatch/include/StopWatchRecordTimeToLimitView.h index 9667176c6..22495f27c 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/stopwatch/include/StopWatchRecordTimeToLimitView.h +++ b/code/sdk/application/wearable/nativeapp/nativeui/stopwatch/include/StopWatchRecordTimeToLimitView.h @@ -11,27 +11,16 @@ /*弹窗视图:到达最高时间99:59.99时弹出*/ namespace OHOS { - class StopWatchRecordTimeToLimitPresenter; - class StopWatchRecordTimeToLimitView : public View + class StopWatchRecordTimeToLimitView { - public: StopWatchRecordTimeToLimitView(); virtual ~StopWatchRecordTimeToLimitView(); static StopWatchRecordTimeToLimitView *GetInstance(void); - - void OnStart() override; - void OnSetUpView() override; - void OnTearDownView() override; - void OnStop() override; - - private: - void InitView(void); + UIScrollView *InitStopWatchRecordTimeToLimitView(void); void DeInitView(void); - void PreLoad(void); private: - UIViewGroup *container_ = nullptr; UIScrollView *scrollView1_ = nullptr; UILabel *label1_ = nullptr; UIImageView *image1_ = nullptr; diff --git a/code/sdk/application/wearable/nativeapp/nativeui/stopwatch/src/MainStopWatchPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/stopwatch/src/MainStopWatchPresenter.cpp index 8cd78aa7a..dd5f176a4 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/stopwatch/src/MainStopWatchPresenter.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/stopwatch/src/MainStopWatchPresenter.cpp @@ -50,9 +50,42 @@ namespace OHOS Presenter::OnStop(); } - bool MainStopWatchPresenter::OnDrag(UIView &view, const DragEvent &event) + /// @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(); + } + 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())))) { @@ -64,7 +97,62 @@ namespace OHOS bool MainStopWatchPresenter::OnClick(UIView &view, const ClickEvent &event) { UNUSED(view); - UNUSED(event); + if (strcmp(view.GetViewId(), ResetOrMarkButton_MARK_VIEWID) == 0) + { + printf("mark!\n"); + RecordCycleNumber += 1; + printf("RecordCycleNumber:%d\n", RecordCycleNumber); + if (RecordCycleNumber > 3) + { + // MainStopWatchView::GetInstance()->ChangeView(MAIN_STOPWATCH, STOPWATCH_RECORD_CYCLE_TO_LIMIT); + MainStopWatchView::GetInstance()->ChangeView(MAIN_STOPWATCH, STOPWATCH_RECORD_TIME_TO_LIMIT); + return true; + } + /* -------------------------------------------------------------------------- */ + MainStopWatchView::GetInstance()->SetViewIsVisible(m_stopWatchlabel, false); + /* -------------------------------------------------------------------------- */ + SetShowTimeLableStyle(m_showTimelabel, 93, 60, 65, 78); + /* -------------------------------------------------------------------------- */ + } + else if (strcmp(view.GetViewId(), ResetOrMarkButton_RESET2_VIEWID) == 0) + { + printf("Reset2!\n"); + m_button->SetViewId(ResetOrMarkButton_RESET1_VIEWID); + m_button->SetImageSrc(ResetOrMarkButtonImg_Reset1, ResetOrMarkButtonImg_Reset1); + m_button->Invalidate(); + /* -------------------------------------------------------------------------- */ + MainStopWatchView::GetInstance()->SetViewIsVisible(m_stopWatchlabel, true); + /* -------------------------------------------------------------------------- */ + SetShowTimeLableStyle(m_showTimelabel, 63, 160, 80, 94); + /* -------------------------------------------------------------------------- */ + } + else if (strcmp(view.GetViewId(), "CycleToLimitReturnButton") == 0) + { + MainStopWatchView::GetInstance()->ChangeView(STOPWATCH_RECORD_CYCLE_TO_LIMIT, MAIN_STOPWATCH); + return true; + } + else if (strcmp(view.GetViewId(), "TimeToLimitReturnButton") == 0) + { + MainStopWatchView::GetInstance()->ChangeView(STOPWATCH_RECORD_TIME_TO_LIMIT, MAIN_STOPWATCH); + return true; + } + 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; } } \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/stopwatch/src/MainStopWatchView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/stopwatch/src/MainStopWatchView.cpp index 29c080bd9..5c42304bb 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/stopwatch/src/MainStopWatchView.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/stopwatch/src/MainStopWatchView.cpp @@ -6,129 +6,167 @@ /*秒表主视图*/ namespace OHOS { - /*点击该复选框会播放或暂停计时*/ - class PlayOrPausecheckBoxOnChangeListener : public UICheckBox::OnChangeListener + + static MainStopWatchView *g_pMainStopWatchView{nullptr}; + + MainStopWatchView::MainStopWatchView() { - public: - PlayOrPausecheckBoxOnChangeListener(UICheckBox *checkbox, UIButton *button) - { - m_checkbox = checkbox; - m_button = button; - } - bool OnChange(UICheckBox::UICheckBoxState state) override + + g_pMainStopWatchView = this; + } + + MainStopWatchView::~MainStopWatchView() + { + if (viewInitStatus == true) { - 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; + DeInitView(); } + g_pMainStopWatchView = nullptr; + } - private: - UICheckBox *m_checkbox{nullptr}; - UIButton *m_button{nullptr}; - }; - int flag = 0; - /*标记或重置时间按钮监听*/ - class ResetOrMarkbuttonOnClickListener : public UIView::OnClickListener + MainStopWatchView *MainStopWatchView::GetInstance() + { + + return g_pMainStopWatchView; + } + + /// @brief 设置视图是否可见 + /// @param view 具体视图 + /// @param status true 可见 false 不可见 + void MainStopWatchView::SetViewIsVisible(UIView *view, bool status) { - public: - ResetOrMarkbuttonOnClickListener(UIButton *button) + if (status == true) { - m_button = button; + view->SetVisible(true); } + else + { + view->SetVisible(false); + } + RootView::GetInstance()->Invalidate(); + } + + // 切换到秒表主视图 + bool MainStopWatchView::ChangeMainStopWatch(int16_t thisView) + { + container_->Add(scrollView[thisView]); + return true; + } - bool OnClick(UIView &view, const ClickEvent &event) override + // 切换到秒表到达最高圈数视图 + bool MainStopWatchView::ChangeStopWatchRecordCycleLimit(int16_t thisView) + { + if (scrollView[thisView] == nullptr) { - if (strcmp(view.GetViewId(), ResetOrMarkButton_MARK_VIEWID) == 0) + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainAlarmView::StopWatchRecordCycleToLimitView"); + p_StopWatchRecordCycleToLimitView = new StopWatchRecordCycleToLimitView(); + if (p_StopWatchRecordCycleToLimitView == nullptr) { - printf("mark!\n"); - if (flag == 0) - { - flag = 1; - NativeAbility::GetInstance().ChangeSlice(VIEW_STOPWATCH_RECORD_CYCLE_TO_LIMIT); - } - else - { - flag = 0; - NativeAbility::GetInstance().ChangeSlice(VIEW_STOPWATCH_RECORD_TIME_TO_LIMIT); - } + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainStopWatchView:: new scrollView[%d] fail", thisView); + return false; } - else if (strcmp(view.GetViewId(), ResetOrMarkButton_RESET2_VIEWID) == 0) + 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) { - printf("Reset2!\n"); - m_button->SetViewId(ResetOrMarkButton_RESET1_VIEWID); - m_button->SetImageSrc(ResetOrMarkButtonImg_Reset1, ResetOrMarkButtonImg_Reset1); - m_button->Invalidate(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainStopWatchView:: new scrollView[%d] fail", thisView); + return false; } - return true; + scrollView[thisView] = p_StopWatchRecordTimeToLimitView->InitStopWatchRecordTimeToLimitView(); + container_->Add(scrollView[thisView]); } - UIButton *m_button{nullptr}; + return true; + } + /* -------------------------------------------------------------------------- */ + // 1.MainStopWatchViewMapper:结构体定义了一个将视图ID映射到特定成员函数指针的映射表。 + struct MainStopWatchViewMapper + { + const int16_t viewId; + bool (MainStopWatchView::*func)(int16_t thisView); }; -} -namespace OHOS -{ - - static MainStopWatchView *g_pMainStopWatchView{nullptr}; - MainStopWatchView::MainStopWatchView() + // 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} + }; - g_pMainStopWatchView = this; - } - - MainStopWatchView::~MainStopWatchView() + // 3.根据传入的interface参数执行相应视图ID关联的成员函数。 + bool MainStopWatchView::ClickFunc(int16_t interface) { - if (viewInitStatus == true) + int funcSize = sizeof(ViewMapper) / sizeof(ViewMapper[0]); + for (int i = 0; i < funcSize; i++) { - DeInitView(); + if (interface == ViewMapper[i].viewId) + { + bool jug = (this->*(ViewMapper[i].func))(interface); + if (jug == false) + { + return false; + } + return true; + } } - g_pMainStopWatchView = nullptr; + return false; } - MainStopWatchView *MainStopWatchView::GetInstance() + // 4.切换视图 + void MainStopWatchView::ChangeView(int16_t hideView, int16_t showView) { - - return g_pMainStopWatchView; + 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::InitView() + /* -------------------------------------------------------------------------- */ + // 初始化秒表主视图 + void MainStopWatchView::InitMainStopWatchView() { - if (scrollView1_ == nullptr) + if (scrollView[MAIN_STOPWATCH] == nullptr) { - scrollView1_ = new UIScrollView(); + scrollView[MAIN_STOPWATCH] = new UIScrollView(); } - scrollView1_->SetPosition(0, 0); - scrollView1_->Resize(466, 466); - scrollView1_->SetViewId("scrollView1"); - scrollView1_->SetStyle(STYLE_BACKGROUND_OPA, 0xff); - container_->Add(scrollView1_); - scrollView1_->SetVisible(true); + 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 (label1_ == nullptr) + if (stopWatchlabel == nullptr) { - label1_ = new UILabel(); + stopWatchlabel = 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); + 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) { @@ -144,7 +182,7 @@ namespace OHOS showTimelabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); showTimelabel->SetRollSpeed(0); showTimelabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 80); - scrollView1_->Add(showTimelabel); + scrollView[MAIN_STOPWATCH]->Add(showTimelabel); showTimelabel->SetVisible(true); /* -------------------------------------------------------------------------- */ // Add CheckBox to App @@ -153,13 +191,13 @@ namespace OHOS PlayOrPausecheckBox = new UICheckBox(); } PlayOrPausecheckBox->SetPosition(118, 321); - PlayOrPausecheckBox->Resize(100, 100); + 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 - scrollView1_->Add(PlayOrPausecheckBox); + scrollView[MAIN_STOPWATCH]->Add(PlayOrPausecheckBox); PlayOrPausecheckBox->SetVisible(true); /* -------------------------------------------------------------------------- */ // Add Button to App @@ -167,7 +205,7 @@ namespace OHOS { ResetOrMarkbutton = new UIButton(); } - ResetOrMarkbutton->SetPosition(248, 321); + ResetOrMarkbutton->SetPosition(256, 333); ResetOrMarkbutton->Resize(100, 100); ResetOrMarkbutton->SetViewId(ResetOrMarkButton_RESET1_VIEWID); ResetOrMarkbutton->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); @@ -176,22 +214,24 @@ namespace OHOS ResetOrMarkbutton->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xfffbfbfb, UIButton::PRESSED); ResetOrMarkbutton->SetStyleForState(STYLE_BACKGROUND_OPA, 0x00, UIButton::PRESSED); ResetOrMarkbutton->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); - scrollView1_->Add(ResetOrMarkbutton); + scrollView[MAIN_STOPWATCH]->Add(ResetOrMarkbutton); ResetOrMarkbutton->SetVisible(true); /* -------------------------------------------------------------------------- */ + MainStopWatchPresenter::GetInstance()->SetCheckBoxAndButton(PlayOrPausecheckBox, ResetOrMarkbutton); + MainStopWatchPresenter::GetInstance()->SetLable(stopWatchlabel, showTimelabel); // Add the CallBack about events - PlayOrPausecheckBoxChangeListener = static_cast(new PlayOrPausecheckBoxOnChangeListener(PlayOrPausecheckBox, ResetOrMarkbutton)); + PlayOrPausecheckBoxChangeListener = static_cast(MainStopWatchPresenter::GetInstance()); PlayOrPausecheckBox->SetOnChangeListener(PlayOrPausecheckBoxChangeListener); - ResetOrMarkbuttonClick = static_cast(new ResetOrMarkbuttonOnClickListener(ResetOrMarkbutton)); + ResetOrMarkbuttonClick = static_cast(MainStopWatchPresenter::GetInstance()); ResetOrMarkbutton->SetOnClickListener(ResetOrMarkbuttonClick); } void MainStopWatchView::DeInitView() { - if (label1_ != nullptr) + if (stopWatchlabel != nullptr) { - delete label1_; - label1_ = nullptr; + delete stopWatchlabel; + stopWatchlabel = nullptr; } if (showTimelabel != nullptr) { @@ -223,10 +263,10 @@ namespace OHOS delete ResetOrMarkbuttonClick; ResetOrMarkbuttonClick = nullptr; } - if (scrollView1_ != nullptr) + if (scrollView[MAIN_STOPWATCH] != nullptr) { - delete scrollView1_; - scrollView1_ = nullptr; + delete scrollView[MAIN_STOPWATCH]; + scrollView[MAIN_STOPWATCH] = nullptr; } if (container_ != nullptr) { @@ -239,7 +279,7 @@ namespace OHOS { if (!viewInitStatus) { - InitView(); + InitMainStopWatchView(); viewInitStatus = true; } } diff --git a/code/sdk/application/wearable/nativeapp/nativeui/stopwatch/src/StopWatchRecordCycleToLimitPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/stopwatch/src/StopWatchRecordCycleToLimitPresenter.cpp deleted file mode 100755 index 730c2c9e1..000000000 --- a/code/sdk/application/wearable/nativeapp/nativeui/stopwatch/src/StopWatchRecordCycleToLimitPresenter.cpp +++ /dev/null @@ -1,70 +0,0 @@ -#include "AppViewIDs.h" -#include "NativeAbility.h" -#include "stopwatch/include/StopWatchRecordCycleToLimitPresenter.h" - -/*弹窗视图:到达最高圈数99时弹出*/ -namespace OHOS -{ - - // 当前Presenter属性实例化的内存指针 - static StopWatchRecordCycleToLimitPresenter *g_pStopWatchRecordCycleToLimitPresenter = nullptr; - - StopWatchRecordCycleToLimitPresenter::StopWatchRecordCycleToLimitPresenter() - { - - g_pStopWatchRecordCycleToLimitPresenter = this; - } - - StopWatchRecordCycleToLimitPresenter::~StopWatchRecordCycleToLimitPresenter() - { - - g_pStopWatchRecordCycleToLimitPresenter = nullptr; - } - - StopWatchRecordCycleToLimitPresenter *StopWatchRecordCycleToLimitPresenter::GetInstance() - { - - return g_pStopWatchRecordCycleToLimitPresenter; - } - - void StopWatchRecordCycleToLimitPresenter::OnStart() - { - - Presenter::OnStart(); - } - - void StopWatchRecordCycleToLimitPresenter::OnPause(void) - { - - Presenter::OnPause(); - } - - void StopWatchRecordCycleToLimitPresenter::OnResume(void) - { - - Presenter::OnResume(); - } - - void StopWatchRecordCycleToLimitPresenter::OnStop(void) - { - - Presenter::OnStop(); - } - - bool StopWatchRecordCycleToLimitPresenter::OnDrag(UIView &view, const DragEvent &event) - { - UNUSED(view); - UNUSED(event); - return true; - } - - bool StopWatchRecordCycleToLimitPresenter::OnClick(UIView &view, const ClickEvent &event) - { - // 根据控件id查找是哪个控件触发了点击回调 - if (strcmp(view.GetViewId(), "ReturnButton") == 0) - { - NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN_STOPWATCH); - } - return true; - } -} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/stopwatch/src/StopWatchRecordCycleToLimitView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/stopwatch/src/StopWatchRecordCycleToLimitView.cpp index 9862deb5f..51c9cdd6c 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/stopwatch/src/StopWatchRecordCycleToLimitView.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/stopwatch/src/StopWatchRecordCycleToLimitView.cpp @@ -1,6 +1,5 @@ #include "stopwatch/include/StopWatchRecordCycleToLimitView.h" -#include "stopwatch/include/StopWatchRecordCycleToLimitPresenter.h" -#include "UiConfig.h" +#include "stopwatch/include/MainStopWatchPresenter.h" /*弹窗视图:到达最高圈数99时弹出*/ namespace OHOS { @@ -27,27 +26,27 @@ namespace OHOS return g_pStopWatchRecordCycleToLimitView; } - - void StopWatchRecordCycleToLimitView::InitView() + // 初始化秒表到达最高圈数时弹出的视图 + UIScrollView *StopWatchRecordCycleToLimitView::InitStopWatchRecordCycleToLimitView() { if (scrollView1_ == nullptr) { scrollView1_ = new UIScrollView(); } - scrollView1_->SetPosition(0, 0); - scrollView1_->Resize(466, 466); - scrollView1_->SetViewId("scrollView1"); + scrollView1_->SetPosition(0, 0); + scrollView1_->Resize(466, 466); + scrollView1_->SetViewId("scrollView1"); scrollView1_->SetStyle(STYLE_BACKGROUND_OPA, 0xff); - container_->Add(scrollView1_); + // container_->Add(scrollView1_); scrollView1_->SetVisible(true); /* -------------------------------------------------------------------------- */ if (label1_ == nullptr) { label1_ = new UILabel(); } - label1_->SetPosition(203, 52); - label1_->Resize(60, 35); - label1_->SetViewId("label1"); + 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("秒表"); @@ -62,9 +61,9 @@ namespace OHOS { image1_ = new UIImageView(); } - image1_->SetPosition(193, 121); - image1_->Resize(100, 100); - image1_->SetViewId("image1"); + 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); @@ -76,9 +75,9 @@ namespace OHOS { label3_ = new UILabel(); } - label3_->SetPosition(83, 253); - label3_->Resize(300, 35); - label3_->SetViewId("label3"); + 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("当前已达到了最高圈数"); @@ -95,9 +94,9 @@ namespace OHOS { button1_ = new UIButton(); } - button1_->SetPosition(0, 366); - button1_->Resize(466, 100); - button1_->SetViewId("ReturnButton"); + button1_->SetPosition(0, 366); + button1_->Resize(466, 100); + button1_->SetViewId("CycleToLimitReturnButton"); button1_->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); button1_->SetStyle(STYLE_BACKGROUND_OPA, 0x00); char *button1defaultImgSrc = "/user/res/countdown/COUNTDOWN_BUTTON.bin"; @@ -107,11 +106,12 @@ namespace OHOS button1_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); // Add the CallBack about events - UIView::OnClickListener *button1Click = static_cast(StopWatchRecordCycleToLimitPresenter::GetInstance()); + UIView::OnClickListener *button1Click = static_cast(MainStopWatchPresenter::GetInstance()); button1_->SetOnClickListener(button1Click); // Add to scrollView1 scrollView1_->Add(button1_); button1_->SetVisible(true); + return scrollView1_; } void StopWatchRecordCycleToLimitView::DeInitView() @@ -148,48 +148,4 @@ namespace OHOS button1_ = nullptr; } } - void StopWatchRecordCycleToLimitView::PreLoad(void) - { - if (!viewInitStatus) - { - InitView(); - viewInitStatus = true; - } - } - void StopWatchRecordCycleToLimitView::OnStart() - { - // container_容器属性 new - container_ = new UIViewGroup(); - if (container_ == nullptr) - { - return; - } - // container_容器属性 扩展 - container_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); - container_->SetTouchable(true); - PreLoad(); - RootView::GetInstance()->Add(container_); - } - - void StopWatchRecordCycleToLimitView::OnSetUpView() - { - - View::OnSetUpView(); - Draw(); - } - - void StopWatchRecordCycleToLimitView::OnTearDownView() - { - - View::OnTearDownView(); - return; - } - - void StopWatchRecordCycleToLimitView::OnStop() - { - - View::OnStop(); - RootView::GetInstance()->RemoveAll(); - return; - } } \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/stopwatch/src/StopWatchRecordTimeToLimitPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/stopwatch/src/StopWatchRecordTimeToLimitPresenter.cpp deleted file mode 100755 index d58558f76..000000000 --- a/code/sdk/application/wearable/nativeapp/nativeui/stopwatch/src/StopWatchRecordTimeToLimitPresenter.cpp +++ /dev/null @@ -1,70 +0,0 @@ -#include "AppViewIDs.h" -#include "NativeAbility.h" -#include "stopwatch/include/StopWatchRecordTimeToLimitPresenter.h" - -/*弹窗视图:到达最高时间99:59.99时弹出*/ -namespace OHOS -{ - - // 当前Presenter属性实例化的内存指针 - static StopWatchRecordTimeToLimitPresenter *g_pStopWatchRecordTimeToLimitPresenter = nullptr; - - StopWatchRecordTimeToLimitPresenter::StopWatchRecordTimeToLimitPresenter() - { - - g_pStopWatchRecordTimeToLimitPresenter = this; - } - - StopWatchRecordTimeToLimitPresenter::~StopWatchRecordTimeToLimitPresenter() - { - - g_pStopWatchRecordTimeToLimitPresenter = nullptr; - } - - StopWatchRecordTimeToLimitPresenter *StopWatchRecordTimeToLimitPresenter::GetInstance() - { - - return g_pStopWatchRecordTimeToLimitPresenter; - } - - void StopWatchRecordTimeToLimitPresenter::OnStart() - { - - Presenter::OnStart(); - } - - void StopWatchRecordTimeToLimitPresenter::OnPause(void) - { - - Presenter::OnPause(); - } - - void StopWatchRecordTimeToLimitPresenter::OnResume(void) - { - - Presenter::OnResume(); - } - - void StopWatchRecordTimeToLimitPresenter::OnStop(void) - { - - Presenter::OnStop(); - } - - bool StopWatchRecordTimeToLimitPresenter::OnDrag(UIView &view, const DragEvent &event) - { - UNUSED(view); - UNUSED(event); - return true; - } - - bool StopWatchRecordTimeToLimitPresenter::OnClick(UIView &view, const ClickEvent &event) - { - // 根据控件id查找是哪个控件触发了点击回调 - if (strcmp(view.GetViewId(), "ReturnButton") == 0) - { - NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN_STOPWATCH); - } - return true; - } -} \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/stopwatch/src/StopWatchRecordTimeToLimitView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/stopwatch/src/StopWatchRecordTimeToLimitView.cpp index 2fb5b9624..a9ce7de06 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/stopwatch/src/StopWatchRecordTimeToLimitView.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/stopwatch/src/StopWatchRecordTimeToLimitView.cpp @@ -1,6 +1,5 @@ #include "stopwatch/include/StopWatchRecordTimeToLimitView.h" -#include "stopwatch/include/StopWatchRecordTimeToLimitPresenter.h" - +#include "stopwatch/include/MainStopWatchPresenter.h" #include "UiConfig.h" /*弹窗视图:到达最高时间99:59.99时弹出*/ @@ -30,7 +29,7 @@ namespace OHOS return g_pStopWatchRecordTimeToLimitView; } - void StopWatchRecordTimeToLimitView::InitView() + UIScrollView *StopWatchRecordTimeToLimitView::InitStopWatchRecordTimeToLimitView() { if (scrollView1_ == nullptr) { @@ -40,7 +39,6 @@ namespace OHOS scrollView1_->Resize(466, 466); scrollView1_->SetViewId("scrollView1"); scrollView1_->SetStyle(STYLE_BACKGROUND_OPA, 0xff); - container_->Add(scrollView1_); scrollView1_->SetVisible(true); /* -------------------------------------------------------------------------- */ if (label1_ == nullptr) @@ -99,7 +97,7 @@ namespace OHOS } button1_->SetPosition(0, 366); button1_->Resize(466, 100); - button1_->SetViewId("ReturnButton"); + button1_->SetViewId("TimeToLimitReturnButton"); button1_->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); button1_->SetStyle(STYLE_BACKGROUND_OPA, 0x00); char *button1defaultImgSrc = "/user/res/countdown/COUNTDOWN_BUTTON.bin"; @@ -108,58 +106,16 @@ namespace OHOS 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(StopWatchRecordTimeToLimitPresenter::GetInstance()); + 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() { } - void StopWatchRecordTimeToLimitView::PreLoad(void) - { - if (!viewInitStatus) - { - InitView(); - viewInitStatus = true; - } - } - void StopWatchRecordTimeToLimitView::OnStart() - { - // container_容器属性 new - container_ = new UIViewGroup(); - if (container_ == nullptr) - { - return; - } - // container_容器属性 扩展 - container_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); - container_->SetTouchable(true); - PreLoad(); - RootView::GetInstance()->Add(container_); - } - - void StopWatchRecordTimeToLimitView::OnSetUpView() - { - - View::OnSetUpView(); - Draw(); - } - - void StopWatchRecordTimeToLimitView::OnTearDownView() - { - - View::OnTearDownView(); - return; - } - - void StopWatchRecordTimeToLimitView::OnStop() - { - - View::OnStop(); - RootView::GetInstance()->RemoveAll(); - return; - } } \ No newline at end of file diff --git a/code/sdk/drivers/chips/brandy/porting/uart/uart_porting.c b/code/sdk/drivers/chips/brandy/porting/uart/uart_porting.c index b6f409070..e308f60cc 100755 --- a/code/sdk/drivers/chips/brandy/porting/uart/uart_porting.c +++ b/code/sdk/drivers/chips/brandy/porting/uart/uart_porting.c @@ -221,7 +221,7 @@ static uart_config_t g_uart_config[UART_BUS_MAX_NUMBER] = { log_factory_at_callback, #endif { - .baud_rate = 500000, + .baud_rate = 2000000, .data_bits = UART_DATA_BIT_8, .parity = UART_PARITY_NONE, .stop_bits = UART_STOP_BIT_1,