diff --git a/example/ohos/build-profile.json5 b/example/ohos/build-profile.json5 index e8c7d7eb0de5e1a65194730cc12e2a4c3d3e4a92..1d12140d202702d7c73d64f1b291fe5c45a660ce 100644 --- a/example/ohos/build-profile.json5 +++ b/example/ohos/build-profile.json5 @@ -1,18 +1,3 @@ -/* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - { "app": { "signingConfigs": [], @@ -20,9 +5,8 @@ { "name": "default", "signingConfig": "default", - "compileSdkVersion": "4.1.0(11)", - "compatibleSdkVersion": "4.1.0(11)", - "runtimeOS": "HarmonyOS", + "compatibleSdkVersion": "5.0.0(12)", + "runtimeOS": "HarmonyOS" } ] }, diff --git a/example/ohos/entry/oh-package.json5 b/example/ohos/entry/oh-package.json5 index 803b25293388deda7b9a05a21b5aeadeb716b4d5..322f1ee940c25a2ab6194792d174b3141abd6363 100644 --- a/example/ohos/entry/oh-package.json5 +++ b/example/ohos/entry/oh-package.json5 @@ -5,5 +5,7 @@ "main": "", "author": "", "license": "", - "dependencies": {} + "dependencies": { + "screen": "file:..\\har\\screen.har" + } } \ No newline at end of file diff --git a/example/ohos/hvigor/hvigor-config.json5 b/example/ohos/hvigor/hvigor-config.json5 index 491a0712f4ad9b05d079bf177fbc08424065bf7c..541ba35711b75986f9295410ee38fdb8f2572878 100644 --- a/example/ohos/hvigor/hvigor-config.json5 +++ b/example/ohos/hvigor/hvigor-config.json5 @@ -14,8 +14,7 @@ */ { - "hvigorVersion": "4.1.2", + "modelVersion": "5.0.0", "dependencies": { - "@ohos/hvigor-ohos-plugin": "4.1.2" } } \ No newline at end of file diff --git a/example/ohos/hvigorfile.ts b/example/ohos/hvigorfile.ts index 0a2abe3cb928957b3c7d78d89451e335dd2fe60e..91caad7b7aa80dee3c04b05a35a919769de65644 100644 --- a/example/ohos/hvigorfile.ts +++ b/example/ohos/hvigorfile.ts @@ -12,8 +12,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - - import { appTasks } from '@ohos/hvigor-ohos-plugin'; export default { diff --git a/example/ohos/hvigorw b/example/ohos/hvigorw deleted file mode 100644 index 778c9a2866b630b83e3153937c1ac3c71289823b..0000000000000000000000000000000000000000 --- a/example/ohos/hvigorw +++ /dev/null @@ -1,61 +0,0 @@ -#!/bin/bash - -# Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# ---------------------------------------------------------------------------- -# Hvigor startup script, version 1.0.0 -# -# Required ENV vars: -# ------------------ -# NODE_HOME - location of a Node home dir -# or -# Add /usr/local/nodejs/bin to the PATH environment variable -# ---------------------------------------------------------------------------- - -HVIGOR_APP_HOME=$(dirname $(readlink -f $0)) -HVIGOR_WRAPPER_SCRIPT=${HVIGOR_APP_HOME}/hvigor/hvigor-wrapper.js -warn() { - echo "" - echo -e "\033[1;33m`date '+[%Y-%m-%d %H:%M:%S]'`$@\033[0m" -} - -error() { - echo "" - echo -e "\033[1;31m`date '+[%Y-%m-%d %H:%M:%S]'`$@\033[0m" -} - -fail() { - error "$@" - exit 1 -} - -# Determine node to start hvigor wrapper script -if [ -n "${NODE_HOME}" ];then - EXECUTABLE_NODE="${NODE_HOME}/bin/node" - if [ ! -x "$EXECUTABLE_NODE" ];then - fail "ERROR: NODE_HOME is set to an invalid directory,check $NODE_HOME\n\nPlease set NODE_HOME in your environment to the location where your nodejs installed" - fi -else - EXECUTABLE_NODE="node" - which ${EXECUTABLE_NODE} > /dev/null 2>&1 || fail "ERROR: NODE_HOME is not set and not 'node' command found in your path" -fi - -# Check hvigor wrapper script -if [ ! -r "$HVIGOR_WRAPPER_SCRIPT" ];then - fail "ERROR: Couldn't find hvigor/hvigor-wrapper.js in ${HVIGOR_APP_HOME}" -fi - -# start hvigor-wrapper script -exec "${EXECUTABLE_NODE}" \ - "${HVIGOR_WRAPPER_SCRIPT}" "$@" diff --git a/example/ohos/hvigorw.bat b/example/ohos/hvigorw.bat deleted file mode 100644 index 6941146915901bbe88a0e274e71b25e4e9e2d000..0000000000000000000000000000000000000000 --- a/example/ohos/hvigorw.bat +++ /dev/null @@ -1,79 +0,0 @@ -/* -* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Hvigor startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -set WRAPPER_MODULE_PATH=%APP_HOME%\hvigor\hvigor-wrapper.js -set NODE_EXE=node.exe - -goto start - -:start -@rem Find node.exe -if defined NODE_HOME goto findNodeFromNodeHome - -%NODE_EXE% --version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute - -echo. -echo ERROR: NODE_HOME is not set and no 'node' command could be found in your PATH. -echo. -echo Please set the NODE_HOME variable in your environment to match the -echo location of your NodeJs installation. - -goto fail - -:findNodeFromNodeHome -set NODE_HOME=%NODE_HOME:"=% -set NODE_EXE_PATH=%NODE_HOME%/%NODE_EXE% - -if exist "%NODE_EXE_PATH%" goto execute -echo. -echo ERROR: NODE_HOME is not set and no 'node' command could be found in your PATH. -echo. -echo Please set the NODE_HOME variable in your environment to match the -echo location of your NodeJs installation. - -goto fail - -:execute -@rem Execute hvigor -"%NODE_EXE%" %WRAPPER_MODULE_PATH% %* - -if "%ERRORLEVEL%" == "0" goto hvigorwEnd - -:fail -exit /b 1 - -:hvigorwEnd -if "%OS%" == "Windows_NT" endlocal - -:end diff --git a/example/ohos/oh-package.json5 b/example/ohos/oh-package.json5 index 218e0a57e7118fec5d88756eee38d245d9f63782..13ef4083a181c85cfebb4eaa88e94efd339c3978 100644 --- a/example/ohos/oh-package.json5 +++ b/example/ohos/oh-package.json5 @@ -1,19 +1,5 @@ -/* -* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - { + "modelVersion": "5.0.0", "name": "example", "version": "1.0.0", "description": "Please describe the basic information.", @@ -27,6 +13,8 @@ "@ohos/hypium": "1.0.6" }, "overrides": { - "@ohos/flutter_ohos": "file:./har/flutter.har" + "@ohos/flutter_ohos": "file:./har/flutter.har", + "screen": "file:./har/screen.har", + "@ohos/flutter_module": "file:./entry" } -} +} \ No newline at end of file diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 87170c318f0e02cb6844b6f014b00b37d994116e..acc31090626ddb6f2f7add1062ecc31afc9af953 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -1,17 +1,15 @@ -/* -* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ +# Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. name: screen_example description: Demonstrates how to use the screen plugin. diff --git a/ohos/src/main/ets/flutter/plugins/screen/screen/FlutterScreenPlugin.ets b/ohos/src/main/ets/flutter/plugins/screen/screen/FlutterScreenPlugin.ets index 579fb09fbcccd30fc3ee68b9a3125c0ce0bae7b7..3f4a508666fd46d90ffe88c14bb9e76508e1432a 100644 --- a/ohos/src/main/ets/flutter/plugins/screen/screen/FlutterScreenPlugin.ets +++ b/ohos/src/main/ets/flutter/plugins/screen/screen/FlutterScreenPlugin.ets @@ -101,6 +101,11 @@ export class FlutterScreenPlugin implements FlutterPlugin, MethodCallHandler { } getBrightness(): number { + const brightness = this.mainWindow?.getWindowProperties().brightness; + if (brightness && brightness >= 0) { + return brightness + } + // 首次未获取到窗口亮度时返回系统设置的亮度 let result: number; try { // the application is using the system brightness diff --git a/pubspec.yaml b/pubspec.yaml index 0cb10a55e0833bd530f897dd7fe45ce32d0b710c..d06c40e65cf4c7afc99ee3bb32d8cf50cf04abb1 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -22,7 +22,6 @@ flutter: package: flutter.plugins.screen.screen pluginClass: ScreenPlugin ohos: - package: flutter.plugins.screen.screen pluginClass: ScreenPlugin ios: pluginClass: ScreenPlugin