diff --git a/ArkUI/entry/src/main/ets/entryability/MyAbilityStage.ets b/ArkUI/entry/src/main/ets/entryability/MyAbilityStage.ets new file mode 100644 index 0000000000000000000000000000000000000000..a4ccd99b1f1eac6832ee93898e6d92b3bba459fe --- /dev/null +++ b/ArkUI/entry/src/main/ets/entryability/MyAbilityStage.ets @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2024 Huawei Device 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. +*/ + +/* +* FAQ:在深色模式切换下如何适配状态栏颜色? +*/ + +import { AbilityStage, Configuration, ConfigurationConstant } from '@kit.AbilityKit'; + + +class MyAbilityStage extends AbilityStage { + // [Start dark_mode_switch_status_bar_color_ability_stage] + // EntryAbility.ets + + // 监听系统配置变更 + onConfigurationUpdate(newConfig: Configuration): void { + let newColorMode = newConfig.colorMode; + let currentColorMode = AppStorage.get('currentColorMode'); + if (newColorMode === currentColorMode) { + return; + } + // 更新缓存中的颜色模式 + AppStorage.setOrCreate('currentColorMode', newConfig.colorMode); + } + // [End dark_mode_switch_status_bar_color_ability_stage] +} \ No newline at end of file diff --git a/ArkUI/entry/src/main/resources/en_US/element/string.json b/ArkUI/entry/src/main/resources/en_US/element/string.json index bb8992fc161d11ecf08130fdfed106d503c33cd5..5bfed3b15bdbd737da4f4304d115c8a36c6b1397 100644 --- a/ArkUI/entry/src/main/resources/en_US/element/string.json +++ b/ArkUI/entry/src/main/resources/en_US/element/string.json @@ -1,23 +1,3 @@ -/* -* Copyright (c) 2024 Huawei Device 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. -*/ - -/* -* FAQ:ArkUI组件的字符串中如何实现字符串变量拼接 -*/ - -// [Start implementing_string_variable_concatenation_three] { "string": [ { @@ -33,5 +13,4 @@ "value": "label" } ] -} -// [End implementing_string_variable_concatenation_three] \ No newline at end of file +} \ No newline at end of file diff --git a/ArkUI/entry/src/main/resources/zh_CN/element/string.json b/ArkUI/entry/src/main/resources/zh_CN/element/string.json index 5d385d52dc45b9e30c7efbf7184e2d8ca40aae29..a4518a253bd644e47619084944b83c1f747f83fd 100644 --- a/ArkUI/entry/src/main/resources/zh_CN/element/string.json +++ b/ArkUI/entry/src/main/resources/zh_CN/element/string.json @@ -1,23 +1,3 @@ -/* -* Copyright (c) 2024 Huawei Device 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. -*/ - -/* -* FAQ:ArkUI组件的字符串中如何实现字符串变量拼接 -*/ - -// [Start implementing_string_variable_concatenation_two] { "string": [ { @@ -33,5 +13,4 @@ "value": "label" } ] -} -// [Start implementing_string_variable_concatenation_two] \ No newline at end of file +} \ No newline at end of file