From e5ad27a3f2f01368963cf0ca54e5b8146fe2d3cf Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E7=BD=97=E6=AD=A3?= <1732036298@qq.com> Date: Wed, 24 Jul 2024 01:42:47 +0000 Subject: [PATCH] Merge #577 into sdk602patch0626 from refs/changes/577/head MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Code review from 罗正 * refs/changes/577/head: (15 commits squashed) - 修改恢复出厂设置适配多国语言 - 1.优化设置视图:添加了表冠控制但效果不佳 2.滑动关机和重启视图添加按键注册功能 3.现在设置视图进入关机和重启为“滑动关机重启Slice” - 优化屏幕与亮度Slice: 1.添加了scrollview的表冠控制, 2.标签断行模式为LINE_BREAK_OSCILLATION改为LINE_BREAK_OSCILLATION 3.亮屏时长视图实现点击按钮该变亮屏时长单选按钮选中状态 - 解决手表解绑后恢复出厂设置,如果手机是直接与手表配对成功未选择语言,进入主界面后发现手表缺少字体问题。 1.如果手机与手表先绑定成功,未选择语言,需选择语言才进入主界面。 2.如果已选择语言,这时手机与手表绑定成功将自动进入主界面。 - 传统蓝牙Slice优化修改 - 喝水提醒尾部括号字符移除(原因:特殊字符不显示故删除) - Merge branch 'sdk602patch0626' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0626 - Merge branch 'sdk602patch0626' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0626 - 设置视图优化表冠控制 - 解决天气界面没有时间显示的bug,并优化时间刷新 1.目前主界面天气刷新:如果在天气卡片,天气数据有效,就刷新时间 2.如果是Slice天气:滑到第一个界面,时间就会更新 - 解决左滑进入指南针卡片,手持手表,左上角度数被遮挡bug - 解决左滑进入指南针卡片,与预览图不一致问题q - 解决手表第一次启动:如果选择完语言后重启未配对会直接进入到主界面bug - 通过下拉,刷新蓝牙连接状态,解决手机关闭蓝牙后手机还显示已连接问题需要等待一会才会显示断开连接 - Merge branch 'sdk602patch0626' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0626 Signed-off-by: 罗正 <1732036298@qq.com> Reviewed-by: snickersun@163.com Merged-by: snickersun@163.com CR-link: https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230/change/577 --- .../bluetooth/src/MainBluetoothView.cpp | 3 +- .../include/ClassicBlueToothPresenter.h | 13 +- .../src/BluetoothServiceOptionsView.cpp | 124 ++++++++------- .../src/ClassicBlueToothPresenter.cpp | 21 ++- .../src/ClassicBlueToothView.cpp | 147 +++++++++--------- .../nativeui/compass/include/CompassView.h | 4 +- .../language/Language_xml/input_list_en.txt | 2 +- .../language/Language_xml/input_list_zh.txt | 2 +- .../language/Language_xml/language_en.xml | 2 +- .../language/Language_xml/language_zh.xml | 2 +- .../fd230app/nativeui/language/font/en.lang | Bin 9986 -> 9967 bytes .../fd230app/nativeui/language/font/zh.lang | Bin 9069 -> 9046 bytes .../nativeui/language/languagemake.sh | 6 +- .../nativeui/languagecode/LanguageInit.cpp | 6 +- .../nativeui/main/src/MainPresenterSample.cpp | 6 + .../nativeui/main/src/PullUpDownView.cpp | 23 ++- .../nativeui/settings/src/SettingView.cpp | 11 +- .../nativeui/weather/include/WeatherModel.h | 4 +- .../nativeui/weather/include/WeatherView.h | 4 +- .../weather/src/MainWeatherPresenter.cpp | 4 +- .../nativeui/weather/src/WeatherModel.cpp | 31 +++- .../nativeui/weather/src/WeatherView.cpp | 15 +- .../fs/user/res/MainCard/CompassCard.bin | 2 +- .../fd230/fs/user/res/font/en.lang | Bin 9986 -> 9967 bytes .../fd230/fs/user/res/font/zh.lang | Bin 9069 -> 9046 bytes 25 files changed, 247 insertions(+), 185 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/MainBluetoothView.cpp b/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/MainBluetoothView.cpp index 4792a68c6..3c6aa8cac 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/MainBluetoothView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/MainBluetoothView.cpp @@ -342,7 +342,8 @@ void MainBluetoothView::ChangeSettingView() WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainBluetoothView::ChangeSettingView"); BluetoothModel::GetInstance()->SetTagConnectView(false); BluetoothModel::GetInstance()->SetTagScanDeviceClicked(false); - NativeAbility::GetInstance().ChangeSlice(VIEW_SETTING); + // NativeAbility::GetInstance().ChangeSlice(VIEW_SETTING); + NativeAbility::GetInstance().Back(); } void MainBluetoothView::DropEarPhoneView() diff --git a/code/sdk/application/wearable/fd230app/nativeui/classicbluetooth/include/ClassicBlueToothPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/classicbluetooth/include/ClassicBlueToothPresenter.h index 06f9536a4..0404af427 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/classicbluetooth/include/ClassicBlueToothPresenter.h +++ b/code/sdk/application/wearable/fd230app/nativeui/classicbluetooth/include/ClassicBlueToothPresenter.h @@ -1,3 +1,10 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-04-25 11:50:51 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-07-23 10:15:46 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/classicbluetooth/include/ClassicBlueToothPresenter.h + */ #ifndef CLASSIC_BLUETOOTH_PRESENTER_H #define CLASSIC_BLUETOOTH_PRESENTER_H #include "Presenter.h" @@ -16,21 +23,21 @@ namespace OHOS public: ClassicBlueToothPresenter(); virtual ~ClassicBlueToothPresenter(); + static ClassicBlueToothPresenter *GetInstance(); virtual void OnStart() override; virtual void OnPause() override; virtual void OnResume() override; virtual void OnStop() override; - static ClassicBlueToothPresenter *GetInstance(); - private: - // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; bool OnClick(UIView &view, const ClickEvent &event) override; bool OnDrag(UIView &view, const DragEvent &event) override; bool OnDragEnd(UIView &view, const DragEvent &event) override; bool OnChange(UICheckBox::UICheckBoxState state) override; bool OnKeyAct(UIView &view, const KeyEvent &event) override; + + bool X_DRAG_FLAG{false}; }; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/classicbluetooth/src/BluetoothServiceOptionsView.cpp b/code/sdk/application/wearable/fd230app/nativeui/classicbluetooth/src/BluetoothServiceOptionsView.cpp index 694965bc6..7461ab113 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/classicbluetooth/src/BluetoothServiceOptionsView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/classicbluetooth/src/BluetoothServiceOptionsView.cpp @@ -4,7 +4,9 @@ #include "UiConfig.h" #include "wearable_log.h" #include "PhoneService.h" +#include "phoneservice/include/PhoneService.h" #include "BluetoothModel.h" +#include "ui_resource_string.h" namespace OHOS { static BluetoothServiceOptionsView *g_pBluetoothServiceOptionsView{nullptr}; @@ -31,31 +33,48 @@ namespace OHOS { if (initViewStatus == true) { - BlueToothScrollView->RemoveAll(); - - delete Title; - Title = nullptr; - - delete HFP_Image; - HFP_Image = nullptr; - - delete A2DP_Image; - A2DP_Image = nullptr; - - delete HFP_Label; - HFP_Label = nullptr; - - delete A2DP_Label; - A2DP_Label = nullptr; - - delete HFP_ToggleButton; - HFP_ToggleButton = nullptr; - - delete A2DP_ToggleButton; - A2DP_ToggleButton = nullptr; - - delete BlueToothScrollView; - BlueToothScrollView = nullptr; + if (BlueToothScrollView != nullptr) + { + BlueToothScrollView->RemoveAll(); + + if (Title != nullptr) + { + delete Title; + Title = nullptr; + } + if (HFP_Image != nullptr) + { + delete HFP_Image; + HFP_Image = nullptr; + } + if (A2DP_Image != nullptr) + { + delete A2DP_Image; + A2DP_Image = nullptr; + } + if (HFP_Label != nullptr) + { + delete HFP_Label; + HFP_Label = nullptr; + } + if (A2DP_Label != nullptr) + { + delete A2DP_Label; + A2DP_Label = nullptr; + } + if (HFP_ToggleButton != nullptr) + { + delete HFP_ToggleButton; + HFP_ToggleButton = nullptr; + } + if (A2DP_ToggleButton != nullptr) + { + delete A2DP_ToggleButton; + A2DP_ToggleButton = nullptr; + } + delete BlueToothScrollView; + BlueToothScrollView = nullptr; + } } } @@ -95,9 +114,8 @@ namespace OHOS label->SetPosition(labelconfig.left, labelconfig.top, labelconfig.width, labelconfig.height); // 位置大小 label->SetStyle(STYLE_TEXT_FONT, labelconfig.fontSize); // 字体大小 label->SetStyle(STYLE_LINE_HEIGHT, labelconfig.lineHeigh); // 字体行高 - //label->SetText(labelconfig.text); // 内容 - label->SetTextId(labelconfig.textId); - label->SetLineBreakMode(labelconfig.lineBreakMode); // 断行模式。 + label->SetTextId(labelconfig.textId); + label->SetLineBreakMode(labelconfig.lineBreakMode); // 断行模式。 label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, labelconfig.fontSize); return label; } @@ -107,14 +125,13 @@ namespace OHOS { LabelConfig labelconfig = { .left = 93, - .top = 52, + .top = 50, .width = 280, .height = 40, .fontSize = 30, .lineHeigh = 35, - //.text = "蓝牙服务选项", - .textId = STR_BLUETOOTH_SERVICE_OPTIONS, - .lineBreakMode = UILabel::LINE_BREAK_MARQUEE, + .textId = STR_BLUETOOTH_SERVICE_OPTIONS, /*蓝牙服务选项*/ + .lineBreakMode = UILabel::LINE_BREAK_OSCILLATION, }; Title = SetBluetoothServiceOptionsViewLabel(labelconfig); if (nullptr == Title) @@ -131,9 +148,8 @@ namespace OHOS .height = 40, .fontSize = 30, .lineHeigh = 35, - //.text = "通话蓝牙", - .textId = STR_HFP, - .lineBreakMode = UILabel::LINE_BREAK_MARQUEE, + .textId = STR_HFP, /*通话蓝牙*/ + .lineBreakMode = UILabel::LINE_BREAK_OSCILLATION, }; HFP_Label = SetBluetoothServiceOptionsViewLabel(labelconfig); if (nullptr == HFP_Label) @@ -142,8 +158,7 @@ namespace OHOS return false; } labelconfig.top = 273; - //labelconfig.text = "媒体蓝牙"; - labelconfig.textId = STR_A2DP; + labelconfig.textId = STR_A2DP; /*媒体蓝牙*/ A2DP_Label = SetBluetoothServiceOptionsViewLabel(labelconfig); if (nullptr == A2DP_Label) { @@ -164,7 +179,7 @@ namespace OHOS return false; } HFP_ToggleButton->SetPosition(298, 145, 100, 50); - HFP_ToggleButton->SetState(uapi_hfp_connect_state());//ConfigModel::GetInstance()->GetHFPState()); + HFP_ToggleButton->SetState(uapi_hfp_connect_state()); // ConfigModel::GetInstance()->GetHFPState()); HFP_ToggleButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); HFP_ToggleButton->SetImages(PNG_TOGGLEBUTTON_ON_IMAGE, PNG_TOGGLEBUTTON_OFF_IMAGE); /* -------------------------------------------------------------------------- */ @@ -180,6 +195,11 @@ namespace OHOS A2DP_ToggleButton->SetImages(PNG_TOGGLEBUTTON_ON_IMAGE, PNG_TOGGLEBUTTON_OFF_IMAGE); /* -------------------------------------------------------------------------- */ UIView::OnClickListener *clickListener = static_cast(BluetoothServiceOptionsPresenter::GetInstance()); + if (nullptr == clickListener) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothServiceOptionsPresenter::GetInstance fail!!"); + return false; + } HFP_ToggleButton->SetOnClickListener(clickListener); A2DP_ToggleButton->SetOnClickListener(clickListener); @@ -226,33 +246,23 @@ namespace OHOS /// @param void void BluetoothServiceOptionsView::BluetoothServiceOptionsViewInit(void) { - if (!SetUpBlueToothScrollView()) - { - return; - } - - if (!SetUpBlueToothImageView()) + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothServiceOptionsView::BluetoothServiceOptionsViewInit"); + if (!SetUpBlueToothScrollView() || !SetUpBlueToothImageView() || !SetUpBlueToothLabel() || !SetUpBlueToothToggleButton()) { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothServiceOptionsView::BluetoothServiceOptionsViewInit fail!!"); return; } - - if (!SetUpBlueToothLabel()) - { - return; - } - - if (!SetUpBlueToothToggleButton()) - { - return; - } - - initViewStatus = true; } void BluetoothServiceOptionsView::OnStart() { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BluetoothServiceOptionsView::OnStart"); View::OnStart(); - BluetoothServiceOptionsViewInit(); + if (!initViewStatus) + { + BluetoothServiceOptionsViewInit(); + initViewStatus = true; + } // 增加按键监听 RootView::OnKeyActListener *keyactListener = (RootView::OnKeyActListener *)OHOS::BluetoothServiceOptionsPresenter::GetInstance(); diff --git a/code/sdk/application/wearable/fd230app/nativeui/classicbluetooth/src/ClassicBlueToothPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/classicbluetooth/src/ClassicBlueToothPresenter.cpp index e91a7ede4..b63e96800 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/classicbluetooth/src/ClassicBlueToothPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/classicbluetooth/src/ClassicBlueToothPresenter.cpp @@ -1,8 +1,8 @@ /* * @Author: luozheng 1732036298@qq.com * @Date: 2024-04-25 11:50:57 - * @LastEditors: SnickerSun snickersun@163.com - * @LastEditTime: 2024-07-03 15:18:50 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-07-23 10:18:06 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/classicbluetooth/src/ClassicBlueToothPresenter.cpp */ #include "classicbluetooth/include/ClassicBlueToothPresenter.h" @@ -14,6 +14,7 @@ #include #include "wearable_log.h" #include "ConfigModel.h" +#include namespace OHOS { // 当前Presenter属性实例化的内存指针 @@ -36,23 +37,25 @@ namespace OHOS void ClassicBlueToothPresenter::OnStart() { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ClassicBlueToothPresenter::OnStart"); Presenter::OnStart(); } void ClassicBlueToothPresenter::OnPause(void) { - + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ClassicBlueToothPresenter::OnPause"); Presenter::OnPause(); } void ClassicBlueToothPresenter::OnResume(void) { - + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ClassicBlueToothPresenter::OnResume"); Presenter::OnResume(); } void ClassicBlueToothPresenter::OnStop(void) { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ClassicBlueToothPresenter::OnStop"); Presenter::OnStop(); } @@ -85,8 +88,11 @@ namespace OHOS bool ClassicBlueToothPresenter::OnDrag(UIView &view, const DragEvent &event) { UNUSED(view); - UNUSED(event); WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ClassicBlueToothPresenter::OnDrag"); + if ((event.GetDeltaX() > X_DRAG_OFFSET) && (event.GetDeltaX() > (DOUBLES * MATH_ABS(event.GetDeltaY())))) // 拖动过程中判断是否是水平滑动 + { + X_DRAG_FLAG = true; + } return true; } @@ -94,9 +100,10 @@ namespace OHOS { UNUSED(view); WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ClassicBlueToothPresenter::OnDragEnd"); - if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) + if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && X_DRAG_FLAG) { NativeAbility::GetInstance().Back(); + X_DRAG_FLAG = false; } return true; @@ -128,7 +135,7 @@ namespace OHOS bool ClassicBlueToothPresenter::OnKeyAct(UIView &view, const KeyEvent &event) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ClassicBlueToothPresenter::OnKeyAct"); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ClassicBlueToothPresenter::OnKeyAct"); uint16 keyID = event.GetKeyId(); uint16 keyState = event.GetState(); // 如果是power键,且是亮屏状态,按键释放就返回上一级 diff --git a/code/sdk/application/wearable/fd230app/nativeui/classicbluetooth/src/ClassicBlueToothView.cpp b/code/sdk/application/wearable/fd230app/nativeui/classicbluetooth/src/ClassicBlueToothView.cpp index 520695e45..789145744 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/classicbluetooth/src/ClassicBlueToothView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/classicbluetooth/src/ClassicBlueToothView.cpp @@ -16,7 +16,6 @@ namespace OHOS ClassicBlueToothView::~ClassicBlueToothView() { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "~ClassicBlueToothView::ClassicBlueToothView"); - ClearAll(); g_pClassicBlueToothView = nullptr; } @@ -29,34 +28,52 @@ namespace OHOS { if (initViewStatus == true) { - BlueToothScrollView->RemoveAll(); - - delete Title; - Title = nullptr; - - delete BlueToothEarPhoneButton; - BlueToothEarPhoneButton = nullptr; - - delete TradionalBlueToothButton; - TradionalBlueToothButton = nullptr; - - delete BluetoothServiceOptionsButton; - BluetoothServiceOptionsButton = nullptr; - - delete BlueToothEarPhoneLabel; - BlueToothEarPhoneLabel = nullptr; - - delete TradionalBlueToothLabel; - TradionalBlueToothLabel = nullptr; - - delete AttentionLabel; - AttentionLabel = nullptr; - - delete TradionalBlueToothToggleButton; - TradionalBlueToothToggleButton = nullptr; - - delete BlueToothScrollView; - BlueToothScrollView = nullptr; + if (BlueToothScrollView) + { + BlueToothScrollView->RemoveAll(); + if (Title != nullptr) + { + delete Title; + Title = nullptr; + } + if (BlueToothEarPhoneButton != nullptr) + { + delete BlueToothEarPhoneButton; + BlueToothEarPhoneButton = nullptr; + } + if (TradionalBlueToothButton != nullptr) + { + delete TradionalBlueToothButton; + TradionalBlueToothButton = nullptr; + } + if (BluetoothServiceOptionsButton != nullptr) + { + delete BluetoothServiceOptionsButton; + BluetoothServiceOptionsButton = nullptr; + } + if (BlueToothEarPhoneLabel != nullptr) + { + delete BlueToothEarPhoneLabel; + BlueToothEarPhoneLabel = nullptr; + } + if (TradionalBlueToothLabel != nullptr) + { + delete TradionalBlueToothLabel; + TradionalBlueToothLabel = nullptr; + } + if (AttentionLabel != nullptr) + { + delete AttentionLabel; + AttentionLabel = nullptr; + } + if (TradionalBlueToothToggleButton != nullptr) + { + delete TradionalBlueToothToggleButton; + TradionalBlueToothToggleButton = nullptr; + } + delete BlueToothScrollView; + BlueToothScrollView = nullptr; + } } } @@ -69,9 +86,10 @@ namespace OHOS return false; } BlueToothScrollView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); - BlueToothScrollView->SetScrollBlankSize(35); + BlueToothScrollView->SetScrollBlankSize(50); BlueToothScrollView->SetReboundSize(50); BlueToothScrollView->SetDirection(1); + BlueToothScrollView->RequestFocus(); UIView::OnDragListener *draglistener = static_cast(ClassicBlueToothPresenter::GetInstance()); if (draglistener == nullptr) { @@ -96,7 +114,6 @@ namespace OHOS label->SetPosition(labelconfig.left, labelconfig.top, labelconfig.width, labelconfig.height); // 位置大小 label->SetStyle(STYLE_TEXT_FONT, labelconfig.fontSize); // 字体大小 label->SetStyle(STYLE_LINE_HEIGHT, labelconfig.lineHeigh); // 字体行高 - // label->SetText(labelconfig.text); // 内容 label->SetTextId(labelconfig.textId); label->SetLineBreakMode(labelconfig.lineBreakMode); // 断行模式。 label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, labelconfig.fontSize); @@ -108,14 +125,13 @@ namespace OHOS { LabelConfig labelconfig = { .left = 93, - .top = 52, + .top = 50, .width = 300, .height = 35, .fontSize = 30, .lineHeigh = 35, - //.text = "蓝牙", - .textId = STR_BLUETOOTH, - .lineBreakMode = UILabel::LINE_BREAK_MARQUEE, + .textId = STR_BLUETOOTH, /*蓝牙*/ + .lineBreakMode = UILabel::LINE_BREAK_OSCILLATION, }; Title = SetClassicBlueToothViewLabel(labelconfig); if (nullptr == Title) @@ -132,9 +148,8 @@ namespace OHOS .height = 35, .fontSize = 30, .lineHeigh = 35, - //.text = "蓝牙耳机", - .textId = STR_BLUETOOTH_HEADPHONES, - .lineBreakMode = UILabel::LINE_BREAK_MARQUEE, + .textId = STR_BLUETOOTH_HEADPHONES, /*蓝牙耳机*/ + .lineBreakMode = UILabel::LINE_BREAK_OSCILLATION, }; BlueToothEarPhoneLabel = SetClassicBlueToothViewLabel(labelconfig); if (nullptr == BlueToothEarPhoneLabel) @@ -144,8 +159,7 @@ namespace OHOS } /* -------------------------------------------------------------------------- */ labelconfig.top = 273; - // labelconfig.text = "传统蓝牙"; - labelconfig.textId = STR_TRADITIONAL_BLUETOOTH; + labelconfig.textId = STR_TRADITIONAL_BLUETOOTH; /*传统蓝牙*/ TradionalBlueToothLabel = SetClassicBlueToothViewLabel(labelconfig); if (nullptr == TradionalBlueToothLabel) { @@ -154,8 +168,7 @@ namespace OHOS } /* -------------------------------------------------------------------------- */ labelconfig.top = 393; - // labelconfig.text = "蓝牙服务选项"; - labelconfig.textId = STR_BLUETOOTH_SERVICE_OPTIONS; + labelconfig.textId = STR_BLUETOOTH_SERVICE_OPTIONS; /*蓝牙服务选项*/ BluetoothServiceOptionsLabel = SetClassicBlueToothViewLabel(labelconfig); if (nullptr == BluetoothServiceOptionsLabel) { @@ -172,10 +185,10 @@ namespace OHOS AttentionLabel->SetPosition(53, 499, 360, 180); // 位置大小 AttentionLabel->SetStyle(STYLE_TEXT_FONT, 20); // 字体大小 AttentionLabel->SetStyle(STYLE_LINE_HEIGHT, 30); // 字体行高 - //.text = "注:开启后10分钟没连接成功会自动关闭,因为传统蓝牙长时间打开会增加电耗,建议在有需要的时候使用\n\n(该功能主要用于电话拨打/通知、音乐控制/传输等)", - //SetLabelId(AttentionLabel, STR_AUTO_OFF_BLUETOOTH_NOTE); + //.text = "注:开启后10分钟没连接成功会自动关闭,因为传统蓝牙长时间打开会增加电耗,建议在有需要的时候使用(该功能主要用于电话拨打/通知、音乐控制/传输等)", AttentionLabel->SetTextId(STR_AUTO_OFF_BLUETOOTH_NOTE); AttentionLabel->SetTextColor(Color::GetColorFromRGBA(0x99, 0x99, 0x99, 0xff)); + AttentionLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); AttentionLabel->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); // 断行模式。 AttentionLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20); /* -------------------------------------------------------------------------- */ @@ -197,7 +210,7 @@ namespace OHOS BlueToothEarPhoneButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); BlueToothEarPhoneButton->SetImagePosition(326, 37); BlueToothEarPhoneButton->SetImageSrc(PNG_SETTING_NEXT_IMAGE, PNG_SETTING_NEXT_IMAGE); - BlueToothEarPhoneButton->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff191919, UIButton::PRESSED); + BlueToothEarPhoneButton->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff000000, UIButton::PRESSED); /* -------------------------------------------------------------------------- */ TradionalBlueToothButton = new UILabelButtonExt(); if (TradionalBlueToothButton == nullptr) @@ -222,11 +235,10 @@ namespace OHOS BluetoothServiceOptionsButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); BluetoothServiceOptionsButton->SetImagePosition(326, 37); BluetoothServiceOptionsButton->SetImageSrc(PNG_SETTING_NEXT_IMAGE, PNG_SETTING_NEXT_IMAGE); - BluetoothServiceOptionsButton->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff191919, UIButton::PRESSED); + BluetoothServiceOptionsButton->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff000000, UIButton::PRESSED); /* -------------------------------------------------------------------------- */ - UIView::OnClickListener *clickListener = static_cast(ClassicBlueToothPresenter::GetInstance()); - BlueToothEarPhoneButton->SetOnClickListener(clickListener); - BluetoothServiceOptionsButton->SetOnClickListener(clickListener); + BlueToothEarPhoneButton->SetOnClickListener(presenter_); + BluetoothServiceOptionsButton->SetOnClickListener(presenter_); return true; } @@ -244,8 +256,7 @@ namespace OHOS TradionalBlueToothToggleButton->SetState(ConfigModel::GetInstance()->GetClassicBlueToothState()); TradionalBlueToothToggleButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); TradionalBlueToothToggleButton->SetImages(PNG_TOGGLEBUTTON_ON_IMAGE, PNG_TOGGLEBUTTON_OFF_IMAGE); - UICheckBox::OnChangeListener *changeListener = static_cast(ClassicBlueToothPresenter::GetInstance()); - TradionalBlueToothToggleButton->SetOnChangeListener(changeListener); + TradionalBlueToothToggleButton->SetOnChangeListener(presenter_); return true; } @@ -258,37 +269,25 @@ namespace OHOS /// @param void void ClassicBlueToothView::ClassicBlueToothViewInit(void) { - if (!SetUpBlueToothScrollView()) - { - return; - } - - if (!SetUpBlueToothButton()) + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ClassicBlueToothView::ClassicBlueToothViewInit"); + if (!SetUpBlueToothScrollView() || !SetUpBlueToothButton() || !SetUpBlueToothLabel() || !SetUpBlueToothToggleButton()) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ClassicBlueToothView::ClassicBlueToothViewInit fail!!"); return; } - - if (!SetUpBlueToothLabel()) - { - return; - } - - if (!SetUpBlueToothToggleButton()) - { - return; - } - - initViewStatus = true; } void ClassicBlueToothView::OnStart() { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ClassicBlueToothView::OnStart"); View::OnStart(); - ClassicBlueToothViewInit(); + if (!initViewStatus) + { + ClassicBlueToothViewInit(); + initViewStatus = true; + } - // 增加按键监听 - RootView::OnKeyActListener *keyactListener = (RootView::OnKeyActListener *)OHOS::ClassicBlueToothPresenter::GetInstance(); - RootView::GetInstance()->SetOnKeyActListener(keyactListener); + RootView::GetInstance()->SetOnKeyActListener(presenter_); // 增加按键监听 } void ClassicBlueToothView::OnSetUpView() @@ -305,6 +304,7 @@ namespace OHOS BlueToothScrollView->Add(AttentionLabel); BlueToothScrollView->Add(TradionalBlueToothToggleButton); RootView::GetInstance()->Add(BlueToothScrollView); + container_ = BlueToothScrollView; Draw(); } @@ -321,6 +321,7 @@ namespace OHOS View::OnStop(); RootView::GetInstance()->RemoveAll(); RootView::GetInstance()->ClearOnKeyActListener(); + ClearAll(); return; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/compass/include/CompassView.h b/code/sdk/application/wearable/fd230app/nativeui/compass/include/CompassView.h index 877572f3e..420dee6ee 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/compass/include/CompassView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/compass/include/CompassView.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-06-12 11:44:04 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-06-27 09:51:49 + * @LastEditTime: 2024-07-23 15:18:13 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/compass/include/CompassView.h */ @@ -20,7 +20,7 @@ #include "CompassCalibrationView.h" namespace OHOS { -static constexpr float VIEW_CENTERS = 227; +static constexpr float VIEW_CENTERS = 233;/*233代表分辨率为466的屏幕*/ class CompassView : public AppGroupView { public: diff --git a/code/sdk/application/wearable/fd230app/nativeui/language/Language_xml/input_list_en.txt b/code/sdk/application/wearable/fd230app/nativeui/language/Language_xml/input_list_en.txt index 969dd6934..baca8ed6c 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/language/Language_xml/input_list_en.txt +++ b/code/sdk/application/wearable/fd230app/nativeui/language/Language_xml/input_list_en.txt @@ -451,7 +451,7 @@ STR_DEVICE_BINDING_NOTE$XX wants to connect and bind with you STR_EQUIPMENT_UNTYING$Equipment untying STR_EQUIPMENT_UNTYING_NOTE$XX would like to unbind you STR_DRINK_WATER_REMINDER$Drink water reminder -STR_DRINK_WATER_REMINDER_NOTE$Time for some water! And stay hydrated (๑•̀ㅂ•́) +STR_DRINK_WATER_REMINDER_NOTE$Time for some water! And stay hydrated STR_SEDENTARY_REMINDER$Sedentary reminder STR_SEDENTARY_REMINDER_NOTE$You haven't moved for XX hours. Get up and move. STR_SYSTEM_UPGRADING$System upgrading diff --git a/code/sdk/application/wearable/fd230app/nativeui/language/Language_xml/input_list_zh.txt b/code/sdk/application/wearable/fd230app/nativeui/language/Language_xml/input_list_zh.txt index 099b258a6..459021969 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/language/Language_xml/input_list_zh.txt +++ b/code/sdk/application/wearable/fd230app/nativeui/language/Language_xml/input_list_zh.txt @@ -451,7 +451,7 @@ STR_DEVICE_BINDING_NOTE$XX想要与你进行连接绑定 STR_EQUIPMENT_UNTYING$设备解绑 STR_EQUIPMENT_UNTYING_NOTE$XX想要与你进行解绑 STR_DRINK_WATER_REMINDER$喝水提醒 -STR_DRINK_WATER_REMINDER_NOTE$该喝水啦!记得按时保持水分充足(๑•̀ㅂ•́)و✧ +STR_DRINK_WATER_REMINDER_NOTE$该喝水啦!记得按时保持水分充足 STR_SEDENTARY_REMINDER$久坐提醒 STR_SEDENTARY_REMINDER_NOTE$你已经XX小时未活动了,站起来活动一下吧。 STR_SYSTEM_UPGRADING$系统升级中 diff --git a/code/sdk/application/wearable/fd230app/nativeui/language/Language_xml/language_en.xml b/code/sdk/application/wearable/fd230app/nativeui/language/Language_xml/language_en.xml index 08bd8e479..974a1d2c4 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/language/Language_xml/language_en.xml +++ b/code/sdk/application/wearable/fd230app/nativeui/language/Language_xml/language_en.xml @@ -452,7 +452,7 @@ - + diff --git a/code/sdk/application/wearable/fd230app/nativeui/language/Language_xml/language_zh.xml b/code/sdk/application/wearable/fd230app/nativeui/language/Language_xml/language_zh.xml index 8bb63aa69..6ad434bcc 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/language/Language_xml/language_zh.xml +++ b/code/sdk/application/wearable/fd230app/nativeui/language/Language_xml/language_zh.xml @@ -452,7 +452,7 @@ - + diff --git a/code/sdk/application/wearable/fd230app/nativeui/language/font/en.lang b/code/sdk/application/wearable/fd230app/nativeui/language/font/en.lang index 0cc6eea44aea6e3bd46fe1e537a999ab37b9ebdd..3f74213716b15079a68ae8f020d202b01c2caedb 100644 GIT binary patch delta 113 zcmZqjd+*EQ!awKyMiwphNF7-Q274eb0OCd$pM3y9wWF|RxWgE|oF0I?YmTLZB(5QlDVXV;V6d_u*F2>|1S6y5*; delta 133 zcmaFw+vLa6;=8YZBa0S$q`fQyLl6)*1Mw6f_K{;?2nFIiAg%=BRv=yq#D{_SED+xX z;%7ko7Kj<-85k6R*b0d4f!Gs>{eUL28d4r@g*RB2*mGz_%{%XNHZ{~1F<;} qy8v+r5Jv-X1`yW)aW@c80^<2Vyab5X0P&v9?d(q_H#aN3VgvxCdl<$5 delta 137 zcmccS_STJM$3cF!jVxO1k-sDv7}%v47@UDP7>FML@k=270mQ7*3=Bd*tPR9=K_{55!Y}co7h<1mbN#yc>uQ1M%g}?d(q_#Wf!6ocO3=(V2$FtxX`hQS)ZU NqdChr=P15n1OOQ4COiND diff --git a/code/sdk/application/wearable/fd230app/nativeui/language/languagemake.sh b/code/sdk/application/wearable/fd230app/nativeui/language/languagemake.sh index b2140ff72..1b158ed5f 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/language/languagemake.sh +++ b/code/sdk/application/wearable/fd230app/nativeui/language/languagemake.sh @@ -1,14 +1,14 @@ #!/bin/bash ### # @Date: 2024-07-10 21:03:33 - # @LastEditors: Caisking 3449750381@qq.com - # @LastEditTime: 2024-07-10 21:03:37 + # @LastEditors: luozheng 1732036298@qq.com + # @LastEditTime: 2024-07-23 11:29:39 # @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/language/languagemake.sh ### # 进入目录 Language_xml cd ~/XTS_FD230/FD230/code/sdk/application/wearable/fd230app/nativeui/language/Language_xml - +#cd /home/luozheng/xts_origin/FD230/code/sdk/application/wearable/fd230app/nativeui/language/Language_xml # 运行 languagetool.py python languagetool.py diff --git a/code/sdk/application/wearable/fd230app/nativeui/languagecode/LanguageInit.cpp b/code/sdk/application/wearable/fd230app/nativeui/languagecode/LanguageInit.cpp index 047731c5d..807de8b2c 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/languagecode/LanguageInit.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/languagecode/LanguageInit.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-03-30 09:14:38 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-07-20 18:03:40 + * @LastEditTime: 2024-07-23 17:10:22 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/languagecode/LanguageInit.cpp */ #include @@ -117,11 +117,11 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitLangues"); // 获取json里面的语言 int thelanguage = ConfigModel::GetInstance()->GetLanguage(); - if( thelanguage == -1 ) + if(ConfigModel::GetInstance()->GetisFirstTimeStart() == true) { /** * TODO: - * 如果 thelanguage = -1 证明第一次启动,需要实现弹窗切换语言的功能。 + * 如果 GetisFirstTimeStart()证明第一次启动,需要实现弹窗切换语言的功能。 * 在此之前,先设置成默认0 */ //thelanguage = 0; diff --git a/code/sdk/application/wearable/fd230app/nativeui/main/src/MainPresenterSample.cpp b/code/sdk/application/wearable/fd230app/nativeui/main/src/MainPresenterSample.cpp index 8cb7d95ef..6698e3683 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/main/src/MainPresenterSample.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/main/src/MainPresenterSample.cpp @@ -29,6 +29,7 @@ #include "custom_utils.h" #include "traing/training_card/include/Training_CardView.h" #include "dnotdisturb/include/DnotDisturbModel.h" +#include "weather/include/WeatherModel.h" #if USE_OFFLINE_DIAL #include "DialViewGroup.h" #endif @@ -392,6 +393,11 @@ namespace OHOS } } break; + case WEATHER: + if(WeatherModel::GetInstance().GetWeatherDataIsValid()) { + WeatherModel::GetInstance().UpdateWeatherCurTime(); + } + break; } } diff --git a/code/sdk/application/wearable/fd230app/nativeui/main/src/PullUpDownView.cpp b/code/sdk/application/wearable/fd230app/nativeui/main/src/PullUpDownView.cpp index 2f08ff2e6..c82401102 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/main/src/PullUpDownView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/main/src/PullUpDownView.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-06-26 18:14:24 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-07-16 15:31:46 + * @LastEditTime: 2024-07-23 18:13:38 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/main/src/PullUpDownView.cpp */ @@ -18,6 +18,8 @@ #include "dnotdisturb/include/DnotDisturbModel.h" #include "custom_utils.h" #include "custom_runtime.h" +#include "bluetooth/include/BluetoothModel.h" +#include "phoneservice/include/PhoneService.h" namespace OHOS { @@ -755,7 +757,7 @@ namespace OHOS } else if (cat1_powerOn == 1 && sim == 1) { - if (signal == SIGNAL_NO_SIGNAL) //计算信号强度 + if (signal == SIGNAL_NO_SIGNAL) // 计算信号强度 { // 无信号UI显示 // UpdateCat1NoSignalisplay(true); @@ -780,10 +782,10 @@ namespace OHOS } else { - if (cat1_network_type == NETWORK_TYPE_NO_NETWORK) + if (cat1_network_type == NETWORK_TYPE_NO_NETWORK) { // 无信号,无4G图标 显示 - //UpdateCat1NoSignalisplay(true); + // UpdateCat1NoSignalisplay(true); UpdateCat14GDisplay(false); UpdateCat1MobileDataDisplay(false); // UpdateSignalBarDisplay(CalculateSignalBars(signal), false); @@ -791,7 +793,7 @@ namespace OHOS else if (cat1_network_type == NETWORK_TYPE_4G) { // 有4G图标,正常显示信号 - //UpdateCat1NoSignalisplay(false); + // UpdateCat1NoSignalisplay(false); UpdateCat14GDisplay(true); UpdateCat1MobileDataDisplay(true); // UpdateSignalBarDisplay(CalculateSignalBars(signal), true); @@ -799,7 +801,7 @@ namespace OHOS else { // 无4G图标,正常显示信号 - //UpdateCat1NoSignalisplay(false); + // UpdateCat1NoSignalisplay(false); UpdateCat14GDisplay(false); UpdateCat1MobileDataDisplay(true); // UpdateSignalBarDisplay(CalculateSignalBars(signal), true); @@ -880,7 +882,7 @@ namespace OHOS /*更新移动数据图标显示*/ void PullUpDownView::UpdateCat1MobileDataDisplay(bool state) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PullUpDownView::UpdateCat1MobileDataDisplay %d",state); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PullUpDownView::UpdateCat1MobileDataDisplay %d", state); if (MobileData != nullptr) { MobileData->SetVisible(state); @@ -910,7 +912,12 @@ namespace OHOS { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PullUpDownView::UpdateSignalStrengthStatusAndBatteryPosition"); updateSignalDisplay(); - //UpdateBatteryPosition(GetSignalStrength()); + + int a2dp = uapi_a2dp_snk_get_device_connect_state(); + int hfp = uapi_hfp_connect_state(); + bool bluetoothstatus = (a2dp == 0 || hfp == 0) ? false : true; + UpdateBlueToothStatus(bluetoothstatus); + // UpdateBatteryPosition(GetSignalStrength()); } // 下拉视图初始化 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 02a307348..94efc0bb2 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/settings/src/SettingView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/settings/src/SettingView.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-07-12 09:55:29 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-07-22 11:33:17 + * @LastEditTime: 2024-07-22 18:30:57 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/settings/src/SettingView.cpp */ @@ -84,7 +84,7 @@ namespace OHOS WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingView::OnStart::scrollView is nullptr"); return; } - scrollView->Resize(HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); + scrollView->SetPosition(0, 0, 466, 466); scrollView->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full); scrollView->SetStyle(STYLE_BACKGROUND_OPA, UN_OPACITY); scrollView->SetScrollBlankSize(SETTING_SCROLLBLANKSIZE); @@ -125,12 +125,13 @@ namespace OHOS WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingView::OnStart::contentList is nullptr"); return; } - contentList->SetPosition(SETTING_LIST_POSITION_X, SETTING_LIST_POSITION_Y, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); + contentList->SetPosition(SETTING_LIST_POSITION_X, SETTING_LIST_POSITION_Y, 380, 400); contentList->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); - contentList->SetScrollBlankSize(SETTING_SCROLLBLANKSIZE); - contentList->SetSelectPosition(HORIZONTAL_RESOLUTION / SNUM_2); // middle position + contentList->SetScrollBlankSize(75); + // contentList->SetSelectPosition(820 / SNUM_2); // middle position contentList->SetDraggable(true); contentList->SetThrowDrag(true); + contentList->EnableAutoAlign(true); contentList->SetReboundSize(REBOUNDSIZE); contentList->SetMaxScrollDistance(MAX_SCR_DIS); contentList->RequestFocus(); diff --git a/code/sdk/application/wearable/fd230app/nativeui/weather/include/WeatherModel.h b/code/sdk/application/wearable/fd230app/nativeui/weather/include/WeatherModel.h index 669210b24..2d9205247 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/weather/include/WeatherModel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/weather/include/WeatherModel.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-04-08 18:40:20 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-06-19 10:24:03 + * @LastEditTime: 2024-07-23 14:41:27 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/weather/include/WeatherModel.h */ #ifndef WEATHER_MODEL_H @@ -88,6 +88,7 @@ namespace OHOS static WeatherModel &GetInstance(void); void InitFutureWeatherItem(); void TimestampToMonthDayString(time_t timestamp, char *buffer); + std::string GetWeatherCurTime(); std::string GetWeatherImage(); std::string GetWeatherTemperature(); std::string GetWeatherDescription(); @@ -109,6 +110,7 @@ namespace OHOS void SetWeatherDataIsValid(bool value); /* -------------------------------------------------------------------------- */ void UpdateMainWeatherData(void); + void UpdateWeatherCurTime(void); private: WeatherModel(); WeatherModel(const WeatherModel &) = delete; diff --git a/code/sdk/application/wearable/fd230app/nativeui/weather/include/WeatherView.h b/code/sdk/application/wearable/fd230app/nativeui/weather/include/WeatherView.h index 3c93ddf58..618c91589 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/weather/include/WeatherView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/weather/include/WeatherView.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-03-30 09:14:38 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-06-15 16:31:50 + * @LastEditTime: 2024-07-23 14:51:03 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/weather/include/WeatherView.h */ #ifndef WEATHER_VIEW_H @@ -35,6 +35,7 @@ namespace OHOS virtual bool InitView(void *caller) override; void ClearAll(); bool UpdateWeatherViewData(void); + bool UpdateWeatherTime(void); private: UILabelExt *InitLabelExt(int x, int y, int w, int h, const char *text, int textfont, int lineheight); @@ -45,7 +46,6 @@ namespace OHOS void DumpWeatherInfo(); bool SetImageSource(UIImageView *image, const std::string &source); bool SetTextLabel(UILabel *label, const std::string &text); - bool UpdateWeatherTime(void); bool UpdateWeatherImag(void); bool UpdateWeatherTemperature(void); bool UpdateWeatherWeatherDescription(void); diff --git a/code/sdk/application/wearable/fd230app/nativeui/weather/src/MainWeatherPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/weather/src/MainWeatherPresenter.cpp index daaba8b2c..edeae73b5 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/weather/src/MainWeatherPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/weather/src/MainWeatherPresenter.cpp @@ -101,9 +101,9 @@ namespace OHOS { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainWeatherPresenter::OnSwipe,current tab index = %d", view.GetCurrentPage()); // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "the view index = %d,dragging direction = %d,current tab index = %d", view.GetViewIndex(), view.GetDirection(), view.GetCurrentPage()); - if (view.GetCurrentPage() == WEATHERREPORTVIEW) + if (view.GetCurrentPage() == MAINWEATHERVIEW) { - //MainWeatherView::GetInstance()->GetFutureWeatherView()->GetFutureWeatherList()->RefreshList(); + WeatherModel::GetInstance().UpdateWeatherCurTime(); } } diff --git a/code/sdk/application/wearable/fd230app/nativeui/weather/src/WeatherModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/weather/src/WeatherModel.cpp index 7002393f8..eb23d0194 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/weather/src/WeatherModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/weather/src/WeatherModel.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-04-08 18:40:09 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-06-19 10:24:12 + * @LastEditTime: 2024-07-23 14:54:46 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/weather/src/WeatherModel.cpp */ #include "weather/include/WeatherModel.h" @@ -135,6 +135,22 @@ namespace OHOS sprintf(buffer, "%02d.%02d", timeinfo.tm_mon + 1, timeinfo.tm_mday); } + /*获取天气界面的当前时间*/ + std::string WeatherModel::GetWeatherCurTime() + { + struct tm pTM; + time_t seconds; + time(&seconds); + localtime_r(&seconds, &pTM); + + int hour = pTM.tm_hour; + int minute = pTM.tm_min; + + std::string weatherTime = (hour < 10 ? "0" : "") + std::to_string(hour) + ":" + (minute < 10 ? "0" : "") + std::to_string(minute); + + return weatherTime; + } + // 获取天气图片 std::string WeatherModel::GetWeatherImage() { @@ -267,7 +283,7 @@ namespace OHOS /* 更新所有天气数据 */ void WeatherModel::UpdateMainWeatherData(void) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "UpdateMainWeatherData"); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "UpdateMainWeatherData"); MainWeatherView *p_MainWeatherView = MainWeatherView::GetInstance(); if (p_MainWeatherView != nullptr) @@ -287,4 +303,15 @@ namespace OHOS p_WeatherControlView->UpdateWeatherControlViewVisibility(); } } + + /*更新天气界面的时间显示*/ + void WeatherModel::UpdateWeatherCurTime(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "UpdateWeatherCurTime"); + MainWeatherView *p_MainWeatherView = MainWeatherView::GetInstance(); + if (p_MainWeatherView != nullptr) + { + p_MainWeatherView->GetWeatherView()->UpdateWeatherTime(); + } + } } \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/weather/src/WeatherView.cpp b/code/sdk/application/wearable/fd230app/nativeui/weather/src/WeatherView.cpp index 7e79b1afb..d4c105770 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/weather/src/WeatherView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/weather/src/WeatherView.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-06-12 11:44:04 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-06-19 10:51:02 + * @LastEditTime: 2024-07-23 14:44:07 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/weather/src/WeatherView.cpp */ #include "weather/include/WeatherView.h" @@ -87,6 +87,7 @@ namespace OHOS SetViewIndex(0); // 视图索引 WeatherModel *p_WeatherModel = &WeatherModel::GetInstance(); + WeatherTime = p_WeatherModel->GetWeatherCurTime(); WeatherImag = p_WeatherModel->GetWeatherImage(); Temperature = p_WeatherModel->GetWeatherTemperature(); WeatherDescription = p_WeatherModel->GetWeatherDescription(); @@ -200,7 +201,7 @@ namespace OHOS showWeatherImage->SetResizeMode(UIImageView::CONTAIN); showWeatherImage->SetSrc(WeatherImag.c_str()); /* -------------------------------------------------------------------------- */ - showCurrentTimeLabel = InitLabelExt(CURRENT_TIME_LABEL_X, CURRENT_TIME_LABEL_Y, CURRENT_TIME_LABEL_W, CURRENT_TIME_LABEL_H, "", + showCurrentTimeLabel = InitLabelExt(CURRENT_TIME_LABEL_X, CURRENT_TIME_LABEL_Y, CURRENT_TIME_LABEL_W, CURRENT_TIME_LABEL_H, WeatherTime.c_str(), CURRENT_TIME_LABEL_TEXT_FONT, CURRENT_TIME_LABEL_LINE_HEIGHT); if (showCurrentTimeLabel == nullptr) { @@ -362,15 +363,7 @@ namespace OHOS { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "WeatherView::UpdateWeatherTime"); - struct tm pTM; - time_t seconds; - time(&seconds); - localtime_r(&seconds, &pTM); - - int hour = pTM.tm_hour; - int minute = pTM.tm_min; - - std::string weatherTime = (hour < 10 ? "0" : "") + std::to_string(hour) + ":" + (minute < 10 ? "0" : "") + std::to_string(minute); + std::string weatherTime = WeatherModel::GetInstance().GetWeatherCurTime(); return SetTextLabel(showCurrentTimeLabel, weatherTime); } diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/MainCard/CompassCard.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/MainCard/CompassCard.bin index 75283ca35..25c79b289 100644 --- a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/MainCard/CompassCard.bin +++ b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/MainCard/CompassCard.bin @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:415ed08d7a18c8ae54261cccab21f908cba231c8a64954d9703f02273277f36b +oid sha256:bdb3fef91dd660c63d6c0a52e4bc34fbd20b5f5a3ce77fa5b8d24066a4bd562c size 52664 diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/font/en.lang b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/font/en.lang index 0cc6eea44aea6e3bd46fe1e537a999ab37b9ebdd..3f74213716b15079a68ae8f020d202b01c2caedb 100644 GIT binary patch delta 113 zcmZqjd+*EQ!awKyMiwphNF7-Q274eb0OCd$pM3y9wWF|RxWgE|oF0I?YmTLZB(5QlDVXV;V6d_u*F2>|1S6y5*; delta 133 zcmaFw+vLa6;=8YZBa0S$q`fQyLl6)*1Mw6f_K{;?2nFIiAg%=BRv=yq#D{_SED+xX z;%7ko7Kj<-85k6R*b0d4f!Gs>{eUL28d4r@g*RB2*mGz_%{%XNHZ{~1F<;} qy8v+r5Jv-X1`yW)aW@c80^<2Vyab5X0P&v9?d(q_H#aN3VgvxCdl<$5 delta 137 zcmccS_STJM$3cF!jVxO1k-sDv7}%v47@UDP7>FML@k=270mQ7*3=Bd*tPR9=K_{55!Y}co7h<1mbN#yc>uQ1M%g}?d(q_#Wf!6ocO3=(V2$FtxX`hQS)ZU NqdChr=P15n1OOQ4COiND -- 2.17.1