mirror of
https://gitee.com/openharmony/applications_photos
synced 2024-11-27 01:01:06 +00:00
code check
Signed-off-by: z00513345 <zhuchengfeng1@huawei.com>
This commit is contained in:
parent
2f7939daae
commit
ccda297f44
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,5 +1,6 @@
|
||||
/node_modules
|
||||
/local.properties
|
||||
/.hvigor
|
||||
/.idea
|
||||
/.deveco
|
||||
**/build
|
||||
|
@ -1,5 +0,0 @@
|
||||
{
|
||||
"totalTime": 2467438200,
|
||||
"moduleNum": 0,
|
||||
"taskTime": {}
|
||||
}
|
39
README.md
39
README.md
@ -1,39 +0,0 @@
|
||||
# NewPhotos
|
||||
|
||||
#### 介绍
|
||||
{**以下是 Gitee 平台说明,您可以替换此简介**
|
||||
Gitee 是 OSCHINA 推出的基于 Git 的代码托管平台(同时支持 SVN)。专为开发者提供稳定、高效、安全的云端软件开发协作平台
|
||||
无论是个人、团队、或是企业,都能够用 Gitee 实现代码托管、项目管理、协作开发。企业项目请看 [https://gitee.com/enterprises](https://gitee.com/enterprises)}
|
||||
|
||||
#### 软件架构
|
||||
软件架构说明
|
||||
|
||||
|
||||
#### 安装教程
|
||||
|
||||
1. xxxx
|
||||
2. xxxx
|
||||
3. xxxx
|
||||
|
||||
#### 使用说明
|
||||
|
||||
1. xxxx
|
||||
2. xxxx
|
||||
3. xxxx
|
||||
|
||||
#### 参与贡献
|
||||
|
||||
1. Fork 本仓库
|
||||
2. 新建 Feat_xxx 分支
|
||||
3. 提交代码
|
||||
4. 新建 Pull Request
|
||||
|
||||
|
||||
#### 特技
|
||||
|
||||
1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md
|
||||
2. Gitee 官方博客 [blog.gitee.com](https://blog.gitee.com)
|
||||
3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解 Gitee 上的优秀开源项目
|
||||
4. [GVP](https://gitee.com/gvp) 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目
|
||||
5. Gitee 官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help)
|
||||
6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)
|
377
README_zh.md
Normal file
377
README_zh.md
Normal file
@ -0,0 +1,377 @@
|
||||
# 图库源码开发说明
|
||||
## 1. 简介
|
||||
图库是系统内置的可视资源访问应用,提供图片和视频的管理、浏览、显示、编辑操作等功能,并支持默认相册和用户相册管理。
|
||||
图库项目采用 TS 语言开发。
|
||||
|
||||
![](./figures/1层逻辑.png)
|
||||
|
||||
|
||||
|
||||
图库整体以 OpenHarmony 既有的 MVVM 的 App 架构设计为基础,向下扩展出一套 MVP(View, Presenter, Model)分层架构(既有的 MVVM 框架整体理解为新扩展的 MVP 框架的 View 层),用于处理图库的业务逻辑与数据管理。
|
||||
|
||||
各层的作用分别如下:
|
||||
|
||||
- 视图层(View):负责更新 UI 显示以及触摸与点击事件的监听。
|
||||
- 展现层(Presenter):负责处理视图层(View)发送的业务逻辑处理请求,并连通 Model 层获取数据。
|
||||
- 模型层(Model):负责处理展现层(Presenter) 中关于数据处理的请求以及返回数据请求结果。
|
||||
|
||||
应用各层中重要类及其功能如下表所示
|
||||
|
||||
| 模块 | 层级 | 类名 | 作用 |
|
||||
| ------ | ------ | ------------------------ | ------------------------------------ |
|
||||
| photos | 视图层 | phone.view.Index | phone图库入口画面的视图层逻辑控制类 |
|
||||
| photos | 视图层 | pad.view.Index | pad图库入口画面的视图层逻辑控制类 |
|
||||
| photos | 视图层 | TimelinePage | 图库图片视图层逻辑控制类 |
|
||||
| photos | 视图层 | AlbumSetPage | 图库相册视图层逻辑控制类 |
|
||||
| photos | 视图层 | PhotoBrowser | 图库大图浏览视图层逻辑控制类 |
|
||||
| photos | 视图层 | PhotoGridPage | 图库宫格视图层逻辑控制类 |
|
||||
| photos | 视图层 | ThirdSelectAlbumSetPage | 图库三方选择相册视图层逻辑控制类 |
|
||||
| photos | 视图层 | ThirdSelectPhotoGridPage | 图库三方选择宫格视图层逻辑控制类 |
|
||||
| photos | 视图层 | ThirdSelectPhotoBrowser | 图库三方选择大图浏览视图层逻辑控制类 |
|
||||
| photos | 展现层 | PhotoDataSource | 图库列大图浏览展现层数据逻辑类 |
|
||||
| photos | 展现层 | TimelineDataSource | 图库日试图展现层数据逻辑类 |
|
||||
| photos | 展现层 | AlbumSetDataSource | 图库相册展现层数据逻辑类 |
|
||||
| photos | 展现层 | MediaDataSource | 图库宫格展现层数据逻辑类 |
|
||||
| photos | 展现层 | TimelineSelectManager | 图库日试图展现层选择逻辑类 |
|
||||
| photos | 展现层 | ThirdSelectManager | 图库三方选择展现层选择逻辑类 |
|
||||
| photos | 展现层 | AlbumSetSelectManager | 图库相册展现层选择逻辑类 |
|
||||
| photos | 展现层 | SelectManager | 图库展现层选择逻辑类 |
|
||||
| photos | 展现层 | BroadCast | 图库展现层消息分发类 |
|
||||
| photos | 模型层 | AlbumInfo | 图库模型层相册信息类 |
|
||||
| photos | 模型层 | MediaItem | 图库模型层媒体信息类 |
|
||||
| photos | 模型层 | Thumbnail | 图库模型层媒体缩略信息类 |
|
||||
|
||||
|
||||
|
||||
## 2. 目录
|
||||
|
||||
```
|
||||
/applications
|
||||
├── src
|
||||
│ └── main
|
||||
│ ├── ets # ets代码目录
|
||||
│ ├── MainAbility
|
||||
│ ├── common # 共同代码目录
|
||||
│ ├── access # 媒体库接口目录
|
||||
│ ├── model # model目录
|
||||
│ ├── browser # 浏览model目录
|
||||
│ ├── album # 相册model目录
|
||||
│ ├── dataObserver # 数据注册model目录
|
||||
│ ├── interface # 接口model目录
|
||||
│ ├── operation # 操作项model目录
|
||||
│ └── photo # 照片model目录
|
||||
│ └── common #共同业务逻辑和实体模型目录
|
||||
│ ├── utils # 共同工具目录
|
||||
│ └── view # 共同视图组件
|
||||
│ ├── actionbar 共同标题栏、底层栏和工具栏组件目录
|
||||
│ ├── dialog 共同对话框目录。
|
||||
│ └── mediaOperation 共同相册选择页目录
|
||||
│ ├── feature # 功能模块目录
|
||||
│ ├── brower # 图库浏览功能目录
|
||||
│ ├── utils # 图库浏览工具目录
|
||||
│ └── view # 图库浏览视图目录
|
||||
│ ├── album # 相册视图目录
|
||||
│ ├── photo # 照片视图目录
|
||||
│ └── photoGrid # 照片宫格目录
|
||||
│ ├── thirdSelect # 第三方选择功能目录
|
||||
│ ├── utils # 第三方选择工具目录
|
||||
│ └── view # 第三方视图目录
|
||||
│ └── timeline # 日视图宫格功能目录
|
||||
│ ├── model # 日视图model目录
|
||||
│ ├── utils # 日试图工具目录
|
||||
│ └── view # 日试图视图目录
|
||||
│ ├── product # 产品模块目录
|
||||
│ ├── pad # pad模块目录
|
||||
│ └── view # pad模块视图目录
|
||||
│ └── phone # phone模块目录
|
||||
│ └── view # phone模块视图目录
|
||||
│ ├── resources # 资源目录
|
||||
│ └── config.json # 项目配置信息
|
||||
```
|
||||
###
|
||||
|
||||
## 3. 基础开发说明
|
||||
### 资源引用
|
||||
#### 定义资源文件
|
||||
- 在 `src/main/resources/`目录下,根据不同的资源类型,定义资源文件。
|
||||
|
||||
```json
|
||||
{
|
||||
"name": "default_background_color",
|
||||
"value": "#F1F3F5"
|
||||
},
|
||||
```
|
||||
#### 引用资源
|
||||
- 在有对应page的ets文件中,可直接通过`$r()`引用。
|
||||
```` JavaScript
|
||||
@Provide backgroundColor: Resource = $r('app.color.default_background_color');
|
||||
````
|
||||
## 4. 典型接口的使用
|
||||
1. 相机启动图库大图浏览
|
||||
|
||||
```
|
||||
this.context.startAbility({
|
||||
bundleName:"com.ohos.photos",
|
||||
abilityName: "com.ohos.photos.MainAbility",
|
||||
parameters: {
|
||||
uri: "photodetail"
|
||||
}
|
||||
}).then((data) => {
|
||||
console.debug('startAbility complete');
|
||||
}).catch((error) => {
|
||||
console.debug(`startAbility failed, error: ${JSON.stringify(error)}`);
|
||||
})
|
||||
```
|
||||
|
||||
2. 三方应用启动图库三方单选
|
||||
|
||||
```
|
||||
let startParmameter = {
|
||||
bundleName:"com.ohos.photos",
|
||||
abilityName: "com.ohos.photos.MainAbility",
|
||||
parameters: {
|
||||
uri: "singleselect"
|
||||
}
|
||||
};
|
||||
this.context.startAbilityForResult(startParmameter).then((result) => {
|
||||
console.info(`startAbilityForResult Promise.resolve is called, result.resultCode = ${JSON.stringify(result)}`)
|
||||
let want = result['want'];
|
||||
console.info(`test select single ${JSON.stringify(want)}`);
|
||||
if (want != null && want != undefined) {
|
||||
let param = want['parameters'];
|
||||
console.info(`test select single ${JSON.stringify(param)}`);
|
||||
if (param != null && param != undefined) {
|
||||
let uri = param['select-item-list'];
|
||||
console.info(`test select single ${uri}`);
|
||||
}
|
||||
}
|
||||
}, (error) => {
|
||||
console.info(`startAbilityForResult Promise.Reject is called, error.code = ${error.code}`)
|
||||
})
|
||||
```
|
||||
|
||||
3. 三方应用启动图库三方多选
|
||||
|
||||
```
|
||||
let startParmameter = {
|
||||
bundleName:"com.ohos.photos",
|
||||
abilityName: "com.ohos.photos.MainAbility",
|
||||
parameters: {
|
||||
uri: "multipleselect"
|
||||
}
|
||||
};
|
||||
this.context.startAbilityForResult(startParmameter).then((v) => {
|
||||
let want = v['want'];
|
||||
console.info(`test select multiple ${want}`);
|
||||
if (want != null && want != undefined) {
|
||||
let param = want['parameters'];
|
||||
console.info(`test select multiple ${param}`);
|
||||
if (param != null && param != undefined) {
|
||||
let uri = param['select-item-list'];
|
||||
console.info(`test select multiple ${uri[0]} ${uri[1]}`);
|
||||
}
|
||||
}
|
||||
}, (error) => {
|
||||
console.debug(`startAbility failed, error: ${JSON.stringify(error)}`);
|
||||
})
|
||||
```
|
||||
|
||||
## 5. 签名打包
|
||||
### 签名
|
||||
#### 签名文件的获取
|
||||
1. 拷贝 OpenHarmony 标准版的 prebuilts\signcenter 目录到操作目录。
|
||||
2. 拷贝图库工程的 signature\photos.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
|
||||
```
|
||||
|
||||
变更根目录读写权限
|
||||
|
||||
```
|
||||
hdc shell "mount -o remount,rw /"
|
||||
```
|
||||
|
||||
将签名好的 hap 包放入设备的 `/system/app` 目录下,并修改hap包的权限。删除和发送文件命令如下:
|
||||
|
||||
```
|
||||
hdc file send 本地路径 /system/app/hap包名称
|
||||
```
|
||||
例:将当前本地目录的 `Photos.hap` 文件放入到 `system/app/Photos.hap` 文件中。
|
||||
```
|
||||
hdc file send Photos.hap /system/app/Photos.hap
|
||||
```
|
||||
> 注意,如果设备不存在 `/system/app` 目录,则需要手动创建该目录并修改权限。
|
||||
> ```
|
||||
> hdc shell
|
||||
> cd system
|
||||
> mkdir app
|
||||
> chmod 777 app
|
||||
> ```
|
||||
> `/system/app` 目录放置系统应用,例如:Photos,SystemUI,Settings 等。
|
||||
>
|
||||
> 但hap包需要在该目录下手动设置权限
|
||||
> ```
|
||||
> chmod 666 hap包名
|
||||
> ```
|
||||
> 此目录应用不用手动安装,系统自动拉起。
|
||||
### 应用运行
|
||||
图库属于系统应用,在将签名的 hap 包放入 `/system/app` 目录后,重启系统,应用会自动拉起。
|
||||
```
|
||||
hdc_std shell "reboot"
|
||||
```
|
||||
> 注意,如果设备之前安装过系统应用,则需要执行如下几条命令清除设备中存储的应用信息才能够在设备重启的时候将我们装入设备的新 hap 包正常拉起。
|
||||
> ```
|
||||
> hdc_std shell "rm /data/* -rf"
|
||||
> hdc_std shell "sync"
|
||||
> hdc_std shell "/system/bin/udevadm trigger"
|
||||
> ```
|
||||
### 应用调试
|
||||
#### log打印
|
||||
- 在程序中添加 log
|
||||
```JS
|
||||
private log: Logger = new Logger('MoudleXXX')
|
||||
|
||||
entry() {
|
||||
let input = 'hello'
|
||||
this.log.info(`entry: ${input}`)
|
||||
}
|
||||
```
|
||||
上述log打印为:
|
||||
|
||||
```
|
||||
Photos_MoudleXXX:entry: hello
|
||||
```
|
||||
|
||||
可以在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 过滤信息
|
||||
```
|
||||
|
||||
例:过滤包含信息 Album的 hilog
|
||||
```
|
||||
hilog | grep Album
|
||||
```
|
||||
## 7. 贡献代码
|
||||
### Fork 代码仓库
|
||||
1. 在码云上打开 photos代码仓库([仓库地址](https://gitee.com/OHOS_STD/applications_photos))。
|
||||
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. 在本地新建 Photos 目录,在 Photos 目录中执行如下命令
|
||||
```
|
||||
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 Request(PR)的方式来为 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)
|
||||
|
||||
|
||||
|
@ -1,10 +1,11 @@
|
||||
{
|
||||
"name": "entry",
|
||||
"version": "1.0.0",
|
||||
"ohos": {
|
||||
"org": "huawei",
|
||||
"buildTool": "hvigor",
|
||||
"directoryLevel": "module"
|
||||
},
|
||||
"dependencies": {}
|
||||
"devDependencies": {},
|
||||
"name": "entry",
|
||||
"ohos": {
|
||||
"org": "huawei",
|
||||
"directoryLevel": "module",
|
||||
"buildTool": "hvigor"
|
||||
},
|
||||
"version": "1.0.0",
|
||||
"dependencies": {}
|
||||
}
|
||||
|
@ -14,10 +14,10 @@
|
||||
*/
|
||||
|
||||
import FormExtension from '@ohos.application.FormExtension';
|
||||
import {Logger} from './common/Logger'
|
||||
import {FormControllerManager} from './controller/FormControllerManager'
|
||||
import {FormController} from './controller/FormController'
|
||||
import {Constants} from './common/Constants'
|
||||
import { Logger } from './common/Logger'
|
||||
import { FormControllerManager } from './controller/FormControllerManager'
|
||||
import { FormController } from './controller/FormController'
|
||||
import { Constants } from './common/Constants'
|
||||
|
||||
export default class FormAbility extends FormExtension {
|
||||
private logger: Logger = new Logger('FormAbility');
|
||||
@ -72,7 +72,7 @@ export default class FormAbility extends FormExtension {
|
||||
|
||||
onDestroy(formId) {
|
||||
this.logger.info(`onDestroy, formId: ${formId}`);
|
||||
let formControllerManager: FormControllerManager = FormControllerManager.getInstance(this.context);
|
||||
let formControllerManager: FormControllerManager = FormControllerManager.getInstance(this.context);
|
||||
formControllerManager.destroyController(formId);
|
||||
}
|
||||
};
|
@ -39,7 +39,7 @@ export class Constants {
|
||||
static readonly NUMBER_12: number = 12;
|
||||
static readonly NUMBER_24: number = 24;
|
||||
static readonly FROM_PLAYBACK_INTERVAL = 'form_playback_interval';
|
||||
static readonly PHOTOS_FORM_DEFAULT_PERIOD = 30;
|
||||
static readonly PHOTOS_FORM_DEFAULT_PERIOD = 30;
|
||||
static readonly SELECT_ALBUM: string = 'selectAlbum';
|
||||
static readonly SELECT_PHOTO: string = 'selectPhoto';
|
||||
}
|
@ -13,7 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {Logger as RootLogger} from '../../common/utils/Logger'
|
||||
import { Logger as RootLogger } from '../../common/utils/Logger'
|
||||
|
||||
const MODULE_ALBUM = 'Form_';
|
||||
|
@ -13,14 +13,14 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {MediaDataManager} from '../data/MediaDataManager'
|
||||
import {Logger} from '../common/Logger'
|
||||
import { MediaDataManager } from '../data/MediaDataManager'
|
||||
import { Logger } from '../common/Logger'
|
||||
import formBindingData from '@ohos.application.formBindingData';
|
||||
import {Constants} from '../common/Constants'
|
||||
import {DataStoreUtil} from '../../common/utils/DataStoreUtil'
|
||||
import { Constants } from '../common/Constants'
|
||||
import { DataStoreUtil } from '../../common/utils/DataStoreUtil'
|
||||
import formProvider from '@ohos.application.formProvider';
|
||||
import {MediaLibraryAccess} from '../../common/access/MediaLibraryAccess'
|
||||
import {Constants as commonConstants} from '../../common/model/common/Constants'
|
||||
import { MediaLibraryAccess } from '../../common/access/MediaLibraryAccess'
|
||||
import { Constants as commonConstants } from '../../common/model/common/Constants'
|
||||
|
||||
export class FormController {
|
||||
private context: any;
|
||||
@ -46,21 +46,21 @@ export class FormController {
|
||||
let dataObj1: any;
|
||||
if (image == "image0") {
|
||||
dataObj1 = {
|
||||
"fd": fd==-1? false: true,
|
||||
"fd": fd == -1 ? false : true,
|
||||
"image1": "memory://image" + this.mediaDataManager.getMediaData().arkUri,
|
||||
"albumName": this.mediaDataManager.getCurrentAlbumName(),
|
||||
"currentIndex": this.mediaDataManager.getCurrentIndex(),
|
||||
"isShow": this.mediaDataManager.getIsShowAlbumName(),
|
||||
"formImages": {"image0": fd}
|
||||
"formImages": { "image0": fd }
|
||||
};
|
||||
} else {
|
||||
dataObj1 = {
|
||||
"fd": fd==-1? false: true,
|
||||
"fd": fd == -1 ? false : true,
|
||||
"image1": "memory://image" + this.mediaDataManager.getMediaData().arkUri,
|
||||
"albumName": this.mediaDataManager.getCurrentAlbumName(),
|
||||
"currentIndex": this.mediaDataManager.getCurrentIndex(),
|
||||
"isShow": this.mediaDataManager.getIsShowAlbumName(),
|
||||
"formImages": {"image1": fd}
|
||||
"formImages": { "image1": fd }
|
||||
};
|
||||
}
|
||||
this.logger.debug(`bindFormData, createFormBindingData dataObj2.data: ${JSON.stringify(dataObj1)}`);
|
||||
@ -93,10 +93,11 @@ export class FormController {
|
||||
this.onDestroy();
|
||||
}
|
||||
}).catch((error) => {
|
||||
this.logger.error(`updateForm failed. Cause: ${JSON.stringify(error)}`);
|
||||
this.mediaDataManager.closeFd();
|
||||
});
|
||||
this.logger.error(`updateForm failed. Cause: ${JSON.stringify(error)}`);
|
||||
this.mediaDataManager.closeFd();
|
||||
});
|
||||
}
|
||||
|
||||
onDestroy() {
|
||||
this.logger.info('onDestroy start!');
|
||||
this.mediaDataManager.closeFd();
|
||||
@ -105,6 +106,7 @@ export class FormController {
|
||||
this.callback = null;
|
||||
this.logger.info('onDestroy done end!');
|
||||
}
|
||||
|
||||
onUpdateFormData(formId: string): void {
|
||||
this.logger.debug(`onUpdateFormData formId: ${formId}`);
|
||||
this.mediaDataManager.setNextIndex();
|
||||
@ -116,7 +118,9 @@ export class FormController {
|
||||
'bundleName': 'com.ohos.photos',
|
||||
'abilityName': 'com.ohos.photos.MainAbility',
|
||||
'parameters': {
|
||||
'uri': (this.mediaDataManager.getMediaData().currentUri != '')? commonConstants.ACTION_URI_FORM_ABILITY : commonConstants.ACTION_URI_FORM_ABILITY_NONE,
|
||||
'uri': (
|
||||
this.mediaDataManager.getMediaData()
|
||||
.currentUri != '') ? commonConstants.ACTION_URI_FORM_ABILITY : commonConstants.ACTION_URI_FORM_ABILITY_NONE,
|
||||
'albumId': `${this.mediaDataManager.getMediaData().albumId}`,
|
||||
'currentIndex': this.mediaDataManager.getMediaData().currentIndex
|
||||
}
|
||||
@ -141,7 +145,7 @@ export class FormController {
|
||||
}
|
||||
}
|
||||
|
||||
onEvent(formId: string):void {
|
||||
onEvent(formId: string): void {
|
||||
this.logger.debug('onEvent start!');
|
||||
if (this.callback != null) {
|
||||
if (this.mediaDataManager.getUpdateTag()) {
|
||||
@ -149,13 +153,12 @@ export class FormController {
|
||||
this.logger.debug(`updateFormData formId: ${JSON.stringify(formId)}`);
|
||||
let obj3 = this.bindFormData(formId);
|
||||
this.logger.debug(`updateFormData obj: ${JSON.stringify(obj3)}`);
|
||||
formProvider.updateForm(formId, obj3)
|
||||
.then((data) => {
|
||||
this.logger.info(`updateFormData, data: ${JSON.stringify(data)}`);
|
||||
this.onTriggerFormEvent(formId, this.callback.call(this.callback));
|
||||
}).catch((error) => {
|
||||
this.onTriggerFormEvent(formId, this.callback.call(this.callback));
|
||||
});
|
||||
formProvider.updateForm(formId, obj3).then((data) => {
|
||||
this.logger.info(`updateFormData, data: ${JSON.stringify(data)}`);
|
||||
this.onTriggerFormEvent(formId, this.callback.call(this.callback));
|
||||
}).catch((error) => {
|
||||
this.onTriggerFormEvent(formId, this.callback.call(this.callback));
|
||||
});
|
||||
} else {
|
||||
this.onTriggerFormEvent(formId, this.callback.call(this.callback));
|
||||
}
|
||||
@ -163,7 +166,7 @@ export class FormController {
|
||||
this.logger.debug('onEvent end!');
|
||||
}
|
||||
|
||||
onCallback():void {
|
||||
onCallback(): void {
|
||||
this.logger.debug('onCallback start!');
|
||||
if (this.callback != null) {
|
||||
this.callback.call(this.callback);
|
@ -12,12 +12,10 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import {Constants} from '../common/Constants'
|
||||
import {FormController} from './FormController'
|
||||
import {Logger} from '../common/Logger'
|
||||
import {DataStoreUtil} from '../../common/utils/DataStoreUtil'
|
||||
import abilityAccessCtrl from '@ohos.abilityAccessCtrl'
|
||||
import bundle from '@ohos.bundle'
|
||||
import { Constants } from '../common/Constants'
|
||||
import { FormController } from './FormController'
|
||||
import { Logger } from '../common/Logger'
|
||||
import { DataStoreUtil } from '../../common/utils/DataStoreUtil'
|
||||
|
||||
export class FormControllerManager {
|
||||
private context: any;
|
||||
@ -98,7 +96,6 @@ export class FormControllerManager {
|
||||
return controller;
|
||||
}
|
||||
|
||||
|
||||
public deleteFormController(formId: string): void {
|
||||
this.logger.debug('deleteFormController start!')
|
||||
if (this.formControllerMap.has(formId)) {
|
@ -18,14 +18,14 @@ export class MediaData {
|
||||
albumId: string = '';
|
||||
displayName: string = '';
|
||||
currentUri: string = '';
|
||||
currentIndex:number = 0;
|
||||
currentIndex: number = 0;
|
||||
intervalTime: number = 0;
|
||||
//数据持久化保存布尔型目前存在问题,使用数字类型保存。
|
||||
isShowAlbumName: number = 0;
|
||||
arkUri: number = 0;
|
||||
|
||||
constructor(formId: string, displayName: string, albumName: string,
|
||||
albumId: string, currentUri: string,currentIndex: number,
|
||||
albumId: string, currentUri: string, currentIndex: number,
|
||||
intervalTime: number, isShowAlbumName: number, arkUri: number) {
|
||||
this.formId = formId;
|
||||
this.albumId = albumId;
|
@ -1,3 +1,4 @@
|
||||
// @ts-nocheck
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@ -12,12 +13,12 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import {MediaData} from './MediaData'
|
||||
import {Constants} from '../common/Constants'
|
||||
import {Logger} from '../common/Logger'
|
||||
import {AlbumDefine} from '../../common/model/browser/AlbumDefine'
|
||||
import {DataStoreUtil} from '../../common/utils/DataStoreUtil'
|
||||
import {MediaLibraryAccess} from '../../common/access/MediaLibraryAccess'
|
||||
import { MediaData } from './MediaData'
|
||||
import { Constants } from '../common/Constants'
|
||||
import { Logger } from '../common/Logger'
|
||||
import { AlbumDefine } from '../../common/model/browser/AlbumDefine'
|
||||
import { DataStoreUtil } from '../../common/utils/DataStoreUtil'
|
||||
import { MediaLibraryAccess } from '../../common/access/MediaLibraryAccess'
|
||||
import resourceManager from '@ohos.resourceManager';
|
||||
|
||||
export class MediaDataManager {
|
||||
@ -29,7 +30,7 @@ export class MediaDataManager {
|
||||
private fd: number = -1;
|
||||
private key: string = '';
|
||||
private operationMode: number = Constants.PHOTOS_FORM_OPERATION_MODE_NONE;
|
||||
private context:any;
|
||||
private context: any;
|
||||
private isNextFag: boolean = true;
|
||||
private isUpdate: boolean = false;
|
||||
|
||||
@ -118,7 +119,7 @@ export class MediaDataManager {
|
||||
|
||||
operationFormController() {
|
||||
this.logger.debug(`operFormControllerOper operationMode ${this.operationMode}`);
|
||||
switch (this.operationMode){
|
||||
switch (this.operationMode) {
|
||||
case Constants.PHOTOS_FORM_OPERATION_MODE_DESTROY:
|
||||
this.operationMode = Constants.PHOTOS_FORM_OPERATION_MODE_NONE;
|
||||
this.formController.onDeleteForm(this.mediaData.formId);
|
||||
@ -258,7 +259,7 @@ export class MediaDataManager {
|
||||
this.logger.debug('storageDelete end!');
|
||||
}
|
||||
|
||||
setMediaData(displayName:string, albumName: string, currentUri: string, intervalTime: number) {
|
||||
setMediaData(displayName: string, albumName: string, currentUri: string, intervalTime: number) {
|
||||
this.logger.debug('setAlbumNameAndUri start!');
|
||||
if (this.mediaData != null) {
|
||||
this.mediaData.currentUri = currentUri;
|
||||
@ -304,6 +305,7 @@ export class MediaDataManager {
|
||||
this.mediaData.currentIndex = 0;
|
||||
this.logger.debug('filterOutVideoMediaData end!');
|
||||
}
|
||||
|
||||
updateMediaData() {
|
||||
this.logger.debug('updateMediaData start! index ${this.mediaData.currentIndex}');
|
||||
if (this.mediaData.currentIndex == -1) {
|
||||
@ -322,18 +324,18 @@ export class MediaDataManager {
|
||||
}
|
||||
}
|
||||
if (!isExist) {
|
||||
if ((this.items.length !=0) && (this.mediaData.currentIndex < this.items.length)) {
|
||||
if ((this.items.length != 0) && (this.mediaData.currentIndex < this.items.length)) {
|
||||
this.mediaData.currentUri = this.items[this.mediaData.currentIndex].uri;
|
||||
this.isUpdate = true;
|
||||
}
|
||||
if ((this.items.length == 0) || (this.mediaData.isShowAlbumName == 0)) {
|
||||
if ((this.items.length == 0) || (this.mediaData.isShowAlbumName == 0)) {
|
||||
this.mediaData.currentUri = '';
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ((this.items.length !=0) &&
|
||||
(this.mediaData.currentIndex < this.items.length) &&
|
||||
(this.mediaData.isShowAlbumName != 0)) {
|
||||
if ((this.items.length != 0) &&
|
||||
(this.mediaData.currentIndex < this.items.length) &&
|
||||
(this.mediaData.isShowAlbumName != 0)) {
|
||||
this.mediaData.currentUri = this.items[this.mediaData.currentIndex].uri;
|
||||
}
|
||||
}
|
||||
@ -350,7 +352,7 @@ export class MediaDataManager {
|
||||
|
||||
getCurrentItem(): any {
|
||||
if ((this.mediaData.currentIndex < this.items.length) &&
|
||||
(this.mediaData.currentUri != '')) {
|
||||
(this.mediaData.currentUri != '')) {
|
||||
return this.items[this.mediaData.currentIndex];
|
||||
} else {
|
||||
return null;
|
||||
@ -366,7 +368,7 @@ export class MediaDataManager {
|
||||
}
|
||||
|
||||
getIsShowAlbumName(): boolean {
|
||||
return this.mediaData.isShowAlbumName == 1? true: false;
|
||||
return this.mediaData.isShowAlbumName == 1 ? true : false;
|
||||
}
|
||||
|
||||
getIntervalTime(): number {
|
||||
@ -402,7 +404,7 @@ export class MediaDataManager {
|
||||
async openCurrentFd(): Promise<number> {
|
||||
let fileAsset = this.getCurrentItem();
|
||||
this.logger.info(`openCurrentFd uri: ${this.mediaData.currentUri}`);
|
||||
let fd = (fileAsset != null) ? await MediaLibraryAccess.getInstance().openAsset('R', fileAsset): -1;
|
||||
let fd = (fileAsset != null) ? await MediaLibraryAccess.getInstance().openAsset('R', fileAsset) : -1;
|
||||
this.logger.info(`openCurrentFd the fd: ${fd}`);
|
||||
return fd;
|
||||
}
|
||||
@ -431,10 +433,10 @@ export class MediaDataManager {
|
||||
this.logger.debug('loadData end!');
|
||||
}
|
||||
|
||||
async getItems(albumId: string, startIndex?: number, count?:number, deviceId?) {
|
||||
async getItems(albumId: string, startIndex?: number, count?: number, deviceId?) {
|
||||
this.logger.info('getItems start!');
|
||||
let fetchOpt = AlbumDefine.getFileFetchOpt(albumId, deviceId, startIndex, count);
|
||||
switch (albumId){
|
||||
switch (albumId) {
|
||||
case AlbumDefine.ALBUM_ID_ALL:
|
||||
let allObject = await MediaLibraryAccess.getInstance().getAllObject(fetchOpt);
|
||||
return allObject;
|
@ -15,23 +15,24 @@
|
||||
|
||||
import Ability from '@ohos.application.Ability'
|
||||
import wantConstant from '@ohos.ability.wantConstant'
|
||||
import {Logger} from '../common/utils/Logger'
|
||||
import {ScreenManager} from '../common/model/common/ScreenManager'
|
||||
import {PixelMapManager} from '../common/model/common/PixelMapManager'
|
||||
import {StatusBarColorController} from '../common/model/common/StatusBarColorController'
|
||||
import {MediaLibraryAccess} from '../common/access/MediaLibraryAccess'
|
||||
import {TimelineDataSourceManager} from '../feature/timeline/model/TimelineDataSourceManager'
|
||||
import {Constants} from '../common/model/common/Constants'
|
||||
import {MediaDataSource} from '../common/model/browser/photo/MediaDataSource'
|
||||
import {BroadCastManager} from '../common/model/common/BroadCastManager';
|
||||
import {TraceControllerUtils} from '../common/utils/TraceControllerUtils';
|
||||
import {BroadCastConstants} from '../common/model/common/BroadCastConstants'
|
||||
import { Logger } from '../common/utils/Logger'
|
||||
import { ScreenManager } from '../common/model/common/ScreenManager'
|
||||
import { PixelMapManager } from '../common/model/common/PixelMapManager'
|
||||
import { StatusBarColorController } from '../common/model/common/StatusBarColorController'
|
||||
import { MediaLibraryAccess } from '../common/access/MediaLibraryAccess'
|
||||
import { TimelineDataSourceManager } from '../feature/timeline/model/TimelineDataSourceManager'
|
||||
import { Constants } from '../common/model/common/Constants'
|
||||
import { MediaDataSource } from '../common/model/browser/photo/MediaDataSource'
|
||||
import { BroadCastManager } from '../common/model/common/BroadCastManager';
|
||||
import { TraceControllerUtils } from '../common/utils/TraceControllerUtils';
|
||||
import { BroadCastConstants } from '../common/model/common/BroadCastConstants'
|
||||
import router from '@system.router'
|
||||
|
||||
const appLogger: Logger = new Logger('app');
|
||||
let isFromCard = false;
|
||||
let isFromCamera = false;
|
||||
let appBroadCast = BroadCastManager.getInstance().getBroadCast();
|
||||
|
||||
export default class MainAbility extends Ability {
|
||||
private static readonly RETRY_MAX_TIMES = 100;
|
||||
private static readonly ACTION_URI_SINGLE_SELECT = 'singleselect';
|
||||
@ -58,7 +59,7 @@ export default class MainAbility extends Ability {
|
||||
AppStorage.SetOrCreate(Constants.FROM_CURRENT_INDEX, action.currentIndex);
|
||||
} else if (action != null && action != undefined && action.uri == Constants.ACTION_URI_FORM_ABILITY_NONE) {
|
||||
AppStorage.SetOrCreate(Constants.ENTRY_FROM_HAP, Constants.ENTRY_FROM_FORM_ABILITY_NONE);
|
||||
} else if (action != null && action != undefined && action['formId'] != null) {
|
||||
} else if (action != null && action != undefined && action['formId'] != null) {
|
||||
AppStorage.SetOrCreate(Constants.FA_SETTING_FROM_ID, action['formId']);
|
||||
AppStorage.SetOrCreate(Constants.ENTRY_FROM_HAP, Constants.ENTRY_FROM_FORM_FORM_EDITOR);
|
||||
} else if (want.action == wantConstant.Action.ACTION_VIEW_DATA) {
|
||||
@ -99,6 +100,7 @@ export default class MainAbility extends Ability {
|
||||
}, (err) => {
|
||||
appLogger.error(`Failed to requestPermissionsFromUser, ${err.code}`);
|
||||
});
|
||||
|
||||
appBroadCast.on(BroadCastConstants.THIRD_ROUTE_PAGE, this.thirdRouterPage.bind(this));
|
||||
appLogger.info('Application onCreate end');
|
||||
}
|
||||
@ -118,7 +120,7 @@ export default class MainAbility extends Ability {
|
||||
AppStorage.SetOrCreate(Constants.FROM_CURRENT_INDEX, action.currentIndex);
|
||||
} else if (action != null && action != undefined && action.uri == Constants.ACTION_URI_FORM_ABILITY_NONE) {
|
||||
AppStorage.SetOrCreate(Constants.ENTRY_FROM_HAP, Constants.ENTRY_FROM_FORM_ABILITY_NONE);
|
||||
} else if (action != null && action != undefined && action['formId'] != null) {
|
||||
} else if (action != null && action != undefined && action['formId'] != null) {
|
||||
AppStorage.SetOrCreate(Constants.FA_SETTING_FROM_ID, action['formId']);
|
||||
AppStorage.SetOrCreate(Constants.ENTRY_FROM_HAP, Constants.ENTRY_FROM_FORM_FORM_EDITOR);
|
||||
} else if (want.action == wantConstant.Action.ACTION_VIEW_DATA) {
|
||||
|
@ -1,3 +1,4 @@
|
||||
// @ts-nocheck
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@ -13,20 +14,17 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {Logger} from '../utils/Logger'
|
||||
import { Logger } from '../utils/Logger'
|
||||
import MediaLib from '@ohos.multimedia.mediaLibrary';
|
||||
import {Constants} from '../model/common/Constants'
|
||||
import { Constants } from '../model/common/Constants'
|
||||
import { TraceControllerUtils } from '../utils/TraceControllerUtils';
|
||||
|
||||
export class MediaLibraryAccess {
|
||||
private logger: Logger = new Logger('MediaLibraryAccess');
|
||||
|
||||
static readonly MEDIA_TYPE_IMAGE = MediaLib.MediaType.IMAGE;
|
||||
static readonly MEDIA_TYPE_VIDEO = MediaLib.MediaType.VIDEO;
|
||||
|
||||
static readonly DIRECTORY_TYPE_IMAGE = MediaLib.DirectoryType.DIR_IMAGE;
|
||||
static readonly DIRECTORY_TYPE_CAMERA = MediaLib.DirectoryType.DIR_CAMERA;
|
||||
|
||||
static readonly FILE_KEY_ID = MediaLib.FileKey.ID;
|
||||
static readonly FILE_KEY_MEDIA_TYPE = MediaLib.FileKey.MEDIA_TYPE;
|
||||
static readonly FILE_KEY_ALBUM_NAME = MediaLib.FileKey.ALBUM_NAME;
|
||||
@ -34,11 +32,10 @@ export class MediaLibraryAccess {
|
||||
static readonly FILE_KEY_DISPLAY_NAME = MediaLib.FileKey.DISPLAY_NAME;
|
||||
static readonly FILE_KEY_RELATIVE_PATH = MediaLib.FileKey.RELATIVE_PATH;
|
||||
static readonly FILE_KEY_DATE_TAKEN = MediaLib.FileKey.DATE_ADDED; // TODO dateTaken is not supported, use dateAdded
|
||||
static readonly FILE_KEY_DATE_TRASHED = 'date_trashed' //TODO dataTrashed is not define in FileKey
|
||||
static readonly FILE_KEY_DATE_TRASHED = 'date_trashed' //TODO dataTrashed is not define in FileKey
|
||||
|
||||
PUBLIC_PATH_IMAGE = '';
|
||||
PUBLIC_PATH_CAMERA = '';
|
||||
|
||||
private media = null;
|
||||
private requestTime: number;
|
||||
|
||||
@ -83,7 +80,6 @@ export class MediaLibraryAccess {
|
||||
return this.media;
|
||||
}
|
||||
|
||||
|
||||
async getAllObject(fetchOpt) {
|
||||
this.logger.info(`getAllObject: ${JSON.stringify(fetchOpt)}`);
|
||||
try {
|
||||
@ -121,7 +117,7 @@ export class MediaLibraryAccess {
|
||||
let result = dataList.getCount();
|
||||
dataList.close();
|
||||
TraceControllerUtils.finishTraceWithTaskId('getCount', this.requestTime);
|
||||
return result ;
|
||||
return result;
|
||||
} catch (error) {
|
||||
this.logger.error(`get Count error: ${error}`);
|
||||
return 0;
|
||||
@ -160,16 +156,16 @@ export class MediaLibraryAccess {
|
||||
}
|
||||
}
|
||||
|
||||
async deleteAsset(uri: string){
|
||||
async deleteAsset(uri: string) {
|
||||
this.logger.debug(`deleteAsset uri: ${uri}`);
|
||||
await this.media.deleteAsset(uri);
|
||||
}
|
||||
|
||||
async getPublicDirectory() {
|
||||
this.PUBLIC_PATH_IMAGE =
|
||||
await this.media.getPublicDirectory(MediaLibraryAccess.DIRECTORY_TYPE_IMAGE);
|
||||
await this.media.getPublicDirectory(MediaLibraryAccess.DIRECTORY_TYPE_IMAGE);
|
||||
this.PUBLIC_PATH_CAMERA =
|
||||
await this.media.getPublicDirectory(MediaLibraryAccess.DIRECTORY_TYPE_CAMERA);
|
||||
await this.media.getPublicDirectory(MediaLibraryAccess.DIRECTORY_TYPE_CAMERA);
|
||||
}
|
||||
|
||||
async createAsset(mediaType: any, displayName: string, relativePath: string) {
|
||||
@ -220,7 +216,7 @@ export class MediaLibraryAccess {
|
||||
this.logger.debug(`[getFavoriteObject] objects done`);
|
||||
fileResult.close();
|
||||
return objects;
|
||||
} catch(err) {
|
||||
} catch (err) {
|
||||
this.logger.error(`Get favorite object exception! msg: ${err}`);
|
||||
return [];
|
||||
}
|
||||
@ -237,7 +233,7 @@ export class MediaLibraryAccess {
|
||||
this.logger.debug(`[getTrashObject] get objects done`);
|
||||
fileResult.close();
|
||||
return objects;
|
||||
} catch(err) {
|
||||
} catch (err) {
|
||||
this.logger.error(`Get Trash Object exception! msg: ${err}`);
|
||||
return [];
|
||||
}
|
||||
@ -262,7 +258,7 @@ export class MediaLibraryAccess {
|
||||
this.logger.debug(`[getEntityAlbumObject]Get objects done`);
|
||||
fileResult.close();
|
||||
return objects;
|
||||
} catch(err) {
|
||||
} catch (err) {
|
||||
this.logger.error(`Get Entity Album Object exception! msg: ${err}`);
|
||||
return []
|
||||
}
|
||||
@ -283,7 +279,7 @@ export class MediaLibraryAccess {
|
||||
let count = fileResult.getCount();
|
||||
fileResult.close();
|
||||
return count;
|
||||
} catch(err) {
|
||||
} catch (err) {
|
||||
this.logger.error(`Get Favorite count exception! msg: ${err}`);
|
||||
return 0;
|
||||
}
|
||||
@ -297,14 +293,14 @@ export class MediaLibraryAccess {
|
||||
order: ''
|
||||
}
|
||||
try {
|
||||
let albums = await this.media.getPrivateAlbum(MediaLib.PrivateAlbumType.TYPE_TRASH);
|
||||
this.logger.debug(`[getTrashCount]Get smart Albums length:${albums.length} name:${albums[0].albumName}`);
|
||||
let fileResult = await albums[0].getFileAssets(fetchOpt);
|
||||
this.logger.debug(`[getTrashCount]Get objects done`);
|
||||
let count = fileResult.getCount();
|
||||
fileResult.close();
|
||||
return count;
|
||||
} catch(err) {
|
||||
let albums = await this.media.getPrivateAlbum(MediaLib.PrivateAlbumType.TYPE_TRASH);
|
||||
this.logger.debug(`[getTrashCount]Get smart Albums length:${albums.length} name:${albums[0].albumName}`);
|
||||
let fileResult = await albums[0].getFileAssets(fetchOpt);
|
||||
this.logger.debug(`[getTrashCount]Get objects done`);
|
||||
let count = fileResult.getCount();
|
||||
fileResult.close();
|
||||
return count;
|
||||
} catch (err) {
|
||||
this.logger.error(`Get Trash count exception! msg: ${err}`);
|
||||
return 0;
|
||||
}
|
||||
@ -330,7 +326,7 @@ export class MediaLibraryAccess {
|
||||
let count = fileResult.getCount();
|
||||
fileResult.close();
|
||||
return count;
|
||||
} catch(err) {
|
||||
} catch (err) {
|
||||
this.logger.error(`Get Entity Album count exception! msg: ${err}`);
|
||||
return 0;
|
||||
}
|
||||
@ -343,7 +339,7 @@ export class MediaLibraryAccess {
|
||||
this.logger.debug(`[getAlbums]Get Albums done`);
|
||||
this.logger.debug(`[getAlbums]length :${albums.length}`);
|
||||
return albums;
|
||||
} catch(err) {
|
||||
} catch (err) {
|
||||
this.logger.error(`Get Album exception! msg: ${err}`);
|
||||
return [];
|
||||
}
|
||||
@ -369,7 +365,7 @@ export class MediaLibraryAccess {
|
||||
fileResult.close();
|
||||
}
|
||||
return result;
|
||||
} catch(err) {
|
||||
} catch (err) {
|
||||
this.logger.error(`Get Favorite album exception! msg: ${err}`);
|
||||
return result;
|
||||
}
|
||||
@ -395,7 +391,7 @@ export class MediaLibraryAccess {
|
||||
fileResult.close();
|
||||
}
|
||||
return result;
|
||||
} catch(err) {
|
||||
} catch (err) {
|
||||
this.logger.error(`Get Trash album exception! msg: ${err}`);
|
||||
return result;
|
||||
}
|
||||
@ -407,9 +403,9 @@ export class MediaLibraryAccess {
|
||||
let result = await this.media.getActivePeers();
|
||||
this.logger.debug(`[getConnectedRemoteDevice]device count: ${result.length}`);
|
||||
return result;
|
||||
} catch(err) {
|
||||
} catch (err) {
|
||||
this.logger.error(`Get Connected Remote Device exception! msg: ${err}`);
|
||||
return[];
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -418,11 +414,11 @@ export class FetchOptionBuilder {
|
||||
private fetchOption = {
|
||||
selections: '',
|
||||
selectionArgs: [],
|
||||
order:''
|
||||
order: ''
|
||||
}
|
||||
|
||||
constructor(fetchOpt?){
|
||||
if (fetchOpt){
|
||||
constructor(fetchOpt?) {
|
||||
if (fetchOpt) {
|
||||
this.fetchOption = fetchOpt;
|
||||
}
|
||||
}
|
||||
@ -431,76 +427,76 @@ export class FetchOptionBuilder {
|
||||
return this.fetchOption;
|
||||
}
|
||||
|
||||
media(mediaType: string){
|
||||
media(mediaType: string) {
|
||||
this.fetchOption.selections = `${this.prefix(this.fetchOption.selections)}${MediaLibraryAccess.FILE_KEY_MEDIA_TYPE} =?`;
|
||||
this.fetchOption.selectionArgs.push(mediaType);
|
||||
return this;
|
||||
}
|
||||
|
||||
order(key:string, isAsc = true){
|
||||
order(key: string, isAsc = true) {
|
||||
let order = isAsc ? '' : ' DESC';
|
||||
this.fetchOption.order = `${this.prefix(this.fetchOption.order)}${key}${order}`;
|
||||
return this;
|
||||
}
|
||||
|
||||
select(start: number, count: number){
|
||||
select(start: number, count: number) {
|
||||
this.fetchOption.order = `${this.prefix(this.fetchOption.order)}LIMIT ${start},${count}`
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
device(deviceId: string){
|
||||
device(deviceId: string) {
|
||||
this.fetchOption['networkId'] = deviceId;
|
||||
return this;
|
||||
}
|
||||
|
||||
fileId(id: string){
|
||||
fileId(id: string) {
|
||||
this.fetchOption.selections = `${this.prefix(this.fetchOption.selections)}${MediaLibraryAccess.FILE_KEY_ID} =?`;
|
||||
this.fetchOption.selectionArgs.push(id);
|
||||
return this;
|
||||
}
|
||||
|
||||
albumId(id: string){
|
||||
albumId(id: string) {
|
||||
this.fetchOption.selections = `${this.prefix(this.fetchOption.selections)}${MediaLibraryAccess.FILE_KEY_ALBUM_ID} =?`;
|
||||
this.fetchOption.selectionArgs.push(id);
|
||||
return this;
|
||||
}
|
||||
|
||||
relativePath(path: string){
|
||||
relativePath(path: string) {
|
||||
this.fetchOption.selections = `${this.prefix(this.fetchOption.selections)}${MediaLibraryAccess.FILE_KEY_RELATIVE_PATH} =?`;
|
||||
this.fetchOption.selectionArgs.push(path);
|
||||
return this;
|
||||
}
|
||||
|
||||
albumName(name: string){
|
||||
albumName(name: string) {
|
||||
this.fetchOption.selections = `${this.prefix(this.fetchOption.selections)}${MediaLibraryAccess.FILE_KEY_ALBUM_NAME} =?`;
|
||||
this.fetchOption.selectionArgs.push(name);
|
||||
return this;
|
||||
}
|
||||
|
||||
displayName(name: string){
|
||||
displayName(name: string) {
|
||||
this.fetchOption.selections = `${this.prefix(this.fetchOption.selections)}${MediaLibraryAccess.FILE_KEY_DISPLAY_NAME} =?`;
|
||||
this.fetchOption.selectionArgs.push(name);
|
||||
return this;
|
||||
}
|
||||
|
||||
logicalAnd(){
|
||||
logicalAnd() {
|
||||
this.fetchOption.selections = `${this.prefix(this.fetchOption.selections)}AND`;
|
||||
return this;
|
||||
}
|
||||
|
||||
logicalOr(){
|
||||
logicalOr() {
|
||||
this.fetchOption.selections = `${this.prefix(this.fetchOption.selections)}OR`;
|
||||
return this;
|
||||
}
|
||||
|
||||
parentheses(){
|
||||
parentheses() {
|
||||
this.fetchOption.selections = `(${this.fetchOption.selections})`
|
||||
return this;
|
||||
}
|
||||
|
||||
private prefix(str: string){
|
||||
if (str.length > 0){
|
||||
private prefix(str: string) {
|
||||
if (str.length > 0) {
|
||||
return `${str} `;
|
||||
}
|
||||
return str;
|
@ -17,7 +17,7 @@ import { TimelineDataImpl } from '../model/browser/photo/TimelineDataImpl';
|
||||
import { PhotoDataImpl } from '../model/browser/photo/PhotoDataImpl';
|
||||
import { AlbumDataImpl } from '../model/browser/album/AlbumDataImpl';
|
||||
import { DistributedDataImpl } from '../model/browser/album/DistributedDataImpl'
|
||||
import {BrowserDataInterface} from './BrowserDataInterface'
|
||||
import { BrowserDataInterface } from './BrowserDataInterface'
|
||||
|
||||
export class BrowserDataFactory {
|
||||
static readonly TYPE_PHOTO = 'photo';
|
||||
@ -25,14 +25,14 @@ export class BrowserDataFactory {
|
||||
static readonly TYPE_GROUP = 'group';
|
||||
static readonly TYPE_DISTRIBUTED = 'distributed';
|
||||
|
||||
static getFeature(type: string, param? : any): BrowserDataInterface {
|
||||
static getFeature(type: string, param?: any): BrowserDataInterface {
|
||||
if (type == BrowserDataFactory.TYPE_ALBUM) {
|
||||
return new AlbumDataImpl(param);
|
||||
}else if (type == BrowserDataFactory.TYPE_PHOTO) {
|
||||
} else if (type == BrowserDataFactory.TYPE_PHOTO) {
|
||||
return new PhotoDataImpl();
|
||||
}else if (type == BrowserDataFactory.TYPE_GROUP) {
|
||||
} else if (type == BrowserDataFactory.TYPE_GROUP) {
|
||||
return new TimelineDataImpl();
|
||||
}else if (type == BrowserDataFactory.TYPE_DISTRIBUTED) {
|
||||
} else if (type == BrowserDataFactory.TYPE_DISTRIBUTED) {
|
||||
return new DistributedDataImpl();
|
||||
}
|
||||
}
|
@ -14,8 +14,11 @@
|
||||
*/
|
||||
|
||||
export interface BrowserDataInterface {
|
||||
getData(callback:any, param:any): void;
|
||||
getDataCount(callback:any, param:any): void;
|
||||
getDataById(id: any, deviceId? :any): any;
|
||||
getData(callback: any, param: any): void;
|
||||
|
||||
getDataCount(callback: any, param: any): void;
|
||||
|
||||
getDataById(id: any, deviceId?: any): any;
|
||||
|
||||
getDataByName(name: string, albumInfo: any): any;
|
||||
}
|
@ -13,8 +13,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { OperationImpl } from '../model/browser/photo/OperationImpl'
|
||||
import {AlbumOperationImpl} from '../model/browser/album/AlbumOperationImpl'
|
||||
import {BrowserOperationInterface} from './BrowserOperationInterface'
|
||||
import { AlbumOperationImpl } from '../model/browser/album/AlbumOperationImpl'
|
||||
import { BrowserOperationInterface } from './BrowserOperationInterface'
|
||||
|
||||
export class BrowserOperationFactory {
|
||||
static readonly TYPE_PHOTO = 'photo';
|
||||
@ -23,7 +23,7 @@ export class BrowserOperationFactory {
|
||||
static getFeature(type: string): BrowserOperationInterface {
|
||||
if (type == BrowserOperationFactory.TYPE_PHOTO) {
|
||||
return new OperationImpl();
|
||||
}else if (type == BrowserOperationFactory.TYPE_ALBUM) {
|
||||
} else if (type == BrowserOperationFactory.TYPE_ALBUM) {
|
||||
return new AlbumOperationImpl();
|
||||
}
|
||||
}
|
@ -15,12 +15,20 @@
|
||||
|
||||
export interface BrowserOperationInterface {
|
||||
create(param: any): any;
|
||||
|
||||
delete(uri: string): any;
|
||||
|
||||
trash(uri: string, isTrash: boolean): any;
|
||||
|
||||
copy(source: any, target: any): any;
|
||||
|
||||
favor(uri: string, isFavor: boolean): void;
|
||||
|
||||
setName(source: any, name: string): void;
|
||||
|
||||
setOrientation(source: any, orientation: number): void;
|
||||
|
||||
setRelativePath(source: any, relativePath: string): void;
|
||||
commitChanges(source :any): any;
|
||||
|
||||
commitChanges(source: any): any;
|
||||
}
|
@ -13,10 +13,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {MenuOperation} from '../view/browserOperation/MenuOperation'
|
||||
import {MenuContext} from '../view/browserOperation/MenuContext'
|
||||
import {Logger} from '../utils/Logger'
|
||||
import {Constants} from '../model/common/Constants'
|
||||
import { MenuOperation } from '../view/browserOperation/MenuOperation'
|
||||
import { MenuContext } from '../view/browserOperation/MenuContext'
|
||||
import { Logger } from '../utils/Logger'
|
||||
import { Constants } from '../model/common/Constants'
|
||||
|
||||
export class MenuOperationFactory {
|
||||
private logger: Logger = new Logger('MenuOperationFactory');
|
||||
@ -33,7 +33,7 @@ export class MenuOperationFactory {
|
||||
}
|
||||
|
||||
public createMenuOperation<T extends MenuOperation>
|
||||
(operation: { new(menuContext: MenuContext): T }, menuContext: MenuContext): T {
|
||||
(operation: { new(menuContext: MenuContext): T }, menuContext: MenuContext): T {
|
||||
this.logger.info(`createMenuOperation: ${operation.name}`);
|
||||
return new operation(menuContext);
|
||||
}
|
@ -13,8 +13,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {Logger} from '../../utils/Logger'
|
||||
import {LoadingListener} from './LoadingListener'
|
||||
import { Logger } from '../../utils/Logger'
|
||||
import { LoadingListener } from './LoadingListener'
|
||||
|
||||
// Abs DataSource
|
||||
export abstract class AbsDataSource implements IDataSource {
|
@ -12,7 +12,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import {MediaLibraryAccess, FetchOptionBuilder} from '../../access/MediaLibraryAccess'
|
||||
import { MediaLibraryAccess, FetchOptionBuilder } from '../../access/MediaLibraryAccess'
|
||||
|
||||
export class AlbumDefine {
|
||||
static readonly ALBUM_ID_ALL = 'default_all';
|
||||
@ -22,23 +22,20 @@ export class AlbumDefine {
|
||||
static readonly ALBUM_ID_FAVOR = 'default_favor';
|
||||
static readonly ALBUM_ID_SNAPSHOT = 'default_snapshot';
|
||||
static readonly ALBUM_ID_REMOTE = 'default_remote';
|
||||
|
||||
static readonly ALBUM_DISABLE_COPY_LIST = new Set ([
|
||||
static readonly ALBUM_DISABLE_COPY_LIST = new Set([
|
||||
AlbumDefine.ALBUM_ID_ALL,
|
||||
AlbumDefine.ALBUM_ID_VIDEO,
|
||||
AlbumDefine.ALBUM_ID_RECYCLE,
|
||||
AlbumDefine.ALBUM_ID_FAVOR
|
||||
]);
|
||||
|
||||
static readonly ALBUM_DISABLE_DELETE_LIST = new Set ([
|
||||
static readonly ALBUM_DISABLE_DELETE_LIST = new Set([
|
||||
AlbumDefine.ALBUM_ID_ALL,
|
||||
AlbumDefine.ALBUM_ID_CAMERA,
|
||||
AlbumDefine.ALBUM_ID_VIDEO,
|
||||
AlbumDefine.ALBUM_ID_RECYCLE,
|
||||
AlbumDefine.ALBUM_ID_FAVOR
|
||||
]);
|
||||
|
||||
static readonly ALBUM_DISABLE_NEW_LIST = new Set ([
|
||||
static readonly ALBUM_DISABLE_NEW_LIST = new Set([
|
||||
AlbumDefine.ALBUM_ID_ALL,
|
||||
AlbumDefine.ALBUM_ID_CAMERA,
|
||||
AlbumDefine.ALBUM_ID_VIDEO,
|
||||
@ -46,8 +43,7 @@ export class AlbumDefine {
|
||||
AlbumDefine.ALBUM_ID_FAVOR,
|
||||
AlbumDefine.ALBUM_ID_SNAPSHOT
|
||||
]);
|
||||
|
||||
static readonly ALBUM_DISABLE_RENAME_LIST = new Set ([
|
||||
static readonly ALBUM_DISABLE_RENAME_LIST = new Set([
|
||||
AlbumDefine.ALBUM_ID_ALL,
|
||||
AlbumDefine.ALBUM_ID_CAMERA,
|
||||
AlbumDefine.ALBUM_ID_VIDEO,
|
||||
@ -55,7 +51,6 @@ export class AlbumDefine {
|
||||
AlbumDefine.ALBUM_ID_FAVOR,
|
||||
AlbumDefine.ALBUM_ID_SNAPSHOT
|
||||
]);
|
||||
|
||||
static readonly ALBUM_DEFAULT_SORT_LIST = [
|
||||
AlbumDefine.ALBUM_ID_CAMERA,
|
||||
AlbumDefine.ALBUM_ID_ALL,
|
||||
@ -63,12 +58,11 @@ export class AlbumDefine {
|
||||
AlbumDefine.ALBUM_ID_SNAPSHOT,
|
||||
AlbumDefine.ALBUM_ID_FAVOR
|
||||
];
|
||||
|
||||
static readonly CAMERA_ALBUM_PATH = 'Camera'
|
||||
static readonly REMOTE_ALBUM_PATH = 'FromOtherDevices'
|
||||
static readonly SNAPSHOT_ALBUM_PATH = 'Screenshots'
|
||||
|
||||
static getFileFetchOpt(albumId: string, deviceId?, startIndex?: number, count?: number){
|
||||
static getFileFetchOpt(albumId: string, deviceId?, startIndex?: number, count?: number) {
|
||||
let builder = new FetchOptionBuilder();
|
||||
|
||||
switch (albumId) {
|
||||
@ -95,11 +89,11 @@ export class AlbumDefine {
|
||||
break;
|
||||
}
|
||||
|
||||
if (startIndex != undefined && count != undefined && startIndex >= 0 && count >= 0) {
|
||||
if (startIndex != undefined && count != undefined && startIndex >= 0 && count >= 0) {
|
||||
builder.select(startIndex, count);
|
||||
}
|
||||
|
||||
if(deviceId){
|
||||
if (deviceId) {
|
||||
builder.device(deviceId);
|
||||
}
|
||||
|
||||
@ -109,28 +103,29 @@ export class AlbumDefine {
|
||||
static getFileFetchOptById(fileId: number, deviceId?: string) {
|
||||
let builder = new FetchOptionBuilder().fileId(`${fileId}`);
|
||||
|
||||
if(deviceId){
|
||||
if (deviceId) {
|
||||
builder.device(deviceId);
|
||||
}
|
||||
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
static getFileFetchOptByName(displayName: string, relativePath? :string) {
|
||||
static getFileFetchOptByName(displayName: string, relativePath?: string) {
|
||||
let builder = new FetchOptionBuilder().displayName(displayName);
|
||||
|
||||
if(relativePath){
|
||||
if (relativePath) {
|
||||
builder.logicalAnd().relativePath(relativePath);
|
||||
}
|
||||
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
static getAlbumFetchOptByName(name, relativePath){
|
||||
static getAlbumFetchOptByName(name, relativePath) {
|
||||
let builder = new FetchOptionBuilder()
|
||||
.albumName(name)
|
||||
.logicalAnd()
|
||||
.relativePath(relativePath);;
|
||||
.relativePath(relativePath);
|
||||
;
|
||||
|
||||
return builder.build();
|
||||
}
|
||||
@ -142,19 +137,20 @@ export class AlbumDefine {
|
||||
.media(MediaLibraryAccess.MEDIA_TYPE_VIDEO.toString())
|
||||
.parentheses();
|
||||
|
||||
if (id){
|
||||
if (id == AlbumDefine.ALBUM_ID_CAMERA){
|
||||
if (id) {
|
||||
if (id == AlbumDefine.ALBUM_ID_CAMERA) {
|
||||
builder
|
||||
.logicalAnd()
|
||||
.relativePath('')
|
||||
.logicalAnd()
|
||||
.albumName(`${MediaLibraryAccess.getInstance().PUBLIC_PATH_CAMERA.substr(0, MediaLibraryAccess.getInstance().PUBLIC_PATH_CAMERA.length - 1)}`)
|
||||
}else{
|
||||
.albumName(`${MediaLibraryAccess.getInstance().PUBLIC_PATH_CAMERA.substr(0,
|
||||
MediaLibraryAccess.getInstance().PUBLIC_PATH_CAMERA.length - 1)}`)
|
||||
} else {
|
||||
builder.logicalAnd().albumId(id)
|
||||
}
|
||||
}
|
||||
|
||||
if(deviceId){
|
||||
if (deviceId) {
|
||||
builder.device(deviceId);
|
||||
}
|
||||
|
||||
@ -162,7 +158,7 @@ export class AlbumDefine {
|
||||
}
|
||||
|
||||
static genAlbumRelativePath(albumName: string, isOrigin: boolean = false): string {
|
||||
if (isOrigin){
|
||||
if (isOrigin) {
|
||||
return MediaLibraryAccess.getInstance().PUBLIC_PATH_CAMERA;
|
||||
}
|
||||
let path = `${MediaLibraryAccess.getInstance().PUBLIC_PATH_CAMERA}${albumName}/`;
|
@ -12,18 +12,21 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import {BrowserDataInterface} from '../../interface/BrowserDataInterface'
|
||||
import {AlbumDefine} from './AlbumDefine'
|
||||
import {Logger} from '../../utils/Logger'
|
||||
import {MediaLibraryAccess} from '../../access/MediaLibraryAccess';
|
||||
import { BrowserDataInterface } from '../../interface/BrowserDataInterface'
|
||||
import { AlbumDefine } from './AlbumDefine'
|
||||
import { Logger } from '../../utils/Logger'
|
||||
import { MediaLibraryAccess } from '../../access/MediaLibraryAccess';
|
||||
|
||||
export abstract class BrowserDataImpl implements BrowserDataInterface {
|
||||
logger: Logger = new Logger('BrowserDataImpl');
|
||||
static readonly THUMBNAIL_WIDTH = 256;
|
||||
|
||||
abstract getData(callback, param): void;
|
||||
|
||||
abstract getDataCount(callback, param): void;
|
||||
abstract getDataById(id: any, deviceId? :any): any;
|
||||
|
||||
abstract getDataById(id: any, deviceId?: any): any;
|
||||
|
||||
abstract getDataByName(name: string, albumInfo: any): any;
|
||||
|
||||
async getAllObject(fetchOpt) {
|
||||
@ -43,7 +46,7 @@ export abstract class BrowserDataImpl implements BrowserDataInterface {
|
||||
return firstObject;
|
||||
}
|
||||
|
||||
async getItems(albumId: string, startIndex?: number, count?:number, deviceId?) {
|
||||
async getItems(albumId: string, startIndex?: number, count?: number, deviceId?) {
|
||||
let fetchOpt = AlbumDefine.getFileFetchOpt(albumId, deviceId, startIndex, count);
|
||||
switch (albumId) {
|
||||
case AlbumDefine.ALBUM_ID_ALL:
|
||||
@ -55,7 +58,7 @@ export abstract class BrowserDataImpl implements BrowserDataInterface {
|
||||
return await MediaLibraryAccess.getInstance().getTrashObject(fetchOpt);
|
||||
default:
|
||||
return await MediaLibraryAccess.getInstance().getEntityAlbumObject(
|
||||
AlbumDefine.getAlbumFetchOpt(albumId, deviceId), fetchOpt);
|
||||
AlbumDefine.getAlbumFetchOpt(albumId, deviceId), fetchOpt);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -79,7 +82,7 @@ export abstract class BrowserDataImpl implements BrowserDataInterface {
|
||||
getThumbnailSafe(sourceUri: string, size?) {
|
||||
this.logger.debug('getThumbnailSafe');
|
||||
|
||||
try{
|
||||
try {
|
||||
if (size) {
|
||||
return `${sourceUri}/thumbnail/${size.width}/${size.height}`;
|
||||
} else {
|
@ -13,7 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {MediaObserverCallback} from './dataObserver/MediaObserverCallback'
|
||||
import { MediaObserverCallback } from './dataObserver/MediaObserverCallback'
|
||||
|
||||
export class CommonObserverCallback implements MediaObserverCallback {
|
||||
source: any;
|
@ -13,13 +13,13 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {TimelineData} from './photo/TimelineData'
|
||||
import {Logger} from '../../utils/Logger'
|
||||
import {MediaItem} from './photo/MediaItem'
|
||||
import {AsyncCallback} from '../common/AsyncCallback'
|
||||
import {AlbumDefine} from './AlbumDefine'
|
||||
import {BrowserDataFactory} from '../../interface/BrowserDataFactory'
|
||||
import {BrowserDataInterface} from '../../interface/BrowserDataInterface'
|
||||
import { TimelineData } from './photo/TimelineData'
|
||||
import { Logger } from '../../utils/Logger'
|
||||
import { MediaItem } from './photo/MediaItem'
|
||||
import { AsyncCallback } from '../common/AsyncCallback'
|
||||
import { AlbumDefine } from './AlbumDefine'
|
||||
import { BrowserDataFactory } from '../../interface/BrowserDataFactory'
|
||||
import { BrowserDataInterface } from '../../interface/BrowserDataInterface'
|
||||
|
||||
export class BucketSelectionEntry {
|
||||
private groupId = -1;
|
||||
@ -90,7 +90,7 @@ export class BucketSelectionEntry {
|
||||
* it is global inverse selection and requires reverse operation
|
||||
*/
|
||||
public changeSelectMode(isInverseMode: boolean) {
|
||||
isInverseMode
|
||||
isInverseMode
|
||||
? (this.getSelectedCount() == 0 ? this.selectAll() : this.unselectAll())
|
||||
: (this.inSelectAllMode() ? this.unselectAll() : this.selectAll())
|
||||
}
|
||||
@ -163,7 +163,7 @@ export class SelectManager {
|
||||
}
|
||||
|
||||
public setAlbumId(albumId) {
|
||||
this.albumId = albumId;
|
||||
this.albumId = albumId;
|
||||
}
|
||||
|
||||
public setDeviceId(deviceId) {
|
||||
@ -315,10 +315,10 @@ export class SelectManager {
|
||||
|
||||
if (this.albumId) {
|
||||
await photoDataImpl.getData(cb,
|
||||
{id: this.albumId, start: start, count: count, deviceId: this.deviceId});
|
||||
{ id: this.albumId, start: start, count: count, deviceId: this.deviceId });
|
||||
} else {
|
||||
await photoDataImpl.getData(cb,
|
||||
{id: AlbumDefine.ALBUM_ID_ALL, start: start, count: count, deviceId: this.deviceId});
|
||||
{ id: AlbumDefine.ALBUM_ID_ALL, start: start, count: count, deviceId: this.deviceId });
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -602,7 +602,7 @@ export class TimelineSelectManager extends SelectManager {
|
||||
});
|
||||
} else {
|
||||
await this.getItems(this.photoDataImpl, start, this.mGroupData[i].count, (temp: MediaItem[]) => {
|
||||
temp.forEach((item) =>{
|
||||
temp.forEach((item) => {
|
||||
result.push(item.uri);
|
||||
});
|
||||
this.logger.info(`getInverseGroupItems result ${result.length}`);
|
||||
@ -641,7 +641,7 @@ export class TimelineSelectManager extends SelectManager {
|
||||
this.logger.info('getSelectedItems: mode is inverseSelection');
|
||||
for (let i = 0; i < this.mGroupData.length; i++) {
|
||||
let entry = this.mSelectionEntryArray[i];
|
||||
if(entry) {
|
||||
if (entry) {
|
||||
if (entry.getInverseSelection()) {
|
||||
await this.getItems(this.photoDataImpl, start, this.mGroupData[i].count, (temp: MediaItem[]) => {
|
||||
temp.forEach((item) => {
|
||||
@ -681,7 +681,7 @@ export class TimelineSelectManager extends SelectManager {
|
||||
for (let i = 0; i < this.mGroupData.length; i++) {
|
||||
let entry = this.mSelectionEntryArray[i];
|
||||
if (entry) {
|
||||
await this.getItems(this.photoDataImpl, start, this.mGroupData[i].count, (temp: MediaItem[]) =>{
|
||||
await this.getItems(this.photoDataImpl, start, this.mGroupData[i].count, (temp: MediaItem[]) => {
|
||||
temp.forEach((item) => {
|
||||
if (!entry.getInverseSelection()) {
|
||||
if (entry.getClickSet().has(item.uri)) {
|
||||
@ -705,7 +705,6 @@ export class TimelineSelectManager extends SelectManager {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private checkIsGetSelectionFinish(doneCount: number, result: string[], callback: AsyncCallback<string[]>): void {
|
||||
if (this.mGroupData.length == doneCount) {
|
||||
this.logger.info(`getSelection result ${result.length}`);
|
||||
@ -798,7 +797,7 @@ export class AlbumSetSelectManager extends SelectManager {
|
||||
let isDisableRenameFlag = !(this.isDisableRenameClickedSet.size == 0);
|
||||
let isDisableDeleteFlag = !(this.isDisableDeleteClickedSet.size == 0);
|
||||
this.mCallbacks['updateToolBarState']
|
||||
&& this.mCallbacks['updateToolBarState'](isDisableRenameFlag, isDisableDeleteFlag);
|
||||
&& this.mCallbacks['updateToolBarState'](isDisableRenameFlag, isDisableDeleteFlag);
|
||||
}
|
||||
|
||||
public onModeChange(newMode: boolean) {
|
@ -12,17 +12,16 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import {AlbumDefine} from '../AlbumDefine'
|
||||
import {AlbumInfo} from './AlbumInfo'
|
||||
import {AsyncCallback} from '../../common/AsyncCallback'
|
||||
import {BrowserDataImpl} from '../BrowserDataImpl'
|
||||
import {MediaLibraryAccess} from '../../../access/MediaLibraryAccess'
|
||||
import {Logger} from '../../../utils/Logger'
|
||||
import {UiUtil} from '../../../utils/UiUtil'
|
||||
import { AlbumDefine } from '../AlbumDefine'
|
||||
import { AlbumInfo } from './AlbumInfo'
|
||||
import { AsyncCallback } from '../../common/AsyncCallback'
|
||||
import { BrowserDataImpl } from '../BrowserDataImpl'
|
||||
import { MediaLibraryAccess } from '../../../access/MediaLibraryAccess'
|
||||
import { Logger } from '../../../utils/Logger'
|
||||
import { UiUtil } from '../../../utils/UiUtil'
|
||||
|
||||
export class AlbumDataImpl extends BrowserDataImpl {
|
||||
logger = new Logger('AlbumDataImpl');
|
||||
|
||||
private virtualAlbumList = [
|
||||
AlbumDefine.ALBUM_ID_ALL,
|
||||
AlbumDefine.ALBUM_ID_VIDEO,
|
||||
@ -32,9 +31,8 @@ export class AlbumDataImpl extends BrowserDataImpl {
|
||||
[`${MediaLibraryAccess.getInstance().PUBLIC_PATH_CAMERA}${AlbumDefine.REMOTE_ALBUM_PATH}/`, AlbumDefine.ALBUM_ID_REMOTE],
|
||||
[`${MediaLibraryAccess.getInstance().PUBLIC_PATH_IMAGE}${AlbumDefine.SNAPSHOT_ALBUM_PATH}/`, AlbumDefine.ALBUM_ID_SNAPSHOT],
|
||||
]);
|
||||
|
||||
private deviceId:string = '';
|
||||
private deviceName:string = '';
|
||||
private deviceId: string = '';
|
||||
private deviceName: string = '';
|
||||
private moreInfo: boolean = false;
|
||||
|
||||
constructor(param) {
|
||||
@ -43,37 +41,37 @@ export class AlbumDataImpl extends BrowserDataImpl {
|
||||
this.logger.debug(`Remote networkId: ${param.deviceId}`);
|
||||
this.deviceId = param.deviceId;
|
||||
this.deviceName = param.deviceName;
|
||||
}else{
|
||||
} else {
|
||||
this.logger.debug(`Local`);
|
||||
}
|
||||
|
||||
if (param && param.moreInfo){
|
||||
if (param && param.moreInfo) {
|
||||
this.moreInfo = param.moreInfo
|
||||
}
|
||||
|
||||
this.logger = new Logger(`AlbumDataImpl[${this.deviceId}]`);
|
||||
}
|
||||
|
||||
getData(callback, param) : void {
|
||||
getData(callback, param): void {
|
||||
if (param == null) {
|
||||
this.buildAlbums(callback);
|
||||
} else {
|
||||
this.genAlbumsInfo(callback,param);
|
||||
this.genAlbumsInfo(callback, param);
|
||||
}
|
||||
}
|
||||
|
||||
async getDataById(id: any, deviceId? :any) {
|
||||
async getDataById(id: any, deviceId?: any) {
|
||||
let albums = await MediaLibraryAccess.getInstance().getAlbums(AlbumDefine.getAlbumFetchOpt(id, deviceId));
|
||||
if (albums && albums.length > 0){
|
||||
if (albums && albums.length > 0) {
|
||||
return albums[0];
|
||||
}else{
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async getDataByName(name: string, albumInfo: any) {
|
||||
let albums = await MediaLibraryAccess.getInstance().getAlbums(AlbumDefine.getAlbumFetchOptByName(name, albumInfo.relativePath));
|
||||
if (albums && albums.length > 0){
|
||||
if (albums && albums.length > 0) {
|
||||
let fileResult = await albums[0].getFileAssets(AlbumDefine.getFileFetchOpt(''));
|
||||
let count = fileResult.getCount();
|
||||
if (count <= 0) {
|
||||
@ -81,7 +79,7 @@ export class AlbumDataImpl extends BrowserDataImpl {
|
||||
return null;
|
||||
}
|
||||
return albums[0];
|
||||
}else{
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -159,19 +157,19 @@ export class AlbumDataImpl extends BrowserDataImpl {
|
||||
}
|
||||
|
||||
private async getFavorAlbum(albumList) {
|
||||
if (this.isRemoteDevice()){
|
||||
if (this.isRemoteDevice()) {
|
||||
return;
|
||||
}
|
||||
|
||||
let favAlbum = await MediaLibraryAccess.getInstance().getFavoriteAlbum(AlbumDefine.getFileFetchOpt(AlbumDefine.ALBUM_ID_FAVOR));
|
||||
if (favAlbum.count > 0) {
|
||||
let fav = new AlbumInfo(AlbumDefine.ALBUM_ID_FAVOR, this.getThumbnailSafe(favAlbum.file.uri), AlbumDefine.ALBUM_ID_FAVOR,
|
||||
await this.getAlbumDisplayName(AlbumDefine.ALBUM_ID_FAVOR), favAlbum.count, this.deviceId, '');
|
||||
fav.coverOrientation = favAlbum.file.orientation;
|
||||
fav.innerId = fav.id;
|
||||
fav.isDisableDelete = AlbumDefine.ALBUM_DISABLE_DELETE_LIST.has(fav.innerId);
|
||||
fav.isDisableRename = AlbumDefine.ALBUM_DISABLE_RENAME_LIST.has(fav.innerId);
|
||||
albumList.set(fav.innerId, fav);
|
||||
let fav = new AlbumInfo(AlbumDefine.ALBUM_ID_FAVOR, this.getThumbnailSafe(favAlbum.file.uri), AlbumDefine.ALBUM_ID_FAVOR,
|
||||
await this.getAlbumDisplayName(AlbumDefine.ALBUM_ID_FAVOR), favAlbum.count, this.deviceId, '');
|
||||
fav.coverOrientation = favAlbum.file.orientation;
|
||||
fav.innerId = fav.id;
|
||||
fav.isDisableDelete = AlbumDefine.ALBUM_DISABLE_DELETE_LIST.has(fav.innerId);
|
||||
fav.isDisableRename = AlbumDefine.ALBUM_DISABLE_RENAME_LIST.has(fav.innerId);
|
||||
albumList.set(fav.innerId, fav);
|
||||
}
|
||||
}
|
||||
|
||||
@ -220,7 +218,7 @@ export class AlbumDataImpl extends BrowserDataImpl {
|
||||
|
||||
album.isDisableDelete = AlbumDefine.ALBUM_DISABLE_DELETE_LIST.has(album.innerId);
|
||||
album.isDisableRename = AlbumDefine.ALBUM_DISABLE_RENAME_LIST.has(album.innerId);
|
||||
if (this.moreInfo){
|
||||
if (this.moreInfo) {
|
||||
await this.updateAlbumVideoCount(album);
|
||||
}
|
||||
output.set(album.innerId, album);
|
||||
@ -303,8 +301,8 @@ export class AlbumDataImpl extends BrowserDataImpl {
|
||||
break;
|
||||
default:
|
||||
albumInfo.videoCount
|
||||
= await MediaLibraryAccess.getInstance().getEntityAlbumCount(AlbumDefine.getAlbumFetchOpt(albumInfo.id),
|
||||
AlbumDefine.getFileFetchOpt(AlbumDefine.ALBUM_ID_VIDEO));
|
||||
= await MediaLibraryAccess.getInstance().getEntityAlbumCount(AlbumDefine.getAlbumFetchOpt(albumInfo.id),
|
||||
AlbumDefine.getFileFetchOpt(AlbumDefine.ALBUM_ID_VIDEO));
|
||||
break;
|
||||
}
|
||||
}
|
@ -12,8 +12,8 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import {BrowserOperationInterface} from '../../../interface/BrowserOperationInterface'
|
||||
import {Logger} from '../../../utils/Logger'
|
||||
import { BrowserOperationInterface } from '../../../interface/BrowserOperationInterface'
|
||||
import { Logger } from '../../../utils/Logger'
|
||||
|
||||
export class AlbumOperationImpl implements BrowserOperationInterface {
|
||||
logger: Logger = new Logger('AlbumOperationImpl');
|
||||
@ -22,15 +22,28 @@ export class AlbumOperationImpl implements BrowserOperationInterface {
|
||||
album.albumName = name;
|
||||
}
|
||||
|
||||
async commitChanges(album :any) {
|
||||
async commitChanges(album: any) {
|
||||
await album.commitModify();
|
||||
}
|
||||
|
||||
favor(uri: string, isFavor: boolean): void{}
|
||||
delete(uri: string): any{}
|
||||
copy(source: any, target: any): any{}
|
||||
trash(uri: string, isTrash: boolean): void{}
|
||||
create(param: any): any{}
|
||||
setOrientation(source: any, orientation: number): void{}
|
||||
setRelativePath(source: any, relativePath: string): void{}
|
||||
favor(uri: string, isFavor: boolean): void{
|
||||
}
|
||||
|
||||
delete(uri: string): any{
|
||||
}
|
||||
|
||||
copy(source: any, target: any): any{
|
||||
}
|
||||
|
||||
trash(uri: string, isTrash: boolean): void{
|
||||
}
|
||||
|
||||
create(param: any): any{
|
||||
}
|
||||
|
||||
setOrientation(source: any, orientation: number): void{
|
||||
}
|
||||
|
||||
setRelativePath(source: any, relativePath: string): void{
|
||||
}
|
||||
}
|
@ -13,8 +13,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {AlbumSetDataSource} from './AlbumSetDataSource'
|
||||
import {AsyncCallback} from '../../common/AsyncCallback'
|
||||
import { AlbumSetDataSource } from './AlbumSetDataSource'
|
||||
import { AsyncCallback } from '../../common/AsyncCallback'
|
||||
import { TraceControllerUtils } from '../../../utils/TraceControllerUtils';
|
||||
import { AlbumInfo } from './AlbumInfo';
|
||||
|
@ -25,11 +25,8 @@ import { Constants } from '../../common/Constants';
|
||||
|
||||
export class AlbumSetDataSource extends AbsDataSource {
|
||||
logger: Logger = new Logger('AlbumSetDataSource');
|
||||
|
||||
mediaSetList: AlbumInfo[] = [];
|
||||
|
||||
albumBrowserDataImpl: BrowserDataInterface
|
||||
|
||||
private broadCast_: BroadCast;
|
||||
private blackList: Array<string> = [];
|
||||
private deviceId = ''
|
||||
@ -41,7 +38,7 @@ export class AlbumSetDataSource extends AbsDataSource {
|
||||
this.broadCast_ = broadCast;
|
||||
this.albumBrowserDataImpl = BrowserDataFactory.getFeature(BrowserDataFactory.TYPE_ALBUM, param);
|
||||
|
||||
if (param && param.deviceId){
|
||||
if (param && param.deviceId) {
|
||||
this.deviceId = param.deviceId;
|
||||
}
|
||||
}
|
||||
@ -107,12 +104,12 @@ export class AlbumSetDataSource extends AbsDataSource {
|
||||
}
|
||||
|
||||
onChange(mediaType: string) {
|
||||
if(this.deviceId == '' || this.deviceId == undefined) {
|
||||
if (mediaType == Constants.MEDIA_TYPE_IMAGE || mediaType == Constants.MEDIA_TYPE_VIDEO || mediaType == Constants.MEDIA_TYPE_ALBUM){
|
||||
if (this.deviceId == '' || this.deviceId == undefined) {
|
||||
if (mediaType == Constants.MEDIA_TYPE_IMAGE || mediaType == Constants.MEDIA_TYPE_VIDEO || mediaType == Constants.MEDIA_TYPE_ALBUM) {
|
||||
super.onChange(mediaType);
|
||||
}
|
||||
}else{
|
||||
if (mediaType == Constants.MEDIA_TYPE_REMOTE){
|
||||
} else {
|
||||
if (mediaType == Constants.MEDIA_TYPE_REMOTE) {
|
||||
super.onChange(mediaType);
|
||||
}
|
||||
}
|
@ -13,16 +13,16 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {PeerInfo} from './PeerInfo'
|
||||
import {Logger} from '../../../utils/Logger'
|
||||
import {AbsDataSource} from '../AbsDataSource'
|
||||
import { PeerInfo } from './PeerInfo'
|
||||
import { Logger } from '../../../utils/Logger'
|
||||
import { AbsDataSource } from '../AbsDataSource'
|
||||
import { BroadCast } from '../../../utils/BroadCast';
|
||||
import { BrowserDataFactory } from '../../../interface/BrowserDataFactory';
|
||||
import { BrowserDataInterface } from '../../../interface/BrowserDataInterface';
|
||||
|
||||
import {BroadCastConstants} from '../../common/BroadCastConstants'
|
||||
import {BroadCastManager} from '../../common/BroadCastManager'
|
||||
import {Constants} from '../../common/Constants';
|
||||
import { BroadCastConstants } from '../../common/BroadCastConstants'
|
||||
import { BroadCastManager } from '../../common/BroadCastManager'
|
||||
import { Constants } from '../../common/Constants';
|
||||
|
||||
export class DistributedDataSource extends AbsDataSource {
|
||||
logger: Logger = new Logger('DistributedDataSource');
|
||||
@ -76,7 +76,7 @@ export class DistributedDataSource extends AbsDataSource {
|
||||
}
|
||||
|
||||
onChange(mediaType: string) {
|
||||
if (mediaType == Constants.MEDIA_TYPE_DEVICE|| mediaType == Constants.MEDIA_TYPE_REMOTE) {
|
||||
if (mediaType == Constants.MEDIA_TYPE_DEVICE || mediaType == Constants.MEDIA_TYPE_REMOTE) {
|
||||
this.logger.info(`onChange: ${mediaType}`);
|
||||
this.lastChangeTime = Date.now();
|
||||
this.loadData();
|
||||
@ -99,7 +99,7 @@ export class DistributedDataSource extends AbsDataSource {
|
||||
if (!this.hasDevice(device.networkId, devices)) {
|
||||
this.logger.debug(`offline: ${device.networkId}`);
|
||||
params.push(Constants.DEVICE_STATE_OFFLINE);
|
||||
}else{
|
||||
} else {
|
||||
params.push(Constants.DEVICE_STATE_CHANGE);
|
||||
}
|
||||
params.push(device.networkId);
|
@ -13,20 +13,19 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {MediaObserverCallback} from './MediaObserverCallback';
|
||||
import {Logger} from '../../../utils/Logger'
|
||||
import {Constants} from '../../common/Constants'
|
||||
import {MediaLibraryAccess} from '../../../access/MediaLibraryAccess'
|
||||
import { MediaObserverCallback } from './MediaObserverCallback';
|
||||
import { Logger } from '../../../utils/Logger'
|
||||
import { Constants } from '../../common/Constants'
|
||||
import { MediaLibraryAccess } from '../../../access/MediaLibraryAccess'
|
||||
|
||||
export class MediaObserver {
|
||||
private logger: Logger = new Logger('MediaObserver');
|
||||
callbacks: MediaObserverCallback[] = [];
|
||||
|
||||
private static readonly OBSERVER_IMAGE_CHANGE : string = 'imageChange'
|
||||
private static readonly OBSERVER_VIDEO_CHANGE : string = 'videoChange'
|
||||
private static readonly OBSERVER_DEVICE_CHANGE : string = 'deviceChange'
|
||||
private static readonly OBSERVER_ALBUM_CHANGE : string = 'albumChange'
|
||||
private static readonly OBSERVER_REMOTE_FILE_CHANGE : string = 'remoteFileChange'
|
||||
private static readonly OBSERVER_IMAGE_CHANGE: string = 'imageChange'
|
||||
private static readonly OBSERVER_VIDEO_CHANGE: string = 'videoChange'
|
||||
private static readonly OBSERVER_DEVICE_CHANGE: string = 'deviceChange'
|
||||
private static readonly OBSERVER_ALBUM_CHANGE: string = 'albumChange'
|
||||
private static readonly OBSERVER_REMOTE_FILE_CHANGE: string = 'remoteFileChange'
|
||||
|
||||
static getInstance(): MediaObserver {
|
||||
if (AppStorage.Get(Constants.APP_KEY_MENU_MEDIA_OBSERVER) == null) {
|
@ -98,25 +98,18 @@ export class Constants {
|
||||
|
||||
// overScale animation duration
|
||||
static readonly OVER_SCALE_ANIME_DURATION = 500;
|
||||
|
||||
static readonly ROTATE_ONCE = 90;
|
||||
static readonly ROTATE_TWICE = 180;
|
||||
static readonly ROTATE_THRICE = 270;
|
||||
static readonly ROTATE_QUARTIC = 360;
|
||||
|
||||
static readonly DEFAULT_SIZE = 256;
|
||||
|
||||
static readonly SHARE_TRANSITION_DURATION = 200;
|
||||
static readonly PAGE_SHOW_ANIMATION_DURATION = 200;
|
||||
|
||||
static readonly RESERVED_DIGITS = 6;
|
||||
|
||||
static readonly CENTER_DEFAULT = 0.5;
|
||||
|
||||
static readonly NUMBER_2 = 2;
|
||||
static readonly NUMBER_3 = 3;
|
||||
static readonly NUMBER_12 = 12;
|
||||
static readonly NUMBER_13 = 13;
|
||||
|
||||
static readonly DEFAULT_TRANSITION_ID: string = 'default_id';
|
||||
}
|
@ -14,13 +14,13 @@
|
||||
*/
|
||||
|
||||
import Matrix4 from '@ohos.matrix4'
|
||||
import {MediaItem} from './MediaItem'
|
||||
import {Logger} from '../../../utils/Logger'
|
||||
import {BroadCast} from '../../../utils/BroadCast'
|
||||
import {MathUtil} from '../../../utils/MathUtil'
|
||||
import {Constants as PhotoConstants} from './Constants'
|
||||
import {ScreenManager} from '../../common/ScreenManager'
|
||||
import {Constants} from './Constants'
|
||||
import { MediaItem } from './MediaItem'
|
||||
import { Logger } from '../../../utils/Logger'
|
||||
import { BroadCast } from '../../../utils/BroadCast'
|
||||
import { MathUtil } from '../../../utils/MathUtil'
|
||||
import { Constants as PhotoConstants } from './Constants'
|
||||
import { ScreenManager } from '../../common/ScreenManager'
|
||||
import { Constants } from './Constants'
|
||||
|
||||
export class EventPipeline {
|
||||
// logger
|
||||
@ -91,7 +91,6 @@ export class EventPipeline {
|
||||
|
||||
// pull down to return flag to prevent multiple triggers
|
||||
private isExiting = false;
|
||||
|
||||
private orientation = 0;
|
||||
|
||||
constructor(broadCastParam: BroadCast, item: MediaItem) {
|
||||
@ -194,7 +193,7 @@ export class EventPipeline {
|
||||
}
|
||||
|
||||
if (direction == PanDirection.Vertical || direction == (PanDirection.Vertical | PanDirection.Left) ||
|
||||
direction == (PanDirection.Vertical | PanDirection.Right)) {
|
||||
direction == (PanDirection.Vertical | PanDirection.Right)) {
|
||||
this.broadCast.emit(PhotoConstants.SET_DISABLE_SWIPE, [false]);
|
||||
} else {
|
||||
this.broadCast.emit(PhotoConstants.SET_DISABLE_SWIPE, [true]);
|
||||
@ -447,18 +446,18 @@ export class EventPipeline {
|
||||
let scale = this.lastScale * this.scale;
|
||||
let limits = this.evaluateOffsetRange(scale);
|
||||
let measureX = this.lastOffset[0] + (this.center[0] - PhotoConstants.CENTER_DEFAULT) * this.componentWidth
|
||||
* (this.defaultScale - this.scale) * this.lastScale;
|
||||
* (this.defaultScale - this.scale) * this.lastScale;
|
||||
let measureY = this.lastOffset[1] + (this.center[1] - PhotoConstants.CENTER_DEFAULT) * this.componentHeight
|
||||
* (this.defaultScale - this.scale) * this.lastScale;
|
||||
* (this.defaultScale - this.scale) * this.lastScale;
|
||||
let moveX = offsetX;
|
||||
let moveY = offsetY;
|
||||
if (this.orientation == Constants.ROTATE_ONCE) {
|
||||
moveX = offsetY;
|
||||
moveY = -1 * offsetX;
|
||||
}else if (this.orientation == Constants.ROTATE_TWICE) {
|
||||
} else if (this.orientation == Constants.ROTATE_TWICE) {
|
||||
moveX = -1 * offsetX;
|
||||
moveY = -1 * offsetY;
|
||||
}else if (this.orientation == Constants.ROTATE_THRICE) {
|
||||
} else if (this.orientation == Constants.ROTATE_THRICE) {
|
||||
moveX = -1 * offsetY;
|
||||
moveY = offsetX;
|
||||
}
|
||||
@ -540,9 +539,9 @@ export class EventPipeline {
|
||||
|
||||
// Get the touch coordinates relative to the control
|
||||
let cxRelativeToComp = MathUtil.clamp((centerX - leftTop[0])
|
||||
/ (this.componentWidth * scale), this.leftMost, 1 - this.leftMost);
|
||||
/ (this.componentWidth * scale), this.leftMost, 1 - this.leftMost);
|
||||
let cyRelativeToComp = MathUtil.clamp((centerY - leftTop[1])
|
||||
/ (this.componentHeight * scale), this.topMost, 1 - this.topMost);
|
||||
/ (this.componentHeight * scale), this.topMost, 1 - this.topMost);
|
||||
|
||||
let imgDisplaySize: [number, number] = this.evaluateImgDisplaySize();
|
||||
let imgDisplayWidth = imgDisplaySize[0];
|
||||
@ -616,9 +615,9 @@ export class EventPipeline {
|
||||
private evaluateAnimeMatrix(scale: number, center: [number, number]): any {
|
||||
let offset = [
|
||||
this.lastOffset[0] + this.offset[0] + (center[0] - PhotoConstants.CENTER_DEFAULT) * this.componentWidth
|
||||
* (this.defaultScale - scale / this.lastScale) * this.lastScale,
|
||||
* (this.defaultScale - scale / this.lastScale) * this.lastScale,
|
||||
this.lastOffset[1] + this.offset[1] + (center[1] - PhotoConstants.CENTER_DEFAULT) * this.componentHeight
|
||||
* (this.defaultScale - scale / this.lastScale) * this.lastScale
|
||||
* (this.defaultScale - scale / this.lastScale) * this.lastScale
|
||||
];
|
||||
if (Number(scale.toFixed(Constants.RESERVED_DIGITS)) > Number(this.defaultScale.toFixed(Constants.RESERVED_DIGITS))) {
|
||||
let limits = this.evaluateOffsetRange(scale);
|
@ -13,10 +13,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {Logger} from '../../../utils/Logger'
|
||||
import {Releasable} from '../../common/Releasable'
|
||||
import { Logger } from '../../../utils/Logger'
|
||||
import { Releasable } from '../../common/Releasable'
|
||||
|
||||
export class FifoCache <T extends Releasable> {
|
||||
export class FifoCache<T extends Releasable> {
|
||||
private logger: Logger = new Logger('FifoCache');
|
||||
map: Map<string, T> = new Map<string, T>();
|
||||
pendingSet: Set<string> = new Set<string>();
|
@ -13,11 +13,11 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {AsyncCallback} from '../../common/AsyncCallback'
|
||||
import {MediaItem} from './MediaItem'
|
||||
import {MediaDataSource} from './MediaDataSource'
|
||||
import {Logger} from '../../../utils/Logger'
|
||||
import {TraceControllerUtils} from '../../../utils/TraceControllerUtils'
|
||||
import { AsyncCallback } from '../../common/AsyncCallback'
|
||||
import { MediaItem } from './MediaItem'
|
||||
import { MediaDataSource } from './MediaDataSource'
|
||||
import { Logger } from '../../../utils/Logger'
|
||||
import { TraceControllerUtils } from '../../../utils/TraceControllerUtils'
|
||||
|
||||
// Datasource requests media mediaItem callback
|
||||
export class GetItemsCallback implements AsyncCallback<MediaItem[]> {
|
@ -13,10 +13,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {AsyncCallback} from '../../common/AsyncCallback'
|
||||
import {MediaDataSource} from './MediaDataSource'
|
||||
import {Logger} from '../../../utils/Logger'
|
||||
import {TraceControllerUtils} from '../../../utils/TraceControllerUtils'
|
||||
import { AsyncCallback } from '../../common/AsyncCallback'
|
||||
import { MediaDataSource } from './MediaDataSource'
|
||||
import { Logger } from '../../../utils/Logger'
|
||||
import { TraceControllerUtils } from '../../../utils/TraceControllerUtils'
|
||||
|
||||
// DataSource request media photo quantity callback
|
||||
export class GetMediaCountCallback implements AsyncCallback<number> {
|
@ -13,8 +13,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {MediaItem} from './MediaItem'
|
||||
import {SelectionState} from '../SelectionState'
|
||||
import { MediaItem } from './MediaItem'
|
||||
import { SelectionState } from '../SelectionState'
|
||||
|
||||
export class ImageGridItem {
|
||||
mediaItem: MediaItem;
|
@ -13,21 +13,21 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {MediaItem} from './MediaItem'
|
||||
import {AbsDataSource} from '../AbsDataSource'
|
||||
import {GetItemsCallback} from './GetItemsCallback'
|
||||
import {GetMediaCountCallback} from './GetMediaCountCallback'
|
||||
import {Logger} from '../../../utils/Logger'
|
||||
import { MediaItem } from './MediaItem'
|
||||
import { AbsDataSource } from '../AbsDataSource'
|
||||
import { GetItemsCallback } from './GetItemsCallback'
|
||||
import { GetMediaCountCallback } from './GetMediaCountCallback'
|
||||
import { Logger } from '../../../utils/Logger'
|
||||
import { BroadCastConstants } from '../../common/BroadCastConstants';
|
||||
import { BroadCast } from '../../../utils/BroadCast';
|
||||
import {BroadCastManager} from '../../common/BroadCastManager'
|
||||
import {Constants} from '../../common/Constants'
|
||||
import {PendingTask} from './PendingTask'
|
||||
import {PendingCondition} from './PendingCondition'
|
||||
import {TraceControllerUtils} from '../../../utils/TraceControllerUtils'
|
||||
import {AlbumDefine} from '../AlbumDefine'
|
||||
import {BrowserDataFactory} from '../../../interface/BrowserDataFactory'
|
||||
import {BrowserDataInterface} from '../../../interface/BrowserDataInterface'
|
||||
import { BroadCastManager } from '../../common/BroadCastManager'
|
||||
import { Constants } from '../../common/Constants'
|
||||
import { PendingTask } from './PendingTask'
|
||||
import { PendingCondition } from './PendingCondition'
|
||||
import { TraceControllerUtils } from '../../../utils/TraceControllerUtils'
|
||||
import { AlbumDefine } from '../AlbumDefine'
|
||||
import { BrowserDataFactory } from '../../../interface/BrowserDataFactory'
|
||||
import { BrowserDataInterface } from '../../../interface/BrowserDataInterface'
|
||||
|
||||
export class MediaDataSource extends AbsDataSource {
|
||||
// Number of first pictures loaded during initialization
|
||||
@ -84,11 +84,8 @@ export class MediaDataSource extends AbsDataSource {
|
||||
// Request time of the first batch of data
|
||||
firstPatchDataRequestTime: number;
|
||||
albumId: string = AlbumDefine.ALBUM_ID_ALL;
|
||||
|
||||
deviceId: string = undefined;
|
||||
|
||||
isRefresh: boolean = false;
|
||||
|
||||
isEditSaveReload: boolean = false;
|
||||
|
||||
constructor(windowSize: number) {
|
||||
@ -179,7 +176,7 @@ export class MediaDataSource extends AbsDataSource {
|
||||
}
|
||||
};
|
||||
this.photoDataImpl.getData(firstPatchDataCallback,
|
||||
{id: this.albumId, start: start, count: limit, deviceId: this.deviceId});
|
||||
{ id: this.albumId, start: start, count: limit, deviceId: this.deviceId });
|
||||
this.loadData();
|
||||
}
|
||||
|
||||
@ -252,7 +249,7 @@ export class MediaDataSource extends AbsDataSource {
|
||||
if (this.mediaCount == 0) {
|
||||
this.hasNewChange = false;
|
||||
this.onDataReloaded();
|
||||
} else if(this.isEditSaveReload || this.isCountChanged || this.isRefresh) {
|
||||
} else if (this.isEditSaveReload || this.isCountChanged || this.isRefresh) {
|
||||
// dirty data, need to get data again
|
||||
this.logger.info('dirty data, need to get data again');
|
||||
let callback: GetItemsCallback = new GetItemsCallback(this, this.activeStart);
|
||||
@ -340,7 +337,7 @@ export class MediaDataSource extends AbsDataSource {
|
||||
for (let i = fromIndex; i < endIndex; i++) {
|
||||
this.items[i - this.activeStart] = mediaItems[i - start];
|
||||
this.logger.debug(`updateMediaData ${this.layoutIndexes[i]}`);
|
||||
// !this.isCountChanged && this.onDataChanged(this.layoutIndexes[i]);
|
||||
// !this.isCountChanged && this.onDataChanged(this.layoutIndexes[i]);
|
||||
}
|
||||
|
||||
if (this.isCountChanged || this.isRefresh) {
|
||||
@ -409,7 +406,7 @@ export class MediaDataSource extends AbsDataSource {
|
||||
}
|
||||
};
|
||||
this.photoDataImpl.getData(firstPatchDataCallback,
|
||||
{id: this.albumId, start: start, count: limit, deviceId: this.deviceId });
|
||||
{ id: this.albumId, start: start, count: limit, deviceId: this.deviceId });
|
||||
}
|
||||
|
||||
if (newActiveEnd < this.activeEnd && newActiveEnd > this.activeStart) {
|
||||
@ -428,7 +425,7 @@ export class MediaDataSource extends AbsDataSource {
|
||||
this.logger.info(`trigger data fetch start: ${requestStart}, count: ${requestCount}`);
|
||||
let callback: GetItemsCallback = new GetItemsCallback(this, requestStart);
|
||||
this.photoDataImpl.getData(callback,
|
||||
{id: this.albumId, start: requestStart, count: requestCount, deviceId: this.deviceId });
|
||||
{ id: this.albumId, start: requestStart, count: requestCount, deviceId: this.deviceId });
|
||||
}
|
||||
|
||||
private getWindowActiveStart(dataIndex: number, windowCenter: number): number{
|
||||
@ -521,7 +518,7 @@ export class MediaDataSource extends AbsDataSource {
|
||||
}
|
||||
|
||||
getIndexByMediaItem(item: MediaItem): number {
|
||||
for(let index = 0; index < this.items.length; index++) {
|
||||
for (let index = 0; index < this.items.length; index++) {
|
||||
if (item.uri == this.items[index].uri) {
|
||||
this.items[index] = item
|
||||
return index;
|
||||
@ -535,7 +532,7 @@ export class MediaDataSource extends AbsDataSource {
|
||||
}
|
||||
|
||||
onChange(mediaType: string) {
|
||||
if(this.deviceId == '' || this.deviceId == undefined) {
|
||||
if (this.deviceId == '' || this.deviceId == undefined) {
|
||||
if (mediaType == Constants.MEDIA_TYPE_IMAGE || mediaType == Constants.MEDIA_TYPE_VIDEO || mediaType == Constants.MEDIA_TYPE_ALBUM) {
|
||||
this.logger.debug(`local onChange ${mediaType}`);
|
||||
super.onChange(mediaType);
|
@ -48,7 +48,7 @@ export class MediaItem {
|
||||
this.duration = data.duration;
|
||||
this.title = data.title;
|
||||
this.size = data.size;
|
||||
this.dateTaken = data.dateAdded * DateUtil.MILLISECONDS_PER_SECOND; // TODO dateTaken is not supported, use dateAdded
|
||||
this.dateTaken = data.dateAdded * DateUtil.MILLISECONDS_PER_SECOND; // TODO dateTaken is not supported, use dateAdded
|
||||
this.dateModified = data.dateModified * DateUtil.MILLISECONDS_PER_SECOND;
|
||||
this.orientation = data.orientation;
|
||||
if (this.orientation == Constants.ANGLE_90 || this.orientation == Constants.ANGLE_270) {
|
@ -12,13 +12,13 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import {BrowserOperationInterface} from '../../../interface/BrowserOperationInterface'
|
||||
import {Logger} from '../../../utils/Logger'
|
||||
import {MediaLibraryAccess} from '../../../access/MediaLibraryAccess';
|
||||
import { BrowserOperationInterface } from '../../../interface/BrowserOperationInterface'
|
||||
import { Logger } from '../../../utils/Logger'
|
||||
import { MediaLibraryAccess } from '../../../access/MediaLibraryAccess';
|
||||
import fileio from '@ohos.fileio';
|
||||
import {AlbumDefine} from '../AlbumDefine'
|
||||
import {StringUtil} from '../../../utils/StringUtil'
|
||||
import {TraceControllerUtils} from '../../../utils/TraceControllerUtils';
|
||||
import { AlbumDefine } from '../AlbumDefine'
|
||||
import { StringUtil } from '../../../utils/StringUtil'
|
||||
import { TraceControllerUtils } from '../../../utils/TraceControllerUtils';
|
||||
|
||||
export class OperationImpl implements BrowserOperationInterface {
|
||||
logger: Logger = new Logger('OperationImpl');
|
||||
@ -29,7 +29,7 @@ export class OperationImpl implements BrowserOperationInterface {
|
||||
let fileAsset = (await MediaLibraryAccess.getInstance().getFirstObject(AlbumDefine.getFileFetchOptById(id))).obj
|
||||
fileAsset.favorite(isFavor);
|
||||
return true;
|
||||
} catch(e) {
|
||||
} catch (e) {
|
||||
this.logger.error(`favor error ${e}`);
|
||||
return false;
|
||||
}
|
||||
@ -80,7 +80,7 @@ export class OperationImpl implements BrowserOperationInterface {
|
||||
let fileAsset;
|
||||
if (isTrash) {
|
||||
fileAsset = (await MediaLibraryAccess.getInstance().getFirstObject(AlbumDefine.getFileFetchOptById(fileId))).obj;
|
||||
}else{
|
||||
} else {
|
||||
fileAsset = (await MediaLibraryAccess.getInstance().getTrashObject(AlbumDefine.getFileFetchOptById(fileId)))[0];
|
||||
}
|
||||
|
||||
@ -88,11 +88,11 @@ export class OperationImpl implements BrowserOperationInterface {
|
||||
this.logger.debug(`trash end: ${isTrash}`);
|
||||
}
|
||||
|
||||
async create(param: any){
|
||||
async create(param: any) {
|
||||
return await MediaLibraryAccess.getInstance().createAsset(param.mediaType, param.name, param.path);
|
||||
}
|
||||
|
||||
async commitChanges(file){
|
||||
async commitChanges(file) {
|
||||
await file.commitModify();
|
||||
}
|
||||
|
||||
@ -124,7 +124,7 @@ export class OperationImpl implements BrowserOperationInterface {
|
||||
}
|
||||
let step = 10000000;
|
||||
let last = stat.size % step;
|
||||
let count = (stat.size - last)/step;
|
||||
let count = (stat.size - last) / step;
|
||||
if (last > 0) {
|
||||
count = count + 1;
|
||||
}
|
@ -13,7 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {PendingCondition} from './PendingCondition'
|
||||
import { PendingCondition } from './PendingCondition'
|
||||
// Pending task queue
|
||||
export class PendingTask {
|
||||
private tasks: Function[] = new Array<Function>();
|
@ -13,19 +13,19 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {Logger} from '../../../utils/Logger'
|
||||
import {MediaDataSource} from './MediaDataSource'
|
||||
import {LoadingListener} from '../LoadingListener'
|
||||
import {BroadCast} from '../../../utils/BroadCast'
|
||||
import {Constants as PhotoConstants} from './Constants'
|
||||
import {MediaItem} from './MediaItem'
|
||||
import {Constants} from '../../common/Constants'
|
||||
import {PixelMapManager} from '../../common/PixelMapManager'
|
||||
import {BrowserDataFactory} from '../../../interface/BrowserDataFactory';
|
||||
import {AlbumDefine} from '../AlbumDefine'
|
||||
import {BroadCastManager} from '../../common/BroadCastManager';
|
||||
import {ImageUtil} from '../../../utils/ImageUtil';
|
||||
import {ScreenManager} from '../../common/ScreenManager';
|
||||
import { Logger } from '../../../utils/Logger'
|
||||
import { MediaDataSource } from './MediaDataSource'
|
||||
import { LoadingListener } from '../LoadingListener'
|
||||
import { BroadCast } from '../../../utils/BroadCast'
|
||||
import { Constants as PhotoConstants } from './Constants'
|
||||
import { MediaItem } from './MediaItem'
|
||||
import { Constants } from '../../common/Constants'
|
||||
import { PixelMapManager } from '../../common/PixelMapManager'
|
||||
import { BrowserDataFactory } from '../../../interface/BrowserDataFactory';
|
||||
import { AlbumDefine } from '../AlbumDefine'
|
||||
import { BroadCastManager } from '../../common/BroadCastManager';
|
||||
import { ImageUtil } from '../../../utils/ImageUtil';
|
||||
import { ScreenManager } from '../../common/ScreenManager';
|
||||
|
||||
// DataSource
|
||||
export class PhotoDataSource implements IDataSource, LoadingListener {
|
||||
@ -117,7 +117,7 @@ export class PhotoDataSource implements IDataSource, LoadingListener {
|
||||
return {
|
||||
data: mediaItem,
|
||||
pos: index,
|
||||
thumbnail: this.photoDataImpl.getThumbnail(mediaItem.uri, {height: imgHeight, width: imgWidth})
|
||||
thumbnail: this.photoDataImpl.getThumbnail(mediaItem.uri, { height: imgHeight, width: imgWidth })
|
||||
};
|
||||
}
|
||||
|
||||
@ -217,7 +217,7 @@ export class PhotoDataSource implements IDataSource, LoadingListener {
|
||||
this.albumDataSource.onChange(changeType);
|
||||
}
|
||||
|
||||
switchRefreshOn(){
|
||||
switchRefreshOn() {
|
||||
this.albumDataSource.switchRefreshOn();
|
||||
};
|
||||
|
@ -13,7 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {Releasable} from '../../common/Releasable'
|
||||
import { Releasable } from '../../common/Releasable'
|
||||
|
||||
/**
|
||||
* Thumbnail, view layer, data encapsulation
|
@ -12,12 +12,12 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import {BrowserDataImpl} from '../BrowserDataImpl'
|
||||
import {AsyncCallback} from '../../common/AsyncCallback'
|
||||
import {AlbumDefine} from '../AlbumDefine'
|
||||
import {TimelineData} from './TimelineData'
|
||||
import {DateUtil} from '../../../utils/DateUtil';
|
||||
import {MediaItem} from './MediaItem'
|
||||
import { BrowserDataImpl } from '../BrowserDataImpl'
|
||||
import { AsyncCallback } from '../../common/AsyncCallback'
|
||||
import { AlbumDefine } from '../AlbumDefine'
|
||||
import { TimelineData } from './TimelineData'
|
||||
import { DateUtil } from '../../../utils/DateUtil';
|
||||
import { MediaItem } from './MediaItem'
|
||||
|
||||
export class TimelineDataImpl extends BrowserDataImpl {
|
||||
getData(callback: AsyncCallback<TimelineData[]>, param): void{
|
||||
@ -38,7 +38,7 @@ export class TimelineDataImpl extends BrowserDataImpl {
|
||||
if (dataList != null) {
|
||||
if (dataList.length) {
|
||||
let groupCount = 1;
|
||||
let startTime = dataList[0].dateAdded * DateUtil.MILLISECONDS_PER_SECOND; // TODO dateTaken is not supported, use dateAdded
|
||||
let startTime = dataList[0].dateAdded * DateUtil.MILLISECONDS_PER_SECOND; // TODO dateTaken is not supported, use dateAdded
|
||||
let endTime = dataList[0].dateAdded * DateUtil.MILLISECONDS_PER_SECOND;
|
||||
for (let i = 1; i < dataList.length; i++) {
|
||||
let dateTaken = dataList[i].dateAdded * DateUtil.MILLISECONDS_PER_SECOND;
|
||||
@ -63,6 +63,7 @@ export class TimelineDataImpl extends BrowserDataImpl {
|
||||
callback.callback(groupDataList);
|
||||
})
|
||||
}
|
||||
|
||||
getDataCount(callback: AsyncCallback<number>, param): void {
|
||||
this.getItemsCount(param.id).then((count) => {
|
||||
this.logger.info(`getMediaItemCount callback: ${count}`);
|
||||
@ -70,6 +71,9 @@ export class TimelineDataImpl extends BrowserDataImpl {
|
||||
});
|
||||
}
|
||||
|
||||
getDataById(id: any, deviceId? :any): any{}
|
||||
getDataByName(name: string, albumInfo: any): any{}
|
||||
getDataById(id: any, deviceId?: any): any{
|
||||
}
|
||||
|
||||
getDataByName(name: string, albumInfo: any): any{
|
||||
}
|
||||
}
|
@ -13,23 +13,24 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {Logger} from '../../../utils/Logger'
|
||||
import {PhotoDataSource} from './PhotoDataSource';
|
||||
import {MediaItem} from './MediaItem'
|
||||
import {Constants as PhotoConstants} from './Constants'
|
||||
import {MediaLibraryAccess} from '../../../access/MediaLibraryAccess';
|
||||
import {ScreenManager} from '../../common/ScreenManager'
|
||||
import { Logger } from '../../../utils/Logger'
|
||||
import { PhotoDataSource } from './PhotoDataSource';
|
||||
import { MediaItem } from './MediaItem'
|
||||
import { Constants as PhotoConstants } from './Constants'
|
||||
import { MediaLibraryAccess } from '../../../access/MediaLibraryAccess';
|
||||
import { ScreenManager } from '../../common/ScreenManager'
|
||||
|
||||
class InnerMediaItem extends MediaItem {
|
||||
static readonly MEDIA_ABILITY = 'dataAbility';
|
||||
isHttp: boolean;
|
||||
|
||||
constructor(uri: string) {
|
||||
super({
|
||||
id: 0,
|
||||
mediaType: MediaLibraryAccess.MEDIA_TYPE_IMAGE,
|
||||
uri: uri,
|
||||
duration:0,
|
||||
title:"",
|
||||
duration: 0,
|
||||
title: "",
|
||||
size: PhotoConstants.DEFAULT_SIZE,
|
||||
thumbnail: uri,
|
||||
dateTaken: 0,
|
||||
@ -52,7 +53,7 @@ export class UriDataSource extends PhotoDataSource {
|
||||
private mItems: InnerMediaItem[] = [];
|
||||
private static readonly URL_TAG = '-UriDataSource';
|
||||
|
||||
constructor(uriArr:string[]) {
|
||||
constructor(uriArr: string[]) {
|
||||
super()
|
||||
this.mItems = uriArr.map((uri) => {
|
||||
let item = new InnerMediaItem(uri);
|
||||
@ -70,13 +71,18 @@ export class UriDataSource extends PhotoDataSource {
|
||||
this.logger.debug(`create items: ${JSON.stringify(this.mItems)}`);
|
||||
}
|
||||
|
||||
initData() {}
|
||||
initData() {
|
||||
}
|
||||
|
||||
totalCount(): number {
|
||||
return this.mItems.length;
|
||||
}
|
||||
|
||||
getData(index: number): { data:MediaItem, pos:number, thumbnail:string } {
|
||||
getData(index: number): {
|
||||
data: MediaItem,
|
||||
pos: number,
|
||||
thumbnail: string
|
||||
} {
|
||||
return {
|
||||
data: this.mItems[index],
|
||||
pos: index,
|
@ -13,9 +13,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {Logger} from '../../utils/Logger'
|
||||
import {BroadCast} from '../../utils/BroadCast'
|
||||
import {Constants} from './Constants'
|
||||
import { Logger } from '../../utils/Logger'
|
||||
import { BroadCast } from '../../utils/BroadCast'
|
||||
import { Constants } from './Constants'
|
||||
|
||||
export class BroadCastManager {
|
||||
private logger: Logger = new Logger('BroadCastManager');
|
@ -37,9 +37,7 @@ export class Constants {
|
||||
|
||||
// Default sliding window size
|
||||
static readonly DEFAULT_SLIDING_WIN_SIZE = 500;
|
||||
|
||||
static readonly DEFAULT_ROTATE_VALUE = 90;
|
||||
|
||||
static readonly ROTATE_AROUND = 360;
|
||||
static readonly ANGLE_90 = 90;
|
||||
static readonly ANGLE_270 = 270;
|
||||
@ -66,7 +64,6 @@ export class Constants {
|
||||
|
||||
// BroadCast
|
||||
static readonly APP_KEY_EVENT_BUS = 'app_key_event_bus';
|
||||
|
||||
static readonly SCREEN_MANAGER = 'screen_manager';
|
||||
static readonly PIXEL_MAP_MANAGER = 'pixel_map_manager';
|
||||
|
||||
@ -82,8 +79,7 @@ export class Constants {
|
||||
|
||||
// Large jump source: camera
|
||||
static readonly PHOTO_TRANSITION_CAMERA: string = 'Camera';
|
||||
|
||||
static readonly PHOTO_TRANSITION_EDIT: string = 'EditPage';
|
||||
static readonly PHOTO_TRANSITION_EDIT: string = 'EditPage';
|
||||
|
||||
// Timeline page index
|
||||
static readonly TIMELINE_PAGE_INDEX: number = 0;
|
||||
@ -111,11 +107,8 @@ export class Constants {
|
||||
|
||||
// Column flag
|
||||
static readonly SCREEN_COLUMNS: string = 'screen_columns';
|
||||
|
||||
static readonly ADD_NOTES_MAX_LENGTH: number = 140;
|
||||
|
||||
static readonly RENAME_MAX_LENGTH: number = 80;
|
||||
|
||||
static readonly ENTRY_FROM_NONE = 0;
|
||||
static readonly ENTRY_FROM_CAMERA = 1;
|
||||
static readonly ENTRY_FROM_SINGLE_SELECT = 2;
|
||||
@ -127,7 +120,6 @@ export class Constants {
|
||||
static readonly ENTRY_FROM_FORM_FORM_EDITOR = 8;
|
||||
static readonly ENTRY_FROM_VIEW_DATA = 9;
|
||||
static readonly ENTRY_FROM_FORM_ABILITY_NONE = 12;
|
||||
|
||||
static readonly ENTRY_FROM = {
|
||||
NORMAL: 0,
|
||||
CAMERA: 1,
|
||||
@ -138,7 +130,6 @@ export class Constants {
|
||||
CARD: 6,
|
||||
VIEW_DATA: 7
|
||||
}
|
||||
|
||||
static readonly DIALOG_BOTTOM_OFFSET: number = 16;
|
||||
|
||||
// Local tab index
|
||||
@ -176,7 +167,6 @@ export class Constants {
|
||||
static readonly UPDATE_TOUCH_EVENT: string = 'update_touch_event';
|
||||
static readonly PHOTO_COLLAGE_MANAGER: string = 'photo_collage_manager';
|
||||
static readonly RETURN_TO_MAIN: string = 'return_to_main';
|
||||
|
||||
static readonly NEGATIVE_FORTY: string = '-40.0°';
|
||||
static readonly NEGATIVE_THIRTY: string = '-30.0°';
|
||||
static readonly NEGATIVE_TWENTY: string = '-20.0°';
|
||||
@ -193,7 +183,6 @@ export class Constants {
|
||||
static readonly RULER_FILL_STYLE_90: string = "#E5FFFFFF";
|
||||
static readonly RULER_FILL_STYLE_40: string = '#66FFFFFF';
|
||||
static readonly RULER_TEXT_ALIGN: string = 'center';
|
||||
|
||||
static readonly MEDIA_TYPE_IMAGE: string = 'image';
|
||||
static readonly MEDIA_TYPE_VIDEO: string = 'video';
|
||||
static readonly MEDIA_TYPE_ALBUM: string = 'album';
|
||||
@ -202,7 +191,6 @@ export class Constants {
|
||||
static readonly DEVICE_STATE_ONLINE: string = 'online';
|
||||
static readonly DEVICE_STATE_OFFLINE: string = 'offline';
|
||||
static readonly DEVICE_STATE_CHANGE: string = 'change';
|
||||
|
||||
static readonly TOP_BAR_SIZE: number = 56;
|
||||
static readonly TOOL_BAR_SIZE: number = 72;
|
||||
static readonly BOTTOM_TOOL_BAR_SIZE: number = 196;
|
||||
@ -212,7 +200,7 @@ export class Constants {
|
||||
static readonly RESET_SIZE_HORIZONTAL: number = 48;
|
||||
static readonly TIMEOUT: number = 50;
|
||||
static readonly PADDING_VERTICAL: number = 140;
|
||||
static readonly PADDING_HORIZONTAL : number = 160;
|
||||
static readonly PADDING_HORIZONTAL: number = 160;
|
||||
static readonly MID_LINE_WIDTH: number = 1.5;
|
||||
static readonly MID_LINE_HEIGHT: number = 20;
|
||||
static readonly RULER_LINE_WIDTH: number = 1;
|
||||
@ -280,7 +268,6 @@ export class Constants {
|
||||
static readonly DETAILS_DIALOG_NAME_MAX_LINE: number = 5;
|
||||
static readonly PROGRESS_MAX: number = 100;
|
||||
static readonly BYTE_TO_MB: number = 1024 * 1024;
|
||||
|
||||
static readonly BIG_SCREEN_WIDTH: number = 600;
|
||||
static readonly BIG_EMPTY_ICON_SIZE: number = 160;
|
||||
static readonly SMALL_EMPTY_ICON_SIZE: number = 120;
|
||||
@ -301,7 +288,7 @@ export class Constants {
|
||||
static readonly FROM_CURRENT_INDEX: string = 'form_currentIndex';
|
||||
static readonly FA_SETTING_FROM_ID: string = 'FASetting_FormId';
|
||||
static readonly VIEW_DATA_URI: string = 'viewDataUri';
|
||||
static readonly VIEW_DATA_POS: string = 'viewDataPos';
|
||||
static readonly VIEW_DATA_POS: string = 'viewDataPos';
|
||||
static readonly PERMISSION_STATUS: string = 'permissionStatus';
|
||||
static readonly LEFT_BLANK: string = 'leftBlank';
|
||||
static readonly FROM_FORM_PHOTO_EDITOR: string = 'from_form_photo_editor';
|
||||
@ -310,13 +297,9 @@ export class Constants {
|
||||
static readonly FORM_ITEM_DISPLAY_NAME: string = 'form_itemDisplayName';
|
||||
static readonly MAIN_WINDOW: string = 'mainWindow';
|
||||
static readonly IS_SPLIT_MODE: string = 'isSplitMode';
|
||||
|
||||
static readonly ACTION_URI_FORM_ABILITY: string = 'formAbility';
|
||||
static readonly ACTION_URI_FORM_ABILITY_NONE: string = 'formAbilityNone';
|
||||
|
||||
static readonly PROGRESS_LENGTH_DIFF: number = 88;
|
||||
static readonly ALBUM_NAME_MAX_LENGTH = 80;
|
||||
|
||||
static readonly BACK_FROM_FORM_DETAIL: string = 'back_from_form_detail';
|
||||
|
||||
}
|
@ -13,7 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
import inputConsumer from '@ohos.multimodalInput.inputConsumer';
|
||||
import {Logger} from '../../utils/Logger';
|
||||
import { Logger } from '../../utils/Logger';
|
||||
|
||||
export class MultimodalInputManager {
|
||||
logger: Logger = new Logger('MultimodalInputManager');
|
||||
@ -33,7 +33,6 @@ export class MultimodalInputManager {
|
||||
'isFinalKeyDown': true,
|
||||
'finalKeyDownDuration': 0
|
||||
};
|
||||
|
||||
escKeyOptions: any = {
|
||||
'preKeys': [],
|
||||
'finalKey': 2070,
|
||||
@ -71,7 +70,6 @@ export class MultimodalInputManager {
|
||||
});
|
||||
this.logger.debug(`unregisterListener end`);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
let mMultimodalInputManager = new MultimodalInputManager();
|
@ -13,10 +13,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {FifoCache} from '../browser/photo/FifoCache'
|
||||
import {Thumbnail} from '../browser/photo/Thumbnail'
|
||||
import {Logger} from '../../utils/Logger'
|
||||
import {Constants} from './Constants'
|
||||
import { FifoCache } from '../browser/photo/FifoCache'
|
||||
import { Thumbnail } from '../browser/photo/Thumbnail'
|
||||
import { Logger } from '../../utils/Logger'
|
||||
import { Constants } from './Constants'
|
||||
|
||||
export class PixelMapManager {
|
||||
private logger: Logger = new Logger('PixelMapManager');
|
@ -13,9 +13,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {Logger} from '../../utils/Logger'
|
||||
import {Constants} from './Constants'
|
||||
import {UiUtil} from '../../utils/UiUtil'
|
||||
import { Logger } from '../../utils/Logger'
|
||||
import { Constants } from './Constants'
|
||||
import { UiUtil } from '../../utils/UiUtil'
|
||||
|
||||
export enum ColumnSize {
|
||||
COLUMN_TWO = 2,
|
||||
@ -42,8 +42,8 @@ export class ScreenManager {
|
||||
static readonly ON_WIN_SIZE_CHANGED = 'on_win_size_changed';
|
||||
static readonly ON_SPLIT_MODE_CHANGED = 'on_split_mode_changed';
|
||||
static readonly ON_LEFT_BLANK_CHANGED = 'on_left_blank_changed';
|
||||
static readonly DEFAULT_WIDTH : number = 1920;
|
||||
static readonly DEFAULT_HEIGHT : number = 1080;
|
||||
static readonly DEFAULT_WIDTH: number = 1920;
|
||||
static readonly DEFAULT_HEIGHT: number = 1080;
|
||||
private static readonly SPLIT_THRESHOLD = 1.7;
|
||||
private logger: Logger = new Logger('ScreenManager');
|
||||
private winWidth = 0.0;
|
||||
@ -77,7 +77,7 @@ export class ScreenManager {
|
||||
|
||||
async initializationSize(win): Promise<void> {
|
||||
this.mainWindow = win;
|
||||
let properties = await win.getProperties();
|
||||
let properties = await win.getProperties();
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
if (!properties || !properties.windowRect) {
|
||||
reject();
|
||||
@ -277,8 +277,13 @@ export class ScreenManager {
|
||||
if (!barContentColor) {
|
||||
barContentColor = '#FF000000';
|
||||
}
|
||||
topWindow.setSystemBarProperties({navigationBarColor: barColor, navigationBarContentColor: barContentColor},
|
||||
() => { this.logger.info('setStatusBarColor done'); });
|
||||
topWindow.setSystemBarProperties({
|
||||
navigationBarColor: barColor,
|
||||
navigationBarContentColor: barContentColor
|
||||
},
|
||||
() => {
|
||||
this.logger.info('setStatusBarColor done');
|
||||
});
|
||||
});
|
||||
});
|
||||
} catch (err) {
|
||||
@ -290,8 +295,10 @@ export class ScreenManager {
|
||||
this.logger.debug('setNavigationBarColor start');
|
||||
let topWindow: any = AppStorage.Get(Constants.MAIN_WINDOW);
|
||||
try {
|
||||
topWindow.setSystemBarProperties({navigationBarContentColor: resource},
|
||||
() => { this.logger.info('setStatusBarColor done'); });
|
||||
topWindow.setSystemBarProperties({ navigationBarContentColor: resource },
|
||||
() => {
|
||||
this.logger.info('setStatusBarColor done');
|
||||
});
|
||||
} catch (err) {
|
||||
this.logger.error(`setNavigationBarColor err: ${err}`);
|
||||
}
|
||||
@ -303,8 +310,10 @@ export class ScreenManager {
|
||||
let backColor = barColor == '' ? '#00000000' : barColor;
|
||||
let contentColor = barContentColor == '' ? '#ff000000' : barContentColor;
|
||||
try {
|
||||
topWindow.setSystemBarProperties({navigationBarColor: backColor, navigationBarContentColor: contentColor},
|
||||
() => { this.logger.info('setStatusBarColor done'); });
|
||||
topWindow.setSystemBarProperties({ navigationBarColor: backColor, navigationBarContentColor: contentColor },
|
||||
() => {
|
||||
this.logger.info('setStatusBarColor done');
|
||||
});
|
||||
} catch (err) {
|
||||
this.logger.error(`setNavigationBarColor err: ${err}`);
|
||||
}
|
@ -14,9 +14,9 @@
|
||||
*/
|
||||
|
||||
|
||||
import {UiUtil} from '../../utils/UiUtil'
|
||||
import {Logger} from '../../utils/Logger'
|
||||
import {Constants} from './Constants'
|
||||
import { UiUtil } from '../../utils/UiUtil'
|
||||
import { Logger } from '../../utils/Logger'
|
||||
import { Constants } from './Constants'
|
||||
|
||||
export enum StatusBarColorMode {
|
||||
NORMAL,
|
||||
@ -34,8 +34,7 @@ export class StatusBarColorController {
|
||||
UiUtil.getResourceString($r('app.color.default_background_color')).then((value) => {
|
||||
this.statusBarColor = value;
|
||||
this.logger.info(`statusBarColor: ${value}`);
|
||||
})
|
||||
.catch((error) => {
|
||||
}).catch((error) => {
|
||||
this.logger.error(`getResourceString error: ${error}`);
|
||||
})
|
||||
}
|
||||
@ -57,8 +56,8 @@ export class StatusBarColorController {
|
||||
this.logger.info(`invalidate mode: ${this.mode}`);
|
||||
switch (this.mode) {
|
||||
case StatusBarColorMode.TRANSPARENT:
|
||||
UiUtil.getResourceString($r('app.color.transparent')).then(() => {})
|
||||
.catch((error) => {
|
||||
UiUtil.getResourceString($r('app.color.transparent')).then(() => {
|
||||
}).catch((error) => {
|
||||
this.logger.error(`getResourceString for transparent color error: ${error}`);
|
||||
})
|
||||
break;
|
@ -50,7 +50,6 @@ export class TabItem {
|
||||
export class TabItemWithText {
|
||||
name: Resource;
|
||||
isSelected: boolean;
|
||||
|
||||
textSizeDefault: Resource = $r('sys.float.ohos_id_text_size_body1');
|
||||
textSizeSelected: Resource = $r('sys.float.ohos_id_text_size_sub_title2');
|
||||
textWeightDefault: FontWeight = FontWeight.Regular;
|
||||
@ -58,7 +57,7 @@ export class TabItemWithText {
|
||||
textColorDefault: Resource = $r('sys.color.ohos_id_color_bottom_tab_text_off');
|
||||
textColorSelected: Resource = $r('app.color.color_system_highlight');
|
||||
|
||||
constructor (name: Resource, isSelected: boolean) {
|
||||
constructor(name: Resource, isSelected: boolean) {
|
||||
this.name = name;
|
||||
this.isSelected = isSelected;
|
||||
}
|
||||
|
@ -12,13 +12,13 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import {Logger} from './Logger'
|
||||
import {Constants} from '../model/common/Constants'
|
||||
import { Logger } from './Logger'
|
||||
import { Constants } from '../model/common/Constants'
|
||||
import data_preferences from '@ohos.data.preferences'
|
||||
|
||||
export class DataStoreUtil {
|
||||
private logger: Logger = new Logger('DataStoreUtil');
|
||||
private context:any = undefined;
|
||||
private context: any = undefined;
|
||||
private preferences: any = undefined;
|
||||
private static readonly PREFERENCES_KEY_MY_FORM_STORE = 'myFormStore'
|
||||
|
||||
@ -28,10 +28,10 @@ export class DataStoreUtil {
|
||||
}
|
||||
|
||||
public static getInstance(context: any): DataStoreUtil {
|
||||
if (AppStorage.Get(Constants.FROM_DATA_STORE_UTIL) == null) {
|
||||
AppStorage.SetOrCreate(Constants.FROM_DATA_STORE_UTIL, new DataStoreUtil(context));
|
||||
}
|
||||
return AppStorage.Get(Constants.FROM_DATA_STORE_UTIL);
|
||||
if (AppStorage.Get(Constants.FROM_DATA_STORE_UTIL) == null) {
|
||||
AppStorage.SetOrCreate(Constants.FROM_DATA_STORE_UTIL, new DataStoreUtil(context));
|
||||
}
|
||||
return AppStorage.Get(Constants.FROM_DATA_STORE_UTIL);
|
||||
}
|
||||
|
||||
public async init(): Promise<void> {
|
||||
@ -40,17 +40,19 @@ export class DataStoreUtil {
|
||||
this.logger.debug('init already!');
|
||||
return;
|
||||
}
|
||||
await data_preferences.getPreferences(this.context, DataStoreUtil.PREFERENCES_KEY_MY_FORM_STORE).then((preferences) => {
|
||||
this.logger.info(`init preferences ${preferences}`);
|
||||
this.preferences = preferences;
|
||||
}).catch((err) => {
|
||||
this.logger.error(`init err ${err}`);
|
||||
})
|
||||
await data_preferences.getPreferences(this.context, DataStoreUtil.PREFERENCES_KEY_MY_FORM_STORE)
|
||||
.then((preferences) => {
|
||||
this.logger.info(`init preferences ${preferences}`);
|
||||
this.preferences = preferences;
|
||||
})
|
||||
.catch((err) => {
|
||||
this.logger.error(`init err ${err}`);
|
||||
})
|
||||
this.logger.debug('init end!');
|
||||
return;
|
||||
}
|
||||
|
||||
public async getData(key:string, defValue) {
|
||||
public async getData(key: string, defValue) {
|
||||
this.logger.debug('getData start!');
|
||||
if (this.preferences == undefined) {
|
||||
this.logger.error(`getData preferences is undefined`);
|
||||
@ -96,7 +98,6 @@ export class DataStoreUtil {
|
||||
await this.preferences.flush();
|
||||
}
|
||||
|
||||
|
||||
public async hasData(key: string) {
|
||||
this.logger.debug(`hasData start! preferences ${this.preferences}`);
|
||||
let ret = false;
|
||||
@ -117,11 +118,13 @@ export class DataStoreUtil {
|
||||
|
||||
public async removeCache() {
|
||||
this.logger.debug('removeCache start!');
|
||||
await data_preferences.removePreferencesFromCache(this.context, DataStoreUtil.PREFERENCES_KEY_MY_FORM_STORE).then(() => {
|
||||
this.preferences = undefined;
|
||||
console.info("removeCache successfully.")
|
||||
}).catch((err) => {
|
||||
console.error("removeCache failed with err: " + err)
|
||||
})
|
||||
await data_preferences.removePreferencesFromCache(this.context, DataStoreUtil.PREFERENCES_KEY_MY_FORM_STORE)
|
||||
.then(() => {
|
||||
this.preferences = undefined;
|
||||
console.info("removeCache successfully.")
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error("removeCache failed with err: " + err)
|
||||
})
|
||||
}
|
||||
}
|
@ -13,7 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {Logger} from './Logger'
|
||||
import { Logger } from './Logger'
|
||||
import i18n from '@ohos.i18n';
|
||||
import Intl from '@ohos.intl';
|
||||
|
||||
@ -98,7 +98,7 @@ export class DateUtil {
|
||||
let is24HourClock = i18n.is24HourClock();
|
||||
this.logger.info(`get is24HourClock ${is24HourClock}`);
|
||||
|
||||
return new Intl.DateTimeFormat(locales, this.buildDateTimeOpt('','','',(!is24HourClock ? '2-digit' : 'numeric'), '2-digit')).format(new Date(milliseconds));
|
||||
return new Intl.DateTimeFormat(locales, this.buildDateTimeOpt('', '', '', (!is24HourClock ? '2-digit' : 'numeric'), '2-digit')).format(new Date(milliseconds));
|
||||
}
|
||||
|
||||
static getLocales(): string {
|
||||
@ -166,7 +166,7 @@ export class DateUtil {
|
||||
return startYear === endYear ? true : false;
|
||||
}
|
||||
|
||||
public static buildDateTimeOpt(year: string, month: string, day: string, hour:string, minute: string){
|
||||
public static buildDateTimeOpt(year: string, month: string, day: string, hour: string, minute: string) {
|
||||
return {
|
||||
locale: '',
|
||||
dateStyle: '',
|
@ -13,7 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {Logger} from './Logger'
|
||||
import { Logger } from './Logger'
|
||||
|
||||
export class ImageUtil {
|
||||
static logger: Logger = new Logger('ImageUtil');
|
@ -17,13 +17,11 @@ const PHOTOS = 'Photos_'
|
||||
|
||||
export class Logger {
|
||||
prefix: string;
|
||||
|
||||
static readonly DEBUG = 0;
|
||||
static readonly LOG = 1;
|
||||
static readonly INFO = 2;
|
||||
static readonly WARN = 3;
|
||||
static readonly ERROR = 4;
|
||||
|
||||
static logLevel = Logger.DEBUG;
|
||||
|
||||
constructor(module: string) {
|
@ -13,7 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {Logger} from './Logger'
|
||||
import { Logger } from './Logger'
|
||||
|
||||
export class StringUtil {
|
||||
static logger: Logger = new Logger('StringUtil');
|
||||
@ -61,7 +61,7 @@ export class StringUtil {
|
||||
return result.substr(0, (result.length - connector.length));
|
||||
}
|
||||
|
||||
static getIdFromUri(uri:string): number {
|
||||
static getIdFromUri(uri: string): number {
|
||||
let srcIndex = uri.lastIndexOf('/');
|
||||
let srcEnd = uri.length;
|
||||
let srcId = uri.substring(srcIndex + 1, srcEnd);
|
@ -14,7 +14,7 @@
|
||||
*/
|
||||
|
||||
import i18n from '@ohos.i18n';
|
||||
import {Logger} from './Logger'
|
||||
import { Logger } from './Logger'
|
||||
|
||||
export class SystemUtil {
|
||||
static logger: Logger = new Logger('SystemUtil');
|
@ -1,3 +1,4 @@
|
||||
// @ts-nocheck
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@ -13,12 +14,12 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {MathUtil} from './MathUtil'
|
||||
import {Logger} from './Logger'
|
||||
import {Constants} from '../model/common/Constants';
|
||||
import { MathUtil } from './MathUtil'
|
||||
import { Logger } from './Logger'
|
||||
import { Constants } from '../model/common/Constants';
|
||||
import resourceManager from '@ohos.resourceManager';
|
||||
import prompt from '@system.prompt';
|
||||
import {ScreenManager} from '../model/common/ScreenManager';
|
||||
import { ScreenManager } from '../model/common/ScreenManager';
|
||||
|
||||
export class UiUtil {
|
||||
|
||||
@ -56,7 +57,6 @@ export class UiUtil {
|
||||
* Opacity length of hex color
|
||||
*/
|
||||
private static readonly HEX_COLOR_OPACITY_LENGTH = 2;
|
||||
|
||||
public static readonly TOAST_DURATION = 3000;
|
||||
|
||||
/**
|
||||
@ -101,11 +101,11 @@ export class UiUtil {
|
||||
names = [];
|
||||
}
|
||||
this.logger.debug(`getTopWindow names: ${names} end`);
|
||||
try{
|
||||
try {
|
||||
topWindow.setSystemBarEnable(names, () => {
|
||||
this.logger.debug('setFullScreen Succeeded');
|
||||
})
|
||||
}catch(err) {
|
||||
} catch (err) {
|
||||
this.logger.error(`setSystemUi err: ${err}`);
|
||||
}
|
||||
}
|
||||
@ -178,8 +178,10 @@ export class UiUtil {
|
||||
* @param statusBarColor statusBarColor
|
||||
*/
|
||||
static setStatusBarColor(topWindow): void {
|
||||
topWindow.setSystemBarProperties({navigationBarColor: '#FFF1F3F5', navigationBarContentColor: '#FF000000'},
|
||||
() => { this.logger.info('setStatusBarColor done'); });
|
||||
topWindow.setSystemBarProperties({ navigationBarColor: '#FFF1F3F5', navigationBarContentColor: '#FF000000' },
|
||||
() => {
|
||||
this.logger.info('setStatusBarColor done');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@ -235,7 +237,7 @@ export class UiUtil {
|
||||
static async getResourceString(resource: Resource) {
|
||||
try {
|
||||
this.logger.info(`getResourceString: ${JSON.stringify(resource)}`);
|
||||
let mgr:resourceManager.ResourceManager = await resourceManager.getResourceManager(globalThis.photosAbilityContext);
|
||||
let mgr: resourceManager.ResourceManager = await resourceManager.getResourceManager(globalThis.photosAbilityContext);
|
||||
if (mgr != null || mgr != undefined) {
|
||||
return await mgr.getString(resource.id);
|
||||
} else {
|
@ -12,7 +12,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import {Constants} from '../model/common/Constants'
|
||||
|
||||
@Component
|
||||
export struct GridScrollBar {
|
||||
@ -22,7 +21,7 @@ export struct GridScrollBar {
|
||||
|
||||
build() {
|
||||
ScrollBar({ scroller: this.scroller, direction: ScrollBarDirection.Vertical,
|
||||
state: this.isHideScrollBar? BarState.Off: BarState.Auto }) {
|
||||
state: this.isHideScrollBar ? BarState.Off : BarState.Auto }) {
|
||||
Row() {
|
||||
if (this.isClickScrollBar) {
|
||||
Image($r("app.media.scroll_press_light"))
|
||||
@ -38,12 +37,12 @@ export struct GridScrollBar {
|
||||
.height('100%')
|
||||
.width(this.isClickScrollBar
|
||||
? $r('app.float.scroll_bar_margin_small') : $r('app.float.scroll_bar_small_width'),)
|
||||
.position({x:'100%', y:0})
|
||||
.position({ x: '100%', y: 0 })
|
||||
.markAnchor({
|
||||
x: this.isClickScrollBar ? $r('app.float.scroll_bar_big_width') : $r('app.float.scroll_bar_small_width'),
|
||||
y: 0
|
||||
})
|
||||
.onTouch((event: TouchEvent)=> {
|
||||
.onTouch((event: TouchEvent) => {
|
||||
if (event.type == TouchType.Down) {
|
||||
this.isClickScrollBar = true;
|
||||
} else if (event.type == TouchType.Up) {
|
||||
|
@ -13,16 +13,15 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {Logger} from '../utils/Logger'
|
||||
import {Constants} from '../model/common/Constants'
|
||||
import {MediaItem} from '../model/browser/photo/MediaItem'
|
||||
import {DateUtil} from '../utils/DateUtil'
|
||||
import {BroadCast} from '../utils/BroadCast'
|
||||
import {BroadCastConstants} from '../model/common/BroadCastConstants'
|
||||
import image from '@ohos.multimedia.image'
|
||||
import {ImageUtil} from '../utils/ImageUtil'
|
||||
import {ScreenManager} from '../model/common/ScreenManager'
|
||||
import {TraceControllerUtils} from '../utils/TraceControllerUtils'
|
||||
import { Logger } from '../utils/Logger'
|
||||
import { Constants } from '../model/common/Constants'
|
||||
import { MediaItem } from '../model/browser/photo/MediaItem'
|
||||
import { DateUtil } from '../utils/DateUtil'
|
||||
import { BroadCast } from '../utils/BroadCast'
|
||||
import { BroadCastConstants } from '../model/common/BroadCastConstants'
|
||||
import { ImageUtil } from '../utils/ImageUtil'
|
||||
import { ScreenManager } from '../model/common/ScreenManager'
|
||||
import { TraceControllerUtils } from '../utils/TraceControllerUtils'
|
||||
import { MediaLibraryAccess } from '../access/MediaLibraryAccess';
|
||||
|
||||
// General grid picture control
|
||||
@ -130,8 +129,8 @@ export struct ImageGridItemComponent {
|
||||
selectStateChange() {
|
||||
this.logger.info('change selected.');
|
||||
let newState = !this.isSelected;
|
||||
if(this.item.uri) {
|
||||
this.broadCast.emit(BroadCastConstants.SELECT, [this.position, this.item.uri, newState, function() {
|
||||
if (this.item.uri) {
|
||||
this.broadCast.emit(BroadCastConstants.SELECT, [this.position, this.item.uri, newState, function(){
|
||||
this.logger.info('enter callback');
|
||||
this.isSelected = newState;
|
||||
}.bind(this)]);
|
||||
@ -161,7 +160,7 @@ export struct ImageGridItemComponent {
|
||||
.objectFit(ImageFit.Cover)
|
||||
.autoResize(false)
|
||||
.onError(() => {
|
||||
if(this.imageThumbnail) {
|
||||
if (this.imageThumbnail) {
|
||||
this.useAlt = true;
|
||||
}
|
||||
this.logger.error('alt Image error');
|
||||
@ -169,7 +168,7 @@ export struct ImageGridItemComponent {
|
||||
.onComplete(() => {
|
||||
this.logger.debug(`Draw the image! ${this.imageThumbnail}`);
|
||||
})
|
||||
}.sharedTransition(this.transitionId, {duration : Constants.SHARE_TRANSITION_DURATION})
|
||||
}.sharedTransition(this.transitionId, { duration: Constants.SHARE_TRANSITION_DURATION })
|
||||
|
||||
if (this.item.mediaType == MediaLibraryAccess.MEDIA_TYPE_VIDEO) {
|
||||
Column()
|
||||
@ -184,7 +183,10 @@ export struct ImageGridItemComponent {
|
||||
.fontColor($r('app.color.text_color_above_picture'))
|
||||
.lineHeight($r('app.float.grid_item_text_line_height'))
|
||||
.position({ x: '0%', y: '100%' })
|
||||
.markAnchor({ x: $r('app.float.grid_item_duration_markAnchor_x'), y: $r('app.float.grid_item_duration_markAnchor_y') })
|
||||
.markAnchor({
|
||||
x: $r('app.float.grid_item_duration_markAnchor_x'),
|
||||
y: $r('app.float.grid_item_duration_markAnchor_y')
|
||||
})
|
||||
.margin({ right: $r('app.float.grid_item_duration_margin_right') })
|
||||
}
|
||||
|
||||
@ -193,14 +195,17 @@ export struct ImageGridItemComponent {
|
||||
.width($r('app.float.icon_size'))
|
||||
.objectFit(ImageFit.Contain)
|
||||
.position({ x: '100%', y: '0%' })
|
||||
.markAnchor({ x: $r('app.float.grid_item_favor_markAnchor_x'), y: $r('app.float.grid_item_favor_markAnchor_y') })
|
||||
.markAnchor({
|
||||
x: $r('app.float.grid_item_favor_markAnchor_x'),
|
||||
y: $r('app.float.grid_item_favor_markAnchor_y')
|
||||
})
|
||||
.visibility(this.item.isFavor ? Visibility.Visible : Visibility.None)
|
||||
|
||||
Column()
|
||||
.height('100%')
|
||||
.width('100%')
|
||||
.backgroundColor(this.isSelected && this.isSelectedMode ?
|
||||
$r('app.color.item_selection_bg_color') : $r('app.color.transparent'))
|
||||
$r('app.color.item_selection_bg_color') : $r('app.color.transparent'))
|
||||
.onClick(() => {
|
||||
if (this.isSelectedMode) {
|
||||
this.selectStateChange();
|
||||
@ -233,45 +238,48 @@ export struct ImageGridItemComponent {
|
||||
.height($r('app.float.icon_size'))
|
||||
.width($r('app.float.icon_size'))
|
||||
.position({ x: '100%', y: '100%' })
|
||||
.markAnchor({ x: $r('app.float.grid_item_checkbox_markAnchor'), y: $r('app.float.grid_item_checkbox_markAnchor') })
|
||||
.markAnchor({
|
||||
x: $r('app.float.grid_item_checkbox_markAnchor'),
|
||||
y: $r('app.float.grid_item_checkbox_markAnchor')
|
||||
})
|
||||
.visibility(this.isSelectedMode ? Visibility.Visible : Visibility.None)
|
||||
.onClick(() => {
|
||||
this.selectStateChange();
|
||||
})
|
||||
}
|
||||
.gesture(
|
||||
LongPressGesture()
|
||||
.onAction((event: GestureEvent) => {
|
||||
this.logger.info(`LongPressGesture ${event}`);
|
||||
this.selectStateChange();
|
||||
this.pressAnimScale = 1;
|
||||
})
|
||||
LongPressGesture()
|
||||
.onAction((event: GestureEvent) => {
|
||||
this.logger.info(`LongPressGesture ${event}`);
|
||||
this.selectStateChange();
|
||||
this.pressAnimScale = 1;
|
||||
})
|
||||
)
|
||||
}
|
||||
.scale({
|
||||
x: this.pressAnimScale,
|
||||
y: this.pressAnimScale
|
||||
})
|
||||
.alignItems(HorizontalAlign.Start)
|
||||
.animation({
|
||||
duration: Constants.PRESS_ANIM_DURATION,
|
||||
curve: Curve.Ease
|
||||
})
|
||||
.onTouch(event => {
|
||||
this.logger.info(`onTouch trigger: isSelectedMode: ${this.isSelectedMode},
|
||||
.alignItems(HorizontalAlign.Start)
|
||||
.animation({
|
||||
duration: Constants.PRESS_ANIM_DURATION,
|
||||
curve: Curve.Ease
|
||||
})
|
||||
.onTouch(event => {
|
||||
this.logger.info(`onTouch trigger: isSelectedMode: ${this.isSelectedMode},
|
||||
isEnteringPhoto: ${this.isEnteringPhoto}, ${JSON.stringify(event)}`);
|
||||
if (this.isSelectedMode) {
|
||||
return;
|
||||
}
|
||||
if (this.isSelectedMode) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Press animation
|
||||
if (event.type == TouchType.Down) {
|
||||
this.pressAnimScale = Constants.PRESS_ANIM_SCALE;
|
||||
}
|
||||
// Press animation
|
||||
if (event.type == TouchType.Down) {
|
||||
this.pressAnimScale = Constants.PRESS_ANIM_SCALE;
|
||||
}
|
||||
|
||||
if (event.type == TouchType.Up && !this.isEnteringPhoto && this.pressAnimScale != 1) {
|
||||
this.pressAnimScale = 1;
|
||||
}
|
||||
})
|
||||
if (event.type == TouchType.Up && !this.isEnteringPhoto && this.pressAnimScale != 1) {
|
||||
this.pressAnimScale = 1;
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
@ -13,9 +13,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {ScreenManager} from '../model/common/ScreenManager'
|
||||
import {Constants} from '../model/common/Constants'
|
||||
import {Logger} from '../utils/Logger'
|
||||
import { ScreenManager } from '../model/common/ScreenManager'
|
||||
import { Constants } from '../model/common/Constants'
|
||||
import { Logger } from '../utils/Logger'
|
||||
|
||||
@Component
|
||||
export struct NoPhotoComponent {
|
||||
@ -32,13 +32,14 @@ export struct NoPhotoComponent {
|
||||
|
||||
aboutToAppear(): void {
|
||||
this.logger.info(`aboutToAppear`);
|
||||
this.bigScreen = Math.min(ScreenManager.getInstance().getWinHeight(), ScreenManager.getInstance().getWinWidth()) > Constants.BIG_SCREEN_WIDTH
|
||||
this.bigScreen = Math.min(ScreenManager.getInstance().getWinHeight(), ScreenManager.getInstance()
|
||||
.getWinWidth()) > Constants.BIG_SCREEN_WIDTH
|
||||
let halfImageHeight = this.bigScreen ? Constants.BIG_EMPTY_ICON_SIZE / 2 : Constants.SMALL_EMPTY_ICON_SIZE / 2
|
||||
let screenHeight = ScreenManager.getInstance().getWinHeight() - this.leftBlank[1] - this.leftBlank[3]
|
||||
if (this.isHorizontal) {
|
||||
if (this.isSidebar) {
|
||||
// Pad landscape
|
||||
this.offSetY = screenHeight / Constants.NUMBER_2 - halfImageHeight - Constants.ActionBarHeight;
|
||||
this.offSetY = screenHeight / Constants.NUMBER_2 - halfImageHeight - Constants.ActionBarHeight;
|
||||
} else {
|
||||
// Phone landscape
|
||||
this.offSetY = (screenHeight - Constants.ActionBarHeight) / Constants.NUMBER_2 - halfImageHeight;
|
||||
@ -46,7 +47,7 @@ export struct NoPhotoComponent {
|
||||
} else {
|
||||
// Phone vertical screen
|
||||
this.offSetY = screenHeight * Constants.EMPTY_PAGE_OFFSET_RADIO -
|
||||
Constants.ActionBarHeight - halfImageHeight;
|
||||
Constants.ActionBarHeight - halfImageHeight;
|
||||
}
|
||||
|
||||
this.logger.info(`isHorizontal: ${this.isHorizontal}, offSetY: ${this.offSetY}, bigScreen: ${this.bigScreen}`);
|
||||
@ -71,8 +72,8 @@ export struct NoPhotoComponent {
|
||||
.fontColor($r('app.color.tertiary_title_text_color'))
|
||||
}
|
||||
.width('100%')
|
||||
.offset({ x: 0, y: this.offSetY })
|
||||
.padding({ left: $r('app.float.max_padding_start'), right: $r('app.float.max_padding_start') })
|
||||
.offset({ x: 0, y: this.offSetY })
|
||||
.padding({ left: $r('app.float.max_padding_start'), right: $r('app.float.max_padding_start') })
|
||||
}
|
||||
.width('100%')
|
||||
}
|
||||
|
@ -13,9 +13,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {ScreenManager} from '../model/common/ScreenManager'
|
||||
import {Constants} from '../model/common/Constants'
|
||||
import {Logger} from '../utils/Logger'
|
||||
import { ScreenManager } from '../model/common/ScreenManager'
|
||||
import { Constants } from '../model/common/Constants'
|
||||
import { Logger } from '../utils/Logger'
|
||||
|
||||
const IMAGE_SCREEN_RATIO = 0.8
|
||||
|
||||
@ -42,7 +42,7 @@ export struct NoPhotoIndexComponent {
|
||||
let winWidth = ScreenManager.getInstance().getWinWidth();
|
||||
let winHeightHalf = ScreenManager.getInstance().getWinHeight() / 2;
|
||||
this.imageSize
|
||||
= (winWidth < winHeightHalf) ? (winWidth * IMAGE_SCREEN_RATIO) : (winHeightHalf * IMAGE_SCREEN_RATIO)
|
||||
= (winWidth < winHeightHalf) ? (winWidth * IMAGE_SCREEN_RATIO) : (winHeightHalf * IMAGE_SCREEN_RATIO)
|
||||
this.logger.info(`window size: ${winWidth}, ${winHeightHalf} ,empty photos or album picture size = ${this.imageSize}`);
|
||||
}
|
||||
|
||||
@ -89,7 +89,7 @@ export struct NoPhotoIndexComponent {
|
||||
}
|
||||
}
|
||||
.width('100%')
|
||||
.margin({ top: $r('app.float.appbar_max_height')})
|
||||
.margin({ top: $r('app.float.appbar_max_height') })
|
||||
}
|
||||
.width('100%')
|
||||
.height('100%')
|
||||
|
@ -12,7 +12,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import {Constants as PhotoConstants} from '../../common/model/browser/photo/Constants'
|
||||
import { Constants as PhotoConstants } from '../../common/model/browser/photo/Constants'
|
||||
|
||||
@Component
|
||||
export struct PhotoBrowserBg {
|
||||
@ -23,10 +23,10 @@ export struct PhotoBrowserBg {
|
||||
Column() {
|
||||
}
|
||||
.backgroundColor(this.backgroundColor)
|
||||
.width('100%')
|
||||
.height('100%')
|
||||
.animation({
|
||||
duration: PhotoConstants.IMMERSE_ANIM_DURATION
|
||||
})
|
||||
.width('100%')
|
||||
.height('100%')
|
||||
.animation({
|
||||
duration: PhotoConstants.IMMERSE_ANIM_DURATION
|
||||
})
|
||||
}
|
||||
}
|
@ -12,7 +12,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import {ScreenManager} from '../model/common/ScreenManager';
|
||||
import { ScreenManager } from '../model/common/ScreenManager';
|
||||
|
||||
@Component
|
||||
export struct PhotoBrowserHolder {
|
||||
@ -24,11 +24,11 @@ export struct PhotoBrowserHolder {
|
||||
Column() {
|
||||
}
|
||||
.backgroundColor($r('app.color.default_background_color'))
|
||||
.width('100%')
|
||||
.height(this.leftBlank[3])
|
||||
.markAnchor({x: '0%', y: '100%'})
|
||||
.position({x: '0%', y: '100%'})
|
||||
.opacity($r('app.float.photo_browser_holder_opacity'))
|
||||
.visibility(this.isShowBar ? Visibility.Visible : Visibility.Hidden)
|
||||
.width('100%')
|
||||
.height(this.leftBlank[3])
|
||||
.markAnchor({ x: '0%', y: '100%' })
|
||||
.position({ x: '0%', y: '100%' })
|
||||
.opacity($r('app.float.photo_browser_holder_opacity'))
|
||||
.visibility(this.isShowBar ? Visibility.Visible : Visibility.Hidden)
|
||||
}
|
||||
}
|
@ -14,16 +14,16 @@
|
||||
*/
|
||||
import Matrix4 from '@ohos.matrix4'
|
||||
import router from '@system.router'
|
||||
import {MediaItem} from '../../common/model/browser/photo/MediaItem'
|
||||
import {EventPipeline} from '../../common/model/browser/photo/EventPipeline'
|
||||
import {BroadCast} from '../../common/utils/BroadCast'
|
||||
import {Logger} from '../utils/Logger'
|
||||
import {Constants as PhotoConstants} from '../../common/model/browser/photo/Constants'
|
||||
import {MediaLibraryAccess} from '../../common/access/MediaLibraryAccess'
|
||||
import {ScreenManager} from '../model/common/ScreenManager'
|
||||
import {Constants} from '../model/common/Constants';
|
||||
import {TraceControllerUtils} from '../utils/TraceControllerUtils';
|
||||
import {LoadingPanel} from '../../feature/browser/view/photo/components/LoadingPanel'
|
||||
import { MediaItem } from '../../common/model/browser/photo/MediaItem'
|
||||
import { EventPipeline } from '../../common/model/browser/photo/EventPipeline'
|
||||
import { BroadCast } from '../../common/utils/BroadCast'
|
||||
import { Logger } from '../utils/Logger'
|
||||
import { Constants as PhotoConstants } from '../../common/model/browser/photo/Constants'
|
||||
import { MediaLibraryAccess } from '../../common/access/MediaLibraryAccess'
|
||||
import { ScreenManager } from '../model/common/ScreenManager'
|
||||
import { Constants } from '../model/common/Constants';
|
||||
import { TraceControllerUtils } from '../utils/TraceControllerUtils';
|
||||
import { LoadingPanel } from '../../feature/browser/view/photo/components/LoadingPanel'
|
||||
|
||||
@Component
|
||||
export struct PhotoItem {
|
||||
@ -48,7 +48,7 @@ export struct PhotoItem {
|
||||
@Provide isLoading: boolean = true;
|
||||
private imgScale: number = 1;
|
||||
private firstLoad: boolean = true;
|
||||
private preItem = {rotate: 0, height: 0, width: 0};
|
||||
private preItem = { rotate: 0, height: 0, width: 0 };
|
||||
|
||||
onTransitionChange() {
|
||||
this.logger.info(`onTransitionChange , ${this.updateTransition} ${this.position}`);
|
||||
@ -112,7 +112,7 @@ export struct PhotoItem {
|
||||
onViewDataChanged(): void {
|
||||
this.logger.info(`onViewDataChanged start`);
|
||||
if ((this.preItem.rotate == this.item.orientation && this.preItem.height == this.item.imgHeight &&
|
||||
this.preItem.width == this.item.imgWidth) && !this.firstLoad) {
|
||||
this.preItem.width == this.item.imgWidth) && !this.firstLoad) {
|
||||
this.preItem.rotate = this.item.orientation;
|
||||
this.preItem.width = this.item.imgWidth;
|
||||
this.preItem.height = this.item.imgHeight;
|
||||
@ -157,6 +157,7 @@ export struct PhotoItem {
|
||||
}
|
||||
.width('100%')
|
||||
.height('100%')
|
||||
|
||||
Flex({
|
||||
direction: FlexDirection.Row,
|
||||
alignItems: ItemAlign.Center,
|
||||
@ -191,157 +192,164 @@ export struct PhotoItem {
|
||||
.onClick(() => {
|
||||
this.broadCast.emit(PhotoConstants.TOGGLE_BAR, [null]);
|
||||
})
|
||||
.gesture(
|
||||
GestureGroup(GestureMode.Parallel,
|
||||
PinchGesture({
|
||||
fingers: 2,
|
||||
distance: 1
|
||||
})
|
||||
.onActionStart((event: GestureEvent) => {
|
||||
this.logger.debug('PinchGesture onActionStart');
|
||||
if (this.isPullingDown) {
|
||||
this.logger.debug('Not allow to pinch when pullingDown');
|
||||
return;
|
||||
}
|
||||
this.logger.debug(`PinchGesture onActionStart scale:\
|
||||
.gesture(
|
||||
GestureGroup(GestureMode.Parallel,
|
||||
PinchGesture({
|
||||
fingers: 2,
|
||||
distance: 1
|
||||
})
|
||||
.onActionStart((event: GestureEvent) => {
|
||||
this.logger.debug('PinchGesture onActionStart');
|
||||
if (this.isPullingDown) {
|
||||
this.logger.debug('Not allow to pinch when pullingDown');
|
||||
return;
|
||||
}
|
||||
this.logger.debug(`PinchGesture onActionStart scale:\
|
||||
${event.scale}, cx: ${event.pinchCenterX}, cy: ${event.pinchCenterY}`);
|
||||
if (this.item.mediaType == MediaLibraryAccess.MEDIA_TYPE_IMAGE) {
|
||||
this.eventPipeline.onScaleStart(event.scale, event.pinchCenterX, event.pinchCenterY);
|
||||
}
|
||||
})
|
||||
.onActionUpdate((event) => {
|
||||
this.logger.debug(`PinchGesture onActionUpdate scale: ${event.scale}`);
|
||||
if (this.isPullingDown) {
|
||||
this.logger.debug('Not allow to pinch when pullingDown');
|
||||
return;
|
||||
}
|
||||
if (this.item.mediaType == MediaLibraryAccess.MEDIA_TYPE_IMAGE) {
|
||||
this.eventPipeline.onScale(event.scale);
|
||||
}
|
||||
})
|
||||
.onActionEnd(() => {
|
||||
this.logger.debug('PinchGesture onActionEnd');
|
||||
if (this.isPullingDown) {
|
||||
this.logger.debug('Not allow to pinch when pullingDown');
|
||||
return;
|
||||
}
|
||||
if (this.item.mediaType == MediaLibraryAccess.MEDIA_TYPE_IMAGE) {
|
||||
this.eventPipeline.onScaleEnd();
|
||||
if (this.animationOption != null) {
|
||||
animateTo({
|
||||
duration: this.animationOption.duration,
|
||||
curve: this.animationOption.curve,
|
||||
onFinish: () => {
|
||||
this.eventPipeline.onAnimationEnd(this.animationEndMatrix);
|
||||
this.animationOption = null;
|
||||
this.animationEndMatrix = null;
|
||||
}
|
||||
}, () => {
|
||||
this.matrix = this.animationEndMatrix;
|
||||
})
|
||||
if (this.item.mediaType == MediaLibraryAccess.MEDIA_TYPE_IMAGE) {
|
||||
this.eventPipeline.onScaleStart(event.scale, event.pinchCenterX, event.pinchCenterY);
|
||||
}
|
||||
})
|
||||
.onActionUpdate((event) => {
|
||||
this.logger.debug(`PinchGesture onActionUpdate scale: ${event.scale}`);
|
||||
if (this.isPullingDown) {
|
||||
this.logger.debug('Not allow to pinch when pullingDown');
|
||||
return;
|
||||
}
|
||||
if (this.item.mediaType == MediaLibraryAccess.MEDIA_TYPE_IMAGE) {
|
||||
this.eventPipeline.onScale(event.scale);
|
||||
}
|
||||
})
|
||||
.onActionEnd(() => {
|
||||
this.logger.debug('PinchGesture onActionEnd');
|
||||
if (this.isPullingDown) {
|
||||
this.logger.debug('Not allow to pinch when pullingDown');
|
||||
return;
|
||||
}
|
||||
if (this.item.mediaType == MediaLibraryAccess.MEDIA_TYPE_IMAGE) {
|
||||
this.eventPipeline.onScaleEnd();
|
||||
if (this.animationOption != null) {
|
||||
animateTo({
|
||||
duration: this.animationOption.duration,
|
||||
curve: this.animationOption.curve,
|
||||
onFinish: () => {
|
||||
this.eventPipeline.onAnimationEnd(this.animationEndMatrix);
|
||||
this.animationOption = null;
|
||||
this.animationEndMatrix = null;
|
||||
}
|
||||
}
|
||||
}),
|
||||
PanGesture({
|
||||
direction: this.direction
|
||||
})
|
||||
.onActionStart((event: GestureEvent) => {
|
||||
this.logger.debug(`PanGesture start offsetX:\
|
||||
}, () => {
|
||||
this.matrix = this.animationEndMatrix;
|
||||
})
|
||||
}
|
||||
}
|
||||
}),
|
||||
PanGesture({
|
||||
direction: this.direction
|
||||
})
|
||||
.onActionStart((event: GestureEvent) => {
|
||||
this.logger.debug(`PanGesture start offsetX:\
|
||||
${vp2px(event.offsetX)}, offsetY: ${vp2px(event.offsetY)}`);
|
||||
this.eventPipeline.onMoveStart(vp2px(event.offsetX), vp2px(event.offsetY));
|
||||
})
|
||||
.onActionUpdate((event: GestureEvent) => {
|
||||
this.logger.debug(`PanGesture update offsetX:\
|
||||
this.eventPipeline.onMoveStart(vp2px(event.offsetX), vp2px(event.offsetY));
|
||||
})
|
||||
.onActionUpdate((event: GestureEvent) => {
|
||||
this.logger.debug(`PanGesture update offsetX:\
|
||||
${vp2px(event.offsetX)}, offsetY: ${vp2px(event.offsetY)}`);
|
||||
this.eventPipeline.onMove(vp2px(event.offsetX), vp2px(event.offsetY));
|
||||
})
|
||||
.onActionEnd((event: GestureEvent) => {
|
||||
this.logger.debug(`PanGesture end offsetX:\
|
||||
this.eventPipeline.onMove(vp2px(event.offsetX), vp2px(event.offsetY));
|
||||
})
|
||||
.onActionEnd((event: GestureEvent) => {
|
||||
this.logger.debug(`PanGesture end offsetX:\
|
||||
${vp2px(event.offsetX)}, offsetY: ${vp2px(event.offsetY)}`);
|
||||
this.eventPipeline.onMoveEnd(vp2px(event.offsetX), vp2px(event.offsetY));
|
||||
if (this.animationOption != null) {
|
||||
animateTo({
|
||||
duration: this.animationOption.duration,
|
||||
curve: this.animationOption.curve,
|
||||
onFinish: () => {
|
||||
this.eventPipeline.onAnimationEnd(this.animationEndMatrix);
|
||||
this.animationOption = null;
|
||||
this.animationEndMatrix = null;
|
||||
}
|
||||
}, () => {
|
||||
this.matrix = this.animationEndMatrix;
|
||||
})
|
||||
}
|
||||
}),
|
||||
TapGesture({
|
||||
count: 2
|
||||
})
|
||||
.onAction((event: GestureEvent) => {
|
||||
if (this.isPullingDown) {
|
||||
this.logger.debug('Not allow to double tap when pullingDown');
|
||||
return;
|
||||
}
|
||||
this.logger.debug(`onDoubleTap event: ${JSON.stringify(event)}`);
|
||||
if (this.item.mediaType == MediaLibraryAccess.MEDIA_TYPE_VIDEO) {
|
||||
return;
|
||||
}
|
||||
this.eventPipeline.onDoubleTap(event.fingerList[0].localX, event.fingerList[0].localY);
|
||||
if (this.animationOption != null) {
|
||||
this.logger.debug('TapGesture animateTo start');
|
||||
animateTo({
|
||||
duration: this.animationOption.duration,
|
||||
curve: this.animationOption.curve,
|
||||
onFinish: () => {
|
||||
this.eventPipeline.onAnimationEnd(this.animationEndMatrix);
|
||||
this.animationOption = null;
|
||||
this.animationEndMatrix = null;
|
||||
}
|
||||
}, () => {
|
||||
this.matrix = this.animationEndMatrix;
|
||||
})
|
||||
this.eventPipeline.onMoveEnd(vp2px(event.offsetX), vp2px(event.offsetY));
|
||||
if (this.animationOption != null) {
|
||||
animateTo({
|
||||
duration: this.animationOption.duration,
|
||||
curve: this.animationOption.curve,
|
||||
onFinish: () => {
|
||||
this.eventPipeline.onAnimationEnd(this.animationEndMatrix);
|
||||
this.animationOption = null;
|
||||
this.animationEndMatrix = null;
|
||||
}
|
||||
}, () => {
|
||||
this.matrix = this.animationEndMatrix;
|
||||
})
|
||||
)
|
||||
}
|
||||
}),
|
||||
TapGesture({
|
||||
count: 2
|
||||
})
|
||||
.onAction((event: GestureEvent) => {
|
||||
if (this.isPullingDown) {
|
||||
this.logger.debug('Not allow to double tap when pullingDown');
|
||||
return;
|
||||
}
|
||||
this.logger.debug(`onDoubleTap event: ${JSON.stringify(event)}`);
|
||||
if (this.item.mediaType == MediaLibraryAccess.MEDIA_TYPE_VIDEO) {
|
||||
return;
|
||||
}
|
||||
this.eventPipeline.onDoubleTap(event.fingerList[0].localX, event.fingerList[0].localY);
|
||||
if (this.animationOption != null) {
|
||||
this.logger.debug('TapGesture animateTo start');
|
||||
animateTo({
|
||||
duration: this.animationOption.duration,
|
||||
curve: this.animationOption.curve,
|
||||
onFinish: () => {
|
||||
this.eventPipeline.onAnimationEnd(this.animationEndMatrix);
|
||||
this.animationOption = null;
|
||||
this.animationEndMatrix = null;
|
||||
}
|
||||
}, () => {
|
||||
this.matrix = this.animationEndMatrix;
|
||||
})
|
||||
}
|
||||
})
|
||||
)
|
||||
)
|
||||
.clip(true)
|
||||
.onTouch((event) => {
|
||||
this.eventPipeline.onTouch(event);
|
||||
})
|
||||
.onTouch((event) => {
|
||||
this.eventPipeline.onTouch(event);
|
||||
})
|
||||
// TODO Remind users when pictures of other devices cannot be show
|
||||
if ((this.showError || this.item.mediaType == MediaLibraryAccess.MEDIA_TYPE_VIDEO) &&
|
||||
this.pageFrom == Constants.ENTRY_FROM.DISTRIBUTED) {
|
||||
this.pageFrom == Constants.ENTRY_FROM.DISTRIBUTED) {
|
||||
Row() {
|
||||
Text((this.item.mediaType == MediaLibraryAccess.MEDIA_TYPE_VIDEO) ?
|
||||
$r('app.string.no_distributed_photo_show_video') :
|
||||
$r('app.string.no_distributed_photo_show_image'))
|
||||
$r('app.string.no_distributed_photo_show_video') :
|
||||
$r('app.string.no_distributed_photo_show_image'))
|
||||
.fontSize($r('sys.float.ohos_id_text_size_body2'))
|
||||
.fontFamily($r('app.string.id_text_font_family_regular'))
|
||||
.fontColor($r('sys.color.ohos_id_color_text_tertiary'))
|
||||
}.margin({top: (this.item.mediaType == MediaLibraryAccess.MEDIA_TYPE_VIDEO) ? $r('app.float.input_text_notify_margin') : 0})
|
||||
}
|
||||
.margin({
|
||||
top: (this.item.mediaType == MediaLibraryAccess.MEDIA_TYPE_VIDEO) ? $r('app.float.input_text_notify_margin') : 0
|
||||
})
|
||||
}
|
||||
Row() {
|
||||
Image($r('app.media.ic_video_play_btn_png')).objectFit(ImageFit.Contain).width($r('app.float.icon_video_size'))
|
||||
.height($r('app.float.icon_video_size')).onClick(() => {
|
||||
if (this.item != undefined) {
|
||||
router.push({
|
||||
uri: 'feature/browser/view/photo/VideoBrowser',
|
||||
params: {
|
||||
uri: this.item.uri,
|
||||
dateTaken: this.item.dateTaken,
|
||||
previewUri: this.thumbnail
|
||||
}
|
||||
})
|
||||
}
|
||||
}).visibility(this.isVideoPlayBtnShow())
|
||||
Image($r('app.media.ic_video_play_btn_png'))
|
||||
.objectFit(ImageFit.Contain)
|
||||
.width($r('app.float.icon_video_size'))
|
||||
.height($r('app.float.icon_video_size'))
|
||||
.onClick(() => {
|
||||
if (this.item != undefined) {
|
||||
router.push({
|
||||
uri: 'feature/browser/view/photo/VideoBrowser',
|
||||
params: {
|
||||
uri: this.item.uri,
|
||||
dateTaken: this.item.dateTaken,
|
||||
previewUri: this.thumbnail
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
.visibility(this.isVideoPlayBtnShow())
|
||||
}
|
||||
}.width('100%')
|
||||
.height('100%')
|
||||
.sharedTransition(this.transitionId, {duration: PhotoConstants.SHARE_TRANSITION_DURATION})
|
||||
.sharedTransition(this.transitionId, { duration: PhotoConstants.SHARE_TRANSITION_DURATION })
|
||||
}
|
||||
|
||||
isVideoPlayBtnShow(): Visibility {
|
||||
this.logger.debug(`isVideoPlayBtnShow: ${this.item.mediaType}`);
|
||||
return ((this.item != undefined)
|
||||
&& (this.item.mediaType == MediaLibraryAccess.MEDIA_TYPE_VIDEO)) ? Visibility.Visible : Visibility.None;
|
||||
&& (this.item.mediaType == MediaLibraryAccess.MEDIA_TYPE_VIDEO)) ? Visibility.Visible : Visibility.None;
|
||||
}
|
||||
}
|
||||
|
@ -13,12 +13,12 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {PhotoItem} from './PhotoItem'
|
||||
import {BroadCastConstants} from '../model/common/BroadCastConstants';
|
||||
import {Logger} from '../../feature/browser/utils/Logger';
|
||||
import {BroadCast} from '../utils/BroadCast';
|
||||
import {Constants} from '../model/common/Constants';
|
||||
import {Constants as PhotoConstants} from '../../common/model/browser/photo/Constants'
|
||||
import { PhotoItem } from './PhotoItem'
|
||||
import { BroadCastConstants } from '../model/common/BroadCastConstants';
|
||||
import { Logger } from '../../feature/browser/utils/Logger';
|
||||
import { BroadCast } from '../utils/BroadCast';
|
||||
import { Constants } from '../model/common/Constants';
|
||||
import { Constants as PhotoConstants } from '../../common/model/browser/photo/Constants'
|
||||
|
||||
@Component
|
||||
export struct PhotoSwiper {
|
||||
@ -48,7 +48,7 @@ export struct PhotoSwiper {
|
||||
this.dataSource.onDataChanged(this.currentIndex + 2);
|
||||
}
|
||||
this.dataSource.onDataReloaded();
|
||||
}}, () => {
|
||||
} }, () => {
|
||||
this.dataSource.deleteData(this.currentIndex);
|
||||
})
|
||||
});
|
||||
@ -78,13 +78,13 @@ export struct PhotoSwiper {
|
||||
direction: PanDirection.Horizontal
|
||||
}))
|
||||
.index(this.currentIndex)
|
||||
.indicator(false)
|
||||
.loop(false)
|
||||
.onChange((index: number) => {
|
||||
if (this.duration != 0) {
|
||||
this.onPhotoChanged(index);
|
||||
}
|
||||
})
|
||||
.disableSwipe(this.canSwipe)
|
||||
.indicator(false)
|
||||
.loop(false)
|
||||
.onChange((index: number) => {
|
||||
if (this.duration != 0) {
|
||||
this.onPhotoChanged(index);
|
||||
}
|
||||
})
|
||||
.disableSwipe(this.canSwipe)
|
||||
}
|
||||
}
|
@ -13,12 +13,12 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {Logger} from '../utils/Logger'
|
||||
import {TabItem, TabItemWithText} from '../model/common/TabItem'
|
||||
import {BroadCastManager} from '../model/common/BroadCastManager'
|
||||
import {BroadCast} from '../utils/BroadCast'
|
||||
import {BroadCastConstants} from '../model/common/BroadCastConstants'
|
||||
import {Constants} from '../model/common/Constants'
|
||||
import { Logger } from '../utils/Logger'
|
||||
import { TabItem, TabItemWithText } from '../model/common/TabItem'
|
||||
import { BroadCastManager } from '../model/common/BroadCastManager'
|
||||
import { BroadCast } from '../utils/BroadCast'
|
||||
import { BroadCastConstants } from '../model/common/BroadCastConstants'
|
||||
import { Constants } from '../model/common/Constants'
|
||||
|
||||
export enum DEVICE_TYPE {
|
||||
DEVICE_PHONE,
|
||||
@ -40,7 +40,9 @@ export struct TabBar {
|
||||
aboutToAppear(): void {
|
||||
this.onTabSelected = this.onTabSelected.bind(this);
|
||||
this.tabs[this.currentIndex].isSelected = true;
|
||||
this.tabs.forEach((tab: TabItem) => {this.logger.info(`${JSON.stringify(tab.name)} , ${tab.iconSelected}`)});
|
||||
this.tabs.forEach((tab: TabItem) => {
|
||||
this.logger.info(`${JSON.stringify(tab.name)} , ${tab.iconSelected}`)
|
||||
});
|
||||
}
|
||||
|
||||
private onTabSelected(index: number) {
|
||||
@ -74,10 +76,10 @@ export struct TabBar {
|
||||
}
|
||||
.height(DEVICE_TYPE.DEVICE_PAD == this.deviceType ? $r('app.float.horizontal_width') : '100%')
|
||||
}
|
||||
.markAnchor({x: '0%', y: '0%'})
|
||||
.position({x: '0%', y: '0%'})
|
||||
.markAnchor({ x: '0%', y: '0%' })
|
||||
.position({ x: '0%', y: '0%' })
|
||||
.width($r('app.float.tab_bar_width'))
|
||||
.backgroundColor($r('app.color.default_background_color'))
|
||||
.backgroundColor($r('app.color.default_background_color'))
|
||||
} else {
|
||||
Flex({
|
||||
direction: FlexDirection.Row,
|
||||
@ -90,8 +92,8 @@ export struct TabBar {
|
||||
}.layoutWeight(1)
|
||||
}, tab => tab.name.id)
|
||||
}
|
||||
.markAnchor({x: '0%', y: '100%'})
|
||||
.position({x: '0%', y: '100%'})
|
||||
.markAnchor({ x: '0%', y: '100%' })
|
||||
.position({ x: '0%', y: '100%' })
|
||||
.visibility((this.isSelectedMode || this.isAlbumSetSelectedMode) ? Visibility.None : Visibility.Visible)
|
||||
.height('56vp')
|
||||
.backgroundColor($r('app.color.default_background_color'))
|
||||
@ -129,10 +131,10 @@ struct Tab {
|
||||
left: $r('app.float.tab_bar_text_padding_horizontal')
|
||||
})
|
||||
}
|
||||
.onClick(() => {
|
||||
this.onTabSelected && this.onTabSelected(this.index);
|
||||
this.tabItem.isSelected = true;
|
||||
})
|
||||
.onClick(() => {
|
||||
this.onTabSelected && this.onTabSelected(this.index);
|
||||
this.tabItem.isSelected = true;
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@ -157,7 +159,7 @@ export struct TabBarForAlbumSet {
|
||||
this.logger.info(`this.currentIndex: ${this.currentIndex} index: ${index}`);
|
||||
this.currentIndex = index;
|
||||
this.controller.changeIndex(this.currentIndex);
|
||||
this.tabs.forEach((tab:TabItemWithText) => {
|
||||
this.tabs.forEach((tab: TabItemWithText) => {
|
||||
tab.isSelected = false;
|
||||
})
|
||||
this.logger.info(`select ${this.currentIndex}`);
|
||||
@ -170,13 +172,13 @@ export struct TabBarForAlbumSet {
|
||||
alignItems: ItemAlign.Start
|
||||
}) {
|
||||
ForEach(this.tabs, (tab: TabItemWithText) => {
|
||||
TabWithText({tabItemWithText: tab, index: this.tabs.indexOf(tab), onTabSelected: this.onTabSelected})
|
||||
TabWithText({ tabItemWithText: tab, index: this.tabs.indexOf(tab), onTabSelected: this.onTabSelected })
|
||||
}, tab => tab.name.id)
|
||||
}
|
||||
.width('100%')
|
||||
.visibility(this.isTabBarShow ? Visibility.Visible : Visibility.None)
|
||||
.height($r('app.float.album_set_tab_bar_height'))
|
||||
.padding({left: $r('app.float.max_padding_start'), right: $r('app.float.max_padding_end')})
|
||||
.padding({ left: $r('app.float.max_padding_start'), right: $r('app.float.max_padding_end') })
|
||||
.backgroundColor($r('app.color.default_background_color'))
|
||||
}
|
||||
}
|
||||
@ -213,10 +215,10 @@ struct TabWithText {
|
||||
.fontWeight(this.tabItemWithText.getTextWeight())
|
||||
.fontColor(this.tabItemWithText.getTextColor())
|
||||
.maxLines(1)
|
||||
.margin({top: $r('app.float.tab_bar_line_margin_top'),
|
||||
.margin({ top: $r('app.float.tab_bar_line_margin_top'),
|
||||
left: $r('app.float.single_tab_margin'),
|
||||
right: $r('app.float.single_tab_margin'),
|
||||
bottom: $r('app.float.tab_bar_line_margin_top')})
|
||||
bottom: $r('app.float.tab_bar_line_margin_top') })
|
||||
Column()
|
||||
.width(this.TabWidth)
|
||||
.height($r('app.float.tab_bar_line_height'))
|
||||
|
@ -13,12 +13,12 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {Action} from './browserOperation/Action'
|
||||
import {ActionBar} from './actionbar/ActionBar'
|
||||
import {ActionBarProp} from './browserOperation/ActionBarProp'
|
||||
import {ActionBarMode, ActionBarColorMode, ActionBarSelectionMode} from './browserOperation/ActionBarMode'
|
||||
import {Logger} from '../utils/Logger'
|
||||
import {ScreenManager} from '../model/common/ScreenManager';
|
||||
import { Action } from './browserOperation/Action'
|
||||
import { ActionBar } from './actionbar/ActionBar'
|
||||
import { ActionBarProp } from './browserOperation/ActionBarProp'
|
||||
import { ActionBarMode, ActionBarColorMode, ActionBarSelectionMode } from './browserOperation/ActionBarMode'
|
||||
import { Logger } from '../utils/Logger'
|
||||
import { ScreenManager } from '../model/common/ScreenManager';
|
||||
|
||||
@Component
|
||||
export struct ThirdSelectPhotoBrowserActionBar {
|
||||
@ -53,7 +53,7 @@ export struct ThirdSelectPhotoBrowserActionBar {
|
||||
onMenuClicked: this.onMenuClicked
|
||||
})
|
||||
}
|
||||
.markAnchor({x: '0%', y: '0%'})
|
||||
.position({x: '0%', y: this.leftBlank[1]})
|
||||
.markAnchor({ x: '0%', y: '0%' })
|
||||
.position({ x: '0%', y: this.leftBlank[1] })
|
||||
}
|
||||
}
|
@ -13,17 +13,17 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {Logger} from '../../utils/Logger'
|
||||
import {ActionBarProp} from '../browserOperation/ActionBarProp'
|
||||
import {Action} from '../browserOperation/Action'
|
||||
import {ActionBarMode} from '../browserOperation/ActionBarMode'
|
||||
import {SingleTitle} from './SingleTitle'
|
||||
import {DetailTitle} from './DetailTitle'
|
||||
import {SelectionTitle} from './SelectionTitle'
|
||||
import {MenuPanel} from './MenuPanel'
|
||||
import {DetailMenuPanel} from './DetailMenuPanel'
|
||||
import {Constants} from '../../model/common/Constants'
|
||||
import {ActionBarButton} from './ActionBarButton'
|
||||
import { Logger } from '../../utils/Logger'
|
||||
import { ActionBarProp } from '../browserOperation/ActionBarProp'
|
||||
import { Action } from '../browserOperation/Action'
|
||||
import { ActionBarMode } from '../browserOperation/ActionBarMode'
|
||||
import { SingleTitle } from './SingleTitle'
|
||||
import { DetailTitle } from './DetailTitle'
|
||||
import { SelectionTitle } from './SelectionTitle'
|
||||
import { MenuPanel } from './MenuPanel'
|
||||
import { DetailMenuPanel } from './DetailMenuPanel'
|
||||
import { Constants } from '../../model/common/Constants'
|
||||
import { ActionBarButton } from './ActionBarButton'
|
||||
|
||||
// ActionBar,It consists of action on the left, title in the middle and menu panel on the right
|
||||
@Component
|
||||
@ -58,32 +58,35 @@ export struct ActionBar {
|
||||
if (this.actionBarProp.getMode() === ActionBarMode.DETAIL_MODE) {
|
||||
DetailMenuPanel({ actionBarProp: this.actionBarProp, onMenuClicked: this.onMenuClicked, isLeft: true })
|
||||
} else if (this.actionBarProp.getMode() === ActionBarMode.SELECTION_MODE) {
|
||||
Stack({alignContent: Alignment.Start}) {
|
||||
Stack({ alignContent: Alignment.Start }) {
|
||||
SelectionTitle({ actionBarProp: this.actionBarProp })
|
||||
}.flexGrow(1)
|
||||
|
||||
MenuPanel({ actionBarProp: this.actionBarProp, onMenuClicked: this.onMenuClicked })
|
||||
} else if (this.actionBarProp.getMode() === ActionBarMode.TOP_MODE) {
|
||||
Stack({alignContent: Alignment.Start}) {
|
||||
DetailTitle({isVideoPage: this.isVideoPage})
|
||||
Stack({ alignContent: Alignment.Start }) {
|
||||
DetailTitle({ isVideoPage: this.isVideoPage })
|
||||
}.flexGrow(1)
|
||||
|
||||
DetailMenuPanel({ actionBarProp: this.actionBarProp, onMenuClicked: this.onMenuClicked, isLeft: false })
|
||||
} else {
|
||||
Stack({ alignContent: Alignment.Start }) {
|
||||
SingleTitle({ actionBarProp: this.actionBarProp })
|
||||
}.flexGrow(1)
|
||||
|
||||
MenuPanel({ actionBarProp: this.actionBarProp, onMenuClicked: this.onMenuClicked })
|
||||
}
|
||||
}
|
||||
.height(Constants.ActionBarHeight)
|
||||
.zIndex(3)
|
||||
.width('100%')
|
||||
.backgroundColor(this.actionBarProp.getBackgroundColor())
|
||||
.opacity(this.actionBarProp.getAlpha())
|
||||
.padding({ right: $r('app.float.default_actionbar_padding_right'),
|
||||
left: (this.hasTabBar ?
|
||||
$r('app.float.default_padding_start_with_tab_bar') :
|
||||
$r('app.float.default_actionbar_padding_start_without_tab_bar'))
|
||||
})
|
||||
.visibility(this.isShowBar ? Visibility.Visible : Visibility.Hidden)
|
||||
.zIndex(3)
|
||||
.width('100%')
|
||||
.backgroundColor(this.actionBarProp.getBackgroundColor())
|
||||
.opacity(this.actionBarProp.getAlpha())
|
||||
.padding({ right: $r('app.float.default_actionbar_padding_right'),
|
||||
left: (this.hasTabBar ?
|
||||
$r('app.float.default_padding_start_with_tab_bar') :
|
||||
$r('app.float.default_actionbar_padding_start_without_tab_bar'))
|
||||
})
|
||||
.visibility(this.isShowBar ? Visibility.Visible : Visibility.Hidden)
|
||||
}
|
||||
}
|
@ -13,10 +13,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {Action} from '../browserOperation/Action'
|
||||
import {ActionBarColorMode} from '../browserOperation/ActionBarMode'
|
||||
import {ScreenManager, ColumnSize} from '../../model/common/ScreenManager';
|
||||
import {Constants} from '../../model/common/Constants';
|
||||
import { Action } from '../browserOperation/Action'
|
||||
import { ActionBarColorMode } from '../browserOperation/ActionBarMode'
|
||||
import { ScreenManager, ColumnSize } from '../../model/common/ScreenManager';
|
||||
import { Constants } from '../../model/common/Constants';
|
||||
|
||||
@Component
|
||||
export struct ActionBarButton {
|
||||
@ -31,7 +31,8 @@ export struct ActionBarButton {
|
||||
@State showPopup: boolean = false
|
||||
@Consume moreMenuList: Action[];
|
||||
|
||||
aboutToAppear(): void {}
|
||||
aboutToAppear(): void {
|
||||
}
|
||||
|
||||
@Builder PopupBuilder() {
|
||||
Column() {
|
||||
@ -54,13 +55,13 @@ export struct ActionBarButton {
|
||||
}, menu => (menu.actionType != null ? menu.actionType.id : menu.actionID))
|
||||
}.width(ScreenManager.getInstance().getColumnsWidth(ColumnSize.COLUMN_TWO))
|
||||
.borderRadius($r('sys.float.ohos_id_corner_radius_default_l'))
|
||||
.padding({
|
||||
top: $r('app.float.menu_padding_vertical'),
|
||||
bottom: $r('app.float.menu_padding_vertical'),
|
||||
left: $r('app.float.menu_padding_horizontal'),
|
||||
right: $r('app.float.menu_padding_horizontal')
|
||||
})
|
||||
.backgroundColor(Color.White)
|
||||
.padding({
|
||||
top: $r('app.float.menu_padding_vertical'),
|
||||
bottom: $r('app.float.menu_padding_vertical'),
|
||||
left: $r('app.float.menu_padding_horizontal'),
|
||||
right: $r('app.float.menu_padding_horizontal')
|
||||
})
|
||||
.backgroundColor(Color.White)
|
||||
}
|
||||
|
||||
@Builder ActionBarButtonBuilder() {
|
||||
@ -82,8 +83,8 @@ export struct ActionBarButton {
|
||||
}
|
||||
}
|
||||
.height($r('app.float.default_button_size'))
|
||||
.width($r('app.float.default_button_size'))
|
||||
.margin({ left: (this.action == Action.NAVIGATION) ? $r('app.float.max_padding_start') : 0 })
|
||||
.width($r('app.float.default_button_size'))
|
||||
.margin({ left: (this.action == Action.NAVIGATION) ? $r('app.float.max_padding_start') : 0 })
|
||||
}
|
||||
|
||||
build() {
|
||||
@ -94,18 +95,18 @@ export struct ActionBarButton {
|
||||
.onClick(() => {
|
||||
this.showPopup = !this.showPopup
|
||||
})
|
||||
.bindPopup(this.showPopup, {
|
||||
builder: this.PopupBuilder,
|
||||
placement: Placement.Top,
|
||||
maskColor: 0x33000000,
|
||||
popupColor: '#00FFFFFF',
|
||||
enableArrow: false,
|
||||
onStateChange: (e) => {
|
||||
if (!e.isVisible) {
|
||||
this.showPopup = false
|
||||
}
|
||||
.bindPopup(this.showPopup, {
|
||||
builder: this.PopupBuilder,
|
||||
placement: Placement.Top,
|
||||
maskColor: 0x33000000,
|
||||
popupColor: '#00FFFFFF',
|
||||
enableArrow: false,
|
||||
onStateChange: (e) => {
|
||||
if (!e.isVisible) {
|
||||
this.showPopup = false
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
} else {
|
||||
Row() {
|
||||
this.ActionBarButtonBuilder()
|
||||
|
@ -13,10 +13,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {Logger} from '../../utils/Logger'
|
||||
import {ActionBarProp} from '../browserOperation/ActionBarProp'
|
||||
import {Action} from '../browserOperation/Action'
|
||||
import {ActionBarButton} from './ActionBarButton'
|
||||
import { Logger } from '../../utils/Logger'
|
||||
import { ActionBarProp } from '../browserOperation/ActionBarProp'
|
||||
import { Action } from '../browserOperation/Action'
|
||||
import { ActionBarButton } from './ActionBarButton'
|
||||
|
||||
// Large picture button for dynamic refresh
|
||||
@Component
|
||||
|
@ -13,8 +13,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {Logger} from '../../utils/Logger'
|
||||
import {ActionBarProp} from '../browserOperation/ActionBarProp'
|
||||
import { Logger } from '../../utils/Logger'
|
||||
import { ActionBarProp } from '../browserOperation/ActionBarProp'
|
||||
|
||||
// Large picture title, including primary date title and secondary time and place title
|
||||
@Component
|
||||
@ -47,9 +47,9 @@ export struct DetailTitle {
|
||||
.textOverflow({ overflow: TextOverflow.Ellipsis })
|
||||
}
|
||||
.constraintSize({ minHeight: ('app.float.detail_title_constraint_size_min_height') })
|
||||
.alignItems(HorizontalAlign.Start)
|
||||
.alignItems(HorizontalAlign.Start)
|
||||
}.margin({ left: $r('app.float.actionbar_title_margin'),
|
||||
right: $r('app.float.actionbar_title_margin') })
|
||||
.alignItems(VerticalAlign.Center)
|
||||
.alignItems(VerticalAlign.Center)
|
||||
}
|
||||
}
|
@ -13,10 +13,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {Logger} from '../../utils/Logger'
|
||||
import {ActionBarProp} from '../browserOperation/ActionBarProp'
|
||||
import {Action} from '../browserOperation/Action'
|
||||
import {ActionBarButton} from './ActionBarButton'
|
||||
import { Logger } from '../../utils/Logger'
|
||||
import { ActionBarProp } from '../browserOperation/ActionBarProp'
|
||||
import { Action } from '../browserOperation/Action'
|
||||
import { ActionBarButton } from './ActionBarButton'
|
||||
|
||||
// MenuPanel,Right menu button panel
|
||||
@Component
|
||||
|
@ -13,9 +13,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {ActionBarColorMode, ActionBarSelectionMode} from '../browserOperation/ActionBarMode'
|
||||
import {Logger} from '../../utils/Logger'
|
||||
import {ActionBarProp} from '../browserOperation/ActionBarProp'
|
||||
import { ActionBarColorMode, ActionBarSelectionMode } from '../browserOperation/ActionBarMode'
|
||||
import { Logger } from '../../utils/Logger'
|
||||
import { ActionBarProp } from '../browserOperation/ActionBarProp'
|
||||
|
||||
// Select the mode title, the content changes with the number of selections
|
||||
@Component
|
||||
@ -33,9 +33,9 @@ export struct SelectionTitle {
|
||||
Text((this.actionBarProp.getSelectionMode() == ActionBarSelectionMode.MULTI ?
|
||||
(this.count == 0 ? ActionBarProp.MULTI_UNSELECT_TITLE :
|
||||
(this.actionBarProp.getMaxSelectCount() > 0 ?
|
||||
ActionBarProp.getCountDetailExternalSelectedTitle(this.count,
|
||||
this.actionBarProp.getMaxSelectCount()) :
|
||||
ActionBarProp.getCountDetailSelectedTitle(this.count))) :
|
||||
ActionBarProp.getCountDetailExternalSelectedTitle(this.count,
|
||||
this.actionBarProp.getMaxSelectCount()) :
|
||||
ActionBarProp.getCountDetailSelectedTitle(this.count))) :
|
||||
ActionBarProp.SINGLE_UNSELECT_TITLE))
|
||||
.fontSize(ActionBarProp.TITLE_TEXT_SIZE)
|
||||
.fontWeight(FontWeight.Bold)
|
||||
@ -46,6 +46,6 @@ export struct SelectionTitle {
|
||||
}
|
||||
.margin({ left: $r('app.float.actionbar_title_margin'),
|
||||
right: $r('app.float.actionbar_title_margin') })
|
||||
.alignItems(VerticalAlign.Center)
|
||||
.alignItems(VerticalAlign.Center)
|
||||
}
|
||||
}
|
@ -13,9 +13,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {Logger} from '../../utils/Logger'
|
||||
import {ActionBarProp} from '../browserOperation/ActionBarProp'
|
||||
import {Action} from '../browserOperation/Action';
|
||||
import { Logger } from '../../utils/Logger'
|
||||
import { ActionBarProp } from '../browserOperation/ActionBarProp'
|
||||
import { Action } from '../browserOperation/Action';
|
||||
|
||||
// Single line title, fixed content
|
||||
@Component
|
||||
@ -39,10 +39,10 @@ export struct SingleTitle {
|
||||
}
|
||||
.width('80%')
|
||||
.alignItems(VerticalAlign.Center)
|
||||
.padding({
|
||||
left: this.actionBarProp.getLeftAction().equals(Action.NONE) ?
|
||||
$r('app.float.default_actionbar_padding_start_without_tab_bar') :
|
||||
$r('app.float.actionbar_title_margin')
|
||||
})
|
||||
.padding({
|
||||
left: this.actionBarProp.getLeftAction().equals(Action.NONE) ?
|
||||
$r('app.float.default_actionbar_padding_start_without_tab_bar') :
|
||||
$r('app.float.actionbar_title_margin')
|
||||
})
|
||||
}
|
||||
}
|
@ -13,12 +13,12 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {ScreenManager,ColumnSize} from '../../model/common/ScreenManager'
|
||||
import {ToolBarButton} from './ToolBarButton'
|
||||
import {Constants} from '../../model/common/Constants'
|
||||
import {ActionBarProp} from '../browserOperation/ActionBarProp'
|
||||
import {Action} from '../browserOperation/Action'
|
||||
import {ActionBarMode} from '../browserOperation/ActionBarMode'
|
||||
import { ScreenManager, ColumnSize } from '../../model/common/ScreenManager'
|
||||
import { ToolBarButton } from './ToolBarButton'
|
||||
import { Constants } from '../../model/common/Constants'
|
||||
import { ActionBarProp } from '../browserOperation/ActionBarProp'
|
||||
import { Action } from '../browserOperation/Action'
|
||||
import { ActionBarMode } from '../browserOperation/ActionBarMode'
|
||||
|
||||
export class MenuItem {
|
||||
value: string;
|
||||
@ -34,7 +34,6 @@ export struct ToolBar {
|
||||
@Consume toolMenuList: Action[];
|
||||
@Consume moreMenuList: Action[];
|
||||
@StorageLink('isHorizontal') isHorizontal: boolean = ScreenManager.getInstance().isHorizontal();
|
||||
|
||||
@State showPopup: boolean = false;
|
||||
private isFromPhotoBrowser = false;
|
||||
onMenuClicked: Function;
|
||||
@ -74,13 +73,13 @@ export struct ToolBar {
|
||||
}, menu => (menu.actionType != null ? menu.actionType.id : menu.actionID))
|
||||
}.width(ScreenManager.getInstance().getColumnsWidth(ColumnSize.COLUMN_TWO))
|
||||
.borderRadius($r('sys.float.ohos_id_corner_radius_default_l'))
|
||||
.padding({
|
||||
top: $r('app.float.menu_padding_vertical'),
|
||||
bottom: $r('app.float.menu_padding_vertical'),
|
||||
left: $r('app.float.menu_padding_horizontal'),
|
||||
right: $r('app.float.menu_padding_horizontal')
|
||||
})
|
||||
.backgroundColor(Color.White)
|
||||
.padding({
|
||||
top: $r('app.float.menu_padding_vertical'),
|
||||
bottom: $r('app.float.menu_padding_vertical'),
|
||||
left: $r('app.float.menu_padding_horizontal'),
|
||||
right: $r('app.float.menu_padding_horizontal')
|
||||
})
|
||||
.backgroundColor(Color.White)
|
||||
}
|
||||
|
||||
build() {
|
||||
@ -154,8 +153,8 @@ export struct ToolBar {
|
||||
}
|
||||
.width('100%')
|
||||
.height(Constants.ActionBarHeight)
|
||||
.padding(this.toolMenuList.length > 4 ? {} : {left: $r('app.float.actionbar_margin_horizontal'),
|
||||
right: $r('app.float.actionbar_margin_horizontal')})
|
||||
.padding(this.toolMenuList.length > 4 ? {} : { left: $r('app.float.actionbar_margin_horizontal'),
|
||||
right: $r('app.float.actionbar_margin_horizontal') })
|
||||
}
|
||||
.margin({
|
||||
bottom: this.isFromPhotoBrowser ? this.leftBlank[3] : 0
|
||||
@ -164,7 +163,7 @@ export struct ToolBar {
|
||||
.backgroundColor(this.actionBarProp.getBackgroundColor())
|
||||
.opacity(this.actionBarProp.getAlpha())
|
||||
.visibility(this.isShowBar && !this.isHorizontal ? Visibility.Visible : Visibility.Hidden)
|
||||
.markAnchor({x: '0%', y: '100%'})
|
||||
.position({x: '0%', y: '100%'})
|
||||
.markAnchor({ x: '0%', y: '100%' })
|
||||
.position({ x: '0%', y: '100%' })
|
||||
}
|
||||
}
|
@ -13,8 +13,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {Action} from '../browserOperation/Action'
|
||||
import {ActionBarColorMode} from '../browserOperation/ActionBarMode'
|
||||
import { Action } from '../browserOperation/Action'
|
||||
import { ActionBarColorMode } from '../browserOperation/ActionBarMode'
|
||||
|
||||
@Component
|
||||
export struct ToolBarButton {
|
||||
@ -41,11 +41,11 @@ export struct ToolBarButton {
|
||||
}
|
||||
}
|
||||
.height($r('app.float.icon_size'))
|
||||
.width($r('app.float.icon_size'))
|
||||
.width($r('app.float.icon_size'))
|
||||
}
|
||||
}
|
||||
|
||||
@Extend(Image) function commonButtonStyle () {
|
||||
.height($r('app.float.icon_size'))
|
||||
.width($r('app.float.icon_size'))
|
||||
.width($r('app.float.icon_size'))
|
||||
}
|
@ -71,59 +71,50 @@ export class Action {
|
||||
iconRes: null,
|
||||
textRes: null
|
||||
});
|
||||
|
||||
public static OK = new Action({
|
||||
id: ActionID.OK,
|
||||
iconRes: $r('app.media.ic_gallery_public_ok'),
|
||||
textRes: $r('app.string.action_ok')
|
||||
});
|
||||
|
||||
public static CANCEL = new Action({
|
||||
id: ActionID.CANCEL,
|
||||
iconRes: $r('app.media.ic_gallery_public_cancel'),
|
||||
textRes: $r('app.string.action_cancel')
|
||||
});
|
||||
|
||||
public static BACK = new Action({
|
||||
id: ActionID.BACK,
|
||||
iconRes: $r('app.media.ic_gallery_public_back'),
|
||||
textRes: $r('app.string.action_back')
|
||||
});
|
||||
|
||||
public static INFO = new Action({
|
||||
id: ActionID.INFO,
|
||||
iconRes: $r('app.media.ic_gallery_public_details'),
|
||||
textRes: $r('app.string.action_info')
|
||||
});
|
||||
|
||||
public static INFO_INVALID = new Action({
|
||||
id: ActionID.INFO,
|
||||
iconRes: $r('app.media.ic_gallery_public_details'),
|
||||
textRes: $r('app.string.action_info'),
|
||||
fillColor: $r('app.color.icon_disabled_color')
|
||||
});
|
||||
|
||||
public static DELETE = new Action({
|
||||
id: ActionID.DELETE,
|
||||
iconRes: $r('app.media.ic_gallery_public_delete_line'),
|
||||
textRes: $r('app.string.action_delete'),
|
||||
actionType: $r('app.string.action_delete')
|
||||
});
|
||||
|
||||
public static DELETE_RECYCLE = new Action({
|
||||
id: ActionID.DELETE_RECYCLE,
|
||||
iconRes: $r('app.media.ic_gallery_public_delete_line'),
|
||||
textRes: $r('app.string.action_delete'),
|
||||
actionType: $r('app.string.action_delete')
|
||||
});
|
||||
|
||||
public static CLEAR_RECYCLE = new Action({
|
||||
id: ActionID.CLEAR_RECYCLE,
|
||||
iconRes: $r('app.media.ic_gallery_public_delete_line'),
|
||||
textRes: $r('app.string.action_clear_recycle'),
|
||||
actionType: $r('app.string.action_delete')
|
||||
});
|
||||
|
||||
public static CLEAR_RECYCLE_INVALID = new Action({
|
||||
id: ActionID.CLEAR_RECYCLE_INVALID,
|
||||
iconRes: $r('app.media.ic_gallery_public_delete_line'),
|
||||
@ -131,7 +122,6 @@ export class Action {
|
||||
fillColor: $r('app.color.icon_disabled_color'),
|
||||
actionType: $r('app.string.action_delete')
|
||||
});
|
||||
|
||||
public static DELETE_INVALID = new Action({
|
||||
id: ActionID.DELETE_INVALID,
|
||||
iconRes: $r('app.media.ic_gallery_public_delete_line'),
|
||||
@ -139,14 +129,12 @@ export class Action {
|
||||
fillColor: $r('app.color.icon_disabled_color'),
|
||||
actionType: $r('app.string.action_delete')
|
||||
});
|
||||
|
||||
public static RECOVER = new Action({
|
||||
id: ActionID.RECOVER,
|
||||
iconRes: $r('app.media.ic_gallery_public_undo'),
|
||||
textRes: $r('app.string.action_recover'),
|
||||
actionType: $r('app.string.action_recover')
|
||||
});
|
||||
|
||||
public static RECOVER_INVALID = new Action({
|
||||
id: ActionID.RECOVER_INVALID,
|
||||
iconRes: $r('app.media.ic_gallery_public_undo'),
|
||||
@ -154,7 +142,6 @@ export class Action {
|
||||
fillColor: $r('app.color.icon_disabled_color'),
|
||||
actionType: $r('app.string.action_recover')
|
||||
});
|
||||
|
||||
public static FAVORITE = new Action({
|
||||
id: ActionID.FAVORITE,
|
||||
iconRes: $r('app.media.ic_gallery_public_Favorite_filled'),
|
||||
@ -162,21 +149,18 @@ export class Action {
|
||||
fillColor: $r('app.color.color_system_highlight'),
|
||||
actionType: $r('app.string.action_favorite')
|
||||
});
|
||||
|
||||
public static NOT_FAVORITE = new Action({
|
||||
id: ActionID.NOT_FAVORITE,
|
||||
iconRes: $r('app.media.ic_gallery_public_favorite_line'),
|
||||
textRes: $r('app.string.action_not_favorite'),
|
||||
actionType: $r('app.string.action_favorite')
|
||||
});
|
||||
|
||||
public static UN_SELECTED = new Action({
|
||||
id: ActionID.UN_SELECTED,
|
||||
iconRes: $r('app.media.ic_checkbox_off'),
|
||||
textRes: $r('app.string.action_unselected'),
|
||||
actionType: $r('app.string.action_selected')
|
||||
});
|
||||
|
||||
public static SELECTED = new Action({
|
||||
id: ActionID.SELECTED,
|
||||
iconRes: $r('app.media.ic_gallery_public_checkbox_filled'),
|
||||
@ -184,31 +168,26 @@ export class Action {
|
||||
isAutoTint: false,
|
||||
actionType: $r('app.string.action_selected')
|
||||
});
|
||||
|
||||
public static SELECT_ALL = new Action({
|
||||
id: ActionID.SELECT_ALL,
|
||||
iconRes: $r('app.media.ic_gallery_public_select_all'),
|
||||
textRes: $r('app.string.action_select_all'),
|
||||
actionType: $r('app.string.action_select_all')
|
||||
});
|
||||
|
||||
public static DESELECT_ALL = new Action({
|
||||
id: ActionID.DESELECT_ALL,
|
||||
iconRes: $r('app.media.ic_gallery_public_select_all_action'),
|
||||
textRes: $r('app.string.action_deselect_all'),
|
||||
actionType: $r('app.string.action_select_all')
|
||||
});
|
||||
|
||||
public static SETTING = new Action({
|
||||
id: ActionID.SETTING,
|
||||
textRes: $r('app.string.action_setting')
|
||||
});
|
||||
|
||||
public static NAVIGATION = new Action({
|
||||
id: ActionID.NAVIGATION,
|
||||
textRes: $r('app.string.action_navigation')
|
||||
});
|
||||
|
||||
public static MATERIAL_SELECT = new Action({
|
||||
id: ActionID.MATERIAL_SELECT,
|
||||
iconRes: $r('app.media.ic_checkbox_off_overlay'),
|
||||
@ -216,20 +195,17 @@ export class Action {
|
||||
isAutoTint: false,
|
||||
actionType: $r('app.string.action_selected')
|
||||
});
|
||||
|
||||
public static GOTO_PHOTOS = new Action({
|
||||
id: ActionID.GOTO_PHOTOS,
|
||||
iconRes: $r('app.media.ic_goto_photos'),
|
||||
textRes: $r('app.string.action_goto_photos')
|
||||
});
|
||||
|
||||
public static SHARE = new Action({
|
||||
id: ActionID.SHARE,
|
||||
iconRes: $r('app.media.ic_gallery_public_share'),
|
||||
textRes: $r('app.string.action_share'),
|
||||
actionType: $r('app.string.action_share')
|
||||
});
|
||||
|
||||
public static SHARE_INVALID = new Action({
|
||||
id: ActionID.SHARE_INVALID,
|
||||
iconRes: $r('app.media.ic_gallery_public_share'),
|
||||
@ -237,39 +213,33 @@ export class Action {
|
||||
textRes: $r('app.string.action_share'),
|
||||
actionType: $r('app.string.action_share')
|
||||
});
|
||||
|
||||
public static EDIT = new Action({
|
||||
id: ActionID.EDIT,
|
||||
iconRes: $r('app.media.ic_gallery_public_edit'),
|
||||
textRes: $r('app.string.action_edit')
|
||||
});
|
||||
|
||||
public static EDIT_INVALID = new Action({
|
||||
id: ActionID.EDIT_INVALID,
|
||||
iconRes: $r('app.media.ic_gallery_public_edit'),
|
||||
textRes: $r('app.string.action_edit'),
|
||||
fillColor: $r('app.color.icon_disabled_color')
|
||||
});
|
||||
|
||||
public static MORE = new Action({
|
||||
id: ActionID.MORE,
|
||||
iconRes: $r('app.media.ic_gallery_public_more'),
|
||||
textRes: $r('app.string.action_more')
|
||||
});
|
||||
|
||||
public static NEW = new Action({
|
||||
id: ActionID.NEW,
|
||||
iconRes: $r('app.media.ic_gallery_public_new'),
|
||||
textRes: $r('app.string.action_new')
|
||||
});
|
||||
|
||||
public static RENAME = new Action({
|
||||
id: ActionID.RENAME,
|
||||
iconRes: $r('app.media.ic_gallery_public_rename'),
|
||||
textRes: $r('app.string.action_rename'),
|
||||
actionType: $r('app.string.action_rename')
|
||||
});
|
||||
|
||||
public static RENAME_INVALID = new Action({
|
||||
id: ActionID.RENAME_INVALID,
|
||||
iconRes: $r('app.media.ic_gallery_public_rename'),
|
||||
@ -277,64 +247,53 @@ export class Action {
|
||||
fillColor: $r('app.color.icon_disabled_color'),
|
||||
actionType: $r('app.string.action_rename')
|
||||
});
|
||||
|
||||
public static ROTATE = new Action({
|
||||
id: ActionID.ROTATE,
|
||||
iconRes: $r('app.media.ic_edit_photo_crop_rotate'),
|
||||
textRes: $r('app.string.rotate_text'),
|
||||
actionType: $r('app.string.rotate_text')
|
||||
});
|
||||
|
||||
public static ADD_NOTES = new Action({
|
||||
id: ActionID.ADD_NOTES,
|
||||
iconRes: null,
|
||||
textRes: $r('app.string.add_notes')
|
||||
});
|
||||
|
||||
public static MOVE = new Action({
|
||||
id: ActionID.MOVE,
|
||||
textRes: $r('app.string.action_move_to_album')
|
||||
});
|
||||
|
||||
public static MOVE_INVALID = new Action({
|
||||
id: ActionID.MOVE_INVALID,
|
||||
textRes: $r('app.string.action_move_to_album'),
|
||||
fillColor: $r('app.color.icon_disabled_color')
|
||||
});
|
||||
|
||||
public static COPY = new Action({
|
||||
id: ActionID.COPY,
|
||||
textRes: $r('app.string.action_copy_to_album')
|
||||
});
|
||||
|
||||
public static COPY_INVALID = new Action({
|
||||
id: ActionID.COPY_INVALID,
|
||||
textRes: $r('app.string.action_copy_to_album'),
|
||||
fillColor: $r('app.color.icon_disabled_color')
|
||||
});
|
||||
|
||||
public static NAVIGATION_ALBUMS = new Action({
|
||||
id: ActionID.NAVIGATION_ALBUMS,
|
||||
iconRes: $r('app.media.ic_navigation_albums_line'),
|
||||
textRes: $r('app.string.rotate_text')
|
||||
});
|
||||
|
||||
public static DOWNLOAD = new Action({
|
||||
id: ActionID.DOWNLOAD,
|
||||
iconRes: $r('app.media.download'),
|
||||
textRes: $r('app.string.save_to_local')
|
||||
});
|
||||
|
||||
public static DOWNLOAD_INVALID = new Action({
|
||||
id: ActionID.DOWNLOAD_INVALID,
|
||||
iconRes: $r('app.media.download'),
|
||||
textRes: $r('app.string.save_to_local'),
|
||||
fillColor: $r('app.color.icon_disabled_color')
|
||||
});
|
||||
|
||||
public static ICON_DEFAULT_COLOR: Resource = $r('app.color.icon_default_color');
|
||||
public static ICON_DEFAULT_COLOR_CONTRARY: Resource = $r('app.color.icon_default_color_contrary');
|
||||
|
||||
readonly actionID: number;
|
||||
readonly textRes: Resource;
|
||||
readonly iconRes: Resource = $r('app.media.ic_gallery_public_more');
|
@ -13,8 +13,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {Action} from './Action'
|
||||
import {ActionBarMode, ActionBarColorMode, ActionBarSelectionMode} from './ActionBarMode'
|
||||
import { Action } from './Action'
|
||||
import { ActionBarMode, ActionBarColorMode, ActionBarSelectionMode } from './ActionBarMode'
|
||||
|
||||
// ActionBarProp
|
||||
export class ActionBarProp {
|
@ -1,3 +1,4 @@
|
||||
// @ts-nocheck
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
@ -13,17 +13,16 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {Logger} from '../../utils/Logger'
|
||||
import {SelectManager} from '../../model/browser/SelectManager'
|
||||
import {MenuContext} from './MenuContext'
|
||||
import {BrowserOperationFactory} from '../../interface/BrowserOperationFactory'
|
||||
import {BroadCastConstants} from '../../model/common/BroadCastConstants';
|
||||
import { Logger } from '../../utils/Logger'
|
||||
import { SelectManager } from '../../model/browser/SelectManager'
|
||||
import { MenuContext } from './MenuContext'
|
||||
import { BrowserOperationFactory } from '../../interface/BrowserOperationFactory'
|
||||
import { BroadCastConstants } from '../../model/common/BroadCastConstants';
|
||||
import { AlbumDefine } from '../../model/browser/AlbumDefine'
|
||||
import {ProcessMenuOperation} from './ProcessMenuOperation';
|
||||
import { ProcessMenuOperation } from './ProcessMenuOperation';
|
||||
import { TraceControllerUtils } from '../../utils/TraceControllerUtils';
|
||||
|
||||
export class BatchDeleteMenuOperation extends ProcessMenuOperation {
|
||||
|
||||
logger: Logger = new Logger('BatchDeleteMenuOperation');
|
||||
|
||||
constructor(menuContext: MenuContext) {
|
@ -13,14 +13,14 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {Logger} from '../../utils/Logger'
|
||||
import {MenuContext} from './MenuContext'
|
||||
import {ProcessMenuOperation, FindSameOperation} from './ProcessMenuOperation'
|
||||
import {BroadCastConstants} from '../../model/common/BroadCastConstants';
|
||||
import {SelectManager} from '../../model/browser/SelectManager'
|
||||
import {BrowserOperationFactory} from '../../interface/BrowserOperationFactory'
|
||||
import {MediaOperationType} from '../../model/common/MediaOperationType'
|
||||
import {AlbumInfo} from '../../model/browser/album/AlbumInfo';
|
||||
import { Logger } from '../../utils/Logger'
|
||||
import { MenuContext } from './MenuContext'
|
||||
import { ProcessMenuOperation, FindSameOperation } from './ProcessMenuOperation'
|
||||
import { BroadCastConstants } from '../../model/common/BroadCastConstants';
|
||||
import { SelectManager } from '../../model/browser/SelectManager'
|
||||
import { BrowserOperationFactory } from '../../interface/BrowserOperationFactory'
|
||||
import { MediaOperationType } from '../../model/common/MediaOperationType'
|
||||
import { AlbumInfo } from '../../model/browser/album/AlbumInfo';
|
||||
import { AlbumDefine } from '../../model/browser/AlbumDefine'
|
||||
import { TraceControllerUtils } from '../../utils/TraceControllerUtils';
|
||||
|
||||
@ -32,7 +32,7 @@ export class CopyMenuOperation extends ProcessMenuOperation {
|
||||
constructor(menuContext: MenuContext) {
|
||||
super(menuContext);
|
||||
this.albumInfo = menuContext.albumInfo;
|
||||
if (this.menuContext.deviceId){
|
||||
if (this.menuContext.deviceId) {
|
||||
this.albumInfo = new AlbumInfo('', '', '', '', 0, '', AlbumDefine.genAlbumRelativePath(AlbumDefine.REMOTE_ALBUM_PATH))
|
||||
}
|
||||
}
|
||||
@ -95,13 +95,13 @@ export class CopyMenuOperation extends ProcessMenuOperation {
|
||||
if (this.isCancelled) {
|
||||
return;
|
||||
}
|
||||
this.currentBatch ++;
|
||||
this.currentBatch++;
|
||||
let startIndex = (this.currentBatch - 1) * this.BATCH_SIZE;
|
||||
let endIndex = this.currentBatch * this.BATCH_SIZE;
|
||||
let batchUris: string[] = this.uris.slice(startIndex, Math.min(endIndex, this.uris.length));
|
||||
if (batchUris[0] == undefined) {
|
||||
this.onOperateContinue();
|
||||
return;
|
||||
this.onOperateContinue();
|
||||
return;
|
||||
}
|
||||
this.logger.info(`requestOneBatchOperation ${JSON.stringify(this.albumInfo)}`);
|
||||
|
||||
@ -112,7 +112,11 @@ export class CopyMenuOperation extends ProcessMenuOperation {
|
||||
let displayName = assets.sourceAsset.displayName;
|
||||
let index = displayName.lastIndexOf('.');
|
||||
displayName = `${displayName.slice(0, index)}${new Date().getTime()}${displayName.slice(index)}`;
|
||||
this.copy(assets.sourceAsset, null, {mediaType: assets.sourceAsset.mediaType, name: displayName, path: this.albumInfo.relativePath});
|
||||
this.copy(assets.sourceAsset, null, {
|
||||
mediaType: assets.sourceAsset.mediaType,
|
||||
name: displayName,
|
||||
path: this.albumInfo.relativePath
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
@ -120,10 +124,10 @@ export class CopyMenuOperation extends ProcessMenuOperation {
|
||||
if (assets.targetAsset.uri == assets.sourceAsset.uri) {
|
||||
this.logger.info('copy same fileAsset');
|
||||
this.onOperateContinue();
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
this.logger.info('show find same file dialog');
|
||||
switch(this.findSameOperation) {
|
||||
switch (this.findSameOperation) {
|
||||
case FindSameOperation.NONE:
|
||||
this.menuContext.broadCast.emit(BroadCastConstants.FIND_SAME_FILE_DIALOG,
|
||||
[assets, this.count, () => {
|
||||
@ -142,17 +146,21 @@ export class CopyMenuOperation extends ProcessMenuOperation {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
this.copy(assets.sourceAsset, null, {mediaType: assets.sourceAsset.mediaType, name: assets.sourceAsset.displayName, path: this.albumInfo.relativePath});
|
||||
this.copy(assets.sourceAsset, null, {
|
||||
mediaType: assets.sourceAsset.mediaType,
|
||||
name: assets.sourceAsset.displayName,
|
||||
path: this.albumInfo.relativePath
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async copy(source, target, param?){
|
||||
try{
|
||||
if(!target){
|
||||
async copy(source, target, param?) {
|
||||
try {
|
||||
if (!target) {
|
||||
TraceControllerUtils.startTraceWithTaskId('create', this.currentBatch)
|
||||
target = await this.operationImpl.create(param);
|
||||
if(target == null){
|
||||
if (target == null) {
|
||||
this.logger.error(`Target file creat failed when copyFile!`);
|
||||
this.onError();
|
||||
return;
|
||||
@ -163,7 +171,7 @@ export class CopyMenuOperation extends ProcessMenuOperation {
|
||||
await this.operationImpl.copy(source, target);
|
||||
TraceControllerUtils.finishTraceWithTaskId('openWriteClose', this.currentBatch)
|
||||
this.onCompleted();
|
||||
}catch(error){
|
||||
} catch (error) {
|
||||
this.logger.error(`copyFile is error ${error}`);
|
||||
this.onError();
|
||||
}
|
@ -13,27 +13,26 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {Logger} from '../../utils/Logger'
|
||||
import {Action} from './Action'
|
||||
import {ActionBar} from '../../../common/view/actionbar/ActionBar'
|
||||
import {ActionBarProp} from './ActionBarProp'
|
||||
import {ActionBarMode} from './ActionBarMode'
|
||||
import {ScreenManager} from '../../model/common/ScreenManager'
|
||||
import {MediaOperationType} from '../../model/common/MediaOperationType'
|
||||
import { Logger } from '../../utils/Logger'
|
||||
import { Action } from './Action'
|
||||
import { ActionBar } from '../../../common/view/actionbar/ActionBar'
|
||||
import { ActionBarProp } from './ActionBarProp'
|
||||
import { ActionBarMode } from './ActionBarMode'
|
||||
import { ScreenManager } from '../../model/common/ScreenManager'
|
||||
import { MediaOperationType } from '../../model/common/MediaOperationType'
|
||||
|
||||
@Component
|
||||
export struct MediaOperationActionBar {
|
||||
@Consume pageType:string;
|
||||
@Consume pageType: string;
|
||||
@Consume loadingFinish: boolean;
|
||||
onMenuClicked : Function;
|
||||
onMenuClicked: Function;
|
||||
logger: Logger = new Logger('MediaOperationActionBar');
|
||||
|
||||
@StorageLink('isHorizontal') isHorizontal: boolean = ScreenManager.getInstance().isHorizontal();
|
||||
|
||||
private createActionBar(): ActionBarProp {
|
||||
let menuList: Array<Action> = new Array<Action>();
|
||||
let actionBarProp: ActionBarProp = new ActionBarProp();
|
||||
if(this.loadingFinish){
|
||||
if (this.loadingFinish) {
|
||||
menuList.push(Action.NEW);
|
||||
}
|
||||
actionBarProp
|
||||
|
@ -12,25 +12,25 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import {MediaOperationType} from '../../model/common/MediaOperationType'
|
||||
import {MediaOperationActionBar} from './MediaOperationActionBar'
|
||||
import {Logger} from '../../utils/Logger'
|
||||
import {BroadCast} from '../../utils/BroadCast'
|
||||
import {AlbumSetNewMenuOperation} from './AlbumSetNewMenuOperation';
|
||||
import {MenuOperationFactory} from '../../interface/MenuOperationFactory';
|
||||
import {AlbumSetDataSource} from '../../model/browser/album/AlbumSetDataSource';
|
||||
import {AlbumInfo} from '../../model/browser/album/AlbumInfo';
|
||||
import {BroadCastConstants} from '../../model/common/BroadCastConstants';
|
||||
import {AlbumListCard} from './AlbumListCard';
|
||||
import { MediaOperationType } from '../../model/common/MediaOperationType'
|
||||
import { MediaOperationActionBar } from './MediaOperationActionBar'
|
||||
import { Logger } from '../../utils/Logger'
|
||||
import { BroadCast } from '../../utils/BroadCast'
|
||||
import { AlbumSetNewMenuOperation } from './AlbumSetNewMenuOperation';
|
||||
import { MenuOperationFactory } from '../../interface/MenuOperationFactory';
|
||||
import { AlbumSetDataSource } from '../../model/browser/album/AlbumSetDataSource';
|
||||
import { AlbumInfo } from '../../model/browser/album/AlbumInfo';
|
||||
import { BroadCastConstants } from '../../model/common/BroadCastConstants';
|
||||
import { AlbumListCard } from './AlbumListCard';
|
||||
import router from '@system.router';
|
||||
import {MenuContext} from './MenuContext';
|
||||
import {Action} from './Action';
|
||||
import {JumpSourceToMain} from '../../../common/model/browser/photo/JumpSourceToMain'
|
||||
import {CustomDialogView} from '../dialog/CustomDialogView';
|
||||
import {AlbumDefine} from '../../model/browser/AlbumDefine';
|
||||
import {ScreenManager, ColumnSize} from '../../model/common/ScreenManager';
|
||||
import {BroadCastManager} from '../../model/common/BroadCastManager';
|
||||
import {Constants} from '../../model/common/Constants';
|
||||
import { MenuContext } from './MenuContext';
|
||||
import { Action } from './Action';
|
||||
import { JumpSourceToMain } from '../../../common/model/browser/photo/JumpSourceToMain'
|
||||
import { CustomDialogView } from '../dialog/CustomDialogView';
|
||||
import { AlbumDefine } from '../../model/browser/AlbumDefine';
|
||||
import { ScreenManager, ColumnSize } from '../../model/common/ScreenManager';
|
||||
import { BroadCastManager } from '../../model/common/BroadCastManager';
|
||||
import { Constants } from '../../model/common/Constants';
|
||||
|
||||
@Entry
|
||||
@Component
|
||||
@ -52,7 +52,7 @@ struct MediaOperationPage {
|
||||
|
||||
aboutToAppear(): void {
|
||||
let self = this;
|
||||
this.albums = new AlbumSetDataSource(this.broadCast, {moreInfo: true});
|
||||
this.albums = new AlbumSetDataSource(this.broadCast, { moreInfo: true });
|
||||
|
||||
this.onActive();
|
||||
let param = router.getParams();
|
||||
@ -70,7 +70,7 @@ struct MediaOperationPage {
|
||||
this.broadCast.on(BroadCastConstants.MEDIA_OPERATION, (albumInfo: AlbumInfo, completedFunc?: Function) => {
|
||||
router.back({
|
||||
uri: '',
|
||||
params:{
|
||||
params: {
|
||||
pageType: self.pageType,
|
||||
albumInfo: JSON.stringify(albumInfo)
|
||||
}
|
||||
@ -165,24 +165,24 @@ struct MediaOperationPage {
|
||||
return list[list.length - 1].innerId == info.innerId;
|
||||
}
|
||||
|
||||
onPageShow(){
|
||||
onPageShow() {
|
||||
this.appBroadCast.emit(BroadCastConstants.THIRD_ROUTE_PAGE, []);
|
||||
}
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
MediaOperationActionBar({onMenuClicked: this.onMenuClicked})
|
||||
MediaOperationActionBar({ onMenuClicked: this.onMenuClicked })
|
||||
|
||||
List({scroller: this.scroller}) {
|
||||
List({ scroller: this.scroller }) {
|
||||
LazyForEach(this.albums, (item: AlbumInfo, index) => {
|
||||
ListItem() {
|
||||
if (!AlbumDefine.ALBUM_DISABLE_COPY_LIST.has(item.id) && item.id != this.sourceAlbumId) {
|
||||
Column() {
|
||||
AlbumListCard({item: item})
|
||||
AlbumListCard({ item: item })
|
||||
if (!this.isLast(item)) {
|
||||
Divider().vertical(false).strokeWidth(1)
|
||||
.color($r('sys.color.ohos_id_color_list_separator'))
|
||||
.margin({left: $r('app.float.album_list_card_divider_margin_left')})
|
||||
.margin({ left: $r('app.float.album_list_card_divider_margin_left') })
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -192,26 +192,27 @@ struct MediaOperationPage {
|
||||
.borderRadius($r('sys.float.ohos_id_corner_radius_default_l'))
|
||||
.margin({
|
||||
top: $r('app.float.album_let_page_padding_top'),
|
||||
left : $r('app.float.max_padding_start'),
|
||||
right : $r('app.float.max_padding_end'),
|
||||
left: $r('app.float.max_padding_start'),
|
||||
right: $r('app.float.max_padding_end'),
|
||||
bottom: this.leftBlank[3]
|
||||
})
|
||||
.padding({
|
||||
left : $r('app.float.list_card_margin'),
|
||||
right : $r('app.float.list_card_margin')
|
||||
left: $r('app.float.list_card_margin'),
|
||||
right: $r('app.float.list_card_margin')
|
||||
})
|
||||
.width(this.listCardWidth)
|
||||
.backgroundColor($r('sys.color.ohos_id_color_card_bg'))
|
||||
|
||||
CustomDialogView()
|
||||
}
|
||||
.backgroundColor($r('app.color.default_background_color')) // ux: colorSubBackground
|
||||
.backgroundColor($r('app.color.default_background_color')) // ux: colorSubBackground
|
||||
.height('100%')
|
||||
.padding({
|
||||
top: this.leftBlank[1],
|
||||
bottom: this.leftBlank[3]
|
||||
})
|
||||
}
|
||||
|
||||
pageTransition() {
|
||||
PageTransitionEnter({ type: RouteType.None, duration: 1 })
|
||||
.opacity(0)
|
||||
|
@ -13,11 +13,11 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {MediaItem} from '../../model/browser/photo/MediaItem'
|
||||
import {SelectManager} from '../../model/browser/SelectManager'
|
||||
import {BroadCast} from '../../utils/BroadCast'
|
||||
import {AlbumSetDataSource} from '../../model/browser/album/AlbumSetDataSource'
|
||||
import {AlbumInfo} from '../../model/browser/album/AlbumInfo';
|
||||
import { MediaItem } from '../../model/browser/photo/MediaItem'
|
||||
import { SelectManager } from '../../model/browser/SelectManager'
|
||||
import { BroadCast } from '../../utils/BroadCast'
|
||||
import { AlbumSetDataSource } from '../../model/browser/album/AlbumSetDataSource'
|
||||
import { AlbumInfo } from '../../model/browser/album/AlbumInfo';
|
||||
|
||||
export class MenuContext {
|
||||
mediaItem: MediaItem;
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user