mirror of
https://gitee.com/openharmony/applications_screenlock
synced 2024-11-23 06:19:47 +00:00
commit
a1eceab582
3
.gitignore
vendored
3
.gitignore
vendored
@ -3,6 +3,9 @@
|
||||
/common/build
|
||||
/build/
|
||||
/features/batterycomponent/build/
|
||||
/features/datetimecomponent/build/
|
||||
/features/shortcutcomponent/build/
|
||||
/features/wallpapercomponent/build/
|
||||
/features/noticeitem/build/
|
||||
/features/notificationservice/build/
|
||||
/features/screenlock/build/
|
||||
|
22
OAT.xml
22
OAT.xml
@ -56,21 +56,27 @@
|
||||
<filefilterlist>
|
||||
<filefilter name="binaryFileTypePolicyFilter" desc="Filters for binary file policies">
|
||||
<filteritem type="filepath" name="entry/src/main/resources/base/media/.*.png" desc="self developed image"/>
|
||||
|
||||
|
||||
<filteritem type="filepath" name="features/batterycomponent/src/main/resources/base/media/.*.png" desc="self developed image"/>
|
||||
|
||||
|
||||
<filteritem type="filepath" name="features/datetimecomponent/src/main/resources/base/media/.*.png" desc="self developed image"/>
|
||||
|
||||
<filteritem type="filepath" name="features/shortcutcomponent/src/main/resources/base/media/.*.png" desc="self developed image"/>
|
||||
|
||||
<filteritem type="filepath" name="features/wallpapercomponent/src/main/resources/base/media/.*.png" desc="self developed image"/>
|
||||
|
||||
<filteritem type="filepath" name="features/noticeitem/src/main/resources/base/media/.*.png" desc="self developed image"/>
|
||||
|
||||
|
||||
<filteritem type="filepath" name="features/notificationservice/src/main/resources/base/media/.*.png" desc="self developed image"/>
|
||||
|
||||
|
||||
<filteritem type="filepath" name="features/screenlock/src/main/resources/base/media/.*.png" desc="self developed image"/>
|
||||
|
||||
|
||||
<filteritem type="filepath" name="product/pc/src/main/resources/base/media/.*.png" desc="self developed image"/>
|
||||
|
||||
|
||||
<filteritem type="filepath" name="product/phone/src/main/resources/base/media/.*.png" desc="self developed image"/>
|
||||
|
||||
|
||||
<filteritem type="filepath" name="figures/.*.png" desc="self developed image"/>
|
||||
|
||||
|
||||
<filteritem type="filepath" name="figures/.*.jpg" desc="self developed image"/>
|
||||
</filefilter>
|
||||
</filefilterlist>
|
||||
|
17
README_zh.md
17
README_zh.md
@ -2,18 +2,24 @@
|
||||
|
||||
## 简介
|
||||
|
||||
### 内容介绍
|
||||
锁屏应用是OpenHarmony中预置的系统应用,为用户提供锁屏的基础能力,提供滑动解锁、密码解锁等解锁能力,以及锁屏页面的信息展示能力。
|
||||
|
||||
### 架构图
|
||||
### 架构图介绍
|
||||
|
||||
![](figures/screenlock.png)
|
||||
锁屏应用具有以下特性:\
|
||||
|
||||
feature
|
||||
```
|
||||
1.在开机流程、亮屏流程、灭屏流程中添加加锁流程及所对应的解锁流程,实现和系统的交互。\
|
||||
2.通过时间日期组件、通知组件、状态栏组件、lockIcon和快捷开关组件,实现不要的信息展示。\
|
||||
3.支持数字解锁、图案解锁、人脸解锁和密码混合解锁。
|
||||
```
|
||||
|
||||
在common模块中,实现日志打印,外部接口管理,通用熟悉设置等功能。
|
||||
|
||||
common
|
||||
```
|
||||
通用接口,实现日志打印,外部接口管理等功能
|
||||
```
|
||||
## 目录
|
||||
|
||||
```
|
||||
@ -25,6 +31,9 @@
|
||||
├── signature # 证书文件目录
|
||||
├── features # 子组件目录
|
||||
│ ├── batterycomponent # 电池组件
|
||||
│ ├── datetimecomponent # 日期时间组件
|
||||
│ ├── shortcutcomponent # 快捷开关组件
|
||||
│ ├── wallpapercomponent # 壁纸组件
|
||||
│ ├── noticeitem # 通知子组件
|
||||
│ ├── notificationservice # 通知服务组件
|
||||
│ ├── screenlock # 锁屏组件
|
||||
|
21
features/datetimecomponent/build.gradle
Normal file
21
features/datetimecomponent/build.gradle
Normal file
@ -0,0 +1,21 @@
|
||||
apply plugin: 'com.huawei.ohos.library'
|
||||
//For instructions on signature configuration, see https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ide_debug_device-0000001053822404#section1112183053510
|
||||
ohos {
|
||||
compileSdkVersion rootProject.ext.version.compileSdk
|
||||
defaultConfig {
|
||||
compatibleSdkVersion rootProject.ext.version.compatibleSdk
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
proguardOpt {
|
||||
proguardEnabled false
|
||||
rulesFiles 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar', '*.har'])
|
||||
implementation project(':common')
|
||||
}
|
23
features/datetimecomponent/src/main/config.json
Normal file
23
features/datetimecomponent/src/main/config.json
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
"app": {
|
||||
"bundleName": "com.ohos.screenlock",
|
||||
"vendor": "ohos",
|
||||
"version": {
|
||||
"code": 1000000,
|
||||
"name": "1.0.0"
|
||||
}
|
||||
},
|
||||
"deviceConfig": {},
|
||||
"module": {
|
||||
"package": "com.ohos.screenlock.datetimecomponent",
|
||||
"deviceType": [
|
||||
"phone"
|
||||
],
|
||||
"distro": {
|
||||
"deliveryWithInstall": true,
|
||||
"moduleName": "datetimecomponent",
|
||||
"moduleType": "har"
|
||||
},
|
||||
"srcPath": "default"
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2022 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 default class Constants {
|
||||
//layout params - Pic
|
||||
static FULL_CONTAINER_WIDTH = '100%'
|
||||
|
||||
//The refresh interval
|
||||
static INTERVAL = 1000
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 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
|
||||
@ -14,8 +14,8 @@
|
||||
*/
|
||||
|
||||
import Log from '../../../../../../../../../common/src/main/ets/default/Log.ets'
|
||||
import ViewModel from '../../vm/dateTimeViewModel.ets'
|
||||
import Constants from '../../common/constants.ets'
|
||||
import ViewModel from '../../vm/dateTimeViewModel'
|
||||
import Constants from '../../common/constants'
|
||||
import {ScreenLockStatus} from '../../../../../../../../../common/src/main/ets/default/ScreenLockCommon.ets'
|
||||
|
||||
const TAG = 'ScreenLock-DateTime'
|
@ -0,0 +1,102 @@
|
||||
/**
|
||||
* Copyright (c) 2021-2022 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 featureAbility from '@ohos.ability.featureAbility'
|
||||
import settings from '@ohos.settingsnapi';
|
||||
import Log from '../../../../../../../../common/src/main/ets/default/Log.ets'
|
||||
import DateTimeCommon from '../../../../../../../../common/src/main/ets/default/DateTimeCommon'
|
||||
import Constants from '../common/constants'
|
||||
import {ScreenLockStatus} from '../../../../../../../../common/src/main/ets/default/ScreenLockCommon.ets'
|
||||
|
||||
const TAG = 'ScreenLock-DateTimeViewModel'
|
||||
|
||||
/**
|
||||
* DateTimeViewModel class
|
||||
*/
|
||||
export default class DateTimeViewModel {
|
||||
timeVal: string = ''
|
||||
dateVal: any = {}
|
||||
weekVal: any = {}
|
||||
setDateTimeHandle: number = -1
|
||||
isUsing24hFormat: boolean= false
|
||||
|
||||
ViewModelInit(): void{
|
||||
Log.showInfo(TAG, 'ViewModelInit');
|
||||
|
||||
// TODO api 8 下有问题,临时注释
|
||||
// this.timeFormatMonitor();
|
||||
|
||||
this.setDateTime.bind(this)()
|
||||
this.setDateTimeHandle = setInterval(this.setDateTime.bind(this), Constants.INTERVAL);
|
||||
Log.showInfo(TAG, 'ViewModelInit end');
|
||||
}
|
||||
|
||||
private timeFormatMonitor(): void {
|
||||
Log.showInfo(TAG, 'timeFormatMonitor');
|
||||
let urivar = settings.getUri('settings.time.format')
|
||||
let helper = featureAbility.acquireDataAbilityHelper(urivar);
|
||||
this.checkTimeFormat(helper);
|
||||
helper.on("dataChange", urivar, (err) => {
|
||||
if (err.code !== 0) {
|
||||
Log.showError(TAG, `failed to getAbilityWant because ${err.message}`);
|
||||
return;
|
||||
} else {
|
||||
this.checkTimeFormat(helper);
|
||||
}
|
||||
Log.showInfo(TAG, 'observer reveive notifychange on success data : ' + JSON.stringify(err))
|
||||
})
|
||||
}
|
||||
|
||||
private checkTimeFormat(helper) {
|
||||
Log.showInfo(TAG, 'checkTimeFormat');
|
||||
let getRetValue = settings.getValue(helper, 'settings.time.format', '24')
|
||||
if (getRetValue === '12') {
|
||||
this.isUsing24hFormat = false;
|
||||
} else if (getRetValue === '24') {
|
||||
this.isUsing24hFormat = true;
|
||||
}
|
||||
}
|
||||
|
||||
private setDateTime() {
|
||||
Log.showInfo(TAG, `setDateTime`)
|
||||
this.timeVal = DateTimeCommon.getSystemTime(this.isUsing24hFormat)
|
||||
this.dateVal = DateTimeCommon.getSystemDate()
|
||||
this.weekVal = DateTimeCommon.getSystemWeek()
|
||||
}
|
||||
|
||||
stopPolling() {
|
||||
Log.showInfo(TAG, `stopPolling start`)
|
||||
Log.showInfo(TAG, `stopPolling setDateTimeHandle:${this.setDateTimeHandle}`);
|
||||
if (this.setDateTimeHandle > 0) {
|
||||
clearInterval(this.setDateTimeHandle)
|
||||
this.setDateTimeHandle = -1
|
||||
Log.showInfo(TAG, `stopPolling setDateTimeHandle new :${this.setDateTimeHandle}`);
|
||||
}
|
||||
Log.showInfo(TAG, `stopPolling end`)
|
||||
}
|
||||
|
||||
onStatusChange(lockStatus: ScreenLockStatus): void {
|
||||
Log.showInfo(TAG, `onStatusChange lockStatus:${lockStatus}`);
|
||||
Log.showInfo(TAG, `onStatusChange setDateTimeHandle:${this.setDateTimeHandle}`);
|
||||
if (lockStatus == ScreenLockStatus.Locking) {
|
||||
if (this.setDateTimeHandle <= 0) {
|
||||
this.setDateTimeHandle = setInterval(this.setDateTime.bind(this), Constants.INTERVAL);
|
||||
Log.showInfo(TAG, `onStatusChange setDateTimeHandle new:${this.setDateTimeHandle}`);
|
||||
}
|
||||
} else {
|
||||
this.stopPolling();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
{
|
||||
"color": [
|
||||
{
|
||||
"name": "date_time_color",
|
||||
"value": "#ffffff"
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
{
|
||||
"float": [
|
||||
{
|
||||
"name": "time_fontsize",
|
||||
"value": "148"
|
||||
},
|
||||
{
|
||||
"name": "time_top_margin",
|
||||
"value": "10"
|
||||
},
|
||||
{
|
||||
"name": "time_bottom_margin",
|
||||
"value": "10"
|
||||
},
|
||||
{
|
||||
"name": "date_fontsize",
|
||||
"value": "18"
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
{
|
||||
"string": [
|
||||
{
|
||||
"name": "yyyy_mm_dd",
|
||||
"value": "%d/%d/%d"
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
{
|
||||
"string": [
|
||||
{
|
||||
"name": "yyyy_mm_dd",
|
||||
"value": "%d/%d/%d"
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
{
|
||||
"string": [
|
||||
{
|
||||
"name": "yyyy_mm_dd",
|
||||
"value": "%d年%d月%d日"
|
||||
}
|
||||
]
|
||||
}
|
@ -14,15 +14,12 @@
|
||||
*/
|
||||
import Log from '../../../../../../../../common/src/main/ets/default/Log.ets'
|
||||
import ScreenLockMar from '@ohos.screenlock';
|
||||
import featureAbility from '@ohos.ability.featureAbility'
|
||||
import settings from '@ohos.settingsnapi';
|
||||
import windowManager from '@ohos.window'
|
||||
import Constants from '../common/constants.ets'
|
||||
import UserIDM from '@ohos.useridm'
|
||||
import UserAuth from '@ohos.userauth'
|
||||
import PinAuth from '@ohos.pinauth'
|
||||
import util from '@ohos.util';
|
||||
import WallpaperMar from '@ohos.app.wallpaperability'
|
||||
|
||||
const TAG = 'ScreenLock-ScreenLockModel';
|
||||
|
||||
@ -78,11 +75,6 @@ export default class ScreenLockModel {
|
||||
static UserAuthManager = new UserAuth.UserAuth();
|
||||
static PINAuthManager = new PinAuth.PINAuth();
|
||||
|
||||
static getScreenLockWallpaper(callback) {
|
||||
Log.showInfo(TAG, 'getScreenLockWallpaper');
|
||||
WallpaperMar.getPixelMap(WallpaperMar.WALLPAPER_LOCKSCREEN, callback)
|
||||
}
|
||||
|
||||
static eventListener(typeName: string, callback) {
|
||||
Log.showInfo(TAG, `eventListener:typeName ${typeName}`);
|
||||
ScreenLockMar.on(typeName, (err, data) => {
|
||||
@ -121,34 +113,6 @@ export default class ScreenLockModel {
|
||||
})
|
||||
}
|
||||
|
||||
static timeFormatMonitor(callback): void {
|
||||
Log.showInfo(TAG, 'timeFormatMonitor');
|
||||
let urivar = settings.getUri('settings.time.format')
|
||||
let helper = featureAbility.acquireDataAbilityHelper(urivar);
|
||||
callback(ScreenLockModel.isUsing24hFormat(helper));
|
||||
helper.on("dataChange", urivar, (err) => {
|
||||
if (err.code !== 0) {
|
||||
Log.showError(TAG, `failed to getAbilityWant because ${err.message}`);
|
||||
return;
|
||||
} else {
|
||||
callback(ScreenLockModel.isUsing24hFormat(helper));
|
||||
}
|
||||
Log.showInfo(TAG, 'observer reveive notifychange on success data : ' + JSON.stringify(err))
|
||||
})
|
||||
}
|
||||
|
||||
static isUsing24hFormat(helper): boolean {
|
||||
Log.showInfo(TAG, 'isUsing24hFormat');
|
||||
let isUsing24hFormat: boolean = false;
|
||||
let getRetValue = settings.getValue(helper, 'settings.time.format', '24')
|
||||
if (getRetValue === '12') {
|
||||
isUsing24hFormat = false;
|
||||
} else if (getRetValue === '24') {
|
||||
isUsing24hFormat = true;
|
||||
}
|
||||
return isUsing24hFormat;
|
||||
}
|
||||
|
||||
static openIDMSession(callback) {
|
||||
Log.showInfo(TAG, 'openIDMSession');
|
||||
ScreenLockModel.UserIdentityManager.openSession().then((credentialId) => {
|
||||
|
@ -1,77 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2021 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 Log from '../../../../../../../../common/src/main/ets/default/Log.ets'
|
||||
import DateTimeCommon from '../../../../../../../../common/src/main/ets/default/DateTimeCommon'
|
||||
import Constants from '../common/constants.ets'
|
||||
import {ScreenLockStatus} from '../../../../../../../../common/src/main/ets/default/ScreenLockCommon.ets'
|
||||
import ScreenLockModel from '../model/screenLockModel.ets'
|
||||
|
||||
const TAG = 'ScreenLock-DateTimeViewModel'
|
||||
|
||||
/**
|
||||
* DateTimeViewModel class
|
||||
*/
|
||||
export default class DateTimeViewModel {
|
||||
timeVal: string = ''
|
||||
dateVal: any = {}
|
||||
weekVal: any = {}
|
||||
setDateTimeHandle: number = -1
|
||||
isUsing24hFormat: boolean= false
|
||||
|
||||
ViewModelInit(): void{
|
||||
Log.showInfo(TAG, 'ViewModelInit');
|
||||
|
||||
// TODO api 8 下有问题,临时注释
|
||||
// ScreenLockModel.timeFormatMonitor((result) => {
|
||||
// this.isUsing24hFormat = result;
|
||||
// });
|
||||
|
||||
this.setDateTime.bind(this)()
|
||||
this.setDateTimeHandle = setInterval(this.setDateTime.bind(this), Constants.INTERVAL);
|
||||
Log.showInfo(TAG, 'ViewModelInit end');
|
||||
}
|
||||
|
||||
setDateTime() {
|
||||
Log.showInfo(TAG, `setDateTime`)
|
||||
this.timeVal = DateTimeCommon.getSystemTime(this.isUsing24hFormat)
|
||||
this.dateVal = DateTimeCommon.getSystemDate()
|
||||
this.weekVal = DateTimeCommon.getSystemWeek()
|
||||
}
|
||||
|
||||
stopPolling() {
|
||||
Log.showInfo(TAG, `stopPolling start`)
|
||||
Log.showInfo(TAG, `stopPolling setDateTimeHandle:${this.setDateTimeHandle}`);
|
||||
if (this.setDateTimeHandle > 0) {
|
||||
clearInterval(this.setDateTimeHandle)
|
||||
this.setDateTimeHandle = -1
|
||||
Log.showInfo(TAG, `stopPolling setDateTimeHandle new :${this.setDateTimeHandle}`);
|
||||
}
|
||||
Log.showInfo(TAG, `stopPolling end`)
|
||||
}
|
||||
|
||||
onStatusChange(lockStatus: ScreenLockStatus): void {
|
||||
Log.showInfo(TAG, `onStatusChange lockStatus:${lockStatus}`);
|
||||
Log.showInfo(TAG, `onStatusChange setDateTimeHandle:${this.setDateTimeHandle}`);
|
||||
if (lockStatus == ScreenLockStatus.Locking) {
|
||||
if (this.setDateTimeHandle <= 0) {
|
||||
this.setDateTimeHandle = setInterval(this.setDateTime.bind(this), Constants.INTERVAL);
|
||||
Log.showInfo(TAG, `onStatusChange setDateTimeHandle new:${this.setDateTimeHandle}`);
|
||||
}
|
||||
} else {
|
||||
this.stopPolling();
|
||||
}
|
||||
}
|
||||
}
|
@ -4,10 +4,6 @@
|
||||
"name": "lock_prompt_color",
|
||||
"value": "#ffffff"
|
||||
},
|
||||
{
|
||||
"name": "date_time_color",
|
||||
"value": "#ffffff"
|
||||
},
|
||||
{
|
||||
"name": "nonotification_text_color",
|
||||
"value": "#ffffff"
|
||||
@ -35,14 +31,6 @@
|
||||
{
|
||||
"name": "lock_ic_color",
|
||||
"value": "#ffffff"
|
||||
},
|
||||
{
|
||||
"name": "shortcut_icon_color",
|
||||
"value": "rgba(255, 255, 255, 0.5)"
|
||||
},
|
||||
{
|
||||
"name": "shortcut_text_color",
|
||||
"value": "#ffffff"
|
||||
}
|
||||
]
|
||||
}
|
@ -20,22 +20,6 @@
|
||||
"name": "lock_prompt_fontsize",
|
||||
"value": "32"
|
||||
},
|
||||
{
|
||||
"name": "time_fontsize",
|
||||
"value": "148"
|
||||
},
|
||||
{
|
||||
"name": "time_top_margin",
|
||||
"value": "10"
|
||||
},
|
||||
{
|
||||
"name": "time_bottom_margin",
|
||||
"value": "10"
|
||||
},
|
||||
{
|
||||
"name": "date_fontsize",
|
||||
"value": "18"
|
||||
},
|
||||
{
|
||||
"name": "deleteall_image_opacity",
|
||||
"value": "0.9"
|
||||
|
@ -8,22 +8,10 @@
|
||||
"name": "unlock_prompt",
|
||||
"value": "上滑解锁"
|
||||
},
|
||||
{
|
||||
"name": "yyyy_mm_dd",
|
||||
"value": "%d/%d/%d"
|
||||
},
|
||||
{
|
||||
"name": "nonotification_text",
|
||||
"value": "无通知"
|
||||
},
|
||||
{
|
||||
"name": "shutdown",
|
||||
"value": "关机"
|
||||
},
|
||||
{
|
||||
"name": "reboot",
|
||||
"value": "重启"
|
||||
},
|
||||
{
|
||||
"name": "input",
|
||||
"value": "输入密码"
|
||||
|
@ -8,10 +8,6 @@
|
||||
"name": "unlock_prompt",
|
||||
"value": "Please slide to unlock"
|
||||
},
|
||||
{
|
||||
"name": "yyyy_mm_dd",
|
||||
"value": "%d/%d/%d"
|
||||
},
|
||||
{
|
||||
"name": "nonotification_text",
|
||||
"value": "No Notification"
|
||||
@ -55,14 +51,6 @@
|
||||
{
|
||||
"name": "charge_full",
|
||||
"value": "Already full"
|
||||
},
|
||||
{
|
||||
"name": "shutdown",
|
||||
"value": "shutdown"
|
||||
},
|
||||
{
|
||||
"name": "reboot",
|
||||
"value": "reboot"
|
||||
}
|
||||
]
|
||||
}
|
@ -7,10 +7,6 @@
|
||||
{
|
||||
"name": "unlock_prompt",
|
||||
"value": "上滑解锁"
|
||||
},
|
||||
{
|
||||
"name": "yyyy_mm_dd",
|
||||
"value": "%d年%d月%d日"
|
||||
},
|
||||
{
|
||||
"name": "nonotification_text",
|
||||
@ -56,14 +52,6 @@
|
||||
{
|
||||
"name": "charge_full",
|
||||
"value": "已充满"
|
||||
},
|
||||
{
|
||||
"name": "shutdown",
|
||||
"value": "关机"
|
||||
},
|
||||
{
|
||||
"name": "reboot",
|
||||
"value": "重启"
|
||||
}
|
||||
]
|
||||
}
|
21
features/shortcutcomponent/build.gradle
Normal file
21
features/shortcutcomponent/build.gradle
Normal file
@ -0,0 +1,21 @@
|
||||
apply plugin: 'com.huawei.ohos.library'
|
||||
//For instructions on signature configuration, see https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ide_debug_device-0000001053822404#section1112183053510
|
||||
ohos {
|
||||
compileSdkVersion rootProject.ext.version.compileSdk
|
||||
defaultConfig {
|
||||
compatibleSdkVersion rootProject.ext.version.compatibleSdk
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
proguardOpt {
|
||||
proguardEnabled false
|
||||
rulesFiles 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar', '*.har'])
|
||||
implementation project(':common')
|
||||
}
|
23
features/shortcutcomponent/src/main/config.json
Normal file
23
features/shortcutcomponent/src/main/config.json
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
"app": {
|
||||
"bundleName": "com.ohos.screenlock",
|
||||
"vendor": "ohos",
|
||||
"version": {
|
||||
"code": 1000000,
|
||||
"name": "1.0.0"
|
||||
}
|
||||
},
|
||||
"deviceConfig": {},
|
||||
"module": {
|
||||
"package": "com.ohos.screenlock.shortcutcomponent",
|
||||
"deviceType": [
|
||||
"phone"
|
||||
],
|
||||
"distro": {
|
||||
"deliveryWithInstall": true,
|
||||
"moduleName": "shortcutcomponent",
|
||||
"moduleType": "har"
|
||||
},
|
||||
"srcPath": "default"
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright (c) 2022 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 default class Constants {
|
||||
//Shortcut params
|
||||
static SHORTCUT_CIRCLE_WIDTH = '80px'
|
||||
static SHORTCUT_CIRCLE_HEIGHT = '80px'
|
||||
static SHORTCUT_TEXT_SIZE = '24px'
|
||||
static SHORTCUT_TEXT_WIDTH = '48px'
|
||||
static SHORTCUT_TEXT_HEIGHT = '34px'
|
||||
static SHORTCUT_BLOCK_HEIGHT = '10px'
|
||||
static SHORTCUT_HEIGHT = '150px'
|
||||
|
||||
// Click types
|
||||
static CLICK_TYPE_SHUTDOWN = "clickTypeShutDown"
|
||||
static CLICK_TYPE_REBOOT = "clickTypeReboot"
|
||||
}
|
@ -14,15 +14,15 @@
|
||||
*/
|
||||
|
||||
import Log from '../../../../../../../../../common/src/main/ets/default/Log.ets'
|
||||
import Constants from '../../common/constants.ets'
|
||||
import Constants from '../../common/constants'
|
||||
import ViewModel from '../../vm/shortcutViewModel'
|
||||
import power from '@ohos.power'
|
||||
|
||||
const TAG = 'ScreenLock-Shortcut'
|
||||
const TAG_Shutdown = 'ScreenLock-Shutdown'
|
||||
const TAG_Reboot = 'ScreenLock-Reboot'
|
||||
|
||||
@Component
|
||||
export default struct Shortcut {
|
||||
private viewModel: ViewModel = new ViewModel()
|
||||
private shutdownIcon: Resource = $r("app.media.shutdown")
|
||||
private shutdownLabel: Resource = $r("app.string.shutdown")
|
||||
private rebootIcon: Resource = $r("app.media.reboot")
|
||||
@ -33,47 +33,38 @@ export default struct Shortcut {
|
||||
}
|
||||
|
||||
build() {
|
||||
Row({ space:'30px' }) {
|
||||
Row({ space: '30px' }) {
|
||||
ShortcutComponent({
|
||||
mTag: 'ScreenLock-Shutdown',
|
||||
mIcon: this.shutdownIcon,
|
||||
mLabel: this.shutdownLabel,
|
||||
mClickEvent: () => this.onShutdownClick()
|
||||
mClickEvent: () => this.viewModel.onShortcutClick(Constants.CLICK_TYPE_SHUTDOWN)
|
||||
})
|
||||
|
||||
ShortcutComponent({
|
||||
mTag: 'ScreenLock-Reboot',
|
||||
mIcon: this.rebootIcon,
|
||||
mLabel: this.rebootLabel,
|
||||
mClickEvent: () => this.onRebootClick()
|
||||
mClickEvent: () => this.viewModel.onShortcutClick(Constants.CLICK_TYPE_REBOOT)
|
||||
})
|
||||
}
|
||||
.margin({left: '50px'})
|
||||
}
|
||||
|
||||
onShutdownClick() {
|
||||
Log.showInfo(TAG, `onShutdownClick`)
|
||||
power.shutdownDevice("shutdown_device")
|
||||
Log.showInfo(TAG, `power shutdown success`)
|
||||
}
|
||||
|
||||
onRebootClick() {
|
||||
Log.showInfo(TAG, `onRebootClick`)
|
||||
power.rebootDevice("reboot_device")
|
||||
Log.showInfo(TAG, `power reboot success`)
|
||||
.margin({ left: '50px' })
|
||||
}
|
||||
}
|
||||
|
||||
@Component
|
||||
struct ShortcutComponent {
|
||||
private mTag: string
|
||||
private mIcon: Resource
|
||||
private mLabel: Resource
|
||||
private mClickEvent: Function
|
||||
|
||||
aboutToAppear() {
|
||||
Log.showInfo(TAG_Shutdown, `aboutToAppear Start`)
|
||||
Log.showInfo(this.mTag, `aboutToAppear Start`)
|
||||
}
|
||||
|
||||
aboutToDisappear() {
|
||||
Log.showInfo(TAG_Shutdown, `aboutToDisAppear`)
|
||||
Log.showInfo(this.mTag, `aboutToDisAppear`)
|
||||
}
|
||||
|
||||
build() {
|
||||
@ -85,7 +76,7 @@ struct ShortcutComponent {
|
||||
.width(Constants.SHORTCUT_CIRCLE_WIDTH)
|
||||
.height(Constants.SHORTCUT_CIRCLE_HEIGHT)
|
||||
Image(this.mIcon)
|
||||
.size({ width: Constants.SHORTCUT_CIRCLE_WIDTH, height: Constants.SHORTCUT_CIRCLE_HEIGHT})
|
||||
.size({ width: Constants.SHORTCUT_CIRCLE_WIDTH, height: Constants.SHORTCUT_CIRCLE_HEIGHT })
|
||||
.objectFit(ImageFit.Contain)
|
||||
}
|
||||
|
@ -0,0 +1,37 @@
|
||||
/**
|
||||
* Copyright (c) 2022 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 Log from '../../../../../../../../common/src/main/ets/default/Log.ets'
|
||||
import Constants from '../common/constants'
|
||||
import power from '@ohos.power'
|
||||
|
||||
const TAG = 'ScreenLock-ShortcutViewModel'
|
||||
|
||||
export default class ShortcutViewModel {
|
||||
onShortcutClick(shortcutType: string) {
|
||||
Log.showInfo(TAG, `onShortcutClick ${shortcutType}`)
|
||||
switch (shortcutType) {
|
||||
case Constants.CLICK_TYPE_SHUTDOWN:
|
||||
power.shutdownDevice("shutdown_device")
|
||||
break;
|
||||
case Constants.CLICK_TYPE_REBOOT:
|
||||
power.rebootDevice("reboot_device")
|
||||
break;
|
||||
default:
|
||||
Log.showError(TAG, `${shortcutType} is not support`)
|
||||
}
|
||||
Log.showInfo(TAG, `onShortcutClick ${shortcutType} success`)
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
{
|
||||
"color": [
|
||||
{
|
||||
"name": "shortcut_icon_color",
|
||||
"value": "rgba(255, 255, 255, 0.5)"
|
||||
},
|
||||
{
|
||||
"name": "shortcut_text_color",
|
||||
"value": "#ffffff"
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
{
|
||||
"string": [
|
||||
{
|
||||
"name": "shutdown",
|
||||
"value": "关机"
|
||||
},
|
||||
{
|
||||
"name": "reboot",
|
||||
"value": "重启"
|
||||
}
|
||||
]
|
||||
}
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.1 KiB |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
@ -0,0 +1,12 @@
|
||||
{
|
||||
"string": [
|
||||
{
|
||||
"name": "shutdown",
|
||||
"value": "shutdown"
|
||||
},
|
||||
{
|
||||
"name": "reboot",
|
||||
"value": "reboot"
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
{
|
||||
"string": [
|
||||
{
|
||||
"name": "shutdown",
|
||||
"value": "关机"
|
||||
},
|
||||
{
|
||||
"name": "reboot",
|
||||
"value": "重启"
|
||||
}
|
||||
]
|
||||
}
|
21
features/wallpapercomponent/build.gradle
Normal file
21
features/wallpapercomponent/build.gradle
Normal file
@ -0,0 +1,21 @@
|
||||
apply plugin: 'com.huawei.ohos.library'
|
||||
//For instructions on signature configuration, see https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ide_debug_device-0000001053822404#section1112183053510
|
||||
ohos {
|
||||
compileSdkVersion rootProject.ext.version.compileSdk
|
||||
defaultConfig {
|
||||
compatibleSdkVersion rootProject.ext.version.compatibleSdk
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
proguardOpt {
|
||||
proguardEnabled false
|
||||
rulesFiles 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar', '*.har'])
|
||||
implementation project(':common')
|
||||
}
|
23
features/wallpapercomponent/src/main/config.json
Normal file
23
features/wallpapercomponent/src/main/config.json
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
"app": {
|
||||
"bundleName": "com.ohos.screenlock",
|
||||
"vendor": "ohos",
|
||||
"version": {
|
||||
"code": 1000000,
|
||||
"name": "1.0.0"
|
||||
}
|
||||
},
|
||||
"deviceConfig": {},
|
||||
"module": {
|
||||
"package": "com.ohos.screenlock.wallpapercomponent",
|
||||
"deviceType": [
|
||||
"phone"
|
||||
],
|
||||
"distro": {
|
||||
"deliveryWithInstall": true,
|
||||
"moduleName": "wallpapercomponent",
|
||||
"moduleType": "har"
|
||||
},
|
||||
"srcPath": "default"
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2022 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 default class Constants {
|
||||
//layout params - Pic
|
||||
static FULL_CONTAINER_WIDTH = '100%'
|
||||
static FULL_CONTAINER_HEIGHT = '100%'
|
||||
}
|
@ -14,8 +14,8 @@
|
||||
*/
|
||||
|
||||
import Log from '../../../../../../../../../common/src/main/ets/default/Log.ets'
|
||||
import ViewModel from '../../vm/wallpaperViewModel.ets'
|
||||
import Constants from '../../common/constants.ets'
|
||||
import ViewModel from '../../vm/wallpaperViewModel'
|
||||
import Constants from '../../common/constants'
|
||||
|
||||
const TAG = 'ScreenLock-Wallpaper'
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 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
|
||||
@ -13,24 +13,29 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import ScreenLockModel from '../model/screenLockModel.ets'
|
||||
import WallpaperMar from '@ohos.app.wallpaperability'
|
||||
import Log from '../../../../../../../../common/src/main/ets/default/Log.ets'
|
||||
//TODO:import image from '@ohos.multimedia.image'
|
||||
|
||||
const TAG = 'ScreenLock-WallpaperViewModel'
|
||||
|
||||
export default class WallpaperViewModel {
|
||||
screenlockWallpaper: string = ''
|
||||
screenlockWallpaper: string = ''
|
||||
|
||||
ViewModelInit(): void{
|
||||
Log.showInfo(TAG, 'ViewModelInit');
|
||||
ScreenLockModel.getScreenLockWallpaper((error, data) => {
|
||||
if (error != undefined && error != null) {
|
||||
Log.showInfo(TAG, 'getScreenLockWallpaper error:' + JSON.stringify(error));
|
||||
} else {
|
||||
Log.showInfo(TAG, 'getScreenLockWallpaper data:' + JSON.stringify(data));
|
||||
this.screenlockWallpaper = data
|
||||
}
|
||||
})
|
||||
}
|
||||
ViewModelInit(): void{
|
||||
Log.showInfo(TAG, 'ViewModelInit');
|
||||
this.getScreenLockWallpaper()
|
||||
}
|
||||
|
||||
private getScreenLockWallpaper() {
|
||||
Log.showInfo(TAG, 'getScreenLockWallpaper');
|
||||
WallpaperMar.getPixelMap(WallpaperMar.WALLPAPER_LOCKSCREEN, (error, data) => {
|
||||
if (error != undefined && error != null) {
|
||||
Log.showInfo(TAG, 'getScreenLockWallpaper error:' + JSON.stringify(error));
|
||||
} else {
|
||||
Log.showInfo(TAG, 'getScreenLockWallpaper data:' + JSON.stringify(data));
|
||||
this.screenlockWallpaper = data
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
@ -20,5 +20,8 @@ dependencies {
|
||||
entryImplementation project(':entry')
|
||||
implementation project(':common')
|
||||
implementation project(':features:screenlock')
|
||||
implementation project(':features:datetimecomponent')
|
||||
implementation project(':features:shortcutcomponent')
|
||||
implementation project(':features:wallpapercomponent')
|
||||
implementation project(':features:noticeitem')
|
||||
}
|
||||
|
@ -15,13 +15,13 @@
|
||||
|
||||
import Log from '../../../../../../../common/src/main/ets/default/Log.ets'
|
||||
import Accounts from '../../../../../../../features/screenlock/src/main/ets/com/ohos/view/component/accounts.ets'
|
||||
import DateTime from '../../../../../../../features/screenlock/src/main/ets/com/ohos/view/component/dateTime.ets'
|
||||
import DateTime from '../../../../../../../features/datetimecomponent/src/main/ets/com/ohos/view/component/dateTime.ets'
|
||||
import BatterySoc from '../../../../../../../features/screenlock/src/main/ets/com/ohos/view/component/batterySoc.ets'
|
||||
import LockIcon from '../../../../../../../features/screenlock/src/main/ets/com/ohos/view/component/lockIcon.ets'
|
||||
import Wallpaper from '../../../../../../../features/screenlock/src/main/ets/com/ohos/view/component/wallpaper.ets'
|
||||
import Wallpaper from '../../../../../../../features/wallpapercomponent/src/main/ets/com/ohos/view/component/wallpaper.ets'
|
||||
import NotificationListComponent from '../../../../../../../features/noticeitem/src/main/ets/com/ohos/noticeItem/view/NotificationListComponent.ets'
|
||||
import StatusBar from '../../../../../../../features/screenlock/src/main/ets/com/ohos/view/component/statusBar.ets'
|
||||
import Shortcut from '../../../../../../../features/screenlock/src/main/ets/com/ohos/view/component/shortcut.ets'
|
||||
import Shortcut from '../../../../../../../features/shortcutcomponent/src/main/ets/com/ohos/view/component/shortcut.ets'
|
||||
import Constants from '../common/constants.ets'
|
||||
import ViewModel from '../vm/slideScreenLockViewModel.ets'
|
||||
|
||||
@ -49,6 +49,7 @@ export default struct SlideScreenlock {
|
||||
Column() {
|
||||
StatusBar()
|
||||
}
|
||||
|
||||
Column() {
|
||||
Row() {
|
||||
Shortcut()
|
||||
@ -58,6 +59,7 @@ export default struct SlideScreenlock {
|
||||
.width(Constants.NOTIFICATION_AREA_WIDTH)
|
||||
.height($r('app.float.shortcut_area_height'))
|
||||
}
|
||||
|
||||
Column() {
|
||||
LockIcon()
|
||||
}.height($r('app.float.lockicon_area_height'))
|
||||
@ -65,7 +67,7 @@ export default struct SlideScreenlock {
|
||||
Column() {
|
||||
DateTime({ isShowData: false })
|
||||
}.height($r('app.float.datetime_area_height'))
|
||||
.margin({ top: $r('app.float.datetime_margin_top')})
|
||||
.margin({ top: $r('app.float.datetime_margin_top') })
|
||||
|
||||
Column() {
|
||||
BatterySoc()
|
||||
|
@ -20,5 +20,8 @@ dependencies {
|
||||
entryImplementation project(':entry')
|
||||
implementation project(':common')
|
||||
implementation project(':features:screenlock')
|
||||
implementation project(':features:datetimecomponent')
|
||||
implementation project(':features:shortcutcomponent')
|
||||
implementation project(':features:wallpapercomponent')
|
||||
implementation project(':features:noticeitem')
|
||||
}
|
||||
|
@ -15,9 +15,9 @@
|
||||
|
||||
import Log from '../../../../../../../common/src/main/ets/default/Log.ets'
|
||||
import Accounts from '../../../../../../../features/screenlock/src/main/ets/com/ohos/view/component/accounts.ets'
|
||||
import DateTime from '../../../../../../../features/screenlock/src/main/ets/com/ohos/view/component/dateTime.ets'
|
||||
import DateTime from '../../../../../../../features/datetimecomponent/src/main/ets/com/ohos/view/component/dateTime.ets'
|
||||
import LockIcon from '../../../../../../../features/screenlock/src/main/ets/com/ohos/view/component/lockIcon.ets'
|
||||
import Wallpaper from '../../../../../../../features/screenlock/src/main/ets/com/ohos/view/component/wallpaper.ets'
|
||||
import Wallpaper from '../../../../../../../features/wallpapercomponent/src/main/ets/com/ohos/view/component/wallpaper.ets'
|
||||
import NotificationListComponent from '../../../../../../../features/noticeitem/src/main/ets/com/ohos/noticeItem/view/NotificationListComponent.ets'
|
||||
import StatusBar from '../../../../../../../features/screenlock/src/main/ets/com/ohos/view/component/statusBar.ets'
|
||||
import Constants from '../common/constants.ets'
|
||||
|
@ -12,7 +12,8 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
include ':entry',':phone', ':pc', ':common', ':features:screenlock',
|
||||
':features:noticeitem', ':features:notificationservice',':features:batterycomponent'
|
||||
include ':entry', ':phone', ':pc', ':common', ':features:screenlock',
|
||||
':features:noticeitem', ':features:notificationservice', ':features:batterycomponent',
|
||||
':features:datetimecomponent', ':features:wallpapercomponent', ':features:shortcutcomponent'
|
||||
project(':phone').projectDir = new File('./product/phone')
|
||||
project(':pc').projectDir = new File('./product/pc')
|
Loading…
Reference in New Issue
Block a user