手电筒界面亮度设置优化
authorluozheng <1732036298@qq.com>
Sun, 3 Nov 2024 07:59:09 +0000 (15:59 +0800)
committerluozheng <1732036298@qq.com>
Sun, 3 Nov 2024 07:59:09 +0000 (15:59 +0800)
code/sdk/application/wearable/fd230app/nativelauncher/include/UiConfig.h
code/sdk/application/wearable/fd230app/nativeui/flashlight/src/FlashlightPresenter.cpp
code/sdk/application/wearable/fd230app/nativeui/flashlight/src/FlashlightView.cpp

index 0f7e5b8..b8afb16 100644 (file)
@@ -79,6 +79,7 @@ namespace OHOS
 
 #define MIN_BRIGHTNESS 51   /*最低亮度*/
 #define MAX_BRIGHTNESS 255  /*最高亮度*/
+#define MAX_BRIGHTNESS_HALF 127  /*最高亮度的一半*/
 
     static constexpr const char *CARD_CONFIG_PATH = "/user/cardconfig.bin";
 
index 3b3394d..9564206 100644 (file)
@@ -2,7 +2,7 @@
  * @Author: luozheng 1732036298@qq.com
  * @Date: 2024-04-10 17:32:38
  * @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-10-23 18:16:39
+ * @LastEditTime: 2024-11-03 15:58:20
  * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/flashligh/src/FlashlightPresenter.cpp
  */
 
@@ -49,6 +49,7 @@ namespace OHOS
     {
         Presenter<FlashlightView>::OnStart();
 
+        uapi_setScreenBrightness(MAX_BRIGHTNESS);
         FlashlightModel::GetInstance().FlashlightStartTimer();
         ScreenAlwaysOnCtr(OPEN_SCREEN_ALWAYS_ON);
     }
@@ -67,6 +68,7 @@ namespace OHOS
     {
         Presenter<FlashlightView>::OnStop();
 
+        uapi_setScreenBrightness(ConfigModel::GetInstance()->GetBrightness());//退出APP将亮度恢复到ConfigModel中设置的亮度值
         ScreenAlwaysOnCtr(CANCEL_SCREEN_ALWAYS_ON);
         FlashlightModel::GetInstance().FlashlightStopTimer();
         FlashlightModel::GetInstance().SaveSettingInfo();
@@ -196,6 +198,7 @@ namespace OHOS
         
         if(0 == view.GetCurrentPage())
         {
+            uapi_setScreenBrightness(MAX_BRIGHTNESS);//恢复最高亮度
             FlashlightModel::GetInstance().FlashlightStartTimer();
             ScreenAlwaysOnCtr(OPEN_SCREEN_ALWAYS_ON);
         }
index 64eb424..fe82a48 100644 (file)
@@ -2,7 +2,7 @@
  * @Author: luozheng 1732036298@qq.com
  * @Date: 2024-04-10 17:32:08
  * @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-10-03 19:51:39
+ * @LastEditTime: 2024-11-03 15:50:47
  * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/flashligh/src/FlashlightView.cpp
  */
 #include "flashlight/include/FlashlightView.h"
@@ -147,7 +147,6 @@ namespace OHOS
     {
         if(nullptr != GroupMain_)
         {
-            uapi_setScreenBrightness(ConfigModel::GetInstance()->GetBrightness());
             GroupMain_->RemoveAll();
             delete GroupMain_;
             GroupMain_ = nullptr;
@@ -206,12 +205,12 @@ namespace OHOS
         if(true == flag)
         {
             // GroupMain_->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full);
-            uapi_setScreenBrightness(127);//50%
+            uapi_setScreenBrightness(MAX_BRIGHTNESS_HALF);//50%
         }
         else
         {
             // GroupMain_->SetStyle(STYLE_BACKGROUND_COLOR, presenter_->GetColorValue());
-            uapi_setScreenBrightness(0xff);//100%
+            uapi_setScreenBrightness(MAX_BRIGHTNESS);//100%
         }
 
         Draw();