From: 罗正 <1732036298@qq.com> Date: Sat, 21 Sep 2024 04:44:04 +0000 (+0000) Subject: Merge #992 into sdk602patch0626 from refs/changes/992/head X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=d2d7d050117ea4032baa840c7289f0f69c90098c;p=mirrors%2FFD230.git Merge #992 into sdk602patch0626 from refs/changes/992/head Code review from 罗正 * refs/changes/992/head: (27 commits squashed) - #524,解决:录音删除,删除后不是返回到录音列表界面,返回的是录音界面bug #658,解决,手表,录音频繁点击会有蓝色效果 - #656,解决,手表,闹钟偶现0000闹钟提醒bug - Merge branch 'sdk602patch0626' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0626 - 4G界面添加“注:启用4G,可能会加速消耗电量”提醒 - 运动识别界面添加提醒标签,#192,解决,运动识别界面单一bug - Merge branch 'sdk602patch0626' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0626 - 根据禅道上期望:APP查找手表和闹钟,勿扰睡眠静音模式下都有响铃和震动提醒 #421解决, 睡眠模式,闹钟无响铃震动bug - 解决静音模式错误开启后会全局静音bug,根据禅道期望“来电铃声、短信消息提醒,勿扰睡眠静音模式下只有亮屏提醒” - #717,解决,设置界面向上滑有黑色空白,需优化bug - Merge branch 'sdk602patch0626' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0626 - Merge branch 'sdk602patch0626' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0626 - #716,解决,设置屏幕与亮度界面右滑返回上一级界面,有上下晃动,优化退出晃动bug - #720,解决,手表默认通话音量过小,手表是恢复出厂设置后查看的bug - 修复msg_senter关于喝水提醒被覆盖代码 - 1.添加APP在调节系统音量时候若当前界面在音乐的的声音调节视图则ui同步显示设置的音量值。 2.解决音乐从本地音乐切换到手机音乐在切换到本地音乐切换不回来bug - Merge branch 'sdk602patch0626' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0626 - 解决#748,关于手表界面,编码器旋转不起作用bug - 关机,恢复出厂增加震动效果,开机的震动还未加,震动强度会受设置中影响 - #176,解决,4G能力开关名称修改成4G网络,界面单一bug - 1.解决语言界面内存泄漏问题 2.解决.#741语言选择界面上滑时底部会有黑边,使用编码器时无此情况bug 3.解决系统界面的内存泄漏问题,并使用一个辅助组件解决系统视图最后一个按钮被则挡住bug - Merge branch 'sdk602patch0626' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0626 - Merge branch 'sdk602patch0626' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0626 - Merge branch 'sdk602patch0626' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0626 - Merge branch 'sdk602patch0626' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0626 - #747,解决声音与震动,显示方式,系统界面 下拉后无法恢复到原位置,有向下偏移bug - 解决设置视图右滑难退出问题 - #575,解决,Al 安卓 文心一言 手表端不输出结果,手机输出结果bug,原因为文件路径不存在问题 Signed-off-by: 罗正 <1732036298@qq.com> Reviewed-by: snickersun@163.com Merged-by: snickersun@163.com CR-link: https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230/change/992 --- diff --git a/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoiceModel.h b/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoiceModel.h index ded12eb54..d5110ac2f 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoiceModel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoiceModel.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-06-20 15:14:43 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-09-07 11:14:50 + * @LastEditTime: 2024-09-21 11:07:14 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoiceModel.h */ #ifndef AI_VOICE_MODEL_H @@ -102,6 +102,8 @@ namespace OHOS int GetSelectAiModel(void); int GetAiModelTextId(void); + bool CreateDirectory(const char* path); + private: AiVoiceModel(); ~AiVoiceModel(); diff --git a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceModel.cpp index cd0f1fd1d..d2ce77f7c 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceModel.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-06-20 15:14:50 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-09-07 17:08:17 + * @LastEditTime: 2024-09-21 11:13:21 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceModel.cpp */ #include "aivoice/include/AiVoiceModel.h" @@ -24,6 +24,8 @@ #include #include "ConfigModel.h" #include "settings/include/SettingModel.h" +#include +#include namespace OHOS { // 声明定时器变量 @@ -32,7 +34,10 @@ namespace OHOS static int Time = THIRTY_TIME; static int AiModelConnectTimeout = 5; - AiVoiceModel::AiVoiceModel() {} + AiVoiceModel::AiVoiceModel() + { + CreateDirectory("/user/userdata/AiRecording/"); + } AiVoiceModel::~AiVoiceModel() {} @@ -42,6 +47,20 @@ namespace OHOS return instance; } + bool AiVoiceModel::CreateDirectory(const char* path) + { + if (access(path, F_OK) == -1) { // 如果路径不存在 + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Directory %s not exist, creating directory\n", path); + if (mkdir(path, 0777)!= 0) { // 尝试创建目录,如果创建失败 + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Create directory %s failed\n", path); + return false; + } + } else { // 如果路径存在 + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Directory %s already exists\n", path); + } + return true; + } + // 跳转到返回结果界面 bool AiVoiceModel::ChangeToReturnResultTextView(void) { diff --git a/code/sdk/application/wearable/fd230app/nativeui/languagecode/src/LanguageSwitchListitemView.cpp b/code/sdk/application/wearable/fd230app/nativeui/languagecode/src/LanguageSwitchListitemView.cpp index 1a584fd12..5f63bca0f 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/languagecode/src/LanguageSwitchListitemView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/languagecode/src/LanguageSwitchListitemView.cpp @@ -1,8 +1,8 @@ /* * @Author: luozheng 1732036298@qq.com * @Date: 2024-03-28 14:28:03 - * @LastEditors: SnickerSun snickersun@163.com - * @LastEditTime: 2024-08-30 20:49:17 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-09-19 16:35:47 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/languagecode/src/LanguageSwitchListitemView.cpp */ #include "languagecode/include/LanguageSwitchListitemView.h" @@ -28,6 +28,7 @@ namespace OHOS { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "LanguageSwitchListitemView::~LanguageSwitchListitemView"); Remove(&m_LabelButtonExt); + Remove(&languae_Image); } void LanguageSwitchListitemView::SetItemInfo(const Language itemInfo) diff --git a/code/sdk/application/wearable/fd230app/nativeui/languagecode/src/LanguageSwitchView.cpp b/code/sdk/application/wearable/fd230app/nativeui/languagecode/src/LanguageSwitchView.cpp index 58e906b68..de74878b7 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/languagecode/src/LanguageSwitchView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/languagecode/src/LanguageSwitchView.cpp @@ -19,8 +19,8 @@ namespace OHOS static constexpr int16_t MAX_SCROLL_DIS = 1000; static constexpr int16_t MAX_REBOUND_SIZE = 40; static constexpr int16_t MAX_LANGUAGE_LIST_SCROLLBLANKSIZE = 50; - static constexpr int16_t ROTATEFACTORVALUE = 4; - + static constexpr int16_t ROTATEFACTORVALUE = 1.0; + static LanguageSwitchView *g_pLanguageSwitchView{nullptr}; LanguageSwitchView::LanguageSwitchView() { @@ -59,35 +59,56 @@ namespace OHOS void LanguageSwitchView::ClearAll(void) { - if (LanguageSwitchScrollView != nullptr) + if (container_ != nullptr) { - LanguageSwitchScrollView->RemoveAll(); - - delete LanguageSwitchViewTitleLabel; - LanguageSwitchViewTitleLabel = nullptr; - - delete p_LanguageSwitchListAdapter; - p_LanguageSwitchListAdapter = nullptr; - - delete LanguageList; - LanguageList = nullptr; - - delete LanguageSwitchScrollView; - LanguageSwitchScrollView = nullptr; - - if(group) + container_->RemoveAll(); + if (LanguageSwitchScrollView != nullptr) + { + LanguageSwitchScrollView->RemoveAll(); + if (LanguageSwitchViewTitleLabel) + { + delete LanguageSwitchViewTitleLabel; + LanguageSwitchViewTitleLabel = nullptr; + } + if (p_LanguageSwitchListAdapter) + { + delete p_LanguageSwitchListAdapter; + p_LanguageSwitchListAdapter = nullptr; + } + if (LanguageList) + { + delete LanguageList; + LanguageList = nullptr; + } + delete LanguageSwitchScrollView; + LanguageSwitchScrollView = nullptr; + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "LanguageSwitchView::ClearAll LanguageSwitchScrollView over!!"); + } + if (group != nullptr) { group->RemoveAll(); - - delete button_cancel; - button_cancel = nullptr; - - delete button_ensure; - button_ensure = nullptr; - - delete LanguageSwitchViewhintLabel; - LanguageSwitchViewhintLabel = nullptr; + if (button_cancel) + { + delete button_cancel; + button_cancel = nullptr; + } + if (button_ensure) + { + delete button_ensure; + button_ensure = nullptr; + } + if (LanguageSwitchViewhintLabel) + { + delete LanguageSwitchViewhintLabel; + LanguageSwitchViewhintLabel = nullptr; + } + delete group; + group = nullptr; + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "LanguageSwitchView::ClearAll group over!!"); } + delete container_; + container_ = nullptr; + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "LanguageSwitchView::ClearAll over!!"); } } @@ -101,7 +122,7 @@ namespace OHOS return false; } LanguageSwitchScrollView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); - LanguageSwitchScrollView->SetScrollBlankSize(MAX_LANGUAGE_LIST_SCROLLBLANKSIZE); + // LanguageSwitchScrollView->SetScrollBlankSize(MAX_LANGUAGE_LIST_SCROLLBLANKSIZE); LanguageSwitchScrollView->SetHorizontalScrollState(false); LanguageSwitchScrollView->SetTouchable(true); LanguageSwitchScrollView->SetDraggable(true); @@ -149,15 +170,18 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "LanguageSwitchView::LanguageList is nullptr!"); return false; } - LanguageList->SetPosition(LANGUAGE_LIST_X, LANGUAGE_LIST_Y, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); + LanguageList->SetPosition(LANGUAGE_LIST_X, LANGUAGE_LIST_Y, HORIZONTAL_RESOLUTION, 346); LanguageList->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); - LanguageList->SetScrollBlankSize(MAX_LANGUAGE_LIST_SCROLLBLANKSIZE); - LanguageList->EnableAutoAlign(true); // 设置此列表的自动对齐状态。当滚动停止时,子视图被选中,其位置自动与预设位置对齐 - LanguageList->SetThrowDrag(true); // 设置手指抬起屏幕后是否继续滚动。 - LanguageList->SetMaxScrollDistance(MAX_SCROLL_DIS); // 设置手指抬起屏幕后的最大滚动距离。 - LanguageList->SetReboundSize(MAX_REBOUND_SIZE); - LanguageList->SetRotateFactor(ROTATEFACTORVALUE); + LanguageList->EnableAutoAlign(true); // 设置此列表的自动对齐状态。当滚动停止时,子视图被选中,其位置自动与预设位置对齐 + LanguageList->SetThrowDrag(true); // 设置手指抬起屏幕后是否继续滚动。 + LanguageList->SetMaxScrollDistance(1000); // 设置手指抬起屏幕后的最大滚动距离。 + LanguageList->SetSwipeACCLevel(800); /*设置手指抬起屏幕后的补偿距离。*/ + LanguageList->SetReboundSize(30); + LanguageList->SetScrollBlankSize(20); + LanguageList->SetStartIndex(0); FocusManager::GetInstance()->RequestFocus(LanguageList); + FocusManager::GetInstance()->RequestFocusByDirection(FOCUS_DIRECTION_UP); + LanguageList->SetRotateFactor(1.0); return true; } @@ -171,13 +195,13 @@ namespace OHOS } } - void LanguageSwitchView::show_hint_group(std::string code,bool data) + void LanguageSwitchView::show_hint_group(std::string code, bool data) { group->SetVisible(data); RootView::GetInstance()->Invalidate(); - if(data) + if (data) { - hint_id_code=code; + hint_id_code = code; } return; } @@ -187,18 +211,16 @@ namespace OHOS return button_cancel; } - UIButton *LanguageSwitchView::GetLanguagebutton_ensure(void) { return button_ensure; } - //Take effect after restart + // Take effect after restart void LanguageSwitchView::InithintView() { - group = new UIViewGroup(); - if(group==nullptr) + if (group == nullptr) { return; } @@ -207,13 +229,13 @@ namespace OHOS group->SetDraggable(true); group->SetOnDragListener(presenter_); - - if (LanguageSwitchViewhintLabel == nullptr) { - LanguageSwitchViewhintLabel = new UILabel(); + if (LanguageSwitchViewhintLabel == nullptr) + { + LanguageSwitchViewhintLabel = new UILabel(); } - LanguageSwitchViewhintLabel->SetPosition(47, 194); // widget's left position and top position - LanguageSwitchViewhintLabel->Resize(370, 60); // widget's width and height - LanguageSwitchViewhintLabel->SetViewId("label1");// Set style + LanguageSwitchViewhintLabel->SetPosition(47, 194); // widget's left position and top position + LanguageSwitchViewhintLabel->Resize(370, 60); // widget's width and height + LanguageSwitchViewhintLabel->SetViewId("label1"); // Set style LanguageSwitchViewhintLabel->SetStyle(STYLE_TEXT_FONT, 30); LanguageSwitchViewhintLabel->SetText("Take effect after restart"); @@ -225,13 +247,11 @@ namespace OHOS group->Add(LanguageSwitchViewhintLabel); LanguageSwitchViewhintLabel->SetVisible(true); - - button_cancel = new UIButton(); if (button_cancel == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemShutdown::new button_cancel fail!"); - return ; + return; } button_cancel->SetPosition(97, 299, 130, 130); button_cancel->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); @@ -247,7 +267,7 @@ namespace OHOS if (button_ensure == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemShutdown::new button_ensure fail!"); - return ; + return; } button_ensure->SetPosition(240, 299, 130, 130); button_ensure->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); @@ -262,15 +282,18 @@ namespace OHOS button_cancel->SetOnClickListener(presenter_); button_ensure->SetOnClickListener(presenter_); group->SetVisible(false); - } - void LanguageSwitchView::OnStart() { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "LanguageSwitchView::OnStart"); View::OnStart(); SetContainerView(new UIViewGroup()); + if (GetContainer() == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SetContainerView fail!!"); + return; + } container_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); container_->SetTouchable(true); container_->SetDraggable(true); @@ -303,12 +326,6 @@ namespace OHOS { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "LanguageSwitchView::OnStop"); View::OnStop(); - if (container_ != nullptr) - { - container_->RemoveAll(); - delete container_; - container_ = nullptr; - } RootView::GetInstance()->ClearOnKeyActListener(); FocusManager::GetInstance()->ClearFocus(); ClearAll(); diff --git a/code/sdk/application/wearable/fd230app/nativeui/networkandcall/src/NetworkAndCallView.cpp b/code/sdk/application/wearable/fd230app/nativeui/networkandcall/src/NetworkAndCallView.cpp index 9b2ac3a69..aa54db719 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/networkandcall/src/NetworkAndCallView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/networkandcall/src/NetworkAndCallView.cpp @@ -195,7 +195,7 @@ namespace OHOS } note->SetStyle(STYLE_TEXT_FONT, 26); note->SetStyle(STYLE_LINE_HEIGHT, 40); - note->SetText("注:启用4G,可能会加速消耗电量"); + note->SetText("开启此功能后,手表可以4G SIM卡拨打电话,耗电会增加。"); note->SetTextColor(Color::GetColorFromRGBA(0x99, 0x99, 0x99, 0xff)); note->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); note->SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_CENTER); diff --git a/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/RebootAndShutdownPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/RebootAndShutdownPresenter.cpp index d1263a9af..90d00fad0 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/RebootAndShutdownPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/RebootAndShutdownPresenter.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-06-20 15:11:17 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-08-29 17:39:15 + * @LastEditTime: 2024-09-19 14:21:00 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/RebootAndShutdownPresenter.cpp */ #include "AppViewIDs.h" @@ -14,6 +14,7 @@ #include "rebootandshutdown/include/RebootAndShutdownView.h" #include "rebootandshutdown/include/RebootAndShutdownModel.h" #include "dial_sos_c.h" +#include "vibrator_service.h" namespace OHOS { @@ -81,6 +82,7 @@ namespace OHOS } else if (strcmp(view.GetViewId(), FACTORY_RESET_BUTTON_CHECK_ON) == 0) // 恢复出厂设置确认 { + ui_api_vibrate_once_func(); //恢复出厂增加震动 do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_TYPE_RESTORE_FACTORY_SETTING, NULL, 0); return true; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/ShutDownImageAnimatorView.cpp b/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/ShutDownImageAnimatorView.cpp index 0baff6ab1..60db0d238 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/ShutDownImageAnimatorView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/ShutDownImageAnimatorView.cpp @@ -9,6 +9,7 @@ #include "wearable_log.h" #include #include "uicomponents/UIComponents.h" +#include "vibrator_service.h" namespace OHOS { @@ -71,6 +72,9 @@ namespace OHOS shutDownImageAnimatorView->Start(); isShutDownImageAnimatorStart = true; ScreenAlwaysOnCtr(OPEN_SCREEN_ALWAYS_ON);//关机动画已经开始了不能息屏 + + //关机增加震动 + ui_api_vibrate_once_func(); } // 获取开机动画是否已经开始 diff --git a/code/sdk/application/wearable/fd230app/nativeui/settings/src/SettingItemView.cpp b/code/sdk/application/wearable/fd230app/nativeui/settings/src/SettingItemView.cpp index 06680a958..698c286f3 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/settings/src/SettingItemView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/settings/src/SettingItemView.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-03-27 19:48:49 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-09-18 10:12:06 + * @LastEditTime: 2024-09-20 15:44:27 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/settings/src/SettingItemView.cpp */ @@ -33,7 +33,7 @@ namespace OHOS SettingItemView::SettingItemView() { - SetPosition(0, 120, 380, 120); + SetPosition(43, 120, 380, 120); SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full); SetStyle(STYLE_BACKGROUND_OPA, UN_OPACITY); SetTouchable(true); 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 e6a2827b9..9bd7ca5fb 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-09-18 10:49:14 + * @LastEditTime: 2024-09-20 20:42:55 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/settings/src/SettingView.cpp */ @@ -87,7 +87,6 @@ namespace OHOS 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); scrollView->SetHorizontalScrollState(false); scrollView->SetTouchable(true); scrollView->SetThrowDrag(true); @@ -125,16 +124,16 @@ namespace OHOS WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingView::OnStart::contentList is nullptr"); return; } - contentList->SetPosition(SETTING_LIST_POSITION_X, SETTING_LIST_POSITION_Y, 380, 360); + contentList->SetPosition(SETTING_LIST_POSITION_X, SETTING_LIST_POSITION_Y, HORIZONTAL_RESOLUTION, 346); contentList->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); + contentList->EnableAutoAlign(true); // 设置此列表的自动对齐状态。当滚动停止时,子视图被选中,其位置自动与预设位置对齐 + contentList->SetThrowDrag(true); // 设置手指抬起屏幕后是否继续滚动。 + contentList->SetMaxScrollDistance(1000); // 设置手指抬起屏幕后的最大滚动距离。 + contentList->SetSwipeACCLevel(800); /*设置手指抬起屏幕后的补偿距离。*/ + contentList->SetReboundSize(30); contentList->SetScrollBlankSize(30); - contentList->SetDraggable(true); - contentList->SetThrowDrag(true); - contentList->EnableAutoAlign(true); - contentList->SetReboundSize(REBOUNDSIZE); - contentList->SetMaxScrollDistance(MAX_SCR_DIS); - contentList->SetSwipeACCLevel(800); /*设置手指抬起屏幕后的补偿距离。*/ - contentList->RequestFocus(); + FocusManager::GetInstance()->RequestFocus(contentList); + FocusManager::GetInstance()->RequestFocusByDirection(FOCUS_DIRECTION_UP); contentList->SetRotateFactor(1.0); /* ----------------------------------- Add ---------------------------------- */ scrollView->Add(title); diff --git a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationView.h b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationView.h index 44ec1d184..b46b0683f 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationView.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-04-19 21:03:26 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-07-24 17:33:52 + * @LastEditTime: 2024-09-20 15:01:12 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/include/SoundAndVibrationView.h */ #ifndef SOUND_AND_VIBRATION_VIEW_H @@ -98,6 +98,7 @@ namespace OHOS UILabelExt *SilentModeLabel{nullptr}; // 静音模式标签 UIToggleButton *SilentModeToggleButton{nullptr}; // 静音模式切换按钮 bool initViewStatus{false}; + UIImageView *temp{nullptr}; }; } // namespace OHOS diff --git a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationView.cpp b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationView.cpp index 54c3c6dda..1b8aca042 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationView.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-02-19 10:39:14 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-07-24 17:48:13 + * @LastEditTime: 2024-09-20 15:12:30 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationView.cpp */ #include "soundandvibration/include/SoundAndVibrationView.h" @@ -92,6 +92,9 @@ namespace OHOS delete SilentModeLabel; SilentModeLabel = nullptr; + delete temp; + temp = nullptr; + delete SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]; SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW] = nullptr; } @@ -117,15 +120,17 @@ namespace OHOS } SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]->SetStyle(STYLE_BACKGROUND_OPA, 0xff); - SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]->SetScrollBlankSize(75); - SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]->SetReboundSize(35); - SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]->SetDirection(1); - SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]->SetMaxScrollDistance(1000); SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]->SetThrowDrag(true); SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]->SetTouchable(true); SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]->SetDraggable(true); - SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]->RequestFocus(); - SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]->SetRotateFactor(2.0); + SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]->SetScrollBlankSize(30); + SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]->SetReboundSize(30); + SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]->SetDirection(1); + SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]->SetMaxScrollDistance(1000); // 设置手指抬起屏幕后的最大滚动距离。 + SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]->SetSwipeACCLevel(800); /*设置手指抬起屏幕后的补偿距离。*/ + FocusManager::GetInstance()->RequestFocus(SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]); + FocusManager::GetInstance()->RequestFocusByDirection(FOCUS_DIRECTION_UP); + SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]->SetRotateFactor(1.0); container_->Add(SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]); return true; @@ -306,6 +311,19 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::CreateSoundAndVibrationView fail!!"); return; } + /* ------------------- 该组件的使用是为了解决不能单独设置滚动视图底部空白大小问题,用一个不可见组件占位置 ------------------ */ + /* ---------------------------- 因为使用SetScrollBlankSize设置大小后下拉后无法恢复到原位置,有向下偏移 --------------------------- */ + if (temp == nullptr) + { + temp = new UIImageView(); + if (temp == nullptr) + { + return; + } + temp->SetPosition(43, 480 + 120, 380, 40); + temp->SetVisible(false); + SoundAndVibrationScrollView[SOUNDANDVIBRATIONVIEW]->Add(temp); + } initViewStatus = true; } @@ -350,6 +368,7 @@ namespace OHOS WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::OnStop"); View::OnStop(); RootView::GetInstance()->ClearOnKeyActListener(); + FocusManager::GetInstance()->ClearFocus(); ClearAll(); return; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/system/include/SystemView.h b/code/sdk/application/wearable/fd230app/nativeui/system/include/SystemView.h index 14afb967d..16239faee 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/system/include/SystemView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/system/include/SystemView.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-03-30 18:29:39 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-08-28 19:43:28 + * @LastEditTime: 2024-09-19 20:07:09 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/system/include/SystemView.h */ #ifndef SYSTEM_VIEW_H @@ -111,9 +111,10 @@ namespace OHOS void NeedToUpdateImageinit(void); UILabelExt *Title{nullptr}; // 标题 UIScrollView *SystemScrollView[MAX_SYSTEMVIEWID]{nullptr}; - UILabelButtonExt *SystemViewLabelButton[5]{nullptr}; - UILabelExt *SystemViewLabel[5]{nullptr}; + UILabelButtonExt *SystemViewLabelButton[7]{nullptr}; + UILabelExt *SystemViewLabel[7]{nullptr}; UIImageView *NeedToUpdateImage{nullptr}; // 提示需要系统更新的icon图片 + UIImageView *temp{nullptr}; bool viewInitStatus{false}; }; } // namespace OHOS diff --git a/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemAboutTheWatchView.cpp b/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemAboutTheWatchView.cpp index e6fd4359f..9f8691a0e 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemAboutTheWatchView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemAboutTheWatchView.cpp @@ -29,22 +29,22 @@ namespace OHOS { - static constexpr uint16_t SYSTEM_ABOUT_THEWATCH_TITLE_X = 93; - static constexpr uint16_t SYSTEM_ABOUT_THEWATCH_TITLE_Y = 52; - static constexpr uint16_t SYSTEM_ABOUT_THEWATCH_TITLE_W = 280; - static constexpr uint16_t SYSTEM_ABOUT_THEWATCH_TITLE_H = 40; + static constexpr uint16_t SYSTEM_ABOUT_THEWATCH_TITLE_X = 83; + static constexpr uint16_t SYSTEM_ABOUT_THEWATCH_TITLE_Y = 50; + static constexpr uint16_t SYSTEM_ABOUT_THEWATCH_TITLE_W = 300; + static constexpr uint16_t SYSTEM_ABOUT_THEWATCH_TITLE_H = 35; static constexpr uint16_t SYSTEM_ABOUT_THEWATCH_TITLE_FONTSIZE = 30; static constexpr uint16_t SYSTEM_ABOUT_THEWATCH_TITLE_LINEHEIGHT = 35; static constexpr uint16_t TITLE_LABEL_X = 53; static constexpr uint16_t TITLE_LABEL_W = 360; - static constexpr uint16_t TITLE_LABEL_H = 40; + static constexpr uint16_t TITLE_LABEL_H = 35; static constexpr uint16_t TITLE_LABEL_FONTSIZE = 30; static constexpr uint16_t TITLE_LABEL_LINEHEIGHT = 35; static constexpr uint16_t LABEL_X = 33; static constexpr uint16_t LABEL_W = 400; - static constexpr uint16_t LABEL_H = 40; + static constexpr uint16_t LABEL_H = 35; static constexpr uint16_t LABEL_FONTSIZE = 30; static constexpr uint16_t LABEL_LINEHEIGHT = 35; @@ -127,6 +127,7 @@ namespace OHOS delete CyweeVersion; CyweeVersion = nullptr; + FocusManager::GetInstance()->ClearFocus(); delete SystemAboutTheWatchScrollView; SystemAboutTheWatchScrollView = nullptr; } @@ -178,9 +179,15 @@ namespace OHOS SystemAboutTheWatchScrollView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); SystemAboutTheWatchScrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff); SystemAboutTheWatchScrollView->SetStyle(STYLE_BORDER_RADIUS, 1294); - SystemAboutTheWatchScrollView->SetScrollBlankSize(TITLE_LABEL_LINEHEIGHT); - SystemAboutTheWatchScrollView->SetReboundSize(50); + SystemAboutTheWatchScrollView->SetScrollBlankSize(30); + SystemAboutTheWatchScrollView->SetReboundSize(30); SystemAboutTheWatchScrollView->SetDirection(1); + SystemAboutTheWatchScrollView->SetThrowDrag(true); + SystemAboutTheWatchScrollView->SetMaxScrollDistance(1000); + SystemAboutTheWatchScrollView->SetSwipeACCLevel(800); /*设置手指抬起屏幕后的补偿距离。*/ + FocusManager::GetInstance()->RequestFocus(SystemAboutTheWatchScrollView); + FocusManager::GetInstance()->RequestFocusByDirection(FOCUS_DIRECTION_UP); + SystemAboutTheWatchScrollView->SetRotateFactor(1.0); UIView::OnDragListener *draglistener = static_cast(SystemPresenter::GetInstance()); if (draglistener == nullptr) { @@ -214,7 +221,7 @@ namespace OHOS .lineHeigh = SYSTEM_ABOUT_THEWATCH_TITLE_LINEHEIGHT, .text = "关于手表", .textId = STR_ABOUT_WATCH, - .lineBreakMode = UILabel::LINE_BREAK_MARQUEE, + .lineBreakMode = UILabel::LINE_BREAK_OSCILLATION, }; SystemAboutTheWatchTitle = InitLabel_Ext(Config); if (SystemAboutTheWatchTitle == nullptr) @@ -233,7 +240,7 @@ namespace OHOS .lineHeigh = TITLE_LABEL_LINEHEIGHT, .text = "手表名称", .textId = STR_WATCH_NAME, - .lineBreakMode = UILabel::LINE_BREAK_MARQUEE, + .lineBreakMode = UILabel::LINE_BREAK_OSCILLATION, }; WatchNameTitle = InitLabel_Ext(Config); if (WatchNameTitle == nullptr) @@ -275,7 +282,7 @@ namespace OHOS .lineHeigh = TITLE_LABEL_LINEHEIGHT, .text = "固件版本", .textId = STR_FIRMWARE_VERSION, - .lineBreakMode = UILabel::LINE_BREAK_MARQUEE, + .lineBreakMode = UILabel::LINE_BREAK_OSCILLATION, }; FirmwareVersionTitle = InitLabel_Ext(Config); if (FirmwareVersionTitle == nullptr) @@ -320,7 +327,7 @@ namespace OHOS .lineHeigh = TITLE_LABEL_LINEHEIGHT, .text = "蓝牙名称", .textId = STR_BLUETOOTH_NAME, - .lineBreakMode = UILabel::LINE_BREAK_MARQUEE, + .lineBreakMode = UILabel::LINE_BREAK_OSCILLATION, }; BluetoothNameTitle = InitLabel_Ext(Config); if (BluetoothNameTitle == nullptr) @@ -363,7 +370,7 @@ namespace OHOS .lineHeigh = TITLE_LABEL_LINEHEIGHT, .text = "蓝牙地址", .textId = STR_BLUETOOTH_ADDRESS, - .lineBreakMode = UILabel::LINE_BREAK_MARQUEE, + .lineBreakMode = UILabel::LINE_BREAK_OSCILLATION, }; BluetoothAddressTitle = InitLabel_Ext(Config); if (BluetoothAddressTitle == nullptr) @@ -407,7 +414,7 @@ namespace OHOS .fontSize = TITLE_LABEL_FONTSIZE, .lineHeigh = TITLE_LABEL_LINEHEIGHT, .text = "4G Modem", - .lineBreakMode = UILabel::LINE_BREAK_MARQUEE, + .lineBreakMode = UILabel::LINE_BREAK_OSCILLATION, }; Network4GTitle = InitLabel(Config); if (Network4GTitle == nullptr) @@ -444,7 +451,7 @@ namespace OHOS .fontSize = TITLE_LABEL_FONTSIZE, .lineHeigh = TITLE_LABEL_LINEHEIGHT, .text = "pyVer", - .lineBreakMode = UILabel::LINE_BREAK_MARQUEE, + .lineBreakMode = UILabel::LINE_BREAK_OSCILLATION, }; PyVerTitle = InitLabel(Config); if (PyVerTitle == nullptr) @@ -481,7 +488,7 @@ namespace OHOS .fontSize = TITLE_LABEL_FONTSIZE, .lineHeigh = TITLE_LABEL_LINEHEIGHT, .text = "IMEI", - .lineBreakMode = UILabel::LINE_BREAK_MARQUEE, + .lineBreakMode = UILabel::LINE_BREAK_OSCILLATION, }; IMELTitle = InitLabel(Config); if (IMELTitle == nullptr) @@ -518,7 +525,7 @@ namespace OHOS .fontSize = TITLE_LABEL_FONTSIZE, .lineHeigh = TITLE_LABEL_LINEHEIGHT, .text = "OS Version", - .lineBreakMode = UILabel::LINE_BREAK_MARQUEE, + .lineBreakMode = UILabel::LINE_BREAK_OSCILLATION, }; FONTTitle = InitLabel(Config); if (FONTTitle == nullptr) @@ -555,7 +562,7 @@ namespace OHOS .fontSize = TITLE_LABEL_FONTSIZE, .lineHeigh = TITLE_LABEL_LINEHEIGHT, .text = "HW Version", - .lineBreakMode = UILabel::LINE_BREAK_MARQUEE, + .lineBreakMode = UILabel::LINE_BREAK_OSCILLATION, }; HWVERTitle = InitLabel(Config); if (HWVERTitle == nullptr) @@ -592,7 +599,7 @@ namespace OHOS .fontSize = TITLE_LABEL_FONTSIZE, .lineHeigh = TITLE_LABEL_LINEHEIGHT, .text = "Cywee Version", - .lineBreakMode = UILabel::LINE_BREAK_MARQUEE, + .lineBreakMode = UILabel::LINE_BREAK_OSCILLATION, }; CyweeVersionTitle = InitLabel(Config); if (CyweeVersionTitle == nullptr) diff --git a/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemPresenter.cpp index 5e5356b58..8daedb063 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemPresenter.cpp @@ -14,6 +14,7 @@ #include "languagecode/LanguageInit.h" #include "ui_resource_string.h" #include "ConfigModel.h" +#include "vibrator_service.h" namespace OHOS { @@ -224,6 +225,7 @@ namespace OHOS } else if (strcmp(view.GetViewId(), FACTORYRESET_CHECKON) == 0) // 恢复出厂设置确认 { + ui_api_vibrate_once_func(); //恢复出厂增加震动 do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_TYPE_RESTORE_FACTORY_SETTING, NULL, 0); return true; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemView.cpp b/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemView.cpp index 182c659a2..8bc05f6ff 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemView.cpp @@ -29,6 +29,13 @@ namespace OHOS void SystemView::ClearAll() { + if (container_ != nullptr) + { + container_->RemoveAll(); + delete container_; + container_ = nullptr; + } + if (viewInitStatus) { if (SystemScrollView[SYSTEMVIEW] != nullptr) @@ -39,7 +46,7 @@ namespace OHOS delete Title; Title = nullptr; } - for (int i = 0; i < 5; i++) + for (int i = 0; i < sizeof(SystemViewLabelButton) / sizeof(SystemViewLabelButton[0]); i++) { if (SystemViewLabelButton[i] != nullptr) { @@ -58,6 +65,11 @@ namespace OHOS delete NeedToUpdateImage; NeedToUpdateImage = nullptr; } + if (temp != nullptr) + { + delete temp; + temp = nullptr; + } delete SystemScrollView[SYSTEMVIEW]; SystemScrollView[SYSTEMVIEW] = nullptr; } @@ -131,7 +143,7 @@ namespace OHOS bool SystemView::CreateSystemViewLabel(void) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SystemView::CreateSystemViewLabel"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::CreateSystemViewLabel"); LabelConfig labelConfig = { .left = 83, .top = 50, @@ -195,7 +207,7 @@ namespace OHOS bool SystemView::CreateSystemViewLabelButton(void) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SystemView::CreateSystemViewLabelButton"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::CreateSystemViewLabelButton"); struct ButtonSetup { int y; @@ -234,7 +246,7 @@ namespace OHOS bool SystemView::CreateSystemScrollView(void) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SystemView::CreateSystemScrollView"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::CreateSystemScrollView"); SystemScrollView[SYSTEMVIEW] = new UIScrollView(); if (SystemScrollView[SYSTEMVIEW] == nullptr) { @@ -243,12 +255,14 @@ namespace OHOS } SystemScrollView[SYSTEMVIEW]->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); SystemScrollView[SYSTEMVIEW]->SetStyle(STYLE_BACKGROUND_OPA, 0xff); - SystemScrollView[SYSTEMVIEW]->SetScrollBlankSize(75); - SystemScrollView[SYSTEMVIEW]->SetReboundSize(35); + SystemScrollView[SYSTEMVIEW]->SetScrollBlankSize(30); + SystemScrollView[SYSTEMVIEW]->SetReboundSize(30); SystemScrollView[SYSTEMVIEW]->SetDirection(1); SystemScrollView[SYSTEMVIEW]->SetThrowDrag(true); // 设置手指抬起屏幕后是否继续滚动。 SystemScrollView[SYSTEMVIEW]->SetMaxScrollDistance(1000); // 设置手指抬起屏幕后的最大滚动距离。 - SystemScrollView[SYSTEMVIEW]->RequestFocus(); + SystemScrollView[SYSTEMVIEW]->SetSwipeACCLevel(800); /*设置手指抬起屏幕后的补偿距离。*/ + FocusManager::GetInstance()->RequestFocus(SystemScrollView[SYSTEMVIEW]); + FocusManager::GetInstance()->RequestFocusByDirection(FOCUS_DIRECTION_UP); SystemScrollView[SYSTEMVIEW]->SetRotateFactor(1.0); SystemScrollView[SYSTEMVIEW]->SetOnDragListener(presenter_); SystemScrollView[SYSTEMVIEW]->SetTouchable(true); @@ -279,12 +293,25 @@ namespace OHOS void SystemView::CreateSystemView(void) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SystemView::CreateSystemView"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::CreateSystemView"); if (!CreateSystemScrollView() || !CreateSystemViewLabelButton() || !CreateSystemViewLabel()) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SystemView::CreateSystemView"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::CreateSystemView fail!!"); return; } + /* ------------------- 该组件的使用是为了解决不能单独设置滚动视图底部空白大小问题,用一个不可见组件占位置 ------------------ */ + /* ---------------------------- 因为使用SetScrollBlankSize设置过大后,下拉后无法恢复到原位置,有明显的向下偏移 --------------------------- */ + if (temp == nullptr) + { + temp = new UIImageView(); + if (temp == nullptr) + { + return; + } + temp->SetPosition(43, 960, 380, 40); + temp->SetVisible(false); + SystemScrollView[SYSTEMVIEW]->Add(temp); + } viewInitStatus = true; } @@ -336,13 +363,8 @@ namespace OHOS { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SystemView::OnStop"); View::OnStop(); - if (container_ != nullptr) - { - container_->RemoveAll(); - delete container_; - container_ = nullptr; - } RootView::GetInstance()->ClearOnKeyActListener(); + FocusManager::GetInstance()->ClearFocus(); ClearAll(); return; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/themestyle/include/ThemeStyleView.h b/code/sdk/application/wearable/fd230app/nativeui/themestyle/include/ThemeStyleView.h index b9a870d06..01502388b 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/themestyle/include/ThemeStyleView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/themestyle/include/ThemeStyleView.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-06-14 09:40:13 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-08-19 18:24:49 + * @LastEditTime: 2024-09-20 15:31:42 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/themestyle/include/ThemeStyleView.h */ @@ -97,6 +97,7 @@ namespace OHOS UIImageView *ThemeStyleImage[MAX_STYLE]{nullptr}; UILabelButtonExt *ExitLabelButton{nullptr}; UILabelExt *ExitLabel{nullptr}; + UIImageView *temp{nullptr}; bool initViewStatus{false}; }; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/themestyle/src/ThemeStyleView.cpp b/code/sdk/application/wearable/fd230app/nativeui/themestyle/src/ThemeStyleView.cpp index f6b970827..c1925ff46 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/themestyle/src/ThemeStyleView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/themestyle/src/ThemeStyleView.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-06-14 09:40:20 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-08-19 18:48:59 + * @LastEditTime: 2024-09-20 15:36:31 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/themestyle/src/ThemeStyleView.cpp */ @@ -10,7 +10,7 @@ #include "themestyle/include/ThemeStyleView.h" #include "themestyle/include/ThemeStylePresenter.h" #include "ui_resource_string.h" - +#include "dock/focus_manager.h" namespace OHOS { static ThemeStyleView *g_pThemeStyleView{nullptr}; @@ -35,15 +35,23 @@ namespace OHOS void ThemeStyleView::ClearAll(void) { + if (container_ != nullptr) + { + container_->RemoveAll(); + delete container_; + container_ = nullptr; + } + if (initViewStatus) { if (scrollView != nullptr) { scrollView->RemoveAll(); - - delete titleText; - titleText = nullptr; - + if (titleText) + { + delete titleText; + titleText = nullptr; + } for (int i = 0; i < MAX_STYLE; i++) { delete ThemeStyleLabelButton[i]; @@ -55,13 +63,21 @@ namespace OHOS delete ThemeStyleImage[i]; ThemeStyleImage[i] = nullptr; } - - delete ExitLabelButton; - ExitLabelButton = nullptr; - - delete ExitLabel; - ExitLabel = nullptr; - + if (ExitLabelButton) + { + delete ExitLabelButton; + ExitLabelButton = nullptr; + } + if (ExitLabel) + { + delete ExitLabel; + ExitLabel = nullptr; + } + if(temp) + { + delete temp; + temp = nullptr; + } delete scrollView; scrollView = nullptr; } @@ -132,14 +148,16 @@ namespace OHOS return false; } scrollView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); - scrollView->SetScrollBlankSize(SCROLLBLANKSIZE); - scrollView->SetReboundSize(REBOUNDSIZE); - scrollView->SetHorizontalScrollState(false); - scrollView->RequestFocus(); + scrollView->SetScrollBlankSize(30); + scrollView->SetReboundSize(30); + scrollView->SetDirection(1); + scrollView->SetThrowDrag(true); // 设置手指抬起屏幕后是否继续滚动。 + scrollView->SetMaxScrollDistance(1000); // 设置手指抬起屏幕后的最大滚动距离。 + scrollView->SetSwipeACCLevel(800); /*设置手指抬起屏幕后的补偿距离。*/ + FocusManager::GetInstance()->RequestFocus(scrollView); + FocusManager::GetInstance()->RequestFocusByDirection(FOCUS_DIRECTION_UP); scrollView->SetRotateFactor(1.0); - scrollView->SetMaxScrollDistance(1000); - scrollView->SetDragACCLevel(5); - scrollView->SetSwipeACCLevel(800); /*设置手指抬起屏幕后的补偿距离。*/ + scrollView->SetOnDragListener(presenter_); scrollView->SetTouchable(true); scrollView->SetDraggable(true); container_->Add(scrollView); @@ -286,6 +304,22 @@ namespace OHOS } UpdateSelectedStyle(); + /* ------------------- 该组件的使用是为了解决不能单独设置滚动视图底部空白大小问题,用一个不可见组件占位置 ------------------ */ + /* ---------------------------- 因为使用SetScrollBlankSize设置过大后,下拉后无法恢复到原位置,有明显的向下偏移 --------------------------- */ + if (temp == nullptr) + { + temp = new UIImageView(); + if (temp == nullptr) + { + return; + } + if (ExitLabelButton) + { + temp->SetPosition(43, ExitLabelButton->GetY() + ExitLabelButton->GetHeight(), 380, 40); + } + temp->SetVisible(false); + scrollView->Add(temp); + } initViewStatus = true; } @@ -294,8 +328,12 @@ namespace OHOS WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThemeStyleView::OnStart"); View::OnStart(); SetContainerView(new UIViewGroup()); + if (GetContainer() == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "container_ new fail!!"); + return; + } container_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); - container_->SetOnDragListener(presenter_); container_->SetTouchable(true); container_->SetDraggable(true); @@ -324,12 +362,7 @@ namespace OHOS WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThemeStyleView::OnStop"); View::OnStop(); RootView::GetInstance()->ClearOnKeyActListener(); - if (container_ != nullptr) - { - container_->RemoveAll(); - delete container_; - container_ = nullptr; - } + FocusManager::GetInstance()->ClearFocus(); ClearAll(); }