From: luozheng <1732036298@qq.com> Date: Tue, 20 Aug 2024 08:25:29 +0000 (+0800) Subject: 倒计时配置多国语言 X-Git-Tag: release_V1.2.70_20241020_135402~622 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=2c7c25e559864e24c2445c4fca2ba92c5f9a03bc;p=mirrors%2FFD230.git 倒计时配置多国语言 --- diff --git a/code/sdk/application/wearable/fd230app/nativeui/stopwatch/src/MainStopWatchPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/stopwatch/src/MainStopWatchPresenter.cpp index d9284b70f..4c32e7d27 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/stopwatch/src/MainStopWatchPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/stopwatch/src/MainStopWatchPresenter.cpp @@ -272,7 +272,7 @@ namespace OHOS { StopWatchModel::GetInstance()->StopWatch_PauseTimer(); // 暂停定时器 m_button->SetViewId(ResetOrMarkButton_RESET2_VIEWID); - m_button->SetImageSrc(ResetOrMarkButtonImg_Reset2, nullptr); + m_button->SetImageSrc(ResetOrMarkButtonImg_Reset2, ResetOrMarkButtonImg_Reset2); m_button->Invalidate(); } return true; diff --git a/code/sdk/application/wearable/fd230app/nativeui/stopwatch/src/MainStopWatchView.cpp b/code/sdk/application/wearable/fd230app/nativeui/stopwatch/src/MainStopWatchView.cpp index 165ae0266..cfac70da8 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/stopwatch/src/MainStopWatchView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/stopwatch/src/MainStopWatchView.cpp @@ -30,78 +30,83 @@ namespace OHOS void MainStopWatchView::ClearAll() { - group->RemoveAll(); - scrollView[MAIN_STOPWATCH]->RemoveAll(); - - if (stopWatchlabel != nullptr) + if (group != nullptr) { - delete stopWatchlabel; - stopWatchlabel = nullptr; - } + group->RemoveAll(); + scrollView[MAIN_STOPWATCH]->RemoveAll(); - if (showTimelabel != nullptr) - { - delete showTimelabel; - showTimelabel = nullptr; - } + if (stopWatchlabel != nullptr) + { + delete stopWatchlabel; + stopWatchlabel = nullptr; + } - if (PlayOrPausecheckBox != nullptr) - { - delete PlayOrPausecheckBox; - PlayOrPausecheckBox = nullptr; - } + if (showTimelabel != nullptr) + { + delete showTimelabel; + showTimelabel = nullptr; + } - if (ResetOrMarkbutton != nullptr) - { - delete ResetOrMarkbutton; - ResetOrMarkbutton = nullptr; - } + if (PlayOrPausecheckBox != nullptr) + { + delete PlayOrPausecheckBox; + PlayOrPausecheckBox = nullptr; + } - if (LineImage != nullptr) - { - delete LineImage; - LineImage = nullptr; - } + if (ResetOrMarkbutton != nullptr) + { + delete ResetOrMarkbutton; + ResetOrMarkbutton = nullptr; + } - if (list != nullptr) - { - delete list; - list = nullptr; - } + if (LineImage != nullptr) + { + delete LineImage; + LineImage = nullptr; + } - if (listadapter != nullptr) - { - delete listadapter; - listadapter = nullptr; - } + if (list != nullptr) + { + delete list; + list = nullptr; + } - if (listdata != nullptr) - { - listdata->Clear(); - delete listdata; - listdata = nullptr; - } + if (listadapter != nullptr) + { + delete listadapter; + listadapter = nullptr; + } - if (scrollView[MAIN_STOPWATCH] != nullptr) - { - delete scrollView[MAIN_STOPWATCH]; - scrollView[MAIN_STOPWATCH] = nullptr; - } + if (listdata != nullptr) + { + listdata->Clear(); + delete listdata; + listdata = nullptr; + } - if (p_StopWatchRecordCycleToLimitView != nullptr) - { - delete p_StopWatchRecordCycleToLimitView; - p_StopWatchRecordCycleToLimitView = nullptr; - } + if (scrollView[MAIN_STOPWATCH] != nullptr) + { + delete scrollView[MAIN_STOPWATCH]; + scrollView[MAIN_STOPWATCH] = nullptr; + } - if (p_StopWatchRecordTimeToLimitView != nullptr) - { - delete p_StopWatchRecordTimeToLimitView; - p_StopWatchRecordTimeToLimitView = nullptr; - } + if (p_StopWatchRecordCycleToLimitView != nullptr) + { + delete p_StopWatchRecordCycleToLimitView; + p_StopWatchRecordCycleToLimitView = nullptr; + } + + if (p_StopWatchRecordTimeToLimitView != nullptr) + { + delete p_StopWatchRecordTimeToLimitView; + p_StopWatchRecordTimeToLimitView = nullptr; + } + + for (int i = MAIN_STOPWATCH; i < STOPWATCH_MAXVIEWID; i++) + { + scrollView[MAIN_STOPWATCH] = nullptr; + } - if (group != nullptr) - { delete group; group = nullptr; } @@ -251,13 +256,13 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "stopWatchlabel new fail!!"); return; } - stopWatchlabel->SetPosition(83, 52, 300, 40); + stopWatchlabel->SetPosition(83, 50, 300, 35); stopWatchlabel->SetStyle(STYLE_TEXT_FONT, 30); stopWatchlabel->SetStyle(STYLE_LINE_HEIGHT, 35); - stopWatchlabel->SetText("秒表"); - stopWatchlabel->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE); + stopWatchlabel->SetTextId(STR_STOPWATCH); // 秒表 + stopWatchlabel->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION); stopWatchlabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - stopWatchlabel->SetRollSpeed(40); + stopWatchlabel->SetRollSpeed(70); stopWatchlabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); stopWatchlabel->SetVisible(true); /* ------------------------------ showTimelabel ----------------------------- */ @@ -295,6 +300,11 @@ namespace OHOS list->SetPosition(56, 170, 360, 100); list->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); list->SetReboundSize(30); + list->SetThrowDrag(true); + list->SetIntercept(true); + list->SetMaxScrollDistance(1000); + list->SetDragACCLevel(5); + list->SetSwipeACCLevel(800); /*设置手指抬起屏幕后的补偿距离。*/ list->SetVisible(false); /* ------------------------------- listadapter ------------------------------ */ listadapter = new TextAdapter(); diff --git a/code/sdk/application/wearable/fd230app/nativeui/stopwatch/src/StopWatchModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/stopwatch/src/StopWatchModel.cpp index 3b64f189e..d7276cf39 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/stopwatch/src/StopWatchModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/stopwatch/src/StopWatchModel.cpp @@ -82,7 +82,7 @@ namespace OHOS static void StopWatch_TimerCallbackProc(int data) { g_StopWatchTimes += 10; // 每次回调增加10毫秒 - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "g_StopWatchTimes:%d\n", g_StopWatchTimes); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "g_StopWatchTimes:%d\n", g_StopWatchTimes); if (MainStopWatchView::GetInstance() == nullptr) { diff --git a/code/sdk/application/wearable/fd230app/nativeui/stopwatch/src/StopWatchRecordCycleToLimitView.cpp b/code/sdk/application/wearable/fd230app/nativeui/stopwatch/src/StopWatchRecordCycleToLimitView.cpp index feca45ee8..276d7f90c 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/stopwatch/src/StopWatchRecordCycleToLimitView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/stopwatch/src/StopWatchRecordCycleToLimitView.cpp @@ -1,6 +1,7 @@ #include "stopwatch/include/StopWatchRecordCycleToLimitView.h" #include "stopwatch/include/MainStopWatchPresenter.h" #include "UiConfig.h" +#include "wearable_log.h" /*弹窗视图:到达最高圈数99时弹出*/ namespace OHOS { @@ -9,19 +10,19 @@ namespace OHOS StopWatchRecordCycleToLimitView::StopWatchRecordCycleToLimitView() { - + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "StopWatchRecordCycleToLimitView::StopWatchRecordCycleToLimitView"); g_pStopWatchRecordCycleToLimitView = this; } StopWatchRecordCycleToLimitView::~StopWatchRecordCycleToLimitView() { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "StopWatchRecordCycleToLimitView::~StopWatchRecordCycleToLimitView"); ClearAll(); g_pStopWatchRecordCycleToLimitView = nullptr; } StopWatchRecordCycleToLimitView *StopWatchRecordCycleToLimitView::GetInstance() { - return g_pStopWatchRecordCycleToLimitView; } // 初始化秒表到达最高圈数时弹出的视图 @@ -37,19 +38,29 @@ namespace OHOS if (Title == nullptr) { Title = new UILabelExt(); + if (Title == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Title new fail"); + return nullptr; + } } - Title->SetPosition(83, 52, 300, 40); + Title->SetPosition(83, 50, 300, 35); Title->SetStyle(STYLE_TEXT_FONT, 30); Title->SetStyle(STYLE_LINE_HEIGHT, 35); - Title->SetText("秒表"); - Title->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE); + Title->SetTextId(STR_STOPWATCH); // 秒表 + Title->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION); Title->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - Title->SetRollSpeed(40); + Title->SetRollSpeed(70); Title->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); /* -------------------------------------------------------------------------- */ if (AttentionImage == nullptr) { AttentionImage = new UIImageView(); + if (AttentionImage == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AttentionImage new fail"); + return nullptr; + } } AttentionImage->SetPosition(193, 121, 100, 100); AttentionImage->SetStyle(STYLE_BORDER_RADIUS, 100); @@ -58,29 +69,44 @@ namespace OHOS if (AttentionLabel == nullptr) { AttentionLabel = new UILabelExt(); + if (AttentionLabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AttentionLabel new fail"); + return nullptr; + } } - AttentionLabel->SetPosition(83, 253, 300, 40); + AttentionLabel->SetPosition(83, 253, 300, 35); AttentionLabel->SetStyle(STYLE_TEXT_FONT, 30); AttentionLabel->SetStyle(STYLE_LINE_HEIGHT, 35); - AttentionLabel->SetText("当前已达到了最高圈数"); - AttentionLabel->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE); + AttentionLabel->SetTextId(STR_TMCHBR); // 当前已达到了最高计数 + AttentionLabel->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION); AttentionLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); AttentionLabel->SetTextColor(Color::GetColorFromRGBA(0xaa, 0xaa, 0xaa, 0xff)); - AttentionLabel->SetRollSpeed(40); + AttentionLabel->SetRollSpeed(70); AttentionLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); /* -------------------------------------------------------------------------- */ if (button == nullptr) { button = new UILabelButtonExt(); + if (button == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "button new fail"); + return nullptr; + } } button->SetPosition(0, 366, 466, 100); button->SetViewId(CycleToLimitReturnButton_VIEWID); button->SetImageSrc(PNG_466x100BUTTON_IMAGE, PNG_466x100BUTTON_IMAGE); - button->SetText("知道了"); + button->SetTextId(STR_KONW); button->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); button->SetStyle(STYLE_LINE_HEIGHT, 35); button->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff000000, UIButton::PRESSED); UIView::OnClickListener *buttonClick = static_cast(MainStopWatchPresenter::GetInstance()); + if (buttonClick == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "buttonClick new fail"); + return nullptr; + } button->SetOnClickListener(buttonClick); /* ----------------------------------- Add ---------------------------------- */ scrollView->Add(Title); @@ -93,30 +119,29 @@ namespace OHOS void StopWatchRecordCycleToLimitView::ClearAll() { - scrollView->RemoveAll(); - - if (Title != nullptr) - { - delete Title; - Title = nullptr; - } - if (AttentionImage != nullptr) - { - delete AttentionImage; - AttentionImage = nullptr; - } - if (AttentionLabel != nullptr) - { - delete AttentionLabel; - AttentionLabel = nullptr; - } - if (button != nullptr) - { - delete button; - button = nullptr; - } if (scrollView != nullptr) { + scrollView->RemoveAll(); + if (Title != nullptr) + { + delete Title; + Title = nullptr; + } + if (AttentionImage != nullptr) + { + delete AttentionImage; + AttentionImage = nullptr; + } + if (AttentionLabel != nullptr) + { + delete AttentionLabel; + AttentionLabel = nullptr; + } + if (button != nullptr) + { + delete button; + button = nullptr; + } delete scrollView; scrollView = nullptr; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/stopwatch/src/StopWatchRecordTimeToLimitView.cpp b/code/sdk/application/wearable/fd230app/nativeui/stopwatch/src/StopWatchRecordTimeToLimitView.cpp index 241bd2cbb..8df7a038a 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/stopwatch/src/StopWatchRecordTimeToLimitView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/stopwatch/src/StopWatchRecordTimeToLimitView.cpp @@ -1,7 +1,7 @@ #include "stopwatch/include/StopWatchRecordTimeToLimitView.h" #include "stopwatch/include/MainStopWatchPresenter.h" #include "UiConfig.h" - +#include "wearable_log.h" /*弹窗视图:到达最高时间99:59.99时弹出*/ namespace OHOS { @@ -10,11 +10,13 @@ namespace OHOS StopWatchRecordTimeToLimitView::StopWatchRecordTimeToLimitView() { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "StopWatchRecordTimeToLimitView::StopWatchRecordTimeToLimitView"); g_pStopWatchRecordTimeToLimitView = this; } StopWatchRecordTimeToLimitView::~StopWatchRecordTimeToLimitView() { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "StopWatchRecordTimeToLimitView::~StopWatchRecordTimeToLimitView"); ClearAll(); g_pStopWatchRecordTimeToLimitView = nullptr; } @@ -36,19 +38,29 @@ namespace OHOS if (Title == nullptr) { Title = new UILabelExt(); + if (Title == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Title new fail"); + return nullptr; + } } - Title->SetPosition(83, 52, 300, 40); + Title->SetPosition(83, 50, 300, 35); Title->SetStyle(STYLE_TEXT_FONT, 30); Title->SetStyle(STYLE_LINE_HEIGHT, 35); - Title->SetText("秒表"); - Title->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE); + Title->SetTextId(STR_STOPWATCH); // 秒表 + Title->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION); Title->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - Title->SetRollSpeed(40); + Title->SetRollSpeed(70); Title->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); /* -------------------------------------------------------------------------- */ if (AttentionImage == nullptr) { AttentionImage = new UIImageView(); + if (AttentionImage == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AttentionImage new fail"); + return nullptr; + } } AttentionImage->SetPosition(193, 121, 100, 100); AttentionImage->SetStyle(STYLE_BORDER_RADIUS, 100); @@ -57,43 +69,63 @@ namespace OHOS if (AttentionLabel_1 == nullptr) { AttentionLabel_1 = new UILabelExt(); + if (AttentionLabel_1 == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AttentionLabel_1 new fail"); + return nullptr; + } } - AttentionLabel_1->SetPosition(83, 235, 300, 40); + AttentionLabel_1->SetPosition(83, 235, 300, 35); AttentionLabel_1->SetStyle(STYLE_TEXT_FONT, 30); AttentionLabel_1->SetStyle(STYLE_LINE_HEIGHT, 35); - AttentionLabel_1->SetText("当前已达到了最长时间"); - AttentionLabel_1->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE); + AttentionLabel_1->SetTextId(STR_MAXIMUM_TIME_REACH_NOTE); // 当前已达到了最长时间 + AttentionLabel_1->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION); AttentionLabel_1->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); AttentionLabel_1->SetTextColor(Color::GetColorFromRGBA(0xaa, 0xaa, 0xaa, 0xff)); - AttentionLabel_1->SetRollSpeed(40); + AttentionLabel_1->SetRollSpeed(70); AttentionLabel_1->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); /* ---------------------------- AttentionLabel_2 ---------------------------- */ if (AttentionLabel_2 == nullptr) { AttentionLabel_2 = new UILabelExt(); + if (AttentionLabel_2 == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AttentionLabel_2 new fail"); + return nullptr; + } } - AttentionLabel_2->SetPosition(33, 279, 400, 40); + AttentionLabel_2->SetPosition(53, 279, 360, 35); AttentionLabel_2->SetStyle(STYLE_TEXT_FONT, 30); AttentionLabel_2->SetStyle(STYLE_LINE_HEIGHT, 35); - AttentionLabel_2->SetText("表秒自动暂停,请重新开始"); - AttentionLabel_2->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE); + AttentionLabel_2->SetTextId(STR_STOPWATCH_STOP_NOTE); // 秒表自动暂停,请重新开始 + AttentionLabel_2->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION); AttentionLabel_2->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); AttentionLabel_2->SetTextColor(Color::GetColorFromRGBA(0xaa, 0xaa, 0xaa, 0xff)); - AttentionLabel_2->SetRollSpeed(40); + AttentionLabel_2->SetRollSpeed(70); AttentionLabel_2->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); /* -------------------------------------------------------------------------- */ if (button == nullptr) { button = new UILabelButtonExt(); + if (button == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "button new fail"); + return nullptr; + } } button->SetPosition(0, 366, 466, 100); button->SetViewId(TimeToLimitReturnButton_VIEWID); button->SetImageSrc(PNG_466x100BUTTON_IMAGE, PNG_466x100BUTTON_IMAGE); - button->SetText("知道了"); + button->SetTextId(STR_KONW); button->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); button->SetStyle(STYLE_LINE_HEIGHT, 35); button->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff000000, UIButton::PRESSED); UIView::OnClickListener *buttonClick = static_cast(MainStopWatchPresenter::GetInstance()); + if (buttonClick == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "buttonClick new fail"); + return nullptr; + } button->SetOnClickListener(buttonClick); /* ----------------------------------- Add ---------------------------------- */ scrollView->Add(Title); @@ -107,29 +139,30 @@ namespace OHOS void StopWatchRecordTimeToLimitView::ClearAll() { - scrollView->RemoveAll(); - if (Title != nullptr) - { - delete Title; - Title = nullptr; - } - if (AttentionImage != nullptr) - { - delete AttentionImage; - AttentionImage = nullptr; - } - if (AttentionLabel_1 != nullptr) - { - delete AttentionLabel_1; - AttentionLabel_1 = nullptr; - } - if (button != nullptr) - { - delete button; - button = nullptr; - } if (scrollView != nullptr) { + scrollView->RemoveAll(); + if (Title != nullptr) + { + delete Title; + Title = nullptr; + } + if (AttentionImage != nullptr) + { + delete AttentionImage; + AttentionImage = nullptr; + } + if (AttentionLabel_1 != nullptr) + { + delete AttentionLabel_1; + AttentionLabel_1 = nullptr; + } + if (button != nullptr) + { + delete button; + button = nullptr; + } + delete scrollView; scrollView = nullptr; }