update laucher to support Api9

Signed-off-by: 杨怀毅 <yanghuaiyi1@huawei.com>
This commit is contained in:
杨怀毅 2022-04-10 13:42:54 +08:00
parent 554896c3cb
commit 9fb21fd133
374 changed files with 8130 additions and 7454 deletions

233
.eslintrc.json Normal file
View File

@ -0,0 +1,233 @@
{
"env": {
"es2017": true,
"node": true
},
"extends": [],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module",
"project": "tsconfig.json"
},
"plugins": [
"@typescript-eslint"
],
"rules": {
"indent": [
"error",
2
],
"quotes": [
"error",
"single"
],
"semi": [
"error",
"always"
],
"max-lines": [
"warn", 2000
],
"max-lines-per-function": [
"warn", 50
],
"complexity": [
"warn", 20
],
"max-depth": [
"warn", 4
],
"@typescript-eslint/array-type": [
"error",
{
"options":
"array"
}
],
"@typescript-eslint/prefer-as-const": [
"error"
],
"@typescript-eslint/no-inferrable-types": [
"error",
{
"ignoreParameters": false,
"ignoreProperties": false
}
],
"@typescript-eslint/method-signature-style": ["error", "method"],
"@typescript-eslint/naming-convention": [ "error",
{
"selector": "default",
"format": [ "camelCase" ],
"leadingUnderscore": "forbid",
"trailingUnderscore": "forbid"
},
{
"selector": "variable",
"modifiers": ["const"],
"format": [ "camelCase", "UPPER_CASE" ],
"leadingUnderscore": "forbid",
"trailingUnderscore": "forbid"
},
{
"selector": "memberLike",
"modifiers": ["static", "readonly"],
"format": [ "UPPER_CASE" ],
"leadingUnderscore": "forbid",
"trailingUnderscore": "forbid"
},
{
"selector": "typeLike",
"format": [ "PascalCase" ]
}
],
"@typescript-eslint/no-base-to-string": [
"error",
{
"ignoredTypeNames": ["RegExp"]
}
],
"@typescript-eslint/no-confusing-non-null-assertion": ["error"],
"@typescript-eslint/no-dynamic-delete": ["error"],
"@typescript-eslint/no-empty-interface": ["error"],
"@typescript-eslint/no-explicit-any": [
"error",
{
"fixToUnknown": false,
"ignoreRestArgs": false
}
],
"@typescript-eslint/no-extra-non-null-assertion": ["error"],
"@typescript-eslint/no-floating-promises": [
"error",
{
"ignoreVoid": true,
"ignoreIIFE": false
}
],
"@typescript-eslint/no-for-in-array": ["error"],
"@typescript-eslint/no-meaningless-void-operator": [
"error",
{
"checkNever": false
}
],
"@typescript-eslint/no-invalid-void-type": [
"error",
{
"allowInGenericTypeArguments": true,
"allowAsThisParameter": false
}
],
"@typescript-eslint/prefer-readonly": ["error"],
"@typescript-eslint/prefer-string-starts-ends-with": ["error"],
"@typescript-eslint/prefer-ts-expect-error": ["error"],
"@typescript-eslint/promise-function-async": ["error"],
"@typescript-eslint/require-array-sort-compare": ["error"],
"@typescript-eslint/restrict-plus-operands": ["error"],
"@typescript-eslint/restrict-template-expressions": ["error"],
"@typescript-eslint/strict-boolean-expressions": ["error"],
"@typescript-eslint/triple-slash-reference": ["error"],
"@typescript-eslint/type-annotation-spacing": ["error"],
"@typescript-eslint/unbound-method": ["error"],
"@typescript-eslint/unified-signatures": ["error"],
"@typescript-eslint/no-unsafe-argument":["error"],
"@typescript-eslint/no-unsafe-assignment":["error"],
"@typescript-eslint/no-unsafe-call":["error"],
"@typescript-eslint/no-unsafe-member-access":["error"],
"@typescript-eslint/no-unsafe-return":["error"],
"@typescript-eslint/no-var-requires":["error"],
"@typescript-eslint/non-nullable-type-assertion-style":["error"],
"@typescript-eslint/prefer-for-of":["error"],
"@typescript-eslint/prefer-literal-enum-member":["error"],
"@typescript-eslint/prefer-optional-chain":["error"],
"@typescript-eslint/no-misused-new": ["error"],
"@typescript-eslint/no-misused-promises": [
"error",
{
"checksConditionals": true,
"checksVoidReturn": true
}
],
"@typescript-eslint/no-namespace": [
"error",
{
"allowDeclarations": false,
"allowDefinitionFiles": true
}
],
"@typescript-eslint/no-non-null-asserted-nullish-coalescing":["error"],
"@typescript-eslint/no-non-null-asserted-optional-chain":["error"],
"@typescript-eslint/no-non-null-assertion":["error"],
"@typescript-eslint/no-parameter-properties":["error"],
"@typescript-eslint/no-require-imports":["error"],
"@typescript-eslint/no-this-alias":["error"],
"@typescript-eslint/no-type-alias":["error"],
"@typescript-eslint/no-unnecessary-boolean-literal-compare":["error"],
"@typescript-eslint/no-unnecessary-condition":["error"],
"@typescript-eslint/no-unnecessary-qualifier":["error"],
"@typescript-eslint/no-unnecessary-type-arguments":["error"],
"@typescript-eslint/no-unnecessary-type-assertion":["error"],
"@typescript-eslint/no-unnecessary-type-constraint":["error"],
"@typescript-eslint/adjacent-overload-signatures": ["error"],
"@typescript-eslint/await-thenable": ["error"],
"@typescript-eslint/ban-ts-comment":[
"error",
{
"ts-expect-error": true,
"ts-ignore": true,
"ts-nocheck": true,
"ts-check": true
}
],
"@typescript-eslint/ban-tslint-comment": "error",
"@typescript-eslint/ban-types": [
"error",
{
"types": {
"Array": {
"message": "Use [] instead",
"fixWith": "[]"
},
"Boolean": {
"message": "Use boolean instead",
"fixWith": "boolean"
},
"Number": {
"message": "Use number instead",
"fixWith": "number"
},
"function": "Do not use Function",
"String": {
"message": "Use string instead",
"fixWith": "string"
},
"{}": {
"message": "Use object instead",
"fixWith": "object"
}
}
}
],
"@typescript-eslint/consistent-indexed-object-style": [ "error", "record" ],
"@typescript-eslint/explicit-function-return-type": [
"error",
{
"allowExpressions": true,
"allowTypedFunctionExpressions": true,
"allowHigherOrderFunctions": false,
"allowDirectConstAssertionInArrowFunctions": false,
"allowConciseArrowFunctionExpressionsStartingWithVoid": false
}
],
"@typescript-eslint/explicit-member-accessibility": [
"error",
{
"accessibility": "no-public"
}
]
}
}

8
.gitignore vendored Normal file
View File

@ -0,0 +1,8 @@
*.iml
build/
/.idea
/.gradle
local.properties
*.DS_Store
tsconfig.json
node_modules

14
AppScope/app.json5 Normal file
View File

@ -0,0 +1,14 @@
{
"app": {
"bundleName": "com.ohos.launcher",
"vendor": "ohos",
"versionCode": 1000000,
"versionName": "1.0.0",
"icon": "$media:app_icon",
"label": "$string:app_name",
"distributedNotificationEnabled": true,
"keepAlive": true,
"minAPIVersion": 8,
"targetAPIVersion": 9
}
}

View File

@ -0,0 +1,8 @@
{
"string": [
{
"name": "app_name",
"value": "Launcher"
}
]
}

View File

Before

Width:  |  Height:  |  Size: 6.6 KiB

After

Width:  |  Height:  |  Size: 6.6 KiB

View File

