From: luozheng <1732036298@qq.com> Date: Tue, 27 Feb 2024 12:36:44 +0000 (+0800) Subject: 辅助功能快速访问界面适配功能键,跳转进入的Slice退出逻辑需要修改 X-Git-Tag: release_V1.2.70_20241020_135402~1298^2~5 X-Git-Url: http://git.snicker.com.cn/Users/apple/Desktop/static/gitweb.css?a=commitdiff_plain;h=93189751e991526764d0d4118b57d4cb3cdec087;p=mirrors%2FFD230.git 辅助功能快速访问界面适配功能键,跳转进入的Slice退出逻辑需要修改 --- diff --git a/code/sdk/application/wearable/fd230app/CMakeLists.txt b/code/sdk/application/wearable/fd230app/CMakeLists.txt index 59d816ff2..ad88b2f83 100644 --- a/code/sdk/application/wearable/fd230app/CMakeLists.txt +++ b/code/sdk/application/wearable/fd230app/CMakeLists.txt @@ -281,6 +281,7 @@ set(SOURCES #辅助功能 ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/secondaryfunction/src/SecondaryFunctionPresenter.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/secondaryfunction/src/SecondaryFunctionView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/secondaryfunction/src/SecondaryFunctionModel.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/secondaryfunction/src/FastTrainingAttentionPresenter.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/secondaryfunction/src/FastTrainingAttentionView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/secondaryfunction/src/FastTrainingPresenter.cpp diff --git a/code/sdk/application/wearable/fd230app/nativeui/key/src/KeyInputListener.cpp b/code/sdk/application/wearable/fd230app/nativeui/key/src/KeyInputListener.cpp index b00cd41cf..2a1314bf9 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/key/src/KeyInputListener.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/key/src/KeyInputListener.cpp @@ -17,7 +17,7 @@ #include "AlarmPopUpPresenter.h" #include "CallerLogModel.h" #include "MainCallingPresenter.h" - +#include "secondaryfunction/include/SecondaryFunctionModel.h" namespace OHOS { static bool IsCallingNotify() { @@ -130,6 +130,15 @@ void KeyInputListener::OnKeyRelease(const KeyEvent& event) CallVolumeDipSwitchControl(0); } else { // 切换到用户配置的快捷卡片 + if(SecondaryFunctionModel::GetInstance()->GetHeartRateOrBloodOxygenQuickAccessSwitch() == true) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_BLOODOXY, TRANSITION_ZOOM); + } + else + { + //之后需要将VIEW_APPLIST改成心率的SliceID + NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST, TRANSITION_ZOOM); + } } } } diff --git a/code/sdk/application/wearable/fd230app/nativeui/secondaryfunction/include/QuickAccessView.h b/code/sdk/application/wearable/fd230app/nativeui/secondaryfunction/include/QuickAccessView.h index 937315ead..5ee548ad4 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/secondaryfunction/include/QuickAccessView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/secondaryfunction/include/QuickAccessView.h @@ -51,6 +51,7 @@ namespace OHOS UIScrollView *QuickAccessViewInit(void); void ClearAll(void); UIRadioButton * GetRadioButton(int i); + void HeartRateOrBloodOxygenQuickAccessRadioButtonSelectStateSet(int state); private: bool QuickAccessScrollViewInit(void); bool QuickAccessLabelInit(void); diff --git a/code/sdk/application/wearable/fd230app/nativeui/secondaryfunction/include/SecondaryFunctionModel.h b/code/sdk/application/wearable/fd230app/nativeui/secondaryfunction/include/SecondaryFunctionModel.h new file mode 100644 index 000000000..0fa58978c --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/secondaryfunction/include/SecondaryFunctionModel.h @@ -0,0 +1,24 @@ +#ifndef SECONDARY_FUNCTION_MODEL_H +#define SECONDARY_FUNCTION_MODEL_H + +namespace OHOS +{ + class SecondaryFunctionModel + { + public: + static SecondaryFunctionModel *GetInstance(void); + void KeepHeartRateOrBloodOxygenQuickAccessRadioButtonSelectState(int state); + bool HeartRateOrBloodOxygenQuickAccessRadioButtonSelectStateInit(void); + bool GetHeartRateOrBloodOxygenQuickAccessSwitch(void); + private: + SecondaryFunctionModel() {} + ~SecondaryFunctionModel() {} + SecondaryFunctionModel(const SecondaryFunctionModel &); + SecondaryFunctionModel &operator=(const SecondaryFunctionModel &); + + private: + int HeartRateOrBloodOxygenQuickAccessSwitch{0}; // 心率或血氧快速访问开关,默认快速访问血氧打开 + }; +} + +#endif diff --git a/code/sdk/application/wearable/fd230app/nativeui/secondaryfunction/include/SecondaryFunctionPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/secondaryfunction/include/SecondaryFunctionPresenter.h index d4247532a..39b8142b6 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/secondaryfunction/include/SecondaryFunctionPresenter.h +++ b/code/sdk/application/wearable/fd230app/nativeui/secondaryfunction/include/SecondaryFunctionPresenter.h @@ -47,7 +47,7 @@ namespace OHOS void OnStop() override; static SecondaryFunctionPresenter *GetInstance(); - + void SetHeartRateOrBloodOxygenQuickAccessRadioButtonSelectState(int state); private: // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; bool OnClick(UIView &view, const ClickEvent &event) override; diff --git a/code/sdk/application/wearable/fd230app/nativeui/secondaryfunction/src/QuickAccessView.cpp b/code/sdk/application/wearable/fd230app/nativeui/secondaryfunction/src/QuickAccessView.cpp index 9d38d7630..fc6fffd55 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/secondaryfunction/src/QuickAccessView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/secondaryfunction/src/QuickAccessView.cpp @@ -1,5 +1,6 @@ #include "secondaryfunction/include/QuickAccessView.h" #include "secondaryfunction/include/SecondaryFunctionPresenter.h" +#include "secondaryfunction/include/SecondaryFunctionModel.h" namespace OHOS { @@ -36,6 +37,15 @@ namespace OHOS QuickAccessLabel[i] = nullptr; } + if (QuickAccessRadioButton[0]->GetState() == UICheckBox::SELECTED) + { + SecondaryFunctionModel::GetInstance()->KeepHeartRateOrBloodOxygenQuickAccessRadioButtonSelectState(0); + } + else if (QuickAccessRadioButton[1]->GetState() == UICheckBox::SELECTED) + { + SecondaryFunctionModel::GetInstance()->KeepHeartRateOrBloodOxygenQuickAccessRadioButtonSelectState(1); + } + // 循环删除 UIImageView 和 UIRadioButton指针数组 for (int i = 0; i < 2; i++) { @@ -59,6 +69,17 @@ namespace OHOS return QuickAccessRadioButton[i]; } + void QuickAccessView::HeartRateOrBloodOxygenQuickAccessRadioButtonSelectStateSet(int state) + { + if (state == 0) + { + QuickAccessRadioButton[0]->SetState(UICheckBox::SELECTED); + } + else + { + QuickAccessRadioButton[1]->SetState(UICheckBox::SELECTED); + } + } // 设置图片 UIImageView *QuickAccessView::SetUpImageView(ImageConfig &imageconfig) { @@ -233,6 +254,11 @@ namespace OHOS return nullptr; } + if (!SecondaryFunctionModel::GetInstance()->HeartRateOrBloodOxygenQuickAccessRadioButtonSelectStateInit()) + { + return nullptr; + } + initViewStatus = true; return QuickAccessScrollView; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/secondaryfunction/src/SecondaryFunctionModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/secondaryfunction/src/SecondaryFunctionModel.cpp new file mode 100644 index 000000000..6fb72ee05 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/secondaryfunction/src/SecondaryFunctionModel.cpp @@ -0,0 +1,48 @@ +#include "secondaryfunction/include/SecondaryFunctionModel.h" +#include "secondaryfunction/include/SecondaryFunctionPresenter.h" + +#include "wearable_log.h" + +namespace OHOS +{ + SecondaryFunctionModel *SecondaryFunctionModel::GetInstance(void) + { + static SecondaryFunctionModel instacne; + return &instacne; + } + + /// @brief 保存心率或血氧快速访问单选按钮选中状态 + /// @param state 0 选中心率 1 选中血氧 + void SecondaryFunctionModel::KeepHeartRateOrBloodOxygenQuickAccessRadioButtonSelectState(int state) + { + HeartRateOrBloodOxygenQuickAccessSwitch = state; + } + + /// @brief 心率或血氧快速访问单选按钮选中状态初始化 + bool SecondaryFunctionModel::HeartRateOrBloodOxygenQuickAccessRadioButtonSelectStateInit(void) + { + SecondaryFunctionPresenter *p_SecondaryFunctionPresenter = SecondaryFunctionPresenter::GetInstance(); + if (p_SecondaryFunctionPresenter == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SecondaryFunctionPresenter GetInstance fail"); + return false; + } + p_SecondaryFunctionPresenter->SetHeartRateOrBloodOxygenQuickAccessRadioButtonSelectState(HeartRateOrBloodOxygenQuickAccessSwitch); + return true; + } + + /// @brief 获取快速访问开关 + /// @param void + /// @return true 快速访问心率开关开启,反之血氧开关开启 + bool SecondaryFunctionModel::GetHeartRateOrBloodOxygenQuickAccessSwitch(void) + { + if (HeartRateOrBloodOxygenQuickAccessSwitch == 0) + { + return true; + } + else + { + return false; + } + } +} diff --git a/code/sdk/application/wearable/fd230app/nativeui/secondaryfunction/src/SecondaryFunctionPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/secondaryfunction/src/SecondaryFunctionPresenter.cpp index 5421a884d..6bc613888 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/secondaryfunction/src/SecondaryFunctionPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/secondaryfunction/src/SecondaryFunctionPresenter.cpp @@ -2,7 +2,7 @@ #include "AppViewIDs.h" #include "NativeAbility.h" #include "secondaryfunction/include/SecondaryFunctionPresenter.h" - +#include "secondaryfunction/include/SecondaryFunctionModel.h" namespace OHOS { @@ -27,6 +27,27 @@ namespace OHOS return g_pSecondaryFunctionPresenter; } + /// @brief 设置心率或血氧快速访问单选按钮选中状态 + /// @param state + void SecondaryFunctionPresenter::SetHeartRateOrBloodOxygenQuickAccessRadioButtonSelectState(int state) + { + QuickAccessView *p_QuickAccessView = QuickAccessView::GetInstance(); + if (p_QuickAccessView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "p_QuickAccessView GetInstance fail"); + return; + } + if (state != 0) + { + p_QuickAccessView->HeartRateOrBloodOxygenQuickAccessRadioButtonSelectStateSet(1); + SecondaryFunctionModel::GetInstance()->KeepHeartRateOrBloodOxygenQuickAccessRadioButtonSelectState(0); + } + else + { + p_QuickAccessView->HeartRateOrBloodOxygenQuickAccessRadioButtonSelectStateSet(0); + } + } + void SecondaryFunctionPresenter::OnStart() {