From 3b6e79a3f689310a444764d7223f761067ac821d Mon Sep 17 00:00:00 2001 From: luozheng <1732036298@qq.com> Date: Fri, 20 Sep 2024 16:44:01 +0800 Subject: [PATCH] =?utf8?q?#747,=E8=A7=A3=E5=86=B3=E5=A3=B0=E9=9F=B3?= =?utf8?q?=E4=B8=8E=E9=9C=87=E5=8A=A8=EF=BC=8C=E6=98=BE=E7=A4=BA=E6=96=B9?= =?utf8?q?=E5=BC=8F=EF=BC=8C=E7=B3=BB=E7=BB=9F=E7=95=8C=E9=9D=A2=20?= =?utf8?q?=E4=B8=8B=E6=8B=89=E5=90=8E=E6=97=A0=E6=B3=95=E6=81=A2=E5=A4=8D?= =?utf8?q?=E5=88=B0=E5=8E=9F=E4=BD=8D=E7=BD=AE=EF=BC=8C=E6=9C=89=E5=90=91?= =?utf8?q?=E4=B8=8B=E5=81=8F=E7=A7=BBbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../nativeui/settings/src/SettingItemView.cpp | 4 +- .../nativeui/settings/src/SettingView.cpp | 21 +++-- .../include/SoundAndVibrationView.h | 3 +- .../src/SoundAndVibrationView.cpp | 33 +++++-- .../nativeui/system/src/SystemView.cpp | 17 ++-- .../themestyle/include/ThemeStyleView.h | 3 +- .../themestyle/src/ThemeStyleView.cpp | 87 +++++++++++++------ 7 files changed, 113 insertions(+), 55 deletions(-) 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..006795faa 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 16:04:46 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/settings/src/SettingView.cpp */ @@ -87,11 +87,9 @@ 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); - scrollView->SetOnDragListener(presenter_); /* -------------------------------------------------------------------------- */ title = new UILabelExt(); if (title == nullptr) @@ -125,17 +123,18 @@ 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); + contentList->SetOnDragListener(presenter_); /* ----------------------------------- Add ---------------------------------- */ scrollView->Add(title); scrollView->Add(contentList); 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/src/SystemView.cpp b/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemView.cpp index 19dbe79f7..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) @@ -292,6 +299,8 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::CreateSystemView fail!!"); return; } + /* ------------------- 该组件的使用是为了解决不能单独设置滚动视图底部空白大小问题,用一个不可见组件占位置 ------------------ */ + /* ---------------------------- 因为使用SetScrollBlankSize设置过大后,下拉后无法恢复到原位置,有明显的向下偏移 --------------------------- */ if (temp == nullptr) { temp = new UIImageView(); @@ -300,6 +309,7 @@ namespace OHOS return; } temp->SetPosition(43, 960, 380, 40); + temp->SetVisible(false); SystemScrollView[SYSTEMVIEW]->Add(temp); } viewInitStatus = true; @@ -353,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(); } -- 2.17.1