@ -1,43 +0,0 @@
# Launcher<a name="EN-US_TOPIC_0000001103554544"></a>
- [Introduction](#section11660541593)
- [Architecture](#section78574815486)
- [Directory Structure](#section161941989596)
- [Repositories Involved](#section1371113476307)
## Introduction<a name="section11660541593"></a>
The home screen launcher provides a main entry to human-machine interactions. It displays app icons for users to start or uninstall the apps, and allows users to set the home screen layout and manage recent tasks.
### Architecture<a name="section78574815486"></a>
![](figures/launcherl2-en.png)
## Directory Structure<a name="section161941989596"></a>
```
/applications/standard/launcher/
├── figures # Architecture figures
├── launcher # Main ability of the home screen, which provides the functions of displaying app icons, starting and uninstalling apps, and setting the home screen layout.
│ └── src
│ └── main
│ ├── config.json # Global configuration files
│ ├── js # JavaScript code
│ └── resources # Resource configuration files
├── recents # Ability for managing recent tasks
│ └── src
│ └── main
│ ├── config.json # Global configuration files
│ ├── js # JavaScript code
│ └── resources # Resource configuration files
├── signature # Certificate files
├── LICENSE # License files
```
## Repositories Involved<a name="section1371113476307"></a>
System apps
**applications\_standard\_launcher**

View File

@ -1,542 +1,57 @@
# Launcher 源码开发说明
## 1. 项目介绍
# 应用子系统/Launcher
- [应用子系统/Launcher](#应用子系统launcher)
- [简介](#简介)
- [目录](#目录)
- [目录结构](#目录结构)
- [约束](#约束)
- [说明](#说明)
- [使用说明](#使用说明)
- [相关仓](#相关仓)
## 简介
Launcher 作为系统人机交互的首要入口,提供应用图标的显示、点击启动、卸载应用,并提供桌面布局设置以及最近任务管理等功能。
Launcher 采用纯 JS 语言开发,开发过程中不涉及任何 Java 部分的代码。
## 2. 工程结构
Launcher 采用 扩展的TS语言eTS开发主要的结构如下
![](./figures/launcherl2-zh.png)
- **product**
业务形态层:区分不同产品、不同屏幕的各形态桌面,含有桌面窗口、个性化业务,组件的配置,以及个性化资源包。
- **feature**
公共特性层:抽象的公共特性组件集合,可以被各桌面形态引用。
- **common**
公共能力层:基础能力集,每个桌面形态都必须依赖的模块。
## 目录
### 目录结构
```
/applications
├── common # 公共模块目录
│ └── src
│ └── main
│ ├── ets # ets代码目录
│ ├── default
│ ├── base # 公共presenter层代码目录
│ ├── bean # 公共数据对象
│ ├── cache # 缓存目录
│ ├── configs # 应用配置对象目录
│ ├── constants # 应用常量对象目录
│ ├── manager # manager代码目录
│ ├── model # Model层代码目录
│ ├── settings # settings配置项
│ ├── uicomponents # 自定义组件目录
│ ├── utils # 工具类代码目录
│ ├── resources # 资源目录
│ ├── config.json # 项目配置信息
├── feature # feature层模块目录
│ └── appcenter # 应用中心模块目录
│ └── src
│ └── main
│ ├── ets # ets代码目录
│ ├── default
│ ├── common # ets代码目录
│ ├── layout # 业务特性的布局目录
│ ├── resources # 资源目录
│ ├── config.json # 项目配置信息
│ └── bigfolder # 大文件夹模块目录
│ └── src
│ └── main
│ ├── ets # ets代码目录
│ ├── default
│ ├── common # ets代码目录
│ ├── view # 业务特性的布局目录
│ ├── viewmodel # viewmodel数据刷新
│ ├── resources # 资源目录
│ ├── config.json # 项目配置信息
│ └── form # 卡片模块目录
│ └── src
│ └── main
│ ├── ets # ets代码目录
│ ├── default
│ ├── common # ets代码目录
│ ├── layout # 业务特性的布局目录
│ ├── resources # 资源目录
│ ├── config.json # 项目配置信息
│ └── gesturenavigation # 桌面设置模块目录
│ └── src
│ └── main
│ ├── ets # ets代码目录
│ ├── default
│ ├── common # ts代码目录
│ ├── resources # 资源目录
│ ├── config.json # 项目配置信息
│ └── launcherlayout # 桌面布局计算模块目录
│ └── src
│ └── main
│ ├── ets # ets代码目录
│ ├── default
│ ├── common # ts代码目录
│ ├── resources # 资源目录
│ ├── config.json # 项目配置信息
│ └── pagedesktop # 桌面首页模块目录
│ └── src
│ └── main
│ ├── ets # ets代码目录
│ ├── default
│ ├── common # ets代码目录
│ ├── components # 自定义组件目录
│ ├── constants # 应用常量对象目录
│ ├── model # model层代码目录
│ ├── viewmodel # viewmodel层代码目录
│ ├── layout # 业务特性的View层目录
│ ├── resources # 资源目录
│ ├── config.json # 项目配置信息
│ └── recents # 最近任务模块目录
│ └── src
│ └── main
│ ├── ets # ets代码目录
│ ├── default
│ ├── common # ets代码目
│ ├── pages # 业务特性的View层目录
│ ├── resources # 资源目录
│ ├── config.json # 项目配置信息
│ └── settings # 桌面设置模块目录
│ └── src
│ └── main
│ ├── ets # ets代码目录
│ ├── default
│ ├── common # ets代码目录
│ ├── constants # 应用常量对象目录
│ ├── presenter # presenter层代码目录
│ ├── pages # 业务特性的View层目录
│ ├── resources # 资源目录
│ ├── config.json # 项目配置信息
│ └── smartdock # dock栏模块目录
│ └── src
│ └── main
│ ├── ets # ets代码目录
│ ├── default
│ ├── common # ets代码目录
│ ├── constants # 应用常量对象目录
│ ├── presenter # presenter层代码目录
│ ├── pages # 业务特性的View层目录
│ ├── resources # 资源目录
│ ├── config.json # 项目配置信息
├── product # 产品层模块目录
│ └── pad # pad模式模块目录
│ └── src
│ └── main
│ ├── ets # ets代码目录
│ ├── default
│ ├── common # ets代码目录
│ ├── configs # 应用配置对象目录
│ ├── constants # 应用常量对象目录
│ ├── pics # 应用图片目录
│ ├── pages # 业务特性的View层目录
│ ├── resources # 资源目录
│ ├── config.json # 项目配置信息
│ └── phone # phone模式模块目录
│ └── src
│ └── main
│ ├── ets # ets代码目录
│ ├── default
│ ├── common # ets代码目录
│ ├── configs # 应用配置对象目录
│ ├── constants # 应用常量对象目录
│ ├── pics # 应用图片目录
│ ├── pages # 业务特性的View层目录
│ ├── resources # 资源目录
│ ├── config.json # 项目配置信息
/applications/standard/launcher/
├── common # 公共能力层目录
├── docs # 开发指南
├── feature # 公共特性层目录
│ └── appcenter # 应用中心
│ └── bigfolder # 智能文件夹
│ ├── form # 桌面卡片管理功能
│ ├── gesturenavigation # 手势导航
│ ├── pagedesktop # 工作区
│ ├── recents # 最近任务
│ ├── settings # 桌面设置
│ ├── smartdock # dock工具栏
├── product # 业务形态层目录
├── signature # 签名证书
```
### 整体架构
![](./figures/launcherl2-en.png)
Launcher 整体以 OpenHarmony 既有的 MVVM 的 App 架构设计为基础,向下扩展出一套 MVPView, Presenter, Model分层架构既有的 MVVM 框架整体理解为新扩展的 MVP 框架的 View 层),用于处理 Launcher 的业务逻辑与数据管理。
应用整体采用了多模块的设计方式,每个模块都遵循上述架构原则。
各层的作用分别如下:
- 视图层View负责更新 UI 显示以及触摸与点击事件的监听。
- 展现层Presenter负责处理视图层View发送的业务逻辑处理请求并连通 Model 层获取数据。
- 模型层Model负责处理展现层Presenter 中关于数据处理的请求以及返回数据请求结果。
应用各层中重要类及其功能如下表所示
|模块|层级|类名|作用|
|-|-|-|-|
|launcher|视图层|EntryView|桌面入口画面的视图层逻辑控制类。|
|launcher|视图层|AppGridView|桌面网格视图画面的视图层逻辑控制类。|
|launcher|视图层|AppListView|桌面列表视图画面的视图层逻辑控制类。|
|launcher|展现层|EntryPresenter|桌面入口画面的展现层业务逻辑类,主要职责是判断桌面类型,以决定展现网格视图或者列表视图。|
|launcher|展现层|AppGridPresenter|桌面网格布局的展现层业务逻辑类,主要职责是接收视图层请求,处理逻辑业务,业务逻辑处理后实现功能或者向模型层发送请求。|
|launcher|展现层|AppListPresenter|桌面列表布局的展现层业务逻辑类,主要职责是接收视图层请求,处理逻辑业务,业务逻辑处理后实现功能或者向模型层发送请求。|
|launcher|模型层|AppModel|接收展现层AppGridPresenter和AppListPresenter发送过来的请求为其提供所需要的数据或实现其请求的功能。|
|launcher|模型层|SettingsModel|接收展现层EntryPresenter和SettingsPresenter发送过来的请求为其提供所需要的数据或实现其请求的功能。|
|recent|视图层|RecentsView|最近任务列表视图画面的视图层逻辑控制类。|
|recent|展现层|RecentsPresenter|最近任务列表的展现层业务逻辑类,主要职责是接收视图层请求,处理逻辑业务,业务逻辑处理后实现功能或者向模型层发送请求。|
|recent|模型层|RecentsModel|接收展现层RecentsPresenter发送过来的请求为其提供所需要的数据或实现其请求的功能。|
|settings|视图层|SettingsView|桌面设置画面的视图层层逻辑控制类。|
|settings|展现层|SettingsPresenter|设置桌面画面的业务逻辑类,主要职责是处理来自视图层的请求,业务逻辑处理后实现功能或者向模型层发送请求。|
|settings|模型层|SettingsModel|接收展现层EntryPresenter和SettingsPresenter发送过来的请求为其提供所需要的数据或实现其请求的功能。|
## 3. 基础开发说明
### 异步回调的使用
在JS工程中异步回调的使用是一个非常常见的编码需求在 OpenHarmony 的开发中也不例外,这里以获取应用列表信息为例,演示如何在 OpenHarmony 的应用开发中使用回调方法。
假设我们的系统结构为MVP现在要在Presenter`AppPresenter.js`层获取Model`AppModel.js`层提供的应用列表数据并返回给View`AppView.js`)层中使用。
1. 在 `AppModel.js` 中添加获取应用信息的方法。
```JS
import BundleMgr from '@ohos.bundle';
export default class AppModel {
// 获取应用信息
getApplicationInfos(callback) {
// callback 为传入的异步回调方法
BundleMgr.getAllBundleInfo().then(data => {
// 在获取数据成功后,执行回调方法
callback(data);
});
}
}
```
2. 在 `AppPresenter.js` 中定义供 View 层获取数据的方法 `getApplicationInfos(callback)`
```JS
export default class AppPresenter {
constructor(AppModel) {
this.appModel = AppModel;
}
// 获取应用信息
getApplicationInfos(callback) {
appModel.getApplicationInfos(callback);
}
}
```
3. 在 `AppView.js` 中定义获取数据的回调方法 `applicationInfosCallback(data)` (即上文中的 `AppModel.getApplicationInfos(callback)` 中的 `callback` 参数),并将其绑定到 `AppPresenter.getApplicationInfos(callback)``callback` 参数。
```JS
import AppPresenter from './AppListPresenter.js';
var appPresenter;
export default {
data: {
appList: []
},
onInit() {
appPresenter = new AppPresenter(this.$app.$def.data.appModel);
// 绑定回调方法
appPresenter.getApplicationInfos(this.applicationInfosCallback.bind(this))
},
// 定义获取数据的回调方法
applicationInfosCallback(data) {
this.appList = data;
}
}
```
这样,在 `AppModel.js` 中获取数据的方法 `getApplicationInfos` 异步执行成功后,就会将数据通过我们绑定的回调方法,回传到 `AppView.js` 中。
### 资源引用
#### 定义资源文件
- 在 `src/main/resources/`目录下,根据不同的资源类型,定义资源文件。
#### 引用资源
- 在有对应page的js文件中可直接通过`$r()`引用。
```` JavaScript
this.title = this.$r('app.string.title');
````
## 4. 典型接口的使用
1. 启动 Ability
```JS
import FeatureAbility from '@ohos.ability.featureAbility';
//参数paramAbilityname, paramBundleName 是对应应用的abilitynamebundleName
startAbility(paramAbilityname, paramBundleName) {
FeatureAbility.startAbility({
bundleName: paramBundleName,
abilityName: paramAbilityname,
requestCode: 1,
abilityType: "PageAbility",
want:{
action: "action1",
entities: ["entity1"],
type: "PageAbility",
flags: 2,
elementName: {
deviceId : "deviceId",
bundleName : paramBundleName,
abilityName : paramAbilityname,
},
},
syncOption: 1,
}).then(data =>
console.info("Launcher promise::then : " + JSON.stringify(data))
).catch(error =>
console.info("Launcher promise::catch : " +JSON.stringify(error) )
);
}
```
2. 查询应用 bundle 信息
```JS
import BundleMgr from '@ohos.bundle';
//参数bundleName 是对应应用的bundleName
getBundleInfo(bundleName) {
BundleMgr.getBundleInfo(bundleName).then(data => {
console.info('Launcher getBundleInfo ' + data);
});
}
```
3. 查询所有应用信息
```JS
import BundleMgr from '@ohos.bundle';
getApplicationInfos() {
BundleMgr.getAllBundleInfo().then((data) => {
console.info('Launcher getAllBundleInfo '+JSON.stringify(data));
});
}
```
4. 卸载应用
```JS
import BundleMgr from '@ohos.bundle';
//参数bundleName 是对应应用的bundleName
uninstallApp(bundleName) {
var result = BundleMgr.getBundleInstaller().then((data) =>{
data.uninstall(bundleName,{
param: {
userId: 0,
installFlag: 0,
isKeepData: false
}
})
console.info("Launcher uninstall data [" + JSON.stringfy(data) + "]");
}).catch(error => console.info("Launcher uninstall err " + error));
}
```
5. Preferences 存取数据
```JS
import storage from '@ohos.data.storage';
//保存数据的落盘位置
const PREFERENCES_PATH = '/data/accounts/account_0/appdata/com.ohos.launcher/sharedPreference/LauncherPreference';
//键值对标识key类似localStorage用法
const PREFERENCES_KEY = 'PREFERENCES_KEY';
save(data) {
mPreferences.putSync(PREFERENCES_KEY, data);
mPreferences.flushSync();
}
get() {
var data = mPreferences.getSync(PREFERENCES_KEY, "defaultValue");
return data;
}
```
6. 获取最近任务列表
```JS
import NapiAbilityManager from '@ohos.app.abilityManager';
getRecentMissions() {
NapiAbilityManager.queryRunningAbilityMissionInfos().then((data) => {
console.info("Launcher getRecentMissions data [" + data + "]");
});
}
```
7. 移除指定任务
```JS
import NapiAbilityManager from '@ohos.app.abilityManager';
//参数missionId是所选择的最近任务的missionId
removeMission() {
NapiAbilityManager.removeMission(missionId).then((data) => {
console.info('Launcher removeMission data [' + data + ']');
});
}
```
## 5. 签名打包
### 签名
#### 签名文件的获取
1. 拷贝 OpenHarmony 标准版的 prebuilts\signcenter 目录到操作目录。
2. 拷贝Launcher工程的 signature\launcher.p7b 到该目录下。
备注如果需要生成并使用自己的签名文件可参考https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/quick-start/configuring-openharmony-app-signature.md
#### 签名文件的配置
打开项目工程,选择 File → Project Structure
![](./figures/signature_1.png)
选择 Modules → Signing Configs将对应的签名文件配置如下完成后点击Apply再点击OK。
密码为生成签名文件时的密码如果使用默认的签名文件则使用默认密码123456。
![](./figures/signature_2.png)
配置完成后对应的build.gradle文件中会出现如下内容
![](./figures/signature_3.png)
### 打包
DevEco Studio 支持 debug 与 release 两种打包类型。可以在 OhosBuild Variants 窗口中进行切换。
![](./figures/ds_ohosbuild_variants.png)
#### release打包
1. 代码准备完成后,在 OhosBuild Variants 窗口的 Selected Variant 中选择 release
![](./figures/ds_ohosbuild_variants_release.png)
2. 选择Build → Build Haps(s)/APP(s) → Build Hap(s)
![](./figures/ds_build_haps.png)
3. 编译完成后hap包会生成在工程目录下的 `\build\outputs\hap\release\`路径下如果没有配置签名则只会生成未签名的hap包
![](./figures/ds_ohosbuild_output_dir_release.png)
## 6. 安装、运行、调试
### 应用安装
配置 hdc
进入SDK目录中的toolchains文件夹下获取文件路径
![](./figures/sdk_catalogue.png)
并将此路径配置到环境变量中:
![](./figures/sdk_environment_variable.png)
连接开发板打开一个新的cmd命令窗口执行`hdc list targets`,弹出窗口如下:
![](./figures/cmd1.png)
等待一段时间后,窗口出现如下打印,可回到输入 hdc list targets 的命令窗口继续操作:
![](./figures/cmd2.png)
再次输入hdc list targets出现如下结果说明hdc连接成功
![](./figures/cmd3.png)
获取 root 权限与读写权限:
```
hdc target mount
```
***T.B.D smode 不执行的情况下hdc target mount 能否正常执行?***
将签名好的 hap 包放入设备的 `/system/app` 目录下并修改hap包的权限。发送文件命令如下
```
hdc file send 本地路径 /system/app/hap包名称
```
例:将当前本地目录的 `Launcher.hap` 文件放入到 `system/app/Launcher.hap` 文件中。
```
hdc file send Launcher.hap /system/app/Launcher.hap
```
> 注意,如果设备不存在 `/system/app` 目录,则需要手动创建该目录并修改权限。
> ```
> hdc shell
> cd system
> mkdir app
> chmod 777 app
> ```
> `/system/app` 目录放置系统应用例如LauncherSystemUISettings 等。
>
> 但hap包需要在该目录下手动设置权限
> ```
> chmod 666 hap包名
> ```
> 此目录应用不用手动安装,系统自动拉起。
### 应用运行
Launcher 属于系统应用,在将签名的 hap 包放入 `/system/app` 目录后,重启系统,应用会自动拉起。
```
hdc shell
reboot
不可以直接执行hdc reboot命令是无效的)
```
***T.B.D 直接执行 `reboot`,还是执行`hdc shell reboot`***
> 注意,如果设备之前安装过系统应用,则需要执行如下两条命令清除设备中存储的应用信息才能够在设备重启的时候将我们装入设备的新 hap 包正常拉起。
> ```
> hdc shell rm -rf /data/accounts/
> hdc shell rm -rf /data/misc_de/0/mdds/0/default/bundle_manager_service
> ```
### 应用调试
#### log打印
- 在程序中添加 log
```JS
console.info("Launcher log info");
```
可以在DevEco Studio中查看log
![](./figures/ds_hilog_window.png)
#### log获取及过滤
- log获取
将log输出至文件
```
hdc shell hilog > 输出文件名称
```
例:
在真实环境查看log将全log输出到当前目录的hilog.log文件中
```
hdc shell hilog > hilog.log
```
- log过滤
在命令行窗口中过滤log
```
hilog | grep 过滤信息
```
例:过滤包含信息 Label 的 hilog
```
hilog | grep Label
```
## 7. 贡献代码
### Fork 代码仓库
1. 在码云上打开 Launcher 代码仓库([仓库地址](https://gitee.com/openharmony/applications_launcher))。
2. 点击仓库右上角的 Forked 按钮
![](./figures/commit_source_fork_button.png)
3. 在弹出的画面中,选择将仓库 fork 到哪里,点击确认。
![](./figures/commit_source_fork_confirm.png)
4. Fork 成功之后,会在自己的账号下看见 fork 的代码仓库。
![](./figures/commit_source_forked_repo.png)
### 提交代码
1. 访问我们自己在码云账号上 fork 的代码仓库,点击“克隆/下载”按钮,选择 SSH点击“复制”按钮。
![](./figures/commit_source_clone_page.png)
2. 在本地新建 Launcher 目录,在 Launcher 目录中执行如下命令
```
git clone 步骤1中复制的地址
```
3. 修改代码。
> 将代码引入工程,以及编译工程等相关内容请参见 **3. 代码使用** 部分的相关内容。
4. 提交代码到 fork 仓库。
> 修改后的代码,首先执行 `git add` 命令,然后执行 `git commit` 命令与 `git push` 命令,将代码 push 到我们自己的 fork 仓中。
> 关于代码提交的这部分内容涉及 git 的使用,可以参照 [git官网](https://git-scm.com/) 的内容,在此不再赘述。
### 发起 Pull Request (PR)
在将代码提交到 fork 仓之后,我们可以通过发起 Pull RequestPR的方式来为 OpenHarmony 的相关项目贡献代码。
1. 打开 fork 仓库。选择 `Pull Requests``新建 Pull Request`
![](./figures/commit_source_new_pull_request.png)
2. 在 `新建 Pull Request` 画面填入标题与说明,点击 `创建` 按钮。
![](./figures/commit_source_new_pull_request_confirm.png)
3. 创建 Pull Request 完成。 PR 创建完成后,会有专门的代码审查人员对代码进行评审,评审通过之后会合入相应的代码库。
![](./figures/commit_source_new_pr_done.png)
## 约束
- 开发环境
- [DevEco Studio for OpenHarmony](https://developer.harmonyos.com/cn/develop/deveco-studio#download_beta) 版本号大于3.0.0.900下载安装OpenHarmony SDK API Version 9。初始的IDE配置可以参考IDE的使用文档
- 语言版本
- [eTS](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/quick-start/start-with-ets.md)
## 说明
### 使用说明
[使用桌面卡片管理功能调试服务卡片](https://gitee.com/OHOS_STD/applications_launcher/blob/OpenHarmony2.0_20210604/docs/使用桌面卡片管理功能调试服务卡片.md)
## 相关仓
- [applications_hap](https://gitee.com/openharmony/applications_hap)
- [applications_systemui](https://gitee.com/openharmony/applications_systemui)
- [aafwk_standard](https://gitee.com/openharmony/applications_systemui)
- [interface_sdk-js](https://gitee.com/openharmony/interface_sdk-js)

49
build-profile.json5 Normal file
View File

@ -0,0 +1,49 @@
{
"app": {
"compileSdkVersion": 9,
"compatibleSdkVersion": 9,
"products": [
{
"name": "default"
}
]
},
"modules": [
{
"name": "phone-launcher",
"srcPath": "./product/phone",
"targets": [
{
"name": "default",
"applyToProducts": [
"default",
],
},
],
},
{
"name": "pad-launcher",
"srcPath": "./product/pad",
"targets": [
{
"name": "default",
"applyToProducts": [
"default",
],
},
],
},
{
"name": "launcher_settings",
"srcPath": "./feature/settings",
"targets": [
{
"name": "default",
"applyToProducts": [
"default",
],
},
],
}
],
}

View File

@ -1,35 +0,0 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
apply plugin: 'com.huawei.ohos.app'
ohos {
compileSdkVersion 8
defaultConfig {
compatibleSdkVersion 8
}
supportSystem "standard"
}
buildscript {
repositories {
maven {
url 'https://mirrors.huaweicloud.com/repository/maven/'
}
maven {
url 'https://developer.huawei.com/repo/'
}
}
dependencies {
classpath 'com.huawei.ohos:hap:3.0.5.2'
}
}
allprojects {
repositories {
maven {
url 'https://mirrors.huaweicloud.com/repository/maven/'
}
maven {
url 'https://developer.huawei.com/repo/'
}
}
}

View File

@ -0,0 +1,6 @@
{
"apiType": 'stageMode',
"buildOption": {
"arkEnable": true
}
}

View File

@ -1,21 +0,0 @@
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 8
defaultConfig {
compatibleSdkVersion 8
}
buildTypes {
release {
proguardOpt {
proguardEnabled false
rulesFiles 'proguard-rules.pro'
}
}
}
entryModules "phone"
}
dependencies {
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
/**
* 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
@ -13,11 +13,5 @@
* limitations under the License.
*/
export default {
onCreate() {
console.info('CalleAbility Application onCreate')
},
onDestroy() {
console.info('CalleAbility Application onDestroy')
},
}
// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently.
module.exports = require('@ohos/hvigor-ohos-plugin').hapTasks

12
common/package.json Normal file
View File

@ -0,0 +1,12 @@
{
"name": "@ohos/common",
"version": "1.0.0",
"description": "a npm package which contains common function",
"ohos": {
"org": "huawei",
"buildTool": "hvigor",
"directoryLevel": "module"
},
"dependencies": {
}
}

View File

@ -1,22 +0,0 @@
{
"app": {
"bundleName": "com.ohos.launcher",
"vendor": "ohos",
"version": {
"code": 1000000,
"name": "1.0.0"
}
},
"deviceConfig": {},
"module": {
"package": "com.ohos.launcher",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "common",
"moduleType": "har"
}
}
}

View File

@ -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
@ -18,11 +18,12 @@ import AppModel from '../model/AppModel';
import AppListInfoCacheManager from '../cache/AppListInfoCacheManager';
import ResourceManager from '../manager/ResourceManager';
import CommonConstants from '../constants/CommonConstants';
import { InstallStatus } from 'bundle/bundleinstaller';
const KEY_NAME = 'name';
/**
*
* Base class for view models.
*/
export default class BaseAppPresenter {
protected mAppModel: AppModel;
@ -39,12 +40,12 @@ export default class BaseAppPresenter {
/**
* .
* Start target ability
*
* @param bundleName
* @param abilityName ability名
* @param bundleName target bundle name
* @param abilityName target ability name
*/
jumpTo(abilityName: string, bundleName: string) {
jumpTo(abilityName: string, bundleName: string): void {
launcherAbilityManager.startLauncherAbility(abilityName, bundleName);
}
@ -54,55 +55,55 @@ export default class BaseAppPresenter {
* @param bundleName
* @param abilityName
*/
jumpToForm(abilityName: string, bundleName: string, cardId: number) {
launcherAbilityManager.startAbilityForResult(abilityName, bundleName , cardId);
jumpToForm(abilityName: string, bundleName: string, cardId: number): void {
launcherAbilityManager.startAbilityFormEdit(abilityName, bundleName, cardId);
}
/**
* .
* Start launcher settings page.
*/
jumpToSetting() {
jumpToSetting(): void {
this.jumpTo(CommonConstants.SETTING_ABILITY, CommonConstants.LAUNCHER_BUNDLE);
}
/**
* .
* Uninstall target app by bundle name.
*
* @params uninstallBundleName
* @params isUninstallAble
* @param uninstallBundleName bundle name to uninstall
* @param isUninstallable true if target app is uninstallable.
*/
uninstallApp(uninstallBundleName: string, isUninstallAble: boolean) {
if (!isUninstallAble) {
uninstallApp(uninstallBundleName: string, isUninstallable: boolean): void {
if (!isUninstallable) {
this.informUninstallResult(CommonConstants.UNINSTALL_FORBID);
} else {
launcherAbilityManager.uninstallLauncherAbility(uninstallBundleName, this.uninstallAppCallback.bind(this));
void launcherAbilityManager.uninstallLauncherAbility(uninstallBundleName, this.uninstallAppCallback.bind(this));
}
}
private uninstallAppCallback(resultData) {
this.informUninstallResult(resultData.code);
private uninstallAppCallback(resultData: InstallStatus): void {
this.informUninstallResult(resultData.status);
}
registerAppListChangeCallback() {
registerAppListChangeCallback(): void {
this.mAppModel.registerStateChangeListener(this.listener);
}
unregisterAppListChangeCallback() {
unregisterAppListChangeCallback(): void {
console.info('Launcher appPresenter unregisterAppListChangeCallback');
this.mAppModel.unregisterAppStateChangeListener(this.listener);
}
appListChangeListener(appList) {
appListChangeListener(appList: []): void {
this.regroupDataAppListChange(appList);
}
regroupDataAppListChange(callbackList) {
regroupDataAppListChange(callbackList: []): void {
}
informUninstallResult(resultCode) {
informUninstallResult(resultCode: number): void {
}
getAppName(cacheKey) {
getAppName(cacheKey: string) {
return this.mResourceManager.getAppResourceCache(cacheKey, KEY_NAME);
}
}

View File

@ -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
@ -32,7 +32,7 @@ interface Area {
export default abstract class BaseDragHandler {
protected mIsInEffectArea = false;
protected mDragEffectArea: Area = null;
protected mDragEffectArea: Area | undefined;
private mDragStateListener = null;
@ -69,7 +69,7 @@ export default abstract class BaseDragHandler {
/**
* (ready后删除)
*/
protected getDragEffectArea(): Area {
protected getDragEffectArea(): Area | undefined {
return this.mDragEffectArea;
}

View File

@ -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

View File

@ -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

View File

@ -1,44 +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 rpc from '@ohos.rpc';
import CommonConstants from '../constants/CommonConstants';
/**
* application badge message from call.call or call.callWithResult
*/
export default class AppBadgeMessage {
badge: number = CommonConstants.INVALID_VALUE;
bundleName = '';
constructor(badge: number, bundleName: string) {
this.badge = badge;
this.bundleName = bundleName;
}
marshalling(messageParcel) {
console.log(`AppBadgeMessage marshalling badge[${this.badge}], bundleName[${this.bundleName}]`);
messageParcel.writeInt(this.badge);
messageParcel.writeString(this.bundleName);
return true;
}
unmarshalling(messageParcel) {
console.log(`AppBadgeMessage marshalling badge[${this.badge}], bundleName[${this.bundleName}]`);
this.badge = messageParcel.readInt();
this.bundleName = messageParcel.readString();
return true;
}
}

View File

@ -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
@ -20,47 +20,47 @@ export default class AppItemInfo {
/**
* Indicates app id.
*/
appId: string;
appId: string | undefined;
/**
* Indicates app name.
*/
appName: string;
appName: string | undefined;
/**
* Indicates appIconId.
*/
appIconId: string;
appIconId: string | undefined;
/**
* Indicates appLabelId.
*/
appLabelId: string;
appLabelId: string | undefined;
/**
* Indicates bundleName.
*/
bundleName: string;
bundleName: string | undefined;
/**
* Indicates abilityName.
*/
abilityName: string;
abilityName: string | undefined;
/**
* Indicates is system App.
*/
isSystemApp: boolean;
isSystemApp: boolean | undefined;
/**
* Indicates is uninstallAble.
*/
isUninstallAble: boolean;
isUninstallAble: boolean | undefined;
/**
* badge number
*/
badgeNumber: number;
badgeNumber: number | undefined;
checked: boolean;
checked: boolean | undefined;
}

View File

@ -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
@ -21,26 +21,26 @@ export default class BadgeItemInfo {
/**
* id
*/
id: string;
id: string | undefined;
/**
* application bundle name
*/
bundleName: string;
bundleName: string | undefined;
/**
* badge number in app
*/
badgeNumber: number;
badgeNumber: number | undefined;
/**
* badge display flag
*/
display: boolean;
display: boolean | undefined;
/**
* belong user
*/
userId: number;
userId: number | undefined;
}

View File

@ -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
@ -20,37 +20,37 @@ export default class CardItemInfo {
/**
* Indicates form id
*/
cardId: number;
cardId: number | undefined;
/**
* Indicates form bundleName.
*/
bundleName: string;
bundleName: string | undefined;
/**
* Indicates form abilityName.
*/
abilityName: string;
abilityName: string | undefined;
/**
* Indicates form moduleName.
*/
moduleName: string;
moduleName: string | undefined;
/**
* Indicates cardName.
*/
cardName: string;
cardName: string | undefined;
/**
* Indicates form dimension.
*/
cardDimension: number;
cardDimension: number | undefined;
/**
* Indicates form size.
*/
area: number[];
area: number[] | undefined;
/**
* Indicates form description.
@ -60,21 +60,21 @@ export default class CardItemInfo {
/**
* Indicates form formConfigAbility.
*/
formConfigAbility: string;
formConfigAbility: string | undefined;
/**
* Indicates form of app labelId.
*/
appLabelId: number;
appLabelId: number | undefined;
/**
* Indicates form of app name.
*/
appName: string;
appName: string | undefined;
/**
* Indicates form of support Dimensions.
*/
supportDimensions: number[];
supportDimensions: number[] | undefined;
}

View File

@ -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
@ -25,10 +25,10 @@ export default class DockItemInfo extends AppItemInfo {
* 1
* 2
*/
itemType: number;
itemType: number | undefined;
/**
* dock是否可编辑
*/
editable: boolean;
editable: boolean | undefined;
}

View File

@ -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
@ -21,15 +21,15 @@ export default class FolderItemInfo {
/**
* id
*/
folderId: string;
folderId: string | undefined;
/**
*
*/
folderName: string;
folderName: string | undefined;
/**
*
*/
appList: string[];
appList: string[] | undefined;
}

View File

@ -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
@ -42,7 +42,7 @@ export default class MenuInfo {
/**
*
*/
onMenuClick: Function = null;
onMenuClick: Function | undefined;
/**
* shortcut icon Id
@ -57,5 +57,5 @@ export default class MenuInfo {
/**
* bundleName
*/
bundleName: string = null;
bundleName: string | undefined;
}

View File

@ -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
@ -20,17 +20,17 @@ export default class MissionInfo {
/**
* Indicates mission id.
*/
missionId: number;
missionId: number | undefined;
/**
* Indicates running state.
*/
runningState: number;
runningState: number | undefined;
/**
* Indicates locked state.
*/
lockedState: boolean;
lockedState: boolean | undefined;
/**
* Indicates mission snapshot.

View File

@ -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
@ -20,5 +20,5 @@ import AppItemInfo from './AppItemInfo';
* Recent mission info
*/
export default class RecentBundleMissionInfo extends AppItemInfo {
missionInfoList: MissionInfo[];
missionInfoList: MissionInfo[] | undefined;
}

View File

@ -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
@ -20,35 +20,35 @@ export default class RecentMissionInfo {
/**
* Recent mission: mission id
*/
missionId: number;
missionId: number | undefined;
/**
* Recent mission: app name
*/
appName: string;
appName: string | undefined;
/**
* Recent mission: app icon Id
*/
appIconId: string;
appIconId: string | undefined;
/**
* Recent mission: app label Id
*/
appLabelId: string;
appLabelId: string | undefined;
/**
* Recent mission: bundle name
*/
bundleName: string;
bundleName: string | undefined;
/**
* Recent mission: ability name
*/
abilityName: string;
abilityName: string | undefined;
/**
* Recent mission: lock status
*/
lockedState: boolean;
lockedState: boolean | undefined;
}

View File

@ -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
@ -21,17 +21,17 @@ export default class SettingItemInfo {
/**
*
*/
ida: number;
ida: number | undefined;
/**
*
*/
settingName: string;
settingName: string | undefined;
/**
*
*/
settingValue: string;
settingValue: string | undefined;
/**
*
@ -41,5 +41,5 @@ export default class SettingItemInfo {
/**
* settings option type.
*/
settingType: number;
settingType: number | undefined;
}

View File

@ -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
@ -20,15 +20,15 @@ export default class SettingItemOption {
/**
*
*/
name: string;
name: string | undefined;
/**
*
*/
value: string;
value: string | undefined;
/**
*
*/
checked: boolean;
checked: boolean | undefined;
}

View File

@ -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

View File

@ -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
@ -37,7 +37,7 @@ export default class AppResourceCacheManager {
* @param {string} key - key of the cache map
* @return {object} - cache get from memory or disk
*/
getCache(bundleName, key) {
getCache(bundleName: string, key: string) {
const cache = this.getCacheFromMemory(bundleName, key);
if (cache == undefined || cache == null || cache == '') {
if (key === KEY_ICON) {
@ -57,7 +57,7 @@ export default class AppResourceCacheManager {
* @param {string} key - key of the cache map
* @param {object} value - value of the cache map
*/
setCache(bundleName, key, value) {
setCache(bundleName: string, key: string, value: object | string) {
console.info('Launcher AppResourceCacheManager setCache bundleName = ' + bundleName + ' key = ' + key);
this.setCacheToMemory(bundleName, key, value);
if (key === KEY_ICON) {
@ -73,7 +73,7 @@ export default class AppResourceCacheManager {
this.memoryCache.clear();
}
private getCacheFromMemory(bundleName, key) {
private getCacheFromMemory(bundleName: string, key: string) {
const cache = this.memoryCache.getCache(bundleName);
if (cache == undefined || cache == null || cache == '' || cache === -1) {
return null;
@ -84,7 +84,7 @@ export default class AppResourceCacheManager {
}
}
private setCacheToMemory(bundleName, key, value) {
private setCacheToMemory(bundleName: string, key: string, value: object | string) {
let cache = this.memoryCache.getCache(bundleName);
if (cache == undefined || cache == null || cache == '' || cache === -1) {
cache = {};
@ -95,12 +95,12 @@ export default class AppResourceCacheManager {
this.memoryCache.putCache(bundleName, cache);
}
private getCacheFromDisk(bundleName, key) {
private getCacheFromDisk(bundleName: string, key: string) {
const data = this.diskCache.getCache(bundleName);
return data !== DISK_CACHE_MISS ? data : null;
}
private setCacheToDisk(bundleName, key, value) {
private setCacheToDisk(bundleName: string, key: string, value: object | string) {
this.diskCache.putCache(bundleName, value);
}
}

View File

@ -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
@ -50,7 +50,7 @@ export default class DiskLruCache {
* @param {string} key - key of the cache map
* @return {object} - target cache object
*/
getCache(key) {
getCache(key: string) {
if (this.cache.has(key)) {
// exist and update
const temp = this.cache.get(key);
@ -71,7 +71,7 @@ export default class DiskLruCache {
* @param {string} key - key of the cache map
* @param {object} value - value of the cache map
*/
putCache(key, value) {
putCache(key: string, value: object | string) {
if (this.cache.has(key)) {
// exist and update
this.cache.delete(key);
@ -93,7 +93,7 @@ export default class DiskLruCache {
*
* @param {string} key - key of the cache map
*/
remove(key) {
remove(key: string) {
this.cache.delete(key);
DiskLruFileUtils.removeFile(key);
}

View File

@ -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
@ -12,8 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import Fileio from '@ohos.fileio';
import fileIO from '@ohos.fileio';
const writeFilePath = globalThis.desktopContext.cacheDir + '/';
const journalPath = writeFilePath + 'journal.txt';
@ -44,9 +43,9 @@ export default class DiskLruFileUtils {
*/
static readJsonFile(path: string): any {
console.info('Launcher FileUtil readJsonFile start execution');
let readStreamSync = null;
let readStreamSync;
try {
readStreamSync = Fileio.createStreamSync(path, 'r');
readStreamSync = fileIO.createStreamSync(path, 'r');
const content = this.getContent(readStreamSync);
console.info('Launcher FileUtil readJsonFile finish execution' + content);
return JSON.parse(content);
@ -69,7 +68,7 @@ export default class DiskLruFileUtils {
const content = JSON.stringify(jsonObj);
let writeStreamSync = null;
try {
writeStreamSync = Fileio.createStreamSync(filePath, 'w+');
writeStreamSync = fileIO.createStreamSync(filePath, 'w+');
writeStreamSync.writeSync(content);
} catch (e) {
console.info('Launcher FileUtil writeJsonObj error: ' + e);
@ -88,7 +87,7 @@ export default class DiskLruFileUtils {
let writeStreamSync = null;
try {
console.info('Launcher FileUtil writeJournal start');
writeStreamSync = Fileio.createStreamSync(journalPath, 'a+');
writeStreamSync = fileIO.createStreamSync(journalPath, 'a+');
writeStreamSync.writeSync(content + '\n');
} catch (e) {
console.info('Launcher FileUtil writeJournal error: ' + e);
@ -107,7 +106,7 @@ export default class DiskLruFileUtils {
console.info('Launcher FileUtil readJournal start execution');
let readStreamSync = null;
try {
readStreamSync = Fileio.createStreamSync(journalPath, 'r');
readStreamSync = fileIO.createStreamSync(journalPath, 'r');
return this.getContent(readStreamSync);
} catch (e) {
console.info('Launcher FileUtil readJournal error: ' + e);
@ -120,7 +119,7 @@ export default class DiskLruFileUtils {
/**
* Read JSON object from a file.
*
* @param {Fileio.Stream} readStreamSync - stream of target file
* @param {fileIO.Stream} readStreamSync - stream of target file
* @return {object} object read from file stream
*/
static getContent(readStreamSync) {
@ -164,7 +163,7 @@ export default class DiskLruFileUtils {
try {
console.info('Launcher FileUtil removeFile');
//remove file,key : bundlename
Fileio.unlinkSync(writeFilePath + bundleName + '.json');
fileIO.unlinkSync(writeFilePath + bundleName + '.json');
} catch (e) {
console.error('Launcher FileUtil removeFile delete has failed for ' + e);
}

View File

@ -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
@ -55,7 +55,7 @@ export default class FormListInfoCacheManager {
* @param {string} key - key of the cache map
* @param {object} value - value of the cache map
*/
setCache(key, value) {
setCache(key: string, value) {
console.info('Launcher FormListInfoCacheManager setCache key = ' + key + ' value = ' + value);
this.lruCache.putCache(key, value);
}

View File

@ -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
@ -17,7 +17,7 @@
* A class provides memory cache operation.
*/
export default class LruCache {
private readonly cache: Map<string, object>;
private readonly cache: Map<string, object | string>;
private readonly capacity: number;
constructor(capacity = 100) {

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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,26 +14,26 @@
*/
/**
*
* Common constants for all features.
*/
export default class CommonConstants {
/**
*
* Bundle name of launcher
*/
static LAUNCHER_BUNDLE = 'com.ohos.launcher';
/**
* Ability名
* Ability name of AppCenter.
*/
static APPCENTER_ABILITY = 'com.ohos.launcher.appcenter.MainAbility';
/**
* Ability名
* Ability name of launcher settings.
*/
static SETTING_ABILITY = 'com.ohos.launcher.settings.MainAbility';
/**
* Ability名
* Ability name of launcher Recents.
*/
static RECENT_ABILITY = 'com.ohos.launcher.recents.MainAbility';
@ -43,7 +43,7 @@ export default class CommonConstants {
static LAUNCHER_ABILITY = 'com.ohos.launcher.MainAbility';
/**
*
* Default invalid value.
*/
static INVALID_VALUE = -1;
@ -53,27 +53,27 @@ export default class CommonConstants {
static FOLDER_APP_VALUE = 1;
/**
*
* Status code if uninstal successed.
*/
static UNINSTALL_SUCCESS = 0;
/**
*
* Status code if uninstall is forbidden.
*/
static UNINSTALL_FORBID = 1;
/**
*
* Grid item type for apps.
*/
static TYPE_APP = 0;
/**
*
* Grid item type for cards.
*/
static TYPE_CARD = 1;
/**
*
* Grid item type for functions.
*/
static TYPE_FUNCTION = 2;
@ -88,22 +88,22 @@ export default class CommonConstants {
static TYPE_ADD = 4;
/**
* 1x2
* Card dimension constants for 1 row 2 columns.
*/
static CARD_DIMENSION_1x2 = 1;
/**
* 2x2
* Card dimension constants for 2 rows 2 columns.
*/
static CARD_DIMENSION_2x2 = 2;
/**
* 2x4
* Card dimension constants for 2 rows 4 columns.
*/
static CARD_DIMENSION_2x4 = 3;
/**
* 4x4
* Card dimension constants for 4 rows 4 columns.
*/
static CARD_DIMENSION_4x4 = 4;
@ -281,4 +281,9 @@ export default class CommonConstants {
* navigationbar status settingDataKey.
*/
static NAVIGATION_BAR_STATUS_KEY = 'settings.display.navigationbar_status';
/**
* setting data ability uri
*/
static SETTING_DATA_ABILITY_URI: string = 'dataability:///com.ohos.settingsdata.DataAbility';
}

View File

@ -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
@ -22,12 +22,14 @@ const EventConstants = {
EVENT_PACKAGE_REMOVED: 'usual.event.PACKAGE_REMOVED',
EVENT_REQUEST_DOCK_ITEM_ADD: 'launcher.event.REQUEST_DOCK_ITEM_ADD', //request add item to smartDock
EVENT_REQUEST_PAGEDESK_ITEM_ADD: 'launcher.event.REQUEST_PAGEDESK_ITEM_ADD', //request add item to pageDesk
EVENT_REQUEST_PAGEDESK_ITEM_DELETE: 'launcher.event.REQUEST_PAGEDESK_ITEM_DELETE', //request add item to pageDesk
EVENT_REQUEST_RESIDENT_DOCK_ITEM_DELETE: 'launcher.event.REQUEST_DOCK_ITEM_DELETE', //request delete resident item
EVENT_REQUEST_RECENT_DOCK_ITEM_DELETE: 'launcher.event.RECENT_DOCK_ITEM_DELETE', //request delete recent item
EVENT_BADGE_UPDATE: 'launcher.event.EVENT_BADGE_UPDATE',
EVENT_REQUEST_JUMP_TO_FORM_VIEW: 'launcher.event.EVENT_REQUEST_JUMP_TO_FORM_VIEW',
EVENT_REQUEST_FORM_ITEM_ADD: 'launcher.event.REQUEST_FORM_ITEM_ADD',
EVENT_FOLDER_PACKAGE_REMOVED: 'usual.event.FOLDER_PACKAGE_REMOVED'
EVENT_FOLDER_PACKAGE_REMOVED: 'usual.event.FOLDER_PACKAGE_REMOVED',
EVENT_NAVIGATOR_BAR_STATUS_CHANGE: 'usual.event.NAVIGATOR_BAR_STATUS_CHANGE'
};
export default EventConstants;

View File

@ -14,14 +14,27 @@
*/
export default class PresetStyleConstants {
//----------- default constants----------
/**
* systemUI top height
*/
static readonly DEFAULT_SYS_TOP_HEIGHT = 44;
/**
* systemUI bottom height
*/
static readonly DEFAULT_SYS_BOTTOM_HEIGHT = 44;
/**
* pad system ui height
*/
static readonly DEFAULT_PAD_SYSTEM_UI = 88;
/**
* phone system ui height
*/
static readonly DEFAULT_PHONE_SYSTEM_UI = 132;
/**
* desktop indicator height
*/
@ -31,34 +44,42 @@ export default class PresetStyleConstants {
* desktop indicator height
*/
static readonly DEFAULT_PHONE_INDICATOR_HEIGHT = 48;
/**
* columns of screen with phone
*/
static readonly DEFAULT_PHONE_GRID_APP_COLUMNS = 4;
/**
* columns of screen with pad
*/
static readonly DEFAULT_PAD_GRID_APP_COLUMNS = 12;
/**
* threshold value of dock isShow recent dock
*/
static readonly DEFAULT_DOCK_RECENT_WIDTH = 520;
/**
* padding top of icon
*/
static readonly DEFAULT_ICON_PADDING_TOP = 0;
/**
* padding left of icon
*/
static readonly DEFAULT_ICON_PADDING_LEFT = 21;
/**
* icon size
*/
static readonly DEFAULT_ICON_SIZE = 54;
/**
* text lines height
*/
static readonly DEFAULT_TEXT_LINES = 36;
/**
* padding of app center
*/
@ -68,151 +89,191 @@ export default class PresetStyleConstants {
* screen grid margin and gap
*/
static readonly DEFAULT_SCREEN_GRID_GAP_AND_MARGIN = 12;
//----------- desktop layout-------------
/**
* desktop item size
*/
static readonly DEFAULT_APP_LAYOUT_SIZE = 96;
/**
* desktop container margin
*/
static readonly DEFAULT_LAYOUT_MARGIN = 82;
/**
* desktop container minimum gutter
*/
static readonly DEFAULT_APP_LAYOUT_MIN_GUTTER = 6;
//----------- desktop icon-------------
/**
* desktop item padding top
*/
static readonly DEFAULT_APP_TOP_RATIO = 0;
/**
* desktop item name lines
*/
static readonly DEFAULT_APP_NAME_LINES = 2;
/**
* desktop item name size
*/
static readonly DEFAULT_APP_NAME_TEXT_SIZE = 18;
/**
* desktop item icon and name gap
*/
static readonly DEFAULT_ICON_NAME_GAP = 4;
/**
* desktop icon name height
*/
static readonly DEFAULT_DESKTOP_NAME_HEIGHT = 36;
/**
* desktop icon name margin
*/
static readonly DEFAULT_DESKTOP_NAME_MARGIN = 3;
//----------- desktop folder-----------
/**
* folder gutter with container size
*/
static readonly DEFAULT_FOLDER_GUTTER_RATIO = 0.06;
/**
* folder padding with container size
*/
static readonly DEFAULT_FOLDER_PADDING_RATIO = 0.1;
//----------- desktop open --------------
/**
* gutter of open folder
*/
static readonly DEFAULT_OPEN_FOLDER_GUTTER = 12;
/**
* padding of open folder
*/
static readonly DEFAULT_OPEN_FOLDER_PADDING = 16;
/**
* margin top of open folder
*/
static readonly DEFAULT_OPEN_FOLDER_MARGIN_TOP = 188;
//----------- folder add list ------------------
/**
* max height of container
*/
static readonly DEFAULT_FOLDER_ADD_MAX_HEIGHT = 0.6;
/**
* margin of container
*/
static readonly DEFAULT_FOLDER_ADD_MARGIN = 12;
/**
* gutter of container
*/
static readonly DEFAULT_FOLDER_ADD_GAP = 12;
/**
* toggle of item
*/
static readonly DEFAULT_APP_GRID_TOGGLE_SIZE = 16;
/**
* icon padding of item with item size
*/
static readonly DEFAULT_FOLDER_ADD_ICON_TOP_RATIO = 0.1;
/**
* name size of container
*/
static readonly DEFAULT_FOLDER_ADD_GRID_TEXT_SIZE = 16;
/**
* title size of container
*/
static readonly DEFAULT_FOLDER_ADD_TITLE_TEXT_SIZE = 20;
/**
* name lines of item
*/
static readonly DEFAULT_FOLDER_ADD_TEXT_LINES = 2;
/**
* button size of container
*/
static readonly DEFAULT_FOLDER_ADD_BUTTON_SIZE = 24;
//----------- app center--------------
/**
* margin left of app center
*/
static readonly DEFAULT_APP_CENTER_MARGIN = 218;
/**
* gutter of app center
*/
static readonly DEFAULT_APP_CENTER_GUTTER = 12;
/**
* item size of app center
*/
static readonly DEFAULT_APP_CENTER_SIZE = 112;
/**
* icon padding top with item size
*/
static readonly DEFAULT_APP_CENTER_TOP_RATIO = 0;
/**
* name lines of app center
*/
static readonly DEFAULT_APP_CENTER_NAME_LINES = 2;
/**
* name size of app center
*/
static readonly DEFAULT_APP_CENTER_NAME_TEXT_SIZE = 18;
static readonly DEFAULT_APP_CENTER_NAME_TEXT_SIZE = 18;
//----------- dock----------------
/**
* icon size of dock
*/
static readonly DEFAULT_DOCK_ICON_SIZE = 54;
/**
* padding of dock
*/
static readonly DEFAULT_DOCK_PADDING = 12;
/**
* gap of dock container
*/
static readonly DEFAULT_DOCK_ITEM_GAP = 8;
/**
* gap with resident and recent
*/
static readonly DEFAULT_DOCK_GUTTER = 12;
/**
* save margin of dock
*/
static readonly DEFAULT_DOCK_SAVE_MARGIN = 24;
/**
* margin bottom of dock
*/
static readonly DEFAULT_DOCK_MARGIN_BOTTOM = 10;
/**
* margin bottom of dock(Immersive navigation bar)
*/
static readonly DEFAULT_DOCK_MARGIN_BOTTOM_HIDE_BAR = 10;
}

View File

@ -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
@ -25,6 +25,7 @@ export default class StyleConstants {
static readonly DEFAULT_DIALOG_RADIUS = '24vp';
static readonly DEFAULT_DIALOG_WIDTH = '395vp';
static readonly DEFAULT_BUTTON_HEIGHT = '40vp';
static readonly DEFAULT_BUTTON_WIDTH = '120vp';
static readonly DEFAULT_COLOR_ERROR = '#FFE84026';
static readonly DEFAULT_ICON = '/common/pics/icon.png';
static readonly DEFAULT_BACKGROUND_IMAGE = '/common/pics/img_wallpaper.jpg';
@ -43,12 +44,17 @@ export default class StyleConstants {
static readonly DEFAULT_FOLDER_GRID_MARGIN= 10;
static readonly DEFAULT_FOLDER_GRID_GAP= 2;
static readonly DEFAULT_OPEN_FOLDER_APP_SIZE= 60;
static readonly DEFAULT_ADD_APP_SIZE= 54;
static readonly DEFAULT_OPEN_FOLDER_APP_NAME_SIZE= 14;
static readonly DEFAULT_OPEN_FOLDER_APP_NAME_HEIGHT= 36;
static readonly DEFAULT_OPEN_FOLDER_GRID_WIDTH= 444;
static readonly DEFAULT_OPEN_FOLDER_GRID_HEIGHT= 455;
static readonly DEFAULT_OPEN_FOLDER_SWIPER_HEIGHT= 480;
static readonly DEFAULT_OPEN_FOLDER_GRID_GAP= 6;
static readonly DEFAULT_OPEN_FOLDER_TITLE_HEIGHT = 130;
static readonly DEFAULT_APP_ADD_TITLE_SIZE = 56;
static readonly DEFAULT_DIALOG_BOTTOM_MARGIN_NUMBER = 16;
static readonly DEFAULT_BUTTON_HEIGHT_NUMBER = 40;
static readonly DEFAULT_MENU_HEIGHT = 76;
static readonly PERCENTAGE_100 = '100%';
static readonly PERCENTAGE_85 = '85%';
@ -71,16 +77,22 @@ export default class StyleConstants {
static readonly PIXEL_150 = 150;
static readonly LIGHT_BLACK = '#3c000000';
static readonly DEFAULT_0 = 0;
static readonly DEFAULT_1 = 1;
static readonly DEFAULT_4 = 4;
static readonly DEFAULT_5 = 5;
static readonly DEFAULT_8 = 8;
static readonly DEFAULT_10 = 10;
static readonly DEFAULT_12 = 12;
static readonly DEFAULT_14 = 14;
static readonly DEFAULT_15 = 15;
static readonly DEFAULT_16 = 16;
static readonly DEFAULT_20 = 20;
static readonly DEFAULT_24 = 24;
static readonly DEFAULT_25 = 25;
static readonly DEFAULT_28 = 28;
static readonly DEFAULT_30 = 30;
static readonly DEFAULT_40 = 40;
static readonly DEFAULT_56 = 56;
static readonly DEFAULT_60 = 60;
static readonly DEFAULT_80 = 80;
static readonly DEFAULT_DIVIDER_COLOR = 'rgb(207, 195, 195)';
@ -102,8 +114,8 @@ export default class StyleConstants {
static readonly DEFAULT_FORM_REMOVE_DIALOG_HEIGHT= 170;
static readonly DEFAULT_FORM_REMOVE_DIALOG_BUTTON_WIDTH= 136;
static readonly DEFAULT_FORM_REMOVE_DIALOG_BUTTON_HEIGHT= 22;
static readonly DEFAULT_SMART_DOCK_MISSION_HEIGHT = 146;
static readonly DEFAULT_SMART_DOCK_MISSION_HEIGHT = 132;
static readonly DEFAULT_SMART_DOCK_MISSION_MERGIN_BOTTOM = 6;
static readonly DEFAULT_SMART_DOCK_MISSION_MERGIN_RIGHT = 2;
static readonly DEFAULT_SMART_DOCK_MISSION_IMAGE_HEIGHT = 96;
static readonly DEFAULT_SMART_DOCK_MISSION_IMAGE_HEIGHT = 80;
}

View File

@ -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
@ -112,8 +112,6 @@ export default class AppGridStyleConfig extends ILayoutConfig {
*/
mIconNameMargin: number = PresetStyleConstants.DEFAULT_ICON_NAME_GAP;
private static sInstance: AppGridStyleConfig = null;
protected constructor() {
super();
}
@ -122,11 +120,11 @@ export default class AppGridStyleConfig extends ILayoutConfig {
*
*/
static getInstance() {
if (AppGridStyleConfig.sInstance == null) {
AppGridStyleConfig.sInstance = new AppGridStyleConfig();
AppGridStyleConfig.sInstance.initConfig();
if (globalThis.AppGridStyleConfig == null) {
globalThis.AppGridStyleConfig = new AppGridStyleConfig();
globalThis.AppGridStyleConfig.initConfig();
}
return AppGridStyleConfig.sInstance;
return globalThis.AppGridStyleConfig;
}
initConfig(): void {

View File

@ -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
@ -27,8 +27,6 @@ export default class AppListStyleConfig extends ILayoutConfig {
*/
static APP_LIST_STYLE_CONFIG = 'AppListStyleConfig';
private static sInstance: AppListStyleConfig = null;
/**
* width of item
*/
@ -109,6 +107,11 @@ export default class AppListStyleConfig extends ILayoutConfig {
*/
mIconNameMargin: number = PresetStyleConstants.DEFAULT_ICON_NAME_GAP;
/**
* list item offset
*/
mItemOffset: {} = {x: 0, y: 0}
protected constructor() {
super();
}
@ -117,11 +120,11 @@ export default class AppListStyleConfig extends ILayoutConfig {
* get instance of list Style config
*/
static getInstance() {
if (AppListStyleConfig.sInstance == null) {
AppListStyleConfig.sInstance = new AppListStyleConfig();
AppListStyleConfig.sInstance.initConfig();
if (globalThis.AppListStyleConfig == null) {
globalThis.AppListStyleConfig = new AppListStyleConfig();
globalThis.AppListStyleConfig.initConfig();
}
return AppListStyleConfig.sInstance;
return globalThis.AppListStyleConfig;
}
initConfig(): void {

View File

@ -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
@ -69,7 +69,7 @@ export default class FolderLayoutConfig extends ILayoutConfig {
*
* @params {gridLayoutInfo} folder layout data
*/
updateFolderLayoutInfo(folderLayoutInfo): void {
updateFolderLayoutInfo(folderLayoutInfo: object): void {
this.mFolderLayoutInfo = folderLayoutInfo;
super.persistConfig();
}

View File

@ -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
@ -69,7 +69,7 @@ export default class FormLayoutConfig extends ILayoutConfig {
*
* @params {gridLayoutInfo} form layout data
*/
updateFormLayoutInfo(formLayoutInfo): void {
updateFormLayoutInfo(formLayoutInfo: object): void {
this.mFormLayoutInfo = formLayoutInfo;
super.persistConfig();
}

View File

@ -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
@ -63,6 +63,13 @@ export default abstract class ILayoutConfig {
return JSON.parse(config);
}
/**
*
*/
isConfigExit(): boolean {
return this.mPreferences.hasSync(this.getConfigName());
}
/**
*
*/

View File

@ -12,15 +12,30 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import CommonConstants from '../../../../../../../common/src/main/ets/default/constants/CommonConstants';
import FeatureConstants from './constants/FeatureConstants';
import AppGridStyleConfig from '../../../../../../../common/src/main/ets/default/layoutconfig/AppGridStyleConfig';
import PresetStyleConstants from '../../../../../../../common/src/main/ets/default/constants/PresetStyleConstants';
import CommonConstants from '../constants/CommonConstants';
import ILayoutConfig from './ILayoutConfig';
import PresetStyleConstants from '../constants/PresetStyleConstants';
/**
* Launcher_layout style
*/
export default class LauncherLayoutStyleConfig extends AppGridStyleConfig {
export default class LauncherLayoutStyleConfig extends ILayoutConfig {
static LAUNCHER_COMMON_STYLE_CONFIG: string = 'launcherStyleCommon';
static LAUNCHER_PRODUCT_STYLE_CONFIG: string = 'launcherStyleProduct';
/**
* systemUI top height
*/
mSysTopHeight = PresetStyleConstants.DEFAULT_SYS_TOP_HEIGHT;
/**
* systemUI bottom height
*/
mSysBottomHeight = PresetStyleConstants.DEFAULT_SYS_BOTTOM_HEIGHT;
mSystemUIHeight = PresetStyleConstants.DEFAULT_PAD_SYSTEM_UI;
mIndicatorHeight = PresetStyleConstants.DEFAULT_PAD_INDICATOR_HEIGHT;
@ -42,76 +57,166 @@ export default class LauncherLayoutStyleConfig extends AppGridStyleConfig {
/**
* icon name lines
*/
mNameLines: number = PresetStyleConstants.DEFAULT_APP_NAME_LINES;
mNameLines : number = PresetStyleConstants.DEFAULT_APP_NAME_LINES;
/**
* icon ratio
*/
mIconRatio: number = PresetStyleConstants.DEFAULT_APP_TOP_RATIO;
mIconRatio : number = PresetStyleConstants.DEFAULT_APP_TOP_RATIO;
/**
* icon name margin
*/
mIconNameGap: number = PresetStyleConstants.DEFAULT_ICON_NAME_GAP;
/**
* icon name text size
*/
mNameSize: number = PresetStyleConstants.DEFAULT_APP_NAME_TEXT_SIZE;
mNameSize : number = PresetStyleConstants.DEFAULT_APP_NAME_TEXT_SIZE;
/**
* folder
* name height
*/
mFolderGutterRatio: number = PresetStyleConstants.DEFAULT_FOLDER_GUTTER_RATIO;
mNameHeight: number = PresetStyleConstants.DEFAULT_DESKTOP_NAME_HEIGHT;
mFolderMarginRatio: number = PresetStyleConstants.DEFAULT_FOLDER_PADDING_RATIO;
//folder
/**
* ratio of gutter with folder
*/
mFolderGutterRatio : number = PresetStyleConstants.DEFAULT_FOLDER_GUTTER_RATIO;
/**
* ratio of margin with folder
*/
mFolderMarginRatio : number = PresetStyleConstants.DEFAULT_FOLDER_PADDING_RATIO;
/**
* gutter of open folder
*/
mFolderOpenGutter: number = PresetStyleConstants.DEFAULT_OPEN_FOLDER_GUTTER;
/**
* padding of open folder
*/
mFolderOpenPADDING: number = PresetStyleConstants.DEFAULT_OPEN_FOLDER_PADDING;
/**
* margin of open folder
*/
mFolderOpenMargin: number = PresetStyleConstants.DEFAULT_OPEN_FOLDER_MARGIN_TOP;
/**
* gutter of add app
*/
mFolderAddGridGap: number = PresetStyleConstants.DEFAULT_FOLDER_ADD_GAP;
/**
* margin of add app and padding of add app
*/
mFolderAddGridMargin: number = PresetStyleConstants.DEFAULT_FOLDER_ADD_MARGIN;
/**
* max height of add app
*/
mFolderAddMaxHeight: number = PresetStyleConstants.DEFAULT_FOLDER_ADD_MAX_HEIGHT;
/**
* toggle size of add app
*/
mFolderToggleSize: number = PresetStyleConstants.DEFAULT_APP_GRID_TOGGLE_SIZE;
/**
* name lines of add app
*/
mFolderAddTextLines: number = PresetStyleConstants.DEFAULT_FOLDER_ADD_TEXT_LINES;
/**
* text size of add app
*/
mFolderAddTextSize: number = PresetStyleConstants.DEFAULT_FOLDER_ADD_GRID_TEXT_SIZE;
/**
* title size of add app
*/
mFolderAddTitleSize: number = PresetStyleConstants.DEFAULT_FOLDER_ADD_TITLE_TEXT_SIZE;
mFolderAddICONRATIO: number = PresetStyleConstants.DEFAULT_FOLDER_ADD_ICON_TOP_RATIO;
/**
* App Center
* ratio of padding top with icon in add app
*/
mFolderAddIconRatio: number = PresetStyleConstants.DEFAULT_FOLDER_ADD_ICON_TOP_RATIO;
/**
* button size of add app
*/
mFolderAddButtonSize: number = PresetStyleConstants.DEFAULT_FOLDER_ADD_BUTTON_SIZE;
//App Center
/**
* margin of app center
*/
mAppCenterMargin: number = PresetStyleConstants.DEFAULT_APP_CENTER_MARGIN;
/**
* gutter of app center
*/
mAppCenterGutter: number = PresetStyleConstants.DEFAULT_APP_CENTER_GUTTER;
/**
* size of app center container
*/
mAppCenterSize: number = PresetStyleConstants.DEFAULT_APP_CENTER_SIZE;
/**
* ratio of padding top with icon in app center
*/
mAppCenterRatio: number = PresetStyleConstants.DEFAULT_APP_CENTER_TOP_RATIO;
/**
* name lines of app center
*/
mAppCenterNameLines: number = PresetStyleConstants.DEFAULT_APP_CENTER_NAME_LINES;
/**
* name size of app center
*/
mAppCenterNameSize: number = PresetStyleConstants.DEFAULT_APP_CENTER_NAME_TEXT_SIZE;
//dock
/**
* dock
* padding of dock
*/
mDockPadding: number = PresetStyleConstants.DEFAULT_DOCK_PADDING;
/**
* icon size of dock
*/
mDockIconSize: number = PresetStyleConstants.DEFAULT_DOCK_ICON_SIZE;
/**
* gap of icon and icon
*/
mDockItemGap: number = PresetStyleConstants.DEFAULT_DOCK_ITEM_GAP;
/**
* gap of dock and dock
*/
mDockGutter: number = PresetStyleConstants.DEFAULT_DOCK_GUTTER;
/**
* save margin of dock
*/
mDockSaveMargin: number = PresetStyleConstants.DEFAULT_DOCK_SAVE_MARGIN;
/**
* margin bottom of dock
*/
mDockMarginBottom: number = PresetStyleConstants.DEFAULT_DOCK_MARGIN_BOTTOM;
/**
* margin bottom of dock (Immersive navigation bar)
*/
mDockMarginBottomHideBar: number = PresetStyleConstants.DEFAULT_DOCK_MARGIN_BOTTOM_HIDE_BAR;
protected constructor() {
super();
}
@ -122,7 +227,6 @@ export default class LauncherLayoutStyleConfig extends AppGridStyleConfig {
static getInstance() {
if (globalThis.LauncherLayoutStyleConfigInstance == null) {
globalThis.LauncherLayoutStyleConfigInstance = new LauncherLayoutStyleConfig();
globalThis.LauncherLayoutStyleConfigInstance.initConfig();
}
return globalThis.LauncherLayoutStyleConfigInstance;
}
@ -131,10 +235,20 @@ export default class LauncherLayoutStyleConfig extends AppGridStyleConfig {
}
getConfigLevel(): string {
return CommonConstants.LAYOUT_CONFIG_LEVEL_FEATURE;
return CommonConstants.LAYOUT_CONFIG_LEVEL_COMMON;
}
getFeatureName() {
return FeatureConstants.FEATURE_NAME;
getConfigType(): number {
return CommonConstants.LAYOUT_CONFIG_TYPE_STYLE;
}
getConfigName(): string {
return LauncherLayoutStyleConfig.LAUNCHER_COMMON_STYLE_CONFIG;
}
protected getPersistConfigJson(): string {
let persistConfig = {
};
return JSON.stringify(persistConfig);
}
}

View File

@ -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
@ -28,8 +28,6 @@ import ILayoutConfig from './ILayoutConfig';
* 3
*/
class LayoutConfigManager {
private static sInstance: LayoutConfigManager = null;
private readonly mPreferences = null;
private readonly mCommonConfig: ILayoutConfig[][] = new Array<ILayoutConfig[]>();
@ -58,11 +56,11 @@ class LayoutConfigManager {
*
*/
static getInstance(): LayoutConfigManager {
if (LayoutConfigManager.sInstance == null) {
LayoutConfigManager.sInstance = new LayoutConfigManager();
if (globalThis.LayoutConfigManager == null) {
globalThis.LayoutConfigManager = new LayoutConfigManager();
}
console.info('Launcher LayoutConfigManager constructor!');
return LayoutConfigManager.sInstance;
return globalThis.LayoutConfigManager;
}
/**

View File

@ -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
@ -27,8 +27,6 @@ export default class PageDesktopAppModeConfig extends ILayoutConfig {
private static readonly DEFAULT_LAYOUT_INFO: any = [];
private static sInstance: PageDesktopAppModeConfig = null;
private mAppListInfo: any = PageDesktopAppModeConfig.DEFAULT_LAYOUT_INFO;
protected constructor() {
@ -39,11 +37,11 @@ export default class PageDesktopAppModeConfig extends ILayoutConfig {
*
*/
static getInstance() {
if (PageDesktopAppModeConfig.sInstance == null) {
PageDesktopAppModeConfig.sInstance = new PageDesktopAppModeConfig();
PageDesktopAppModeConfig.sInstance.initConfig();
if (globalThis.PageDesktopAppModeConfig == null) {
globalThis.PageDesktopAppModeConfig = new PageDesktopAppModeConfig();
globalThis.PageDesktopAppModeConfig.initConfig();
}
return PageDesktopAppModeConfig.sInstance;
return globalThis.PageDesktopAppModeConfig;
}
initConfig(): void {
@ -72,7 +70,7 @@ export default class PageDesktopAppModeConfig extends ILayoutConfig {
*
* @params appListInfo
*/
updateAppListInfo(appListInfo): void {
updateAppListInfo(appListInfo: object): void {
this.mAppListInfo = appListInfo;
super.persistConfig();
}

View File

@ -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
@ -40,8 +40,6 @@ export default class PageDesktopLayoutConfig extends ILayoutConfig {
layoutInfo: []
};
private static readonly sInstance: PageDesktopLayoutConfig = null;
private mGridLayoutInfo: any = PageDesktopLayoutConfig.DEFAULT_LAYOUT_INFO;
protected constructor() {
@ -85,7 +83,7 @@ export default class PageDesktopLayoutConfig extends ILayoutConfig {
*
* @params gridLayoutInfo
*/
updateGridLayoutInfo(gridLayoutInfo): void {
updateGridLayoutInfo(gridLayoutInfo: object): void {
this.mGridLayoutInfo = gridLayoutInfo;
super.persistConfig();
}

View File

@ -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
@ -30,8 +30,6 @@ export default class PageDesktopModeConfig extends ILayoutConfig {
private static readonly GRID_CONFIG = 'GridConfig';
private static readonly sInstance: PageDesktopModeConfig = null;
private mAppStartPageType: string = defaultLayoutConfig.defaultAppPageStartConfig;
private mGridConfig: number = defaultLayoutConfig.defaultGridConfig;

View File

@ -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

View File

@ -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
@ -25,8 +25,6 @@ export default class SmartDockLayoutConfig extends ILayoutConfig {
*/
static SMART_DOCK_LAYOUT_INFO = 'SmartDockLayoutInfo';
private static sInstance: SmartDockLayoutConfig = null;
/**
* Dock功能布局数据
*/
@ -40,12 +38,12 @@ export default class SmartDockLayoutConfig extends ILayoutConfig {
*
*/
static getInstance() {
if (SmartDockLayoutConfig.sInstance == null) {
SmartDockLayoutConfig.sInstance = new SmartDockLayoutConfig();
SmartDockLayoutConfig.sInstance.initConfig();
if (globalThis.SmartDockLayoutConfig == null) {
globalThis.SmartDockLayoutConfig = new SmartDockLayoutConfig();
globalThis.SmartDockLayoutConfig.initConfig();
}
console.info('Launcher SmartDockLayoutConfig getInstance!');
return SmartDockLayoutConfig.sInstance;
return globalThis.SmartDockLayoutConfig;
}
initConfig(): void {
@ -74,7 +72,7 @@ export default class SmartDockLayoutConfig extends ILayoutConfig {
*
* @params gridLayoutInfo dock布局数据
*/
updateDockLayoutInfo(dockLayoutInfo): void {
updateDockLayoutInfo(dockLayoutInfo: object): void {
this.mDockLayoutInfo = dockLayoutInfo;
super.persistConfig();
}

View File

@ -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
@ -25,8 +25,6 @@ export default class SmartDockModeConfig extends ILayoutConfig {
*/
static SMART_DOCK_MODE_CONFIG = 'SmartDockModeConfig';
private static sInstance: SmartDockModeConfig = null;
protected constructor() {
super();
}
@ -35,11 +33,11 @@ export default class SmartDockModeConfig extends ILayoutConfig {
* Dock列表模式配置实例
*/
static getInstance(): SmartDockModeConfig {
if (SmartDockModeConfig.sInstance == null) {
SmartDockModeConfig.sInstance = new SmartDockModeConfig();
SmartDockModeConfig.sInstance.initConfig();
if (globalThis.SmartDockModeConfig == null) {
globalThis.SmartDockModeConfig = new SmartDockModeConfig();
globalThis.SmartDockModeConfig.initConfig();
}
return SmartDockModeConfig.sInstance;
return globalThis.SmartDockModeConfig;
}
initConfig(): void {

View File

@ -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
@ -20,8 +20,6 @@ import CommonConstants from '../constants/CommonConstants';
* Dock样式配置类
*/
export default class SmartDockStyleConfig extends AppListStyleConfig {
private static sFeatureInstance: SmartDockStyleConfig = null;
/**
* dock列表高度
*/
@ -125,18 +123,14 @@ export default class SmartDockStyleConfig extends AppListStyleConfig {
* dock样式实例
*/
static getInstance() {
if (SmartDockStyleConfig.sFeatureInstance == null) {
SmartDockStyleConfig.sFeatureInstance = new SmartDockStyleConfig();
SmartDockStyleConfig.sFeatureInstance.initConfig();
if (globalThis.SmartDockStyleConfigInstance == null) {
globalThis.SmartDockStyleConfigInstance = new SmartDockStyleConfig();
globalThis.SmartDockStyleConfigInstance.initConfig();
}
return SmartDockStyleConfig.sFeatureInstance;
return globalThis.SmartDockStyleConfigInstance;
}
getConfigLevel(): string {
return CommonConstants.LAYOUT_CONFIG_LEVEL_COMMON;
}
// public getFeatureName() {
// return FeatureConstants.FEATURE_NAME;
// }
}

View File

@ -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
@ -98,7 +98,8 @@ class AmsMissionManager {
Log.showError(TAG, 'getRecentBundleMissionsList Empty');
return recentMissionsList;
}
for (let missionInfo of missionInfos) {
for (let i = 0; i < missionInfos.length; i++) {
let missionInfo = missionInfos[i];
let bundleName = missionInfo.want.bundleName!;
let localMissionInfo = recentMissionsList.find((item) => item.bundleName === bundleName);
if (localMissionInfo) {
@ -147,7 +148,7 @@ class AmsMissionManager {
* Clear all missions in the ability manager service.
* locked mission will not clear
*
* @param missionId
* @return nothing.
*/
async clearAllMissions(): Promise<void> {
Log.showInfo(TAG, 'clearAllMissions start!');
@ -163,7 +164,7 @@ class AmsMissionManager {
/**
* lockMission
*
* @param missionId
* @param missionId mission id to lock.
*/
async lockMission(missionId: number): Promise<void> {
Log.showInfo(TAG, `lockMission start! missionId: ${missionId}`);
@ -179,7 +180,7 @@ class AmsMissionManager {
/**
* unlockMission
*
* @param missionId
* @param missionId mission id to unlock.
*/
async unlockMission(missionId: number): Promise<void> {
console.info(`unlockMission start! missionId: ${missionId}`);
@ -195,10 +196,10 @@ class AmsMissionManager {
/**
* Get recent mission snapshot info
*
* @param missionId
* @param missionId mission id to get snapshot.
* @return snapshot info
*/
async getMissionSnapShot(missionId: number) {
async getMissionSnapShot(missionId: number): Promise<object> {
Log.showInfo(TAG, `getMissionSnapShot start! missionId: ${missionId}`);
let snapShotInfo: any;
const pixelMap: {

View File

@ -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
@ -30,9 +30,12 @@ export default class BadgeManager {
static UPDATE_BADGE = 'updateBadge';
private listener;
private constructor() {
this.mDbStoreManager = RdbStoreManager.getInstance();
this.registerAppListEvent();
this.listener = this.appRemovedCallBack.bind(this);
}
/**
* badge manager instance
@ -81,14 +84,14 @@ export default class BadgeManager {
* register app listener.
*/
registerAppListEvent(): void {
launcherAbilityManager.registerLauncherAbilityChangeListener(this.appRemovedCallBack.bind(this));
launcherAbilityManager.registerLauncherAbilityChangeListener(this.listener);
}
/**
* unregister app listener.
*/
unregisterAppListEvent(): void {
launcherAbilityManager.unregisterLauncherAbilityChangeListener(this.appRemovedCallBack.bind(this));
launcherAbilityManager.unregisterLauncherAbilityChangeListener(this.listener);
}
private async appRemovedCallBack(event, bundleName: string, userId): Promise<void> {

View File

@ -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

View File

@ -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

View File

@ -0,0 +1,30 @@
/**
* 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 inputMethod from '@ohos.inputMethod';
export default class InputMethodManager {
static getInstance(): InputMethodManager {
if (globalThis.InputMethodManagerInstance == null) {
globalThis.InputMethodManagerInstance = new InputMethodManager();
}
return globalThis.InputMethodManagerInstance;
}
stopInput() {
inputMethod.getInputMethodController()?.stopInput();
}
}

View File

@ -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
@ -22,6 +22,7 @@ import CheckEmptyUtils from '../utils/CheckEmptyUtils';
import CommonConstants from '../constants/CommonConstants';
import EventConstants from '../constants/EventConstants';
import ResourceManager from './ResourceManager';
import osaccount from '@ohos.account.osAccount'
import Trace from '../utils/Trace';
import Log from '../utils/Log';
@ -34,19 +35,20 @@ class LauncherAbilityManager {
private static readonly CURRENT_USER_ID = -2;
private static readonly BUNDLE_STATUS_CHANGE_KEY = 'BundleStatusChange';
private readonly mAppMap = new Map<string, AppItemInfo>();
private mUserId: number = 100;
private readonly mBundleStatusCallback: BundleStatusCallback = {
add: (bundleName, userId) => {
Log.showInfo(TAG, `mBundleStatusCallback add bundleName: ${bundleName}, userId: ${userId}`);
this.notifyLauncherAbilityChange(EventConstants.EVENT_PACKAGE_ADDED, bundleName, userId);
Log.showInfo(TAG, `mBundleStatusCallback add bundleName: ${bundleName}, userId: ${userId}, mUserId ${this.mUserId}`);
this.mUserId == userId && this.notifyLauncherAbilityChange(EventConstants.EVENT_PACKAGE_ADDED, bundleName, userId);
},
remove: (bundleName, userId) => {
Log.showInfo(TAG, `mBundleStatusCallbackremove bundleName: ${bundleName}, userId: ${userId}`);
this.notifyLauncherAbilityChange(EventConstants.EVENT_PACKAGE_REMOVED, bundleName, userId);
Log.showInfo(TAG, `mBundleStatusCallbackremove bundleName: ${bundleName}, userId: ${userId}, mUserId ${this.mUserId}`);
this.mUserId == userId && this.notifyLauncherAbilityChange(EventConstants.EVENT_PACKAGE_REMOVED, bundleName, userId);
},
update: (bundleName, userId) => {
Log.showInfo(TAG, `mBundleStatusCallbackupdate bundleName: ${bundleName}, userId: ${userId}`);
this.notifyLauncherAbilityChange(EventConstants.EVENT_PACKAGE_CHANGED, bundleName, userId);
Log.showInfo(TAG, `mBundleStatusCallbackupdate bundleName: ${bundleName}, userId: ${userId}, mUserId ${this.mUserId}`);
this.mUserId == userId && this.notifyLauncherAbilityChange(EventConstants.EVENT_PACKAGE_CHANGED, bundleName, userId);
}
};
@ -65,6 +67,14 @@ class LauncherAbilityManager {
return globalThis.LauncherAbilityManagerInstance;
}
private constructor() {
const osAccountManager = osaccount.getAccountManager();
osAccountManager.getOsAccountLocalIdFromProcess((err, localId) => {
Log.showInfo(TAG, "getOsAccountLocalIdFromProcess localId " + localId);
this.mUserId = localId;
})
}
/**
* .
*
@ -132,7 +142,8 @@ class LauncherAbilityManager {
return appItemInfoList;
}
for (let i = 0; i < abilityList.length; i++) {
appItemInfoList.push(this.convertToAppItemInfo(abilityList[i]));
let appItem = await this.convertToAppItemInfo(abilityList[i]);
appItemInfoList.push(appItem);
}
return appItemInfoList;
}
@ -159,7 +170,8 @@ class LauncherAbilityManager {
return appItemInfoList;
}
for (let i = 0; i < abilityInfos.length; i++) {
appItemInfoList.push(this.convertToAppItemInfo(abilityInfos[i]));
let appItem = await this.convertToAppItemInfo(abilityInfos[i]);
appItemInfoList.push(appItem);
}
return appItemInfoList;
}
@ -214,11 +226,12 @@ class LauncherAbilityManager {
appItemInfo.isUninstallAble = info.applicationInfo.removable;
appItemInfo.appIconId = info.iconId;
appItemInfo.abilityName = info.elementName.abilityName;
await ResourceManager.getInstance().updateIconCache(info.iconId, bundleName);
this.mAppMap.set(bundleName, appItemInfo);
return appItemInfo;
}
private convertToAppItemInfo(info): AppItemInfo {
private async convertToAppItemInfo(info): Promise<AppItemInfo> {
const appItemInfo = new AppItemInfo();
appItemInfo.appName = info.applicationInfo.label;
appItemInfo.isSystemApp = info.applicationInfo.systemApp;
@ -227,6 +240,7 @@ class LauncherAbilityManager {
appItemInfo.appLabelId = info.labelId;
appItemInfo.bundleName = info.elementName.bundleName;
appItemInfo.abilityName = info.elementName.abilityName;
await ResourceManager.getInstance().updateIconCache(appItemInfo.appIconId, appItemInfo.bundleName);
return appItemInfo;
}
@ -276,9 +290,9 @@ class LauncherAbilityManager {
* @params paramAbilityName
* @params paramBundleName
*/
startAbilityForResult(paramAbilityName: string, paramBundleName: string, paramCardId: number) {
Log.showInfo(TAG, `startAbilityForResult abilityName: ${paramAbilityName},bundleName: ${paramBundleName},paramCardId: ${paramCardId}`);
const result = globalThis.desktopContext.startAbilityForResult({
startAbilityFormEdit(paramAbilityName: string, paramBundleName: string, paramCardId: number) {
Log.showInfo(TAG, `startAbility abilityName: ${paramAbilityName},bundleName: ${paramBundleName},paramCardId: ${paramCardId}`);
const result = globalThis.desktopContext.startAbility({
bundleName: paramBundleName,
abilityName: paramAbilityName,
parameters:
@ -286,22 +300,11 @@ class LauncherAbilityManager {
formId: paramCardId.toString()
}
}).then((ret) => {
Log.showInfo(TAG, `startAbilityForResult ret: ${JSON.stringify(ret)}`);
Log.showInfo(TAG, `startAbility ret: ${JSON.stringify(ret)}`);
}, (err) => {
Log.showError(TAG, `startAbilityForResult catch error: ${JSON.stringify(err)}`);
Log.showError(TAG, `startAbility catch error: ${JSON.stringify(err)}`);
});
Log.showInfo(TAG, `startAbilityForResult result: ${JSON.stringify(result)}`);
this.requestForm(paramCardId);
}
async requestForm(paramCardId: number) {
await formManagerAbility.requestForm(paramCardId.toString())
.then((result) => {
Log.showInfo(TAG, `requestForm result: ${JSON.stringify(result)}`);
})
.catch((err) => {
Log.showInfo(TAG, `requestForm error: ${JSON.stringify(err)}`);
});
Log.showInfo(TAG, `startAbility result: ${JSON.stringify(result)}`);
}
async getShortcutInfo(paramBundleName, callback) {

View File

@ -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
@ -24,8 +24,6 @@ const TAG = 'LocalEventManager';
* 2
*/
class LocalEventManager {
private static sInstance: LocalEventManager | undefined = undefined;
private mEventListenerMap: Object = {};
private mEventMsgCache: Object = {};
@ -36,11 +34,11 @@ class LocalEventManager {
* @return
*/
static getInstance(): LocalEventManager {
if (LocalEventManager.sInstance == undefined) {
if (globalThis.localEventManager == null) {
Log.showInfo(TAG, 'getInstance');
LocalEventManager.sInstance = new LocalEventManager();
globalThis.localEventManager = new LocalEventManager();
}
return LocalEventManager.sInstance;
return globalThis.localEventManager;
}
/**
@ -57,8 +55,7 @@ class LocalEventManager {
if (this.mEventListenerMap[event] == undefined) {
this.mEventListenerMap[event] = new Array<any>();
}
const listenerList: any[] = this.mEventListenerMap[event];
if (listenerList.indexOf(listener) === CommonConstants.INVALID_VALUE) {
if (this.mEventListenerMap[event].indexOf(listener) === CommonConstants.INVALID_VALUE) {
this.mEventListenerMap[event].push(listener);
}
}
@ -89,10 +86,10 @@ class LocalEventManager {
*/
sendLocalEvent(event, params?): void {
Log.showInfo(TAG, `sendLocalEvent event: ${JSON.stringify(event)}`);
const listenerList = this.mEventListenerMap[event];
let listenerList = this.mEventListenerMap[event];
if (listenerList != undefined) {
Log.showInfo(TAG, `sendLocalEvent listenerList length: ${listenerList.length}`);
for (const listener of listenerList) {
for (let listener of listenerList) {
listener.onReceiveEvent(event, params);
}
} else {

View File

@ -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

View File

@ -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,7 +13,6 @@
* limitations under the License.
*/
import Resmgr from '@ohos.resourceManager';
import AppResourceCacheManager from '../cache/AppResourceCacheManager';
import CheckEmptyUtils from '../utils/CheckEmptyUtils';
import Log from '../utils/Log';
@ -23,21 +22,47 @@ const KEY_NAME = 'name';
const TAG = 'ResourceManager';
export default class ResourceManager {
private static readonly resourceManager: ResourceManager = new ResourceManager();
private mAppResourceCacheManager: AppResourceCacheManager | undefined = undefined;
private constructor() {
}
static getInstance(): ResourceManager {
return this.resourceManager;
if (globalThis.ResourceManager == null) {
globalThis.ResourceManager = new ResourceManager();
}
return globalThis.ResourceManager;
}
private getAppResourceCacheManager(): AppResourceCacheManager {
if (this.mAppResourceCacheManager == undefined) {
this.mAppResourceCacheManager = new AppResourceCacheManager();
if (globalThis.AppResourceCacheManager == null) {
globalThis.AppResourceCacheManager = new AppResourceCacheManager();
}
return globalThis.AppResourceCacheManager;
}
getCachedAppIcon(iconId, bundleName) {
const cacheKey = `${iconId}${bundleName}`;
return this.getAppResourceCacheManager().getCache(cacheKey, KEY_ICON);
}
async updateIconCache(iconId, bundleName): Promise<void> {
try {
let cacheKey = `${iconId}${bundleName}`;
const iconBase64 = this.getAppResourceCacheManager().getCache(cacheKey, KEY_ICON);
if (!CheckEmptyUtils.isEmpty(iconBase64)) {
return;
}
const bundleContext = globalThis.desktopContext.createBundleContext(bundleName);
if (bundleContext == null) {
return;
}
await bundleContext.resourceManager.getMediaBase64(iconId).then((value)=> {
if (value != null) {
this.getAppResourceCacheManager().setCache(cacheKey, KEY_ICON, value);
}
});
} catch (error) {
Log.showError(TAG, `updateIconCache error ${error}`);
}
return this.mAppResourceCacheManager;
}
getAppIconWithCache(iconId, bundleName, callback, defaultAppIcon) {
@ -158,7 +183,7 @@ export default class ResourceManager {
* @param {number} resource.id
* @param {function} callback(value)
*/
getStringById(resId: number, callback) {
getStringById(resId: number, callback: (value: string) => void): void {
if (this.isResourceManagerEmpty()) {
Log.showError(TAG, 'resourceManager is empty');
callback('');
@ -182,6 +207,12 @@ export default class ResourceManager {
|| CheckEmptyUtils.isEmpty(globalThis.desktopContext.resourceManager);
}
public async getStringByResource(res: Resource): Promise<string>{
const json = JSON.parse(JSON.stringify(res));
const id = json.id;
return await this.getStringByIdSync(id);
}
/**
* get string by resource.id.
*

View File

@ -15,9 +15,6 @@
import featureAbility from '@ohos.ability.featureAbility';
import settings from '@ohos.settings';
import Log from '../utils/Log';
const TAG = 'SettingsDataManager';
/**
* settingsData Manager

View File

@ -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
@ -25,13 +25,23 @@ const TAG = 'WindowManager';
*
*/
class WindowManager {
private static sInstance: WindowManager | undefined = undefined;
private mDisplayData = null;
RECENT_WINDOW_NAME = 'recentsWindow';
RECENT_WINDOW_NAME = 'RecentView';
DESKTOP_WINDOW_NAME = 'LauncherWindow';
DESKTOP_WINDOW_NAME = 'EntryView';
APP_CENTER_WINDOW_NAME = 'AppCenterView'
FORM_MANAGER_WINDOW_NAME = 'FormManagerView';
DESKTOP_RANK = 2001;
FORM_MANAGER_RANK = 2100;
RECENT_RANK = 2115;
DOCK_RANK = 2116;
/**
*
@ -39,10 +49,10 @@ class WindowManager {
* @return
*/
static getInstance(): WindowManager {
if (WindowManager.sInstance == undefined) {
WindowManager.sInstance = new WindowManager();
if (globalThis.WindowManager == null) {
globalThis.WindowManager = new WindowManager();
}
return WindowManager.sInstance;
return globalThis.WindowManager;
}
/**
@ -112,13 +122,21 @@ class WindowManager {
void win.loadContent(loadContent).then(() => {
Log.showInfo(TAG, `then begin ${name} window loadContent in then!`);
void win.show().then(() => {
void win.setLayoutFullScreen(true).then(() => {
void win.setSystemBarProperties({
navigationBarColor: StyleConstants.DEFAULT_SYSTEM_UI_COLOR,
statusBarColor: StyleConstants.DEFAULT_SYSTEM_UI_COLOR
}).then(() => {
Log.showInfo(TAG, name + `${name} setSystemBarProperties`);
});
void win.setSystemBarProperties({
navigationBarColor: StyleConstants.DEFAULT_SYSTEM_UI_COLOR,
statusBarColor: StyleConstants.DEFAULT_SYSTEM_UI_COLOR
}).then(() => {
if (name === this.RECENT_WINDOW_NAME) {
// setFullScreen is also need to set system ui bar color to avoid flicker
void win.setFullScreen(true).then(() => {
Log.showInfo(TAG, `${name} setFullScreen`);
});
} else {
void win.setLayoutFullScreen(true).then(() => {
Log.showInfo(TAG, `${name} setLayoutFullScreen`);
});
}
Log.showInfo(TAG, `${name} setSystemBarProperties`);
});
if (callback) {
callback(win);
@ -193,6 +211,7 @@ class WindowManager {
Log.showInfo(TAG, 'Launcher minimizeAll');
});
});
this.destroyWindow(this.FORM_MANAGER_WINDOW_NAME);
}
destroyWindow(name: string, callback?: Function): void {

View File

@ -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
@ -22,52 +22,68 @@ import CommonConstants from '../constants/CommonConstants';
import EventConstants from '../constants/EventConstants';
import AppItemInfo from '../bean/AppItemInfo';
import FormModel from './FormModel';
import Log from '../utils/Log';
const TAG = 'AppModel';
/**
*
* Desktop application information data model.
*/
export default class AppModel {
private static readonly sAppModel = new AppModel();
private readonly mBundleInfoList: AppItemInfo[] = [];
private readonly mSystemApplicationName = [];
private readonly mAppStateChangeListener = [];
private readonly shortcutInfoMap = new Map<string, ShortcutInfo[]>();
private readonly mShortcutInfoMap = new Map<string, ShortcutInfo[]>();
private readonly mFormModel: FormModel;
private mInstallationListener;
private constructor() {
Log.showInfo(TAG, 'constructor start');
this.mSystemApplicationName = SystemApplication.SystemApplicationName.split(',');
this.mFormModel = FormModel.getInstance();
this.mInstallationListener = this.installationSubscriberCallBack.bind(this);
}
/**
* .
* Get the application data model object.
*
* @return
* @return {object} application data model singleton
*/
static getInstance(): AppModel {
return this.sAppModel;
if (globalThis.AppModel == null) {
globalThis.AppModel = new AppModel();
}
return globalThis.AppModel;
}
/**
* .
* Get the list of apps displayed on the desktop.
* (public function, reduce the frequency of method call)
*
* @return {array} bundleInfoList
*/
async getAppList() {
console.info('Launcher AppModel getAppIcon getAppList');
Log.showInfo(TAG, 'getAppList start');
if (!CheckEmptyUtils.isEmptyArr(this.mBundleInfoList)) {
return this.mBundleInfoList;
}
const bundleInfoList: AppItemInfo[] = await this.getAppListAsync();
console.info('Launcher AppModel bundleInfoList length ' + this.mBundleInfoList.length);
Log.showInfo(TAG, `getAppList bundleInfoList length: ${this.mBundleInfoList.length}`);
return bundleInfoList;
}
/**
* Get the list of apps displayed on the desktop (private function).
*
* @return {array} bundleInfoList, excluding system applications
*/
private async getAppListAsync() {
const allAbilityList: AppItemInfo[] = await launcherAbilityManager.getLauncherAbilityList();
if (!CheckEmptyUtils.isEmptyArr(this.mBundleInfoList)) {
return this.mBundleInfoList;
}
for (let i = 0; i < allAbilityList.length; i++) {
if (this.mSystemApplicationName.indexOf(allAbilityList[i].bundleName) == CommonConstants.INVALID_VALUE) {
if (this.mSystemApplicationName.indexOf(allAbilityList[i].bundleName) === CommonConstants.INVALID_VALUE) {
this.mBundleInfoList.push(allAbilityList[i]);
this.updateShortcutInfo(allAbilityList[i].bundleName);
this.mFormModel.updateAppItemFormInfo(allAbilityList[i].bundleName);
@ -77,20 +93,20 @@ export default class AppModel {
}
/**
* .
* Register application list change event listener.
*
* @param listener
* @param listener
*/
registerStateChangeListener(listener) {
if (this.mAppStateChangeListener.indexOf(listener) == CommonConstants.INVALID_VALUE) {
if (this.mAppStateChangeListener.indexOf(listener) === CommonConstants.INVALID_VALUE) {
this.mAppStateChangeListener.push(listener);
}
}
/**
* .
* Unregister application list change event listener.
*
* @param listener
* @param listener
*/
unregisterAppStateChangeListener(listener) {
let index: number = this.mAppStateChangeListener.indexOf(listener);
@ -100,49 +116,69 @@ export default class AppModel {
}
/**
* .
* Start listening to the system application status.
*/
registerAppListEvent() {
launcherAbilityManager.registerLauncherAbilityChangeListener(this.installationSubscriberCallBack.bind(this));
launcherAbilityManager.registerLauncherAbilityChangeListener(this.mInstallationListener);
}
/**
* .
* Stop listening for system application status.
*/
unregisterAppListEvent() {
launcherAbilityManager.unregisterLauncherAbilityChangeListener(this.installationSubscriberCallBack.bind(this));
launcherAbilityManager.unregisterLauncherAbilityChangeListener(this.mInstallationListener);
}
/**
* The callback function of the application installation event.
*
* @param {Object} event
* @param {string} bundleName
* @param {number} userId
*/
private async installationSubscriberCallBack(event, bundleName, userId) {
console.info('Launcher AppModel installationSubscriberCallBack event = ' + event);
Log.showInfo(TAG, `installationSubscriberCallBack event: ${event}`);
await this.updateShortcutInfo(bundleName, event);
if (event == EventConstants.EVENT_PACKAGE_REMOVED) {
if (event === EventConstants.EVENT_PACKAGE_REMOVED) {
this.removeItem(bundleName);
this.mFormModel.deleteFormByBundleName(bundleName);
//delete app from folder
// delete app from folder
localEventManager.sendLocalEventSticky(EventConstants.EVENT_FOLDER_PACKAGE_REMOVED, bundleName);
//delete dock
// delete app form dock
localEventManager.sendLocalEventSticky(EventConstants.EVENT_REQUEST_RESIDENT_DOCK_ITEM_DELETE, bundleName);
localEventManager.sendLocalEventSticky(EventConstants.EVENT_REQUEST_RECENT_DOCK_ITEM_DELETE, bundleName);
// delete app from pageDesktop
localEventManager.sendLocalEventSticky(EventConstants.EVENT_REQUEST_PAGEDESK_ITEM_DELETE, bundleName);
this.notifyAppStateChangeEvent();
} else {
const abilityInfos = await launcherAbilityManager.getLauncherAbilityInfo(bundleName);
this.replaceItem(bundleName, abilityInfos);
this.notifyAppStateChangeEvent();
this.mFormModel.updateAppItemFormInfo(bundleName);
}
}
/**
* Send event about application state change.
*/
private notifyAppStateChangeEvent() {
for (let i = 0; i < this.mAppStateChangeListener.length; i++) {
this.mAppStateChangeListener[i](this.mBundleInfoList);
}
}
/**
* Get the app index in bundleInfoList.
*
* @param {string} bundleName
* @return {number} index
*/
private getItemIndex(bundleName): number {
for (const listItem of this.mBundleInfoList) {
if (listItem.bundleName == bundleName) {
if (listItem.bundleName === bundleName) {
const index = this.mBundleInfoList.indexOf(listItem);
return index;
}
@ -150,14 +186,24 @@ export default class AppModel {
return CommonConstants.INVALID_VALUE;
}
/**
* Append app items into the bundleInfoList.
*
* @param {array} abilityInfos
*/
private appendItem(abilityInfos) {
for (let index = 0; index < abilityInfos.length; index++) {
this.mBundleInfoList.push(abilityInfos[index]);
}
}
/**
* Remove app item from the bundleInfoList.
*
* @param {string} bundleName
*/
private removeItem(bundleName: string) {
console.info('Launcher removeItem: ' + bundleName);
Log.showInfo(TAG, `removeItem bundleName: ${bundleName}`);
let originItemIndex = this.getItemIndex(bundleName);
while (originItemIndex != CommonConstants.INVALID_VALUE) {
this.mBundleInfoList.splice(originItemIndex, 1);
@ -165,25 +211,49 @@ export default class AppModel {
}
}
/**
* Replace app items in the bundleInfoList.
*
* @param {string} bundleName
* @param {array} abilityInfos
*/
private replaceItem(bundleName: string, abilityInfos) {
console.info('Launcher replaceItem: ' + bundleName);
Log.showInfo(TAG, `replaceItem bundleName: ${bundleName}`);
this.removeItem(bundleName);
this.appendItem(abilityInfos);
}
/**
* Put shortcut info into map.
*
* @param {string} bundleName
* @param {array} shortcutInfo
*/
setShortcutInfo(bundleName: string, shortcutInfo: ShortcutInfo[]) {
this.shortcutInfoMap.set(bundleName, shortcutInfo);
this.mShortcutInfoMap.set(bundleName, shortcutInfo);
}
/**
* Get shortcut info from map.
*
* @param {string} bundleName
* @return {array | undefined} shortcutInfo
*/
getShortcutInfo(bundleName: string): ShortcutInfo[] | undefined {
console.info('Launcher AppModel getShortcutInfo bundleName: ' + bundleName + ',shortcutInfo: ' +
JSON.stringify(this.shortcutInfoMap.get(bundleName)));
return this.shortcutInfoMap.get(bundleName);
Log.showInfo(TAG, `getShortcutInfo bundleName: ${bundleName},
shortcutInfo: ${JSON.stringify(this.mShortcutInfoMap.get(bundleName))}`);
return this.mShortcutInfoMap.get(bundleName);
}
/**
* Update shortcut info of map.
*
* @param {string} bundleName
* @param {string | undefined} eventType
*/
private updateShortcutInfo(bundleName, eventType?) {
if (eventType && eventType == EventConstants.EVENT_PACKAGE_REMOVED) {
this.shortcutInfoMap.delete(bundleName);
if (eventType && eventType === EventConstants.EVENT_PACKAGE_REMOVED) {
this.mShortcutInfoMap.delete(bundleName);
return;
}
launcherAbilityManager.getShortcutInfo(bundleName, this.setShortcutInfo.bind(this));

View File

@ -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
@ -21,24 +21,32 @@ import CardItemInfo from '../bean/CardItemInfo';
import FormListInfoCacheManager from '../cache/FormListInfoCacheManager';
import CommonConstants from '../constants/CommonConstants';
import SettingsModel from './SettingsModel';
import Log from '../utils/Log';
const TAG = 'FormModel';
const KEY_FORM_LIST = 'formListInfo';
/**
* form model
* form model.
*/
export default class FormModel {
private readonly mRdbStoreManager: RdbStoreManager;
private readonly mFormManager: FormManager;
private readonly mFormListInfoCacheManager: FormListInfoCacheManager;
private readonly appItemFormInfoMap = new Map<string, CardItemInfo[]>();
private readonly mAppItemFormInfoMap = new Map<string, CardItemInfo[]>();
private constructor() {
Log.showInfo(TAG, 'constructor start');
this.mRdbStoreManager = RdbStoreManager.getInstance();
this.mFormManager = FormManager.getInstance();
this.mFormListInfoCacheManager = FormListInfoCacheManager.getInstance();
}
/**
* Get the form model object.
*
* @return {object} form model singleton
*/
static getInstance() {
if (globalThis.FormModelInstance == null) {
globalThis.FormModelInstance = new FormModel();
@ -47,9 +55,9 @@ export default class FormModel {
}
/**
* Register the form card change event
*
* @param listener object
* Register the form card change event listener.
*
* @param listener
*/
registerJumpToFormViewEvent(listener) {
LocalEventManager.registerEventListener(listener, [
@ -58,78 +66,100 @@ export default class FormModel {
}
/**
* Unregister event listener
*
* @param listener object
* Unregister event listener.
*
* @param listener
*/
unregisterEventListener(listener) {
LocalEventManager.unregisterEventListener(listener);
}
/**
* Send the event of jump to form manager view.
*
* @param {array} formViewInfo
*/
sendJumpFormViewEvent(formViewInfo) {
LocalEventManager.sendLocalEventSticky(EventConstants.EVENT_REQUEST_JUMP_TO_FORM_VIEW, formViewInfo);
}
/**
* Obtains the FormInfo objects provided by all ohos applications on the device.
* Get the form info list of all ohos applications on the device.
*
* @return {array} allFormList
*/
async getAllFormsInfo() {
console.info('Launcher FormModel getAllFormsInfo');
Log.showInfo(TAG, 'getAllFormsInfo start');
const allFormList = await this.mFormManager.getAllFormsInfo();
return allFormList;
}
/**
* Obtains the FormInfo objects provided by a specified application module on the device.
* Get the form info list of all ohos applications on the device by bundle name.
*
* @param {array} bundleName
* @param {function | undefined} callback
*
* @return {array} currentBundleFormsInfo
*/
async getFormsInfoByBundleName(bundleName: string, callback?) {
console.info('Launcher FormModel getFormsInfoByBundleName bundleName:'+ bundleName);
Log.showInfo(TAG, `getFormsInfoByBundleName bundleName: ${bundleName}`);
let currentBundleFormsInfo: any;
await this.mFormManager.getFormsInfoByApp(bundleName)
.then(bundleFormsInfo => {
console.info('Launcher FormModel getFormsInfoByBundleName currentBundleFormsInfo: ' + bundleFormsInfo);
Log.showInfo(TAG, `getFormsInfoByBundleName bundleFormsInfo: ${JSON.stringify(bundleFormsInfo)}`);
currentBundleFormsInfo = bundleFormsInfo;
if (callback != undefined) {
callback(bundleName, bundleFormsInfo);
}
})
.catch(err => {
console.error('Launcher FormModel getFormsInfoByBundleName err:' + err);
Log.showError(TAG, `getFormsInfoByBundleName err: ${err}`);
});
AppStorage.SetOrCreate('formMgrItem', currentBundleFormsInfo);
return currentBundleFormsInfo;
}
/**
* Obtains the FormInfo objects provided by a specified application module on the device.
* Get the form info list of all ohos applications on the device by module name.
*
* @param {string} bundleName
* @param {string} moduleName
*
* @return {array} currentModuleFormsInfo
*/
async getFormsInfoByModuleName(bundleName: string, moduleName: string) {
console.info('Launcher FormModel getFormsInfoByModuleName bundleName:' + bundleName + ', moduleName:' + moduleName);
Log.showInfo(TAG, `getFormsInfoByModuleName bundleName: ${bundleName}, moduleName: ${moduleName}`);
const currentModuleFormsInfo = await this.mFormManager.getFormsInfoByModule(bundleName, moduleName);
return currentModuleFormsInfo;
}
/**
* Obtains the FormInfo objects from launcher
* Get the form info list from rdb.
*
* @return {array} allFormList
*/
async getAllFormsInfoFromRdb() {
console.info('Launcher FormModel getAllFormsInfoFromRdb');
Log.showInfo(TAG, 'getAllFormsInfoFromRdb start');
const allFormList = await this.mRdbStoreManager.getAllFormInfos();
return allFormList;
}
/**
* update the FormInfo objects to launcher
* @param cardItemInfo
* Update the form info in rdb by id.
*
* @param {object} cardItemInfo
*
* @return {boolean} result
*/
async updateFormInfoById(cardItemInfo) {
return await this.mRdbStoreManager.updateFormInfoById(cardItemInfo);
}
/**
* delete form by id
* @param cardId
* Delete form in rdb and fms by id.
*
* @param {number} cardId
*/
deleteFormById(cardId: number) {
this.mRdbStoreManager.deleteFormInfoById(cardId);
@ -137,77 +167,111 @@ export default class FormModel {
}
/**
* delete form by formId
* @param formId
* Delete form in fms by formId.
*
* @param {number} formId
*/
deleteFormByFormID(formId: number) {
this.mFormManager.deleteCard(formId.toString());
}
/**
* set app item formInfo
* @param bundleName
* Set app item form info into map.
*
* @param {string} bundleName
* @param {array} appItemFormInfo
*/
setAppItemFormInfo(bundleName: string, appItemFormInfo: CardItemInfo[]) {
this.appItemFormInfoMap.set(bundleName, appItemFormInfo);
this.mAppItemFormInfoMap.set(bundleName, appItemFormInfo);
}
/**
* get app item formInfo
* @param bundleName
* Get app item form info from map.
*
* @param {string} bundleName
*
* @return {array | undefined} mAppItemFormInfoMap
*/
getAppItemFormInfo(bundleName: string): CardItemInfo[] | undefined {
console.info('Launcher AppModel getShortcutInfo bundleName: ' + bundleName + ',shortcutInfo: ' +
JSON.stringify(this.appItemFormInfoMap.get(bundleName)));
return this.appItemFormInfoMap.get(bundleName);
Log.showInfo(TAG, `getAppItemFormInfo bundleName: ${bundleName},
appItemFormInfo: ${JSON.stringify(this.mAppItemFormInfoMap.get(bundleName))}`);
return this.mAppItemFormInfoMap.get(bundleName);
}
/**
* update app item formInfo
* @param bundleName
* Update app item form info into map.
*
* @param {string} bundleName
* @param {string | undefined} eventType
*/
updateAppItemFormInfo(bundleName, eventType?) {
if (eventType && eventType == EventConstants.EVENT_PACKAGE_REMOVED) {
this.appItemFormInfoMap.delete(bundleName);
if (eventType && eventType === EventConstants.EVENT_PACKAGE_REMOVED) {
this.mAppItemFormInfoMap.delete(bundleName);
return;
}
const formsInfoList = this.getFormsInfoByBundleName(bundleName, this.setAppItemFormInfo.bind(this));
}
/**
* delete form by bundleName
* @param bundleName
* Delete form by bundleName and update layout info.
*
* @param {string} bundleName
*/
deleteFormByBundleName(bundleName) {
const settingsModel = SettingsModel.getInstance();
this.mRdbStoreManager.deleteFormInfoByBundle(bundleName);
const formInfoList: any = this.mFormListInfoCacheManager.getCache(KEY_FORM_LIST);
if (formInfoList == CommonConstants.INVALID_VALUE) {
if (formInfoList === CommonConstants.INVALID_VALUE) {
return;
}
const layoutInfo = settingsModel.getLayoutInfo();
const tempFormInfoList = JSON.parse(JSON.stringify(formInfoList));
for(let i = 0; i < formInfoList.length; i++) {
const formInfo = formInfoList[i];
if (formInfo.bundleName == bundleName){
tempFormInfoList.splice(i, 1);
const pageItemMap = new Map<string, number>();
for (let i = 0; i < layoutInfo.layoutInfo.length; i++) {
const tmpPage = layoutInfo.layoutInfo[i].page.toString();
if (pageItemMap.has(tmpPage)) {
pageItemMap.set(tmpPage, pageItemMap.get(tmpPage) + 1);
} else {
pageItemMap.set(tmpPage, 1);
}
for(let j = layoutInfo.layoutInfo.length - 1; j >= 0; j--) {
if (layoutInfo.layoutInfo[j].type === CommonConstants.TYPE_CARD && formInfo.cardId == layoutInfo.layoutInfo[j].cardId) {
layoutInfo.layoutInfo.splice(j, 1);
break;
}
for(let i = formInfoList.length - 1; i >= 0; i--) {
const formInfo = formInfoList[i];
if (formInfo.bundleName === bundleName) {
tempFormInfoList.splice(i, 1);
for(let j = layoutInfo.layoutInfo.length - 1; j >= 0; j--) {
if (layoutInfo.layoutInfo[j].type === CommonConstants.TYPE_CARD && formInfo.cardId == layoutInfo.layoutInfo[j].cardId) {
const tmpPage = layoutInfo.layoutInfo[j].page.toString();
pageItemMap.set(tmpPage, pageItemMap.get(tmpPage) - 1);
layoutInfo.layoutInfo.splice(j, 1);
break;
}
}
}
}
settingsModel.setLayoutInfo(layoutInfo);
if (tempFormInfoList.length == 0) {
if (tempFormInfoList.length === 0) {
this.mFormListInfoCacheManager.setCache(KEY_FORM_LIST, null);
} else {
this.mFormListInfoCacheManager.setCache(KEY_FORM_LIST, tempFormInfoList);
}
const blankPages = [];
for (let [page, count] of pageItemMap) {
if (count === 0) {
layoutInfo.layoutDescription.pageCount--;
blankPages.push(page);
}
}
for (let m = 0; m < layoutInfo.layoutInfo.length; m++) {
let pageMinus = 0;
for (let n = 0; n < blankPages.length; n++) {
if (layoutInfo.layoutInfo[m].page > blankPages[n]) {
pageMinus++;
}
}
if (pageMinus != 0) {
layoutInfo.layoutInfo[m].page = layoutInfo.layoutInfo[m].page - pageMinus;
}
}
settingsModel.setLayoutInfo(layoutInfo);
}
}

View File

@ -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
@ -12,13 +12,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import amsMissionManager from '../manager/AmsMissionManager';
import Log from '../utils/Log';
const TAG = 'RecentMissionsModel';
/**
* Recent missions data model
* Recent missions data model.
*/
export default class RecentMissionsModel {

View File

@ -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
@ -153,6 +153,10 @@ export default class SettingsModel {
return this.mPageDesktopAppModeConfig.getAppListInfo();
}
isAppListInfoExit(): boolean {
return this.mPageDesktopAppModeConfig.isConfigExit();
}
/**
* Set layout config id of grid view.
*

View File

@ -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
@ -19,4 +19,4 @@
*/
export default interface SettingsModelObserver {
(event: number): void
};;;;;;;;;;
}

View File

@ -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
@ -18,4 +18,4 @@
*/
export default interface SettingItemOptionsChecker {
(): string
};;;;;;;;;;
}

View File

@ -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

View File

@ -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
@ -18,6 +18,10 @@ import AppIcon from './AppIcon.ets';
import AppName from './AppName.ets';
import AppMenu from './AppMenu.ets';
import PresetStyleConstants from '../constants/PresetStyleConstants';
import ResourceManager from '../manager/ResourceManager';
import Log from '../utils/Log';
const TAG = 'AppBubble';
@Component
export default struct AppBubble {
@ -50,32 +54,46 @@ export default struct AppBubble {
build() {
Column() {
AppIcon({
iconSize: this.iconSize,
appIcon: this.appIconId,
bundleName: this.bundleName,
badgeNumber: this.badgeNumber,
useCache: this.useCache
})
AppName({
nameHeight: this.nameHeight,
nameSize: this.nameSize,
nameFontColor: this.nameFontColor,
bundleName: this.bundleName,
appName: this.appName,
labelId: this.appLabelId,
useCache: this.useCache,
nameLines: this.nameLines,
marginTop: this.mIconNameMargin
})
Column() {
AppIcon({
iconSize: this.iconSize,
appIcon: this.appIconId,
icon: ResourceManager.getInstance().getCachedAppIcon(this.appIconId, this.bundleName),
bundleName: this.bundleName,
badgeNumber: this.badgeNumber,
useCache: this.useCache
})
AppName({
nameHeight: this.nameHeight,
nameSize: this.nameSize,
nameFontColor: this.nameFontColor,
bundleName: this.bundleName,
appName: this.appName,
labelId: this.appLabelId,
useCache: this.useCache,
nameLines: this.nameLines,
marginTop: this.mIconNameMargin
})
}
.bindContextMenu(this.MenuBuilder, ResponseType.LongPress)
.bindContextMenu(this.MenuBuilder, ResponseType.RightClick)
.width(this.isSelect ? this.iconSize + StyleConstants.DEFAULT_40 : StyleConstants.PERCENTAGE_100)
.height(StyleConstants.PERCENTAGE_100)
.backgroundColor(this.isSelect ? StyleConstants.DEFAULT_BROAD_COLOR : StyleConstants.DEFAULT_TRANSPARENT_COLOR)
.borderRadius(this.isSelect ? StyleConstants.DEFAULT_15 : StyleConstants.DEFAULT_0)
.padding(this.isSelect ? { left: StyleConstants.DEFAULT_20,
right: StyleConstants.DEFAULT_20, top: this.mPaddingTop } : { top: this.mPaddingTop })
}
.bindContextMenu(this.MenuBuilder, ResponseType.LongPress)
.bindContextMenu(this.MenuBuilder, ResponseType.RightClick)
.width(this.isSelect ? this.iconSize + StyleConstants.DEFAULT_40 : StyleConstants.PERCENTAGE_100)
.height(StyleConstants.PERCENTAGE_100)
.backgroundColor(this.isSelect ? StyleConstants.DEFAULT_BROAD_COLOR : StyleConstants.DEFAULT_TRANSPARENT_COLOR)
.borderRadius(this.isSelect ? StyleConstants.DEFAULT_15 : StyleConstants.DEFAULT_0)
.padding(this.isSelect ? { left: StyleConstants.DEFAULT_20,
right: StyleConstants.DEFAULT_20, top: this.mPaddingTop } : { top: this.mPaddingTop })
.parallelGesture(
LongPressGesture({ repeat: false })
.onAction((event: GestureEvent) => {
Log.showInfo(TAG, `long press source ${event.source}`);
if (event.source == SourceType.Mouse) {
AppStorage.SetOrCreate('selectDesktopAppItem', this.bundleName);
} else {
AppStorage.SetOrCreate('selectDesktopAppItem', '');
}
})
)
}
}

View File

@ -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
@ -17,8 +17,10 @@ import AppItemInfo from '../bean/AppItemInfo';
import AppBubble from './AppBubble.ets';
import AppGridStyleConfig from '../layoutconfig/AppGridStyleConfig';
import CommonConstants from '../constants/CommonConstants';
import Log from '../utils/Log';
let mAppGridStyleConfig: AppGridStyleConfig = null;
const TAG = 'AppGrid';
@Component
export default struct AppGrid {
@ -77,7 +79,7 @@ export default struct AppGrid {
.onMouse((event: MouseEvent) => {
if (event.button == MouseButton.Right) {
event.stopPropagation();
console.info('Launcher AppGrid onMouse MouseButton Right');
Log.showInfo(TAG, 'onMouse MouseButton Right');
}
})
}

View File

@ -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
@ -16,16 +16,20 @@
import ResourceManager from '../manager/ResourceManager';
import BadgeManager from '../manager/BadgeManager';
import StyleConstants from '../constants/StyleConstants';
import CheckEmptyUtils from '../utils/CheckEmptyUtils';
import Log from '../utils/Log';
const TAG = 'AppIcon';
@Component
export default struct AppIcon {
@Prop iconSize: number;
@Prop @Watch("updateIcon") appIcon: string;
@Prop iconSize: number|string;
@Prop appIcon: string;
@Prop bundleName: string;
@State icon: string = ' ';
@Prop icon: string;
@State size: number = 1;
useCache: boolean = true;
@Prop @Watch("updateBadge") badgeNumber: number;
@Prop badgeNumber: number;
@State badge: number = 0;
badgeFontSize: number = StyleConstants.DEFAULT_BADGE_FONT_SIZE;
private mResourceManager;
@ -33,12 +37,11 @@ export default struct AppIcon {
private mDefaultAppIcon;
public aboutToAppear(): void {
this.mDefaultAppIcon = StyleConstants.DEFAULT_ICON;
this.icon = this.mDefaultAppIcon;
this.mResourceManager = ResourceManager.getInstance();
this.mBadgeManager = BadgeManager.getInstance();
this.updateIcon();
this.updateBadge();
if (CheckEmptyUtils.isEmpty(this.icon)) {
this.updateIcon();
}
}
public iconLoadCallback(image) {
@ -78,8 +81,7 @@ export default struct AppIcon {
.height(this.iconSize)
}
.onHover((isHover: boolean) => {
console.info('Launcher AppIcon onHover isHover ' + isHover);
this.size = isHover ? 1.15 : 1
Log.showInfo(TAG, `onHover isHover ${isHover}`);
})
.onTouch((event: TouchEvent) => {
if (event.type === TouchType.Down) {

View File

@ -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
@ -21,11 +21,16 @@ import AppMenu from './AppMenu.ets';
import CommonConstants from '../constants/CommonConstants';
import StyleConstants from '../constants/StyleConstants';
import ScrollerComponent from './ScrollerComponent.ets';
import ResourceManager from '../manager/ResourceManager';
import CheckEmptyUtils from '../utils/CheckEmptyUtils';
import Log from '../utils/Log';
let mAppListStyleConfig: AppListStyleConfig = null;
const TAG = 'AppList';
@Component
export default struct AppList {
@StorageLink('sysUiRecentOnClickEvent') @Watch('sysUiRecentOnClick') sysUiRecentOnClickEvent: number = 0;
@State isHover: boolean = false;
@State showPopup: boolean = false;
@State onHoverItem: string = '';
@ -39,7 +44,7 @@ export default struct AppList {
popup: {
show: boolean,
showItem: string,
popup: PopupOption | CustomPopupOption
popup
} = { show: false, showItem: '', popup: null };
onClickWithPopup: boolean = false;
autoCancel: boolean = false;
@ -49,6 +54,11 @@ export default struct AppList {
mAppListStyleConfig = this.appListStyleConfig;
}
private sysUiRecentOnClick() {
this.showPopup = false;
this.popup = { show: false, showItem: '', popup: null };
}
@Builder popupBuilder() {
Column() {
ScrollerComponent({
@ -81,12 +91,7 @@ export default struct AppList {
}
this.getShowPopup();
})
.onClick((isScrollHover: boolean) => {
if (isScrollHover) {
this.isScrollHover = true;
} else {
this.isScrollHover = false;
}
.onClick(() => {
this.getShowPopup();
})
}
@ -112,7 +117,8 @@ export default struct AppList {
if (mAppListStyleConfig.mNameDisplaySide) {
HorizontalListItem({
appInfo: item,
buildMenu: this.buildMenu
buildMenu: this.buildMenu,
itemOffset: mAppListStyleConfig.mItemOffset
})
} else {
VerticalListItem({
@ -121,7 +127,7 @@ export default struct AppList {
})
}
}
.bindPopup(this.showPopup && item.bundleName == this.onHoverItem, {
.bindPopup(this.showPopup && item.bundleName == this.onHoverItem && !AppStorage.Get('smartDockShowMenu') as boolean, {
builder: this.popupBuilder,
placement: Placement.Top,
enableArrow: true,
@ -129,10 +135,13 @@ export default struct AppList {
maskColor: ('rgba(250,250,250,0)'),
popupColor: ('rgba(250,250,250,0.6)'),
onStateChange: (e) => {
if(!e.isVisible){
this.showPopup = false;
this.onHoverItem = ''
if (!e.isVisible && this.autoCancel) {
this.popup = { show: false, showItem: '', popup: null };
this.onHoverItem = '';
this.onClickWithPopup = false;
this.autoCancel = false;
this.showPopup = false;
AppStorage.SetOrCreate('snapshotList', []);
AppStorage.SetOrCreate('recentShowPopup', false);
}
if (this.updateData) {
@ -152,15 +161,14 @@ export default struct AppList {
})
.onClick((event: ClickEvent) => {
this.onItemClick(event, item);
let shapshotList:[] = AppStorage.Get("shapshotList");
this.onClickWithPopup = AppStorage.Get("recentShowPopup");
console.info('Launcher AppList onClick this.onClickWithPopup:' + this.onClickWithPopup);
if (this.onClickWithPopup && shapshotList?.length > 1) {
this.onClickWithPopup = AppStorage.Get('recentShowPopup');
Log.showInfo(TAG, `onClick this.onClickWithPopup: ${this.onClickWithPopup}`);
if (this.onClickWithPopup) {
this.autoCancel = true;
this.onHoverEvent(true, item.bundleName);
this.showPopup = true
this.onHoverItem = item.bundleName;
}
AppStorage.SetOrCreate('recentShowPopup', false);
})
}, (item) => JSON.stringify(item))
}
@ -175,6 +183,7 @@ struct HorizontalListItem {
@State isShow: boolean = false;
appInfo: AppItemInfo = null;
buildMenu: Function = null;
itemOffset: {} = { x: 0, y: 0 }
private menuInfo;
private aboutToAppear(): void {
@ -216,6 +225,7 @@ struct HorizontalListItem {
if (!e.isVisible) {
this.isShow = false;
}
AppStorage.SetOrCreate('smartDockShowMenu', e.isVisible)
},
autoCancel: true
})
@ -227,11 +237,12 @@ struct HorizontalListItem {
.onMouse((event: MouseEvent) => {
if (event.button == MouseButton.Right) {
event.stopPropagation();
console.info('Launcher AppList onMouse MouseButton Right');
Log.showInfo(TAG, 'onMouse MouseButton Right');
AppStorage.SetOrCreate('selectDesktopAppItem', null);
this.isShow = true;
}
})
.offset(this.itemOffset)
} else {
Column() {
AppItem({
@ -253,6 +264,7 @@ struct VerticalListItem {
AppIcon({
iconSize: mAppListStyleConfig.mIconSize,
appIcon: this.appInfo.appIconId,
icon: ResourceManager.getInstance().getCachedAppIcon(this.appInfo.appIconId, this.appInfo.bundleName),
bundleName: this.appInfo.bundleName,
badgeNumber: CommonConstants.BADGE_DISPLAY_HIDE
})
@ -297,6 +309,7 @@ struct AppItem {
AppIcon({
iconSize: mAppListStyleConfig.mIconSize,
appIcon: this.appInfo.appIconId,
icon: ResourceManager.getInstance().getCachedAppIcon(this.appInfo.appIconId, this.appInfo.bundleName),
bundleName: this.appInfo.bundleName,
badgeNumber: CommonConstants.BADGE_DISPLAY_HIDE
})
@ -318,7 +331,6 @@ struct AppItem {
}
.width(mAppListStyleConfig.mListItemWidth)
.height(mAppListStyleConfig.mListItemHeight)
.padding(mAppListStyleConfig.mItemPadding)
.backgroundColor(mAppListStyleConfig.mItemBackgroundColor)
.borderRadius(mAppListStyleConfig.mItemBorderRadius)
}

View File

@ -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
@ -17,6 +17,9 @@ import MenuInfo from '../bean/MenuInfo';
import CommonConstants from '../constants/CommonConstants';
import StyleConstants from '../constants/StyleConstants';
import ResourceManager from '../manager/ResourceManager';
import Log from '../utils/Log';
const TAG = 'AppMenu';
@Component
export default struct AppMenu {
@ -27,7 +30,7 @@ export default struct AppMenu {
isBothTypeMenuExist: boolean = true;
aboutToAppear() {
console.info("Launcher AppMenu aboutToAppear start");
Log.showInfo(TAG, 'aboutToAppear start');
this.fixedMenuList = new Array<MenuInfo>();
this.dynamicMenuList = new Array<MenuInfo>();
for (let menuInfo of this.menuInfoList) {

View File

@ -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

View File

@ -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
@ -15,8 +15,11 @@
import CommonConstants from '../constants/CommonConstants';
import StyleConstants from '../constants/StyleConstants';
import ResourceManager from '../manager/ResourceManager';
import OverlayAppIcon from './OverlayAppIcon.ets';
import AppIcon from './AppIcon.ets';
import FolderComponent from './FolderComponent.ets';
import MenuInfo from '../bean/MenuInfo'
import FormItemComponent from './FormItemComponent.ets';
@Component
@ -73,9 +76,11 @@ export default struct CustomOverlay {
}
if (this.overlayMode == CommonConstants.OVERLAY_TYPE_APP_ICON) {
Column() {
AppIcon({
OverlayAppIcon({
iconSize: this.overlayData.iconSize,
appIcon: this.overlayData.appInfo.appIconId,
icon: ResourceManager.getInstance()
.getCachedAppIcon(this.overlayData.appInfo.appIconId, this.overlayData.appInfo.bundleName),
bundleName: this.overlayData.appInfo.bundleName,
badgeNumber: CommonConstants.BADGE_DISPLAY_HIDE
})
@ -95,7 +100,10 @@ export default struct CustomOverlay {
folderGridSize:this.overlayData.folderGridSize,
appIconSize: this.overlayData.appIconSize,
gridMargin: this.overlayData.gridMargin,
gridGap: this.overlayData.gridGap
gridGap: this.overlayData.gridGap,
buildMenu: (folderItem) => {
return new Array<MenuInfo>();
}
})
}
.position({

View File

@ -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
@ -12,6 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import AppIcon from './AppIcon.ets';
import AppName from './AppName.ets';
import StyleConstants from '../constants/StyleConstants';
@ -20,6 +21,7 @@ import PresetStyleConstants from '../constants/PresetStyleConstants';
import SettingsModel from '../model/SettingsModel';
import AppMenu from './AppMenu.ets';
import Log from '../utils/Log';
import ResourceManager from '../manager/ResourceManager';
const TAG = 'FolderComponent';
@ -62,6 +64,7 @@ export default struct FolderComponent {
buildMenu: Function = null;
folderNameLines: number = PresetStyleConstants.DEFAULT_APP_NAME_LINES;
iconNameMargin: number = PresetStyleConstants.DEFAULT_ICON_NAME_GAP;
isSelect?: boolean;
private aboutToAppear(): void {
Log.showInfo(TAG, `aboutToAppear`);
@ -99,9 +102,9 @@ export default struct FolderComponent {
this.mSuperposeAppList[1].alignContent = Alignment.Center;
this.mSuperposeAppList[2].alignContent = Alignment.BottomEnd;
Log.showInfo(TAG, `this.superposeIconVisible:${this.superposeIconVisible}`);
Log.showInfo(TAG, `this.mFolderItem.layoutInfo[0].length:${this.mFolderItem.layoutInfo[0].length}`);
Log.showInfo(TAG, `this.mSuperposeAppList.length:${this.mSuperposeAppList.length}`);
Log.showInfo(TAG, `superposeIconVisible:${this.superposeIconVisible}`);
Log.showInfo(TAG, `FolderItem.layoutInfo[0].length:${this.mFolderItem.layoutInfo[0].length}`);
Log.showInfo(TAG, `SuperposeAppList length:${this.mSuperposeAppList.length}`);
}
@Builder MenuBuilder() {
@ -130,14 +133,14 @@ export default struct FolderComponent {
}
}
private showAnimate(animateScale: number, animateOpacity:number, isMoveFolder: boolean) {
private showAnimate(animateScale: number, animateOpacity: number, isMoveFolder: boolean) {
let positionX = 0;
let positionY = 0;
if (this.onGetPosition) {
this.onGetPosition(this.getPosition.bind(this));
if (isMoveFolder) {
positionX = this.animateFolderPositionX;
positionY= this.animateFolderPositionY;
positionY = this.animateFolderPositionY;
}
}
animateTo({
@ -170,144 +173,155 @@ export default struct FolderComponent {
build() {
Column() {
Badge({
count: this.badgeNumber,
maxCount: StyleConstants.MAX_BADGE_COUNT,
style: {
color: StyleConstants.DEFAULT_FONT_COLOR,
fontSize: StyleConstants.DEFAULT_BADGE_FONT_SIZE,
badgeSize: (this.badgeNumber > 0 ? StyleConstants.DEFAULT_BADGE_SIZE : 0),
badgeColor: Color.Red,
}
}) {
Stack() {
Column() {
Column() {
Badge({
count: this.badgeNumber,
maxCount: StyleConstants.MAX_BADGE_COUNT,
style: {
color: StyleConstants.DEFAULT_FONT_COLOR,
fontSize: StyleConstants.DEFAULT_BADGE_FONT_SIZE,
badgeSize: (this.badgeNumber > 0 ? StyleConstants.DEFAULT_BADGE_SIZE : 0),
badgeColor: Color.Red,
}
.backgroundColor(Color.White)
.borderRadius(24)
.opacity(0.5)
.height(this.folderGridSize)
.width(this.folderGridSize)
Grid() {
ForEach(this.mShowAppList, (item) => {
GridItem() {
AppIcon({
iconSize: this.appIconSize,
appIcon: item.appIconId,
bundleName: item.bundleName,
badgeNumber: CommonConstants.BADGE_DISPLAY_HIDE
}) {
Stack() {
Column() {
}
.backgroundColor(Color.White)
.borderRadius(24)
.opacity(0.5)
.height(this.folderGridSize)
.width(this.folderGridSize)
Grid() {
ForEach(this.mShowAppList, (item) => {
GridItem() {
AppIcon({
iconSize: this.appIconSize,
appIcon: item.appIconId,
icon: ResourceManager.getInstance().getCachedAppIcon(item.appIconId, item.bundleName),
bundleName: item.bundleName,
badgeNumber: CommonConstants.BADGE_DISPLAY_HIDE
})
}
.height(StyleConstants.PERCENTAGE_100)
.width(StyleConstants.PERCENTAGE_100)
.onClick((event: ClickEvent) => {
if (this.onAppIconClick) {
this.onAppIconClick(event, item);
}
})
}, (item) => JSON.stringify(item))
if (this.mSuperposeAppList.length > 0) {
GridItem() {
Stack() {
ForEach(this.mSuperposeAppList, (item) => {
Stack({ alignContent: item.alignContent }) {
if (item.isEmpty) {
Column() {
}
.backgroundColor(Color.White)
.borderRadius(10)
.opacity(0.5)
.width(StyleConstants.PERCENTAGE_75)
.height(StyleConstants.PERCENTAGE_75)
.margin({ left: 3, top: 3 })
} else {
AppIcon({
iconSize: '80%',
appIcon: item.appIconId,
icon: ResourceManager.getInstance().getCachedAppIcon(item.appIconId, item.bundleName),
bundleName: item.bundleName,
badgeNumber: CommonConstants.BADGE_DISPLAY_HIDE
})
}
}
.width(StyleConstants.PERCENTAGE_100)
.height(StyleConstants.PERCENTAGE_100)
}, (item) => JSON.stringify(item))
}
.width(this.isPad ?
StyleConstants.DEFAULT_FOLDER_APP_ITEM_WIDTH_SMALL :
StyleConstants.DEFAULT_FOLDER_APP_ITEM_WIDTH)
.height(this.isPad ?
StyleConstants.DEFAULT_FOLDER_APP_ITEM_WIDTH_SMALL :
StyleConstants.DEFAULT_FOLDER_APP_ITEM_WIDTH)
}
.visibility(this.superposeIconVisible ? Visibility.Visible : Visibility.Hidden)
.width(StyleConstants.PERCENTAGE_100)
.height(StyleConstants.PERCENTAGE_100)
.onClick((event: ClickEvent) => {
Log.showInfo(TAG, `last item onClick`);
this.showAnimate(1.5, 0, true);
if (this.onOpenFolderClick) {
this.folderAnimateData.folderId = this.mFolderItem.folderId;
this.folderAnimateData.isOpenFolder = true;
AppStorage.SetOrCreate('folderAnimateData', this.folderAnimateData);
this.onOpenFolderClick(event, this.mFolderItem);
}
})
}
.height(StyleConstants.PERCENTAGE_100)
.width(StyleConstants.PERCENTAGE_100)
.onClick((event: ClickEvent) => {
if (this.onAppIconClick) {
this.onAppIconClick(event, item);
}
})
}, (item) => JSON.stringify(item))
if (this.mSuperposeAppList.length > 0) {
GridItem() {
Stack() {
ForEach(this.mSuperposeAppList, (item) => {
Stack({ alignContent: item.alignContent }) {
if (item.isEmpty) {
Column() {
}
.backgroundColor(Color.White)
.borderRadius(10)
.opacity(0.5)
.width(StyleConstants.PERCENTAGE_75)
.height(StyleConstants.PERCENTAGE_75)
.margin({ left: 3, top: 3 })
} else {
AppIcon({
iconSize: '80%',
appIcon: item.appIconId,
bundleName: item.bundleName,
badgeNumber: CommonConstants.BADGE_DISPLAY_HIDE
})
}
}
.width(StyleConstants.PERCENTAGE_100)
.height(StyleConstants.PERCENTAGE_100)
}, (item) => JSON.stringify(item))
}
.width(this.isPad ?
StyleConstants.DEFAULT_FOLDER_APP_ITEM_WIDTH_SMALL :
StyleConstants.DEFAULT_FOLDER_APP_ITEM_WIDTH)
.height(this.isPad ?
StyleConstants.DEFAULT_FOLDER_APP_ITEM_WIDTH_SMALL :
StyleConstants.DEFAULT_FOLDER_APP_ITEM_WIDTH)
}
.bindContextMenu(this.MenuBuilder, ResponseType.LongPress)
.bindContextMenu(this.MenuBuilder, ResponseType.RightClick)
.padding(this.gridMargin)
.columnsTemplate('1fr 1fr 1fr')
.rowsTemplate('1fr 1fr 1fr')
.columnsGap(this.gridGap)
.rowsGap(this.gridGap)
.onClick((event: ClickEvent) => {
Log.showInfo(TAG, `grid onClick`);
this.showAnimate(1.5, 0, true);
if (this.onOpenFolderClick) {
this.folderAnimateData.folderId = this.mFolderItem.folderId;
this.folderAnimateData.isOpenFolder = true;
AppStorage.SetOrCreate('folderAnimateData', this.folderAnimateData);
this.onOpenFolderClick(event, this.mFolderItem);
}
.visibility(this.superposeIconVisible ? Visibility.Visible : Visibility.Hidden)
.width(StyleConstants.PERCENTAGE_100)
.height(StyleConstants.PERCENTAGE_100)
.onClick((event: ClickEvent) => {
Log.showInfo(TAG, `last item onClick`);
this.showAnimate(1.5, 0, true);
if (this.onOpenFolderClick) {
this.folderAnimateData.folderId = this.mFolderItem.folderId;
this.folderAnimateData.isOpenFolder = true;
AppStorage.SetOrCreate('folderAnimateData', this.folderAnimateData);
this.onOpenFolderClick(event, this.mFolderItem);
}
})
}
})
.onTouch((event: TouchEvent) => {
Log.showInfo(TAG, "onTouch start");
if (this.onFolderTouch) {
this.onFolderTouch(event, this.mFolderItem);
}
Log.showInfo(TAG, "onTouch end");
})
}
.bindContextMenu(this.MenuBuilder, ResponseType.LongPress)
.bindContextMenu(this.MenuBuilder, ResponseType.RightClick)
.padding(this.gridMargin)
.columnsTemplate('1fr 1fr 1fr')
.rowsTemplate('1fr 1fr 1fr')
.columnsGap(this.gridGap)
.rowsGap(this.gridGap)
.onClick((event: ClickEvent) => {
Log.showInfo(TAG, `grid onClick`);
this.showAnimate(1.5, 0, true);
if (this.onOpenFolderClick) {
this.folderAnimateData.folderId = this.mFolderItem.folderId;
this.folderAnimateData.isOpenFolder = true;
AppStorage.SetOrCreate('folderAnimateData', this.folderAnimateData);
this.onOpenFolderClick(event, this.mFolderItem);
}
})
.onTouch((event: TouchEvent) => {
Log.showInfo(TAG, "onTouch start");
if (this.onFolderTouch) {
this.onFolderTouch(event, this.mFolderItem);
}
Log.showInfo(TAG, "onTouch end");
.height(StyleConstants.PERCENTAGE_100)
.width(StyleConstants.PERCENTAGE_100)
.onHover((isHover: boolean) => {
Log.showInfo(TAG, `onHover isHover:${isHover}`);
this.isHover = isHover;
})
}
.height(StyleConstants.PERCENTAGE_100)
.width(StyleConstants.PERCENTAGE_100)
.onHover((isHover: boolean) => {
Log.showInfo(TAG, `onHover isHover:${isHover}`);
this.isHover = isHover;
})
}
.height(this.folderGridSize)
.width(this.folderGridSize)
.height(this.folderGridSize)
.width(this.folderGridSize)
Column() {
AppName({
nameHeight: this.folderNameHeight,
nameSize: this.folderNameSize,
nameFontColor: this.nameFontColor,
appName: this.mFolderItem.folderName,
nameLines: this.folderNameLines,
marginTop: this.iconNameMargin
})
Column() {
AppName({
nameHeight: this.folderNameHeight,
nameSize: this.folderNameSize,
nameFontColor: this.nameFontColor,
appName: this.mFolderItem.folderName,
nameLines: this.folderNameLines,
marginTop: this.iconNameMargin
})
}
.visibility(this.showFolderName ? Visibility.Visible : Visibility.Hidden)
}
.visibility(this.showFolderName ? Visibility.Visible : Visibility.Hidden)
.width(StyleConstants.PERCENTAGE_100)
.height(StyleConstants.PERCENTAGE_100)
.offset({ x: this.folderPositionX, y: this.folderPositionY })
.scale({ x: this.isHover ? 1.05 : this.animateScale, y: this.isHover ? 1.05 : this.animateScale })
.opacity(this.animateOpacity)
}
.width(StyleConstants.PERCENTAGE_100)
.height(StyleConstants.PERCENTAGE_100)
.offset({ x: this.folderPositionX, y: this.folderPositionY })
.padding({top : this.mPaddingTop})
.scale({ x: this.isHover ? 1.15 : this.animateScale, y: this.isHover ? 1.15 : this.animateScale })
.opacity(this.animateOpacity)
.width(this.isSelect ? this.folderGridSize + StyleConstants.DEFAULT_40 : StyleConstants.PERCENTAGE_100)
.height(this.isSelect ? this.folderGridSize + StyleConstants.DEFAULT_40 : StyleConstants.PERCENTAGE_100)
.backgroundColor(this.isSelect ? StyleConstants.DEFAULT_BROAD_COLOR : StyleConstants.DEFAULT_TRANSPARENT_COLOR)
.borderRadius(this.isSelect ? StyleConstants.DEFAULT_15 : StyleConstants.DEFAULT_0)
.padding(this.isSelect ? { left: StyleConstants.DEFAULT_20,
right: StyleConstants.DEFAULT_20, top: this.mPaddingTop + StyleConstants.DEFAULT_10 } : { top: this.mPaddingTop })
}
}

View File

@ -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
@ -12,6 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import StyleConstants from '../constants/StyleConstants';
import PresetStyleConstants from '../constants/PresetStyleConstants';
import AppMenu from './AppMenu.ets';
@ -58,7 +59,7 @@ export default struct FormItemComponent {
build() {
Column() {
FormComponent({
id: 0,
id: this.formItem.cardId,
name: this.formItem.cardName,
bundle: this.formItem.bundleName,
ability: this.formItem.abilityName,
@ -70,7 +71,7 @@ export default struct FormItemComponent {
.allowUpdate(this.isAllowUpdate)
.visibility(this.isShow ? Visibility.Visible : Visibility.None)
.onAcquired((form) => {
console.info(`FormComponent card id is:${form.id}`);
Log.showInfo(TAG, `FormComponent card id is: ${form.id}`);
this.formId = form.id;
if (this.getFormId) {
this.getFormId(form.id);
@ -83,7 +84,7 @@ export default struct FormItemComponent {
}
})
.onError((error) => {
console.info(' FormComponent error msg:' + error.msg);
Log.showInfo(TAG, `FormComponent error msg: ${error.msg}`);
})
Column() {
@ -101,16 +102,15 @@ export default struct FormItemComponent {
.visibility(this.showFormName ? Visibility.Visible : Visibility.Hidden)
}
.onHover((isHover: boolean) => {
console.info(`Launcher Form onHover isHover:${isHover}`);
Log.showInfo(TAG, `Form onHover isHover: ${isHover}`);
this.isHover = isHover;
})
.onDisAppear(() => {
console.log('formItemComponent onDisAppear: ' + this.formId);
Log.showInfo(TAG, `formItemComponent onDisAppear: ${this.formId}`);
})
.padding({top : this.mPaddingTop})
.height(StyleConstants.PERCENTAGE_100)
.width(StyleConstants.PERCENTAGE_100)
.scale({ x: this.isHover ? 1.15 : 1.0, y: this.isHover ? 1.15 : 1.0 })
.bindContextMenu(this.MenuBuilder, ResponseType.LongPress)
.bindContextMenu(this.MenuBuilder, ResponseType.RightClick)
}

View File

@ -0,0 +1,56 @@
/**
* 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 ResourceManager from '../manager/ResourceManager';
import Log from '../utils/Log';
const TAG = 'OverlayAppIcon';
@Component
export default struct OverlayAppIcon {
@Prop iconSize: number;
@Prop appIcon: string;
@Prop bundleName: string;
@Prop icon: string;
// 0.9(pressed size) / 1.05(hover size) = 0.8571
@State size: number = 0.8571;
useCache: boolean = true;
@Prop badgeNumber: number;
@State badge: number = 0;
private mResourceManager;
private mDefaultAppIcon;
public aboutToAppear(): void {
this.mResourceManager = ResourceManager.getInstance();
}
build() {
Column() {
Image(this.icon)
.width(this.iconSize)
.height(this.iconSize)
.onComplete(() => {
Log.showInfo(TAG, 'OverlayAppIcon complete');
this.size = 1;
AppStorage.SetOrCreate('isOverlayComplete', true);
})
}
.width(this.iconSize)
.height(this.iconSize)
.scale({ x: this.size, y: this.size })
.animation({ duration: 100 })
}
}

View File

@ -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
@ -49,6 +49,7 @@ export default struct RemoveFormDialog {
}
.backgroundColor(StyleConstants.DEFAULT_BG_COLOR)
.height(StyleConstants.DEFAULT_BUTTON_HEIGHT)
.width(StyleConstants.DEFAULT_BUTTON_WIDTH)
.onClick(() => {
this.controller.close();
this.cancel()
@ -66,6 +67,7 @@ export default struct RemoveFormDialog {
}
.backgroundColor(StyleConstants.DEFAULT_BG_COLOR)
.height(StyleConstants.DEFAULT_BUTTON_HEIGHT)
.width(StyleConstants.DEFAULT_BUTTON_WIDTH)
.onClick(() => {
this.controller.close();
this.confirm()

View File

@ -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
@ -12,12 +12,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import amsMissionManager from '../manager/AmsMissionManager.ts'
import StyleConstants from '../constants/StyleConstants';
@Component
export default struct ScrollerComponent {
@StorageLink("shapshotList") dataList: {
@StorageLink('snapshotList') dataList: {
name: any,
image: any,
missionId: number,
@ -26,9 +27,9 @@ export default struct ScrollerComponent {
left?: number,
right?: number,
}[] = [];
@StorageLink("snapShotWidth") listWidth: number = 0;
@StorageLink('snapShotWidth') listWidth: number = 0;
scroller: Scroller= new Scroller() ;
private screenWidth = 1200 - StyleConstants.DEFAULT_40 - StyleConstants.DEFAULT_30;
private screenWidth = 800;
popupHide: Function= null;
updateData: Function= null;
@ -39,44 +40,40 @@ export default struct ScrollerComponent {
Row() {
ForEach(this.dataList, (item) => {
Column() {
Column() {
Row() {
Text(item.name.toString())
.height(StyleConstants.DEFAULT_BADGE_FONT_SIZE)
.textOverflow({ overflow: TextOverflow.Ellipsis })
.fontSize(StyleConstants.DEFAULT_10)
.textAlign(TextAlign.Start)
.margin({
top: StyleConstants.DEFAULT_ITEM_RADIUS,
bottom: StyleConstants.DEFAULT_SMART_DOCK_MISSION_MERGIN_BOTTOM
})
.maxLines(1)
.width(item.boxSize - StyleConstants.DEFAULT_30)
.hoverEffect(HoverEffect.None)
Text('×')
.height(StyleConstants.DEFAULT_BADGE_FONT_SIZE)
.fontSize(StyleConstants.DEFAULT_15)
.width(StyleConstants.DEFAULT_20)
.textAlign(TextAlign.Center)
.margin({ top: StyleConstants.DEFAULT_ITEM_RADIUS,
bottom: StyleConstants.DEFAULT_SMART_DOCK_MISSION_MERGIN_BOTTOM,
right: StyleConstants.DEFAULT_SMART_DOCK_MISSION_MERGIN_RIGHT
})
.onClick((event: ClickEvent) => {
if (this.dataList.length <= 1) {
this.updateData(false, "", () => amsMissionManager.clearMission(item.missionId));
return
}
this.updateData(true, item.bundleName, () => amsMissionManager.clearMission(item.missionId));
})
}
Flex({
direction: FlexDirection.Row,
alignItems: ItemAlign.Center,
justifyContent: FlexAlign.SpaceBetween
}) {
Text(item.name.toString())
.height(StyleConstants.DEFAULT_24)
.textOverflow({ overflow: TextOverflow.Ellipsis })
.fontSize(StyleConstants.DEFAULT_14)
.textAlign(TextAlign.Start)
.maxLines(StyleConstants.DEFAULT_1)
.width(item.boxSize - StyleConstants.DEFAULT_30)
.hoverEffect(HoverEffect.None)
.fontWeight(FontWeight.Medium)
Image($r('app.media.ic_public_cancel'))
.width(StyleConstants.DEFAULT_16)
.height(StyleConstants.DEFAULT_16)
.objectFit(ImageFit.Contain)
.margin({ right: StyleConstants.DEFAULT_4 })
.onClick((event: ClickEvent) => {
if (this.dataList.length <= 1) {
this.updateData(false, "", () => amsMissionManager.clearMission(item.missionId));
return
}
this.updateData(true, item.bundleName, () => amsMissionManager.clearMission(item.missionId));
})
}
.width(item.boxSize)
Image(item.image)
.height(StyleConstants.DEFAULT_SMART_DOCK_MISSION_IMAGE_HEIGHT)
.objectFit(ImageFit.Contain)
.borderRadius(StyleConstants.DEFAULT_5)
.borderRadius(StyleConstants.DEFAULT_8)
.hoverEffect(HoverEffect.None)
}
.onClick((event: ClickEvent) => {
@ -84,17 +81,14 @@ export default struct ScrollerComponent {
amsMissionManager.moveMissionToFront(item.missionId);
})
.width(item.boxSize)
.margin({
left: this.dataList.length <= 1 ? 0 : item.left,
right: item.right || StyleConstants.DEFAULT_0
})
.margin({ right: StyleConstants.DEFAULT_14 })
.borderRadius(StyleConstants.DEFAULT_5)
}, item => JSON.stringify(item))
}
}
.margin({
left: this.listWidth > this.screenWidth ? StyleConstants.DEFAULT_40 : StyleConstants.DEFAULT_0,
right: this.listWidth > this.screenWidth ? StyleConstants.DEFAULT_30 : StyleConstants.DEFAULT_0
left: this.listWidth > this.screenWidth ? StyleConstants.DEFAULT_56 : StyleConstants.DEFAULT_14,
right: this.listWidth > this.screenWidth ? StyleConstants.DEFAULT_56 : StyleConstants.DEFAULT_0
})
.constraintSize({
maxWidth: this.screenWidth,
@ -102,46 +96,61 @@ export default struct ScrollerComponent {
})
.scrollable(ScrollDirection.Horizontal)
.scrollBar(BarState.Off)
.height(StyleConstants.DEFAULT_SMART_DOCK_MISSION_HEIGHT)
Flex({
direction: FlexDirection.Row,
alignItems: ItemAlign.Center,
justifyContent: FlexAlign.SpaceBetween
}) {
Flex({
direction: FlexDirection.Row,
alignItems: ItemAlign.Center,
justifyContent: FlexAlign.Center
}) {
Button({ type: ButtonType.Circle, stateEffect: true }) {
Image($r('app.media.ic_public_arrow_left'))
.width(20)
.height(20)
.objectFit(ImageFit.Contain)
}
.width(24)
.height(24)
.backgroundColor('#00000005')
.onClick((event: ClickEvent) => {
this.onClickLeft();
})
}
.width(StyleConstants.DEFAULT_56)
.height(StyleConstants.DEFAULT_SMART_DOCK_MISSION_HEIGHT)
Flex({
direction: FlexDirection.Row,
alignItems: ItemAlign.Center,
justifyContent: FlexAlign.Center
}) {
Button({ type: ButtonType.Circle, stateEffect: true }) {
Image($r('app.media.ic_public_arrow_right'))
.width(20)
.height(20)
.objectFit(ImageFit.Contain)
}
.width(24)
.height(24)
.backgroundColor('#00000005')
.onClick((event: ClickEvent) => {
this.onClickLeft();
})
}
.width(StyleConstants.DEFAULT_56)
.height(StyleConstants.DEFAULT_SMART_DOCK_MISSION_HEIGHT)
}
.width(this.screenWidth + 2 * StyleConstants.DEFAULT_56)
.height(StyleConstants.DEFAULT_SMART_DOCK_MISSION_HEIGHT)
.visibility(this.listWidth > this.screenWidth ? Visibility.Visible : Visibility.None)
}
.height(StyleConstants.DEFAULT_SMART_DOCK_MISSION_HEIGHT)
Text("")
.textAlign(TextAlign.Center)
.height(StyleConstants.DEFAULT_SMART_DOCK_MISSION_HEIGHT)
.width(StyleConstants.DEFAULT_30)
.backgroundColor(StyleConstants.DEFAULT_TRANSPARENT_COLOR)
.fontColor(StyleConstants.DEFAULT_0)
.fontSize(StyleConstants.DEFAULT_20)
.offset({
x: StyleConstants.DEFAULT_0,
y: StyleConstants.DEFAULT_0
})
.visibility(this.listWidth > this.screenWidth ? Visibility.Visible : Visibility.None)
.onClick((event: ClickEvent) => {
this.onClickLeft();
})
Text("")
.textAlign(TextAlign.Center)
.height(StyleConstants.DEFAULT_SMART_DOCK_MISSION_HEIGHT)
.width(StyleConstants.DEFAULT_30)
.backgroundColor(StyleConstants.DEFAULT_TRANSPARENT_COLOR)
.fontColor(StyleConstants.DEFAULT_0)
.fontSize(StyleConstants.DEFAULT_20)
.offset({
x: this.screenWidth + StyleConstants.PIXEL_50,
y: StyleConstants.DEFAULT_0
})
.visibility(this.listWidth > this.screenWidth ? Visibility.Visible : Visibility.None)
.onClick((event: ClickEvent) => {
this.onClickRight();
})
}
.constraintSize({
maxWidth: this.screenWidth + StyleConstants.DEFAULT_40 + StyleConstants.DEFAULT_30,
maxHeight: StyleConstants.DEFAULT_SMART_DOCK_MISSION_HEIGHT
})
.visibility(this.dataList.length < 1 ? Visibility.None : Visibility.Visible)
}
private onClickLeft() {
@ -155,8 +164,7 @@ export default struct ScrollerComponent {
}
this.scroller.scrollTo({
yOffset: this.scroller.currentOffset()
.yOffset,
yOffset: this.scroller.currentOffset().yOffset,
xOffset: currentOffset
})
}
@ -173,8 +181,7 @@ export default struct ScrollerComponent {
}
this.scroller.scrollTo({
yOffset: this.scroller.currentOffset()
.yOffset,
yOffset: this.scroller.currentOffset().yOffset,
xOffset: currentOffset
})
}

View File

@ -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
@ -21,10 +21,9 @@ import FeatureConstants from '../../../../../../feature/smartdock/src/main/ets/d
@Component
export default struct SmartDockContent {
@Link @Watch('onDockListChange') dockItemList: Array<DockItemInfo>;
@StorageLink('dragLocation') @Watch('onTouchEventUpdate') dragLocation: string= "";
@StorageLink('dragLocation') @Watch('onTouchEventUpdate') dragLocation: string = "";
mSmartDockStyleConfig: SmartDockStyleConfig;
mMaxNum: number;
mListWidth: number;
onItemClick: Function;
onItemTouch: Function;
onDockListChangeFunc: Function;
@ -33,7 +32,7 @@ export default struct SmartDockContent {
popup: {
show: boolean,
showItem: string,
popup: PopupOption | CustomPopupOption
popup
};
onHoverEvent: Function;
@ -60,12 +59,11 @@ export default struct SmartDockContent {
AppStorage.SetOrCreate('dragFocus', FeatureConstants.FEATURE_NAME);
this.onItemTouch(event);
})
.width(this.mListWidth)
.width(this.getListWidth(this.dockItemList))
.height(this.mSmartDockStyleConfig.mDockHeight)
.backgroundColor(this.mSmartDockStyleConfig.mBackgroundColor)
.borderRadius(this.mSmartDockStyleConfig.mDockRadius)
.backdropBlur(this.mSmartDockStyleConfig.mBackdropBlur)
.padding(this.mSmartDockStyleConfig.mDockPadding)
.visibility(this.getListWidth(this.dockItemList) === 0 ? Visibility.None : Visibility.Visible)
}
@ -85,7 +83,6 @@ export default struct SmartDockContent {
private onDockListChange() {
this.onDockListChangeFunc();
this.mListWidth = this.getListWidth(this.dockItemList);
}
private onTouchEventUpdate() {

View File

@ -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
@ -43,6 +43,7 @@ export default struct UninstallDialog {
}
.backgroundColor(StyleConstants.DEFAULT_BG_COLOR)
.height(StyleConstants.DEFAULT_BUTTON_HEIGHT)
.width(StyleConstants.DEFAULT_BUTTON_WIDTH)
.onClick(() => {
this.controller.close();
this.cancel()
@ -60,6 +61,7 @@ export default struct UninstallDialog {
}
.backgroundColor(StyleConstants.DEFAULT_BG_COLOR)
.height(StyleConstants.DEFAULT_BUTTON_HEIGHT)
.width(StyleConstants.DEFAULT_BUTTON_WIDTH)
.onClick(() => {
this.controller.close();
this.confirm()

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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
@ -26,7 +26,7 @@ export default class Log {
* @param {string} tag - Page or class tag
* @param {string} log - Log needs to be printed
*/
static showInfo(tag, log) {
static showInfo(tag: string, log: string) {
console.info(`${TAG} tag: ${tag} --> ${log}`);
}
@ -36,7 +36,7 @@ export default class Log {
* @param {string} tag - Page or class tag
* @param {string} log - Log needs to be printed
*/
static showDebug(tag, log) {
static showDebug(tag: string, log: string) {
console.debug(`${TAG} tag: ${tag} --> ${log}`);
}
@ -46,7 +46,7 @@ export default class Log {
* @param {string} tag - Page or class tag
* @param {string} log - Log needs to be printed
*/
static showError(tag, log) {
static showError(tag: string, log: string) {
console.error(`${TAG} tag: ${tag} --> ${log}`);
}
}

View File

@ -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

View File

@ -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

Some files were not shown because too many files have changed in this diff Show More