From: luozheng <1732036298@qq.com> Date: Thu, 18 Apr 2024 07:00:52 +0000 (+0800) Subject: 1.优化亮度调节的ChangeBrightness函数 X-Git-Tag: release_V1.2.70_20241020_135402~1162^2~12 X-Git-Url: http://git.snicker.com.cn/?a=commitdiff_plain;h=c494ebc3f1ea87003260a8cbf6593d916c7d8b01;p=mirrors%2FFD230.git 1.优化亮度调节的ChangeBrightness函数 2.同步选择的亮屏时长在屏幕与亮度显示 3.修改设置视图的OnDrag函数 --- diff --git a/code/sdk/application/wearable/fd230app/nativeui/brightnesslevel/src/BrightnessLevelView.cpp b/code/sdk/application/wearable/fd230app/nativeui/brightnesslevel/src/BrightnessLevelView.cpp index c592d613f..cdbc42431 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/brightnesslevel/src/BrightnessLevelView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/brightnesslevel/src/BrightnessLevelView.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-04-16 14:36:13 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-04-16 16:18:00 + * @LastEditTime: 2024-04-18 14:38:37 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/brightnesslevel/src/BrightnessLevelView.cpp */ #include "brightnesslevel/include/BrightnessLevelView.h" @@ -22,7 +22,7 @@ namespace OHOS BrightnessLevelView::~BrightnessLevelView() { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "~BrightnessLevelView::BrightnessLevelView"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BrightnessLevelView::~BrightnessLevelView"); ClearAll(); g_pBrightnessLevelView = nullptr; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/include/BrightnessControlView.h b/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/include/BrightnessControlView.h index 1b087f3c6..f03208a62 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/include/BrightnessControlView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/include/BrightnessControlView.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-01-29 15:37:44 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-04-16 16:51:33 + * @LastEditTime: 2024-04-18 14:52:47 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/include/BrightnessControlView.h */ #ifndef BRIGHTNESS_CONTROL_VIEW_H @@ -14,12 +14,22 @@ #include "components/ui_slider.h" #include "components/ui_image_view.h" #include +#include "map" namespace OHOS { #define BRIGHTNESS_MIN 51 #define BRIGHTNESS_MAX 0xff #define BRIGHTNESS_PROGRESS "progress" + // 步骤 1: 定义策略接口.定义一个策略接口,所有的亮度调整策略都需要实现这个接口 + class BrightnessControlView; + class BrightnessChangeStrategy + { + public: + virtual void ApplyChange(BrightnessControlView *view, UISlider *slider, uint8_t value) = 0; + virtual ~BrightnessChangeStrategy() = default; + }; + static const char *BRIGHTNESS_CONTROL_SLIDER = "BrightnessControlViewSlider"; class BrightnessSliderEventListener : public UISlider::UISliderEventListener, public UIView::OnClickListener, @@ -28,7 +38,7 @@ namespace OHOS public: BrightnessSliderEventListener(); ~BrightnessSliderEventListener(); - static std::shared_ptr GetInstance(); + static BrightnessSliderEventListener *GetInstance(); void ChangeBrightness(uint8_t status, uint8_t value); void OnChange(int32_t value) override; void OnRelease(int32_t value) override; @@ -36,7 +46,7 @@ namespace OHOS bool OnDrag(UIView &view, const DragEvent &event) override; private: - int32_t BrightnessValue; // 亮度值 + std::map> strategyMap; }; class BrightnessControlView { @@ -47,12 +57,12 @@ namespace OHOS UIScrollView *BrightnessControlViewInit(void); void ClearAll(void); UISlider *GetBrightnessControlViewSlider(void); - int16_t CurrentBrightnessValue{0}; // 当前亮度值 - void SetScreenBrightnessValue(unsigned char value); + private: bool SetUpScrollView(void); bool SetUpSlider(void); bool SetUpImageView(void); + BrightnessSliderEventListener *rawPointer{nullptr}; UIScrollView *BrightnessControlScrollView{nullptr}; UISlider *BrightnessControlViewSlider = nullptr; UIImageView *BrightnessControlViewImageIcon = nullptr; diff --git a/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/include/DisplayBrightnessModel.h b/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/include/DisplayBrightnessModel.h index 336a071ce..015ef9dea 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/include/DisplayBrightnessModel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/include/DisplayBrightnessModel.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-04-12 20:11:04 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-04-17 10:33:16 + * @LastEditTime: 2024-04-18 10:23:37 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/include/DisplayBrightnessModel.h */ #ifndef DISPLAY_BRIGHTNESS_MODEL_H_ @@ -18,6 +18,7 @@ namespace OHOS void SetRaiseToBrightnessCheckBoxButtonStatus(bool value); bool RaiseToBrightnessCheckBoxButtonStatusInit(void); bool ScreenDurationRadioButtonSlectStatusInit(void); + bool SelectScreenDurationLabelInit(void); void SetScreenDurationTime(unsigned int time); unsigned int GetScreenDurationTime(void); private: diff --git a/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/include/DisplayBrightnessPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/include/DisplayBrightnessPresenter.h index 6d4d545ce..bf3a59fc4 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/include/DisplayBrightnessPresenter.h +++ b/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/include/DisplayBrightnessPresenter.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-02-18 09:10:05 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-04-17 10:21:03 + * @LastEditTime: 2024-04-18 10:59:11 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/include/DisplayBrightnessPresenter.h */ #ifndef _DISPLAY_BRIGHTNESS_PRESENTER_H @@ -88,7 +88,8 @@ namespace OHOS static DisplayBrightnessPresenter *GetInstance(); void SetRaiseToBrightnessState(bool value); - void SetScreenDurationRadioButtonSlectStatus(uint32_t value); + void SetScreenDurationRadioButtonSelectStatus(uint32_t value); + void SetSelectScreenDurationLabel(uint32_t value); private: // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; diff --git a/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/include/DisplayBrightnessView.h b/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/include/DisplayBrightnessView.h index cfdb2a686..ad4f44e10 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/include/DisplayBrightnessView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/include/DisplayBrightnessView.h @@ -35,7 +35,7 @@ namespace OHOS int16_t w; int16_t h; const char *ViewId; - const char *ImageSrc; + //const char *ImageSrc; }; struct LabelConfig { @@ -45,7 +45,7 @@ namespace OHOS int16_t height; int16_t fontSize; // 字体大小 int16_t lineHeigh; // 行高 - const char *text; // 文本 + std::string text; // 文本 uint8_t lineBreakMode; // 断行模式。 }; struct CheckBoxConfig @@ -70,7 +70,8 @@ namespace OHOS UIScrollView *GetDisplayBrightnessScrollView(int16_t i); UICheckBox::UICheckBoxState GetRaiseToBrightnessCheckBoxButtonState(void); void SetRaiseToBrightnessCheckBoxButtonState(UICheckBox::UICheckBoxState state); - ScreenDurationView * GetScreenDurationView(void); + ScreenDurationView *GetScreenDurationView(void); + UILabelExt * GetSelectScreenDurationLabel(void); public: void OnStart() override; void OnSetUpView() override; @@ -78,26 +79,28 @@ namespace OHOS void OnStop() override; private: - //ScreenDurationView *p_ScreenDurationView{nullptr}; // 亮屏时长视图 + // ScreenDurationView *p_ScreenDurationView{nullptr}; // 亮屏时长视图 std::shared_ptr p_ScreenDurationView; + private: bool SetUpScrollView(void); bool SetTheTitle(void); UIButton *SetTheButton(ButtonConfig &buttonconfig, UIView::OnClickListener *clickListener); bool InitDisplayBrightnessViewButton(void); - UILabel *SetUpLabel(LabelConfig &labelconfig); // 设置标签 + UILabelExt *SetUpLabel(LabelConfig &labelconfig); // 设置标签 bool InitDisplayBrightnessViewLabel(void); UIImageView *SetUpImageView(ImageConfig &imageconfig); // 设置图片 bool InitDisplayBrightnessViewImage(void); UICheckBox *SetUpCheckBox(CheckBoxConfig &checkboxconfig); // 设置复选框 bool InitDisplayBrightnessViewCheckBox(void); UIScrollView *DisplayBrightnessScrollView[2]{nullptr}; - UILabel *DisplayBrightnessTitleLabel = nullptr; // 显示与亮度标题 - UIButton *BringhtnessControlButton = nullptr; // 亮度调节按钮 - UIButton *ScreenDurationButton = nullptr; // 亮屏时长按钮 - UILabel *BringhtnessControlLabel = nullptr; // 亮度调节标签 - UILabel *ScreenDurationLabel = nullptr; // 亮屏时长标签 - UILabel *RaiseToBrightnessLabel = nullptr; // 抬腕亮屏标签 + UILabelExt *DisplayBrightnessTitleLabel = nullptr; // 显示与亮度标题 + UIButton *BringhtnessControlButton = nullptr; // 亮度调节按钮 + UIButton *ScreenDurationButton = nullptr; // 亮屏时长按钮 + UILabelExt *BringhtnessControlLabel = nullptr; // 亮度调节标签 + UILabelExt *ScreenDurationLabel = nullptr; // 亮屏时长标签 + UILabelExt *selectScreenDurationLabel = nullptr; // 选择的亮屏时间 + UILabelExt *RaiseToBrightnessLabel = nullptr; // 抬腕亮屏标签 UIImageView *NextImage[2]{nullptr}; UIImageView *RaiseToBrightnessImage = nullptr; // 抬腕亮屏图片 UICheckBox *RaiseToBrightnessCheckBoxButton = nullptr; // 抬腕亮屏按钮 diff --git a/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/BrightnessControlView.cpp b/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/BrightnessControlView.cpp index 750aeb0a6..0ec230815 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/BrightnessControlView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/BrightnessControlView.cpp @@ -4,6 +4,8 @@ #include #include "power_display_service.h" #include "config/include/ConfigModel.h" +#include "map" +#include "iostream" namespace OHOS { static BrightnessControlView *g_pBrightnessControlView{nullptr}; @@ -40,6 +42,9 @@ namespace OHOS delete BrightnessControlViewImageIcon; BrightnessControlViewImageIcon = nullptr; + delete rawPointer; + rawPointer = nullptr; + delete BrightnessControlScrollView; BrightnessControlScrollView = nullptr; } @@ -83,13 +88,18 @@ namespace OHOS BrightnessControlViewSlider->SetValue(ConfigModel::GetInstance()->GetBrightness()); BrightnessControlViewSlider->SetIntercept(true); - /* - 注意,使用get方法获取的原生指针不应被用来管理对象的生命周期(不要用它去调用delete),因为智能指针会自动处理对象的销毁。 - */ - BrightnessSliderEventListener *rawPointer = BrightnessSliderEventListener::GetInstance().get(); - BrightnessControlViewSlider->SetSliderEventListener(rawPointer ); - BrightnessControlViewSlider->SetOnClickListener(rawPointer ); - BrightnessControlViewSlider->SetOnDragListener(rawPointer ); + if (rawPointer == nullptr) + { + rawPointer = new BrightnessSliderEventListener(); + if (rawPointer == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "rawPointer new fail"); + return false; + } + } + BrightnessControlViewSlider->SetSliderEventListener(rawPointer); + BrightnessControlViewSlider->SetOnClickListener(rawPointer); + BrightnessControlViewSlider->SetOnDragListener(rawPointer); BrightnessControlViewSlider->SetKnobStyle(StyleDefault::GetSliderKnobStyle()); return true; } @@ -113,10 +123,6 @@ namespace OHOS return BrightnessControlViewSlider; } - void BrightnessControlView::SetScreenBrightnessValue(unsigned char value) - { - BrightnessControlViewSlider->SetValue(value); - } // 亮度调节视图初始化 UIScrollView *BrightnessControlView::BrightnessControlViewInit(void) @@ -149,12 +155,82 @@ namespace OHOS } /* -------------------------------------------------------------------------- */ - static BrightnessSliderEventListener *g_pBrightnessSliderEventListener{nullptr}; - constexpr int16_t BRIGHTNESS_CHANGE = 10; + static constexpr int16_t BRIGHTNESS_CHANGE = 10; + // 步骤 2: 实现具体的策略 + class LowerBrightnessStrategy : public BrightnessChangeStrategy + { + public: + void ApplyChange(BrightnessControlView *view, UISlider *slider, uint8_t value) override + { + // Implement the logic similar to the BRIGHTNESSLOWERS case + uint8_t newBrightnessValue = slider->GetValue() - BRIGHTNESS_CHANGE; + if (newBrightnessValue < BRIGHTNESS_MIN) + { + newBrightnessValue = BRIGHTNESS_MIN; + } + + const power_display_svr_api_t *display_api = power_display_svr_get_api(); + if (display_api->set_brightness(newBrightnessValue) != ERRCODE_SUCC) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "LowerBrightness: set_brightness fail!"); + } + else + { + slider->SetValue(newBrightnessValue); + } + } + }; + + class ElevateBrightnessStrategy : public BrightnessChangeStrategy + { + public: + void ApplyChange(BrightnessControlView *view, UISlider *slider, uint8_t value) override + { + // Implement the logic similar to the BRIGHTNESSEVATED case + uint8_t newBrightnessValue = slider->GetValue() + BRIGHTNESS_CHANGE; + if (newBrightnessValue > BRIGHTNESS_MAX) + { + newBrightnessValue = BRIGHTNESS_MAX; + } + + const power_display_svr_api_t *display_api = power_display_svr_get_api(); + if (display_api->set_brightness(newBrightnessValue) != ERRCODE_SUCC) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ElevateBrightness: set_brightness fail!"); + } + else + { + slider->SetValue(newBrightnessValue); + } + } + }; + + class DragBrightnessStrategy : public BrightnessChangeStrategy + { + public: + void ApplyChange(BrightnessControlView *view, UISlider *slider, uint8_t value) override + { + // Implement the logic similar to the BRIGHTNESSDRAG case + const power_display_svr_api_t *display_api = power_display_svr_get_api(); + // 更新进度条的显示: + slider->SetValue(value); + if (display_api->set_brightness(value) != ERRCODE_SUCC) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ChangeBrightness: set_brightness fail!"); + return; + } + } + }; + /* -------------------------------------------------------------------------- */ + static BrightnessSliderEventListener *g_pBrightnessSliderEventListener{nullptr}; BrightnessSliderEventListener::BrightnessSliderEventListener() { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BrightnessSliderEventListener::BrightnessSliderEventListener"); + // 步骤 3: 创建一个映射表将状态映射到策略 + strategyMap[BRIGHTNESSLOWERS] = std::make_shared(); + strategyMap[BRIGHTNESSEVATED] = std::make_shared(); + strategyMap[BRIGHTNESSDRAG] = std::make_shared(); g_pBrightnessSliderEventListener = this; } @@ -164,78 +240,25 @@ namespace OHOS g_pBrightnessSliderEventListener = nullptr; } - std::shared_ptr BrightnessSliderEventListener::GetInstance(void) + BrightnessSliderEventListener *BrightnessSliderEventListener::GetInstance(void) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BrightnessSliderEventListener::GetInstance"); - static std::shared_ptr instance(new BrightnessSliderEventListener()); - return instance; + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BrightnessSliderEventListener::GetInstance"); + return g_pBrightnessSliderEventListener; } - /// @brief 改变屏幕状态 - /// @param status + // 步骤 4: 使用映射表简化 ChangeBrightness void BrightnessSliderEventListener::ChangeBrightness(uint8_t status, uint8_t value) { - // 1.获取 BrightnessControlView 的实例: - BrightnessControlView *p_BrightnessControlView = BrightnessControlView::GetInstance(); - // 2.检查 BrightnessControlView 指针是否为 nullptr,并在为 nullptr 时打印错误日志并返回 - if (p_BrightnessControlView == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BrightnessControlView::GetInstance fail!"); - return; - } - // 3.获取 p_BrightnessControlView 的进度条 UISlider 实例的指针: - UISlider *progress = p_BrightnessControlView->GetBrightnessControlViewSlider(); - // 4.检查 progress 指针是否为 nullptr,并在为 nullptr 时打印错误日志并返回: - if (progress == nullptr) + auto it = strategyMap.find(status); + if (it != strategyMap.end()) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ChangeBrightness:progress is nullptr!"); - return; - } - // 5.保存当前亮度到变量 BrightnessValue - BrightnessValue = p_BrightnessControlView->CurrentBrightnessValue; - - // 6.获取显示功耗管理服务API接口. - const power_display_svr_api_t *display_api = power_display_svr_get_api(); - // 7.根据传入的 status 值进行亮度变化操作 - switch (status) - { - case BRIGHTNESSLOWERS: - /* code */ - p_BrightnessControlView->CurrentBrightnessValue = progress->GetValue() - BRIGHTNESS_CHANGE; - if (p_BrightnessControlView->CurrentBrightnessValue < BRIGHTNESS_MIN) - { - p_BrightnessControlView->CurrentBrightnessValue = BRIGHTNESS_MIN; - } - break; - case BRIGHTNESSEVATED: - p_BrightnessControlView->CurrentBrightnessValue = progress->GetValue() + BRIGHTNESS_CHANGE; - if (p_BrightnessControlView->CurrentBrightnessValue > BRIGHTNESS_MAX) - { - p_BrightnessControlView->CurrentBrightnessValue = BRIGHTNESS_MAX; - } - break; - case BRIGHTNESSDRAG: - p_BrightnessControlView->CurrentBrightnessValue = value; - if (p_BrightnessControlView->CurrentBrightnessValue < BRIGHTNESS_MIN) - { - p_BrightnessControlView->CurrentBrightnessValue = BRIGHTNESS_MIN; - } - else if (p_BrightnessControlView->CurrentBrightnessValue > BRIGHTNESS_MAX) + // 确保 BrightnessControlView 和 UISlider 都不为 nullptr + BrightnessControlView *view = BrightnessControlView::GetInstance(); + UISlider *slider = view ? view->GetBrightnessControlViewSlider() : nullptr; + if (view && slider) { - p_BrightnessControlView->CurrentBrightnessValue = BRIGHTNESS_MAX; + it->second->ApplyChange(view, slider, value); } - break; - default: - break; - } - // 8.将 p_BrightnessControlView->CurrentBrightnessValue 的值赋给 progress 的值,更新进度条的显示: - progress->SetValue(p_BrightnessControlView->CurrentBrightnessValue); - - // 9.设置当前亮度值并检查是否设置成功 - if (display_api->set_brightness(p_BrightnessControlView->CurrentBrightnessValue) != ERRCODE_SUCC) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ChangeBrightness: set_brightness fail!"); - return; } } diff --git a/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/DisplayBrightnessModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/DisplayBrightnessModel.cpp index 3f357fc9c..f58cbcad8 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/DisplayBrightnessModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/DisplayBrightnessModel.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-04-12 20:11:04 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-04-17 10:33:29 + * @LastEditTime: 2024-04-18 10:55:38 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/DisplayBrightnessModel.cpp */ #include "displaybrightness/include/DisplayBrightnessModel.h" @@ -60,7 +60,19 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DisplayBrightnessViewAndSubViewComponentsStatusInit DisplayBrightnessPresenter GetInstance fail"); return false; } - displayBrightnessPresent->SetScreenDurationRadioButtonSlectStatus(GetScreenDurationTime()); + displayBrightnessPresent->SetScreenDurationRadioButtonSelectStatus(GetScreenDurationTime()); + return true; + } + + bool DisplayBrightnessModel::SelectScreenDurationLabelInit(void) + { + DisplayBrightnessPresenter *displayBrightnessPresent = DisplayBrightnessPresenter::GetInstance(); + if (displayBrightnessPresent == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DisplayBrightnessViewAndSubViewComponentsStatusInit DisplayBrightnessPresenter GetInstance fail"); + return false; + } + displayBrightnessPresent->SetSelectScreenDurationLabel(GetScreenDurationTime()); return true; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/DisplayBrightnessPresent.cpp b/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/DisplayBrightnessPresent.cpp index f2657c9d3..442efe7b0 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/DisplayBrightnessPresent.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/DisplayBrightnessPresent.cpp @@ -1,3 +1,10 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-03-30 09:14:38 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-04-18 11:16:04 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/DisplayBrightnessPresent.cpp + */ #include "AppViewIDs.h" #include "components/ui_label_ext.h" #include "language/font/ui_resource_string.h" @@ -10,6 +17,8 @@ #include "power_display_service.h" #include "common/key_code.h" #include +#include "map" +#include "iostream" namespace OHOS { // 当前Presenter属性实例化的内存指针 @@ -52,38 +61,69 @@ namespace OHOS /// @brief 根据value值设置哪个按钮被选中 /// @param value - void DisplayBrightnessPresenter::SetScreenDurationRadioButtonSlectStatus(uint32_t value) + void DisplayBrightnessPresenter::SetScreenDurationRadioButtonSelectStatus(uint32_t value) { ScreenDurationView *p_ScreenDurationView = ScreenDurationView::GetInstance(); if (p_ScreenDurationView == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SetScreenDurationRadioButtonSlectStatus ScreenDurationView GetInstance fail"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ScreenDurationView GetInstance fail"); return; } - switch (value) + + // 映射表将value映射到特定的单选按钮 + const std::map radioButtonMap = { + {SCREENDURATION_FIVE, ScreenDurationRadioButton1}, + {SCREENDURATION_TEN, ScreenDurationRadioButton2}, + {SCREENDURATION_FIFTEENTH, ScreenDurationRadioButton3}, + {SCREENDURATION_THIRTY, ScreenDurationRadioButton4}, + {SCREENDURATION_SIXTY, ScreenDurationRadioButton5}, + {SCREENDURATION_THREE_HUNDRED, ScreenDurationRadioButton6}, + }; + + auto iter = radioButtonMap.find(value); + if (iter != radioButtonMap.end()) { - case SCREENDURATION_FIVE: - p_ScreenDurationView->SetRadioButtonSelectStatus(ScreenDurationRadioButton1); - break; - case SCREENDURATION_TEN: - p_ScreenDurationView->SetRadioButtonSelectStatus(ScreenDurationRadioButton2); - break; - case SCREENDURATION_FIFTEENTH: - p_ScreenDurationView->SetRadioButtonSelectStatus(ScreenDurationRadioButton3); - break; - case SCREENDURATION_THIRTY: - p_ScreenDurationView->SetRadioButtonSelectStatus(ScreenDurationRadioButton4); - break; - case SCREENDURATION_SIXTY: - p_ScreenDurationView->SetRadioButtonSelectStatus(ScreenDurationRadioButton5); - break; - case SCREENDURATION_THREE_HUNDRED: - p_ScreenDurationView->SetRadioButtonSelectStatus(ScreenDurationRadioButton6); - break; - default: - // Optionally handle any other unexpected value - break; + p_ScreenDurationView->SetRadioButtonSelectStatus(iter->second); } + else + { + // 处理未知值 + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Unexpected duration value"); + } + } + + /* + * @brief 根据value值出设置选择的亮屏时长内容 + */ + void DisplayBrightnessPresenter::SetSelectScreenDurationLabel(uint32_t value) + { + DisplayBrightnessView *p_DisplayBrightnessView = DisplayBrightnessView::GetInstance(); + if (p_DisplayBrightnessView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DisplayBrightnessView GetInstance fail"); + return; + } + + const std::map durationMap = { + {SCREENDURATION_FIVE, "5秒"}, + {SCREENDURATION_TEN, "10秒"}, + {SCREENDURATION_FIFTEENTH, "15秒"}, + {SCREENDURATION_THIRTY, "30秒"}, + {SCREENDURATION_SIXTY, "60秒"}, + {SCREENDURATION_THREE_HUNDRED, "300秒"}}; + + auto iter = durationMap.find(value); + if (iter != durationMap.end()) + { + p_DisplayBrightnessView->GetSelectScreenDurationLabel()->SetText(iter->second.c_str()); + } + else + { + // Handle unexpected value + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Unexpected duration value"); + } + + p_DisplayBrightnessView->GetSelectScreenDurationLabel()->Invalidate(); return; } @@ -146,7 +186,7 @@ namespace OHOS } else if (strcmp(view.GetViewId(), DISPLAY_BRIGHTNESS_VIEW) == 0) { - //NativeAbility::GetInstance().ChangeSlice(VIEW_SETTING); + // NativeAbility::GetInstance().ChangeSlice(VIEW_SETTING); NativeAbility::GetInstance().Back(); return true; } @@ -185,70 +225,52 @@ namespace OHOS return true; } - /*处理亮屏时长*/ + /* + * @brief 用于处理亮屏时长单选按钮的状态改变.根据用户选择的单选按钮,更新屏幕持续显示时间 + */ bool ScreenDurationRadiobuttonOnChangeListener::OnChange(UICheckBox::UICheckBoxState state) { + if (state != UICheckBox::SELECTED) + { + return true; // 如果不是选中状态,无需处理 + } + DisplayBrightnessView *p_DisplayBrightnessView = DisplayBrightnessView::GetInstance(); if (p_DisplayBrightnessView == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DisplayBrightnessView::GetInstance fail!"); return false; } - switch (state) + + ScreenDurationView *p_ScreenDurationView = p_DisplayBrightnessView->GetScreenDurationView(); + if (p_ScreenDurationView == nullptr) { - case UICheckBox::SELECTED: - if (p_DisplayBrightnessView->GetScreenDurationView() != nullptr) - { - if (p_DisplayBrightnessView->GetScreenDurationView()->GetRadioButton(ScreenDurationRadioButton1) == (UIView *)m_view) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Switched to 5 seconds"); - uapi_setScreenDuration(SCREENDURATION_FIVE); - DisplayBrightnessModel::GetInstance()->SetScreenDurationTime(SCREENDURATION_FIVE); - return true; - } - else if (p_DisplayBrightnessView->GetScreenDurationView()->GetRadioButton(ScreenDurationRadioButton2) == (UIView *)m_view) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Switched to 10 seconds"); - uapi_setScreenDuration(SCREENDURATION_TEN); - DisplayBrightnessModel::GetInstance()->SetScreenDurationTime(SCREENDURATION_TEN); - return true; - } - else if (p_DisplayBrightnessView->GetScreenDurationView()->GetRadioButton(ScreenDurationRadioButton3) == (UIView *)m_view) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Switched to 15 seconds"); - uapi_setScreenDuration(SCREENDURATION_FIFTEENTH); - DisplayBrightnessModel::GetInstance()->SetScreenDurationTime(SCREENDURATION_FIFTEENTH); - return true; - } - else if (p_DisplayBrightnessView->GetScreenDurationView()->GetRadioButton(ScreenDurationRadioButton4) == (UIView *)m_view) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Switched to 30 seconds"); - uapi_setScreenDuration(SCREENDURATION_THIRTY); - DisplayBrightnessModel::GetInstance()->SetScreenDurationTime(SCREENDURATION_THIRTY); - return true; - } - else if (p_DisplayBrightnessView->GetScreenDurationView()->GetRadioButton(ScreenDurationRadioButton5) == (UIView *)m_view) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Switched to 60 seconds"); - uapi_setScreenDuration(SCREENDURATION_SIXTY); - DisplayBrightnessModel::GetInstance()->SetScreenDurationTime(SCREENDURATION_SIXTY); - return true; - } - else if (p_DisplayBrightnessView->GetScreenDurationView()->GetRadioButton(ScreenDurationRadioButton6) == (UIView *)m_view) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Switched to 300 seconds"); - uapi_setScreenDuration(SCREENDURATION_THREE_HUNDRED); - DisplayBrightnessModel::GetInstance()->SetScreenDurationTime(SCREENDURATION_THREE_HUNDRED); - return true; - } - } + return false; // 相关视图不存在,直接返回 + } - break; - case UICheckBox::UNSELECTED: - break; - default: - break; + // 关联单选按钮视图和对应的持续时间 + std::map durationMap = { + {p_ScreenDurationView->GetRadioButton(ScreenDurationRadioButton1), SCREENDURATION_FIVE}, + {p_ScreenDurationView->GetRadioButton(ScreenDurationRadioButton2), SCREENDURATION_TEN}, + {p_ScreenDurationView->GetRadioButton(ScreenDurationRadioButton3), SCREENDURATION_FIFTEENTH}, + {p_ScreenDurationView->GetRadioButton(ScreenDurationRadioButton4), SCREENDURATION_THIRTY}, + {p_ScreenDurationView->GetRadioButton(ScreenDurationRadioButton5), SCREENDURATION_SIXTY}, + {p_ScreenDurationView->GetRadioButton(ScreenDurationRadioButton6), SCREENDURATION_THREE_HUNDRED}}; + + auto it = durationMap.find((UIView *)m_view); + if (it != durationMap.end()) + { + uapi_setScreenDuration(it->second); + DisplayBrightnessModel::GetInstance()->SetScreenDurationTime(it->second); + // 此处可以根据需要,添加对 WEARABLE_LOGE 的调用,打印日志 + DisplayBrightnessPresenter::GetInstance()->SetSelectScreenDurationLabel(it->second); } - return false; + else + { + // 如果没有找到对应的映射项,可能是逻辑错误或数据不一致 + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "No matching screen duration found for selected radiobutton."); + } + + return true; } } \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/DisplayBrightnessView.cpp b/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/DisplayBrightnessView.cpp index eada01aac..56872bf9e 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/DisplayBrightnessView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/DisplayBrightnessView.cpp @@ -15,10 +15,7 @@ namespace OHOS DisplayBrightnessView::~DisplayBrightnessView() { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DisplayBrightnessView::~DisplayBrightnessView"); - if (initViewStatus == true) - { - ClearAll(); - } + ClearAll(); g_pDisplayBrightnessView = nullptr; } @@ -48,6 +45,9 @@ namespace OHOS delete ScreenDurationLabel; ScreenDurationLabel = nullptr; + delete selectScreenDurationLabel; + selectScreenDurationLabel = nullptr; + delete RaiseToBrightnessLabel; RaiseToBrightnessLabel = nullptr; @@ -64,12 +64,12 @@ namespace OHOS if (state == UICheckBox::UICheckBoxState::SELECTED) { DisplayBrightnessModel::GetInstance()->SetRaiseToBrightnessCheckBoxButtonStatus(true); - ConfigModel::GetInstance()->set_condigData_Bool(ConfigModel::ConfigItem::CONFIGMODEL_ITEM_RAISE_TO_WAKE,true); + ConfigModel::GetInstance()->set_condigData_Bool(ConfigModel::ConfigItem::CONFIGMODEL_ITEM_RAISE_TO_WAKE, true); } else { DisplayBrightnessModel::GetInstance()->SetRaiseToBrightnessCheckBoxButtonStatus(false); - ConfigModel::GetInstance()->set_condigData_Bool(ConfigModel::ConfigItem::CONFIGMODEL_ITEM_RAISE_TO_WAKE,false); + ConfigModel::GetInstance()->set_condigData_Bool(ConfigModel::ConfigItem::CONFIGMODEL_ITEM_RAISE_TO_WAKE, false); } delete RaiseToBrightnessCheckBoxButton; @@ -111,18 +111,19 @@ namespace OHOS /// @return true 设置成功,false 失败 bool DisplayBrightnessView::SetTheTitle(void) { - DisplayBrightnessTitleLabel = new UILabel(); + DisplayBrightnessTitleLabel = new UILabelExt(); if (DisplayBrightnessTitleLabel == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DisplayBrightnessView::DisplayBrightnessTitleLabel new fail!"); return false; } - DisplayBrightnessTitleLabel->SetPosition(158, 52); + DisplayBrightnessTitleLabel->SetPosition(93, 52, 280, 40); DisplayBrightnessTitleLabel->SetStyle(STYLE_BACKGROUND_OPA, 0xff); DisplayBrightnessTitleLabel->SetStyle(STYLE_TEXT_FONT, 30); DisplayBrightnessTitleLabel->SetStyle(STYLE_LINE_HEIGHT, 35); DisplayBrightnessTitleLabel->SetText("屏幕与亮度"); - DisplayBrightnessTitleLabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + DisplayBrightnessTitleLabel->SetRollSpeed(40); + DisplayBrightnessTitleLabel->SetLineBreakMode(UILabel::LINE_BREAK_MARQUEE); DisplayBrightnessTitleLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); DisplayBrightnessTitleLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); return true; @@ -141,10 +142,11 @@ namespace OHOS } button->SetPosition(buttonconfig.x, buttonconfig.y, buttonconfig.w, buttonconfig.h); button->SetViewId(buttonconfig.ViewId); - button->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); - button->SetStyle(STYLE_BACKGROUND_OPA, 0x00); - button->SetImageSrc(buttonconfig.ImageSrc, buttonconfig.ImageSrc); - button->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + button->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + button->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + // button->SetImageSrc(buttonconfig.ImageSrc, buttonconfig.ImageSrc); + button->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xffffffff, UIButton::PRESSED); + button->SetStyleForState(STYLE_BACKGROUND_OPA, 0x00, UIButton::PRESSED); button->SetOnClickListener(clickListener); return button; } @@ -163,7 +165,7 @@ namespace OHOS buttonconfig.w = 380; buttonconfig.h = 100; buttonconfig.ViewId = BRINGHTNESSCONTROLBUTTON_VIEW; - buttonconfig.ImageSrc = "/user/res/SETTING_BACKGROUND.bin"; + // buttonconfig.ImageSrc = "/user/res/SETTING_BACKGROUND.bin"; BringhtnessControlButton = SetTheButton(buttonconfig, clickListener); if (nullptr == BringhtnessControlButton) { @@ -183,9 +185,9 @@ namespace OHOS } // 设置标签LabelConfig &labelconfig - UILabel *DisplayBrightnessView::SetUpLabel(LabelConfig &labelconfig) + UILabelExt *DisplayBrightnessView::SetUpLabel(LabelConfig &labelconfig) { - UILabel *label = new UILabel(); + UILabelExt *label = new UILabelExt(); if (label == nullptr) { return nullptr; @@ -193,9 +195,10 @@ 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->SetText(labelconfig.text.c_str()); // 内容 label->SetLineBreakMode(labelconfig.lineBreakMode); // 断行模式。 - label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label->SetRollSpeed(40); + // label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, labelconfig.fontSize); return label; } @@ -208,12 +211,12 @@ namespace OHOS LabelConfig labelconfig = { .left = 90, .top = 153, - .width = 200, - .height = 60, + .width = 250, + .height = 40, .fontSize = 30, .lineHeigh = 35, .text = "亮度调节", - .lineBreakMode = UILabel::LINE_BREAK_ADAPT, + .lineBreakMode = UILabel::LINE_BREAK_MARQUEE, }; BringhtnessControlLabel = SetUpLabel(labelconfig); if (BringhtnessControlLabel == nullptr) @@ -223,6 +226,7 @@ namespace OHOS } /* -------------------------------------------------------------------------- */ labelconfig.top = 273; + labelconfig.width = 180; labelconfig.text = "亮屏时长"; ScreenDurationLabel = SetUpLabel(labelconfig); if (ScreenDurationLabel == nullptr) @@ -233,13 +237,31 @@ namespace OHOS /* -------------------------------------------------------------------------- */ labelconfig.top = 393; labelconfig.text = "抬腕亮屏"; - //labelconfig.text = "4G能力开关"; RaiseToBrightnessLabel = SetUpLabel(labelconfig); if (RaiseToBrightnessLabel == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DisplayBrightnessView::RaiseToBrightnessLabel new fail!"); return false; } + /* -------------------------------------------------------------------------- */ + labelconfig = { + .left = 291, + .top = 273, + .width = 65, + .height = 40, + .fontSize = 30, + .lineHeigh = 35, + .text = "", + .lineBreakMode = UILabel::LINE_BREAK_MARQUEE, + }; + selectScreenDurationLabel = SetUpLabel(labelconfig); + if (selectScreenDurationLabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DisplayBrightnessView::selectScreenDurationLabel new fail!"); + return false; + } + selectScreenDurationLabel->SetTextColor(Color::GetColorFromRGBA(0x66, 0x66, 0x66, 0xff)); + /* -------------------------------------------------------------------------- */ return true; } @@ -284,18 +306,19 @@ namespace OHOS return false; } /* -------------------------------------------------------------------------- */ - imageconfig.x = 43; - imageconfig.y = 360; - imageconfig.w = 380; - imageconfig.h = 100; - imageconfig.ImageSrc = "/user/res/SETTING_BACKGROUND.bin"; + imageconfig = { + .x = 43, + .y = 360, + .w = 380, + .h = 100, + .ImageSrc = "/user/res/SETTING_BACKGROUND.bin", + }; RaiseToBrightnessImage = SetUpImageView(imageconfig); - if (nullptr == NextImage[1]) + if (nullptr == RaiseToBrightnessImage) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DisplayBrightnessView::RaiseToBrightnessImage is nullptr!"); return false; } - return true; } @@ -369,6 +392,10 @@ namespace OHOS { return; } + if (!DisplayBrightnessModel::GetInstance()->SelectScreenDurationLabelInit()) + { + return; + } initViewStatus = true; } @@ -414,6 +441,16 @@ namespace OHOS return p_ScreenDurationView.get(); } + UILabelExt *DisplayBrightnessView::GetSelectScreenDurationLabel(void) + { + if (selectScreenDurationLabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DisplayBrightnessView::GetSelectScreenDurationLabel selectScreenDurationLabel is nullptr!"); + return nullptr; + } + return selectScreenDurationLabel; + } + // 1.切换到“屏幕与亮度”视图 bool DisplayBrightnessView::ChangeDisplayBrightnessView(int16_t thisView) { @@ -515,6 +552,7 @@ namespace OHOS DisplayBrightnessScrollView[DISPLAYBRIGHTNESSVIEW]->Add(ScreenDurationButton); DisplayBrightnessScrollView[DISPLAYBRIGHTNESSVIEW]->Add(BringhtnessControlLabel); DisplayBrightnessScrollView[DISPLAYBRIGHTNESSVIEW]->Add(ScreenDurationLabel); + DisplayBrightnessScrollView[DISPLAYBRIGHTNESSVIEW]->Add(selectScreenDurationLabel); DisplayBrightnessScrollView[DISPLAYBRIGHTNESSVIEW]->Add(NextImage[0]); DisplayBrightnessScrollView[DISPLAYBRIGHTNESSVIEW]->Add(NextImage[1]); DisplayBrightnessScrollView[DISPLAYBRIGHTNESSVIEW]->Add(RaiseToBrightnessImage); diff --git a/code/sdk/application/wearable/fd230app/nativeui/settings/src/SettingPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/settings/src/SettingPresenter.cpp index bebac1aa3..9aac7ce73 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/settings/src/SettingPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/settings/src/SettingPresenter.cpp @@ -62,28 +62,29 @@ namespace OHOS if ((event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) && (event.GetDeltaX() > X_DRAG_OFFSET) && (event.GetDeltaX() > (DOUBLES * MATH_ABS(event.GetDeltaY())))) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingPresenter::OnDrag ChangeSlice(VIEW_APPLIST)"); - /* - GetPreSliceId作用:是从已存储的切片中获取上一个切片的ID,并且在切片数小于2的情况下返回一个无效的切片ID。 - */ - uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId(); - if (preSlice == VIEW_APPLIST) - { - NativeAbility::GetInstance().ChangeSlice(preSlice); - return true; - } - else - { - NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN); - return true; - } + // WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingPresenter::OnDrag ChangeSlice(VIEW_APPLIST)"); + // /* + // GetPreSliceId作用:是从已存储的切片中获取上一个切片的ID,并且在切片数小于2的情况下返回一个无效的切片ID。 + // */ + // uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId(); + // if (preSlice == VIEW_APPLIST) + // { + // NativeAbility::GetInstance().ChangeSlice(preSlice); + // return true; + // } + // else + // { + // NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN); + // return true; + // } + NativeAbility::GetInstance().Back(); } - return false; + return true; } // 增加按键事件 bool SettingPresenter::OnKeyAct(UIView &view, const KeyEvent &event) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SettingPresenter::OnKeyAct"); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SettingPresenter::OnKeyAct"); uint16 keyID = event.GetKeyId(); uint16 keyState = event.GetState(); // 如果是power键就返回上一级 @@ -116,7 +117,7 @@ namespace OHOS else { NativeAbility::GetInstance().EnterSlice(SettingModel::GetInstance().GetSettingIdToViewId().at(index)); - //NativeAbility::GetInstance().ChangeSlice(SettingModel::GetInstance().GetSettingIdToViewId().at(index)); + // NativeAbility::GetInstance().ChangeSlice(SettingModel::GetInstance().GetSettingIdToViewId().at(index)); /* -------------------------------------------------------------------------- */ #if 0 if (index == SETTING_ITEM_TWO)