diff --git a/AppScope/app.json5 b/AppScope/app.json5 new file mode 100644 index 0000000000000000000000000000000000000000..6893318448334d0967634126de8fe325ed593795 --- /dev/null +++ b/AppScope/app.json5 @@ -0,0 +1,10 @@ +{ + "app": { + "bundleName": "com.example.mapliveviewsample", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:layered_image", + "label": "$string:app_name" + } +} \ No newline at end of file diff --git a/AppScope/resources/base/element/string.json b/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..bfd2680cc5f0d20c1522483e82a8ea9100d52ff6 --- /dev/null +++ b/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "LiveViewLockScreen" + } + ] +} diff --git a/AppScope/resources/base/media/background.png b/AppScope/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/AppScope/resources/base/media/background.png differ diff --git a/AppScope/resources/base/media/foreground.png b/AppScope/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f Binary files /dev/null and b/AppScope/resources/base/media/foreground.png differ diff --git a/AppScope/resources/base/media/layered_image.json b/AppScope/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/AppScope/resources/base/media/layered_image.json @@ -0,0 +1,7 @@ +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } +} \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..18795a48d6b12fcdc1aa7bac9a9cb99f83815267 --- /dev/null +++ b/LICENSE @@ -0,0 +1,78 @@ + Copyright (c) 2025 Huawei Device Co., Ltd. All rights reserved. + + 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. + +Apache License, Version 2.0 +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. + +"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. + +"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. + +2. Grant of Copyright License. + +Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. + +Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. + +4. Redistribution. + +You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: +1.You must give any other recipients of the Work or Derivative Works a copy of this License; and +2.You must cause any modified files to carry prominent notices stating that You changed the files; and +3.You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and +4.If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. + +You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. + +5. Submission of Contributions. + +Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. + +6. Trademarks. + +This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. + +Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. + +In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. + +While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS \ No newline at end of file diff --git a/README.en.md b/README.en.md deleted file mode 100644 index 6afc900231b651ba79ff9d7d8e1552e7cf82661b..0000000000000000000000000000000000000000 --- a/README.en.md +++ /dev/null @@ -1,36 +0,0 @@ -# LiveViewLockScreen - -#### Description -{**When you're done, you can delete the content in this README and update the file with details for others getting started with your repository**} - -#### Software Architecture -Software architecture description - -#### Installation - -1. xxxx -2. xxxx -3. xxxx - -#### Instructions - -1. xxxx -2. xxxx -3. xxxx - -#### Contribution - -1. Fork the repository -2. Create Feat_xxx branch -3. Commit your code -4. Create Pull Request - - -#### Gitee Feature - -1. You can use Readme\_XXX.md to support different languages, such as Readme\_en.md, Readme\_zh.md -2. Gitee blog [blog.gitee.com](https://blog.gitee.com) -3. Explore open source project [https://gitee.com/explore](https://gitee.com/explore) -4. The most valuable open source project [GVP](https://gitee.com/gvp) -5. The manual of Gitee [https://gitee.com/help](https://gitee.com/help) -6. The most popular members [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/) diff --git a/README.md b/README.md index f587d333100add09db052b536d3f292667b6fd51..6e0b5f79a1314d1b778f62935d46368c4f1fe58c 100644 --- a/README.md +++ b/README.md @@ -1,39 +1,78 @@ -# LiveViewLockScreen +# 锁屏沉浸实况窗 -#### 介绍 -{**以下是 Gitee 平台说明,您可以替换此简介** -Gitee 是 OSCHINA 推出的基于 Git 的代码托管平台(同时支持 SVN)。专为开发者提供稳定、高效、安全的云端软件开发协作平台 -无论是个人、团队、或是企业,都能够用 Gitee 实现代码托管、项目管理、协作开发。企业项目请看 [https://gitee.com/enterprises](https://gitee.com/enterprises)} +## 简介 -#### 软件架构 -软件架构说明 +“Live View Kit”基于HarmonyOS实现了即时配送等多个场景下实况窗的创建、更新和结束功能。基于不同的场景,皆提供了定制的状态节点,帮助用户聚焦关键信息,提升用户体验。 +锁屏沉浸实况窗则是应用进一步展示实时活动状态的通道,系统通过实况窗服务(Live View Kit),将重要信息展示在锁屏界面,让用户一览无余,无需进入应用就能获取活动最新状态,适用于实时性要求高、需要用户及时了解状态的场景。 +## 相关概念 -#### 安装教程 +- 实况窗:实况窗是一种帮助用户聚焦正在进行的任务,方便快速查看和即时处理的通知形态。实况窗具有时效性、时段性、变化性的特点。 -1. xxxx -2. xxxx -3. xxxx +## 效果预览 -#### 使用说明 +锁屏界面: -1. xxxx -2. xxxx -3. xxxx +![](screenshots/phone_lock_screen.png) -#### 参与贡献 +## 使用说明 -1. Fork 本仓库 -2. 新建 Feat_xxx 分支 -3. 提交代码 -4. 新建 Pull Request +1. 打开应用后自动开启实况窗与沉浸实况窗,主页面无具体功能,仅做展示使用。 +2. 上划退出到桌面后,点击位于页面导航栏左侧的胶囊态实况窗或下拉查看消息通知,可查看实况窗卡片页面。 -#### 特技 +3. 点击锁屏键锁屏后再次点击锁屏键激活屏幕,可查看锁屏沉浸实况窗。 -1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md -2. Gitee 官方博客 [blog.gitee.com](https://blog.gitee.com) -3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解 Gitee 上的优秀开源项目 -4. [GVP](https://gitee.com/gvp) 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目 -5. Gitee 官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help) -6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/) +4. 本Sample仅提供在本地创建、更新与结束实况窗的能力(不能后台更新,若要后台更新,请使用Push Kit)。若要使用Push Kit更新,可参考[推送实况窗消息服务](https://developer.huawei.com/consumer/cn/doc/harmonyos-guides/push-update-liveview),用已有服务器调用对应的REST API。 + +## 工程目录 + +``` +├─entry/src/main/ets +│ ├───constant +│ │ └───Constant.ets // 常量 +│ ├───entryability +│ │ └───EntryAbility.ets // EntryAbility +│ ├───liveview +│ │ ├───LiveViewExtAbility.ets // 实况窗 +│ │ └───LockScreenPage.ets // 锁屏页面 +│ ├───model +│ │ └───RouteDataModel.ets // 导航数据Model +│ ├───pages +│ │ └───Index.ets // 主页面 +│ ├───utils +│ │ ├───BreakpointUtil.ets // 断点工具类 +│ │ ├───LiveView.ets // 实况窗类 +│ │ └───LiveViewUtil.ets // 实况窗工具类 +│ ├───view +│ │ ├───RoadView.ets // 道路 +│ │ ├───TrafficInfoView.ets // 导航信息 +│ │ └───TrafficView.ets // 导航页面 +│ └───viewmodel +│ └───RouteDataViewModel.ets // 导航数据ViewModel +└───entry/src/main/resources + +``` + +## 具体实现 + +1. HomePage主页面在创建后,创建实况窗和创建定时任务,每间隔固定时间调用liveViewManager.updateLiveView()接口更新实况窗,并通过commonEventManager.publish()接口传递新的参数给沉浸实况窗页面,实现实况窗和沉浸实况窗更新。 + +## 相关权限 + +1. 若您需要使用本实例,请替换AppScope/app.json5文件内的bundleName为您的包名。 + ![img.png](screenshots/img.png) + +2. 若您自己的包名未申请实况窗与沉浸实况窗权益,请参考[Live View Kit(实况窗服务)开发准备](https://developer.huawei.com/consumer/cn/doc/harmonyos-guides/liveview-preparations),先开通推送服务权益与实况窗权益。 + +3. ohos.permission.KEEP_BACKGROUND_RUNNING 获取应用后台运行权限。 + +## 约束与限制 + +1.本示例仅支持标准系统上运行,支持设备:华为手机; + +2.HarmonyOS系统:HarmonyOS 5.0.0 Developer Release及以上; + +3.DevEco Studio版本:DevEco Studio 5.0.0 Developer Release及以上; + +4.HarmonyOS SDK版本:HarmonyOS 5.0.0 Developer Release SDK及以上。 \ No newline at end of file diff --git a/build-profile.json5 b/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..1e69556b3411622cb2e87a87389653bb34f1b148 --- /dev/null +++ b/build-profile.json5 @@ -0,0 +1,41 @@ +{ + "app": { + "signingConfigs": [], + "products": [ + { + "name": "default", + "signingConfig": "default", + "compatibleSdkVersion": "5.0.0(12)", + "runtimeOS": "HarmonyOS", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/entry/build-profile.json5 b/entry/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..b695582d3680556f4cce2ec518f65720a9413ca3 --- /dev/null +++ b/entry/build-profile.json5 @@ -0,0 +1,28 @@ +{ + "apiType": "stageMode", + "buildOption": { + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": true, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/entry/hvigorfile.ts b/entry/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..c6edcd90486dd5a853cf7d34c8647f08414ca7a3 --- /dev/null +++ b/entry/hvigorfile.ts @@ -0,0 +1,6 @@ +import { hapTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/entry/obfuscation-rules.txt b/entry/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..46686c4feca708e7a0936210a2ddac65938089c6 --- /dev/null +++ b/entry/obfuscation-rules.txt @@ -0,0 +1,22 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/entry/oh-package.json5 b/entry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..248c3b7541a589682a250f86a6d3ecf7414d2d6a --- /dev/null +++ b/entry/oh-package.json5 @@ -0,0 +1,10 @@ +{ + "name": "entry", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": {} +} + diff --git a/entry/src/main/ets/constant/Constant.ets b/entry/src/main/ets/constant/Constant.ets new file mode 100644 index 0000000000000000000000000000000000000000..cb5fef1237ab98487f8c675038c9f9e257a19425 --- /dev/null +++ b/entry/src/main/ets/constant/Constant.ets @@ -0,0 +1,20 @@ +/* +* Copyright (c) 2025 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. +*/ + +export class Constants { + public static readonly BREAK_POINT_SM: string = 'sm'; + public static readonly BREAK_POINT_MD: string = 'md'; + public static readonly BREAK_POINT_LG: string = 'lg'; +} \ No newline at end of file diff --git a/entry/src/main/ets/entryability/EntryAbility.ets b/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..d95a8a6e548bd2dd95bedcac11e6cce59d4f619b --- /dev/null +++ b/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,123 @@ +/* +* Copyright (c) 2025 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. +*/ + +import { ConfigurationConstant, UIAbility } from '@kit.AbilityKit'; +import { display, window } from '@kit.ArkUI'; +import { BusinessError } from '@kit.BasicServicesKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { Constants } from '../constant/Constant'; + +const TAG: string = '[EntryAbility]'; + +export default class EntryAbility extends UIAbility { + private horizontalBreakpoint: string = ''; + private verticalBreakpoint: string = ''; + + private updateBreakpoint(windowSize: window.Size): void { + try { + let windowWidthVp: number = windowSize.width / display.getDefaultDisplaySync().densityPixels; + let windowHeightVp: number = windowSize.height / display.getDefaultDisplaySync().densityPixels; + let windowRatio: number = windowWidthVp / windowHeightVp; + let horizontalBreakpoint: string = ''; + let verticalBreakpoint: string = ''; + if (windowWidthVp < 600) { + horizontalBreakpoint = Constants.BREAK_POINT_SM; + } else if (windowWidthVp < 840) { + horizontalBreakpoint = Constants.BREAK_POINT_MD; + } else { + horizontalBreakpoint = Constants.BREAK_POINT_LG; + } + if (this.horizontalBreakpoint !== horizontalBreakpoint) { + this.horizontalBreakpoint = horizontalBreakpoint; + AppStorage.setOrCreate('horizontalBreakpoint', this.horizontalBreakpoint); + } + if (windowRatio < 0.8) { + verticalBreakpoint = Constants.BREAK_POINT_SM; + } else if (windowRatio > 1.2) { + verticalBreakpoint = Constants.BREAK_POINT_LG; + } else { + verticalBreakpoint = Constants.BREAK_POINT_MD; + } + if (this.verticalBreakpoint !== verticalBreakpoint) { + this.verticalBreakpoint = verticalBreakpoint; + AppStorage.setOrCreate('verticalBreakpoint', this.verticalBreakpoint); + } + } catch (error) { + hilog.error(0x0000, TAG, `updateBreakpoint catch err:`, (error as BusinessError).message); + } + } + + onCreate(): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(0x0000, TAG, '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, TAG, '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, TAG, '%{public}s', 'Ability onWindowStageCreate'); + windowStage.getMainWindow().then((windowObj: window.Window) => { + try { + windowObj.on('windowSizeChange', (windowSize) => { + this.updateBreakpoint(windowSize); + }); + + windowObj.setWindowSystemBarProperties({ + statusBarContentColor: '#ffffff', + }).then(() => { + hilog.info(0x0000, TAG, '%{public}s', 'Succeeded in setting the system bar properties.'); + }).catch((err: BusinessError) => { + hilog.error(0x0000, TAG, 'Failed to set the window layout to full-screen mode. Cause:', err.message); + }); + + windowObj.setWindowLayoutFullScreen(true).then(() => { + hilog.info(0x0000, TAG, '%{public}s', 'Succeeded in setting the window layout to full-screen mode'); + }).catch((err: BusinessError) => { + hilog.error(0x0000, TAG, 'Failed to set the window layout to full-screen mode. Cause:', err.message); + }); + } catch (error) { + hilog.error(0x0000, TAG, '%{public}s', + `onWindowStageCreate failed. Cause code: ${error.code}, message: ${error.message}`); + } + }).catch((err: BusinessError) => { + hilog.error(0x0000, TAG, `Failed to get main window. Cause:`, err.message); + }); + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, TAG, 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, TAG, 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, TAG, '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, TAG, '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, TAG, '%{public}s', 'Ability onBackground'); + } +} \ No newline at end of file diff --git a/entry/src/main/ets/liveview/LiveViewExtAbility.ets b/entry/src/main/ets/liveview/LiveViewExtAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..ed753c1f8a24de4a1f79a4d66eaaa495087bf75d --- /dev/null +++ b/entry/src/main/ets/liveview/LiveViewExtAbility.ets @@ -0,0 +1,148 @@ +/* +* Copyright (c) 2025 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. +*/ + +// [Start windowSizeListener] +import { AbilityConstant, UIExtensionContentSession, Want } from '@kit.AbilityKit'; +// [Start updateBreakPoint] +import { display, window } from '@kit.ArkUI'; +// [StartExclude updateBreakPoint] +// [StartExclude windowSizeListener] +// [Start subscribeCommonEvent] +import { BusinessError, commonEventManager } from '@kit.BasicServicesKit'; +// [StartExclude subscribeCommonEvent] +import { LiveViewLockScreenExtensionAbility } from '@kit.LiveViewKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { Constants } from '../constant/Constant'; +import { LaneData } from '../model/RouteDataModel'; + +const TAG: string = '[LiveViewExtAbility]'; + +// Main class for lock screen live view extension, handles live view presentation on lock screen. +export default class LiveViewExtAbility extends LiveViewLockScreenExtensionAbility { + // Common event subscriber for handling system events. + private subscriber: commonEventManager.CommonEventSubscriber | null = null; + private verticalBreakpoint: string = ''; + + // [EndExclude updateBreakPoint] + // Distinguish page layout using vertical breakpoints. + private updateBreakPoint(windowSize: window.Size): void { + try { + let windowWidthVp: number = windowSize.width / display.getDefaultDisplaySync().densityPixels; + let windowHeightVp: number = windowSize.height / display.getDefaultDisplaySync().densityPixels; + let windowRatio: number = windowWidthVp / windowHeightVp; + let verticalBreakpoint: string = Constants.BREAK_POINT_SM; + // Vertical breakpoints are distinguished by aspect ratio. + if (windowRatio < 0.8) { + verticalBreakpoint = Constants.BREAK_POINT_SM; + } else if (windowRatio > 1.2) { + verticalBreakpoint = Constants.BREAK_POINT_LG; + } else { + verticalBreakpoint = Constants.BREAK_POINT_MD; + } + if (this.verticalBreakpoint !== verticalBreakpoint) { + this.verticalBreakpoint = verticalBreakpoint; + AppStorage.setOrCreate('verticalBreakpoint', this.verticalBreakpoint); + } + hilog.info(0x0000, TAG, `updateBreakpoint ${verticalBreakpoint}`); + } catch (error) { + hilog.error(0x0000, TAG, `updateBreakpoint catch err:`, (error as BusinessError).message); + } + } + // [End updateBreakPoint] + + onCreate(_launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, TAG, 'LiveViewLockScreenExtAbility onCreate begin.'); + } + + onForeground(): void { + hilog.info(0x0000, TAG, 'LiveViewLockScreenExtAbility onForeground begin.'); + } + + onBackground(): void { + hilog.info(0x0000, TAG, 'LiveViewLockScreenExtAbility onBackground begin.'); + } + + onDestroy(): void | Promise { + hilog.info(0x0000, TAG, 'LiveViewLockScreenExtAbility onDestroy begin.'); + } + + // [Start createLiveView] + // Core logic when creating UI session. + onSessionCreate(_want: Want, session: UIExtensionContentSession): void { + // [StartExclude createLiveView] + hilog.info(0x0000, TAG, 'LiveViewLockScreenExtAbility onSessionCreate begin.'); + let param: Record = { + 'session': session + }; + // [EndExclude windowSizeListener] + // Window size listener. + const extensionWindow = session.getUIExtensionWindowProxy(); + extensionWindow.on('windowSizeChange', (windowSize: window.Size) => { + this.updateBreakPoint(windowSize); + }); + // [End windowSizeListener] + // [EndExclude subscribeCommonEvent] + // Create state storage (for cross-page data sharing). + let storage: LocalStorage = new LocalStorage(param); + // Initialize event subscription. + let subscribeInfo: commonEventManager.CommonEventSubscribeInfo = { + events: ['live_view_lock_screen'], + publisherBundleName: 'com.example.mapliveviewsample', + priority: 0 + }; + commonEventManager.createSubscriber(subscribeInfo, + (error: BusinessError, data: commonEventManager.CommonEventSubscriber) => { + if (error) { + hilog.error(0x0000, TAG, '%{public}s', + `Failed to create subscriber. code is ${error.code} message is ${error.message}.`); + return; + } + this.subscriber = data; + hilog.info(0x0000, TAG, '%{public}s', 'Succeeded in creating subscriber.'); + // Event handling logic. + commonEventManager.subscribe(this.subscriber, + async (error: BusinessError, data: commonEventManager.CommonEventData) => { + if (error) { + hilog.error(0x0000, TAG, '%{public}s', + `Failed to subscribe commonEvent. code is ${error.code} message is ${error.message}.`); + return; + } + hilog.info(0x0000, TAG, '%{public}s', 'Succeeded in subscribe commonEvent success.'); + if (data.parameters) { + let laneData = data.parameters['roadData'] as LaneData; + storage.setOrCreate('laneData', laneData); + hilog.info(0x0000, TAG, '%{public}s', 'Succeeded in receive commonEvent.'); + } + }); + }) + // [End subscribeCommonEvent] + // [EndExclude createLiveView] + session.loadContent('liveview/LockScreenPage', storage); + } + + // [End createLiveView] + + // Cleanup operations when destroying UI session + onSessionDestroy(): void { + commonEventManager.unsubscribe(this.subscriber, () => { + this.subscriber = null; + }); + hilog.info(0x0000, TAG, 'LiveViewLockScreenExtAbility onSessionDestroy begin.'); + } + + onConfigurationUpdate(): void { + hilog.info(0x0000, TAG, 'LiveViewLockScreenExtAbility onConfigurationUpdate begin.'); + } +} \ No newline at end of file diff --git a/entry/src/main/ets/liveview/LockScreenPage.ets b/entry/src/main/ets/liveview/LockScreenPage.ets new file mode 100644 index 0000000000000000000000000000000000000000..76679c63f4b4757a2f3a1c0a8611ede851c3ad5a --- /dev/null +++ b/entry/src/main/ets/liveview/LockScreenPage.ets @@ -0,0 +1,47 @@ +/* +* Copyright (c) 2025 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. +*/ + +import { Constants } from '../constant/Constant'; +import { LaneData } from '../model/RouteDataModel'; +import { BreakpointType } from '../utils/BreakpointUtil'; +import { RoadView } from '../view/RoadView'; + +let storage: LocalStorage = LocalStorage.getShared(); + +@Entry(storage) +@Component +struct Index { + // [Start layoutBasedOnVerticalBreakpoint] + @StorageLink('verticalBreakpoint') verticalBreakpoint: string = Constants.BREAK_POINT_SM; + @LocalStorageProp('laneData') roadInfo: LaneData | undefined = undefined; + + build() { + Stack({ alignContent: Alignment.Top }) { + RoadView({ laneNum: this.roadInfo?.laneNum }) + + Image($rawfile('traffic_light.svg')) + .objectFit(ImageFit.Contain) + .width(80) + .position({ + // Layout based on vertical breakpoint. + right: new BreakpointType(25, 25, 75).getValue(this.verticalBreakpoint), + top: 25 + }) + } + .width('100%') + .height('100%') + } + // [End layoutBasedOnVerticalBreakpoint] +} \ No newline at end of file diff --git a/entry/src/main/ets/model/RouteDataModel.ets b/entry/src/main/ets/model/RouteDataModel.ets new file mode 100644 index 0000000000000000000000000000000000000000..2f5416898231e07b897c70bd6983fb12f5ca1ee1 --- /dev/null +++ b/entry/src/main/ets/model/RouteDataModel.ets @@ -0,0 +1,25 @@ +/* +* Copyright (c) 2025 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. +*/ + +export interface LaneData { + laneNum: number, +} + +export interface RouteData { + // route information + roadInfo: LaneData, + distance: number, + roadName: Resource, +} \ No newline at end of file diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..387c24af092a805fb6deddec51dac575d726c98c --- /dev/null +++ b/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 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. + */ + +import { LiveView } from '../utils/LiveView'; +import { TrafficView } from '../view/TrafficView'; + +@Entry +@Component +struct Index { + aboutToAppear(): void { + LiveView.getInstance().createLiveView(); + } + + build() { + Stack() { + Image($r('app.media.traffic_background')) + .width('110%') + .height('110%') + TrafficView() + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/entry/src/main/ets/utils/BreakpointUtil.ets b/entry/src/main/ets/utils/BreakpointUtil.ets new file mode 100644 index 0000000000000000000000000000000000000000..45751d306db3f8a8f49e065a8384793170a9cf80 --- /dev/null +++ b/entry/src/main/ets/utils/BreakpointUtil.ets @@ -0,0 +1,39 @@ +/* + * 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. + */ + +import { Constants } from "../constant/Constant"; + +export class BreakpointType { + private sm: T; + private md: T; + private lg: T; + + constructor(sm: T, md: T, lg: T) { + this.sm = sm; + this.md = md; + this.lg = lg; + } + + getValue(currentBreakpoint: string): T { + if (currentBreakpoint === Constants.BREAK_POINT_MD) { + return this.md; + } + if (currentBreakpoint === Constants.BREAK_POINT_LG) { + return this.lg; + } else { + return this.sm; + } + } +} \ No newline at end of file diff --git a/entry/src/main/ets/utils/LiveView.ets b/entry/src/main/ets/utils/LiveView.ets new file mode 100644 index 0000000000000000000000000000000000000000..fd4d4d28d1b3ca61c3f7c65e34e24687271ed7fc --- /dev/null +++ b/entry/src/main/ets/utils/LiveView.ets @@ -0,0 +1,167 @@ +/* + * 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. + */ + +import { appManager, WantAgent, wantAgent } from '@kit.AbilityKit'; +// [Start startContinuousRunningTask] +import { backgroundTaskManager } from '@kit.BackgroundTasksKit'; +// [StartExclude startContinuousRunningTask] +// [Start pushCommonEvent] +import { BusinessError, commonEventManager } from '@kit.BasicServicesKit'; +// [StartExclude pushCommonEvent] +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { RouteData } from '../model/RouteDataModel'; +import { LiveViewUtil } from '../utils/LiveViewUtil'; +import { getRouteData } from '../viewmodel/RouteDataViewModel'; + +const TAG: string = '[LiveView]'; + +export class LiveView { + // Singleton pattern implementation + private static instance: LiveView; + private context: Context; + private liveViewController: LiveViewUtil; + private updateInterval: number | undefined; + + // Private constructor for singleton pattern + private constructor() { + this.context = getContext(this); + this.liveViewController = new LiveViewUtil(); + } + + // Singleton accessor method + public static getInstance(): LiveView { + // Lazy initialization of the singleton instance + if (!LiveView.instance) { + LiveView.instance = new LiveView(); + } + return LiveView.instance; + } + + // Main entry point to start live view functionality + public createLiveView() { + // Initialize live view and start background tasks + this.liveViewController.startLiveView(getRouteData()).then(() => { + this.startContinuousRunningTask(); + // [Start getRunningProcessInfo] + // Set up periodic state checking + this.updateInterval = setInterval(() => { + // Monitor application state changes + appManager.getRunningProcessInformation().then((data: Array) => { + hilog.info(0x0000, TAG, '%{public}s', 'Success to getRunningProcessInformation'); + // Handle background state + if (data[0].state === appManager.ProcessState.STATE_BACKGROUND) { + // [StartExclude getRunningProcessInfo] + let routeInfo: RouteData = getRouteData(); + this.liveViewController.updateLiveView(routeInfo); + // [EndExclude pushCommonEvent] + // Prepare common event data + let options: commonEventManager.CommonEventPublishData = { + data: 'data', + bundleName: 'com.example.mapliveviewsample', + parameters: { + 'roadData': routeInfo.roadInfo + } + }; + // Publish system event for lock screen updates + commonEventManager.publish('live_view_lock_screen', options, (error: BusinessError) => { + if (error) { + hilog.error(0x0000, TAG, '%{public}s', + `Failed to publish commonEvent. code is ${error.code} message is ${error.message}`); + } else { + hilog.info(0x0000, TAG, '%{public}s', 'Succeeded in publishing commonEvent.') + } + }); + // [End pushCommonEvent] + // [EndExclude getRunningProcessInfo] + } + }).catch((error: BusinessError) => { + hilog.error(0x0000, TAG, '%{public}s', + `Failed to getRunningProcessInformation. code is ${error.code} message is ${error.message}`); + }); + }, 2000) + // [End getRunningProcessInfo] + }) + } + + // Cleanup method to stop all live view activities + public finishLiveView() { + // [Start clearPeriodicUpdates] + // Clear periodic updates + if (this.updateInterval !== undefined) { + clearInterval(this.updateInterval); + this.updateInterval = undefined; + hilog.info(0x0000, TAG, 'Timer has been cleared'); + } + // [End clearPeriodicUpdates] + + // Shutdown live view components + this.liveViewController.closeLiveView(); + + // [Start stopBackgroundRunning] + // Stop background tasks + try { + backgroundTaskManager.stopBackgroundRunning(this.context).then(() => { + console.info("Operation stopBackgroundRunning succeeded"); + }).catch((error: BusinessError) => { + console.error(`Operation stopBackgroundRunning failed. code is ${error.code} message is ${error.message}`); + }); + } catch (error) { + console.error(`Operation stopBackgroundRunning failed. code is ${(error as BusinessError).code} message is ${(error as BusinessError).message}`); + } + // [End stopBackgroundRunning] + } + + // [EndExclude startContinuousRunningTask] + // Internal method to manage background tasks + private startContinuousRunningTask() { + // Configure WantAgent for background operation + let wantAgentInfo: wantAgent.WantAgentInfo = { + wants: [ + { + bundleName: 'com.example.mapliveviewsample', + abilityName: 'EntryAbility' + } + ], + actionType: wantAgent.OperationType.START_ABILITY, + requestCode: 0, + actionFlags: [wantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG] + }; + + try { + // Acquire WantAgent for background operations + wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj: WantAgent) => { + try { + hilog.info(0x0000, TAG, '%{public}s', 'Operation startBackgroundRunning begin.'); + // Required background resource types + const list: string[] = ['location']; + // Request background running permission + backgroundTaskManager.startBackgroundRunning(this.context, list, wantAgentObj).then(() => { + hilog.info(0x0000, TAG, '%{public}s', 'Operation startBackgroundRunning succeeded.'); + }).catch((error: BusinessError) => { + hilog.error(0x0000, TAG, '%{public}s', + `Failed to Operation startBackgroundRunning. code is ${error.code} message is ${error.message}`); + }); + } catch (error) { + hilog.error(0x0000, TAG, '%{public}s', + `Failed to Operation startBackgroundRunning. code is ${(error as BusinessError).code} message is ${(error as BusinessError).message}`); + } + }); + } catch (error) { + hilog.error(0x0000, TAG, '%{public}s', + `Failed to Operation getWantAgent. code is ${(error as BusinessError).code} message is ${(error as BusinessError).message}`); + } + } + // [End startContinuousRunningTask] +} \ No newline at end of file diff --git a/entry/src/main/ets/utils/LiveViewUtil.ets b/entry/src/main/ets/utils/LiveViewUtil.ets new file mode 100644 index 0000000000000000000000000000000000000000..1616ebb8a76f2ffbafb04720dddeb21924e8991d --- /dev/null +++ b/entry/src/main/ets/utils/LiveViewUtil.ets @@ -0,0 +1,167 @@ +/* + * Copyright (c) 2025 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. + */ + +import { application, Want, wantAgent } from '@kit.AbilityKit'; +import { BusinessError } from '@kit.BasicServicesKit'; +// [Start createLiveView] +import { liveViewManager } from '@kit.LiveViewKit'; +// [StartExclude createLiveView] +import { RouteData } from '../model/RouteDataModel'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +const TAG: string = '[LiveViewUtil]'; + +export class LiveViewUtil { + private context = application.getApplicationContext(); + private defaultLiveView?: liveViewManager.LiveView; + private sequence: number = 0; + + public async startLiveView(params: RouteData) { + // Verify that the live view switch is turned on + if (!await LiveViewUtil.isLiveViewEnabled()) { + hilog.error(0x0000, TAG, '%{public}s', 'Live view is disabled.'); + return; + } + this.defaultLiveView = await this.createPrimaryLiveVie(); + this.updateLiveViewInfo(params); + + return await liveViewManager.startLiveView(this.defaultLiveView); + } + + public async updateLiveView(params: RouteData): Promise { + try { + // live view is disabled or default view is not init + if (!await LiveViewUtil.isLiveViewEnabled() || !this.defaultLiveView) { + hilog.error(0x0000, TAG, '%{public}s', 'updateLiveView, live view is disabled.'); + return false; + } + this.updateLiveViewInfo(params); + const result = await liveViewManager.updateLiveView(this.defaultLiveView); + if (result) { + hilog.info(0x0000, TAG, '%{public}s', 'updateLiveView.'); + } + return true; + } catch (error) { + hilog.error(0x0000, TAG, + `Failed to update live view. Cause code: ${(error as BusinessError).code}, message: ${(error as BusinessError).message}`); + return false; + } + } + + // [Start closeLiveView] + // Close live view. + public async closeLiveView() { + // Ensure that the sequence is greater than the current live window page. + this.sequence++; + this.defaultLiveView = await this.createPrimaryLiveVie(); + await liveViewManager.stopLiveView(this.defaultLiveView).then(() => { + this.sequence = 0; + this.defaultLiveView = undefined; + hilog.info(0x0000, TAG, '%{public}s', 'Succeeded in stopping liveView, result: %{public}'); + }).catch((error: BusinessError) => { + hilog.error(0x0000, TAG, '%{public}s', + `Failed to stop liveView. Cause code: ${error.code}, message: ${error.message}`); + }); + return; + } + // [End closeLiveView] + + private static async isLiveViewEnabled(): Promise { + return await liveViewManager.isLiveViewEnabled(); + } + + private updateLiveViewInfo(params: RouteData) { + let liveView: liveViewManager.LiveView = this.defaultLiveView!; + if (params) { + liveView.sequence = this.sequence + this.sequence++; + liveView.liveViewData.capsule = { + type: liveViewManager.CapsuleType.CAPSULE_TYPE_TEXT, + status: 1, + icon: 'turn_right_light_square.png', + backgroundColor: this.context.resourceManager.getStringSync($r('app.string.live_view_background').id), + title: `${params.distance}${this.context.resourceManager.getStringSync($r('app.string.meter').id)}`, + } + liveView.liveViewData.primary.title = + `${this.context.resourceManager.getStringSync($r('app.string.live_view_primary_title_first') + .id)}${params.distance}${this.context.resourceManager.getStringSync($r('app.string.live_view_primary_title_second') + .id)}`; + liveView.liveViewData.primary.content = [{ text: this.context.resourceManager.getStringSync(params.roadName) }]; + liveView.liveViewData.primary.liveViewLockScreenAbilityName = 'LiveViewExtAbility'; + liveView.liveViewData.primary.liveViewLockScreenAbilityParameters = { '': '' }; + if (params.roadInfo.laneNum === 1) { + liveView.liveViewData.primary.layoutData = { + layoutType: liveViewManager.LayoutType.LAYOUT_TYPE_NAVIGATION, + currentNavigationIcon: 'turn_straight_light_rectangle.png', + navigationIcons: ['turn_straight_light_rectangle.png', 'turn_right_dark_rectangle.png'] + }; + } else { + liveView.liveViewData.primary.layoutData = { + layoutType: liveViewManager.LayoutType.LAYOUT_TYPE_NAVIGATION, + currentNavigationIcon: 'turn_right_light_rectangle.png', + navigationIcons: ['turn_straight_dark_rectangle.png', 'turn_right_light_rectangle.png'] + } + } + } + this.defaultLiveView = liveView; + } + + private async createPrimaryLiveVie(): Promise { + // [EndExclude createLiveView] + // Construct live window request body. + let liveView: liveViewManager.LiveView = { + id: 0, + sequence: this.sequence, + // Application scenarios of the live window. NAVIGATION: Navigation. + event: 'NAVIGATION', + liveViewData: { + // Live view capsule related parameters + capsule: { + type: liveViewManager.CapsuleType.CAPSULE_TYPE_TEXT, + status: 1, + icon: 'turn_right_light_square.png', + backgroundColor: this.context.resourceManager.getStringSync($r('app.string.live_view_background').id), + title: this.context.resourceManager.getStringSync($r('app.string.live_view_title').id), + }, + // Live view card related parameters + primary: { + title: this.context.resourceManager.getStringSync($r('app.string.live_view_title').id), + content: [{ text: this.context.resourceManager.getStringSync($r('app.string.live_view_content').id) }], + // Add LiveViewLockScreenExtensionAbility name to build lock screen live view + liveViewLockScreenAbilityName: 'LiveViewExtAbility', + liveViewLockScreenAbilityParameters: { liveViewParameters: '' }, + keepTime: 0, + clickAction: await LiveViewUtil.buildWantAgent() + } + } + }; + // [End createLiveView] + return liveView; + } + + private static async buildWantAgent(): Promise { + const wantAgentInfo: wantAgent.WantAgentInfo = { + wants: [{ + bundleName: 'com.example.mapliveviewsample', + abilityName: 'EntryAbility' + } as Want], + actionType: wantAgent.OperationType.START_ABILITIES, + requestCode: 0, + actionFlags: [wantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG] + }; + const agent: object = await wantAgent.getWantAgent(wantAgentInfo); + return agent; + } +} \ No newline at end of file diff --git a/entry/src/main/ets/view/RoadView.ets b/entry/src/main/ets/view/RoadView.ets new file mode 100644 index 0000000000000000000000000000000000000000..dd5bec6163df874ccb185da4ef12353c5dcee5aa --- /dev/null +++ b/entry/src/main/ets/view/RoadView.ets @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2025 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. + */ + +@Component +export struct RoadView { + @Prop laneNum: number = 1; + + build() { + Stack() { + Row() { + if (this.laneNum === 1) { + Image($r('app.media.traffic_left')) + .objectFit(ImageFit.Contain) + } else { + Image($r('app.media.traffic_right')) + .objectFit(ImageFit.Contain) + } + } + .width('80%') + .height('80%') + } + .backgroundImage($r("app.media.traffic_background")) + .backgroundImageSize(ImageSize.Cover) + .backgroundImagePosition(Alignment.Center) + .height('101%') + .width('101%') + } +} \ No newline at end of file diff --git a/entry/src/main/ets/view/TrafficInfoView.ets b/entry/src/main/ets/view/TrafficInfoView.ets new file mode 100644 index 0000000000000000000000000000000000000000..63efea9afbf7b261764696ead7475a8534546063 --- /dev/null +++ b/entry/src/main/ets/view/TrafficInfoView.ets @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2025 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. + */ +import { LiveView } from "../utils/LiveView" + +@Component +export struct TrafficInfoView { + @State private isStart: boolean = true; + + build() { + Row() { + Column() { + Text($r('app.string.traffic_info_first')) + .fontWeight(FontWeight.Bold) + .alignSelf(ItemAlign.Start) + .fontSize($r('sys.float.padding_level12')) + .margin({ + top: $r('sys.float.padding_level8'), + left: $r('sys.float.padding_level12'), + }) + Row() { + Text($r('app.string.traffic_info_second')) + .fontColor(Color.Grey) + .fontWeight(FontWeight.Bold) + .alignSelf(ItemAlign.Start) + .fontSize($r('sys.float.padding_level8')) + Image($r('app.media.traffic_light')) + .height($r('sys.float.padding_level8')) + Text($r('app.string.traffic_info_third')) + .fontColor(Color.Grey) + .fontWeight(FontWeight.Bold) + .alignSelf(ItemAlign.Start) + .fontSize($r('sys.float.padding_level8')) + } + .padding({ + top: $r('sys.float.padding_level4'), + left: $r('sys.float.padding_level12'), + bottom: $r('sys.float.padding_level16'), + }) + } + .alignItems(HorizontalAlign.Start) + + Column() { + Button('开始导航') + .fontColor(this.isStart ? $r('sys.color.comp_background_emphasize') : Color.White) + .backgroundColor(this.isStart ? $r('sys.color.comp_background_secondary') : + $r('sys.color.comp_background_emphasize')) + .fontSize(12) + .width(80) + .height(30) + .onClick(() => { + this.isStart = true; + LiveView.getInstance().createLiveView(); + }) + Button('结束导航') + .fontColor(!this.isStart ? $r('sys.color.comp_background_emphasize') : Color.White) + .backgroundColor(!this.isStart ? $r('sys.color.comp_background_secondary') : + $r('sys.color.comp_background_emphasize')) + .fontSize(12) + .width(80) + .height(30) + .onClick(() => { + this.isStart = false; + LiveView.getInstance().finishLiveView(); + }) + .margin({ + top: $r('sys.float.padding_level4') + }) + } + .position({ + top: 10, + right: 16, + }) + } + .width('100%') + } +} \ No newline at end of file diff --git a/entry/src/main/ets/view/TrafficView.ets b/entry/src/main/ets/view/TrafficView.ets new file mode 100644 index 0000000000000000000000000000000000000000..c41c0f8b7b8fdb6b8dadc764a23d27a813cd7b42 --- /dev/null +++ b/entry/src/main/ets/view/TrafficView.ets @@ -0,0 +1,203 @@ +/* + * Copyright (c) 2025 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. + */ + +import { Constants } from "../constant/Constant"; +import { LaneData } from "../model/RouteDataModel"; +import { TrafficInfoView } from "./TrafficInfoView"; +import { BreakpointType } from "../utils/BreakpointUtil"; + +@Component +export struct TrafficView { + @StorageLink('horizontalBreakpoint') horizontalBreakpoint: string = Constants.BREAK_POINT_SM; + @StorageLink('verticalBreakpoint') verticalBreakpoint: string = Constants.BREAK_POINT_SM; + @State roadInfo: LaneData | undefined = undefined; + @State isShow: boolean = false; + + @Builder + myBuilder() { + Row() { + TrafficInfoView() + } + .backgroundColor($r('sys.color.background_secondary')) + .width('100%') + .height('100%') + } + + build() { + Column() { + Row() { + Column() { + Column() { + Row() { + Image($r('app.media.big_arrow')) + .objectFit(ImageFit.Contain) + .height(new BreakpointType(80, 70, 70).getValue(this.horizontalBreakpoint)) + Column() { + Text($r('app.string.traffic_info_meter')) + .fontColor(Color.White) + .fontWeight(FontWeight.Bold) + .alignSelf(ItemAlign.Start) + .fontSize(40) + .margin({ + top: $r('sys.float.padding_level8'), + left: $r('sys.float.padding_level8'), + }) + Text($r('app.string.road_name')) + .fontColor(Color.White) + .fontWeight(FontWeight.Regular) + .alignSelf(ItemAlign.Start) + .fontSize(24) + .margin({ + left: $r('sys.float.padding_level8'), + }) + } + } + .borderRadius({ + topLeft: new BreakpointType(0, 16, 16).getValue(this.horizontalBreakpoint), + topRight: new BreakpointType(0, 16, 16).getValue(this.horizontalBreakpoint), + }) + .backgroundColor($r('app.color.Index_background_first')) + .width(new BreakpointType('100%', '50%', '30%').getValue(this.horizontalBreakpoint)) + .padding({ + bottom: $r('sys.float.padding_level8'), + top: new BreakpointType(this.verticalBreakpoint === Constants.BREAK_POINT_MD ? + ('sys.float.padding_level8') : $r('sys.float.padding_level16'), $r('sys.float.padding_level0'), + $r('sys.float.padding_level0')).getValue(this.horizontalBreakpoint), + left: new BreakpointType($r('sys.float.padding_level8'), $r('sys.float.padding_level12'), + $r('sys.float.padding_level16')).getValue(this.horizontalBreakpoint), + }) + + Row() { + Text($r('app.string.then')) + .fontColor(Color.White) + .fontWeight(FontWeight.Regular) + .alignSelf(ItemAlign.Start) + .fontSize(22) + .margin({ + left: $r('sys.float.padding_level8'), + right: $r('sys.float.padding_level2'), + }) + Image($r('app.media.little_arrow')) + .objectFit(ImageFit.Contain) + .height(new BreakpointType(25, 25, 25).getValue(this.horizontalBreakpoint)) + } + .borderRadius({ + bottomLeft: new BreakpointType(0, 16, 16).getValue(this.horizontalBreakpoint), + bottomRight: new BreakpointType(0, 16, 16).getValue(this.horizontalBreakpoint), + }) + .padding({ + bottom: $r('sys.float.padding_level2'), + top: $r('sys.float.padding_level2'), + }) + .width(new BreakpointType('100%', '50%', '30%').getValue(this.horizontalBreakpoint)) + .backgroundColor($r('app.color.Index_background_second')) + + if (this.horizontalBreakpoint !== Constants.BREAK_POINT_SM) { + Image($r('app.media.traffic_info_speed')) + .objectFit(ImageFit.Contain) + .height(80) + .position({ + top: 0, + left: this.horizontalBreakpoint === Constants.BREAK_POINT_MD ? '51%' : '31%', + }) + } + } + + Row() { + if (this.horizontalBreakpoint === Constants.BREAK_POINT_SM) { + Image($r('app.media.traffic_info_speed')) + .objectFit(ImageFit.Contain) + .height(70) + } + Image($r('app.media.traffic_info_label')) + .objectFit(ImageFit.Contain) + .height(new BreakpointType(70, 80, 80).getValue(this.horizontalBreakpoint)) + } + .margin({ + left: new BreakpointType($r('sys.float.padding_level36'), $r('sys.float.padding_level12'), + $r('sys.float.padding_level16')).getValue(this.horizontalBreakpoint), + top: $r('sys.float.padding_level2'), + }) + .width(new BreakpointType('100%', '40%', '30%').getValue(this.horizontalBreakpoint)) + } + .padding({ + left: new BreakpointType($r('sys.float.padding_level0'), $r('sys.float.padding_level12'), + $r('sys.float.padding_level16')).getValue(this.horizontalBreakpoint), + top: new BreakpointType($r('sys.float.padding_level0'), $r('sys.float.padding_level16'), + $r('sys.float.padding_level16')).getValue(this.horizontalBreakpoint), + }) + } + .width('100%') + .justifyContent(FlexAlign.Start) + + Blank() + + Row() { + Stack({ alignContent: Alignment.Top }) { + Image($r('app.media.traffic_right')) + .width(new BreakpointType(this.verticalBreakpoint === Constants.BREAK_POINT_MD ? '35%' : '70%', '50%', + '30%').getValue(this.horizontalBreakpoint)) + Image($rawfile('traffic_light.svg')) + .objectFit(ImageFit.Contain) + .width(new BreakpointType('20%', '20%', '10%').getValue(this.horizontalBreakpoint)) + .position({ + left: '70%', + top: 30 + }) + } + .width('100%') + .onClick(() => { + if (this.horizontalBreakpoint === Constants.BREAK_POINT_SM && + this.verticalBreakpoint === Constants.BREAK_POINT_MD) { + this.isShow = true; + } else { + this.isShow = false; + } + }) + } + + Blank() + + if (this.horizontalBreakpoint !== Constants.BREAK_POINT_SM || + this.verticalBreakpoint !== Constants.BREAK_POINT_MD) { + Row() { + TrafficInfoView() + } + .margin({ + left: new BreakpointType($r('sys.float.padding_level0'), $r('sys.float.padding_level12'), + $r('sys.float.padding_level16')).getValue(this.horizontalBreakpoint), + }) + .backgroundColor($r('sys.color.background_secondary')) + .width(new BreakpointType('100%', '50%', '30%').getValue(this.horizontalBreakpoint)) + .height(120) + .borderRadius({ + topLeft: 32, + topRight: 32, + }) + } + } + .bindSheet($$this.isShow, this.myBuilder(), { + height: 90, + width: 440, + preferType: SheetType.BOTTOM, + showClose: false, + }) + .width('100%') + .height('100%') + .backgroundImage($r('app.media.traffic_background')) + .backgroundImageSize(ImageSize.Cover) + .backgroundImagePosition(Alignment.Center) + } +} \ No newline at end of file diff --git a/entry/src/main/ets/viewmodel/RouteDataViewModel.ets b/entry/src/main/ets/viewmodel/RouteDataViewModel.ets new file mode 100644 index 0000000000000000000000000000000000000000..920ea8d15db0ac01e6d6f8a0f52dfa23fd17f81f --- /dev/null +++ b/entry/src/main/ets/viewmodel/RouteDataViewModel.ets @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2025 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. + */ + +import { RouteData } from '../model/RouteDataModel'; + +const LEFT_STATE: RouteData = { + roadInfo: { + laneNum: 1 + }, + distance: 800, + roadName: $r('app.string.road_name') +}; + +const RIGHT_STATE: RouteData = { + roadInfo: { + laneNum: 2 + }, + distance: 800, + roadName: $r('app.string.road_name') +}; + +let isLeftState: boolean = false; + +export const getRouteData = (): RouteData => { + isLeftState = !isLeftState; + return isLeftState ? LEFT_STATE : RIGHT_STATE; +}; \ No newline at end of file diff --git a/entry/src/main/module.json5 b/entry/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..68b78dcf1af492ef04a3cce07a0966ad9d26c695 --- /dev/null +++ b/entry/src/main/module.json5 @@ -0,0 +1,65 @@ +{ + "module": { + "name": "entry", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "phone", + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ets", + "description": "$string:EntryAbility_desc", + "icon": "$media:layered_image", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "backgroundModes": [ + 'location' + ], + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + // [Start addLiveViewLockScreenExtensionAbilityName] + "extensionAbilities": [ + { + // Keep it consistent with LiveViewLockScreenExtensionAbility name in live view instance + "name": "LiveViewExtAbility", + "type": "liveViewLockScreen", + // LiveViewLockScreenExtensionAbility location + "srcEntry": "./ets/liveview/LiveViewExtAbility.ets", + "exported": false + } + ], + // [End addLiveViewLockScreenExtensionAbilityName] + // [Start requestPermissions] + "requestPermissions": [ + { + "name": "ohos.permission.KEEP_BACKGROUND_RUNNING", + "reason": "$string:reason_background", + "usedScene": { + "abilities": [ + "EntryAbility" + ], + "when": "always" + } + }, + ], + // [End requestPermissions] + } +} \ No newline at end of file diff --git a/entry/src/main/resources/base/element/color.json b/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..a332bbb548865c29565271458a0bf38f4de1ed11 --- /dev/null +++ b/entry/src/main/resources/base/element/color.json @@ -0,0 +1,24 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + }, + { + "name": "Index_background_first", + "value": "#000000" + }, + { + "name": "Index_background_second", + "value": "#303030" + }, + { + "name": "xmark_foreground", + "value": "#E5000000" + }, + { + "name": "xmark_background", + "value": "#19000000" + } + ] +} \ No newline at end of file diff --git a/entry/src/main/resources/base/element/string.json b/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..2a8552a445951c53c36427e3ef102a121c270495 --- /dev/null +++ b/entry/src/main/resources/base/element/string.json @@ -0,0 +1,68 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "锁屏沉浸实况窗" + }, + { + "name": "reason_background", + "value": "Background operation to update the live view" + }, + { + "name": "traffic_info_meter", + "value": "800米" + }, + { + "name": "traffic_info_first", + "value": "1 小时 24 分钟" + }, + { + "name": "traffic_info_second", + "value": "72.6公里·09:32·" + }, + { + "name": "traffic_info_third", + "value": "3" + }, + { + "name": "live_view_title", + "value": "导航中" + }, + { + "name": "live_view_background", + "value": "#ff0959F8" + }, + { + "name": "live_view_content", + "value": "content" + }, + { + "name": "meter", + "value": "米" + }, + { + "name": "live_view_primary_title_first", + "value": "" + }, + { + "name": "live_view_primary_title_second", + "value": "米后右转" + }, + { + "name": "road_name", + "value": "翠湖东路" + }, + { + "name": "then", + "value": "然后" + } + ] +} \ No newline at end of file diff --git a/entry/src/main/resources/base/media/background.png b/entry/src/main/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..f939c9fa8cc8914832e602198745f592a0dfa34d Binary files /dev/null and b/entry/src/main/resources/base/media/background.png differ diff --git a/entry/src/main/resources/base/media/big_arrow.png b/entry/src/main/resources/base/media/big_arrow.png new file mode 100644 index 0000000000000000000000000000000000000000..5e8ca5e5e2adfc67f2cfc31d1f68b4c75fce3b02 Binary files /dev/null and b/entry/src/main/resources/base/media/big_arrow.png differ diff --git a/entry/src/main/resources/base/media/foreground.png b/entry/src/main/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..4483ddad1f079e1089d685bd204ee1cfe1d01902 Binary files /dev/null and b/entry/src/main/resources/base/media/foreground.png differ diff --git a/entry/src/main/resources/base/media/layered_image.json b/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/entry/src/main/resources/base/media/layered_image.json @@ -0,0 +1,7 @@ +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } +} \ No newline at end of file diff --git a/entry/src/main/resources/base/media/little_arrow.png b/entry/src/main/resources/base/media/little_arrow.png new file mode 100644 index 0000000000000000000000000000000000000000..295126ca6cda13bf4a39e91e6fe85e8f52b69a29 Binary files /dev/null and b/entry/src/main/resources/base/media/little_arrow.png differ diff --git a/entry/src/main/resources/base/media/startIcon.png b/entry/src/main/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/entry/src/main/resources/base/media/startIcon.png differ diff --git a/entry/src/main/resources/base/media/traffic_background.png b/entry/src/main/resources/base/media/traffic_background.png new file mode 100644 index 0000000000000000000000000000000000000000..3cc57185978f8e630c99f80c057e75cbbfa486a8 Binary files /dev/null and b/entry/src/main/resources/base/media/traffic_background.png differ diff --git a/entry/src/main/resources/base/media/traffic_info_label.png b/entry/src/main/resources/base/media/traffic_info_label.png new file mode 100644 index 0000000000000000000000000000000000000000..163a9c61c888350d6cbd7c9f771fbc36dde3f6bc Binary files /dev/null and b/entry/src/main/resources/base/media/traffic_info_label.png differ diff --git a/entry/src/main/resources/base/media/traffic_info_speed.png b/entry/src/main/resources/base/media/traffic_info_speed.png new file mode 100644 index 0000000000000000000000000000000000000000..9e53c2ac851b5602371d79fc9449ea6f8805dd11 Binary files /dev/null and b/entry/src/main/resources/base/media/traffic_info_speed.png differ diff --git a/entry/src/main/resources/base/media/traffic_left.png b/entry/src/main/resources/base/media/traffic_left.png new file mode 100644 index 0000000000000000000000000000000000000000..94ee73c185d6ff34abcee535077ca802b1911ce1 Binary files /dev/null and b/entry/src/main/resources/base/media/traffic_left.png differ diff --git a/entry/src/main/resources/base/media/traffic_light.svg b/entry/src/main/resources/base/media/traffic_light.svg new file mode 100644 index 0000000000000000000000000000000000000000..eca422cc829ca2a38255e641d7205a4901a338fa --- /dev/null +++ b/entry/src/main/resources/base/media/traffic_light.svg @@ -0,0 +1,41 @@ + + + Created with Pixso. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/entry/src/main/resources/base/media/traffic_right.png b/entry/src/main/resources/base/media/traffic_right.png new file mode 100644 index 0000000000000000000000000000000000000000..36c2a5f3ea1d534921d5dcd48a38981d8e343115 Binary files /dev/null and b/entry/src/main/resources/base/media/traffic_right.png differ diff --git a/entry/src/main/resources/base/profile/backup_config.json b/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a --- /dev/null +++ b/entry/src/main/resources/base/profile/backup_config.json @@ -0,0 +1,3 @@ +{ + "allowToBackupRestore": true +} \ No newline at end of file diff --git a/entry/src/main/resources/base/profile/main_pages.json b/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..731cedf01ef9edcfa92e1a357b0f5f4b2794f305 --- /dev/null +++ b/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,6 @@ +{ + "src": [ + "liveview/LockScreenPage", + "pages/Index" + ] +} diff --git a/entry/src/main/resources/dark/element/color.json b/entry/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..682f571ff1addde0e6bdf7a19820485847e81f09 --- /dev/null +++ b/entry/src/main/resources/dark/element/color.json @@ -0,0 +1,16 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + }, + { + "name": "xmark_foreground", + "value": "#E5FFFFFF" + }, + { + "name": "xmark_background", + "value": "#19FFFFFF" + } + ] +} \ No newline at end of file diff --git a/entry/src/main/resources/en_US/element/string.json b/entry/src/main/resources/en_US/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..9eacc46fabe45623c5c8ec6c6ac36b0bf1a29d97 --- /dev/null +++ b/entry/src/main/resources/en_US/element/string.json @@ -0,0 +1,68 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "LiveViewLockScreen" + }, + { + "name": "reason_background", + "value": "Background operation to update the live view" + }, + { + "name": "traffic_info_meter", + "value": "800 meters" + }, + { + "name": "traffic_info_first", + "value": "1 hour 24 minutes" + }, + { + "name": "traffic_info_second", + "value": "72.6km·09:32·" + }, + { + "name": "traffic_info_third", + "value": "3" + }, + { + "name": "live_view_title", + "value": "In navigation" + }, + { + "name": "live_view_background", + "value": "#ff0959F8" + }, + { + "name": "live_view_content", + "value": "content" + }, + { + "name": "meter", + "value": " meters" + }, + { + "name": "live_view_primary_title_first", + "value": "Turn right after " + }, + { + "name": "live_view_primary_title_second", + "value": " meters" + }, + { + "name": "road_name", + "value": "Cuihu East Road" + }, + { + "name": "then", + "value": "Then" + } + ] +} \ No newline at end of file diff --git a/entry/src/main/resources/rawfile/traffic_light.svg b/entry/src/main/resources/rawfile/traffic_light.svg new file mode 100644 index 0000000000000000000000000000000000000000..683a432651f7dbc91b854f5f94ec51df3c310ade --- /dev/null +++ b/entry/src/main/resources/rawfile/traffic_light.svg @@ -0,0 +1,12 @@ + + + Created with Pixso. + + + + + + + + + diff --git a/entry/src/main/resources/rawfile/traffic_md.svg b/entry/src/main/resources/rawfile/traffic_md.svg new file mode 100644 index 0000000000000000000000000000000000000000..728e3192851034d51a9e3637390fed210dd34e17 --- /dev/null +++ b/entry/src/main/resources/rawfile/traffic_md.svg @@ -0,0 +1,12 @@ + + + Created with Pixso. + + + + + + + + + diff --git a/entry/src/main/resources/rawfile/traffic_sm.svg b/entry/src/main/resources/rawfile/traffic_sm.svg new file mode 100644 index 0000000000000000000000000000000000000000..cf2c74bfbc4ee0077503e27235dc97ffb5054543 --- /dev/null +++ b/entry/src/main/resources/rawfile/traffic_sm.svg @@ -0,0 +1,12 @@ + + + Created with Pixso. + + + + + + + + + diff --git a/entry/src/main/resources/rawfile/turn_right_dark_rectangle.png b/entry/src/main/resources/rawfile/turn_right_dark_rectangle.png new file mode 100644 index 0000000000000000000000000000000000000000..41f78ea0b59d840cfe841594f054b33257e33933 Binary files /dev/null and b/entry/src/main/resources/rawfile/turn_right_dark_rectangle.png differ diff --git a/entry/src/main/resources/rawfile/turn_right_light_rectangle.png b/entry/src/main/resources/rawfile/turn_right_light_rectangle.png new file mode 100644 index 0000000000000000000000000000000000000000..52dff1c8ba8c9e3c48c150d2939ca376e1832ae9 Binary files /dev/null and b/entry/src/main/resources/rawfile/turn_right_light_rectangle.png differ diff --git a/entry/src/main/resources/rawfile/turn_right_light_square.png b/entry/src/main/resources/rawfile/turn_right_light_square.png new file mode 100644 index 0000000000000000000000000000000000000000..7941168e4f843aa2c850ba818d74fb63edee8a5d Binary files /dev/null and b/entry/src/main/resources/rawfile/turn_right_light_square.png differ diff --git a/entry/src/main/resources/rawfile/turn_straight_dark_rectangle.png b/entry/src/main/resources/rawfile/turn_straight_dark_rectangle.png new file mode 100644 index 0000000000000000000000000000000000000000..076ad2ccb161331ccc25eb95c76af10068839500 Binary files /dev/null and b/entry/src/main/resources/rawfile/turn_straight_dark_rectangle.png differ diff --git a/entry/src/main/resources/rawfile/turn_straight_light_rectangle.png b/entry/src/main/resources/rawfile/turn_straight_light_rectangle.png new file mode 100644 index 0000000000000000000000000000000000000000..c2177d04d55a2e64f4af52de19d19b6ebff2b521 Binary files /dev/null and b/entry/src/main/resources/rawfile/turn_straight_light_rectangle.png differ diff --git a/entry/src/main/resources/zh_CN/element/string.json b/entry/src/main/resources/zh_CN/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..2a8552a445951c53c36427e3ef102a121c270495 --- /dev/null +++ b/entry/src/main/resources/zh_CN/element/string.json @@ -0,0 +1,68 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "锁屏沉浸实况窗" + }, + { + "name": "reason_background", + "value": "Background operation to update the live view" + }, + { + "name": "traffic_info_meter", + "value": "800米" + }, + { + "name": "traffic_info_first", + "value": "1 小时 24 分钟" + }, + { + "name": "traffic_info_second", + "value": "72.6公里·09:32·" + }, + { + "name": "traffic_info_third", + "value": "3" + }, + { + "name": "live_view_title", + "value": "导航中" + }, + { + "name": "live_view_background", + "value": "#ff0959F8" + }, + { + "name": "live_view_content", + "value": "content" + }, + { + "name": "meter", + "value": "米" + }, + { + "name": "live_view_primary_title_first", + "value": "" + }, + { + "name": "live_view_primary_title_second", + "value": "米后右转" + }, + { + "name": "road_name", + "value": "翠湖东路" + }, + { + "name": "then", + "value": "然后" + } + ] +} \ No newline at end of file diff --git a/hvigor/hvigor-config.json5 b/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..06b2783670a348f95533b352c1ceda909a842bbc --- /dev/null +++ b/hvigor/hvigor-config.json5 @@ -0,0 +1,22 @@ +{ + "modelVersion": "5.0.0", + "dependencies": { + }, + "execution": { + // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */ + // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */ + // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */ + // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */ + // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */ + }, + "logging": { + // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */ + }, + "debugging": { + // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */ + }, + "nodeOptions": { + // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/ + // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/ + } +} diff --git a/hvigorfile.ts b/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..f3cb9f1a87a81687554a76283af8df27d8bda775 --- /dev/null +++ b/hvigorfile.ts @@ -0,0 +1,6 @@ +import { appTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/oh-package.json5 b/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..1b8c11ffdf211f76b5774b08e8f5bb2cceb93c55 --- /dev/null +++ b/oh-package.json5 @@ -0,0 +1,6 @@ +{ + "modelVersion": "5.0.0", + "description": "Please describe the basic information.", + "dependencies": {}, + "devDependencies": {} +} diff --git a/screenshots/img.png b/screenshots/img.png new file mode 100644 index 0000000000000000000000000000000000000000..5834cf20dbcfe527e425c3a63879bd3f2741dc73 Binary files /dev/null and b/screenshots/img.png differ diff --git a/screenshots/phone_lock_screen.png b/screenshots/phone_lock_screen.png new file mode 100644 index 0000000000000000000000000000000000000000..768ae85a4b6944a8d37790e32039b4acee1143eb Binary files /dev/null and b/screenshots/phone_lock_screen.png differ