@@ -30,6 +30,7 @@
|
||||
|
||||
<filefilterlist>
|
||||
<filefilter name="binaryFileTypePolicyFilter" desc="Filters for binary file policies">
|
||||
<filteritem type="filepath" name="common/src/main/resources/base/media/.*.png" desc="self developed image"/>
|
||||
<filteritem type="filepath" name="product/phone/src/main/resources/base/media/.*.png" desc="self developed image"/>
|
||||
<filteritem type="filepath" name="product/pad/src/main/resources/base/media/.*.png" desc="self developed image"/>
|
||||
</filefilter>
|
||||
|
||||
@@ -57,7 +57,7 @@ FilePicker应用是OpenHarmony中预置的系统应用,为用户提供文件
|
||||
globalThis.context.startAbilityForResult(
|
||||
{
|
||||
bundleName: "com.ohos.filepicker",
|
||||
abilityName: "com.ohos.filepicker.MainAbility",
|
||||
abilityName: "MainAbility",
|
||||
parameters: {
|
||||
'startMode': 'choose', //choose or save
|
||||
}
|
||||
@@ -69,7 +69,7 @@ globalThis.context.startAbilityForResult(
|
||||
globalThis.context.startAbilityForResult(
|
||||
{
|
||||
bundleName: "com.ohos.filepicker",
|
||||
abilityName: "com.ohos.filepicker.MainAbility",
|
||||
abilityName: "MainAbility",
|
||||
parameters: {
|
||||
'startMode': 'save', //choose or save
|
||||
'saveFile': 'test.jpg',
|
||||
|
||||
@@ -1,19 +1,5 @@
|
||||
{
|
||||
"app": {
|
||||
"signingConfigs": [
|
||||
{
|
||||
"name": "default",
|
||||
"material": {
|
||||
"certpath": "C:\\Users\\Administrator\\.ohos\\config\\openharmony\\auto_ohos.cer",
|
||||
"storePassword": "0000001866B30A00583E19F2A7810409DC21FD1736310F045F4BBAD68308661D5508F6887C450EDE",
|
||||
"keyAlias": "debugKey",
|
||||
"keyPassword": "0000001839D4D8FF10ED142C94E5132CADD090081785A1D581C24FA2D1056AFF1718E4AA97DF4B32",
|
||||
"profile": "C:\\Users\\Administrator\\.ohos\\config\\openharmony\\auto_ohos_default_com.ohos.filepicker.p7b",
|
||||
"signAlg": "SHA256withECDSA",
|
||||
"storeFile": "C:\\Users\\Administrator\\.ohos\\config\\openharmony\\auto_ohos.p12"
|
||||
}
|
||||
}
|
||||
],
|
||||
"compileSdkVersion": 9,
|
||||
"compatibleSdkVersion": 9,
|
||||
"products": [
|
||||
@@ -59,6 +45,10 @@
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "common",
|
||||
"srcPath": "./common"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
/node_modules
|
||||
/.preview
|
||||
/build
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"apiType": "stageMode",
|
||||
"buildOption": {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently.
|
||||
module.exports = require('@ohos/hvigor-ohos-plugin').harTasks
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@@ -13,9 +13,4 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export class DisplayInfo {
|
||||
width: number
|
||||
height: number
|
||||
mainDialogWidth: number
|
||||
mainDialogHeight: number
|
||||
}
|
||||
export { MainPage } from './src/main/ets/components/MainPage/MainPage'
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"name": "@ohos/common",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 1
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"name": "@ohos/common",
|
||||
"description": "a npm package which contains arkUI2.0 page",
|
||||
"ohos": {
|
||||
"org": ""
|
||||
},
|
||||
"version": "1.0.0",
|
||||
"main": "index.ets",
|
||||
"types": "",
|
||||
"repository": {},
|
||||
"license": "ISC",
|
||||
"dependencies": {}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export enum MenuLevel {
|
||||
MENU_FIRST_LEVEL_BY_TYPE = 1,
|
||||
MENU_SECOND_LEVEL_BY_FOLD = 2,
|
||||
MENU_THIRD_LEVEL_HAS_PIC = 3,
|
||||
MENU_THIRD_LEVEL_HAS_DETAIL = 4,
|
||||
}
|
||||
|
||||
export enum MediaType {
|
||||
MEDIA_TYPE_FILE = 1,
|
||||
MEDIA_TYPE_IMAGE = 3,
|
||||
MEDIA_TYPE_VIDEO = 4,
|
||||
MEDIA_TYPE_AUDIO = 5,
|
||||
MEDIA_TYPE_ALBUM = 8
|
||||
}
|
||||
|
||||
export enum MediaName {
|
||||
FILE = 'file',
|
||||
IMAGE = 'image',
|
||||
VIDEO = 'video',
|
||||
AUDIO = 'audio',
|
||||
FILE_TYPE = "fileType"
|
||||
}
|
||||
|
||||
export enum GridItemSize {
|
||||
GRID_ITEM_HEIGHT = 126,
|
||||
GRID_ITEM_WIDTH = 96,
|
||||
GRID_ITEM_COLUMNS_GAP = 8,
|
||||
GRID_ITEM_ROWS_GAP = 8,
|
||||
}
|
||||
|
||||
export enum TerminateReason {
|
||||
SUCCESS = 0,
|
||||
NO_ACTION = -1,
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@@ -13,22 +13,23 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export enum menuLevel {
|
||||
MENU_FIRST_LEVEL_BY_TYPE = 1,
|
||||
MENU_SECOND_LEVEL_BY_FOLD = 2,
|
||||
MENU_THIRD_LEVEL_HAS_PIC = 3,
|
||||
MENU_THIRD_LEVEL_HAS_DETAIL = 4,
|
||||
}
|
||||
import { MediaType } from './Constants'
|
||||
|
||||
export enum mediaType {
|
||||
MEDIA_TYPE_FILE = 1,
|
||||
MEDIA_TYPE_IMAGE = 3,
|
||||
MEDIA_TYPE_VIDEO = 4,
|
||||
MEDIA_TYPE_AUDIO = 5,
|
||||
MEDIA_TYPE_ALBUM = 8
|
||||
}
|
||||
export class FileInfo {
|
||||
name: string
|
||||
path: string
|
||||
type: number= MediaType.MEDIA_TYPE_ALBUM
|
||||
size: string
|
||||
dataAdded_time: string
|
||||
modified_time: string
|
||||
mediaType: string
|
||||
thumbnail: Resource
|
||||
font_color: Color | string | Resource
|
||||
opacity: number
|
||||
list_background: string | Resource
|
||||
textBackground: string | Resource
|
||||
|
||||
export enum terminateReason {
|
||||
SUCCESS = 0,
|
||||
NO_ACTION = -1,
|
||||
constructor(name: string) {
|
||||
this.name = name
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@@ -13,9 +13,13 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export class DisplayInfo {
|
||||
width: number
|
||||
height: number
|
||||
mainDialogWidth: number
|
||||
mainDialogHeight: number
|
||||
export class TopPathInfo {
|
||||
name: string
|
||||
path: string
|
||||
opacity: number = 1
|
||||
|
||||
constructor(name: string, path: string) {
|
||||
this.name = name
|
||||
this.path = path
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@@ -13,10 +13,20 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export function LogInfo(TAG: string, message: string | number): void {
|
||||
console.info('filePicker_' + TAG + ': ' + message)
|
||||
}
|
||||
@Entry
|
||||
@Component
|
||||
export struct MainPage {
|
||||
@State message: string = 'Hello World'
|
||||
|
||||
export function LogDebug(TAG: string, message: string | number): void {
|
||||
console.debug('filePicker_' + TAG + ': ' + message)
|
||||
build() {
|
||||
Row() {
|
||||
Column() {
|
||||
Text(this.message)
|
||||
.fontSize(50)
|
||||
.fontWeight(FontWeight.Bold)
|
||||
}
|
||||
.width('100%')
|
||||
}
|
||||
.height('100%')
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { logInfo, logWarn } from './LogUtils'
|
||||
|
||||
var TAG: string = 'AbilityUtils'
|
||||
|
||||
export function terminateSelfWithResult(resultCode: number, result: string): void {
|
||||
logInfo(TAG, 'terminateSelfWithResult')
|
||||
let startMode: string = AppStorage.Get<string>('startMode')
|
||||
var abilityResult = {
|
||||
resultCode: resultCode,
|
||||
want: {
|
||||
parameters: {
|
||||
'startMode': startMode,
|
||||
'result': result
|
||||
}
|
||||
}
|
||||
}
|
||||
globalThis.context.terminateSelfWithResult(abilityResult, (error) => {
|
||||
if (error.code) {
|
||||
logWarn(TAG, 'Operation failed. Cause: ' + JSON.stringify(error))
|
||||
return
|
||||
}
|
||||
logInfo(TAG, 'Operation succeeded')
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,333 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { MediaType, MediaName } from '../Data/Constants';
|
||||
import { FileInfo } from '../Data/FileInfo'
|
||||
import { logInfo } from './LogUtils'
|
||||
|
||||
var TAG = 'FileManagerServiceUtils'
|
||||
var isDebug: boolean = true;
|
||||
|
||||
export function getFirstMenu(deviceName: string): Array<FileInfo> {
|
||||
let fileList: Array<FileInfo> = [];
|
||||
if (isDebug) {
|
||||
let file1: FileInfo = new FileInfo('image_album');
|
||||
file1.type = MediaType.MEDIA_TYPE_ALBUM;
|
||||
file1.path = 'dataability:///album';
|
||||
file1.size = '';
|
||||
file1.dataAdded_time = 'xxx';
|
||||
file1.modified_time = 'xxx';
|
||||
fileList.push(file1);
|
||||
|
||||
let file2: FileInfo = new FileInfo('video_album');
|
||||
file2.type = MediaType.MEDIA_TYPE_ALBUM;
|
||||
file2.path = 'dataability:///album';
|
||||
file2.size = '';
|
||||
file2.dataAdded_time = 'xxx';
|
||||
file2.modified_time = 'xxx';
|
||||
fileList.push(file2);
|
||||
|
||||
let file4: FileInfo = new FileInfo('file_folder');
|
||||
file4.type = MediaType.MEDIA_TYPE_ALBUM;
|
||||
file4.path = 'dataability:///album';
|
||||
file4.size = '';
|
||||
file4.dataAdded_time = 'xxx';
|
||||
file4.modified_time = 'xxx';
|
||||
fileList.push(file4);
|
||||
|
||||
let file3: FileInfo = new FileInfo('audio_album');
|
||||
file3.type = MediaType.MEDIA_TYPE_ALBUM;
|
||||
file3.path = 'dataability:///album';
|
||||
file3.size = '';
|
||||
file3.dataAdded_time = 'xxx';
|
||||
file3.modified_time = 'xxx';
|
||||
fileList.push(file3);
|
||||
} else {
|
||||
// var fileInfo = filemanager.getRoot(deviceName);
|
||||
}
|
||||
|
||||
fileList.forEach(item => {
|
||||
if (item.name == 'image_album') {
|
||||
item.name = "图片";
|
||||
item.mediaType = 'image';
|
||||
item.thumbnail = $r("app.media.ic_type_image")
|
||||
} else if (item.name == 'video_album') {
|
||||
item.name = "视频";
|
||||
item.mediaType = 'video';
|
||||
item.thumbnail = $r("app.media.ic_type_video")
|
||||
} else if (item.name == 'audio_album') {
|
||||
item.name = "音乐";
|
||||
item.mediaType = 'audio';
|
||||
item.thumbnail = $r("app.media.ic_type_audio")
|
||||
} else if (item.name == 'file_folder') {
|
||||
item.name = "文档";
|
||||
item.mediaType = 'file';
|
||||
item.thumbnail = $r("app.media.ic_public_file")
|
||||
}
|
||||
});
|
||||
|
||||
return fileList;
|
||||
}
|
||||
|
||||
export function getListFile(deviceName: string, mediaType: string, path: string): Array<FileInfo> {
|
||||
logInfo(TAG, "getListFile mediaType = " + mediaType + ';path = ' + path);
|
||||
let fileList: Array<FileInfo> = [];
|
||||
if (isDebug) {
|
||||
if (path == 'dataability:///album') {
|
||||
if (mediaType == 'image') {
|
||||
let fileInfo1: FileInfo = new FileInfo("微信的图片");
|
||||
fileInfo1.type = MediaType.MEDIA_TYPE_ALBUM;
|
||||
fileInfo1.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/01';
|
||||
fileInfo1.dataAdded_time = 'xxx';
|
||||
fileInfo1.modified_time = 'xxx';
|
||||
fileList.push(fileInfo1);
|
||||
let fileInfo2: FileInfo = new FileInfo("图片1");
|
||||
fileInfo2.type = MediaType.MEDIA_TYPE_ALBUM;
|
||||
fileInfo2.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/02';
|
||||
fileInfo2.dataAdded_time = 'xxx';
|
||||
fileInfo2.modified_time = 'xxx';
|
||||
fileList.push(fileInfo2);
|
||||
let fileInfo3: FileInfo = new FileInfo("图片2");
|
||||
fileInfo3.type = MediaType.MEDIA_TYPE_ALBUM;
|
||||
fileInfo3.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/03';
|
||||
fileInfo3.dataAdded_time = 'xxx';
|
||||
fileInfo3.modified_time = 'xxx';
|
||||
fileList.push(fileInfo3);
|
||||
let fileInfo4: FileInfo = new FileInfo("图片3");
|
||||
fileInfo4.type = MediaType.MEDIA_TYPE_ALBUM;
|
||||
fileInfo4.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/04';
|
||||
fileInfo4.dataAdded_time = 'xxx';
|
||||
fileInfo4.modified_time = 'xxx';
|
||||
fileList.push(fileInfo4);
|
||||
let fileInfo5: FileInfo = new FileInfo("图片4");
|
||||
fileInfo5.type = MediaType.MEDIA_TYPE_ALBUM;
|
||||
fileInfo5.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/05';
|
||||
fileInfo5.dataAdded_time = 'xxx';
|
||||
fileInfo5.modified_time = 'xxx';
|
||||
fileList.push(fileInfo5);
|
||||
let fileInfo6: FileInfo = new FileInfo("图片5");
|
||||
fileInfo6.type = MediaType.MEDIA_TYPE_ALBUM;
|
||||
fileInfo6.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/06';
|
||||
fileInfo6.dataAdded_time = 'xxx';
|
||||
fileInfo6.modified_time = 'xxx';
|
||||
fileList.push(fileInfo6);
|
||||
let fileInfo7: FileInfo = new FileInfo("图片6");
|
||||
fileInfo7.type = MediaType.MEDIA_TYPE_ALBUM;
|
||||
fileInfo7.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/07';
|
||||
fileInfo7.dataAdded_time = 'xxx';
|
||||
fileInfo7.modified_time = 'xxx';
|
||||
fileList.push(fileInfo7);
|
||||
let fileInfo8: FileInfo = new FileInfo("图片7");
|
||||
fileInfo8.type = MediaType.MEDIA_TYPE_ALBUM;
|
||||
fileInfo8.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/08';
|
||||
fileInfo8.dataAdded_time = 'xxx';
|
||||
fileInfo8.modified_time = 'xxx';
|
||||
fileList.push(fileInfo8);
|
||||
let fileInfo9: FileInfo = new FileInfo("图片8");
|
||||
fileInfo1.type = MediaType.MEDIA_TYPE_ALBUM;
|
||||
fileInfo1.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/09';
|
||||
fileInfo1.dataAdded_time = 'xxx';
|
||||
fileInfo1.modified_time = 'xxx';
|
||||
fileList.push(fileInfo9);
|
||||
let fileInfo10: FileInfo = new FileInfo("图片9");
|
||||
fileInfo10.type = MediaType.MEDIA_TYPE_ALBUM;
|
||||
fileInfo10.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/10';
|
||||
fileInfo10.dataAdded_time = 'xxx';
|
||||
fileInfo10.modified_time = 'xxx';
|
||||
fileList.push(fileInfo10);
|
||||
let fileInfo11: FileInfo = new FileInfo("图片10");
|
||||
fileInfo11.type = MediaType.MEDIA_TYPE_ALBUM;
|
||||
fileInfo11.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/11';
|
||||
fileInfo11.dataAdded_time = 'xxx';
|
||||
fileInfo11.modified_time = 'xxx';
|
||||
fileList.push(fileInfo11);
|
||||
} else if (mediaType == 'video') {
|
||||
let fileInfo1: FileInfo = new FileInfo("视频0");
|
||||
fileInfo1.type = MediaType.MEDIA_TYPE_ALBUM;
|
||||
fileInfo1.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/12';
|
||||
fileInfo1.dataAdded_time = 'xxx';
|
||||
fileInfo1.modified_time = 'xxx';
|
||||
fileList.push(fileInfo1);
|
||||
let fileInfo2: FileInfo = new FileInfo("视频1");
|
||||
fileInfo2.type = MediaType.MEDIA_TYPE_ALBUM;
|
||||
fileInfo2.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/13';
|
||||
fileInfo2.dataAdded_time = 'xxx';
|
||||
fileInfo2.modified_time = 'xxx';
|
||||
fileList.push(fileInfo2);
|
||||
let fileInfo3: FileInfo = new FileInfo("视频2");
|
||||
fileInfo3.type = MediaType.MEDIA_TYPE_ALBUM;
|
||||
fileInfo3.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/14';
|
||||
fileInfo3.dataAdded_time = 'xxx';
|
||||
fileInfo3.modified_time = 'xxx';
|
||||
fileList.push(fileInfo3);
|
||||
let fileInfo4: FileInfo = new FileInfo("视频3");
|
||||
fileInfo4.type = MediaType.MEDIA_TYPE_ALBUM;
|
||||
fileInfo4.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/15';
|
||||
fileInfo4.dataAdded_time = 'xxx';
|
||||
fileInfo4.modified_time = 'xxx';
|
||||
fileList.push(fileInfo4);
|
||||
let fileInfo5: FileInfo = new FileInfo("视频4");
|
||||
fileInfo5.type = MediaType.MEDIA_TYPE_ALBUM;
|
||||
fileInfo5.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/16';
|
||||
fileInfo5.dataAdded_time = 'xxx';
|
||||
fileInfo5.modified_time = 'xxx';
|
||||
fileList.push(fileInfo5);
|
||||
} else if (mediaType == 'audio') {
|
||||
let fileInfo1: FileInfo = new FileInfo("音乐0");
|
||||
fileInfo1.type = MediaType.MEDIA_TYPE_ALBUM;
|
||||
fileInfo1.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/17';
|
||||
fileInfo1.dataAdded_time = 'xxx';
|
||||
fileInfo1.modified_time = 'xxx';
|
||||
fileList.push(fileInfo1);
|
||||
let fileInfo2: FileInfo = new FileInfo("音乐1");
|
||||
fileInfo2.type = MediaType.MEDIA_TYPE_ALBUM;
|
||||
fileInfo2.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/18';
|
||||
fileInfo2.dataAdded_time = 'xxx';
|
||||
fileInfo2.modified_time = 'xxx';
|
||||
fileList.push(fileInfo2);
|
||||
let fileInfo3: FileInfo = new FileInfo("音乐2");
|
||||
fileInfo3.type = MediaType.MEDIA_TYPE_ALBUM;
|
||||
fileInfo3.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/19';
|
||||
fileInfo3.dataAdded_time = 'xxx';
|
||||
fileInfo3.modified_time = 'xxx';
|
||||
fileList.push(fileInfo3);
|
||||
let fileInfo4: FileInfo = new FileInfo("音乐3");
|
||||
fileInfo4.type = MediaType.MEDIA_TYPE_ALBUM;
|
||||
fileInfo4.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/20';
|
||||
fileInfo4.dataAdded_time = 'xxx';
|
||||
fileInfo4.modified_time = 'xxx';
|
||||
fileList.push(fileInfo4);
|
||||
let fileInfo5: FileInfo = new FileInfo("音乐4");
|
||||
fileInfo5.type = MediaType.MEDIA_TYPE_ALBUM;
|
||||
fileInfo5.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/21';
|
||||
fileInfo5.dataAdded_time = 'xxx';
|
||||
fileInfo5.modified_time = 'xxx';
|
||||
fileList.push(fileInfo5);
|
||||
} else if (mediaType == 'file') {
|
||||
let fileInfo1: FileInfo = new FileInfo("文件夹0");
|
||||
fileInfo1.type = MediaType.MEDIA_TYPE_ALBUM;
|
||||
fileInfo1.mediaType = mediaType;
|
||||
fileInfo1.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/22';
|
||||
fileInfo1.dataAdded_time = 'xxx';
|
||||
fileInfo1.modified_time = 'xxx';
|
||||
fileList.push(fileInfo1);
|
||||
let fileInfo2: FileInfo = new FileInfo("文件夹1");
|
||||
fileInfo2.type = MediaType.MEDIA_TYPE_ALBUM;
|
||||
fileInfo2.mediaType = mediaType;
|
||||
fileInfo2.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/23';
|
||||
fileInfo2.dataAdded_time = 'xxx';
|
||||
fileInfo2.modified_time = 'xxx';
|
||||
fileList.push(fileInfo2);
|
||||
let fileInfo3: FileInfo = new FileInfo("文件夹2");
|
||||
fileInfo3.type = MediaType.MEDIA_TYPE_ALBUM;
|
||||
fileInfo3.mediaType = mediaType;
|
||||
fileInfo3.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/24';
|
||||
fileInfo3.dataAdded_time = 'xxx';
|
||||
fileInfo3.modified_time = 'xxx';
|
||||
fileList.push(fileInfo3);
|
||||
let fileInfo4: FileInfo = new FileInfo("文件夹3");
|
||||
fileInfo4.type = MediaType.MEDIA_TYPE_ALBUM;
|
||||
fileInfo4.mediaType = mediaType;
|
||||
fileInfo4.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/25';
|
||||
fileInfo4.dataAdded_time = 'xxx';
|
||||
fileInfo4.modified_time = 'xxx';
|
||||
fileList.push(fileInfo4);
|
||||
let fileInfo5: FileInfo = new FileInfo("文件夹4");
|
||||
fileInfo5.type = MediaType.MEDIA_TYPE_ALBUM;
|
||||
fileInfo5.mediaType = mediaType;
|
||||
fileInfo5.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/26';
|
||||
fileInfo5.dataAdded_time = 'xxx';
|
||||
fileInfo5.modified_time = 'xxx';
|
||||
fileList.push(fileInfo5);
|
||||
let fileInfo6: FileInfo = new FileInfo("文本文档.txt");
|
||||
fileInfo6.type = MediaType.MEDIA_TYPE_FILE;
|
||||
fileInfo6.mediaType = mediaType;
|
||||
fileInfo6.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/27';
|
||||
fileInfo6.dataAdded_time = 'xxx';
|
||||
fileInfo6.modified_time = 'xxx';
|
||||
fileInfo6.size = '1,024 KB'
|
||||
fileList.push(fileInfo6);
|
||||
let fileInfo7: FileInfo = new FileInfo("验收文稿.ppt");
|
||||
fileInfo7.type = MediaType.MEDIA_TYPE_FILE;
|
||||
fileInfo7.mediaType = mediaType;
|
||||
fileInfo7.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/28';
|
||||
fileInfo7.dataAdded_time = 'xxx';
|
||||
fileInfo7.modified_time = 'xxx';
|
||||
fileInfo7.size = '4,562,000 KB'
|
||||
fileList.push(fileInfo7);
|
||||
}
|
||||
} else {
|
||||
if (mediaType == 'image') {
|
||||
for (var index = 0; index < 10; index++) {
|
||||
let file: FileInfo = new FileInfo("" + index + ".png");
|
||||
file.type = MediaType.MEDIA_TYPE_IMAGE;
|
||||
file.path = path + index;
|
||||
file.dataAdded_time = 'xxx';
|
||||
file.modified_time = 'xxx';
|
||||
fileList.push(file);
|
||||
}
|
||||
} else if (mediaType == 'video') {
|
||||
for (var index = 0; index < 15; index++) {
|
||||
let file: FileInfo = new FileInfo("" + index + ".wmv");
|
||||
file.type = MediaType.MEDIA_TYPE_VIDEO;
|
||||
file.path = path + index;
|
||||
file.dataAdded_time = 'xxx';
|
||||
file.modified_time = 'xxx';
|
||||
fileList.push(file);
|
||||
}
|
||||
} else if (mediaType == 'audio') {
|
||||
for (var index = 0; index < 18; index++) {
|
||||
let file: FileInfo = new FileInfo("" + index + ".mp3");
|
||||
file.type = MediaType.MEDIA_TYPE_AUDIO;
|
||||
file.path = path + index;
|
||||
file.dataAdded_time = 'xxx';
|
||||
file.modified_time = 'xxx';
|
||||
fileList.push(file);
|
||||
}
|
||||
} else if (mediaType == 'file') {
|
||||
let fileInfo4: FileInfo = new FileInfo("文件夹3");
|
||||
fileInfo4.type = MediaType.MEDIA_TYPE_ALBUM;
|
||||
fileInfo4.path = path + '5';
|
||||
fileInfo4.dataAdded_time = 'xxx';
|
||||
fileInfo4.modified_time = 'xxx';
|
||||
fileList.push(fileInfo4);
|
||||
let fileInfo5: FileInfo = new FileInfo("文件夹4");
|
||||
fileInfo5.type = MediaType.MEDIA_TYPE_ALBUM;
|
||||
fileInfo5.path = path + '6';
|
||||
fileInfo5.dataAdded_time = 'xxx';
|
||||
fileInfo5.modified_time = 'xxx';
|
||||
fileList.push(fileInfo5);
|
||||
let fileInfo6: FileInfo = new FileInfo("文本文档.txt");
|
||||
fileInfo6.type = MediaType.MEDIA_TYPE_FILE;
|
||||
fileInfo6.path = path + '7';
|
||||
fileInfo6.size = '1,000 KB'
|
||||
fileInfo6.dataAdded_time = 'xxx';
|
||||
fileInfo6.modified_time = 'xxx';
|
||||
fileList.push(fileInfo6);
|
||||
let fileInfo7: FileInfo = new FileInfo("验收文稿.ppt");
|
||||
fileInfo7.type = MediaType.MEDIA_TYPE_FILE;
|
||||
fileInfo7.path = path + '8';
|
||||
fileInfo7.size = '520,000 KB'
|
||||
fileInfo7.dataAdded_time = 'xxx';
|
||||
fileInfo7.modified_time = 'xxx';
|
||||
fileList.push(fileInfo7);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// fileList = filemanager.listfile(deviceName, mediaType, path);
|
||||
}
|
||||
logInfo(TAG, "get file list is " + fileList.length)
|
||||
return fileList;
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@@ -13,10 +13,19 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export function LogInfo(TAG: string, message: string | number): void {
|
||||
console.info('filePicker_' + TAG + ': ' + message)
|
||||
export function logDebug(TAG: string, message: string | number): void {
|
||||
console.debug('FilePicker_' + TAG + ': ' + message)
|
||||
}
|
||||
|
||||
export function LogDebug(TAG: string, message: string | number): void {
|
||||
console.debug('filePicker_' + TAG + ': ' + message)
|
||||
export function logInfo(TAG: string, message: string | number): void {
|
||||
console.info('FilePicker_' + TAG + ': ' + message)
|
||||
}
|
||||
|
||||
|
||||
export function logWarn(TAG: string, message: string | number): void {
|
||||
console.warn('FilePicker_' + TAG + ': ' + message)
|
||||
}
|
||||
|
||||
export function logError(TAG: string, message: string | number): void {
|
||||
console.error('FilePicker_' + TAG + ': ' + message)
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { MediaName } from "../Data/Constants"
|
||||
import { TopPathInfo } from '../data/toppathinfo'
|
||||
import { logInfo } from './logutils'
|
||||
|
||||
var TAG: string = 'Utils'
|
||||
|
||||
var strTypeArr = [
|
||||
[MediaName.IMAGE, '图片'],
|
||||
[MediaName.VIDEO, '视频'],
|
||||
[MediaName.AUDIO, '音乐'],
|
||||
[MediaName.FILE, '文档'],
|
||||
]
|
||||
|
||||
export function changeTypeToString(mediaType: string): string {
|
||||
logInfo(TAG, 'changeTypeToString type = ' + mediaType)
|
||||
for (var i = 0; i < strTypeArr.length; i++) {
|
||||
if (strTypeArr[i][0] == mediaType) {
|
||||
return strTypeArr[i][1]
|
||||
}
|
||||
}
|
||||
return ''
|
||||
}
|
||||
|
||||
export function changeStringToType(name: string): string {
|
||||
logInfo(TAG, 'changeStringToType type = ' + name)
|
||||
for (var i = 0; i < strTypeArr.length; i++) {
|
||||
if (strTypeArr[i][1] == name) {
|
||||
return strTypeArr[i][0]
|
||||
}
|
||||
}
|
||||
return ''
|
||||
}
|
||||
|
||||
var fileSuffixAndType = [
|
||||
['.doc', $r("app.media.ic_file_doc"), $r("app.string.file_docx")],
|
||||
['.html', $r("app.media.ic_file_html"), $r("app.string.file_html")],
|
||||
['.pdf', $r("app.media.ic_file_pdf"), $r("app.string.file_pdf")],
|
||||
['.pptx', $r("app.media.ic_file_pptx"), $r("app.string.file_pptx")],
|
||||
['.ppt', $r("app.media.ic_file_pptx"), $r("app.string.file_pptx")],
|
||||
['.rar', $r("app.media.ic_file_rar"), $r("app.string.file_rar")],
|
||||
['.txt', $r("app.media.ic_file_txt"), $r("app.string.file_txt")],
|
||||
['.xls', $r("app.media.ic_file_xls"), $r("app.string.file_xls")],
|
||||
['.xml', $r("app.media.ic_file_xml"), $r("app.string.file_xml")],
|
||||
['.zip', $r("app.media.ic_file_zip"), $r("app.string.file_zip")],
|
||||
]
|
||||
|
||||
export function getShowIconBySuffix(suffix: string): string | Resource {
|
||||
logInfo(TAG, 'getShowIconBySuffix suffix = ' + suffix)
|
||||
for (var i = 0; i < fileSuffixAndType.length; i++) {
|
||||
if (isTwoStringEqual(fileSuffixAndType[i][0].toString(), suffix)) {
|
||||
return fileSuffixAndType[i][1]
|
||||
}
|
||||
}
|
||||
return $r("app.media.ic_file_unknown")
|
||||
}
|
||||
|
||||
function isTwoStringEqual(src: string, tar: string) {
|
||||
if (src.indexOf(tar) == 0 && tar.indexOf(src) == 0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export function updateTopPathInfo(currentPathInfo: Array<TopPathInfo>, name: string, path: string) {
|
||||
currentPathInfo.forEach((item: TopPathInfo) => {
|
||||
item.opacity = 0.4
|
||||
})
|
||||
|
||||
currentPathInfo.push(new TopPathInfo(name, path))
|
||||
AppStorage.Set('topPathInfo', currentPathInfo)
|
||||
return currentPathInfo
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { FileInfo } from '../Data/FileInfo'
|
||||
import { logInfo } from '../Utils/LogUtils'
|
||||
|
||||
let TAG: string = 'DialogUtils'
|
||||
|
||||
@CustomDialog
|
||||
export struct ChooseDialog {
|
||||
controller: CustomDialogController
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
Row() {
|
||||
Text('选择该文件')
|
||||
}
|
||||
|
||||
Row() {
|
||||
Button() {
|
||||
Text('取消')
|
||||
.height('100%')
|
||||
.fontSize(24)
|
||||
.fontColor(Color.Blue)
|
||||
}
|
||||
.width(px2vp(200))
|
||||
.height(px2vp(50))
|
||||
.backgroundColor(Color.White)
|
||||
.onClick(() => {
|
||||
this.controller.close()
|
||||
})
|
||||
|
||||
Divider()
|
||||
.vertical(true)
|
||||
.color(Color.Gray)
|
||||
.height(40)
|
||||
.margin({ top: 0, right: 10, bottom: 0, left: 10 })
|
||||
|
||||
Button() {
|
||||
Text('确定')
|
||||
.height('100%')
|
||||
.fontSize(24)
|
||||
.fontColor(Color.Blue)
|
||||
}
|
||||
.width(px2vp(200))
|
||||
.height(px2vp(50))
|
||||
.backgroundColor(Color.White)
|
||||
.onClick(() => {
|
||||
let choseItem: FileInfo = AppStorage.Get<FileInfo>('selectedFileInfo')
|
||||
if (choseItem != null) {
|
||||
let files: Array<FileInfo> = AppStorage.Get('choseFiles')
|
||||
let flag: boolean = true
|
||||
files.forEach((item: FileInfo) => {
|
||||
logInfo(TAG, 'item.name = ' + item.name + '; item.path = ' + item.path)
|
||||
logInfo(TAG, 'choseItem.name = ' + choseItem.name + '; choseItem.path = ' + choseItem.path)
|
||||
if (item.name == choseItem.name && item.path == choseItem.path) {
|
||||
flag = false
|
||||
}
|
||||
})
|
||||
if (flag) {
|
||||
files.push(choseItem)
|
||||
AppStorage.Set('choseFiles', files)
|
||||
}
|
||||
}
|
||||
this.controller.close()
|
||||
})
|
||||
}
|
||||
.padding(20)
|
||||
}
|
||||
.padding({
|
||||
top: 25,
|
||||
right: 0,
|
||||
bottom: 15,
|
||||
left: 0
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
@CustomDialog
|
||||
export struct WarningDialog {
|
||||
@Link code: number
|
||||
controller: CustomDialogController
|
||||
cancel: () => void
|
||||
confirm: () => void
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
Text('Warning Title').fontSize(20).margin(10)
|
||||
if (this.code == 1) {
|
||||
Text($r("app.string.save_file_has_same_file")).fontSize(16).margin(10)
|
||||
} else if (this.code == 2) {
|
||||
Text($r("app.string.save_file_no_media_permission")).fontSize(16).margin(10)
|
||||
} else {
|
||||
Text($r("app.string.save_file_unknown_reason")).fontSize(16).margin(10)
|
||||
}
|
||||
Flex({ justifyContent: FlexAlign.SpaceAround }) {
|
||||
Button('cancel')
|
||||
.onClick(() => {
|
||||
this.controller.close()
|
||||
this.cancel()
|
||||
})
|
||||
.backgroundColor("0xffffff")
|
||||
.fontColor(Color.Black)
|
||||
Button('confirm')
|
||||
.onClick(() => {
|
||||
this.controller.close()
|
||||
this.confirm()
|
||||
})
|
||||
.backgroundColor("0xffffff")
|
||||
.fontColor(Color.Red)
|
||||
}.margin({ bottom: 10 })
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"module": {
|
||||
"name": "common",
|
||||
"type": "har",
|
||||
"deviceTypes": [
|
||||
"phone",
|
||||
"tablet"
|
||||
],
|
||||
"uiSyntax": "ets"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
{
|
||||
"string": [
|
||||
{
|
||||
"name": "page_show",
|
||||
"value": "page from npm package"
|
||||
},
|
||||
{
|
||||
"name": "save_file_has_same_file",
|
||||
"value": "Duplicate name file already exists"
|
||||
},
|
||||
{
|
||||
"name": "save_file_no_media_permission",
|
||||
"value": "Saving to media library is not currently supported"
|
||||
},
|
||||
{
|
||||
"name": "save_file_unknown_reason",
|
||||
"value": "Unknown error"
|
||||
},
|
||||
{
|
||||
"name": "file_unknown",
|
||||
"value": "Unknown file"
|
||||
},
|
||||
{
|
||||
"name": "file_zip",
|
||||
"value": "Compressed (zipped) file"
|
||||
},
|
||||
{
|
||||
"name": "file_xml",
|
||||
"value": "XML document"
|
||||
},
|
||||
{
|
||||
"name": "file_xls",
|
||||
"value": "Microsoft Excel worksheet"
|
||||
},
|
||||
{
|
||||
"name": "file_txt",
|
||||
"value": "Txt document"
|
||||
},
|
||||
{
|
||||
"name": "file_rar",
|
||||
"value": "Rar compressed file"
|
||||
},
|
||||
{
|
||||
"name": "file_pdf",
|
||||
"value": "Adobe Acrobat Document"
|
||||
},
|
||||
{
|
||||
"name": "file_html",
|
||||
"value": "HTML Document"
|
||||
},
|
||||
{
|
||||
"name": "file_pptx",
|
||||
"value": "Microsoft PowerPoint Presentation"
|
||||
},
|
||||
{
|
||||
"name": "file_docx",
|
||||
"value": "Microsoft Word Document"
|
||||
},
|
||||
{
|
||||
"name": "file_type",
|
||||
"value": "file type"
|
||||
},
|
||||
{
|
||||
"name": "file_name",
|
||||
"value": "file name : "
|
||||
}
|
||||
]
|
||||
}
|
||||
|
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.5 KiB |
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.4 KiB |
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 2.8 KiB |
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 3.3 KiB |
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 2.8 KiB |
|
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 2.6 KiB |
|
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 2.6 KiB |
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.7 KiB |
@@ -0,0 +1,64 @@
|
||||
{
|
||||
"string": [
|
||||
{
|
||||
"name": "save_file_has_same_file",
|
||||
"value": "已有重名文件"
|
||||
},
|
||||
{
|
||||
"name": "save_file_no_media_permission",
|
||||
"value": "当前不支持保存到媒体库"
|
||||
},
|
||||
{
|
||||
"name": "save_file_unknown_reason",
|
||||
"value": "未知错误"
|
||||
},
|
||||
{
|
||||
"name": "file_unknown",
|
||||
"value": "未知文件"
|
||||
},
|
||||
{
|
||||
"name": "file_zip",
|
||||
"value": "压缩(zipped)文件"
|
||||
},
|
||||
{
|
||||
"name": "file_xml",
|
||||
"value": "XML文档"
|
||||
},
|
||||
{
|
||||
"name": "file_xls",
|
||||
"value": "Microsoft Excel工作表"
|
||||
},
|
||||
{
|
||||
"name": "file_txt",
|
||||
"value": "TXT文档"
|
||||
},
|
||||
{
|
||||
"name": "file_rar",
|
||||
"value": "RAR压缩文件"
|
||||
},
|
||||
{
|
||||
"name": "file_pdf",
|
||||
"value": "Adobe Acrobat Document"
|
||||
},
|
||||
{
|
||||
"name": "file_html",
|
||||
"value": "HTML网页文件"
|
||||
},
|
||||
{
|
||||
"name": "file_pptx",
|
||||
"value": "Microsoft PowerPoint演示文稿"
|
||||
},
|
||||
{
|
||||
"name": "file_docx",
|
||||
"value": "Microsoft Word文档"
|
||||
},
|
||||
{
|
||||
"name": "file_type",
|
||||
"value": "文件类型"
|
||||
},
|
||||
{
|
||||
"name": "file_name",
|
||||
"value": "文件名:"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { mediaType } from './Constants.ets'
|
||||
|
||||
export class FileInfo {
|
||||
name: string
|
||||
path: string
|
||||
type: number= mediaType.MEDIA_TYPE_ALBUM
|
||||
size: string
|
||||
dataAdded_time: string
|
||||
modified_time: string
|
||||
mediaType: string
|
||||
thumbnail: Resource
|
||||
font_color: Color | string | Resource
|
||||
opacity: number
|
||||
list_background: string | Resource
|
||||
|
||||
constructor(name: string) {
|
||||
this.name = name
|
||||
}
|
||||
}
|
||||
|
||||
export class TopPathInfo {
|
||||
name: string
|
||||
path: string
|
||||
opacity: number = 1
|
||||
|
||||
constructor(name: string, path: string) {
|
||||
this.name = name
|
||||
this.path = path
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,18 @@
|
||||
{
|
||||
"license": "ISC",
|
||||
"devDependencies": {},
|
||||
"name": "filepicker",
|
||||
"ohos": {
|
||||
"org": "huawei",
|
||||
"directoryLevel": "project",
|
||||
"buildTool": "hvigor"
|
||||
"license":"ISC",
|
||||
"devDependencies":{},
|
||||
"name":"filepicker",
|
||||
"ohos":{
|
||||
"org":"huawei",
|
||||
"directoryLevel":"project",
|
||||
"buildTool":"hvigor"
|
||||
},
|
||||
"description": "example description",
|
||||
"repository": {},
|
||||
"version": "1.0.0",
|
||||
"dependencies": {
|
||||
"@ohos/hvigor-ohos-plugin": "1.0.6",
|
||||
"hypium": "^1.0.0",
|
||||
"@ohos/hvigor": "1.0.6"
|
||||
"description":"example description",
|
||||
"repository":{},
|
||||
"version":"1.0.0",
|
||||
"dependencies":{
|
||||
"@ohos/hvigor-ohos-plugin":"1.0.6",
|
||||
"hypium":"^1.0.0",
|
||||
"@ohos/hvigor":"1.0.6"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,11 @@
|
||||
{
|
||||
"name": "rk",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 1
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
"@ohos/common": {
|
||||
"version": "file:../../common"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
{
|
||||
"license": "ISC",
|
||||
"devDependencies": {},
|
||||
"name": "rk",
|
||||
"ohos": {
|
||||
"org": "huawei",
|
||||
"directoryLevel": "module",
|
||||
"buildTool": "hvigor"
|
||||
},
|
||||
"description": "example description",
|
||||
"repository": {},
|
||||
"version": "1.0.0",
|
||||
"dependencies": {}
|
||||
"license": "ISC",
|
||||
"devDependencies": {},
|
||||
"name": "rk",
|
||||
"ohos": {
|
||||
"org": "huawei",
|
||||
"directoryLevel": "module",
|
||||
"buildTool": "hvigor"
|
||||
},
|
||||
"description": "example description",
|
||||
"repository": {},
|
||||
"version": "1.0.0",
|
||||
"dependencies": {
|
||||
"@ohos/common": "file:../../common"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,25 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import AbilityStage from "@ohos.application.AbilityStage"
|
||||
import { logInfo } from '../../../../../../common/src/main/ets/components/Utils/LogUtils'
|
||||
|
||||
const TAG = "MyAbilityStage"
|
||||
|
||||
export default class MyAbilityStage extends AbilityStage {
|
||||
onCreate() {
|
||||
console.log("[Demo] MyAbilityStage onCreate")
|
||||
logInfo(TAG, "onCreate")
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import Ability from '@ohos.application.Ability'
|
||||
import display from '@ohos.display'
|
||||
import { Callback } from 'basic'
|
||||
import { LogInfo, LogDebug } from '../module/LogUtils'
|
||||
import { logInfo, logError, logWarn } from '../../../../../../common/src/main/ets/components/Utils/LogUtils'
|
||||
|
||||
let displayWidth: number = 0
|
||||
let displayHeight: number = 0
|
||||
@@ -10,25 +10,22 @@ const TAG = "MainAbility"
|
||||
|
||||
export default class MainAbility extends Ability {
|
||||
onCreate(want, launchParam) {
|
||||
console.log("filePicker_MainAbility: onCreate")
|
||||
logInfo(TAG, "onCreate")
|
||||
globalThis.abilityWant = want;
|
||||
|
||||
globalThis.startMode = want.parameters.startMode
|
||||
globalThis.saveFile = want.parameters.saveFile
|
||||
globalThis.debugMode = want.parameters.debugMode
|
||||
console.log('filePicker_MainAbility: startMode = ' + globalThis.startMode)
|
||||
console.log('filePicker_MainAbility: file_name = ' + globalThis.saveFile)
|
||||
console.log('filePicker_MainAbility: debugMode = ' + globalThis.debugMode)
|
||||
|
||||
logInfo(TAG, `parameters ${JSON.stringify(want.parameters)}`)
|
||||
}
|
||||
|
||||
onDestroy() {
|
||||
console.log("[Demo] MainAbility onDestroy")
|
||||
logInfo(TAG, "onDestroy")
|
||||
}
|
||||
|
||||
onWindowStageCreate(windowStage) {
|
||||
// Main window is created, set main page for this ability
|
||||
LogInfo(TAG, "[Demo] MainAbility onWindowStageCreate")
|
||||
logInfo(TAG, "onWindowStageCreate")
|
||||
|
||||
globalThis.context = this.context
|
||||
|
||||
@@ -37,17 +34,17 @@ export default class MainAbility extends Ability {
|
||||
|
||||
onWindowStageDestroy() {
|
||||
// Main window is destroyed, release UI related resources
|
||||
console.log("[Demo] MainAbility onWindowStageDestroy")
|
||||
logInfo(TAG, "onWindowStageDestroy")
|
||||
}
|
||||
|
||||
onForeground() {
|
||||
// Ability has brought to foreground
|
||||
console.log("[Demo] MainAbility onForeground")
|
||||
logInfo(TAG, "onForeground")
|
||||
}
|
||||
|
||||
onBackground() {
|
||||
// Ability has back to background
|
||||
console.log("[Demo] MainAbility onBackground")
|
||||
logInfo(TAG, "onBackground")
|
||||
}
|
||||
|
||||
private requestPermissions(callback: Callback<void>) {
|
||||
@@ -57,10 +54,10 @@ export default class MainAbility extends Ability {
|
||||
"ohos.permission.WRITE_MEDIA"
|
||||
]
|
||||
globalThis.context.requestPermissionsFromUser(permissionList).then(function (data) {
|
||||
LogInfo(TAG, 'filePicker_MainAbility: request permission data result = ' + data.authResults)
|
||||
logInfo(TAG, 'request permission data result = ' + data.authResults)
|
||||
callback()
|
||||
}, (error) => {
|
||||
LogInfo(TAG, 'filePicker_MainAbility: fail to request permission error code = ' + error.code)
|
||||
logError(TAG, 'fail to request permission error code = ' + error.code)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -74,10 +71,10 @@ export default class MainAbility extends Ability {
|
||||
globalThis.mainDialogWidth = dis.width
|
||||
globalThis.mainDialogHeight = (((displayHeight) - 180) * 0.7) / 1.3
|
||||
|
||||
LogInfo(TAG, "cjl displayWidth = " + displayWidth + " displayHeight = " + displayHeight)
|
||||
logInfo(TAG, "displayWidth = " + displayWidth + " displayHeight = " + displayHeight)
|
||||
|
||||
windowStage.getMainWindow().then(win => {
|
||||
LogInfo(TAG, "cjl windowStage.getMainWindow()")
|
||||
logInfo(TAG, "windowStage.getMainWindow()")
|
||||
|
||||
win.resetSize(displayWidth, displayHeight - 120)
|
||||
|
||||
@@ -85,25 +82,25 @@ export default class MainAbility extends Ability {
|
||||
|
||||
win.setBackgroundColor("#00FFFFFF", (err, data) => {
|
||||
if (err.code) {
|
||||
LogInfo(TAG, "Fail to set the background color" + JSON.stringify(err))
|
||||
logWarn(TAG, "Fail to set the background color" + JSON.stringify(err))
|
||||
} else {
|
||||
LogInfo(TAG, "Success to set the background color" + JSON.stringify(data))
|
||||
logInfo(TAG, "Success to set the background color" + JSON.stringify(data))
|
||||
}
|
||||
})
|
||||
|
||||
win.disableWindowDecor((err, data) => {
|
||||
if (err.code) {
|
||||
LogInfo(TAG, 'Failed to set the disableWindowDecor. Data: ' + JSON.stringify(data))
|
||||
logWarn(TAG, "Fail to disable Window Decor" + JSON.stringify(err))
|
||||
} else {
|
||||
LogInfo(TAG, 'Succeeded in setting the disableWindowDecor. Data: ' + JSON.stringify(data))
|
||||
logInfo(TAG, "Success to disable Window Decor" + JSON.stringify(data))
|
||||
}
|
||||
})
|
||||
|
||||
win.setWindowMode(102, (err, data) => {
|
||||
if (err.code) {
|
||||
LogInfo(TAG, 'Failed to set the setWindowMode. Data: ' + JSON.stringify(data))
|
||||
logWarn(TAG, 'Failed to set the setWindowMode. Data: ' + JSON.stringify(data))
|
||||
} else {
|
||||
LogInfo(TAG, 'Succeeded in setting the setWindowMode. Data: ' + JSON.stringify(data))
|
||||
logInfo(TAG, 'Succeeded in setting the setWindowMode. Data: ' + JSON.stringify(data))
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@@ -1,91 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import display from '@ohos.display'
|
||||
import featureAbility from '@ohos.ability.featureAbility'
|
||||
import { LogInfo } from '../module/LogUtils.ets'
|
||||
import { DisplayInfo } from './DisplayInfo.ets'
|
||||
|
||||
var TAG: string = 'AbilityUtils'
|
||||
|
||||
export function terminateSelfWithResult(resultCode: number, result: string): void {
|
||||
LogInfo(TAG, 'terminateSelfWithResult')
|
||||
let startMode: string = AppStorage.Get<string>('startMode')
|
||||
var abilityResult = {
|
||||
resultCode: resultCode,
|
||||
want: {
|
||||
parameters: {
|
||||
'startMode': startMode,
|
||||
'result': result
|
||||
}
|
||||
}
|
||||
}
|
||||
globalThis.context.terminateSelfWithResult(abilityResult, (error) => {
|
||||
if (error.code) {
|
||||
LogInfo(TAG, 'Operation failed. Cause: ' + JSON.stringify(error))
|
||||
return
|
||||
}
|
||||
LogInfo(TAG, 'Operation succeeded')
|
||||
})
|
||||
}
|
||||
|
||||
export function initData(): void {
|
||||
LogInfo(TAG, 'initData')
|
||||
initWindowScale()
|
||||
|
||||
getWantFromHap()
|
||||
}
|
||||
|
||||
function initWindowScale(): void {
|
||||
display.getDefaultDisplay().then(dis => {
|
||||
LogInfo(TAG, 'width = ' + dis.width + ';height= ' + dis.height)
|
||||
let displayInfo: DisplayInfo = new DisplayInfo()
|
||||
|
||||
if (dis.width > dis.height) { // 横屏
|
||||
displayInfo.width = dis.width
|
||||
displayInfo.height = dis.height * 0.6 // 需要减去信号栏和导航栏的高度
|
||||
displayInfo.mainDialogHeight = displayInfo.height - vp2px(64 + 76)
|
||||
displayInfo.mainDialogWidth = displayInfo.width
|
||||
|
||||
} else { // 竖屏
|
||||
displayInfo.width = dis.width
|
||||
displayInfo.height = dis.height * 0.65 // 需要减去信号栏和导航栏的高度
|
||||
displayInfo.mainDialogHeight = displayInfo.height - vp2px(64 + 76)
|
||||
//displayInfo.mainDialogHeight = displayInfo.height - (64 + 76) * 2
|
||||
displayInfo.mainDialogWidth = displayInfo.width
|
||||
}
|
||||
|
||||
LogInfo(TAG, 'mainDialogWidth = ' + displayInfo.mainDialogWidth)
|
||||
LogInfo(TAG, 'mainDialogHeight = ' + displayInfo.mainDialogHeight)
|
||||
AppStorage.SetOrCreate('displayInfo', displayInfo)
|
||||
})
|
||||
}
|
||||
|
||||
function getWantFromHap(): void {
|
||||
featureAbility.getWant()
|
||||
.then((Want) => {
|
||||
var mode: string = Want.parameters['startMode']
|
||||
if (mode == undefined) {
|
||||
AppStorage.SetOrCreate<string>('startMode', 'choose')
|
||||
} else {
|
||||
AppStorage.SetOrCreate<string>('startMode', mode)
|
||||
}
|
||||
let save_name: string = Want.parameters['file_name']
|
||||
AppStorage.Set<string>('saveName', save_name)
|
||||
LogInfo(TAG, 'saveName = ' + save_name)
|
||||
}).catch((error) => {
|
||||
LogInfo(TAG, 'fail Data: ' + JSON.stringify(error))
|
||||
})
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export enum menuLevel {
|
||||
MENU_FIRST_LEVEL_BY_TYPE = 1,
|
||||
MENU_SECOND_LEVEL_BY_FOLD = 2,
|
||||
MENU_THIRD_LEVEL_HAS_PIC = 3,
|
||||
MENU_THIRD_LEVEL_HAS_DETAIL = 4,
|
||||
}
|
||||
|
||||
export enum media_type {
|
||||
MEDIA_TYPE_FILE = 1,
|
||||
MEDIA_TYPE_IMAGE = 3,
|
||||
MEDIA_TYPE_VIDEO = 4,
|
||||
MEDIA_TYPE_AUDIO = 5,
|
||||
MEDIA_TYPE_ALBUM = 8
|
||||
}
|
||||
|
||||
export enum GridItemSize {
|
||||
GRID_ITEM_HEIGHT = 126,
|
||||
//GRID_ITEM_WIDTH = 112,
|
||||
GRID_ITEM_WIDTH = 96,
|
||||
GRID_ITEM_COLUMNS_GAP = 8,
|
||||
GRID_ITEM_ROWS_GAP = 8,
|
||||
}
|
||||
|
||||
export enum terminate_reason {
|
||||
SUCCESS = 0,
|
||||
NO_ACTION = -1,
|
||||
}
|
||||
@@ -1,110 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { FileInfo } from './FileInfo.ets'
|
||||
|
||||
@CustomDialog
|
||||
export struct WarningDialog {
|
||||
@Link code: number
|
||||
controller: CustomDialogController
|
||||
cancel: () => void
|
||||
confirm: () => void
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
Text('Warning Title').fontSize(20).margin(10)
|
||||
if (this.code == 1) {
|
||||
Text($r("app.string.save_file_has_same_file")).fontSize(16).margin(10)
|
||||
} else if (this.code == 2) {
|
||||
Text($r("app.string.save_file_no_media_permission")).fontSize(16).margin(10)
|
||||
} else {
|
||||
Text($r("app.string.save_file_unknown_reason")).fontSize(16).margin(10)
|
||||
}
|
||||
Flex({ justifyContent: FlexAlign.SpaceAround }) {
|
||||
Button('cancel')
|
||||
.onClick(() => {
|
||||
this.controller.close()
|
||||
this.cancel()
|
||||
}).backgroundColor(0xffffff).fontColor(Color.Black)
|
||||
Button('confirm')
|
||||
.onClick(() => {
|
||||
this.controller.close()
|
||||
this.confirm()
|
||||
}).backgroundColor(0xffffff).fontColor(Color.Red)
|
||||
}.margin({ bottom: 10 })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@CustomDialog
|
||||
export struct ChooseDialog {
|
||||
controller: CustomDialogController
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
Row() {
|
||||
Text('选择该文件')
|
||||
}
|
||||
Row() {
|
||||
Button() {
|
||||
Text('取消')
|
||||
.height('100%')
|
||||
.fontSize(24)
|
||||
.fontColor(Color.Blue)
|
||||
}
|
||||
.width(px2vp(200))
|
||||
.height(px2vp(50))
|
||||
.backgroundColor(Color.White)
|
||||
.onClick(() => {
|
||||
this.controller.close()
|
||||
})
|
||||
|
||||
Divider()
|
||||
.vertical(true)
|
||||
.color(Color.Gray)
|
||||
.height(40)
|
||||
.margin({top: 0, right: 10, bottom: 0, left: 10})
|
||||
|
||||
Button() {
|
||||
Text('确定')
|
||||
.height('100%')
|
||||
.fontSize(24)
|
||||
.fontColor(Color.Blue)
|
||||
}
|
||||
.width(px2vp(200))
|
||||
.height(px2vp(50))
|
||||
.backgroundColor(Color.White)
|
||||
.onClick(() => {
|
||||
let item: FileInfo = AppStorage.Get<FileInfo>('selectedFileInfo')
|
||||
if (item != null) {
|
||||
let files: Array<FileInfo> = AppStorage.Get('choseFiles')
|
||||
if (files.indexOf(item) == -1) {
|
||||
files.push(item)
|
||||
AppStorage.Set('choseFiles', files)
|
||||
}
|
||||
}
|
||||
this.controller.close()
|
||||
})
|
||||
}
|
||||
.padding(20)
|
||||
}
|
||||
.padding({
|
||||
top: 25,
|
||||
right: 0,
|
||||
bottom: 15,
|
||||
left: 0
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export class DisplayInfo {
|
||||
width: number
|
||||
height: number
|
||||
mainDialogWidth: number
|
||||
mainDialogHeight: number
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { media_type } from './Constants.ets'
|
||||
|
||||
export class FileInfo {
|
||||
name: string
|
||||
path: string
|
||||
type: number= media_type.MEDIA_TYPE_ALBUM
|
||||
size: string
|
||||
dataAdded_time: string
|
||||
modified_time: string
|
||||
mediaType: string
|
||||
thumbnail: Resource
|
||||
font_color: Color | string | Resource
|
||||
opacity: number
|
||||
list_background: string | Resource
|
||||
|
||||
constructor(name: string) {
|
||||
this.name = name
|
||||
}
|
||||
}
|
||||
|
||||
export class TopPathInfo {
|
||||
name: string
|
||||
path: string
|
||||
opacity: number = 1
|
||||
|
||||
constructor(name: string, path: string) {
|
||||
this.name = name
|
||||
this.path = path
|
||||
}
|
||||
}
|
||||
@@ -1,341 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { media_type } from './Constants.ets';
|
||||
import { FileInfo } from '../module/FileInfo.ets'
|
||||
import { LogInfo } from '../module/LogUtils.ets'
|
||||
|
||||
var TAG = 'FileManagerServiceUtils'
|
||||
var isDebug: boolean = true;
|
||||
|
||||
export function getFirstMenu(deviceName: string): Array<FileInfo> {
|
||||
let fileList: Array<FileInfo> = [];
|
||||
if (isDebug) {
|
||||
let file1: FileInfo = new FileInfo('image_album');
|
||||
file1.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
file1.path = 'dataability:///album';
|
||||
file1.size = '';
|
||||
file1.dataAdded_time = 'xxx';
|
||||
file1.modified_time = 'xxx';
|
||||
fileList.push(file1);
|
||||
|
||||
let file2: FileInfo = new FileInfo('video_album');
|
||||
file2.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
file2.path = 'dataability:///album';
|
||||
file2.size = '';
|
||||
file2.dataAdded_time = 'xxx';
|
||||
file2.modified_time = 'xxx';
|
||||
fileList.push(file2);
|
||||
|
||||
let file4: FileInfo = new FileInfo('file_folder');
|
||||
file4.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
file4.path = 'dataability:///album';
|
||||
file4.size = '';
|
||||
file4.dataAdded_time = 'xxx';
|
||||
file4.modified_time = 'xxx';
|
||||
fileList.push(file4);
|
||||
|
||||
let file3: FileInfo = new FileInfo('audio_album');
|
||||
file3.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
file3.path = 'dataability:///album';
|
||||
file3.size = '';
|
||||
file3.dataAdded_time = 'xxx';
|
||||
file3.modified_time = 'xxx';
|
||||
fileList.push(file3);
|
||||
} else {
|
||||
// var fileInfo = filemanager.getRoot(deviceName);
|
||||
}
|
||||
|
||||
fileList.forEach(item => {
|
||||
if (item.name == 'image_album') {
|
||||
item.name = "图片";
|
||||
item.mediaType = 'image';
|
||||
item.thumbnail = $r("app.media.ic_photo")
|
||||
} else if (item.name == 'video_album') {
|
||||
item.name = "视频";
|
||||
item.mediaType = 'video';
|
||||
item.thumbnail = $r("app.media.ic_video")
|
||||
} else if (item.name == 'audio_album') {
|
||||
item.name = "音频";
|
||||
item.mediaType = 'audio';
|
||||
item.thumbnail = $r("app.media.ic_audio")
|
||||
} else if (item.name == 'file_folder') {
|
||||
item.name = "文档";
|
||||
item.mediaType = 'file';
|
||||
item.thumbnail = $r("app.media.ic_document")
|
||||
}
|
||||
});
|
||||
|
||||
return fileList;
|
||||
}
|
||||
|
||||
export function getListFile(deviceName: string, mediaType: string, path: string): Array<FileInfo> {
|
||||
LogInfo(TAG, "getListFile mediaType = " + mediaType + ';path = ' + path);
|
||||
let fileList: Array<FileInfo> = [];
|
||||
if (isDebug) {
|
||||
if (path == 'dataability:///album') {
|
||||
if (mediaType == 'image') {
|
||||
let fileInfo1: FileInfo = new FileInfo("微信的图片");
|
||||
fileInfo1.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
fileInfo1.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/01';
|
||||
fileInfo1.dataAdded_time = 'xxx';
|
||||
fileInfo1.modified_time = 'xxx';
|
||||
fileList.push(fileInfo1);
|
||||
let fileInfo2: FileInfo = new FileInfo("图片1");
|
||||
fileInfo2.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
fileInfo2.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/02';
|
||||
fileInfo2.dataAdded_time = 'xxx';
|
||||
fileInfo2.modified_time = 'xxx';
|
||||
fileList.push(fileInfo2);
|
||||
let fileInfo3: FileInfo = new FileInfo("图片2");
|
||||
fileInfo3.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
fileInfo3.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/03';
|
||||
fileInfo3.dataAdded_time = 'xxx';
|
||||
fileInfo3.modified_time = 'xxx';
|
||||
fileList.push(fileInfo3);
|
||||
let fileInfo4: FileInfo = new FileInfo("图片3");
|
||||
fileInfo4.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
fileInfo4.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/04';
|
||||
fileInfo4.dataAdded_time = 'xxx';
|
||||
fileInfo4.modified_time = 'xxx';
|
||||
fileList.push(fileInfo4);
|
||||
let fileInfo5: FileInfo = new FileInfo("图片4");
|
||||
fileInfo5.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
fileInfo5.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/05';
|
||||
fileInfo5.dataAdded_time = 'xxx';
|
||||
fileInfo5.modified_time = 'xxx';
|
||||
fileList.push(fileInfo5);
|
||||
let fileInfo6: FileInfo = new FileInfo("图片5");
|
||||
fileInfo6.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
fileInfo6.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/06';
|
||||
fileInfo6.dataAdded_time = 'xxx';
|
||||
fileInfo6.modified_time = 'xxx';
|
||||
fileList.push(fileInfo6);
|
||||
let fileInfo7: FileInfo = new FileInfo("图片6");
|
||||
fileInfo7.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
fileInfo7.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/07';
|
||||
fileInfo7.dataAdded_time = 'xxx';
|
||||
fileInfo7.modified_time = 'xxx';
|
||||
fileList.push(fileInfo7);
|
||||
let fileInfo8: FileInfo = new FileInfo("图片7");
|
||||
fileInfo8.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
fileInfo8.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/08';
|
||||
fileInfo8.dataAdded_time = 'xxx';
|
||||
fileInfo8.modified_time = 'xxx';
|
||||
fileList.push(fileInfo8);
|
||||
let fileInfo9: FileInfo = new FileInfo("图片8");
|
||||
fileInfo1.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
fileInfo1.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/09';
|
||||
fileInfo1.dataAdded_time = 'xxx';
|
||||
fileInfo1.modified_time = 'xxx';
|
||||
fileList.push(fileInfo9);
|
||||
let fileInfo10: FileInfo = new FileInfo("图片9");
|
||||
fileInfo10.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
fileInfo10.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/10';
|
||||
fileInfo10.dataAdded_time = 'xxx';
|
||||
fileInfo10.modified_time = 'xxx';
|
||||
fileList.push(fileInfo10);
|
||||
let fileInfo11: FileInfo = new FileInfo("图片10");
|
||||
fileInfo11.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
fileInfo11.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/11';
|
||||
fileInfo11.dataAdded_time = 'xxx';
|
||||
fileInfo11.modified_time = 'xxx';
|
||||
fileList.push(fileInfo11);
|
||||
} else if (mediaType == 'video') {
|
||||
let fileInfo1: FileInfo = new FileInfo("视频0");
|
||||
fileInfo1.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
fileInfo1.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/12';
|
||||
fileInfo1.dataAdded_time = 'xxx';
|
||||
fileInfo1.modified_time = 'xxx';
|
||||
fileList.push(fileInfo1);
|
||||
let fileInfo2: FileInfo = new FileInfo("视频1");
|
||||
fileInfo2.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
fileInfo2.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/13';
|
||||
fileInfo2.dataAdded_time = 'xxx';
|
||||
fileInfo2.modified_time = 'xxx';
|
||||
fileList.push(fileInfo2);
|
||||
let fileInfo3: FileInfo = new FileInfo("视频2");
|
||||
fileInfo3.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
fileInfo3.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/14';
|
||||
fileInfo3.dataAdded_time = 'xxx';
|
||||
fileInfo3.modified_time = 'xxx';
|
||||
fileList.push(fileInfo3);
|
||||
let fileInfo4: FileInfo = new FileInfo("视频3");
|
||||
fileInfo4.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
fileInfo4.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/15';
|
||||
fileInfo4.dataAdded_time = 'xxx';
|
||||
fileInfo4.modified_time = 'xxx';
|
||||
fileList.push(fileInfo4);
|
||||
let fileInfo5: FileInfo = new FileInfo("视频4");
|
||||
fileInfo5.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
fileInfo5.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/16';
|
||||
fileInfo5.dataAdded_time = 'xxx';
|
||||
fileInfo5.modified_time = 'xxx';
|
||||
fileList.push(fileInfo5);
|
||||
} else if (mediaType == 'audio') {
|
||||
let fileInfo1: FileInfo = new FileInfo("音频0");
|
||||
fileInfo1.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
fileInfo1.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/17';
|
||||
fileInfo1.dataAdded_time = 'xxx';
|
||||
fileInfo1.modified_time = 'xxx';
|
||||
fileList.push(fileInfo1);
|
||||
let fileInfo2: FileInfo = new FileInfo("音频1");
|
||||
fileInfo2.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
fileInfo2.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/18';
|
||||
fileInfo2.dataAdded_time = 'xxx';
|
||||
fileInfo2.modified_time = 'xxx';
|
||||
fileList.push(fileInfo2);
|
||||
let fileInfo3: FileInfo = new FileInfo("音频2");
|
||||
fileInfo3.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
fileInfo3.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/19';
|
||||
fileInfo3.dataAdded_time = 'xxx';
|
||||
fileInfo3.modified_time = 'xxx';
|
||||
fileList.push(fileInfo3);
|
||||
let fileInfo4: FileInfo = new FileInfo("音频3");
|
||||
fileInfo4.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
fileInfo4.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/20';
|
||||
fileInfo4.dataAdded_time = 'xxx';
|
||||
fileInfo4.modified_time = 'xxx';
|
||||
fileList.push(fileInfo4);
|
||||
let fileInfo5: FileInfo = new FileInfo("音频4");
|
||||
fileInfo5.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
fileInfo5.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/21';
|
||||
fileInfo5.dataAdded_time = 'xxx';
|
||||
fileInfo5.modified_time = 'xxx';
|
||||
fileList.push(fileInfo5);
|
||||
} else if (mediaType == 'file') {
|
||||
let fileInfo1: FileInfo = new FileInfo("文件夹0");
|
||||
fileInfo1.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
fileInfo1.mediaType = mediaType;
|
||||
fileInfo1.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/22';
|
||||
fileInfo1.dataAdded_time = 'xxx';
|
||||
fileInfo1.modified_time = 'xxx';
|
||||
fileList.push(fileInfo1);
|
||||
let fileInfo2: FileInfo = new FileInfo("文件夹1");
|
||||
fileInfo2.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
fileInfo2.mediaType = mediaType;
|
||||
fileInfo2.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/23';
|
||||
fileInfo2.dataAdded_time = 'xxx';
|
||||
fileInfo2.modified_time = 'xxx';
|
||||
fileList.push(fileInfo2);
|
||||
let fileInfo3: FileInfo = new FileInfo("文件夹2");
|
||||
fileInfo3.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
fileInfo3.mediaType = mediaType;
|
||||
fileInfo3.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/24';
|
||||
fileInfo3.dataAdded_time = 'xxx';
|
||||
fileInfo3.modified_time = 'xxx';
|
||||
fileList.push(fileInfo3);
|
||||
let fileInfo4: FileInfo = new FileInfo("文件夹3");
|
||||
fileInfo4.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
fileInfo4.mediaType = mediaType;
|
||||
fileInfo4.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/25';
|
||||
fileInfo4.dataAdded_time = 'xxx';
|
||||
fileInfo4.modified_time = 'xxx';
|
||||
fileList.push(fileInfo4);
|
||||
let fileInfo5: FileInfo = new FileInfo("文件夹4");
|
||||
fileInfo5.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
fileInfo5.mediaType = mediaType;
|
||||
fileInfo5.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/26';
|
||||
fileInfo5.dataAdded_time = 'xxx';
|
||||
fileInfo5.modified_time = 'xxx';
|
||||
fileList.push(fileInfo5);
|
||||
let fileInfo6: FileInfo = new FileInfo("文本文档.txt");
|
||||
fileInfo6.type = media_type.MEDIA_TYPE_FILE;
|
||||
fileInfo6.mediaType = mediaType;
|
||||
fileInfo6.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/27';
|
||||
fileInfo6.dataAdded_time = 'xxx';
|
||||
fileInfo6.modified_time = 'xxx';
|
||||
fileInfo6.size = '1,024 KB'
|
||||
fileList.push(fileInfo6);
|
||||
let fileInfo7: FileInfo = new FileInfo("验收文稿.ppt");
|
||||
fileInfo7.type = media_type.MEDIA_TYPE_FILE;
|
||||
fileInfo7.mediaType = mediaType;
|
||||
fileInfo7.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/28';
|
||||
fileInfo7.dataAdded_time = 'xxx';
|
||||
fileInfo7.modified_time = 'xxx';
|
||||
fileInfo7.size = '4,562,000 KB'
|
||||
fileList.push(fileInfo7);
|
||||
}
|
||||
} else {
|
||||
if (mediaType == 'image') {
|
||||
for (var index = 0; index < 10; index++) {
|
||||
let file: FileInfo = new FileInfo("" + index + ".png");
|
||||
file.type = media_type.MEDIA_TYPE_IMAGE;
|
||||
file.path = path + index;
|
||||
file.dataAdded_time = 'xxx';
|
||||
file.modified_time = 'xxx';
|
||||
fileList.push(file);
|
||||
}
|
||||
} else if (mediaType == 'video') {
|
||||
for (var index = 0; index < 15; index++) {
|
||||
let file: FileInfo = new FileInfo("" + index + ".wmv");
|
||||
file.type = media_type.MEDIA_TYPE_VIDEO;
|
||||
file.path = path + index;
|
||||
file.dataAdded_time = 'xxx';
|
||||
file.modified_time = 'xxx';
|
||||
fileList.push(file);
|
||||
}
|
||||
} else if (mediaType == 'audio') {
|
||||
for (var index = 0; index < 18; index++) {
|
||||
let file: FileInfo = new FileInfo("" + index + ".mp3");
|
||||
file.type = media_type.MEDIA_TYPE_AUDIO;
|
||||
file.path = path + index;
|
||||
file.dataAdded_time = 'xxx';
|
||||
file.modified_time = 'xxx';
|
||||
fileList.push(file);
|
||||
}
|
||||
} else if (mediaType == 'file') {
|
||||
let fileInfo4: FileInfo = new FileInfo("文件夹3");
|
||||
fileInfo4.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
fileInfo4.path = path + '5';
|
||||
fileInfo4.dataAdded_time = 'xxx';
|
||||
fileInfo4.modified_time = 'xxx';
|
||||
fileList.push(fileInfo4);
|
||||
let fileInfo5: FileInfo = new FileInfo("文件夹4");
|
||||
fileInfo5.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
fileInfo5.path = path + '6';
|
||||
fileInfo5.dataAdded_time = 'xxx';
|
||||
fileInfo5.modified_time = 'xxx';
|
||||
fileList.push(fileInfo5);
|
||||
let fileInfo6: FileInfo = new FileInfo("文本文档.txt");
|
||||
fileInfo6.type = media_type.MEDIA_TYPE_FILE;
|
||||
fileInfo6.path = path + '7';
|
||||
fileInfo6.size = '1,000 KB'
|
||||
fileInfo6.dataAdded_time = 'xxx';
|
||||
fileInfo6.modified_time = 'xxx';
|
||||
fileList.push(fileInfo6);
|
||||
let fileInfo7: FileInfo = new FileInfo("验收文稿.ppt");
|
||||
fileInfo7.type = media_type.MEDIA_TYPE_FILE;
|
||||
fileInfo7.path = path + '8';
|
||||
fileInfo7.size = '520,000 KB'
|
||||
fileInfo7.dataAdded_time = 'xxx';
|
||||
fileInfo7.modified_time = 'xxx';
|
||||
fileList.push(fileInfo7);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// fileList = filemanager.listfile(deviceName, mediaType, path);
|
||||
}
|
||||
LogInfo(TAG, "get file list is " + fileList.length)
|
||||
return fileList;
|
||||
}
|
||||
|
||||
//保存某个文件,返回是否保存成功,或有错误提示,还需要增加三方应用包名
|
||||
export function saveFile(deviceName: string, name: string, path: string): boolean {
|
||||
LogInfo(TAG, 'saveFile');
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
@@ -1,126 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { TopPathInfo } from '../module/FileInfo.ets'
|
||||
import { LogInfo } from '../module/LogUtils.ets'
|
||||
|
||||
var TAG: string = 'Utils'
|
||||
|
||||
export function getRootPath(): Array<TopPathInfo> {
|
||||
var root_path: Array<TopPathInfo> = []
|
||||
root_path.push(new TopPathInfo('文件类型', ''))
|
||||
return root_path
|
||||
}
|
||||
|
||||
var strTypeArr = [
|
||||
['image', '图片'],
|
||||
['video', '视频'],
|
||||
['audio', '音频'],
|
||||
['file', '文档'],
|
||||
]
|
||||
|
||||
export function changeTypeToString(type: string): string {
|
||||
LogInfo(TAG, 'changeTypeToString type = ' + type)
|
||||
for (var i = 0; i < strTypeArr.length; i++) {
|
||||
if (strTypeArr[i][0] == type) {
|
||||
return strTypeArr[i][1]
|
||||
}
|
||||
}
|
||||
return ''
|
||||
}
|
||||
|
||||
export function changeStringToType(type: string): string {
|
||||
LogInfo(TAG, 'changeStringToType type = ' + type)
|
||||
for (var i = 0; i < strTypeArr.length; i++) {
|
||||
if (strTypeArr[i][1] == type) {
|
||||
return strTypeArr[i][0]
|
||||
}
|
||||
}
|
||||
return ''
|
||||
}
|
||||
|
||||
export function getItemNumberInGrid(itemWidth: number, itemGap: number, parentWidth: number): string {
|
||||
LogInfo(TAG, 'getItemNumberInGrid')
|
||||
let columnTemples: string = ''
|
||||
let remainderWidth: number = parentWidth - itemWidth
|
||||
columnTemples += '1fr'
|
||||
while (itemWidth + itemGap < remainderWidth) {
|
||||
remainderWidth = remainderWidth - (itemWidth + itemGap)
|
||||
columnTemples += ' 1fr'
|
||||
}
|
||||
LogInfo(TAG, 'columnTemples = ' + columnTemples)
|
||||
return columnTemples
|
||||
}
|
||||
|
||||
var fileSuffixAndType = [
|
||||
['.doc', $r("app.media.ic_file_doc"), $r("app.string.file_docx")],
|
||||
['.html', $r("app.media.ic_file_html"), $r("app.string.file_html")],
|
||||
['.pdf', $r("app.media.ic_file_pdf"), $r("app.string.file_pdf")],
|
||||
['.pptx', $r("app.media.ic_file_pptx"), $r("app.string.file_pptx")],
|
||||
['.ppt', $r("app.media.ic_file_pptx"), $r("app.string.file_pptx")],
|
||||
['.rar', $r("app.media.ic_file_rar"), $r("app.string.file_rar")],
|
||||
['.txt', $r("app.media.ic_file_txt"), $r("app.string.file_txt")],
|
||||
['.xls', $r("app.media.ic_file_xls"), $r("app.string.file_xls")],
|
||||
['.xml', $r("app.media.ic_file_xml"), $r("app.string.file_xml")],
|
||||
['.zip', $r("app.media.ic_file_zip"), $r("app.string.file_zip")],
|
||||
]
|
||||
|
||||
export function getShowIconBySuffix(suffix: string): string | Resource {
|
||||
LogInfo(TAG, 'getShowIconBySuffix suffix = ' + suffix)
|
||||
for (var i = 0; i < fileSuffixAndType.length; i++) {
|
||||
if (isTwoStringEqual(fileSuffixAndType[i][0].toString(),suffix)) {
|
||||
return fileSuffixAndType[i][1]
|
||||
}
|
||||
}
|
||||
return $r("app.media.ic_file_unknown")
|
||||
}
|
||||
|
||||
export function getShowTextBySuffix(suffix: string): string | Resource {
|
||||
LogInfo(TAG, 'getShowTextBySuffix suffix = ' + suffix)
|
||||
for (var i = 0; i < fileSuffixAndType.length; i++) {
|
||||
if (fileSuffixAndType[i][0] == suffix) {
|
||||
return fileSuffixAndType[i][2]
|
||||
}
|
||||
}
|
||||
return $r("app.string.file_unknown")
|
||||
}
|
||||
|
||||
export function getWarningDialogMessage(code: number): string | Resource {
|
||||
switch (code) {
|
||||
case 1:
|
||||
return $r("app.string.save_file_has_same_file")
|
||||
case 2:
|
||||
return $r("app.string.save_file_no_media_permission")
|
||||
default:
|
||||
return $r("app.string.save_file_unknown_reason")
|
||||
}
|
||||
}
|
||||
|
||||
export function isTwoStringEqual(src: string, tar: string) {
|
||||
if (src.indexOf(tar) == 0 && tar.indexOf(src) == 0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export function updateTopPathInfo(currentPathInfo: Array<TopPathInfo>, name: string, path: string) {
|
||||
currentPathInfo.forEach((item: TopPathInfo) => {
|
||||
item.opacity = 0.4
|
||||
})
|
||||
|
||||
currentPathInfo.push(new TopPathInfo(name, path))
|
||||
AppStorage.Set('topPathInfo', currentPathInfo)
|
||||
return currentPathInfo
|
||||
}
|
||||
@@ -13,78 +13,77 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { FileInfo } from '../module/FileInfo'
|
||||
import { LogInfo } from '../module/LogUtils'
|
||||
import { menuLevel } from '../module/Constants'
|
||||
import { FileInfo } from '../../../../../../common/src/main/ets/components/Data/FileInfo'
|
||||
import { MenuLevel } from '../../../../../../common/src/main/ets/components/Data/Constants'
|
||||
|
||||
@Component
|
||||
export struct FirstLevelByType {
|
||||
private TAG: string = 'FirstLevelByType'
|
||||
private mWorker
|
||||
private mFileList: FileInfo[]
|
||||
@Link mType: string
|
||||
@Link mMenuLevel: number
|
||||
@Link mCurrentPath: string
|
||||
private TAG: string = 'FirstLevelByType'
|
||||
private mWorker
|
||||
private mFileList: FileInfo[]
|
||||
@Link mType: string
|
||||
@Link mMenuLevel: number
|
||||
@Link mCurrentPath: string
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
ForEach(this.mFileList, (item: FileInfo, index: number) => {
|
||||
build() {
|
||||
Column() {
|
||||
RowView({
|
||||
item: item,
|
||||
mMenuLevel: $mMenuLevel,
|
||||
mType: $mType,
|
||||
mCurrentPath: $mCurrentPath
|
||||
})
|
||||
ForEach(this.mFileList, (item: FileInfo, index: number) => {
|
||||
Column() {
|
||||
RowView({
|
||||
item: item,
|
||||
mMenuLevel: $mMenuLevel,
|
||||
mType: $mType,
|
||||
mCurrentPath: $mCurrentPath
|
||||
})
|
||||
|
||||
Divider()
|
||||
.color('#000000')
|
||||
.opacity(0.1)
|
||||
.visibility(this.mFileList.length == index + 1 ? Visibility.Hidden : Visibility.Visible)
|
||||
.margin({ left: 40 * 1.3 })
|
||||
Divider()
|
||||
.color('#000000')
|
||||
.opacity(0.1)
|
||||
.visibility(this.mFileList.length == index + 1 ? Visibility.Hidden : Visibility.Visible)
|
||||
.margin({ left: 40 * 1.3 })
|
||||
}
|
||||
.width('100%')
|
||||
.height(56 * 1.3)
|
||||
}, item => item.name.toString())
|
||||
}
|
||||
.padding({ top: 4 * 1.3, bottom: 4 * 1.3, right: 12 * 1.3, left: 12 * 1.3 })
|
||||
.alignItems(HorizontalAlign.Start) // 导致圆角消失
|
||||
.border({ radius: 24 })
|
||||
.opacity(0.9)
|
||||
.backgroundColor('#FFFFFF')
|
||||
.width('100%')
|
||||
.height(56 * 1.3)
|
||||
}, item => item.name.toString())
|
||||
}
|
||||
.padding({ top: 4 * 1.3, bottom: 4 * 1.3, right: 12 * 1.3, left: 12 * 1.3 })
|
||||
.alignItems(HorizontalAlign.Start) // 导致圆角消失
|
||||
.border({ radius: 24 })
|
||||
.opacity(0.9)
|
||||
.backgroundColor('#FFFFFF')
|
||||
.width('100%')
|
||||
}
|
||||
}
|
||||
|
||||
@Component
|
||||
struct RowView {
|
||||
private item: FileInfo = new FileInfo('')
|
||||
@Link mMenuLevel: number
|
||||
@Link mType: string
|
||||
@Link mCurrentPath: string
|
||||
private item: FileInfo = new FileInfo('')
|
||||
@Link mMenuLevel: number
|
||||
@Link mType: string
|
||||
@Link mCurrentPath: string
|
||||
|
||||
build() {
|
||||
Row() {
|
||||
Image($r("app.media.ic_type_smallfile"))
|
||||
.width(24 * 1.3)
|
||||
.height(24 * 1.3)
|
||||
Text(this.item.name)
|
||||
.fontSize(16 * 1.3)
|
||||
.fontColor('#182431')
|
||||
.fontWeight(FontWeight.Medium)
|
||||
.margin({ left: 16 * 1.3 })
|
||||
Blank()
|
||||
Image($r("app.media.ic_right"))
|
||||
.width(12 * 1.3)
|
||||
.height(24 * 1.3)
|
||||
build() {
|
||||
Row() {
|
||||
Image($r("app.media.ic_type_smallfile"))
|
||||
.width(24 * 1.3)
|
||||
.height(24 * 1.3)
|
||||
Text(this.item.name)
|
||||
.fontSize(16 * 1.3)
|
||||
.fontColor('#182431')
|
||||
.fontWeight(FontWeight.Medium)
|
||||
.margin({ left: 16 * 1.3 })
|
||||
Blank()
|
||||
Image($r("app.media.ic_right"))
|
||||
.width(12 * 1.3)
|
||||
.height(24 * 1.3)
|
||||
}
|
||||
.height(56 * 1.3)
|
||||
.width('100%') // TODO
|
||||
.backgroundColor(this.item.list_background)
|
||||
.onClick(() => {
|
||||
this.mType = this.item.mediaType
|
||||
this.mCurrentPath = this.item.path
|
||||
this.mMenuLevel = MenuLevel.MENU_SECOND_LEVEL_BY_FOLD
|
||||
})
|
||||
}
|
||||
.height(56 * 1.3)
|
||||
.width('100%') // TODO
|
||||
.backgroundColor(this.item.list_background)
|
||||
.onClick(() => {
|
||||
this.mType = this.item.mediaType
|
||||
this.mCurrentPath = this.item.path
|
||||
this.mMenuLevel = menuLevel.MENU_SECOND_LEVEL_BY_FOLD
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -13,125 +13,125 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { FileInfo } from '../module/FileInfo'
|
||||
import { changeTypeToString, updateTopPathInfo } from '../module/Utils'
|
||||
import { LogInfo, LogDebug } from '../module/LogUtils'
|
||||
import { menuLevel } from '../module/Constants'
|
||||
import { getListFile } from '../module/FileManagerServiceUtils'
|
||||
import { MenuLevel } from '../../../../../../common/src/main/ets/components/Data/Constants'
|
||||
import { FileInfo } from '../../../../../../common/src/main/ets/components/Data/FileInfo'
|
||||
import { getListFile } from '../../../../../../common/src/main/ets/components/Utils/FileManagerServiceUtils'
|
||||
import { logDebug, logInfo } from '../../../../../../common/src/main/ets/components/Utils/LogUtils'
|
||||
import { changeTypeToString, updateTopPathInfo } from '../../../../../../common/src/main/ets/components/utils/Utils'
|
||||
|
||||
let TAG: string = 'SecondLevelByFold'
|
||||
|
||||
@Component
|
||||
export struct SecondLevelByFold {
|
||||
private mWorker
|
||||
@Link mFileList: FileInfo[]
|
||||
@Link @Watch('fileTypeChange') mType: string
|
||||
@Link mMenuLevel: number
|
||||
@Link mCurrentPath: string
|
||||
private mWorker
|
||||
@Link mFileList: FileInfo[]
|
||||
@Link @Watch('fileTypeChange') mType: string
|
||||
@Link mMenuLevel: number
|
||||
@Link mCurrentPath: string
|
||||
|
||||
aboutToAppear(): void{
|
||||
LogInfo(TAG, 'aboutToAppear')
|
||||
if (globalThis.debugMode) {
|
||||
this.mFileList = getListFile('local', this.mType, this.mCurrentPath)
|
||||
LogDebug(TAG, 'mFileList length = ' + this.mFileList.length)
|
||||
} else {
|
||||
this.mWorker.postMessage({
|
||||
request_data: 'listFile',
|
||||
device_name: 'local',
|
||||
menu_level: this.mMenuLevel,
|
||||
media_type: this.mType,
|
||||
path: this.mCurrentPath
|
||||
})
|
||||
}
|
||||
|
||||
updateTopPathInfo([], '文件类型', '')
|
||||
updateTopPathInfo(AppStorage.Get('topPathInfo'), changeTypeToString(this.mType), this.mCurrentPath)
|
||||
}
|
||||
|
||||
fileTypeChange() {
|
||||
LogInfo(TAG, 'fileTypeChange ' + this.mType)
|
||||
if (globalThis.debugMode) {
|
||||
this.mFileList = getListFile('local', this.mType, this.mCurrentPath)
|
||||
} else {
|
||||
this.mWorker.postMessage({
|
||||
request_data: 'listFile',
|
||||
device_name: 'local',
|
||||
menu_level: this.mMenuLevel,
|
||||
media_type: this.mType,
|
||||
path: this.mCurrentPath
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
ForEach(this.mFileList, (item: FileInfo, index: number) => {
|
||||
Column() {
|
||||
SecondRowView({
|
||||
item: item,
|
||||
mMenuLevel: $mMenuLevel,
|
||||
mCurrentPath: $mCurrentPath,
|
||||
isType: $mType
|
||||
})
|
||||
|
||||
Divider()
|
||||
.color('#000000')
|
||||
.opacity(0.05)
|
||||
.visibility(this.mFileList.length == index + 1 ? Visibility.Hidden : Visibility.Visible)
|
||||
.margin({ left: 40 * 1.3 })
|
||||
aboutToAppear(): void{
|
||||
logInfo(TAG, 'aboutToAppear')
|
||||
if (globalThis.debugMode) {
|
||||
this.mFileList = getListFile('local', this.mType, this.mCurrentPath)
|
||||
logDebug(TAG, 'mFileList length = ' + this.mFileList.length)
|
||||
} else {
|
||||
this.mWorker.postMessage({
|
||||
request_data: 'listFile',
|
||||
device_name: 'local',
|
||||
menu_level: this.mMenuLevel,
|
||||
MediaType: this.mType,
|
||||
path: this.mCurrentPath
|
||||
})
|
||||
}
|
||||
.width('100%')
|
||||
.height(56 * 1.3)
|
||||
}, item => item.name.toString())
|
||||
|
||||
updateTopPathInfo([], '文件类型', '')
|
||||
updateTopPathInfo(AppStorage.Get('topPathInfo'), changeTypeToString(this.mType), this.mCurrentPath)
|
||||
}
|
||||
|
||||
fileTypeChange() {
|
||||
logInfo(TAG, 'fileTypeChange ' + this.mType)
|
||||
if (globalThis.debugMode) {
|
||||
this.mFileList = getListFile('local', this.mType, this.mCurrentPath)
|
||||
} else {
|
||||
this.mWorker.postMessage({
|
||||
request_data: 'listFile',
|
||||
device_name: 'local',
|
||||
menu_level: this.mMenuLevel,
|
||||
MediaType: this.mType,
|
||||
path: this.mCurrentPath
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
ForEach(this.mFileList, (item: FileInfo, index: number) => {
|
||||
Column() {
|
||||
SecondRowView({
|
||||
item: item,
|
||||
mMenuLevel: $mMenuLevel,
|
||||
mCurrentPath: $mCurrentPath,
|
||||
isType: $mType
|
||||
})
|
||||
|
||||
Divider()
|
||||
.color('#000000')
|
||||
.opacity(0.05)
|
||||
.visibility(this.mFileList.length == index + 1 ? Visibility.Hidden : Visibility.Visible)
|
||||
.margin({ left: 40 * 1.3 })
|
||||
}
|
||||
.width('100%')
|
||||
.height(56 * 1.3)
|
||||
}, item => item.name.toString())
|
||||
}
|
||||
.padding({ top: 4 * 1.3, bottom: 4 * 1.3, left: 12 * 1.3, right: 12 * 1.3 })
|
||||
.width('100%')
|
||||
.alignItems(HorizontalAlign.Start)
|
||||
.border({ radius: 24 })
|
||||
.opacity(0.9)
|
||||
.backgroundColor(Color.White)
|
||||
}
|
||||
.padding({ top: 4 * 1.3, bottom: 4 * 1.3, left: 12 * 1.3, right: 12 * 1.3 })
|
||||
.width('100%')
|
||||
.alignItems(HorizontalAlign.Start)
|
||||
.border({ radius: 24 })
|
||||
.opacity(0.9)
|
||||
.backgroundColor(Color.White)
|
||||
}
|
||||
}
|
||||
|
||||
@Component
|
||||
struct SecondRowView {
|
||||
private item: FileInfo = new FileInfo('')
|
||||
@Link mMenuLevel: number
|
||||
@Link mCurrentPath: string
|
||||
@Link isType: string
|
||||
private item: FileInfo = new FileInfo('')
|
||||
@Link mMenuLevel: number
|
||||
@Link mCurrentPath: string
|
||||
@Link isType: string
|
||||
|
||||
build() {
|
||||
Row() {
|
||||
Image($r("app.media.ic_type_smallfile"))
|
||||
.width(24 * 1.3)
|
||||
.height(24 * 1.3)
|
||||
Text(this.item.name)
|
||||
.fontSize(16 * 1.3)
|
||||
.fontColor('#182431')
|
||||
.fontWeight(FontWeight.Medium)
|
||||
.margin({ left: 17 * 1.3 })
|
||||
Blank()
|
||||
Image($r("app.media.ic_right"))
|
||||
.width(12 * 1.3)
|
||||
.height(24 * 1.3)
|
||||
}
|
||||
.height(56 * 1.3)
|
||||
.width('100%') // TODO
|
||||
.backgroundColor(this.item.list_background)
|
||||
.onClick(() => {
|
||||
LogInfo(TAG, 'onClick this.mCurrentPath = ' + this.mCurrentPath)
|
||||
this.mCurrentPath = this.item.path
|
||||
updateTopPathInfo(AppStorage.Get('topPathInfo'), this.item.name, this.mCurrentPath)
|
||||
|
||||
if (this.item.path.includes('dataability:///album') == false) {
|
||||
if (this.isType != 'file') {
|
||||
LogInfo(TAG, 'MENU_THIRD_LEVEL_HAS_PIC - onClick')
|
||||
this.mMenuLevel = menuLevel.MENU_THIRD_LEVEL_HAS_PIC
|
||||
} else {
|
||||
this.mMenuLevel = menuLevel.MENU_THIRD_LEVEL_HAS_DETAIL
|
||||
LogInfo(TAG, 'MENU_THIRD_LEVEL_HAS_DETAIL - onClick')
|
||||
build() {
|
||||
Row() {
|
||||
Image($r("app.media.ic_type_smallfile"))
|
||||
.width(24 * 1.3)
|
||||
.height(24 * 1.3)
|
||||
Text(this.item.name)
|
||||
.fontSize(16 * 1.3)
|
||||
.fontColor('#182431')
|
||||
.fontWeight(FontWeight.Medium)
|
||||
.margin({ left: 17 * 1.3 })
|
||||
Blank()
|
||||
Image($r("app.media.ic_right"))
|
||||
.width(12 * 1.3)
|
||||
.height(24 * 1.3)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
.height(56 * 1.3)
|
||||
.width('100%') // TODO
|
||||
.backgroundColor(this.item.list_background)
|
||||
.onClick(() => {
|
||||
logInfo(TAG, 'onClick this.mCurrentPath = ' + this.mCurrentPath)
|
||||
this.mCurrentPath = this.item.path
|
||||
updateTopPathInfo(AppStorage.Get('topPathInfo'), this.item.name, this.mCurrentPath)
|
||||
|
||||
if (this.item.path.includes('dataability:///album') == false) {
|
||||
if (this.isType != 'file') {
|
||||
logInfo(TAG, 'MENU_THIRD_LEVEL_HAS_PIC - onClick')
|
||||
this.mMenuLevel = MenuLevel.MENU_THIRD_LEVEL_HAS_PIC
|
||||
} else {
|
||||
this.mMenuLevel = MenuLevel.MENU_THIRD_LEVEL_HAS_DETAIL
|
||||
logInfo(TAG, 'MENU_THIRD_LEVEL_HAS_DETAIL - onClick')
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -13,209 +13,210 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { FileInfo } from '../module/FileInfo'
|
||||
import { LogInfo } from '../module/LogUtils'
|
||||
import { getShowIconBySuffix, updateTopPathInfo } from '../module/Utils'
|
||||
import { media_type } from '../module/Constants'
|
||||
import { ChooseDialog } from '../module/DialogUtils'
|
||||
import { getListFile } from '../module/FileManagerServiceUtils'
|
||||
import { MediaType } from '../../../../../../common/src/main/ets/components/Data/Constants'
|
||||
import { FileInfo } from '../../../../../../common/src/main/ets/components/Data/FileInfo'
|
||||
import { logInfo } from '../../../../../../common/src/main/ets/components/Utils/LogUtils'
|
||||
import { getListFile } from '../../../../../../common/src/main/ets/components/Utils/FileManagerServiceUtils'
|
||||
import { getShowIconBySuffix, updateTopPathInfo } from '../../../../../../common/src/main/ets/components/utils/utils'
|
||||
import { ChooseDialog } from '../../../../../../common/src/main/ets/components/View/ChooseDialog'
|
||||
|
||||
let TAG: string = 'ThirdLevelHasDetail'
|
||||
|
||||
@Component
|
||||
export struct ThirdLevelHasDetail {
|
||||
private mCurrentMode: string
|
||||
private mWorker
|
||||
@Link mFileInfo: Array<FileInfo>
|
||||
@Link @Watch('refreshFiles') mCurrentPath: string
|
||||
@Link mMenuLevel: number
|
||||
@Link mType: string
|
||||
private mCurrentMode: string
|
||||
private mWorker
|
||||
@Link mFileInfo: Array<FileInfo>
|
||||
@Link @Watch('refreshFiles') mCurrentPath: string
|
||||
@Link mMenuLevel: number
|
||||
@Link mType: string
|
||||
|
||||
private aboutToAppear(): void{
|
||||
LogInfo(TAG, 'aboutToAppear')
|
||||
if (globalThis.debugMode) {
|
||||
this.mFileInfo = getListFile('local', this.mType, this.mCurrentPath)
|
||||
} else {
|
||||
this.mWorker.postMessage({
|
||||
request_data: 'listFile',
|
||||
device_name: 'local',
|
||||
menu_level: this.mMenuLevel,
|
||||
media_type: this.mType,
|
||||
path: this.mCurrentPath
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
private aboutToDisappear() {
|
||||
LogInfo(TAG, 'aboutToDisappear')
|
||||
AppStorage.Set('choseFiles', [])
|
||||
}
|
||||
|
||||
refreshFiles() {
|
||||
LogInfo(TAG, 'refreshFiles')
|
||||
AppStorage.Set('choseFiles', [])
|
||||
|
||||
this.mWorker.postMessage({
|
||||
request_data: 'listFile',
|
||||
device_name: 'local',
|
||||
menu_level: this.mMenuLevel,
|
||||
media_type: this.mType,
|
||||
path: this.mCurrentPath
|
||||
})
|
||||
}
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
Flex({
|
||||
direction: FlexDirection.Row,
|
||||
wrap: FlexWrap.Wrap,
|
||||
justifyContent: FlexAlign.Start,
|
||||
alignItems: ItemAlign.Start
|
||||
}) {
|
||||
ForEach(this.mFileInfo, (item: FileInfo, index: number) => {
|
||||
Column() {
|
||||
DetailRowView({
|
||||
item: item,
|
||||
mMenuLevel: $mMenuLevel,
|
||||
mCurrentPath: $mCurrentPath
|
||||
private aboutToAppear(): void{
|
||||
logInfo(TAG, 'aboutToAppear')
|
||||
if (globalThis.debugMode) {
|
||||
this.mFileInfo = getListFile('local', this.mType, this.mCurrentPath)
|
||||
} else {
|
||||
this.mWorker.postMessage({
|
||||
request_data: 'listFile',
|
||||
device_name: 'local',
|
||||
menu_level: this.mMenuLevel,
|
||||
MediaType: this.mType,
|
||||
path: this.mCurrentPath
|
||||
})
|
||||
|
||||
Divider()
|
||||
.color('#000000')
|
||||
.opacity(0.05)
|
||||
.visibility(this.mFileInfo.length == index + 1 ? Visibility.Hidden : Visibility.Visible)
|
||||
.margin({ left: 64 * 1.3, right: 12 * 1.3 })
|
||||
}
|
||||
}, (item: FileInfo) => item.name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private aboutToDisappear() {
|
||||
logInfo(TAG, 'aboutToDisappear')
|
||||
AppStorage.Set('choseFiles', [])
|
||||
}
|
||||
|
||||
refreshFiles() {
|
||||
logInfo(TAG, 'refreshFiles')
|
||||
AppStorage.Set('choseFiles', [])
|
||||
if (!globalThis.debugMode) {
|
||||
this.mWorker.postMessage({
|
||||
request_data: 'listFile',
|
||||
device_name: 'local',
|
||||
menu_level: this.mMenuLevel,
|
||||
MediaType: this.mType,
|
||||
path: this.mCurrentPath
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
Flex({
|
||||
direction: FlexDirection.Row,
|
||||
wrap: FlexWrap.Wrap,
|
||||
justifyContent: FlexAlign.Start,
|
||||
alignItems: ItemAlign.Start
|
||||
}) {
|
||||
ForEach(this.mFileInfo, (item: FileInfo, index: number) => {
|
||||
Column() {
|
||||
DetailRowView({
|
||||
item: item,
|
||||
mMenuLevel: $mMenuLevel,
|
||||
mCurrentPath: $mCurrentPath
|
||||
})
|
||||
|
||||
Divider()
|
||||
.color('#000000')
|
||||
.opacity(0.05)
|
||||
.visibility(this.mFileInfo.length == index + 1 ? Visibility.Hidden : Visibility.Visible)
|
||||
.margin({ left: 64 * 1.3, right: 12 * 1.3 })
|
||||
}
|
||||
}, (item: FileInfo) => item.name)
|
||||
}
|
||||
}
|
||||
.padding({ bottom: 4 * 1.3 })
|
||||
.alignItems(HorizontalAlign.Start)
|
||||
.border({ radius: 24 })
|
||||
.opacity(0.9)
|
||||
.backgroundColor(Color.White)
|
||||
}
|
||||
.padding({ bottom: 4 * 1.3 })
|
||||
.alignItems(HorizontalAlign.Start)
|
||||
.border({ radius: 24 })
|
||||
.opacity(0.9)
|
||||
.backgroundColor(Color.White)
|
||||
}
|
||||
}
|
||||
|
||||
@Component
|
||||
struct DetailRowView {
|
||||
private dialogController: CustomDialogController = new CustomDialogController({
|
||||
builder: ChooseDialog(),
|
||||
cancel: () => {
|
||||
},
|
||||
autoCancel: true
|
||||
})
|
||||
@State item: FileInfo = new FileInfo('')
|
||||
@Link mCurrentPath: string
|
||||
@Link mMenuLevel: number
|
||||
@StorageLink('choseFiles') tmpChoseFiles: Array<FileInfo> = []
|
||||
|
||||
build() {
|
||||
Row() {
|
||||
if (this.item.type == media_type.MEDIA_TYPE_ALBUM) {
|
||||
Row() {
|
||||
Image($r("app.media.ic_type_bigfile"))
|
||||
.width(40 * 1.3)
|
||||
.height(40 * 1.3)
|
||||
.margin({ left: 10 * 1.3 })
|
||||
Text(this.item.name)
|
||||
.fontSize(16 * 1.3)
|
||||
.fontColor('#182431')
|
||||
.fontWeight(FontWeight.Medium)
|
||||
.margin({ left: 16 * 1.3 })
|
||||
.maxLines(1)
|
||||
.textOverflow({ overflow: TextOverflow.Ellipsis })
|
||||
Blank()
|
||||
Image($r("app.media.ic_right"))
|
||||
.width(12 * 1.3)
|
||||
.height(24 * 1.3)
|
||||
.margin({ right: 12 * 1.3 })
|
||||
}
|
||||
.margin({ right: 12 * 1.3 })
|
||||
.height(64 * 1.3)
|
||||
.width('100%')
|
||||
.backgroundColor(this.item.list_background)
|
||||
} else {
|
||||
Row() {
|
||||
Image(getShowIconBySuffix(this.item.name.substring(this.item.name.lastIndexOf('.'))))
|
||||
.width(40 * 1.3)
|
||||
.height(40 * 1.3)
|
||||
.margin({ left: 8 * 1.3 })
|
||||
Column() {
|
||||
Text(this.item.name)
|
||||
.height(22 * 1.3)
|
||||
.fontSize(16 * 1.3)
|
||||
.fontColor(this.item.font_color)
|
||||
.fontWeight(FontWeight.Medium)
|
||||
.maxLines(1)
|
||||
.textOverflow({ overflow: TextOverflow.Ellipsis })
|
||||
.margin({ top: 10 * 1.3 })
|
||||
.height(22 * 1.3)
|
||||
.width(248 * 1.3)
|
||||
Row() {
|
||||
Text('' + this.item.modified_time)
|
||||
.fontSize(14 * 1.3)
|
||||
.fontColor(this.item.font_color)
|
||||
.fontWeight(FontWeight.Regular)
|
||||
.maxLines(1)
|
||||
.textOverflow({ overflow: TextOverflow.Ellipsis })
|
||||
Text('-')
|
||||
.fontSize(14 * 1.3)
|
||||
.fontColor(this.item.font_color)
|
||||
.margin({ left: 8 * 1.3 })
|
||||
Text('' + this.item.size)
|
||||
.fontSize(14 * 1.3)
|
||||
.fontColor(this.item.font_color)
|
||||
.fontWeight(FontWeight.Regular)
|
||||
.margin({ left: 8 * 1.3 })
|
||||
.maxLines(1)
|
||||
.textOverflow({ overflow: TextOverflow.Ellipsis })
|
||||
}
|
||||
.width(248 * 1.3)
|
||||
.height(19 * 1.3)
|
||||
.margin({ top: 2 * 1.3 })
|
||||
.opacity(0.6)
|
||||
}
|
||||
.height(64 * 1.3)
|
||||
.alignItems(HorizontalAlign.Start)
|
||||
.margin({ left: 16 * 1.3 })
|
||||
}
|
||||
.width('100%')
|
||||
.height(64 * 1.3) // TODO
|
||||
|
||||
}
|
||||
}
|
||||
.margin({ top: 4 * 1.3, left: 4 * 1.3, right: 4 * 1.3 })
|
||||
.border({ radius: 20 })
|
||||
.backgroundColor(this.item.list_background)
|
||||
.onClick(() => {
|
||||
if (this.item.type == media_type.MEDIA_TYPE_ALBUM) {
|
||||
LogInfo(TAG, 'fold onClick')
|
||||
this.mCurrentPath = this.item.path
|
||||
updateTopPathInfo(AppStorage.Get('topPathInfo'), this.item.name, this.item.path)
|
||||
} else {
|
||||
var index = this.tmpChoseFiles.indexOf(this.item)
|
||||
if (index == -1) {
|
||||
this.item.font_color = Color.Black
|
||||
this.item.opacity = 0.1
|
||||
this.item.list_background = 'rgba(46,136,255,0.1)'
|
||||
this.tmpChoseFiles.push(this.item)
|
||||
} else {
|
||||
this.item.font_color = Color.Black
|
||||
this.item.opacity = 1
|
||||
this.item.list_background = ''
|
||||
this.tmpChoseFiles.splice(index, 1)
|
||||
}
|
||||
}
|
||||
private dialogController: CustomDialogController = new CustomDialogController({
|
||||
builder: ChooseDialog(),
|
||||
cancel: () => {
|
||||
},
|
||||
autoCancel: true
|
||||
})
|
||||
.gesture(
|
||||
LongPressGesture({ repeat: false })
|
||||
.onAction((event: GestureEvent) => {
|
||||
if (this.item.type != media_type.MEDIA_TYPE_ALBUM) {
|
||||
AppStorage.SetOrCreate<FileInfo>('selectedFileInfo', this.item)
|
||||
this.dialogController.open()
|
||||
@State item: FileInfo = new FileInfo('')
|
||||
@Link mCurrentPath: string
|
||||
@Link mMenuLevel: number
|
||||
@StorageLink('choseFiles') tmpChoseFiles: Array<FileInfo> = []
|
||||
|
||||
build() {
|
||||
Row() {
|
||||
if (this.item.type == MediaType.MEDIA_TYPE_ALBUM) {
|
||||
Row() {
|
||||
Image($r("app.media.ic_type_bigfile"))
|
||||
.width(40 * 1.3)
|
||||
.height(40 * 1.3)
|
||||
.margin({ left: 10 * 1.3 })
|
||||
Text(this.item.name)
|
||||
.fontSize(16 * 1.3)
|
||||
.fontColor('#182431')
|
||||
.fontWeight(FontWeight.Medium)
|
||||
.margin({ left: 16 * 1.3 })
|
||||
.maxLines(1)
|
||||
.textOverflow({ overflow: TextOverflow.Ellipsis })
|
||||
Blank()
|
||||
Image($r("app.media.ic_right"))
|
||||
.width(12 * 1.3)
|
||||
.height(24 * 1.3)
|
||||
.margin({ right: 12 * 1.3 })
|
||||
}
|
||||
.margin({ right: 12 * 1.3 })
|
||||
.height(64 * 1.3)
|
||||
.width('100%')
|
||||
.backgroundColor(this.item.list_background)
|
||||
} else {
|
||||
Row() {
|
||||
Image(getShowIconBySuffix(this.item.name.substring(this.item.name.lastIndexOf('.'))))
|
||||
.width(40 * 1.3)
|
||||
.height(40 * 1.3)
|
||||
.margin({ left: 8 * 1.3 })
|
||||
Column() {
|
||||
Text(this.item.name)
|
||||
.height(22 * 1.3)
|
||||
.fontSize(16 * 1.3)
|
||||
.fontColor(this.item.font_color)
|
||||
.fontWeight(FontWeight.Medium)
|
||||
.maxLines(1)
|
||||
.textOverflow({ overflow: TextOverflow.Ellipsis })
|
||||
.margin({ top: 10 * 1.3 })
|
||||
.height(22 * 1.3)
|
||||
.width(248 * 1.3)
|
||||
Row() {
|
||||
Text('' + this.item.modified_time)
|
||||
.fontSize(14 * 1.3)
|
||||
.fontColor(this.item.font_color)
|
||||
.fontWeight(FontWeight.Regular)
|
||||
.maxLines(1)
|
||||
.textOverflow({ overflow: TextOverflow.Ellipsis })
|
||||
Text('-')
|
||||
.fontSize(14 * 1.3)
|
||||
.fontColor(this.item.font_color)
|
||||
.margin({ left: 8 * 1.3 })
|
||||
Text('' + this.item.size)
|
||||
.fontSize(14 * 1.3)
|
||||
.fontColor(this.item.font_color)
|
||||
.fontWeight(FontWeight.Regular)
|
||||
.margin({ left: 8 * 1.3 })
|
||||
.maxLines(1)
|
||||
.textOverflow({ overflow: TextOverflow.Ellipsis })
|
||||
}
|
||||
.width(248 * 1.3)
|
||||
.height(19 * 1.3)
|
||||
.margin({ top: 2 * 1.3 })
|
||||
.opacity(0.6)
|
||||
}
|
||||
.height(64 * 1.3)
|
||||
.alignItems(HorizontalAlign.Start)
|
||||
.margin({ left: 16 * 1.3 })
|
||||
}
|
||||
.width('100%')
|
||||
.height(64 * 1.3) // TODO
|
||||
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
}
|
||||
.margin({ top: 4 * 1.3, left: 4 * 1.3, right: 4 * 1.3 })
|
||||
.border({ radius: 20 })
|
||||
.backgroundColor(this.item.list_background)
|
||||
.onClick(() => {
|
||||
if (this.item.type == MediaType.MEDIA_TYPE_ALBUM) {
|
||||
logInfo(TAG, 'fold onClick')
|
||||
this.mCurrentPath = this.item.path
|
||||
updateTopPathInfo(AppStorage.Get('topPathInfo'), this.item.name, this.item.path)
|
||||
} else {
|
||||
var index = this.tmpChoseFiles.indexOf(this.item)
|
||||
if (index == -1) {
|
||||
this.item.font_color = Color.Black
|
||||
this.item.opacity = 0.1
|
||||
this.item.list_background = 'rgba(46,136,255,0.1)'
|
||||
this.tmpChoseFiles.push(this.item)
|
||||
} else {
|
||||
this.item.font_color = Color.Black
|
||||
this.item.opacity = 1
|
||||
this.item.list_background = ''
|
||||
this.tmpChoseFiles.splice(index, 1)
|
||||
}
|
||||
}
|
||||
})
|
||||
.gesture(
|
||||
LongPressGesture({ repeat: false })
|
||||
.onAction((event: GestureEvent) => {
|
||||
if (this.item.type != MediaType.MEDIA_TYPE_ALBUM) {
|
||||
AppStorage.SetOrCreate<FileInfo>('selectedFileInfo', this.item)
|
||||
this.dialogController.open()
|
||||
}
|
||||
})
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -13,145 +13,146 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { FileInfo } from '../module/FileInfo'
|
||||
import { LogInfo, LogDebug } from '../module/LogUtils'
|
||||
import { getListFile } from '../module/FileManagerServiceUtils'
|
||||
import { ChooseDialog } from '../module/DialogUtils'
|
||||
import { FileInfo } from '../../../../../../common/src/main/ets/components/Data/FileInfo'
|
||||
import { getListFile } from '../../../../../../common/src/main/ets/components/Utils/FileManagerServiceUtils'
|
||||
import { logDebug, logInfo } from '../../../../../../common/src/main/ets/components/Utils/LogUtils'
|
||||
import { ChooseDialog } from '../../../../../../common/src/main/ets/components/View/ChooseDialog'
|
||||
|
||||
let TAG: string = 'ThirdLevelHasPic'
|
||||
|
||||
@Component
|
||||
export struct ThirdLevelHasPic {
|
||||
private mColumnTemplate: string
|
||||
private mCurrentMode: string
|
||||
private mCurrentIndex: number
|
||||
private mWorker
|
||||
@Link mFileList: Array<FileInfo>
|
||||
@Link mMenuLevel: number
|
||||
@Link mType: string
|
||||
@Link mCurrentPath: string
|
||||
@StorageLink('choseFiles') tmpFiles: Array<FileInfo> = []
|
||||
private mColumnTemplate: string
|
||||
private mCurrentMode: string
|
||||
private mCurrentIndex: number
|
||||
private mWorker
|
||||
@Link mFileList: Array<FileInfo>
|
||||
@Link mMenuLevel: number
|
||||
@Link mType: string
|
||||
@Link mCurrentPath: string
|
||||
@StorageLink('choseFiles') tmpFiles: Array<FileInfo> = []
|
||||
|
||||
aboutToAppear() {
|
||||
if (globalThis.debugMode) {
|
||||
this.mFileList = getListFile('local', this.mType, this.mCurrentPath)
|
||||
LogDebug(TAG, 'mFileList length = ' + this.mFileList.length)
|
||||
} else {
|
||||
this.mWorker.postMessage({
|
||||
request_data: 'listFile',
|
||||
device_name: 'local',
|
||||
menu_level: this.mMenuLevel,
|
||||
media_type: this.mType,
|
||||
path: this.mCurrentPath,
|
||||
offset: 0,
|
||||
count: 100
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
private aboutToDisappear() {
|
||||
LogInfo(TAG, 'aboutToDisappear')
|
||||
AppStorage.Set('choseFiles', [])
|
||||
}
|
||||
|
||||
build() {
|
||||
if (globalThis.startMode == 'choose') {
|
||||
Column() {
|
||||
Flex({
|
||||
direction: FlexDirection.Row,
|
||||
wrap: FlexWrap.Wrap,
|
||||
justifyContent: FlexAlign.Start,
|
||||
alignItems: ItemAlign.Start
|
||||
}) {
|
||||
ForEach(this.mFileList, (item: FileInfo) => {
|
||||
GridItemView({ gridItem: item })
|
||||
}, item => item.name)
|
||||
aboutToAppear() {
|
||||
logInfo(TAG, 'aboutToAppear send message to worker')
|
||||
if (globalThis.debugMode) {
|
||||
this.mFileList = getListFile('local', this.mType, this.mCurrentPath)
|
||||
logDebug(TAG, 'mFileList length = ' + this.mFileList.length)
|
||||
} else {
|
||||
this.mWorker.postMessage({
|
||||
request_data: 'listFile',
|
||||
device_name: 'local',
|
||||
menu_level: this.mMenuLevel,
|
||||
MediaType: this.mType,
|
||||
path: this.mCurrentPath,
|
||||
offset: 0,
|
||||
count: 100
|
||||
})
|
||||
}
|
||||
.margin({ top: 8 * 1.3 })
|
||||
}
|
||||
.alignItems(HorizontalAlign.Start)
|
||||
.border({ radius: 24 })
|
||||
.opacity(0.9)
|
||||
.backgroundColor(Color.White)
|
||||
}
|
||||
|
||||
}
|
||||
private aboutToDisappear() {
|
||||
logInfo(TAG, 'aboutToDisappear')
|
||||
AppStorage.Set('choseFiles', [])
|
||||
}
|
||||
|
||||
build() {
|
||||
if (globalThis.startMode == 'choose') {
|
||||
Column() {
|
||||
Flex({
|
||||
direction: FlexDirection.Row,
|
||||
wrap: FlexWrap.Wrap,
|
||||
justifyContent: FlexAlign.Start,
|
||||
alignItems: ItemAlign.Start
|
||||
}) {
|
||||
ForEach(this.mFileList, (item: FileInfo) => {
|
||||
GridItemView({ gridItem: item })
|
||||
}, item => item.name)
|
||||
}
|
||||
.margin({ top: 8 * 1.3 })
|
||||
}
|
||||
.alignItems(HorizontalAlign.Start)
|
||||
.border({ radius: 24 })
|
||||
.opacity(0.9)
|
||||
.backgroundColor(Color.White)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Component
|
||||
struct GridItemView {
|
||||
private dialogController: CustomDialogController = new CustomDialogController({
|
||||
builder: ChooseDialog(),
|
||||
cancel: () => {
|
||||
},
|
||||
autoCancel: true
|
||||
})
|
||||
@State gridItem: FileInfo = new FileInfo('')
|
||||
|
||||
build() {
|
||||
Flex({
|
||||
direction: FlexDirection.Column,
|
||||
alignItems: ItemAlign.Center,
|
||||
justifyContent: FlexAlign.Center
|
||||
}) {
|
||||
Image(`${this.gridItem.path}/thumbnail/160/160`)
|
||||
.borderRadius(12)
|
||||
.objectFit(ImageFit.Contain)
|
||||
.width(80 * 1.3)
|
||||
.height(80 * 1.3)
|
||||
.margin({
|
||||
left: 8 * 1.3,
|
||||
right: 8 * 1.3,
|
||||
top: 4 * 1.3
|
||||
})
|
||||
Row() {
|
||||
Text(this.gridItem.name)
|
||||
.width(82 * 1.3)
|
||||
.fontSize(12 * 1.3)
|
||||
.fontColor(this.gridItem.list_background == 'rgba(46,136,255,0.1)' ? Color.White : Color.Black)
|
||||
.fontWeight(FontWeight.Regular)
|
||||
.opacity(0.9)
|
||||
.textAlign(TextAlign.Center)
|
||||
.maxLines(2)
|
||||
.textOverflow({ overflow: TextOverflow.Ellipsis })
|
||||
.margin({ top: 2 * 1.3 })
|
||||
.padding({ right: 4 * 1.3, left: 4 * 1.3 })
|
||||
}
|
||||
.borderRadius(12)
|
||||
.backgroundColor(this.gridItem.list_background == 'rgba(46,136,255,0.1)' ? 0x2E8BFF : '')
|
||||
.alignItems(VerticalAlign.Top)
|
||||
.width(82 * 1.3)
|
||||
.height(36 * 1.3)
|
||||
.margin({ top: 4 * 1.3 })
|
||||
}
|
||||
.padding({ bottom: 8 * 1.3 })
|
||||
.width(96 * 1.3)
|
||||
.height(126 * 1.3)
|
||||
.margin({ bottom: 12 * 1.3, left: 12 * 1.3 })
|
||||
.border({ radius: 20 })
|
||||
.backgroundColor(this.gridItem.list_background)
|
||||
.gesture(
|
||||
LongPressGesture({ repeat: false })
|
||||
.onAction((event: GestureEvent) => {
|
||||
AppStorage.SetOrCreate('selectedFileInfo', this.gridItem)
|
||||
this.dialogController.open()
|
||||
})
|
||||
)
|
||||
.onClick(() => {
|
||||
let choseFiles: Array<FileInfo> = AppStorage.Get('choseFiles')
|
||||
let index: number = choseFiles.indexOf(this.gridItem)
|
||||
if (index == -1) {
|
||||
this.gridItem.opacity = 0.1
|
||||
this.gridItem.font_color = '#FFFFFF'
|
||||
this.gridItem.list_background = 'rgba(46,136,255,0.1)'
|
||||
choseFiles.push(this.gridItem)
|
||||
} else {
|
||||
choseFiles.splice(index)
|
||||
this.gridItem.opacity = 1
|
||||
this.gridItem.font_color = '#000000'
|
||||
this.gridItem.list_background = ''
|
||||
}
|
||||
private dialogController: CustomDialogController = new CustomDialogController({
|
||||
builder: ChooseDialog(),
|
||||
cancel: () => {
|
||||
},
|
||||
autoCancel: true
|
||||
})
|
||||
@State gridItem: FileInfo = new FileInfo('')
|
||||
|
||||
}
|
||||
build() {
|
||||
Flex({
|
||||
direction: FlexDirection.Column,
|
||||
alignItems: ItemAlign.Center,
|
||||
justifyContent: FlexAlign.Center
|
||||
}) {
|
||||
Image(`${this.gridItem.path}/thumbnail/160/160`)
|
||||
.borderRadius(12)
|
||||
.objectFit(ImageFit.Contain)
|
||||
.width(80 * 1.3)
|
||||
.height(80 * 1.3)
|
||||
.margin({
|
||||
left: 8 * 1.3,
|
||||
right: 8 * 1.3,
|
||||
top: 4 * 1.3
|
||||
})
|
||||
Row() {
|
||||
Text(this.gridItem.name)
|
||||
.width(82 * 1.3)
|
||||
.fontSize(12 * 1.3)
|
||||
.fontColor(this.gridItem.list_background == 'rgba(46,136,255,0.1)' ? Color.White : Color.Black)
|
||||
.fontWeight(FontWeight.Regular)
|
||||
.opacity(0.9)
|
||||
.textAlign(TextAlign.Center)
|
||||
.maxLines(2)
|
||||
.textOverflow({ overflow: TextOverflow.Ellipsis })
|
||||
.margin({ top: 2 * 1.3 })
|
||||
.padding({ right: 4 * 1.3, left: 4 * 1.3 })
|
||||
}
|
||||
.borderRadius(12)
|
||||
.backgroundColor(this.gridItem.list_background == 'rgba(46,136,255,0.1)' ? 0x2E8BFF : '')
|
||||
.alignItems(VerticalAlign.Top)
|
||||
.width(82 * 1.3)
|
||||
.height(36 * 1.3)
|
||||
.margin({ top: 4 * 1.3 })
|
||||
}
|
||||
.padding({ bottom: 8 * 1.3 })
|
||||
.width(96 * 1.3)
|
||||
.height(126 * 1.3)
|
||||
.margin({ bottom: 12 * 1.3, left: 12 * 1.3 })
|
||||
.border({ radius: 20 })
|
||||
.backgroundColor(this.gridItem.list_background)
|
||||
.gesture(
|
||||
LongPressGesture({ repeat: false })
|
||||
.onAction((event: GestureEvent) => {
|
||||
AppStorage.SetOrCreate('selectedFileInfo', this.gridItem)
|
||||
this.dialogController.open()
|
||||
})
|
||||
)
|
||||
.onClick(() => {
|
||||
let choseFiles: Array<FileInfo> = AppStorage.Get('choseFiles')
|
||||
let index: number = choseFiles.indexOf(this.gridItem)
|
||||
if (index == -1) {
|
||||
this.gridItem.opacity = 0.1
|
||||
this.gridItem.font_color = '#FFFFFF'
|
||||
this.gridItem.list_background = 'rgba(46,136,255,0.1)'
|
||||
choseFiles.push(this.gridItem)
|
||||
} else {
|
||||
choseFiles.splice(index)
|
||||
this.gridItem.opacity = 1
|
||||
this.gridItem.font_color = '#000000'
|
||||
this.gridItem.list_background = ''
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
@@ -18,429 +18,432 @@ import { FirstLevelByType } from './FirstLevelByType'
|
||||
import { SecondLevelByFold } from './SecondLevelByFold'
|
||||
import { ThirdLevelHasDetail } from '../pages/ThirdLevelHasDetail'
|
||||
import { ThirdLevelHasPic } from '../pages/ThirdLevelHasPic'
|
||||
import { FileInfo, TopPathInfo } from '../module/FileInfo'
|
||||
import { menuLevel, terminate_reason, media_type } from '../module/Constants'
|
||||
import { LogInfo, LogDebug } from '../module/LogUtils'
|
||||
import { changeStringToType, updateTopPathInfo } from '../module/Utils'
|
||||
import { terminateSelfWithResult } from '../module/AbilityUtils'
|
||||
import { WarningDialog } from '../module/DialogUtils'
|
||||
import { getFirstMenu } from '../module/FileManagerServiceUtils'
|
||||
import { MenuLevel, TerminateReason, MediaType } from '../../../../../../common/src/main/ets/components/Data/Constants'
|
||||
import { FileInfo } from '../../../../../../common/src/main/ets/components/Data/FileInfo'
|
||||
import { TopPathInfo } from '../../../../../../common/src/main/ets/components/Data/TopPathInfo'
|
||||
import { terminateSelfWithResult } from '../../../../../../common/src/main/ets/components/utils/AbilityUtils'
|
||||
import { getFirstMenu } from '../../../../../../common/src/main/ets/components/Utils/FileManagerServiceUtils'
|
||||
import { logInfo, logDebug, logError } from '../../../../../../common/src/main/ets/components/Utils/LogUtils'
|
||||
import { changeStringToType, updateTopPathInfo } from '../../../../../../common/src/main/ets/components/utils/Utils'
|
||||
import { WarningDialog } from '../../../../../../common/src/main/ets/components/View/WarningDialog'
|
||||
|
||||
@Entry
|
||||
@Component
|
||||
struct allIndex {
|
||||
build() {
|
||||
Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.End, justifyContent: FlexAlign.SpaceBetween }) {
|
||||
Stack({ alignContent: Alignment.Bottom }) {
|
||||
Column() {
|
||||
private TAG: string= 'Main'
|
||||
|
||||
build() {
|
||||
Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.End, justifyContent: FlexAlign.SpaceBetween }) {
|
||||
Stack({ alignContent: Alignment.Bottom }) {
|
||||
Column() {
|
||||
}
|
||||
.onClick(() => {
|
||||
globalThis.context.terminateSelf((err, data) => {
|
||||
logInfo(this.TAG, 'terminateSelf success')
|
||||
})
|
||||
})
|
||||
.width('100%')
|
||||
.height('100%')
|
||||
|
||||
Index()
|
||||
}
|
||||
.width('100%')
|
||||
.height('100%')
|
||||
}
|
||||
.onClick(() => {
|
||||
globalThis.context.terminateSelf((err, data) => {
|
||||
console.log('terminateSelf success')
|
||||
})
|
||||
})
|
||||
.backgroundColor('rgba(0,0,0,0.1)')
|
||||
.position({ x: 0, y: 0 })
|
||||
.width('100%')
|
||||
.height('100%')
|
||||
|
||||
Index()
|
||||
}
|
||||
.width('100%')
|
||||
.height('100%')
|
||||
}
|
||||
.backgroundColor('rgba(0,0,0,0.1)')
|
||||
.position({ x: 0, y: 0 })
|
||||
.width('100%')
|
||||
.height('100%')
|
||||
}
|
||||
}
|
||||
|
||||
@Component
|
||||
struct Index {
|
||||
private TAG: string= 'Main'
|
||||
private mWorker
|
||||
private customDialogController: CustomDialogController = new CustomDialogController({
|
||||
builder: WarningDialog({ code: $code })
|
||||
})
|
||||
@State mFirstMenuData: FileInfo[] = []
|
||||
@State mSecondMenuData: FileInfo[] = []
|
||||
@State mThirdMenuPicData: FileInfo[]= []
|
||||
@State mThirdMenuDetailData: FileInfo[]= []
|
||||
@State mType: string = ''
|
||||
@State mMenuLevel: number = menuLevel.MENU_FIRST_LEVEL_BY_TYPE
|
||||
@State mCurrentPath: string= ''
|
||||
@State code: number = 2;
|
||||
@StorageLink('startMode') mCurrentMode: string = 'choose'
|
||||
@StorageLink('topPathInfo') topPathInfo: Array<TopPathInfo> = updateTopPathInfo([], '文件类型', '')
|
||||
scroller: Scroller = new Scroller()
|
||||
private TAG: string= 'Main'
|
||||
private mWorker
|
||||
private customDialogController: CustomDialogController = new CustomDialogController({
|
||||
builder: WarningDialog({ code: $code })
|
||||
})
|
||||
@State mFirstMenuData: FileInfo[] = []
|
||||
@State mSecondMenuData: FileInfo[] = []
|
||||
@State mThirdMenuPicData: FileInfo[]= []
|
||||
@State mThirdMenuDetailData: FileInfo[]= []
|
||||
@State mType: string = ''
|
||||
@State mMenuLevel: number = MenuLevel.MENU_FIRST_LEVEL_BY_TYPE
|
||||
@State mCurrentPath: string= ''
|
||||
@State code: number = 2;
|
||||
@StorageLink('startMode') mCurrentMode: string = 'choose'
|
||||
@StorageLink('topPathInfo') topPathInfo: Array<TopPathInfo> = updateTopPathInfo([], '文件类型', '')
|
||||
scroller: Scroller = new Scroller()
|
||||
|
||||
aboutToAppear() {
|
||||
LogInfo(this.TAG, 'aboutToAppear')
|
||||
if (globalThis.debugMode) {
|
||||
this.mFirstMenuData = getFirstMenu('')
|
||||
LogDebug(this.TAG, 'mFirstMenuData length = ' + this.mFirstMenuData.length)
|
||||
} else {
|
||||
this.initWork()
|
||||
LogInfo(this.TAG, 'send message to worker')
|
||||
this.mWorker.postMessage({
|
||||
request_data: 'getRoot',
|
||||
device_name: 'local',
|
||||
menu_level: this.mMenuLevel,
|
||||
media_type: this.mType,
|
||||
path: this.mCurrentPath
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
private initWork() {
|
||||
if (this.mWorker == undefined) {
|
||||
LogInfo(this.TAG, 'initWorker')
|
||||
this.mWorker = new worker.Worker('RK/ets/workers/DataWorker.js', { type: 'classic', name: 'filePicker' })
|
||||
this.mWorker.onerror = this.onError.bind(this)
|
||||
this.mWorker.onmessageerror = this.onMessageError.bind(this)
|
||||
this.mWorker.onexit = this.onExit.bind(this)
|
||||
this.mWorker.onmessage = this.onMessage.bind(this)
|
||||
}
|
||||
}
|
||||
|
||||
private onError(e): void{
|
||||
LogInfo(this.TAG, 'onError = ' + JSON.stringify(e))
|
||||
}
|
||||
|
||||
private onMessageError(e): void{
|
||||
LogInfo(this.TAG, 'onMessageError = ' + JSON.stringify(e))
|
||||
}
|
||||
|
||||
private onExit(): void{
|
||||
LogInfo(this.TAG, 'onExit')
|
||||
this.mWorker = undefined
|
||||
}
|
||||
|
||||
private onMessage(result) {
|
||||
LogInfo(this.TAG, 'main thread onMessage')
|
||||
var params = result.data.params
|
||||
var file = JSON.parse(String.fromCharCode.apply(null, new Uint16Array(result.data.data)))
|
||||
if (params.request_data == 'createFile') {
|
||||
if (file.code == undefined) {
|
||||
terminateSelfWithResult(terminate_reason.SUCCESS, file)
|
||||
} else {
|
||||
if (params.path == 'dataability:///album') {
|
||||
this.code = 2;
|
||||
this.customDialogController.open()
|
||||
aboutToAppear() {
|
||||
if (globalThis.debugMode) {
|
||||
this.mFirstMenuData = getFirstMenu('')
|
||||
logDebug(this.TAG, 'mFirstMenuData length = ' + this.mFirstMenuData.length)
|
||||
} else {
|
||||
this.code = file.code
|
||||
this.customDialogController.open()
|
||||
logInfo(this.TAG, 'aboutToAppear')
|
||||
this.initWork()
|
||||
logInfo(this.TAG, 'send message to worker')
|
||||
this.mWorker.postMessage({
|
||||
request_data: 'getRoot',
|
||||
device_name: 'local',
|
||||
menu_level: this.mMenuLevel,
|
||||
MediaType: this.mType,
|
||||
path: this.mCurrentPath
|
||||
})
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
if (Array.isArray(file)) {
|
||||
let listData: Array<FileInfo> = []
|
||||
for (var index = 0;index < file.length; index++) {
|
||||
var info = file[index]
|
||||
let item = new FileInfo(info.name)
|
||||
item.path = info.path
|
||||
item.type = info.type
|
||||
item.size = info.size
|
||||
item.dataAdded_time = info.added_time
|
||||
item.modified_time = info.modified_time
|
||||
if (params.menu_level == menuLevel.MENU_FIRST_LEVEL_BY_TYPE) {
|
||||
if (item.name == 'image_album') {
|
||||
item.name = '图片'
|
||||
item.mediaType = 'image'
|
||||
item.thumbnail = $r("app.media.ic_type_image")
|
||||
} else if (item.name == 'video_album') {
|
||||
item.name = '视频'
|
||||
item.mediaType = 'video'
|
||||
item.thumbnail = $r("app.media.ic_type_video")
|
||||
} else if (item.name == 'audio_album') {
|
||||
item.name = '音乐'
|
||||
item.mediaType = 'audio'
|
||||
item.thumbnail = $r("app.media.ic_type_audio")
|
||||
} else if (item.name == 'file_folder') {
|
||||
item.name = '文档'
|
||||
item.mediaType = 'file'
|
||||
item.thumbnail = $r("app.media.ic_type_file")
|
||||
}
|
||||
}
|
||||
|
||||
if (params.menu_level == menuLevel.MENU_THIRD_LEVEL_HAS_DETAIL) {
|
||||
if (this.mCurrentMode == 'save' && item.type != media_type.MEDIA_TYPE_ALBUM) {
|
||||
break
|
||||
}
|
||||
private initWork() {
|
||||
if (this.mWorker == undefined) {
|
||||
logInfo(this.TAG, 'initWorker')
|
||||
this.mWorker = new worker.Worker('RK/ets/workers/DataWorker.js', { type: 'classic', name: 'filePicker' })
|
||||
this.mWorker.onerror = this.onError.bind(this)
|
||||
this.mWorker.onmessageerror = this.onMessageError.bind(this)
|
||||
this.mWorker.onexit = this.onExit.bind(this)
|
||||
this.mWorker.onmessage = this.onMessage.bind(this)
|
||||
}
|
||||
listData.push(item)
|
||||
}
|
||||
if (params.menu_level == menuLevel.MENU_FIRST_LEVEL_BY_TYPE && params.request_data == 'getRoot') {
|
||||
LogDebug(this.TAG, 'mFirstMenuData length = ' + listData.length)
|
||||
this.mFirstMenuData = listData
|
||||
} else if (params.menu_level == menuLevel.MENU_SECOND_LEVEL_BY_FOLD) {
|
||||
LogDebug(this.TAG, 'mSecondMenuData length = ' + listData.length)
|
||||
this.mSecondMenuData = listData
|
||||
} else if (params.menu_level == menuLevel.MENU_THIRD_LEVEL_HAS_PIC) {
|
||||
LogDebug(this.TAG, 'mThirdMenuPicData length = ' + listData.length)
|
||||
this.mThirdMenuPicData = listData
|
||||
} else if (params.menu_level == menuLevel.MENU_THIRD_LEVEL_HAS_DETAIL) {
|
||||
LogDebug(this.TAG, 'mThirdMenuDetailData length = ' + listData.length)
|
||||
if (listData.length > 0) {
|
||||
this.mThirdMenuDetailData = listData
|
||||
} else {
|
||||
this.mThirdMenuDetailData = []
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
TopBarArea()
|
||||
private onError(e): void{
|
||||
logError(this.TAG, 'onError = ' + JSON.stringify(e))
|
||||
}
|
||||
|
||||
Column() {
|
||||
Column() {
|
||||
Row() {
|
||||
List() {
|
||||
ForEach(this.topPathInfo, (item: TopPathInfo) => {
|
||||
ListItem() {
|
||||
Row() {
|
||||
if (item.name != '文件类型') {
|
||||
Image($r("app.media.ic_public_right"))
|
||||
.width(12 * 1.3)
|
||||
.height(24 * 1.3)
|
||||
.margin({
|
||||
left: 4 * 1.3,
|
||||
right: 4 * 1.3
|
||||
})
|
||||
}
|
||||
private onMessageError(e): void{
|
||||
logError(this.TAG, 'onMessageError = ' + JSON.stringify(e))
|
||||
}
|
||||
|
||||
Text(item.name)
|
||||
.height(24 * 1.3)
|
||||
.fontColor('#000000')
|
||||
.fontSize(16 * 1.3)
|
||||
.fontWeight(FontWeight.Medium)
|
||||
.opacity(item.opacity)
|
||||
.onClick(() => {
|
||||
LogInfo(this.TAG, item.name + ' onClick')
|
||||
if (item.name == '文件类型') {
|
||||
updateTopPathInfo([], '文件类型', '')
|
||||
this.mMenuLevel = menuLevel.MENU_FIRST_LEVEL_BY_TYPE
|
||||
this.mType = ''
|
||||
} else if (this.mMenuLevel == menuLevel.MENU_THIRD_LEVEL_HAS_DETAIL) {
|
||||
this.mCurrentPath = item.path
|
||||
LogInfo(this.TAG, 'item.path' + item.path)
|
||||
let topPathInfo: Array<TopPathInfo> = AppStorage.Get('topPathInfo')
|
||||
let index: number = topPathInfo.indexOf(item)
|
||||
if (index != -1) {
|
||||
var deleteNum = topPathInfo.length - index + 1
|
||||
topPathInfo.splice(index + 1, deleteNum)
|
||||
topPathInfo[topPathInfo.length - 1].opacity = 1
|
||||
AppStorage.Set('topPathInfo', topPathInfo)
|
||||
}
|
||||
} else if (this.mMenuLevel == menuLevel.MENU_THIRD_LEVEL_HAS_PIC) {
|
||||
this.mMenuLevel = menuLevel.MENU_SECOND_LEVEL_BY_FOLD
|
||||
this.mType = changeStringToType(item.name)
|
||||
LogInfo(this.TAG, 'item.path 2 ' + item.path)
|
||||
this.mCurrentPath = item.path
|
||||
}
|
||||
})
|
||||
}
|
||||
private onExit(): void{
|
||||
logInfo(this.TAG, 'onExit')
|
||||
this.mWorker = undefined
|
||||
}
|
||||
|
||||
private onMessage(result) {
|
||||
logInfo(this.TAG, 'main thread onMessage')
|
||||
var params = result.data.params
|
||||
var file = JSON.parse(String.fromCharCode.apply(null, new Uint16Array(result.data.data)))
|
||||
if (params.request_data == 'createFile') {
|
||||
if (file.code == undefined) {
|
||||
terminateSelfWithResult(TerminateReason.SUCCESS, file)
|
||||
} else {
|
||||
if (params.path == 'dataability:///album') {
|
||||
this.code = 2;
|
||||
this.customDialogController.open()
|
||||
} else {
|
||||
this.code = file.code
|
||||
this.customDialogController.open()
|
||||
}
|
||||
}, item => item.name.toString())
|
||||
}
|
||||
.padding({ right: 24 * 1.3 })
|
||||
.listDirection(Axis.Horizontal)
|
||||
}
|
||||
.alignItems(VerticalAlign.Center)
|
||||
.width('100%')
|
||||
.height(48 * 1.3)
|
||||
.margin({ left: 12 * 1.3, top: 4 * 1.3 })
|
||||
.padding({ top: 13 * 1.3, bottom: 13 * 1.3 })
|
||||
return
|
||||
}
|
||||
if (Array.isArray(file)) {
|
||||
let listData: Array<FileInfo> = []
|
||||
for (var index = 0;index < file.length; index++) {
|
||||
var info = file[index]
|
||||
let item = new FileInfo(info.name)
|
||||
item.path = info.path
|
||||
item.type = info.type
|
||||
item.size = info.size
|
||||
item.dataAdded_time = info.added_time
|
||||
item.modified_time = info.modified_time
|
||||
if (params.menu_level == MenuLevel.MENU_FIRST_LEVEL_BY_TYPE) {
|
||||
if (item.name == 'image_album') {
|
||||
item.name = '图片'
|
||||
item.mediaType = 'image'
|
||||
item.thumbnail = $r("app.media.ic_type_image")
|
||||
} else if (item.name == 'video_album') {
|
||||
item.name = '视频'
|
||||
item.mediaType = 'video'
|
||||
item.thumbnail = $r("app.media.ic_type_video")
|
||||
} else if (item.name == 'audio_album') {
|
||||
item.name = '音乐'
|
||||
item.mediaType = 'audio'
|
||||
item.thumbnail = $r("app.media.ic_type_audio")
|
||||
} else if (item.name == 'file_folder') {
|
||||
item.name = '文档'
|
||||
item.mediaType = 'file'
|
||||
item.thumbnail = $r("app.media.ic_type_file")
|
||||
}
|
||||
}
|
||||
|
||||
if (params.menu_level == MenuLevel.MENU_THIRD_LEVEL_HAS_DETAIL) {
|
||||
if (this.mCurrentMode == 'save' && item.type != MediaType.MEDIA_TYPE_ALBUM) {
|
||||
break
|
||||
}
|
||||
}
|
||||
listData.push(item)
|
||||
}
|
||||
if (params.menu_level == MenuLevel.MENU_FIRST_LEVEL_BY_TYPE && params.request_data == 'getRoot') {
|
||||
logDebug(this.TAG, 'mFirstMenuData length = ' + listData.length)
|
||||
this.mFirstMenuData = listData
|
||||
} else if (params.menu_level == MenuLevel.MENU_SECOND_LEVEL_BY_FOLD) {
|
||||
logDebug(this.TAG, 'mSecondMenuData length = ' + listData.length)
|
||||
this.mSecondMenuData = listData
|
||||
} else if (params.menu_level == MenuLevel.MENU_THIRD_LEVEL_HAS_PIC) {
|
||||
logDebug(this.TAG, 'mThirdMenuPicData length = ' + listData.length)
|
||||
this.mThirdMenuPicData = listData
|
||||
} else if (params.menu_level == MenuLevel.MENU_THIRD_LEVEL_HAS_DETAIL) {
|
||||
logDebug(this.TAG, 'mThirdMenuDetailData length = ' + listData.length)
|
||||
if (listData.length > 0) {
|
||||
this.mThirdMenuDetailData = listData
|
||||
} else {
|
||||
this.mThirdMenuDetailData = []
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
TopBarArea()
|
||||
|
||||
Scroll(this.scroller) {
|
||||
Column() {
|
||||
if (this.mMenuLevel == menuLevel.MENU_FIRST_LEVEL_BY_TYPE) {
|
||||
FirstLevelByType({
|
||||
mFileList: this.mFirstMenuData,
|
||||
mType: $mType,
|
||||
mMenuLevel: $mMenuLevel,
|
||||
mCurrentPath: $mCurrentPath,
|
||||
mWorker: this.mWorker,
|
||||
})
|
||||
} else if (this.mMenuLevel == menuLevel.MENU_SECOND_LEVEL_BY_FOLD) {
|
||||
SecondLevelByFold({
|
||||
mType: $mType,
|
||||
mMenuLevel: $mMenuLevel,
|
||||
mCurrentPath: $mCurrentPath,
|
||||
mWorker: this.mWorker,
|
||||
mFileList: $mSecondMenuData
|
||||
})
|
||||
} else if (this.mMenuLevel == menuLevel.MENU_THIRD_LEVEL_HAS_PIC) {
|
||||
ThirdLevelHasPic({
|
||||
mType: $mType,
|
||||
mMenuLevel: $mMenuLevel,
|
||||
mCurrentPath: $mCurrentPath,
|
||||
mWorker: this.mWorker,
|
||||
mFileList: $mThirdMenuPicData
|
||||
})
|
||||
} else if (this.mMenuLevel == menuLevel.MENU_THIRD_LEVEL_HAS_DETAIL) {
|
||||
ThirdLevelHasDetail({
|
||||
mType: $mType,
|
||||
mMenuLevel: $mMenuLevel,
|
||||
mCurrentPath: $mCurrentPath,
|
||||
mWorker: this.mWorker,
|
||||
mFileInfo: $mThirdMenuDetailData
|
||||
})
|
||||
}
|
||||
Row() {
|
||||
}.width('100%').height(53 * 1.3)
|
||||
Column() {
|
||||
Row() {
|
||||
List() {
|
||||
ForEach(this.topPathInfo, (item: TopPathInfo) => {
|
||||
ListItem() {
|
||||
Row() {
|
||||
if (item.name != '文件类型') {
|
||||
Image($r("app.media.ic_public_right"))
|
||||
.width(12 * 1.3)
|
||||
.height(24 * 1.3)
|
||||
.margin({
|
||||
left: 4 * 1.3,
|
||||
right: 4 * 1.3
|
||||
})
|
||||
}
|
||||
|
||||
Text(item.name)
|
||||
.height(24 * 1.3)
|
||||
.fontColor('#000000')
|
||||
.fontSize(16 * 1.3)
|
||||
.fontWeight(FontWeight.Medium)
|
||||
.opacity(item.opacity)
|
||||
.onClick(() => {
|
||||
logInfo(this.TAG, item.name + ' onClick')
|
||||
if (item.name == '文件类型') {
|
||||
updateTopPathInfo([], '文件类型', '')
|
||||
this.mMenuLevel = MenuLevel.MENU_FIRST_LEVEL_BY_TYPE
|
||||
this.mType = ''
|
||||
} else if (this.mMenuLevel == MenuLevel.MENU_THIRD_LEVEL_HAS_DETAIL) {
|
||||
this.mCurrentPath = item.path
|
||||
logInfo(this.TAG, 'item.path' + item.path)
|
||||
let topPathInfo: Array<TopPathInfo> = AppStorage.Get('topPathInfo')
|
||||
let index: number = topPathInfo.indexOf(item)
|
||||
if (index != -1) {
|
||||
var deleteNum = topPathInfo.length - index + 1
|
||||
topPathInfo.splice(index + 1, deleteNum)
|
||||
topPathInfo[topPathInfo.length - 1].opacity = 1
|
||||
AppStorage.Set('topPathInfo', topPathInfo)
|
||||
}
|
||||
} else if (this.mMenuLevel == MenuLevel.MENU_THIRD_LEVEL_HAS_PIC) {
|
||||
this.mMenuLevel = MenuLevel.MENU_SECOND_LEVEL_BY_FOLD
|
||||
this.mType = changeStringToType(item.name)
|
||||
logInfo(this.TAG, 'item.path 2 ' + item.path)
|
||||
this.mCurrentPath = item.path
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}, item => item.name.toString())
|
||||
}
|
||||
.padding({ right: 24 * 1.3 })
|
||||
.listDirection(Axis.Horizontal)
|
||||
}
|
||||
.alignItems(VerticalAlign.Center)
|
||||
.width('100%')
|
||||
.height(48 * 1.3)
|
||||
.margin({ left: 12 * 1.3, top: 4 * 1.3 })
|
||||
.padding({ top: 13 * 1.3, bottom: 13 * 1.3 })
|
||||
|
||||
Scroll(this.scroller) {
|
||||
Column() {
|
||||
if (this.mMenuLevel == MenuLevel.MENU_FIRST_LEVEL_BY_TYPE) {
|
||||
FirstLevelByType({
|
||||
mFileList: this.mFirstMenuData,
|
||||
mType: $mType,
|
||||
mMenuLevel: $mMenuLevel,
|
||||
mCurrentPath: $mCurrentPath,
|
||||
mWorker: this.mWorker,
|
||||
})
|
||||
} else if (this.mMenuLevel == MenuLevel.MENU_SECOND_LEVEL_BY_FOLD) {
|
||||
SecondLevelByFold({
|
||||
mType: $mType,
|
||||
mMenuLevel: $mMenuLevel,
|
||||
mCurrentPath: $mCurrentPath,
|
||||
mWorker: this.mWorker,
|
||||
mFileList: $mSecondMenuData
|
||||
})
|
||||
} else if (this.mMenuLevel == MenuLevel.MENU_THIRD_LEVEL_HAS_PIC) {
|
||||
ThirdLevelHasPic({
|
||||
mType: $mType,
|
||||
mMenuLevel: $mMenuLevel,
|
||||
mCurrentPath: $mCurrentPath,
|
||||
mWorker: this.mWorker,
|
||||
mFileList: $mThirdMenuPicData
|
||||
})
|
||||
} else if (this.mMenuLevel == MenuLevel.MENU_THIRD_LEVEL_HAS_DETAIL) {
|
||||
ThirdLevelHasDetail({
|
||||
mType: $mType,
|
||||
mMenuLevel: $mMenuLevel,
|
||||
mCurrentPath: $mCurrentPath,
|
||||
mWorker: this.mWorker,
|
||||
mFileInfo: $mThirdMenuDetailData
|
||||
})
|
||||
}
|
||||
Row() {
|
||||
}.width('100%').height(53 * 1.3)
|
||||
}
|
||||
.alignItems(HorizontalAlign.Start)
|
||||
}
|
||||
.scrollBar(BarState.Off)
|
||||
.scrollable(ScrollDirection.Vertical)
|
||||
}
|
||||
.alignItems(HorizontalAlign.Start)
|
||||
}
|
||||
.alignItems(HorizontalAlign.Start)
|
||||
}
|
||||
.scrollBar(BarState.Off)
|
||||
.scrollable(ScrollDirection.Vertical)
|
||||
}
|
||||
.alignItems(HorizontalAlign.Start)
|
||||
}
|
||||
.alignItems(HorizontalAlign.Start)
|
||||
.height(globalThis.mainDialogHeight - 182)
|
||||
.height(globalThis.mainDialogHeight - 140 * 1.3)
|
||||
|
||||
BottomBar({
|
||||
mCurrentPath: $mCurrentPath,
|
||||
mMenuLevel: $mMenuLevel,
|
||||
mType: $mType,
|
||||
mWorker: this.mWorker
|
||||
})
|
||||
BottomBar({
|
||||
mCurrentPath: $mCurrentPath,
|
||||
mMenuLevel: $mMenuLevel,
|
||||
mType: $mType,
|
||||
mWorker: this.mWorker
|
||||
})
|
||||
}
|
||||
.padding({ left: 12 * 1.3, right: 12 * 1.3 })
|
||||
.width('100%')
|
||||
.height(globalThis.mainDialogHeight)
|
||||
.border({ radius: 24 })
|
||||
.backgroundColor('#F1F3F5')
|
||||
}
|
||||
.padding({ left: 12 * 1.3, right: 12 * 1.3 })
|
||||
.width('100%')
|
||||
.height(globalThis.mainDialogHeight)
|
||||
.border({ radius: 24 })
|
||||
.backgroundColor('#F1F3F5')
|
||||
}
|
||||
}
|
||||
|
||||
@Component
|
||||
struct TopBarArea {
|
||||
build() {
|
||||
Row() {
|
||||
Text('文件类型')
|
||||
.width(98 * 1.3)
|
||||
.height(33 * 1.3)
|
||||
.fontSize(24 * 1.3)
|
||||
.fontColor('#182431')
|
||||
.fontWeight(FontWeight.Medium)
|
||||
.margin({ left: 12 * 1.3 })
|
||||
build() {
|
||||
Row() {
|
||||
Text('文件类型')
|
||||
.width(98 * 1.3)
|
||||
.height(33 * 1.3)
|
||||
.fontSize(24 * 1.3)
|
||||
.fontColor('#182431')
|
||||
.fontWeight(FontWeight.Medium)
|
||||
.margin({ left: 12 * 1.3 })
|
||||
}
|
||||
.height(64 * 1.3)
|
||||
.width('100%')
|
||||
.border({ radius: 24 })
|
||||
.padding({ top: 8 * 1.3 })
|
||||
}
|
||||
.height(64 * 1.3)
|
||||
.width('100%')
|
||||
.border({ radius: 24 })
|
||||
.padding({ top: 8 * 1.3 })
|
||||
}
|
||||
}
|
||||
|
||||
@Component
|
||||
struct BottomBar {
|
||||
private TAG: string = 'BottomBar'
|
||||
private mWorker
|
||||
@State currentChoseFiles: Array<string> = []
|
||||
@Link mType: string
|
||||
@Link mMenuLevel: number
|
||||
@Link mCurrentPath: string
|
||||
@StorageLink('choseFiles') @Watch('choseFileChange') choseFiles: Array<FileInfo> = []
|
||||
private TAG: string = 'BottomBar'
|
||||
private mWorker
|
||||
@State currentChoseFiles: Array<string> = []
|
||||
@Link mType: string
|
||||
@Link mMenuLevel: number
|
||||
@Link mCurrentPath: string
|
||||
@StorageLink('choseFiles') @Watch('choseFileChange') choseFiles: Array<FileInfo> = []
|
||||
|
||||
aboutToAppear() {
|
||||
LogInfo(this.TAG, 'current choose file number = ' + this.currentChoseFiles.length)
|
||||
}
|
||||
|
||||
private choseFileChange() {
|
||||
this.currentChoseFiles = []
|
||||
let files: Array<FileInfo> = AppStorage.Get('choseFiles')
|
||||
files.forEach((item: FileInfo) => {
|
||||
this.currentChoseFiles.push(item.name)
|
||||
})
|
||||
LogInfo(this.TAG, 'current choose file number = ' + this.currentChoseFiles.length)
|
||||
}
|
||||
|
||||
build() {
|
||||
Row() {
|
||||
Button() {
|
||||
Text('取消')
|
||||
.width(110 * 1.3)
|
||||
.height(22 * 1.3)
|
||||
.fontSize(16 * 1.3)
|
||||
.fontWeight(FontWeight.Medium)
|
||||
.fontColor('#007DFF')
|
||||
.textAlign(TextAlign.Center)
|
||||
}
|
||||
.width(150 * 1.3)
|
||||
.height(40 * 1.3)
|
||||
.margin({ left: 12 * 1.3, top: 12 * 1.3, bottom: 24 * 1.3 })
|
||||
.backgroundColor('#E5E8EA')
|
||||
.onClick((event: ClickEvent) => {
|
||||
terminateSelfWithResult(terminate_reason.NO_ACTION, '')
|
||||
AppStorage.Set('choseFiles', [])
|
||||
})
|
||||
|
||||
if (globalThis.startMode == 'save') {
|
||||
Button() {
|
||||
Text($r("app.string.btn_upload"))
|
||||
.width(110 * 1.3)
|
||||
.height(22 * 1.3)
|
||||
.fontSize(16 * 1.3)
|
||||
.fontWeight(FontWeight.Medium)
|
||||
.fontColor('#007DFF')
|
||||
.textAlign(TextAlign.Center)
|
||||
.opacity(this.choseFiles.length != 0 ? 1 : 0.4)
|
||||
}
|
||||
.backgroundColor(this.choseFiles.length != 0 ? '#E5E8EA' : '#ECEEF0')
|
||||
.margin({
|
||||
left: 12 * 1.3,
|
||||
top: 12 * 1.3,
|
||||
bottom: 24 * 1.3
|
||||
})
|
||||
.height(40 * 1.3)
|
||||
.width(150 * 1.3)
|
||||
.stateEffect(this.mMenuLevel == menuLevel.MENU_FIRST_LEVEL_BY_TYPE ? false : true)
|
||||
.onClick((event: ClickEvent) => {
|
||||
this.mWorker.postMessage({
|
||||
request_data: 'createFile',
|
||||
device_name: 'local',
|
||||
menu_level: this.mMenuLevel,
|
||||
media_type: this.mType,
|
||||
path: this.mCurrentPath,
|
||||
save_name: globalThis.saveFile,
|
||||
})
|
||||
})
|
||||
} else {
|
||||
Button() {
|
||||
Text($r("app.string.btn_upload"))
|
||||
.width(110 * 1.3)
|
||||
.height(22 * 1.3)
|
||||
.fontSize(16 * 1.3)
|
||||
.fontWeight(FontWeight.Medium)
|
||||
.fontColor('#007DFF')
|
||||
.textAlign(TextAlign.Center)
|
||||
.opacity(this.choseFiles.length != 0 ? 1 : 0.4)
|
||||
}
|
||||
.backgroundColor(this.choseFiles.length != 0 ? '#E5E8EA' : '#ECEEF0')
|
||||
.stateEffect(this.choseFiles.length != 0)
|
||||
.margin({
|
||||
left: 12 * 1.3,
|
||||
top: 12 * 1.3,
|
||||
bottom: 24 * 1.3
|
||||
})
|
||||
.height(40 * 1.3)
|
||||
.width(150 * 1.3)
|
||||
.onClick(() => {
|
||||
let result: string = ''
|
||||
this.choseFiles.forEach((item: FileInfo) => {
|
||||
result += item.path + ';'
|
||||
})
|
||||
terminateSelfWithResult(terminate_reason.SUCCESS, result)
|
||||
AppStorage.Set('choseFiles', [])
|
||||
})
|
||||
}
|
||||
aboutToAppear() {
|
||||
logInfo(this.TAG, 'current choose file number = ' + this.currentChoseFiles.length)
|
||||
}
|
||||
|
||||
private choseFileChange() {
|
||||
this.currentChoseFiles = []
|
||||
let files: Array<FileInfo> = AppStorage.Get('choseFiles')
|
||||
files.forEach((item: FileInfo) => {
|
||||
this.currentChoseFiles.push(item.name)
|
||||
})
|
||||
logInfo(this.TAG, 'current choose file number = ' + this.currentChoseFiles.length)
|
||||
}
|
||||
|
||||
build() {
|
||||
Row() {
|
||||
Button() {
|
||||
Text('取消')
|
||||
.width(110 * 1.3)
|
||||
.height(22 * 1.3)
|
||||
.fontSize(16 * 1.3)
|
||||
.fontWeight(FontWeight.Medium)
|
||||
.fontColor('#007DFF')
|
||||
.textAlign(TextAlign.Center)
|
||||
}
|
||||
.width(150 * 1.3)
|
||||
.height(40 * 1.3)
|
||||
.margin({ left: 12 * 1.3, top: 12 * 1.3, bottom: 24 * 1.3 })
|
||||
.backgroundColor('#E5E8EA')
|
||||
.onClick((event: ClickEvent) => {
|
||||
terminateSelfWithResult(TerminateReason.NO_ACTION, '')
|
||||
AppStorage.Set('choseFiles', [])
|
||||
})
|
||||
|
||||
if (globalThis.startMode == 'save') {
|
||||
Button() {
|
||||
Text($r("app.string.btn_upload"))
|
||||
.width(110 * 1.3)
|
||||
.height(22 * 1.3)
|
||||
.fontSize(16 * 1.3)
|
||||
.fontWeight(FontWeight.Medium)
|
||||
.fontColor('#007DFF')
|
||||
.textAlign(TextAlign.Center)
|
||||
.opacity(this.choseFiles.length != 0 ? 1 : 0.4)
|
||||
}
|
||||
.backgroundColor(this.choseFiles.length != 0 ? '#E5E8EA' : '#ECEEF0')
|
||||
.margin({
|
||||
left: 12 * 1.3,
|
||||
top: 12 * 1.3,
|
||||
bottom: 24 * 1.3
|
||||
})
|
||||
.height(40 * 1.3)
|
||||
.width(150 * 1.3)
|
||||
.stateEffect(this.mMenuLevel == MenuLevel.MENU_FIRST_LEVEL_BY_TYPE ? false : true)
|
||||
.onClick((event: ClickEvent) => {
|
||||
this.mWorker.postMessage({
|
||||
request_data: 'createFile',
|
||||
device_name: 'local',
|
||||
menu_level: this.mMenuLevel,
|
||||
MediaType: this.mType,
|
||||
path: this.mCurrentPath,
|
||||
save_name: globalThis.saveFile,
|
||||
})
|
||||
})
|
||||
} else {
|
||||
Button() {
|
||||
Text($r("app.string.btn_upload"))
|
||||
.width(110 * 1.3)
|
||||
.height(22 * 1.3)
|
||||
.fontSize(16 * 1.3)
|
||||
.fontWeight(FontWeight.Medium)
|
||||
.fontColor('#007DFF')
|
||||
.textAlign(TextAlign.Center)
|
||||
.opacity(this.choseFiles.length != 0 ? 1 : 0.4)
|
||||
}
|
||||
.backgroundColor(this.choseFiles.length != 0 ? '#E5E8EA' : '#ECEEF0')
|
||||
.stateEffect(this.choseFiles.length != 0)
|
||||
.margin({
|
||||
left: 12 * 1.3,
|
||||
top: 12 * 1.3,
|
||||
bottom: 24 * 1.3
|
||||
})
|
||||
.height(40 * 1.3)
|
||||
.width(150 * 1.3)
|
||||
.onClick(() => {
|
||||
let result: string = ''
|
||||
this.choseFiles.forEach((item: FileInfo) => {
|
||||
result += item.path + ';'
|
||||
})
|
||||
terminateSelfWithResult(TerminateReason.SUCCESS, result)
|
||||
AppStorage.Set('choseFiles', [])
|
||||
})
|
||||
}
|
||||
}
|
||||
.height(76 * 1.3)
|
||||
.width('100%')
|
||||
.backgroundColor('#F1F3F5')
|
||||
}
|
||||
.height(76 * 1.3)
|
||||
.width('100%')
|
||||
.backgroundColor('#F1F3F5')
|
||||
}
|
||||
}
|
||||
@@ -13,14 +13,14 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { LogInfo, LogDebug } from '../module/LogUtils.ets'
|
||||
import worker from '@ohos.worker'
|
||||
import filemanager from '@ohos.filemanager'
|
||||
import worker from '@ohos.worker'
|
||||
import { logInfo, logDebug, logError } from '../../../../../../common/src/main/ets/components/utils/logutils'
|
||||
|
||||
var TAG = 'DataWorker'
|
||||
const parentPort = worker.parentPort
|
||||
parentPort.onmessage = function (e) {
|
||||
LogInfo(TAG, 'onMessage')
|
||||
logInfo(TAG, 'onMessage')
|
||||
let data = e.data
|
||||
if (data.request_data == 'getRoot') {
|
||||
getRootData(data)
|
||||
@@ -32,74 +32,55 @@ parentPort.onmessage = function (e) {
|
||||
}
|
||||
|
||||
parentPort.onmessageerror = function () {
|
||||
LogInfo(TAG, 'onmessageerror')
|
||||
logInfo(TAG, 'onmessageerror')
|
||||
}
|
||||
|
||||
parentPort.onerror = function (data) {
|
||||
LogInfo(TAG, 'onerror')
|
||||
logInfo(TAG, 'onerror')
|
||||
}
|
||||
|
||||
function getRootData(data) {
|
||||
// let options = {
|
||||
// "dev": {
|
||||
// "name": "external_storage"
|
||||
// }
|
||||
// }
|
||||
filemanager.getRoot()
|
||||
.then(file => {
|
||||
handleData(file, data)
|
||||
})
|
||||
.catch((error) => {
|
||||
LogDebug(TAG, 'getRoot 2 error' + error)
|
||||
});
|
||||
filemanager.getRoot().then(file => {
|
||||
handleData(file, data)
|
||||
}).catch((error) => {
|
||||
logError(TAG, 'getRoot 2 error' + error)
|
||||
});
|
||||
}
|
||||
|
||||
function getListFileData(data) {
|
||||
LogDebug(TAG, 'getListFileData 1')
|
||||
logDebug(TAG, 'getListFileData 1')
|
||||
if (data.offset == undefined || data.count == undefined) {
|
||||
LogDebug(TAG, 'path = ' + data.path + " type = " + data.media_type)
|
||||
|
||||
// let options = {
|
||||
// "dev": {
|
||||
// "name": "external_storage"
|
||||
// }
|
||||
// }
|
||||
filemanager.listFile(data.path, data.media_type)
|
||||
.then(file => {
|
||||
handleData(file, data)
|
||||
})
|
||||
.catch((error) => {
|
||||
LogDebug(TAG, 'getListFileData 2 error' + error)
|
||||
})
|
||||
logDebug(TAG, 'path = ' + data.path + " type = " + data.MediaType)
|
||||
filemanager.listFile(data.path, data.MediaType).then(file => {
|
||||
handleData(file, data)
|
||||
}).catch((error) => {
|
||||
logError(TAG, 'getListFileData 2 error' + error)
|
||||
})
|
||||
|
||||
} else {
|
||||
filemanager.listFile(data.path, data.media_type, {
|
||||
filemanager.listFile(data.path, data.MediaType, {
|
||||
'offset': data.offset,
|
||||
'count': data.count
|
||||
}).then(file => {
|
||||
handleData(file, data)
|
||||
}).catch((error) => {
|
||||
logError(TAG, 'getListFileData 3 error' + error)
|
||||
})
|
||||
.then(file => {
|
||||
handleData(file, data)
|
||||
})
|
||||
.catch((error) => {
|
||||
LogDebug(TAG, 'getListFileData 3 error' + error)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function createFile(data) {
|
||||
filemanager.createFile(data.path, data.save_name)
|
||||
.then((uri) => {
|
||||
handleData(uri, data)
|
||||
})
|
||||
.catch((err) => {
|
||||
handleData(err, data)
|
||||
})
|
||||
filemanager.createFile(data.path, data.save_name).then((uri) => {
|
||||
handleData(uri, data)
|
||||
}).catch((err) => {
|
||||
handleData(err, data)
|
||||
})
|
||||
}
|
||||
|
||||
function handleData(file, data) {
|
||||
LogInfo(TAG, 'handleData')
|
||||
logInfo(TAG, 'handleData')
|
||||
var info = JSON.stringify(file)
|
||||
LogInfo(TAG, 'info = ' + info.length)
|
||||
logInfo(TAG, 'info = ' + info.length)
|
||||
var buf = new ArrayBuffer(info.length * 2)
|
||||
var bufView = new Uint16Array(buf)
|
||||
for (var index = 0; index < info.length; index++) {
|
||||
|
||||
@@ -23,58 +23,6 @@
|
||||
{
|
||||
"name": "btn_save",
|
||||
"value": "save"
|
||||
},
|
||||
{
|
||||
"name": "file_unknown",
|
||||
"value": "Unknown file"
|
||||
},
|
||||
{
|
||||
"name": "save_file_has_same_file",
|
||||
"value": "Duplicate name file already exists"
|
||||
},
|
||||
{
|
||||
"name": "save_file_no_media_permission",
|
||||
"value": "Saving to media library is not currently supported"
|
||||
},
|
||||
{
|
||||
"name": "save_file_unknown_reason",
|
||||
"value": "Unknown error"
|
||||
},
|
||||
{
|
||||
"name": "file_zip",
|
||||
"value": "Compressed (zipped) file"
|
||||
},
|
||||
{
|
||||
"name": "file_xml",
|
||||
"value": "XML document"
|
||||
},
|
||||
{
|
||||
"name": "file_xls",
|
||||
"value": "Microsoft Excel worksheet"
|
||||
},
|
||||
{
|
||||
"name": "file_txt",
|
||||
"value": "Txt document"
|
||||
},
|
||||
{
|
||||
"name": "file_rar",
|
||||
"value": "Rar compressed file"
|
||||
},
|
||||
{
|
||||
"name": "file_pdf",
|
||||
"value": "Adobe Acrobat Document"
|
||||
},
|
||||
{
|
||||
"name": "file_html",
|
||||
"value": "HTML Document"
|
||||
},
|
||||
{
|
||||
"name": "file_pptx",
|
||||
"value": "Microsoft PowerPoint Presentation"
|
||||
},
|
||||
{
|
||||
"name": "file_docx",
|
||||
"value": "Microsoft Word Document"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -23,58 +23,6 @@
|
||||
{
|
||||
"name": "btn_save",
|
||||
"value": "保存"
|
||||
},
|
||||
{
|
||||
"name": "file_unknown",
|
||||
"value": "未知文件"
|
||||
},
|
||||
{
|
||||
"name": "save_file_has_same_file",
|
||||
"value": "已有重名文件"
|
||||
},
|
||||
{
|
||||
"name": "save_file_no_media_permission",
|
||||
"value": "当前不支持保存到媒体库"
|
||||
},
|
||||
{
|
||||
"name": "save_file_unknown_reason",
|
||||
"value": "未知错误"
|
||||
},
|
||||
{
|
||||
"name": "file_zip",
|
||||
"value": "压缩(zipped)文件"
|
||||
},
|
||||
{
|
||||
"name": "file_xml",
|
||||
"value": "XML文档"
|
||||
},
|
||||
{
|
||||
"name": "file_xls",
|
||||
"value": "Microsoft Excel工作表"
|
||||
},
|
||||
{
|
||||
"name": "file_txt",
|
||||
"value": "TXT文档"
|
||||
},
|
||||
{
|
||||
"name": "file_rar",
|
||||
"value": "RAR压缩文件"
|
||||
},
|
||||
{
|
||||
"name": "file_pdf",
|
||||
"value": "Adobe Acrobat Document"
|
||||
},
|
||||
{
|
||||
"name": "file_html",
|
||||
"value": "HTML网页文件"
|
||||
},
|
||||
{
|
||||
"name": "file_pptx",
|
||||
"value": "Microsoft PowerPoint演示文稿"
|
||||
},
|
||||
{
|
||||
"name": "file_docx",
|
||||
"value": "Microsoft Word文档"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,5 +1,11 @@
|
||||
{
|
||||
"name": "pad",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 1
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
"@ohos/common": {
|
||||
"version": "file:../../common"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,5 +10,7 @@
|
||||
"description": "example description",
|
||||
"repository": {},
|
||||
"version": "1.0.0",
|
||||
"dependencies": {}
|
||||
"dependencies": {
|
||||
"@ohos/common": "file:../../common"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,25 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import AbilityStage from "@ohos.application.AbilityStage"
|
||||
import { logInfo } from '../../../../../../common/src/main/ets/components/Utils/LogUtils'
|
||||
|
||||
const TAG = "MyAbilityStage"
|
||||
|
||||
export default class MyAbilityStage extends AbilityStage {
|
||||
onCreate() {
|
||||
console.log("[Demo] MyAbilityStage onCreate")
|
||||
logInfo(TAG, "onCreate")
|
||||
}
|
||||
}
|
||||
@@ -1,30 +1,42 @@
|
||||
import Ability from '@ohos.application.Ability'
|
||||
import display from '@ohos.display'
|
||||
import { Callback } from 'basic'
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
let displayWidth: number = 0
|
||||
let displayHeight: number = 0
|
||||
import Ability from '@ohos.application.Ability';
|
||||
import { Callback } from 'basic';
|
||||
import { logInfo, logError } from '../../../../../../common/src/main/ets/components/Utils/LogUtils';
|
||||
|
||||
const TAG: string = 'MainAbility'
|
||||
|
||||
export default class MainAbility extends Ability {
|
||||
onCreate(want, launchParam) {
|
||||
console.log("filePicker_MainAbility: onCreate")
|
||||
logInfo(TAG, "onCreate")
|
||||
globalThis.abilityWant = want;
|
||||
|
||||
globalThis.startMode = want.parameters.startMode
|
||||
globalThis.saveFile = want.parameters.saveFile
|
||||
globalThis.debugMode = want.parameters.debugMode
|
||||
console.log('filePicker_MainAbility: startMode = ' + globalThis.startMode)
|
||||
console.log('filePicker_MainAbility: file_name = ' + globalThis.saveFile)
|
||||
console.log('filePicker_MainAbility: debugMode = ' + globalThis.debugMode)
|
||||
logInfo(TAG, `parameters ${JSON.stringify(want.parameters)}`)
|
||||
}
|
||||
|
||||
onDestroy() {
|
||||
console.log("[Demo] MainAbility onDestroy")
|
||||
logInfo(TAG, "onDestroy")
|
||||
}
|
||||
|
||||
onWindowStageCreate(windowStage) {
|
||||
// Main window is created, set main page for this ability
|
||||
console.log("filePicker_MainAbility: onWindowStageCreate")
|
||||
logInfo(TAG, "onWindowStageCreate")
|
||||
|
||||
globalThis.context = this.context
|
||||
this.requestPermissions(() => this.displayWindow(windowStage))
|
||||
@@ -32,17 +44,17 @@ export default class MainAbility extends Ability {
|
||||
|
||||
onWindowStageDestroy() {
|
||||
// Main window is destroyed, release UI related resources
|
||||
console.log("[Demo] MainAbility onWindowStageDestroy")
|
||||
logInfo(TAG, "onWindowStageDestroy")
|
||||
}
|
||||
|
||||
onForeground() {
|
||||
// Ability has brought to foreground
|
||||
console.log("[Demo] MainAbility onForeground")
|
||||
logInfo(TAG, "onForeground")
|
||||
}
|
||||
|
||||
onBackground() {
|
||||
// Ability has back to background
|
||||
console.log("[Demo] MainAbility onBackground")
|
||||
logInfo(TAG, "onBackground")
|
||||
}
|
||||
|
||||
private requestPermissions(callback: Callback<void>) {
|
||||
@@ -52,35 +64,19 @@ export default class MainAbility extends Ability {
|
||||
"ohos.permission.WRITE_MEDIA"
|
||||
]
|
||||
globalThis.context.requestPermissionsFromUser(permissionList).then(function (data) {
|
||||
console.log('filePicker_MainAbility: request permission data result = ' + data.authResults)
|
||||
logInfo(TAG, `request permission data result = ${data.authResults}`)
|
||||
callback()
|
||||
}, (error) => {
|
||||
console.log('filePicker_MainAbility: fail to request permission error code = ' + error.code)
|
||||
logError(TAG, `fail to request permission error code = ${error.code}`)
|
||||
})
|
||||
}
|
||||
|
||||
private displayWindow(windowStage) {
|
||||
logInfo(TAG, "displayWindow()")
|
||||
windowStage.setUIContent(this.context, "pages/index", null)
|
||||
|
||||
display.getDefaultDisplay().then(dis => {
|
||||
displayWidth = dis.width
|
||||
displayHeight = dis.height
|
||||
})
|
||||
|
||||
windowStage.getMainWindow().then(win => {
|
||||
console.log("filePicker_MainAbility: windowStage.getMainWindow()")
|
||||
win.setWindowMode(102, (err, data) => {
|
||||
})
|
||||
|
||||
win.resetSize(vp2px(752), vp2px(446))
|
||||
|
||||
let positionX: number = (displayWidth - vp2px(752)) / 2
|
||||
let positionY: number = (displayHeight - vp2px(446)) / 2
|
||||
win.moveTo(positionX, positionY)
|
||||
|
||||
win.on('windowSizeChange', () => {
|
||||
win.resetSize(vp2px(752), vp2px(446))
|
||||
})
|
||||
logInfo(TAG, "windowStage.getMainWindow()")
|
||||
win.resetSize(vp2px(752), vp2px(450))
|
||||
})
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,91 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import display from '@ohos.display'
|
||||
import featureAbility from '@ohos.ability.featureAbility'
|
||||
import { LogInfo } from '../../../../../../common/LogUtils'
|
||||
import { DisplayInfo } from './DisplayInfo'
|
||||
|
||||
var TAG: string = 'AbilityUtils'
|
||||
|
||||
export function terminateSelfWithResult(resultCode: number, result: string): void {
|
||||
LogInfo(TAG, 'terminateSelfWithResult')
|
||||
let startMode: string = AppStorage.Get<string>('startMode')
|
||||
var abilityResult = {
|
||||
resultCode: resultCode,
|
||||
want: {
|
||||
parameters: {
|
||||
'startMode': startMode,
|
||||
'result': result
|
||||
}
|
||||
}
|
||||
}
|
||||
globalThis.context.terminateSelfWithResult(abilityResult, (error) => {
|
||||
if (error.code) {
|
||||
LogInfo(TAG, 'Operation failed. Cause: ' + JSON.stringify(error))
|
||||
return
|
||||
}
|
||||
LogInfo(TAG, 'Operation succeeded')
|
||||
})
|
||||
}
|
||||
|
||||
export function initData(): void {
|
||||
LogInfo(TAG, 'initData')
|
||||
initWindowScale()
|
||||
|
||||
getWantFromHap()
|
||||
}
|
||||
|
||||
function initWindowScale(): void {
|
||||
display.getDefaultDisplay().then(dis => {
|
||||
LogInfo(TAG, 'width = ' + dis.width + ';height= ' + dis.height)
|
||||
let displayInfo: DisplayInfo = new DisplayInfo()
|
||||
|
||||
if (dis.width > dis.height) { // 横屏
|
||||
displayInfo.width = dis.width
|
||||
displayInfo.height = dis.height * 0.7 // 需要减去信号栏和导航栏的高度
|
||||
displayInfo.mainDialogHeight = displayInfo.height - vp2px(64 + 76)
|
||||
displayInfo.mainDialogWidth = displayInfo.width
|
||||
|
||||
} else { // 竖屏
|
||||
displayInfo.width = dis.width
|
||||
displayInfo.height = dis.height * 0.7 // 需要减去信号栏和导航栏的高度
|
||||
displayInfo.mainDialogHeight = displayInfo.height - vp2px(64 + 76)
|
||||
displayInfo.mainDialogWidth = displayInfo.width
|
||||
}
|
||||
|
||||
LogInfo(TAG, 'mainDialogWidth = ' + displayInfo.mainDialogWidth)
|
||||
LogInfo(TAG, 'mainDialogHeight = ' + displayInfo.mainDialogHeight)
|
||||
AppStorage.SetOrCreate('displayInfo', displayInfo)
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
function getWantFromHap(): void {
|
||||
featureAbility.getWant()
|
||||
.then((Want) => {
|
||||
var mode: string = Want.parameters['startMode']
|
||||
if (mode == undefined) {
|
||||
AppStorage.SetOrCreate<string>('startMode', 'choose')
|
||||
} else {
|
||||
AppStorage.SetOrCreate<string>('startMode', mode)
|
||||
}
|
||||
let save_name: string = Want.parameters['file_name']
|
||||
AppStorage.Set<string>('saveName', save_name)
|
||||
LogInfo(TAG, 'saveName = ' + save_name)
|
||||
}).catch((error) => {
|
||||
LogInfo(TAG, 'fail Data: ' + JSON.stringify(error))
|
||||
})
|
||||
}
|
||||
@@ -1,102 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export enum menuLevel {
|
||||
MENU_FIRST_LEVEL_BY_TYPE = 1,
|
||||
MENU_SECOND_LEVEL_BY_FOLD = 2,
|
||||
MENU_THIRD_LEVEL_HAS_PIC = 3,
|
||||
MENU_THIRD_LEVEL_HAS_DETAIL = 4,
|
||||
}
|
||||
|
||||
export enum media_type {
|
||||
MEDIA_TYPE_FILE = 1,
|
||||
MEDIA_TYPE_IMAGE = 3,
|
||||
MEDIA_TYPE_VIDEO = 4,
|
||||
MEDIA_TYPE_AUDIO = 5,
|
||||
MEDIA_TYPE_ALBUM = 8
|
||||
}
|
||||
|
||||
export enum GridItemSize {
|
||||
GRID_ITEM_HEIGHT = 126,
|
||||
GRID_ITEM_WIDTH = 96,
|
||||
GRID_ITEM_COLUMNS_GAP = 8,
|
||||
GRID_ITEM_ROWS_GAP = 8,
|
||||
}
|
||||
|
||||
export enum terminate_reason {
|
||||
SUCCESS = 0,
|
||||
NO_ACTION = -1,
|
||||
}
|
||||
|
||||
export enum pad_size {
|
||||
MAIN_DIALOG_WIDTH = 752,
|
||||
MAIN_DIALOG_HEIGHT = 502,
|
||||
LEFT_DIALOG_WIDTH = 200,
|
||||
LEFT_DIALOG_HEIGHT = 332,
|
||||
RIGHT_DIALOG_WIDTH = 544,
|
||||
RIGHT_DIALOG_HEIGHT = 332,
|
||||
BOTTOM_WIDTH = 744,
|
||||
BOTTOM_HEIGHT = 120,
|
||||
|
||||
IC_PUBLIC_FOLDER_WIDTH = 24,
|
||||
IC_PUBLIC_FOLDER_HEIGHT = 24,
|
||||
ONE = 1,
|
||||
TWO = 2,
|
||||
FOUR = 4,
|
||||
EIGHT = 8,
|
||||
NINE = 9,
|
||||
TEN = 10,
|
||||
ELEVEN = 11,
|
||||
TWELVE = 12,
|
||||
FOURTEEN = 14,
|
||||
SIXTEEN = 16,
|
||||
SEVENTEEN = 17,
|
||||
EIGHTEEN = 18,
|
||||
NINETEEN = 19,
|
||||
TWENTY = 20,
|
||||
TWENTY_ONE = 21,
|
||||
TWENTY_TWO = 22,
|
||||
TWENTY_FOUR = 24,
|
||||
TWENTY_SEVEN = 27,
|
||||
TWENTY_NINE = 29,
|
||||
THIRTY = 30,
|
||||
THIRTY_TWO = 32,
|
||||
FORTY = 40,
|
||||
FORTY_SIX = 46,
|
||||
FIFTY_SIX = 56,
|
||||
SIXTY_FOUR = 64,
|
||||
EIGHTY = 80,
|
||||
EIGHTY_TWO = 82,
|
||||
EIGHTY_EIGHT = 88,
|
||||
NINETY_SIX = 96,
|
||||
ONE_HUNDRED_AND_FOUR = 104,
|
||||
ONE_HUNDRED_AND_THIRTY_FOUR = 134,
|
||||
ONE_HUNDRED_AND_SEVENTY_SIX = 176,
|
||||
ONE_HUNDRED_AND_SEVENTY_EIGHT = 178,
|
||||
TWO_HUNDRED_AND_SIXTY = 260,
|
||||
THREE_HUNDRED_AND_FORTY = 340,
|
||||
FOUR_HUNDRED = 400,
|
||||
FIVE_HUNDRED_AND_FOUR = 504,
|
||||
SIX_HUNDRED_AND_NINE = 609,
|
||||
SEVEN_HUNDRED_AND_FOURTEEN = 714,
|
||||
}
|
||||
|
||||
export enum mediaName {
|
||||
IMAGE = '图片',
|
||||
VIDEO = '视频',
|
||||
AUDIO = '音乐',
|
||||
DOCUMENT = '文档',
|
||||
FILE_TYPE = "文件类型"
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export enum PadSize {
|
||||
MAIN_DIALOG_WIDTH = 752,
|
||||
MAIN_DIALOG_HEIGHT = 502,
|
||||
LEFT_DIALOG_WIDTH = 200,
|
||||
LEFT_DIALOG_HEIGHT = 332,
|
||||
RIGHT_DIALOG_WIDTH = 544,
|
||||
RIGHT_DIALOG_HEIGHT = 332,
|
||||
GRID_WIDTH = 512,
|
||||
BOTTOM_WIDTH = 744,
|
||||
BOTTOM_HEIGHT = 120,
|
||||
|
||||
IC_PUBLIC_FOLDER_WIDTH = 24,
|
||||
IC_PUBLIC_FOLDER_HEIGHT = 24,
|
||||
ONE = 1,
|
||||
TWO = 2,
|
||||
FOUR = 4,
|
||||
EIGHT = 8,
|
||||
NINE = 9,
|
||||
TEN = 10,
|
||||
ELEVEN = 11,
|
||||
TWELVE = 12,
|
||||
FOURTEEN = 14,
|
||||
SIXTEEN = 16,
|
||||
SEVENTEEN = 17,
|
||||
EIGHTEEN = 18,
|
||||
NINETEEN = 19,
|
||||
TWENTY = 20,
|
||||
TWENTY_ONE = 21,
|
||||
TWENTY_TWO = 22,
|
||||
TWENTY_FOUR = 24,
|
||||
TWENTY_SEVEN = 27,
|
||||
TWENTY_NINE = 29,
|
||||
THIRTY = 30,
|
||||
THIRTY_TWO = 32,
|
||||
THIRTY_EIGHT = 38,
|
||||
FORTY = 40,
|
||||
FORTY_SIX = 46,
|
||||
FIFTY_SIX = 56,
|
||||
SIXTY_FOUR = 64,
|
||||
EIGHTY = 80,
|
||||
EIGHTY_TWO = 82,
|
||||
EIGHTY_EIGHT = 88,
|
||||
NINETY_SIX = 96,
|
||||
ONE_HUNDRED_AND_FOUR = 104,
|
||||
ONE_HUNDRED_AND_THIRTY_FOUR = 134,
|
||||
ONE_HUNDRED_AND_THIRTY_SIX = 136,
|
||||
ONE_HUNDRED_AND_SEVENTY_SIX = 176,
|
||||
ONE_HUNDRED_AND_SEVENTY_EIGHT = 178,
|
||||
TWO_HUNDRED_AND_SIXTY = 260,
|
||||
THREE_HUNDRED_AND_FORTY = 340,
|
||||
FOUR_HUNDRED = 400,
|
||||
FIVE_HUNDRED_AND_FOUR = 504,
|
||||
SIX_HUNDRED_AND_NINE = 609,
|
||||
SEVEN_HUNDRED_AND_FOURTEEN = 714,
|
||||
}
|
||||
@@ -1,121 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { FileInfo } from '../../../../../../feature/FileInfo'
|
||||
import { LogInfo } from '../../../../../../common/LogUtils'
|
||||
|
||||
let TAG: string = 'DialogUtils'
|
||||
|
||||
@CustomDialog
|
||||
export struct WarningDialog {
|
||||
@Link code: number
|
||||
controller: CustomDialogController
|
||||
cancel: () => void
|
||||
confirm: () => void
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
Text('Warning Title').fontSize(20).margin(10)
|
||||
if (this.code == 1) {
|
||||
Text($r("app.string.save_file_has_same_file")).fontSize(16).margin(10)
|
||||
} else if (this.code == 2) {
|
||||
Text($r("app.string.save_file_no_media_permission")).fontSize(16).margin(10)
|
||||
} else {
|
||||
Text($r("app.string.save_file_unknown_reason")).fontSize(16).margin(10)
|
||||
}
|
||||
Flex({ justifyContent: FlexAlign.SpaceAround }) {
|
||||
Button('cancel')
|
||||
.onClick(() => {
|
||||
this.controller.close()
|
||||
this.cancel()
|
||||
}).backgroundColor(0xffffff).fontColor(Color.Black)
|
||||
Button('confirm')
|
||||
.onClick(() => {
|
||||
this.controller.close()
|
||||
this.confirm()
|
||||
}).backgroundColor(0xffffff).fontColor(Color.Red)
|
||||
}.margin({ bottom: 10 })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@CustomDialog
|
||||
export struct ChooseDialog {
|
||||
controller: CustomDialogController
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
Row() {
|
||||
Text('选择该文件')
|
||||
}
|
||||
Row() {
|
||||
Button() {
|
||||
Text('取消')
|
||||
.height('100%')
|
||||
.fontSize(24)
|
||||
.fontColor(Color.Blue)
|
||||
}
|
||||
.width(px2vp(200))
|
||||
.height(px2vp(50))
|
||||
.backgroundColor(Color.White)
|
||||
.onClick(() => {
|
||||
this.controller.close()
|
||||
})
|
||||
|
||||
Divider()
|
||||
.vertical(true)
|
||||
.color(Color.Gray)
|
||||
.height(40)
|
||||
.margin({top: 0, right: 10, bottom: 0, left: 10})
|
||||
|
||||
Button() {
|
||||
Text('确定')
|
||||
.height('100%')
|
||||
.fontSize(24)
|
||||
.fontColor(Color.Blue)
|
||||
}
|
||||
.width(px2vp(200))
|
||||
.height(px2vp(50))
|
||||
.backgroundColor(Color.White)
|
||||
.onClick(() => {
|
||||
let choseItem: FileInfo = AppStorage.Get<FileInfo>('selectedFileInfo')
|
||||
if (choseItem != null) {
|
||||
let files: Array<FileInfo> = AppStorage.Get('choseFiles')
|
||||
let flag: boolean = true
|
||||
files.forEach((item: FileInfo) => {
|
||||
LogInfo(TAG, 'item.name = ' + item.name + '; item.path = ' + item.path)
|
||||
LogInfo(TAG, 'choseItem.name = ' + choseItem.name + '; choseItem.path = ' + choseItem.path)
|
||||
if (item.name == choseItem.name && item.path == choseItem.path) {
|
||||
flag = false
|
||||
}
|
||||
})
|
||||
if (flag) {
|
||||
files.push(choseItem)
|
||||
AppStorage.Set('choseFiles', files)
|
||||
}
|
||||
}
|
||||
this.controller.close()
|
||||
})
|
||||
}
|
||||
.padding(20)
|
||||
}
|
||||
.padding({
|
||||
top: 25,
|
||||
right: 0,
|
||||
bottom: 15,
|
||||
left: 0
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { media_type } from './Constants.ets'
|
||||
|
||||
export class FileInfo {
|
||||
name: string
|
||||
path: string
|
||||
type: number= media_type.MEDIA_TYPE_ALBUM
|
||||
size: string
|
||||
dataAdded_time: string
|
||||
modified_time: string
|
||||
mediaType: string
|
||||
thumbnail: Resource
|
||||
font_color: Color | string | Resource
|
||||
opacity: number
|
||||
list_background: string | Resource
|
||||
|
||||
constructor(name: string) {
|
||||
this.name = name
|
||||
}
|
||||
}
|
||||
|
||||
export class TopPathInfo {
|
||||
name: string
|
||||
path: string
|
||||
opacity: number = 1
|
||||
|
||||
constructor(name: string, path: string) {
|
||||
this.name = name
|
||||
this.path = path
|
||||
}
|
||||
}
|
||||
@@ -1,341 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { media_type } from './Constants';
|
||||
import { FileInfo } from '../../../../../../feature/FileInfo'
|
||||
import { LogInfo } from '../../../../../../common/LogUtils'
|
||||
|
||||
var TAG = 'FileManagerServiceUtils'
|
||||
var isDebug: boolean = true;
|
||||
|
||||
export function getFirstMenu(deviceName: string): Array<FileInfo> {
|
||||
let fileList: Array<FileInfo> = [];
|
||||
if (isDebug) {
|
||||
let file1: FileInfo = new FileInfo('image_album');
|
||||
file1.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
file1.path = 'dataability:///album';
|
||||
file1.size = '';
|
||||
file1.dataAdded_time = 'xxx';
|
||||
file1.modified_time = 'xxx';
|
||||
fileList.push(file1);
|
||||
|
||||
let file2: FileInfo = new FileInfo('video_album');
|
||||
file2.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
file2.path = 'dataability:///album';
|
||||
file2.size = '';
|
||||
file2.dataAdded_time = 'xxx';
|
||||
file2.modified_time = 'xxx';
|
||||
fileList.push(file2);
|
||||
|
||||
let file4: FileInfo = new FileInfo('file_folder');
|
||||
file4.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
file4.path = 'dataability:///album';
|
||||
file4.size = '';
|
||||
file4.dataAdded_time = 'xxx';
|
||||
file4.modified_time = 'xxx';
|
||||
fileList.push(file4);
|
||||
|
||||
let file3: FileInfo = new FileInfo('audio_album');
|
||||
file3.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
file3.path = 'dataability:///album';
|
||||
file3.size = '';
|
||||
file3.dataAdded_time = 'xxx';
|
||||
file3.modified_time = 'xxx';
|
||||
fileList.push(file3);
|
||||
} else {
|
||||
// var fileInfo = filemanager.getRoot(deviceName);
|
||||
}
|
||||
|
||||
fileList.forEach(item => {
|
||||
if (item.name == 'image_album') {
|
||||
item.name = "图片";
|
||||
item.mediaType = 'image';
|
||||
item.thumbnail = $r("app.media.ic_type_image")
|
||||
} else if (item.name == 'video_album') {
|
||||
item.name = "视频";
|
||||
item.mediaType = 'video';
|
||||
item.thumbnail = $r("app.media.ic_type_video")
|
||||
} else if (item.name == 'audio_album') {
|
||||
item.name = "音乐";
|
||||
item.mediaType = 'audio';
|
||||
item.thumbnail = $r("app.media.ic_type_audio")
|
||||
} else if (item.name == 'file_folder') {
|
||||
item.name = "文档";
|
||||
item.mediaType = 'file';
|
||||
item.thumbnail = $r("app.media.ic_public_file")
|
||||
}
|
||||
});
|
||||
|
||||
return fileList;
|
||||
}
|
||||
|
||||
export function getListFile(deviceName: string, mediaType: string, path: string): Array<FileInfo> {
|
||||
LogInfo(TAG, "getListFile mediaType = " + mediaType + ';path = ' + path);
|
||||
let fileList: Array<FileInfo> = [];
|
||||
if (isDebug) {
|
||||
if (path == 'dataability:///album') {
|
||||
if (mediaType == 'image') {
|
||||
let fileInfo1: FileInfo = new FileInfo("微信的图片");
|
||||
fileInfo1.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
fileInfo1.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/01';
|
||||
fileInfo1.dataAdded_time = 'xxx';
|
||||
fileInfo1.modified_time = 'xxx';
|
||||
fileList.push(fileInfo1);
|
||||
let fileInfo2: FileInfo = new FileInfo("图片1");
|
||||
fileInfo2.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
fileInfo2.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/02';
|
||||
fileInfo2.dataAdded_time = 'xxx';
|
||||
fileInfo2.modified_time = 'xxx';
|
||||
fileList.push(fileInfo2);
|
||||
let fileInfo3: FileInfo = new FileInfo("图片2");
|
||||
fileInfo3.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
fileInfo3.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/03';
|
||||
fileInfo3.dataAdded_time = 'xxx';
|
||||
fileInfo3.modified_time = 'xxx';
|
||||
fileList.push(fileInfo3);
|
||||
let fileInfo4: FileInfo = new FileInfo("图片3");
|
||||
fileInfo4.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
fileInfo4.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/04';
|
||||
fileInfo4.dataAdded_time = 'xxx';
|
||||
fileInfo4.modified_time = 'xxx';
|
||||
fileList.push(fileInfo4);
|
||||
let fileInfo5: FileInfo = new FileInfo("图片4");
|
||||
fileInfo5.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
fileInfo5.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/05';
|
||||
fileInfo5.dataAdded_time = 'xxx';
|
||||
fileInfo5.modified_time = 'xxx';
|
||||
fileList.push(fileInfo5);
|
||||
let fileInfo6: FileInfo = new FileInfo("图片5");
|
||||
fileInfo6.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
fileInfo6.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/06';
|
||||
fileInfo6.dataAdded_time = 'xxx';
|
||||
fileInfo6.modified_time = 'xxx';
|
||||
fileList.push(fileInfo6);
|
||||
let fileInfo7: FileInfo = new FileInfo("图片6");
|
||||
fileInfo7.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
fileInfo7.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/07';
|
||||
fileInfo7.dataAdded_time = 'xxx';
|
||||
fileInfo7.modified_time = 'xxx';
|
||||
fileList.push(fileInfo7);
|
||||
let fileInfo8: FileInfo = new FileInfo("图片7");
|
||||
fileInfo8.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
fileInfo8.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/08';
|
||||
fileInfo8.dataAdded_time = 'xxx';
|
||||
fileInfo8.modified_time = 'xxx';
|
||||
fileList.push(fileInfo8);
|
||||
let fileInfo9: FileInfo = new FileInfo("图片8");
|
||||
fileInfo1.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
fileInfo1.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/09';
|
||||
fileInfo1.dataAdded_time = 'xxx';
|
||||
fileInfo1.modified_time = 'xxx';
|
||||
fileList.push(fileInfo9);
|
||||
let fileInfo10: FileInfo = new FileInfo("图片9");
|
||||
fileInfo10.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
fileInfo10.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/10';
|
||||
fileInfo10.dataAdded_time = 'xxx';
|
||||
fileInfo10.modified_time = 'xxx';
|
||||
fileList.push(fileInfo10);
|
||||
let fileInfo11: FileInfo = new FileInfo("图片10");
|
||||
fileInfo11.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
fileInfo11.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/11';
|
||||
fileInfo11.dataAdded_time = 'xxx';
|
||||
fileInfo11.modified_time = 'xxx';
|
||||
fileList.push(fileInfo11);
|
||||
} else if (mediaType == 'video') {
|
||||
let fileInfo1: FileInfo = new FileInfo("视频0");
|
||||
fileInfo1.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
fileInfo1.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/12';
|
||||
fileInfo1.dataAdded_time = 'xxx';
|
||||
fileInfo1.modified_time = 'xxx';
|
||||
fileList.push(fileInfo1);
|
||||
let fileInfo2: FileInfo = new FileInfo("视频1");
|
||||
fileInfo2.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
fileInfo2.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/13';
|
||||
fileInfo2.dataAdded_time = 'xxx';
|
||||
fileInfo2.modified_time = 'xxx';
|
||||
fileList.push(fileInfo2);
|
||||
let fileInfo3: FileInfo = new FileInfo("视频2");
|
||||
fileInfo3.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
fileInfo3.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/14';
|
||||
fileInfo3.dataAdded_time = 'xxx';
|
||||
fileInfo3.modified_time = 'xxx';
|
||||
fileList.push(fileInfo3);
|
||||
let fileInfo4: FileInfo = new FileInfo("视频3");
|
||||
fileInfo4.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
fileInfo4.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/15';
|
||||
fileInfo4.dataAdded_time = 'xxx';
|
||||
fileInfo4.modified_time = 'xxx';
|
||||
fileList.push(fileInfo4);
|
||||
let fileInfo5: FileInfo = new FileInfo("视频4");
|
||||
fileInfo5.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
fileInfo5.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/16';
|
||||
fileInfo5.dataAdded_time = 'xxx';
|
||||
fileInfo5.modified_time = 'xxx';
|
||||
fileList.push(fileInfo5);
|
||||
} else if (mediaType == 'audio') {
|
||||
let fileInfo1: FileInfo = new FileInfo("音频0");
|
||||
fileInfo1.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
fileInfo1.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/17';
|
||||
fileInfo1.dataAdded_time = 'xxx';
|
||||
fileInfo1.modified_time = 'xxx';
|
||||
fileList.push(fileInfo1);
|
||||
let fileInfo2: FileInfo = new FileInfo("音频1");
|
||||
fileInfo2.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
fileInfo2.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/18';
|
||||
fileInfo2.dataAdded_time = 'xxx';
|
||||
fileInfo2.modified_time = 'xxx';
|
||||
fileList.push(fileInfo2);
|
||||
let fileInfo3: FileInfo = new FileInfo("音频2");
|
||||
fileInfo3.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
fileInfo3.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/19';
|
||||
fileInfo3.dataAdded_time = 'xxx';
|
||||
fileInfo3.modified_time = 'xxx';
|
||||
fileList.push(fileInfo3);
|
||||
let fileInfo4: FileInfo = new FileInfo("音频3");
|
||||
fileInfo4.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
fileInfo4.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/20';
|
||||
fileInfo4.dataAdded_time = 'xxx';
|
||||
fileInfo4.modified_time = 'xxx';
|
||||
fileList.push(fileInfo4);
|
||||
let fileInfo5: FileInfo = new FileInfo("音频4");
|
||||
fileInfo5.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
fileInfo5.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/21';
|
||||
fileInfo5.dataAdded_time = 'xxx';
|
||||
fileInfo5.modified_time = 'xxx';
|
||||
fileList.push(fileInfo5);
|
||||
} else if (mediaType == 'file') {
|
||||
let fileInfo1: FileInfo = new FileInfo("文件夹0");
|
||||
fileInfo1.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
fileInfo1.mediaType = mediaType;
|
||||
fileInfo1.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/22';
|
||||
fileInfo1.dataAdded_time = 'xxx';
|
||||
fileInfo1.modified_time = 'xxx';
|
||||
fileList.push(fileInfo1);
|
||||
let fileInfo2: FileInfo = new FileInfo("文件夹1");
|
||||
fileInfo2.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
fileInfo2.mediaType = mediaType;
|
||||
fileInfo2.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/23';
|
||||
fileInfo2.dataAdded_time = 'xxx';
|
||||
fileInfo2.modified_time = 'xxx';
|
||||
fileList.push(fileInfo2);
|
||||
let fileInfo3: FileInfo = new FileInfo("文件夹2");
|
||||
fileInfo3.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
fileInfo3.mediaType = mediaType;
|
||||
fileInfo3.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/24';
|
||||
fileInfo3.dataAdded_time = 'xxx';
|
||||
fileInfo3.modified_time = 'xxx';
|
||||
fileList.push(fileInfo3);
|
||||
let fileInfo4: FileInfo = new FileInfo("文件夹3");
|
||||
fileInfo4.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
fileInfo4.mediaType = mediaType;
|
||||
fileInfo4.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/25';
|
||||
fileInfo4.dataAdded_time = 'xxx';
|
||||
fileInfo4.modified_time = 'xxx';
|
||||
fileList.push(fileInfo4);
|
||||
let fileInfo5: FileInfo = new FileInfo("文件夹4");
|
||||
fileInfo5.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
fileInfo5.mediaType = mediaType;
|
||||
fileInfo5.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/26';
|
||||
fileInfo5.dataAdded_time = 'xxx';
|
||||
fileInfo5.modified_time = 'xxx';
|
||||
fileList.push(fileInfo5);
|
||||
let fileInfo6: FileInfo = new FileInfo("文本文档.txt");
|
||||
fileInfo6.type = media_type.MEDIA_TYPE_FILE;
|
||||
fileInfo6.mediaType = mediaType;
|
||||
fileInfo6.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/27';
|
||||
fileInfo6.dataAdded_time = 'xxx';
|
||||
fileInfo6.modified_time = 'xxx';
|
||||
fileInfo6.size = '1,024 KB'
|
||||
fileList.push(fileInfo6);
|
||||
let fileInfo7: FileInfo = new FileInfo("验收文稿.ppt");
|
||||
fileInfo7.type = media_type.MEDIA_TYPE_FILE;
|
||||
fileInfo7.mediaType = mediaType;
|
||||
fileInfo7.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/28';
|
||||
fileInfo7.dataAdded_time = 'xxx';
|
||||
fileInfo7.modified_time = 'xxx';
|
||||
fileInfo7.size = '4,562,000 KB'
|
||||
fileList.push(fileInfo7);
|
||||
}
|
||||
} else {
|
||||
if (mediaType == 'image') {
|
||||
for (var index = 0; index < 10; index++) {
|
||||
let file: FileInfo = new FileInfo("" + index + ".png");
|
||||
file.type = media_type.MEDIA_TYPE_IMAGE;
|
||||
file.path = path + index;
|
||||
file.dataAdded_time = 'xxx';
|
||||
file.modified_time = 'xxx';
|
||||
fileList.push(file);
|
||||
}
|
||||
} else if (mediaType == 'video') {
|
||||
for (var index = 0; index < 15; index++) {
|
||||
let file: FileInfo = new FileInfo("" + index + ".wmv");
|
||||
file.type = media_type.MEDIA_TYPE_VIDEO;
|
||||
file.path = path + index;
|
||||
file.dataAdded_time = 'xxx';
|
||||
file.modified_time = 'xxx';
|
||||
fileList.push(file);
|
||||
}
|
||||
} else if (mediaType == 'audio') {
|
||||
for (var index = 0; index < 18; index++) {
|
||||
let file: FileInfo = new FileInfo("" + index + ".mp3");
|
||||
file.type = media_type.MEDIA_TYPE_AUDIO;
|
||||
file.path = path + index;
|
||||
file.dataAdded_time = 'xxx';
|
||||
file.modified_time = 'xxx';
|
||||
fileList.push(file);
|
||||
}
|
||||
} else if (mediaType == 'file') {
|
||||
let fileInfo4: FileInfo = new FileInfo("文件夹3");
|
||||
fileInfo4.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
fileInfo4.path = path + '5';
|
||||
fileInfo4.dataAdded_time = 'xxx';
|
||||
fileInfo4.modified_time = 'xxx';
|
||||
fileList.push(fileInfo4);
|
||||
let fileInfo5: FileInfo = new FileInfo("文件夹4");
|
||||
fileInfo5.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
fileInfo5.path = path + '6';
|
||||
fileInfo5.dataAdded_time = 'xxx';
|
||||
fileInfo5.modified_time = 'xxx';
|
||||
fileList.push(fileInfo5);
|
||||
let fileInfo6: FileInfo = new FileInfo("文本文档.txt");
|
||||
fileInfo6.type = media_type.MEDIA_TYPE_FILE;
|
||||
fileInfo6.path = path + '7';
|
||||
fileInfo6.size = '1,000 KB'
|
||||
fileInfo6.dataAdded_time = 'xxx';
|
||||
fileInfo6.modified_time = 'xxx';
|
||||
fileList.push(fileInfo6);
|
||||
let fileInfo7: FileInfo = new FileInfo("验收文稿.ppt");
|
||||
fileInfo7.type = media_type.MEDIA_TYPE_FILE;
|
||||
fileInfo7.path = path + '8';
|
||||
fileInfo7.size = '520,000 KB'
|
||||
fileInfo7.dataAdded_time = 'xxx';
|
||||
fileInfo7.modified_time = 'xxx';
|
||||
fileList.push(fileInfo7);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// fileList = filemanager.listfile(deviceName, mediaType, path);
|
||||
}
|
||||
LogInfo(TAG, "get file list is " + fileList.length)
|
||||
return fileList;
|
||||
}
|
||||
|
||||
//保存某个文件,返回是否保存成功,或有错误提示,还需要增加三方应用包名
|
||||
export function saveFile(deviceName: string, name: string, path: string): boolean {
|
||||
LogInfo(TAG, 'saveFile');
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
@@ -1,128 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import resourceManager from '@ohos.resourceManager';
|
||||
import { TopPathInfo } from '../module/FileInfo'
|
||||
import { LogInfo } from '../../../../../../common/LogUtils'
|
||||
import { mediaName } from './Constants'
|
||||
|
||||
var TAG: string = 'Utils'
|
||||
|
||||
export function getRootPath(): Array<TopPathInfo> {
|
||||
var root_path: Array<TopPathInfo> = []
|
||||
root_path.push(new TopPathInfo('文件类型', ''))
|
||||
return root_path
|
||||
}
|
||||
|
||||
var strTypeArr = [
|
||||
['image', '图片'],
|
||||
['video', '视频'],
|
||||
['audio', '音频'],
|
||||
['file', '文档'],
|
||||
]
|
||||
|
||||
export function changeTypeToString(type: string): string {
|
||||
LogInfo(TAG, 'changeTypeToString type = ' + type)
|
||||
for (var i = 0; i < strTypeArr.length; i++) {
|
||||
if (strTypeArr[i][0] == type) {
|
||||
return strTypeArr[i][1]
|
||||
}
|
||||
}
|
||||
return ''
|
||||
}
|
||||
|
||||
export function changeStringToType(type: string): string {
|
||||
LogInfo(TAG, 'changeStringToType type = ' + type)
|
||||
for (var i = 0; i < strTypeArr.length; i++) {
|
||||
if (strTypeArr[i][1] == type) {
|
||||
return strTypeArr[i][0]
|
||||
}
|
||||
}
|
||||
return ''
|
||||
}
|
||||
|
||||
export function getItemNumberInGrid(itemWidth: number, itemGap: number, parentWidth: number): string {
|
||||
LogInfo(TAG, 'getItemNumberInGrid')
|
||||
let columnTemples: string = ''
|
||||
let remainderWidth: number = parentWidth - itemWidth
|
||||
columnTemples += '1fr'
|
||||
while (itemWidth + itemGap < remainderWidth) {
|
||||
remainderWidth = remainderWidth - (itemWidth + itemGap)
|
||||
columnTemples += ' 1fr'
|
||||
}
|
||||
LogInfo(TAG, 'columnTemples = ' + columnTemples)
|
||||
return columnTemples
|
||||
}
|
||||
|
||||
var fileSuffixAndType = [
|
||||
['.doc', $r("app.media.ic_file_doc"), $r("app.string.file_docx")],
|
||||
['.html', $r("app.media.ic_file_html"), $r("app.string.file_html")],
|
||||
['.pdf', $r("app.media.ic_file_pdf"), $r("app.string.file_pdf")],
|
||||
['.pptx', $r("app.media.ic_file_pptx"), $r("app.string.file_pptx")],
|
||||
['.ppt', $r("app.media.ic_file_pptx"), $r("app.string.file_pptx")],
|
||||
['.rar', $r("app.media.ic_file_rar"), $r("app.string.file_rar")],
|
||||
['.txt', $r("app.media.ic_file_txt"), $r("app.string.file_txt")],
|
||||
['.xls', $r("app.media.ic_file_xls"), $r("app.string.file_xls")],
|
||||
['.xml', $r("app.media.ic_file_xml"), $r("app.string.file_xml")],
|
||||
['.zip', $r("app.media.ic_file_zip"), $r("app.string.file_zip")],
|
||||
]
|
||||
|
||||
export function getShowIconBySuffix(suffix: string): string | Resource {
|
||||
LogInfo(TAG, 'getShowIconBySuffix suffix = ' + suffix)
|
||||
for (var i = 0; i < fileSuffixAndType.length; i++) {
|
||||
if (isTwoStringEqual(fileSuffixAndType[i][0].toString(),suffix)) {
|
||||
return fileSuffixAndType[i][1]
|
||||
}
|
||||
}
|
||||
return $r("app.media.ic_file_unknown")
|
||||
}
|
||||
|
||||
export function getShowTextBySuffix(suffix: string): string | Resource {
|
||||
LogInfo(TAG, 'getShowTextBySuffix suffix = ' + suffix)
|
||||
for (var i = 0; i < fileSuffixAndType.length; i++) {
|
||||
if (fileSuffixAndType[i][0] == suffix) {
|
||||
return fileSuffixAndType[i][2]
|
||||
}
|
||||
}
|
||||
return $r("app.string.file_unknown")
|
||||
}
|
||||
|
||||
export function getWarningDialogMessage(code: number): string | Resource {
|
||||
switch (code) {
|
||||
case 1:
|
||||
return $r("app.string.save_file_has_same_file")
|
||||
case 2:
|
||||
return $r("app.string.save_file_no_media_permission")
|
||||
default:
|
||||
return $r("app.string.save_file_unknown_reason")
|
||||
}
|
||||
}
|
||||
|
||||
export function isTwoStringEqual(src: string, tar: string) {
|
||||
if (src.indexOf(tar) == 0 && tar.indexOf(src) == 0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export function updateTopPathInfo(currentPathInfo: Array<TopPathInfo>, name: string, path: string) {
|
||||
currentPathInfo.forEach((item: TopPathInfo) => {
|
||||
item.opacity = 0.4
|
||||
})
|
||||
|
||||
currentPathInfo.push(new TopPathInfo(name, path))
|
||||
AppStorage.Set('topPathInfo', currentPathInfo)
|
||||
return currentPathInfo
|
||||
}
|
||||
@@ -13,97 +13,64 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { DisplayInfo } from '../module/DisplayInfo'
|
||||
import { menuLevel, pad_size } from '../module/Constants'
|
||||
import { FileInfo } from '../../../../../../feature/FileInfo'
|
||||
import { LogInfo } from '../../../../../../common/LogUtils'
|
||||
import { PadSize } from '../module/Constants'
|
||||
import { MenuLevel } from '../../../../../../common/src/main/ets/components/Data/Constants'
|
||||
import { FileInfo } from '../../../../../../common/src/main/ets/components/Data/FileInfo'
|
||||
import { logInfo } from '../../../../../../common/src/main/ets/components/Utils/LogUtils'
|
||||
|
||||
@Component
|
||||
export struct FirstLevelByType {
|
||||
private TAG: string = 'FirstLevelByType'
|
||||
private mWorker
|
||||
private mFileList: FileInfo[]
|
||||
private displayInfo: DisplayInfo = new DisplayInfo()
|
||||
private TAG: string = 'FirstLevelByType'
|
||||
private mWorker
|
||||
private mFileList: FileInfo[]
|
||||
@Link mType: string
|
||||
@Link mMenuLevel: number
|
||||
@Link mCurrentPath: string
|
||||
|
||||
@Link mType: string
|
||||
@Link mMenuLevel: number
|
||||
@Link mCurrentPath: string
|
||||
aboutToAppear() {
|
||||
logInfo(this.TAG, 'aboutToAppear mType = ' + this.mType)
|
||||
logInfo(this.TAG, 'aboutToAppear mCurrentPath = ' + this.mCurrentPath)
|
||||
}
|
||||
|
||||
aboutToAppear() {
|
||||
LogInfo(this.TAG, 'aboutToAppear mType = ' + this.mType)
|
||||
LogInfo(this.TAG, 'aboutToAppear mCurrentPath = ' + this.mCurrentPath)
|
||||
this.displayInfo = AppStorage.Get('displayInfo')
|
||||
}
|
||||
|
||||
build() {
|
||||
Grid() {
|
||||
ForEach(this.mFileList, (item: FileInfo) => {
|
||||
GridItem() {
|
||||
Column() {
|
||||
Image($r("app.media.ic_public_big_folder"))
|
||||
.width(pad_size.EIGHTY)
|
||||
.height(pad_size.EIGHTY)
|
||||
.margin({ left: pad_size.TWELVE, top: pad_size.FOUR, right: pad_size.TWELVE })
|
||||
Text(item.name)
|
||||
.width(pad_size.EIGHTY_EIGHT)
|
||||
.fontSize(pad_size.FOURTEEN)
|
||||
.fontWeight(FontWeight.Regular)
|
||||
.fontColor('#000000')
|
||||
.textAlign(TextAlign.Center)
|
||||
.margin({ top: pad_size.FOUR, bottom: pad_size.TWENTY_SEVEN })
|
||||
}
|
||||
.width(pad_size.ONE_HUNDRED_AND_FOUR)
|
||||
.height(pad_size.ONE_HUNDRED_AND_THIRTY_FOUR)
|
||||
.alignItems(HorizontalAlign.Center)
|
||||
.onClick(() => {
|
||||
this.mType = item.mediaType
|
||||
this.mCurrentPath = item.path
|
||||
this.mMenuLevel = menuLevel.MENU_SECOND_LEVEL_BY_FOLD
|
||||
})
|
||||
build() {
|
||||
Grid() {
|
||||
ForEach(this.mFileList, (item: FileInfo) => {
|
||||
GridItem() {
|
||||
Column() {
|
||||
Image($r("app.media.ic_public_big_folder"))
|
||||
.width(PadSize.EIGHTY)
|
||||
.height(PadSize.EIGHTY)
|
||||
.margin({
|
||||
left: PadSize.TWELVE,
|
||||
right: PadSize.TWELVE,
|
||||
top: PadSize.FOUR,
|
||||
bottom: PadSize.TWO
|
||||
})
|
||||
Text(item.name)
|
||||
.width(PadSize.EIGHTY_EIGHT)
|
||||
.fontSize(PadSize.FOURTEEN)
|
||||
.fontWeight(FontWeight.Regular)
|
||||
.fontColor('#000000')
|
||||
.textAlign(TextAlign.Center)
|
||||
.padding(PadSize.FOUR)
|
||||
.margin({ left: PadSize.FOUR, right: PadSize.FOUR, bottom: PadSize.FOUR })
|
||||
}
|
||||
.width(PadSize.ONE_HUNDRED_AND_FOUR)
|
||||
.height(PadSize.ONE_HUNDRED_AND_THIRTY_SIX)
|
||||
.margin({ left: PadSize.SIXTEEN, right: PadSize.EIGHT, bottom: PadSize.TWENTY })
|
||||
.alignItems(HorizontalAlign.Center)
|
||||
.onClick(() => {
|
||||
this.mType = item.mediaType
|
||||
this.mCurrentPath = item.path
|
||||
this.mMenuLevel = MenuLevel.MENU_SECOND_LEVEL_BY_FOLD
|
||||
})
|
||||
}
|
||||
}, item => item.name)
|
||||
}
|
||||
}, item => item.name)
|
||||
.width(PadSize.GRID_WIDTH)
|
||||
.columnsTemplate('1fr 1fr 1fr 1fr')
|
||||
.columnsGap(1)
|
||||
.rowsGap(1)
|
||||
.margin({ top: PadSize.SIXTEEN })
|
||||
}
|
||||
.columnsTemplate('1fr 1fr 1fr 1fr')
|
||||
.columnsGap(1)
|
||||
.rowsGap(1)
|
||||
.margin({ top: pad_size.SIXTEEN })
|
||||
}
|
||||
}
|
||||
|
||||
@Component
|
||||
struct RowView {
|
||||
private item: FileInfo = new FileInfo('')
|
||||
private displayInfo: DisplayInfo = AppStorage.Get('displayInfo')
|
||||
|
||||
@Link mMenuLevel: number
|
||||
@Link mType: string
|
||||
@Link mCurrentPath: string
|
||||
|
||||
build() {
|
||||
Row() {
|
||||
Image($r("app.media.ic_file_manager"))
|
||||
.width(22 * 2)
|
||||
.height(19 * 2)
|
||||
.margin({ left: 12 })
|
||||
Text(this.item.name)
|
||||
.fontSize(16 * 2)
|
||||
.fontColor('#182431')
|
||||
.fontWeight(FontWeight.Medium)
|
||||
.margin({ left: 16 })
|
||||
Blank()
|
||||
Image($r("app.media.ic_right"))
|
||||
.width(12 * 2)
|
||||
.height(24 * 2)
|
||||
.margin({ right: 24 * 2 })
|
||||
}
|
||||
.height(56)
|
||||
.width(this.displayInfo.mainDialogWidth) // TODO
|
||||
.margin({ top: '16vp', bottom: '16vp' })
|
||||
.backgroundColor(this.item.list_background)
|
||||
.onClick(() => {
|
||||
this.mType = this.item.mediaType
|
||||
this.mCurrentPath = this.item.path
|
||||
this.mMenuLevel = menuLevel.MENU_SECOND_LEVEL_BY_FOLD
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -13,156 +13,109 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { FileInfo, TopPathInfo } from '../../../../../../feature/FileInfo'
|
||||
import { changeTypeToString, updateTopPathInfo } from '../module/Utils'
|
||||
import { LogInfo, LogDebug } from '../../../../../../common/LogUtils'
|
||||
import { menuLevel, pad_size } from '../module/Constants'
|
||||
import { DisplayInfo } from '../module/DisplayInfo'
|
||||
import { getListFile } from '../module/FileManagerServiceUtils'
|
||||
import { PadSize } from '../module/Constants'
|
||||
import { MediaName, MenuLevel } from '../../../../../../common/src/main/ets/components/Data/Constants'
|
||||
import { FileInfo } from '../../../../../../common/src/main/ets/components/Data/FileInfo'
|
||||
import { getListFile } from '../../../../../../common/src/main/ets/components/Utils/FileManagerServiceUtils'
|
||||
import { logDebug, logInfo } from '../../../../../../common/src/main/ets/components/Utils/LogUtils'
|
||||
import { changeTypeToString, updateTopPathInfo } from '../../../../../../common/src/main/ets/components/utils/Utils'
|
||||
|
||||
let TAG: string = 'SecondLevelByFold'
|
||||
|
||||
@Component
|
||||
export struct SecondLevelByFold {
|
||||
private mWorker
|
||||
private displayInfo: DisplayInfo = new DisplayInfo()
|
||||
private mWorker
|
||||
@Link mFileList: FileInfo[]
|
||||
@Link @Watch('fileTypeChange') mType: string
|
||||
@Link mMenuLevel: number
|
||||
@Link mCurrentPath: string
|
||||
|
||||
@Link mFileList: FileInfo[]
|
||||
@Link @Watch('fileTypeChange') mType: string
|
||||
@Link mMenuLevel: number
|
||||
@Link mCurrentPath: string
|
||||
|
||||
private aboutToAppear(): void{
|
||||
LogInfo(TAG, 'aboutToAppear')
|
||||
this.displayInfo = AppStorage.Get('displayInfo')
|
||||
|
||||
if (globalThis.debugMode) {
|
||||
this.mFileList = getListFile('local', this.mType, this.mCurrentPath)
|
||||
LogDebug(TAG, 'mFileList length = ' + this.mFileList.length)
|
||||
} else {
|
||||
LogInfo(TAG, 'aboutToAppear send message to worker')
|
||||
this.mWorker.postMessage({
|
||||
request_data: 'listFile',
|
||||
device_name: 'local',
|
||||
menu_level: this.mMenuLevel,
|
||||
media_type: this.mType,
|
||||
path: this.mCurrentPath
|
||||
})
|
||||
}
|
||||
|
||||
updateTopPathInfo([], '文件类型', '')
|
||||
updateTopPathInfo(AppStorage.Get('topPathInfo'), changeTypeToString(this.mType), this.mCurrentPath)
|
||||
}
|
||||
|
||||
fileTypeChange() {
|
||||
LogInfo(TAG, 'fileTypeChange ' + this.mType)
|
||||
if (globalThis.debugMode) {
|
||||
this.mFileList = getListFile('local', this.mType, this.mCurrentPath)
|
||||
} else {
|
||||
LogInfo(TAG, 'fileTypeChange send message to worker')
|
||||
this.mWorker.postMessage({
|
||||
request_data: 'listFile',
|
||||
device_name: 'local',
|
||||
menu_level: this.mMenuLevel,
|
||||
media_type: this.mType,
|
||||
path: this.mCurrentPath
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
build() {
|
||||
if (globalThis.startMode == 'choose') {
|
||||
Grid() {
|
||||
ForEach(this.mFileList, fileItem => {
|
||||
GridItem() {
|
||||
Column() {
|
||||
Image($r("app.media.ic_public_big_folder"))
|
||||
.width(pad_size.EIGHTY)
|
||||
.height(pad_size.EIGHTY)
|
||||
.margin({ left: pad_size.TWELVE, top: pad_size.FOUR, right: pad_size.TWELVE })
|
||||
Row() {
|
||||
Text(fileItem.name)
|
||||
.width(pad_size.EIGHTY_EIGHT)
|
||||
.fontSize(pad_size.FOURTEEN)
|
||||
.fontWeight(FontWeight.Regular)
|
||||
.fontColor('#000000')
|
||||
.textAlign(TextAlign.Center)
|
||||
.maxLines(pad_size.TWO)
|
||||
.margin({ top: pad_size.FOUR, left: pad_size.FOUR, right: pad_size.FOUR })
|
||||
}
|
||||
.alignItems(VerticalAlign.Top)
|
||||
.width(pad_size.NINETY_SIX)
|
||||
.height(pad_size.FORTY_SIX)
|
||||
}
|
||||
.width(pad_size.ONE_HUNDRED_AND_FOUR)
|
||||
.height(pad_size.ONE_HUNDRED_AND_THIRTY_FOUR)
|
||||
.alignItems(HorizontalAlign.Center)
|
||||
}
|
||||
.onClick(() => {
|
||||
this.mCurrentPath = fileItem.path
|
||||
LogInfo(TAG, 'fileItem.mediaType = ' + fileItem.mediaType)
|
||||
if (fileItem.mediaType == 'file') {
|
||||
this.mMenuLevel = menuLevel.MENU_THIRD_LEVEL_HAS_DETAIL
|
||||
} else {
|
||||
this.mMenuLevel = menuLevel.MENU_THIRD_LEVEL_HAS_PIC
|
||||
}
|
||||
updateTopPathInfo(AppStorage.Get('topPathInfo'), fileItem.name, fileItem.mCurrentPath)
|
||||
})
|
||||
}, fileItem => fileItem.name)
|
||||
}
|
||||
.columnsTemplate('1fr 1fr 1fr 1fr')
|
||||
.columnsGap(1)
|
||||
.rowsGap(1)
|
||||
.margin({ top: pad_size.SIXTEEN })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Component
|
||||
struct SecondRowView {
|
||||
private item: FileInfo = new FileInfo('')
|
||||
private displayInfo: DisplayInfo = AppStorage.Get('displayInfo')
|
||||
|
||||
@Link mMenuLevel: number
|
||||
@Link mCurrentPath: string
|
||||
|
||||
build() {
|
||||
Row() {
|
||||
Image($r("app.media.ic_file_manager"))
|
||||
.width(22 * 2)
|
||||
.height(19 * 2)
|
||||
.margin({ left: 12 })
|
||||
Text(this.item.name)
|
||||
.fontSize(16 * 2)
|
||||
.fontColor('#182431')
|
||||
.fontWeight(FontWeight.Medium)
|
||||
.margin({ left: 16 })
|
||||
Blank()
|
||||
Image($r("app.media.ic_right"))
|
||||
.width(12 * 2)
|
||||
.height(24 * 2)
|
||||
.margin({ right: 24 * 2 })
|
||||
}
|
||||
.height(56)
|
||||
.width(px2vp(this.displayInfo.mainDialogWidth)) // TODO
|
||||
.margin({ top: '16vp', bottom: '16vp' })
|
||||
.backgroundColor(this.item.list_background)
|
||||
.onClick(() => {
|
||||
LogInfo(TAG, 'onClick this.mCurrentPath = ' + this.mCurrentPath)
|
||||
this.mCurrentPath = this.item.path
|
||||
let path: Array<TopPathInfo> = AppStorage.Get('topPathInfo')
|
||||
path.push(new TopPathInfo(this.item.name, this.mCurrentPath))
|
||||
AppStorage.Set('topPathInfo', path)
|
||||
|
||||
if (this.item.path.includes('dataability:///album') == false) {
|
||||
if (this.item.mediaType != 'file') {
|
||||
LogInfo(TAG, 'MENU_THIRD_LEVEL_HAS_PIC - onClick')
|
||||
this.mMenuLevel = menuLevel.MENU_THIRD_LEVEL_HAS_PIC
|
||||
aboutToAppear(): void{
|
||||
logInfo(TAG, 'aboutToAppear')
|
||||
if (globalThis.debugMode) {
|
||||
this.mFileList = getListFile('local', this.mType, this.mCurrentPath)
|
||||
logDebug(TAG, 'mFileList length = ' + this.mFileList.length)
|
||||
} else {
|
||||
this.mMenuLevel = menuLevel.MENU_THIRD_LEVEL_HAS_DETAIL
|
||||
LogInfo(TAG, 'MENU_THIRD_LEVEL_HAS_DETAIL - onClick')
|
||||
this.mWorker.postMessage({
|
||||
request_data: 'listFile',
|
||||
device_name: 'local',
|
||||
menu_level: this.mMenuLevel,
|
||||
MediaType: this.mType,
|
||||
path: this.mCurrentPath
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
updateTopPathInfo([], '文件类型', '')
|
||||
updateTopPathInfo(AppStorage.Get('topPathInfo'), changeTypeToString(this.mType), this.mCurrentPath)
|
||||
}
|
||||
|
||||
fileTypeChange() {
|
||||
logInfo(TAG, 'fileTypeChange ' + this.mType)
|
||||
if (globalThis.debugMode) {
|
||||
this.mFileList = getListFile('local', this.mType, this.mCurrentPath)
|
||||
} else {
|
||||
this.mWorker.postMessage({
|
||||
request_data: 'listFile',
|
||||
device_name: 'local',
|
||||
menu_level: this.mMenuLevel,
|
||||
MediaType: this.mType,
|
||||
path: this.mCurrentPath
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
build() {
|
||||
if (globalThis.startMode == 'choose') {
|
||||
Grid() {
|
||||
ForEach(this.mFileList, fileItem => {
|
||||
GridItem() {
|
||||
Column() {
|
||||
Image($r("app.media.ic_public_big_folder"))
|
||||
.width(PadSize.EIGHTY)
|
||||
.height(PadSize.EIGHTY)
|
||||
.margin({
|
||||
left: PadSize.TWELVE,
|
||||
right: PadSize.TWELVE,
|
||||
top: PadSize.FOUR,
|
||||
bottom: PadSize.TWO
|
||||
})
|
||||
Row() {
|
||||
Text(fileItem.name)
|
||||
.width(PadSize.EIGHTY_EIGHT)
|
||||
.fontSize(PadSize.FOURTEEN)
|
||||
.fontWeight(FontWeight.Regular)
|
||||
.fontColor('#000000')
|
||||
.textAlign(TextAlign.Center)
|
||||
.maxLines(PadSize.TWO)
|
||||
.margin(PadSize.FOUR)
|
||||
}
|
||||
.alignItems(VerticalAlign.Top)
|
||||
.width(PadSize.NINETY_SIX)
|
||||
.height(PadSize.FORTY_SIX)
|
||||
.margin({ left: PadSize.FOUR, right: PadSize.FOUR, bottom: PadSize.FOUR })
|
||||
}
|
||||
.width(PadSize.ONE_HUNDRED_AND_FOUR)
|
||||
.height(PadSize.ONE_HUNDRED_AND_THIRTY_SIX)
|
||||
.margin({ left: PadSize.SIXTEEN, right: PadSize.EIGHT, bottom: PadSize.TWENTY })
|
||||
.alignItems(HorizontalAlign.Center)
|
||||
}
|
||||
.onClick(() => {
|
||||
this.mCurrentPath = fileItem.path
|
||||
logInfo(TAG, 'fileItem.mediaType = ' + fileItem.mediaType)
|
||||
if (fileItem.mediaType == MediaName.FILE) {
|
||||
this.mMenuLevel = MenuLevel.MENU_THIRD_LEVEL_HAS_DETAIL
|
||||
} else {
|
||||
this.mMenuLevel = MenuLevel.MENU_THIRD_LEVEL_HAS_PIC
|
||||
}
|
||||
updateTopPathInfo(AppStorage.Get('topPathInfo'), fileItem.name, fileItem.mCurrentPath)
|
||||
})
|
||||
}, fileItem => fileItem.name)
|
||||
}
|
||||
.width(PadSize.GRID_WIDTH)
|
||||
.columnsTemplate('1fr 1fr 1fr 1fr')
|
||||
.columnsGap(1)
|
||||
.rowsGap(1)
|
||||
.margin({ top: PadSize.SIXTEEN })
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,192 +13,199 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { FileInfo } from '../../../../../../feature/FileInfo'
|
||||
import { LogInfo } from '../../../../../../common/LogUtils'
|
||||
import { getShowIconBySuffix, updateTopPathInfo } from '../module/Utils'
|
||||
import { media_type, pad_size } from '../module/Constants'
|
||||
import { ChooseDialog } from '../module/DialogUtils'
|
||||
import { DisplayInfo } from '../module/DisplayInfo'
|
||||
import { getListFile } from '../module/FileManagerServiceUtils'
|
||||
import { MediaType } from '../../../../../../common/src/main/ets/components/Data/Constants'
|
||||
import { FileInfo } from '../../../../../../common/src/main/ets/components/Data/FileInfo'
|
||||
import { logInfo } from '../../../../../../common/src/main/ets/components/Utils/LogUtils'
|
||||
import { getListFile } from '../../../../../../common/src/main/ets/components/Utils/FileManagerServiceUtils'
|
||||
import { getShowIconBySuffix, updateTopPathInfo } from '../../../../../../common/src/main/ets/components/utils/utils'
|
||||
import { ChooseDialog } from '../../../../../../common/src/main/ets/components/View/ChooseDialog'
|
||||
import { PadSize } from '../module/Constants'
|
||||
|
||||
@Component
|
||||
export struct ThirdLevelHasDetail {
|
||||
private TAG: string = 'ThirdLevelHasDetail'
|
||||
private mWorker
|
||||
private displayInfo: DisplayInfo = new DisplayInfo()
|
||||
private TAG: string = 'ThirdLevelHasDetail'
|
||||
private mWorker
|
||||
@Link mFileInfo: Array<FileInfo>
|
||||
@Link @Watch('refreshFiles') mCurrentPath: string
|
||||
@Link mMenuLevel: number
|
||||
@Link mType: string
|
||||
|
||||
@Link mFileInfo: Array<FileInfo>
|
||||
@Link @Watch('refreshFiles') mCurrentPath: string
|
||||
@Link mMenuLevel: number
|
||||
@Link mType: string
|
||||
|
||||
private aboutToAppear(): void{
|
||||
LogInfo(this.TAG, 'aboutToAppear')
|
||||
this.displayInfo = AppStorage.Get('displayInfo')
|
||||
|
||||
if (globalThis.debugMode) {
|
||||
this.mFileInfo = getListFile('local', this.mType, this.mCurrentPath)
|
||||
} else {
|
||||
this.mWorker.postMessage({
|
||||
request_data: 'listFile',
|
||||
device_name: 'local',
|
||||
menu_level: this.mMenuLevel,
|
||||
media_type: this.mType,
|
||||
path: this.mCurrentPath
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
private aboutToDisappear() {
|
||||
LogInfo(this.TAG, 'aboutToDisappear')
|
||||
AppStorage.Set('choseFiles', [])
|
||||
}
|
||||
|
||||
refreshFiles() {
|
||||
LogInfo(this.TAG, 'refreshFiles')
|
||||
AppStorage.Set('choseFiles', [])
|
||||
|
||||
if (!globalThis.debugMode) {
|
||||
this.mWorker.postMessage({
|
||||
request_data: 'listFile',
|
||||
device_name: 'local',
|
||||
menu_level: this.mMenuLevel,
|
||||
media_type: this.mType,
|
||||
path: this.mCurrentPath
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
List() {
|
||||
ForEach(this.mFileInfo, (item: FileInfo) => {
|
||||
ListItem() {
|
||||
DetailRowView({
|
||||
item: item,
|
||||
mMenuLevel: $mMenuLevel,
|
||||
mCurrentPath: $mCurrentPath
|
||||
private aboutToAppear(): void{
|
||||
logInfo(this.TAG, 'aboutToAppear')
|
||||
if (globalThis.debugMode) {
|
||||
this.mFileInfo = getListFile('local', this.mType, this.mCurrentPath)
|
||||
} else {
|
||||
this.mWorker.postMessage({
|
||||
request_data: 'listFile',
|
||||
device_name: 'local',
|
||||
menu_level: this.mMenuLevel,
|
||||
MediaType: this.mType,
|
||||
path: this.mCurrentPath
|
||||
})
|
||||
}
|
||||
}, (item: FileInfo) => item.name)
|
||||
}.align(Alignment.Top)
|
||||
}
|
||||
}
|
||||
|
||||
private aboutToDisappear() {
|
||||
logInfo(this.TAG, 'aboutToDisappear')
|
||||
AppStorage.Set('choseFiles', [])
|
||||
}
|
||||
|
||||
refreshFiles() {
|
||||
logInfo(this.TAG, 'refreshFiles')
|
||||
AppStorage.Set('choseFiles', [])
|
||||
if (!globalThis.debugMode) {
|
||||
this.mWorker.postMessage({
|
||||
request_data: 'listFile',
|
||||
device_name: 'local',
|
||||
menu_level: this.mMenuLevel,
|
||||
MediaType: this.mType,
|
||||
path: this.mCurrentPath
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
List() {
|
||||
ForEach(this.mFileInfo, (item: FileInfo) => {
|
||||
ListItem() {
|
||||
DetailRowView({
|
||||
listItem: item,
|
||||
mMenuLevel: $mMenuLevel,
|
||||
mCurrentPath: $mCurrentPath
|
||||
})
|
||||
}
|
||||
}, (item: FileInfo) => item.name)
|
||||
}.align(Alignment.Top)
|
||||
}
|
||||
.height(PadSize.TWO_HUNDRED_AND_SIXTY)
|
||||
.alignItems(HorizontalAlign.Start)
|
||||
.opacity(0.9)
|
||||
.backgroundColor(Color.White)
|
||||
.border({ radius: PadSize.TWENTY_FOUR })
|
||||
.margin({ top: PadSize.SIXTEEN })
|
||||
}
|
||||
.height(pad_size.TWO_HUNDRED_AND_SIXTY)
|
||||
.alignItems(HorizontalAlign.Start)
|
||||
.opacity(0.9)
|
||||
.backgroundColor(Color.White)
|
||||
.border({ radius: pad_size.TWENTY_FOUR })
|
||||
.margin({ top: pad_size.SIXTEEN })
|
||||
}
|
||||
}
|
||||
|
||||
@Component
|
||||
struct DetailRowView {
|
||||
private TAG: string = 'DetailRowView'
|
||||
private displayInfo: DisplayInfo = AppStorage.Get('displayInfo')
|
||||
private dialogController: CustomDialogController = new CustomDialogController({
|
||||
builder: ChooseDialog(),
|
||||
cancel: () => {},
|
||||
autoCancel: true
|
||||
})
|
||||
|
||||
@State item: FileInfo = new FileInfo('')
|
||||
@Link mCurrentPath: string
|
||||
@Link mMenuLevel: number
|
||||
@StorageLink('choseFiles') tmpChoseFiles: Array<FileInfo> = []
|
||||
|
||||
build() {
|
||||
Row() {
|
||||
if (this.item.type == media_type.MEDIA_TYPE_ALBUM) {
|
||||
Image($r("app.media.ic_file_fold"))
|
||||
.width(pad_size.FORTY)
|
||||
.height(pad_size.FORTY)
|
||||
.margin({ left: pad_size.TWELVE })
|
||||
Text(this.item.name)
|
||||
.fontSize(pad_size.SIXTEEN)
|
||||
.fontColor('#182431')
|
||||
.fontWeight(FontWeight.Medium)
|
||||
.margin({ left: pad_size.SIXTEEN })
|
||||
.maxLines(pad_size.ONE)
|
||||
.textOverflow({ overflow: TextOverflow.Ellipsis })
|
||||
Blank()
|
||||
Image($r("app.media.ic_right"))
|
||||
.width(pad_size.TWELVE)
|
||||
.height(pad_size.TWENTY_FOUR)
|
||||
.margin({ right: pad_size.TWENTY_FOUR })
|
||||
} else {
|
||||
Image(getShowIconBySuffix(this.item.name.substring(this.item.name.lastIndexOf('.'))))
|
||||
.width(pad_size.FORTY)
|
||||
.height(pad_size.FORTY)
|
||||
.margin({ left: pad_size.EIGHT })
|
||||
Column() {
|
||||
Text(this.item.name)
|
||||
.height(pad_size.TWENTY_TWO)
|
||||
.fontSize(pad_size.SIXTEEN)
|
||||
.fontWeight(FontWeight.Medium)
|
||||
.fontColor(this.item.font_color)
|
||||
.maxLines(1)
|
||||
.textOverflow({ overflow: TextOverflow.Ellipsis })
|
||||
.margin({ top: pad_size.TEN })
|
||||
Row() {
|
||||
Text('' + this.item.modified_time)
|
||||
.fontSize(pad_size.FOURTEEN)
|
||||
.fontWeight(FontWeight.Regular)
|
||||
.fontColor(this.item.font_color)
|
||||
.maxLines(pad_size.ONE)
|
||||
.textOverflow({ overflow: TextOverflow.Ellipsis })
|
||||
Text('-')
|
||||
.fontSize(pad_size.FOURTEEN)
|
||||
.fontColor(this.item.font_color)
|
||||
.margin({ left: pad_size.EIGHT })
|
||||
Text('' + this.item.size)
|
||||
.fontSize(pad_size.FOURTEEN)
|
||||
.fontWeight(FontWeight.Regular)
|
||||
.fontColor(this.item.font_color)
|
||||
.margin({ left: pad_size.EIGHT })
|
||||
.maxLines(pad_size.ONE)
|
||||
.textOverflow({ overflow: TextOverflow.Ellipsis })
|
||||
}
|
||||
.opacity(0.6)
|
||||
.height(pad_size.NINETEEN)
|
||||
.margin({ top: pad_size.TWO, bottom: pad_size.ELEVEN })
|
||||
}
|
||||
.alignItems(HorizontalAlign.Start)
|
||||
.margin({ left: pad_size.SIXTEEN })
|
||||
}
|
||||
}
|
||||
.width(pad_size.FIVE_HUNDRED_AND_FOUR) // TODO
|
||||
.height(pad_size.SIXTY_FOUR)
|
||||
.margin({ left: pad_size.SIXTEEN, right: pad_size.TWENTY_FOUR, bottom: pad_size.TWO })
|
||||
.border({ radius: pad_size.TWENTY })
|
||||
.backgroundColor(this.item.list_background)
|
||||
.onClick(() => {
|
||||
if (this.item.type == media_type.MEDIA_TYPE_ALBUM) {
|
||||
this.mCurrentPath = this.item.path
|
||||
updateTopPathInfo(AppStorage.Get('topPathInfo'), this.item.name, this.item.path)
|
||||
} else {
|
||||
var index = this.tmpChoseFiles.indexOf(this.item)
|
||||
if (index == -1) {
|
||||
this.item.opacity = 0.1
|
||||
this.item.font_color = Color.White
|
||||
this.item.list_background = '#0A59F7'
|
||||
this.tmpChoseFiles.push(this.item)
|
||||
} else {
|
||||
this.item.opacity = 1
|
||||
this.item.font_color = Color.Black
|
||||
this.item.list_background = ''
|
||||
this.tmpChoseFiles.splice(index, 1)
|
||||
}
|
||||
}
|
||||
private TAG: string = 'DetailRowView'
|
||||
private dialogController: CustomDialogController = new CustomDialogController({
|
||||
builder: ChooseDialog(),
|
||||
cancel: () => {
|
||||
},
|
||||
autoCancel: true
|
||||
})
|
||||
.gesture(
|
||||
LongPressGesture({ repeat: false })
|
||||
.onAction((event: GestureEvent) => {
|
||||
if (this.item.type != media_type.MEDIA_TYPE_ALBUM) {
|
||||
AppStorage.SetOrCreate<FileInfo>('selectedFileInfo', this.item)
|
||||
this.dialogController.open()
|
||||
}
|
||||
@State listItem: FileInfo = new FileInfo('')
|
||||
@Link mCurrentPath: string
|
||||
@Link mMenuLevel: number
|
||||
@StorageLink('choseFiles') @Watch('choseFilesChange') choseFiles: Array<FileInfo> = []
|
||||
|
||||
private choseFilesChange() {
|
||||
this.choseFiles.forEach((item: FileInfo) => {
|
||||
logInfo(this.TAG, 'choseFilesChange item.name = ' + item.name + ' gridItem.name = ' + this.listItem.name)
|
||||
logInfo(this.TAG, 'choseFilesChange item.path = ' + item.path + ' gridItem.path = ' + this.listItem.path)
|
||||
if (item.name == this.listItem.name && item.path == this.listItem.path) {
|
||||
this.listItem.list_background = '#19007DFF'
|
||||
} else {
|
||||
this.listItem.list_background = ''
|
||||
}
|
||||
|
||||
})
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
build() {
|
||||
Stack() {
|
||||
Divider()
|
||||
.vertical(false)
|
||||
.color("#0C000000")
|
||||
.margin({ left: PadSize.EIGHTY, top: PadSize.SIXTY_FOUR, right: PadSize.TWENTY_FOUR })
|
||||
Row() {
|
||||
if (this.listItem.type == MediaType.MEDIA_TYPE_ALBUM) {
|
||||
Image($r("app.media.ic_file_fold"))
|
||||
.width(PadSize.FORTY)
|
||||
.height(PadSize.FORTY)
|
||||
.margin({ left: PadSize.EIGHT })
|
||||
Text(this.listItem.name)
|
||||
.fontSize(PadSize.SIXTEEN)
|
||||
.fontColor('#182431')
|
||||
.fontWeight(FontWeight.Medium)
|
||||
.margin({ left: PadSize.SIXTEEN })
|
||||
.maxLines(PadSize.ONE)
|
||||
.textOverflow({ overflow: TextOverflow.Ellipsis })
|
||||
Blank()
|
||||
Image($r("app.media.ic_right"))
|
||||
.width(PadSize.TWELVE)
|
||||
.height(PadSize.TWENTY_FOUR)
|
||||
} else {
|
||||
Image(getShowIconBySuffix(this.listItem.name.substring(this.listItem.name.lastIndexOf('.'))))
|
||||
.width(PadSize.FORTY)
|
||||
.height(PadSize.FORTY)
|
||||
.margin({ left: PadSize.EIGHT })
|
||||
Column() {
|
||||
Text(this.listItem.name)
|
||||
.height(PadSize.TWENTY_TWO)
|
||||
.fontSize(PadSize.SIXTEEN)
|
||||
.fontWeight(FontWeight.Medium)
|
||||
.fontColor(this.listItem.font_color)
|
||||
.maxLines(1)
|
||||
.textOverflow({ overflow: TextOverflow.Ellipsis })
|
||||
.margin({ top: PadSize.TEN })
|
||||
Row() {
|
||||
Text('' + this.listItem.modified_time)
|
||||
.fontSize(PadSize.FOURTEEN)
|
||||
.fontWeight(FontWeight.Regular)
|
||||
.fontColor(this.listItem.font_color)
|
||||
.maxLines(PadSize.ONE)
|
||||
.textOverflow({ overflow: TextOverflow.Ellipsis })
|
||||
Text('-')
|
||||
.fontSize(PadSize.FOURTEEN)
|
||||
.fontColor(this.listItem.font_color)
|
||||
.margin({ left: PadSize.EIGHT })
|
||||
Text('' + this.listItem.size)
|
||||
.fontSize(PadSize.FOURTEEN)
|
||||
.fontWeight(FontWeight.Regular)
|
||||
.fontColor(this.listItem.font_color)
|
||||
.margin({ left: PadSize.EIGHT })
|
||||
.maxLines(PadSize.ONE)
|
||||
.textOverflow({ overflow: TextOverflow.Ellipsis })
|
||||
}
|
||||
.opacity(0.6)
|
||||
.height(PadSize.NINETEEN)
|
||||
.margin({ top: PadSize.TWO, bottom: PadSize.ELEVEN })
|
||||
}
|
||||
.alignItems(HorizontalAlign.Start)
|
||||
.margin({ left: PadSize.SIXTEEN })
|
||||
}
|
||||
}
|
||||
.width(PadSize.FIVE_HUNDRED_AND_FOUR) // TODO
|
||||
.height(PadSize.SIXTY_FOUR)
|
||||
.margin({ left: PadSize.SIXTEEN, right: PadSize.TWENTY_FOUR, bottom: PadSize.ONE })
|
||||
.border({ radius: PadSize.TWENTY })
|
||||
.backgroundColor(this.listItem.list_background)
|
||||
.onClick(() => {
|
||||
if (this.listItem.type == MediaType.MEDIA_TYPE_ALBUM) {
|
||||
this.mCurrentPath = this.listItem.path
|
||||
updateTopPathInfo(AppStorage.Get('topPathInfo'), this.listItem.name, this.listItem.path)
|
||||
} else {
|
||||
var index = this.choseFiles.indexOf(this.listItem)
|
||||
this.choseFiles.splice(0, this.choseFiles.length)
|
||||
if (index == -1) {
|
||||
this.listItem.list_background = '#19007DFF'
|
||||
this.choseFiles.push(this.listItem)
|
||||
} else {
|
||||
this.listItem.list_background = ''
|
||||
}
|
||||
}
|
||||
})
|
||||
.gesture(LongPressGesture({ repeat: false })
|
||||
.onAction((event: GestureEvent) => {
|
||||
if (this.listItem.type != MediaType.MEDIA_TYPE_ALBUM) {
|
||||
AppStorage.SetOrCreate<FileInfo>('selectedFileInfo', this.listItem)
|
||||
this.dialogController.open()
|
||||
}
|
||||
})
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,169 +13,167 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { FileInfo } from '../../../../../../feature/FileInfo'
|
||||
import { LogInfo, LogDebug } from '../../../../../../common/LogUtils'
|
||||
import { pad_size } from '../module/Constants'
|
||||
import { getListFile } from '../module/FileManagerServiceUtils'
|
||||
import { ChooseDialog } from '../module/DialogUtils'
|
||||
import { DisplayInfo } from '../module/DisplayInfo'
|
||||
import { FileInfo } from '../../../../../../common/src/main/ets/components/Data/FileInfo'
|
||||
import { getListFile } from '../../../../../../common/src/main/ets/components/Utils/FileManagerServiceUtils'
|
||||
import { logDebug, logInfo } from '../../../../../../common/src/main/ets/components/Utils/LogUtils'
|
||||
import { ChooseDialog } from '../../../../../../common/src/main/ets/components/View/ChooseDialog'
|
||||
import { PadSize } from '../module/Constants'
|
||||
|
||||
let TAG: string = 'ThirdLevelHasPic'
|
||||
|
||||
@Component
|
||||
export struct ThirdLevelHasPic {
|
||||
private mWorker
|
||||
private mColumnTemplate: string
|
||||
private mCurrentIndex: number
|
||||
private displayInfo: DisplayInfo = new DisplayInfo()
|
||||
private mWorker
|
||||
private mColumnTemplate: string
|
||||
private mCurrentIndex: number
|
||||
@Link mFileList: Array<FileInfo>
|
||||
@Link mMenuLevel: number
|
||||
@Link mType: string
|
||||
@Link mCurrentPath: string
|
||||
|
||||
@Link mFileList: Array<FileInfo>
|
||||
@Link mMenuLevel: number
|
||||
@Link mType: string
|
||||
@Link mCurrentPath: string
|
||||
|
||||
private aboutToAppear() {
|
||||
LogInfo(TAG, 'aboutToAppear')
|
||||
this.displayInfo = AppStorage.Get('displayInfo')
|
||||
|
||||
if (globalThis.debugMode) {
|
||||
this.mFileList = getListFile('local', this.mType, this.mCurrentPath)
|
||||
LogDebug(TAG, 'mFileList length = ' + this.mFileList.length)
|
||||
} else {
|
||||
LogInfo(TAG, 'aboutToAppear send message to worker')
|
||||
this.mWorker.postMessage({
|
||||
request_data: 'listFile',
|
||||
device_name: 'local',
|
||||
menu_level: this.mMenuLevel,
|
||||
media_type: this.mType,
|
||||
path: this.mCurrentPath,
|
||||
offset: 0,
|
||||
count: 100
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
private aboutToDisappear() {
|
||||
LogInfo(TAG, 'aboutToDisappear')
|
||||
AppStorage.Set('choseFiles', [])
|
||||
}
|
||||
|
||||
build() {
|
||||
if (globalThis.startMode == 'choose') {
|
||||
Column() {
|
||||
Grid() {
|
||||
ForEach(this.mFileList, (item: FileInfo) => {
|
||||
GridItem() {
|
||||
GridItemView({ gridItem: item })
|
||||
}
|
||||
}, item => item.name)
|
||||
aboutToAppear() {
|
||||
logInfo(TAG, 'aboutToAppear send message to worker')
|
||||
if (globalThis.debugMode) {
|
||||
this.mFileList = getListFile('local', this.mType, this.mCurrentPath)
|
||||
logDebug(TAG, 'mFileList length = ' + this.mFileList.length)
|
||||
} else {
|
||||
this.mWorker.postMessage({
|
||||
request_data: 'listFile',
|
||||
device_name: 'local',
|
||||
menu_level: this.mMenuLevel,
|
||||
MediaType: this.mType,
|
||||
path: this.mCurrentPath,
|
||||
offset: 0,
|
||||
count: 100
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
private aboutToDisappear() {
|
||||
logInfo(TAG, 'aboutToDisappear')
|
||||
AppStorage.Set('choseFiles', [])
|
||||
}
|
||||
|
||||
build() {
|
||||
if (globalThis.startMode == 'choose') {
|
||||
Column() {
|
||||
Grid() {
|
||||
ForEach(this.mFileList, (item: FileInfo) => {
|
||||
GridItem() {
|
||||
GridItemView({ gridItem: item })
|
||||
}
|
||||
}, item => item.name)
|
||||
}
|
||||
.columnsTemplate('1fr 1fr 1fr 1fr')
|
||||
|
||||
}
|
||||
.width(PadSize.GRID_WIDTH)
|
||||
.alignItems(HorizontalAlign.Start)
|
||||
.border({ radius: PadSize.TWENTY_FOUR })
|
||||
.opacity(0.9)
|
||||
.backgroundColor(Color.White)
|
||||
.margin({ top: PadSize.SIXTEEN })
|
||||
}
|
||||
//.height(300)
|
||||
//.height(this.displayInfo.mainDialogHeight - (48 * 2))
|
||||
.columnsTemplate('1fr 1fr 1fr 1fr')
|
||||
// .height(px2vp(this.displayInfo.mainDialogHeight)) // 必须参数
|
||||
// .columnsTemplate(this.mColumnTemplate)
|
||||
|
||||
}
|
||||
.alignItems(HorizontalAlign.Start)
|
||||
.border({ radius: pad_size.TWENTY_FOUR })
|
||||
.opacity(0.9)
|
||||
.backgroundColor(Color.White)
|
||||
.margin({ top: pad_size.SIXTEEN })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Component
|
||||
struct GridItemView {
|
||||
private dialogController: CustomDialogController = new CustomDialogController({
|
||||
builder: ChooseDialog(),
|
||||
cancel: () => {},
|
||||
autoCancel: true
|
||||
})
|
||||
@State gridItem: FileInfo = new FileInfo('')
|
||||
@StorageLink('choseFiles') @Watch('choseFilesChange') choseFiles: Array<FileInfo> = []
|
||||
|
||||
private choseFilesChange() {
|
||||
this.choseFiles.forEach((item: FileInfo) => {
|
||||
LogInfo(TAG, 'choseFilesChange item.name = ' + item.name + ' gridItem.name = ' + this.gridItem.name)
|
||||
LogInfo(TAG, 'choseFilesChange item.path = ' + item.path + ' gridItem.path = ' + this.gridItem.path)
|
||||
if (item.name == this.gridItem.name && item.path == this.gridItem.path) {
|
||||
this.gridItem.opacity = 1
|
||||
this.gridItem.font_color = Color.White
|
||||
this.gridItem.list_background = '#2E88FF'
|
||||
return;
|
||||
}
|
||||
private dialogController: CustomDialogController = new CustomDialogController({
|
||||
builder: ChooseDialog(),
|
||||
cancel: () => {
|
||||
},
|
||||
autoCancel: true
|
||||
})
|
||||
}
|
||||
@State gridItem: FileInfo = new FileInfo('')
|
||||
@StorageLink('choseFiles') @Watch('choseFilesChange') choseFiles: Array<FileInfo> = []
|
||||
|
||||
build() {
|
||||
Flex({
|
||||
direction: FlexDirection.Column,
|
||||
alignItems: ItemAlign.Center,
|
||||
justifyContent: FlexAlign.Center
|
||||
}) {
|
||||
Image(`${this.gridItem.path}/thumbnail/${pad_size.EIGHTY_TWO}/${pad_size.EIGHTY_TWO}`)
|
||||
.objectFit(ImageFit.Contain)
|
||||
.width(pad_size.EIGHTY_TWO)
|
||||
.height(pad_size.EIGHTY_TWO)
|
||||
.margin({
|
||||
left: pad_size.ELEVEN,
|
||||
right: pad_size.ELEVEN,
|
||||
top: pad_size.FOUR,
|
||||
bottom: pad_size.TWO
|
||||
private choseFilesChange() {
|
||||
this.choseFiles.forEach((item: FileInfo) => {
|
||||
logInfo(TAG, 'choseFilesChange item.name = ' + item.name + ' gridItem.name = ' + this.gridItem.name)
|
||||
logInfo(TAG, 'choseFilesChange item.path = ' + item.path + ' gridItem.path = ' + this.gridItem.path)
|
||||
if (item.name == this.gridItem.name && item.path == this.gridItem.path) {
|
||||
this.gridItem.font_color = Color.White
|
||||
this.gridItem.list_background = '#19007DFF'
|
||||
this.gridItem.textBackground = "#007DFF"
|
||||
return;
|
||||
} else {
|
||||
this.gridItem.font_color = Color.Black
|
||||
this.gridItem.list_background = ''
|
||||
this.gridItem.textBackground = ""
|
||||
}
|
||||
})
|
||||
|
||||
Row() {
|
||||
Text(this.gridItem.name)
|
||||
.width(pad_size.EIGHTY_EIGHT)
|
||||
.fontSize(pad_size.FOURTEEN)
|
||||
.fontColor(this.gridItem.font_color)
|
||||
.fontWeight(FontWeight.Regular)
|
||||
.maxLines(2)
|
||||
.opacity(0.9)
|
||||
.textAlign(TextAlign.Center)
|
||||
.textOverflow({ overflow: TextOverflow.Ellipsis })
|
||||
.margin({ top: pad_size.FOUR })
|
||||
}
|
||||
.alignItems(VerticalAlign.Top)
|
||||
.width(pad_size.NINETY_SIX)
|
||||
.height(pad_size.FORTY_SIX)
|
||||
.margin({ left: pad_size.FOUR, right: pad_size.FOUR, bottom: pad_size.FOUR })
|
||||
}
|
||||
.width(pad_size.ONE_HUNDRED_AND_FOUR)
|
||||
.height(pad_size.ONE_HUNDRED_AND_THIRTY_FOUR)
|
||||
.margin({ bottom: pad_size.SIXTEEN })
|
||||
.border({ radius: pad_size.TWELVE })
|
||||
.opacity(this.gridItem.opacity)
|
||||
.backgroundColor(this.gridItem.list_background)
|
||||
.gesture(
|
||||
LongPressGesture({ repeat: false })
|
||||
.onAction((event: GestureEvent) => {
|
||||
AppStorage.SetOrCreate<FileInfo>('selectedFileInfo', this.gridItem)
|
||||
this.dialogController.open()
|
||||
})
|
||||
)
|
||||
.onClick(() => {
|
||||
let choseFiles: Array<FileInfo> = AppStorage.Get('choseFiles')
|
||||
let index: number = -1
|
||||
choseFiles.forEach((item: FileInfo) => {
|
||||
if (item.name == this.gridItem.name && item.path == this.gridItem.path) {
|
||||
index = choseFiles.indexOf(item)
|
||||
}
|
||||
})
|
||||
if (index == -1) {
|
||||
this.gridItem.opacity = 1
|
||||
this.gridItem.font_color = Color.White
|
||||
this.gridItem.list_background = '#2E88FF'
|
||||
choseFiles.push(this.gridItem)
|
||||
} else {
|
||||
choseFiles.splice(index, 1)
|
||||
this.gridItem.opacity = 1
|
||||
this.gridItem.font_color = Color.Black
|
||||
this.gridItem.list_background = ''
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
build() {
|
||||
Flex({
|
||||
direction: FlexDirection.Column,
|
||||
alignItems: ItemAlign.Center,
|
||||
justifyContent: FlexAlign.Center
|
||||
}) {
|
||||
Image(`${this.gridItem.path}/thumbnail/${PadSize.EIGHTY}/${PadSize.EIGHTY}`)
|
||||
.objectFit(ImageFit.Contain)
|
||||
.width(PadSize.EIGHTY)
|
||||
.height(PadSize.EIGHTY)
|
||||
.margin({
|
||||
left: PadSize.TWELVE,
|
||||
right: PadSize.TWELVE,
|
||||
top: PadSize.FOUR,
|
||||
bottom: PadSize.TWO
|
||||
})
|
||||
.border({ radius: PadSize.TWELVE, width: 0, style: BorderStyle.Solid })
|
||||
|
||||
Row() {
|
||||
Text(this.gridItem.name)
|
||||
.width(PadSize.EIGHTY_EIGHT)
|
||||
.fontSize(PadSize.FOURTEEN)
|
||||
.fontColor(this.gridItem.font_color)
|
||||
.fontWeight(FontWeight.Regular)
|
||||
.maxLines(2)
|
||||
.opacity(0.9)
|
||||
.textAlign(TextAlign.Center)
|
||||
.textOverflow({ overflow: TextOverflow.Ellipsis })
|
||||
.margin(PadSize.FOUR)
|
||||
}
|
||||
.alignItems(VerticalAlign.Top)
|
||||
.width(PadSize.NINETY_SIX)
|
||||
.height(PadSize.FORTY_SIX)
|
||||
.margin({ left: PadSize.FOUR, right: PadSize.FOUR, bottom: PadSize.FOUR })
|
||||
.border({ radius: PadSize.TWELVE, width: 0, style: BorderStyle.Solid })
|
||||
.backgroundColor(this.gridItem.textBackground)
|
||||
}
|
||||
.width(PadSize.ONE_HUNDRED_AND_FOUR)
|
||||
.height(PadSize.ONE_HUNDRED_AND_THIRTY_SIX)
|
||||
.margin({ left: PadSize.SIXTEEN, right: PadSize.EIGHT, bottom: PadSize.TWENTY })
|
||||
.border({ radius: PadSize.TWELVE })
|
||||
.opacity(this.gridItem.opacity)
|
||||
.backgroundColor(this.gridItem.list_background)
|
||||
.gesture(
|
||||
LongPressGesture({ repeat: false })
|
||||
.onAction((event: GestureEvent) => {
|
||||
AppStorage.SetOrCreate<FileInfo>('selectedFileInfo', this.gridItem)
|
||||
this.dialogController.open()
|
||||
})
|
||||
)
|
||||
.onClick(() => {
|
||||
let choseFiles: Array<FileInfo> = AppStorage.Get('choseFiles')
|
||||
let index: number = -1
|
||||
choseFiles.forEach((item: FileInfo) => {
|
||||
if (item.name == this.gridItem.name && item.path == this.gridItem.path) {
|
||||
index = choseFiles.indexOf(item)
|
||||
}
|
||||
})
|
||||
choseFiles.splice(0, choseFiles.length)
|
||||
if (index == -1) {
|
||||
this.gridItem.font_color = Color.White
|
||||
this.gridItem.list_background = '#19007DFF'
|
||||
this.gridItem.textBackground = "#007DFF"
|
||||
choseFiles.push(this.gridItem)
|
||||
} else {
|
||||
this.gridItem.font_color = Color.Black
|
||||
this.gridItem.list_background = ''
|
||||
this.gridItem.textBackground = ""
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -13,16 +13,16 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { LogInfo, LogDebug } from '../../../../../../common/LogUtils'
|
||||
import worker from '@ohos.worker'
|
||||
import filemanager from '@ohos.filemanager'
|
||||
import worker from '@ohos.worker'
|
||||
import { logInfo, logDebug, logError } from '../../../../../../common/src/main/ets/components/utils/logutils'
|
||||
|
||||
var TAG = 'DataWorker'
|
||||
const parentPort = worker.parentPort
|
||||
parentPort.onmessage = function (e) {
|
||||
LogInfo(TAG, 'DataWorker onMessage')
|
||||
logInfo(TAG, 'DataWorker onMessage')
|
||||
let data = e.data
|
||||
LogInfo(TAG, 'DataWorker onMessage ' + data.request_data)
|
||||
logInfo(TAG, 'DataWorker onMessage ' + data.request_data)
|
||||
if (data.request_data == 'getRoot') {
|
||||
getRootData(data)
|
||||
} else if (data.request_data == 'listFile') {
|
||||
@@ -33,11 +33,11 @@ parentPort.onmessage = function (e) {
|
||||
}
|
||||
|
||||
parentPort.onmessageerror = function () {
|
||||
LogInfo(TAG, 'onmessageerror')
|
||||
logInfo(TAG, 'onmessageerror')
|
||||
}
|
||||
|
||||
parentPort.onerror = function (data) {
|
||||
LogInfo(TAG, 'onerror')
|
||||
logInfo(TAG, 'onerror')
|
||||
}
|
||||
|
||||
function getRootData(data) {
|
||||
@@ -46,52 +46,46 @@ function getRootData(data) {
|
||||
handleData(file, data)
|
||||
})
|
||||
.catch((error) => {
|
||||
LogDebug(TAG, 'getRoot error' + error)
|
||||
logError(TAG, 'getRoot error' + error)
|
||||
});
|
||||
}
|
||||
|
||||
function getListFileData(data) {
|
||||
if (data.offset == undefined || data.count == undefined) {
|
||||
LogDebug(TAG, 'path = ' + data.path + " type = " + data.media_type)
|
||||
filemanager.listFile(data.path, data.media_type)
|
||||
.then(file => {
|
||||
handleData(file, data)
|
||||
})
|
||||
.catch((error) => {
|
||||
LogDebug(TAG, 'getListFileData error' + error)
|
||||
handleData([], data)
|
||||
})
|
||||
logDebug(TAG, 'path = ' + data.path + " type = " + data.MediaType)
|
||||
filemanager.listFile(data.path, data.MediaType).then(file => {
|
||||
handleData(file, data)
|
||||
}).catch((error) => {
|
||||
logError(TAG, 'getListFileData error' + error)
|
||||
handleData([], data)
|
||||
})
|
||||
} else {
|
||||
LogDebug(TAG, 'path = ' + data.path + " type = " + data.media_type + " offset = " + data.offset)
|
||||
filemanager.listFile(data.path, data.media_type, {
|
||||
logDebug(TAG, 'path = ' + data.path + " type = " + data.MediaType + " offset = " + data.offset)
|
||||
filemanager.listFile(data.path, data.MediaType, {
|
||||
'offset': data.offset,
|
||||
'count': data.count
|
||||
}).then(file => {
|
||||
handleData(file, data)
|
||||
}).catch((error) => {
|
||||
logError(TAG, 'getListFileData offset error' + error)
|
||||
handleData([], data)
|
||||
})
|
||||
.then(file => {
|
||||
handleData(file, data)
|
||||
})
|
||||
.catch((error) => {
|
||||
LogDebug(TAG, 'getListFileData offset error' + error)
|
||||
handleData([], data)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function createFile(data) {
|
||||
LogDebug(TAG, 'path = ' + data.path + ' files = ' + data.save_name)
|
||||
filemanager.createFile(data.path, data.save_name)
|
||||
.then((uri) => {
|
||||
handleData(uri, data)
|
||||
})
|
||||
.catch((error) => {
|
||||
LogDebug(TAG, 'createFile error' + error)
|
||||
})
|
||||
logDebug(TAG, 'path = ' + data.path + ' files = ' + data.save_name)
|
||||
filemanager.createFile(data.path, data.save_name).then((uri) => {
|
||||
handleData(uri, data)
|
||||
}).catch((error) => {
|
||||
logError(TAG, 'createFile error' + error)
|
||||
})
|
||||
}
|
||||
|
||||
function handleData(file, data) {
|
||||
LogInfo(TAG, 'handleData')
|
||||
logInfo(TAG, 'handleData')
|
||||
var info = JSON.stringify(file)
|
||||
LogInfo(TAG, 'info = ' + info.length)
|
||||
logInfo(TAG, 'info = ' + info.length)
|
||||
var buf = new ArrayBuffer(info.length * 2)
|
||||
var bufView = new Uint16Array(buf)
|
||||
for (var index = 0; index < info.length; index++) {
|
||||
|
||||
@@ -23,66 +23,6 @@
|
||||
{
|
||||
"name": "btn_save",
|
||||
"value": "save"
|
||||
},
|
||||
{
|
||||
"name": "file_unknown",
|
||||
"value": "Unknown file"
|
||||
},
|
||||
{
|
||||
"name": "save_file_has_same_file",
|
||||
"value": "Duplicate name file already exists"
|
||||
},
|
||||
{
|
||||
"name": "save_file_no_media_permission",
|
||||
"value": "Saving to media library is not currently supported"
|
||||
},
|
||||
{
|
||||
"name": "save_file_unknown_reason",
|
||||
"value": "Unknown error"
|
||||
},
|
||||
{
|
||||
"name": "file_zip",
|
||||
"value": "Compressed (zipped) file"
|
||||
},
|
||||
{
|
||||
"name": "file_xml",
|
||||
"value": "XML document"
|
||||
},
|
||||
{
|
||||
"name": "file_xls",
|
||||
"value": "Microsoft Excel worksheet"
|
||||
},
|
||||
{
|
||||
"name": "file_txt",
|
||||
"value": "Txt document"
|
||||
},
|
||||
{
|
||||
"name": "file_rar",
|
||||
"value": "Rar compressed file"
|
||||
},
|
||||
{
|
||||
"name": "file_pdf",
|
||||
"value": "Adobe Acrobat Document"
|
||||
},
|
||||
{
|
||||
"name": "file_html",
|
||||
"value": "HTML Document"
|
||||
},
|
||||
{
|
||||
"name": "file_pptx",
|
||||
"value": "Microsoft PowerPoint Presentation"
|
||||
},
|
||||
{
|
||||
"name": "file_docx",
|
||||
"value": "Microsoft Word Document"
|
||||
},
|
||||
{
|
||||
"name": "file_type",
|
||||
"value": "file type"
|
||||
},
|
||||
{
|
||||
"name": "file_name",
|
||||
"value": "file name : "
|
||||
}
|
||||
]
|
||||
}
|
||||
|
Before Width: | Height: | Size: 2.5 KiB |
|
Before Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 2.4 KiB |
|
Before Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 2.8 KiB |
|
Before Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 3.3 KiB |
|
Before Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 2.8 KiB |
|
Before Width: | Height: | Size: 2.6 KiB |
|
Before Width: | Height: | Size: 2.6 KiB |
|
Before Width: | Height: | Size: 2.7 KiB |
@@ -23,66 +23,6 @@
|
||||
{
|
||||
"name": "btn_save",
|
||||
"value": "保存"
|
||||
},
|
||||
{
|
||||
"name": "file_unknown",
|
||||
"value": "未知文件"
|
||||
},
|
||||
{
|
||||
"name": "save_file_has_same_file",
|
||||
"value": "已有重名文件"
|
||||
},
|
||||
{
|
||||
"name": "save_file_no_media_permission",
|
||||
"value": "当前不支持保存到媒体库"
|
||||
},
|
||||
{
|
||||
"name": "save_file_unknown_reason",
|
||||
"value": "未知错误"
|
||||
},
|
||||
{
|
||||
"name": "file_zip",
|
||||
"value": "压缩(zipped)文件"
|
||||
},
|
||||
{
|
||||
"name": "file_xml",
|
||||
"value": "XML文档"
|
||||
},
|
||||
{
|
||||
"name": "file_xls",
|
||||
"value": "Microsoft Excel工作表"
|
||||
},
|
||||
{
|
||||
"name": "file_txt",
|
||||
"value": "TXT文档"
|
||||
},
|
||||
{
|
||||
"name": "file_rar",
|
||||
"value": "RAR压缩文件"
|
||||
},
|
||||
{
|
||||
"name": "file_pdf",
|
||||
"value": "Adobe Acrobat Document"
|
||||
},
|
||||
{
|
||||
"name": "file_html",
|
||||
"value": "HTML网页文件"
|
||||
},
|
||||
{
|
||||
"name": "file_pptx",
|
||||
"value": "Microsoft PowerPoint演示文稿"
|
||||
},
|
||||
{
|
||||
"name": "file_docx",
|
||||
"value": "Microsoft Word文档"
|
||||
},
|
||||
{
|
||||
"name": "file_type",
|
||||
"value": "文件类型"
|
||||
},
|
||||
{
|
||||
"name": "file_name",
|
||||
"value": "文件名 : "
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,5 +1,11 @@
|
||||
{
|
||||
"name": "phone",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 1
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
"@ohos/common": {
|
||||
"version": "file:../../common"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
{
|
||||
"license": "ISC",
|
||||
"devDependencies": {},
|
||||
"name": "phone",
|
||||
"ohos": {
|
||||
"org": "huawei",
|
||||
"directoryLevel": "module",
|
||||
"buildTool": "hvigor"
|
||||
},
|
||||
"description": "example description",
|
||||
"repository": {},
|
||||
"version": "1.0.0",
|
||||
"dependencies": {}
|
||||
"license": "ISC",
|
||||
"devDependencies": {},
|
||||
"name": "phone",
|
||||
"ohos": {
|
||||
"org": "huawei",
|
||||
"directoryLevel": "module",
|
||||
"buildTool": "hvigor"
|
||||
},
|
||||
"description": "example description",
|
||||
"repository": {},
|
||||
"version": "1.0.0",
|
||||
"dependencies": {
|
||||
"@ohos/common": "file:../../common"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,25 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import AbilityStage from "@ohos.application.AbilityStage"
|
||||
import { logInfo } from '../../../../../../common/src/main/ets/components/Utils/LogUtils'
|
||||
|
||||
const TAG = "MyAbilityStage"
|
||||
|
||||
export default class MyAbilityStage extends AbilityStage {
|
||||
onCreate() {
|
||||
console.log("[Demo] MyAbilityStage onCreate")
|
||||
logInfo(TAG, "onCreate")
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import Ability from '@ohos.application.Ability'
|
||||
import display from '@ohos.display'
|
||||
import { Callback } from 'basic'
|
||||
import { LogInfo, LogDebug } from '../module/LogUtils'
|
||||
import { logInfo, logError, logWarn } from '../../../../../../common/src/main/ets/components/Utils/LogUtils'
|
||||
|
||||
let displayWidth: number = 0
|
||||
let displayHeight: number = 0
|
||||
@@ -10,46 +10,41 @@ const TAG = "MainAbility"
|
||||
|
||||
export default class MainAbility extends Ability {
|
||||
onCreate(want, launchParam) {
|
||||
console.log("filePicker_MainAbility: onCreate")
|
||||
logInfo(TAG, "onCreate")
|
||||
globalThis.abilityWant = want;
|
||||
|
||||
globalThis.startMode = want.parameters.startMode
|
||||
globalThis.saveFile = want.parameters.saveFile
|
||||
globalThis.debugMode = want.parameters.debugMode
|
||||
console.log('filePicker_MainAbility: startMode = ' + globalThis.startMode)
|
||||
console.log('filePicker_MainAbility: file_name = ' + globalThis.saveFile)
|
||||
console.log('filePicker_MainAbility: debugMode = ' + globalThis.debugMode)
|
||||
|
||||
logInfo(TAG, `parameters ${JSON.stringify(want.parameters)}`)
|
||||
}
|
||||
|
||||
onDestroy() {
|
||||
console.log("[Demo] MainAbility onDestroy")
|
||||
logInfo(TAG, "onDestroy")
|
||||
}
|
||||
|
||||
onWindowStageCreate(windowStage) {
|
||||
// Main window is created, set main page for this ability
|
||||
LogInfo(TAG, "[Demo] MainAbility onWindowStageCreate")
|
||||
logInfo(TAG, "onWindowStageCreate")
|
||||
|
||||
globalThis.context = this.context
|
||||
|
||||
this.requestPermissions(() => this.displayWindow(windowStage))
|
||||
|
||||
|
||||
}
|
||||
|
||||
onWindowStageDestroy() {
|
||||
// Main window is destroyed, release UI related resources
|
||||
console.log("[Demo] MainAbility onWindowStageDestroy")
|
||||
logInfo(TAG, "onWindowStageDestroy")
|
||||
}
|
||||
|
||||
onForeground() {
|
||||
// Ability has brought to foreground
|
||||
console.log("[Demo] MainAbility onForeground")
|
||||
logInfo(TAG, "onForeground")
|
||||
}
|
||||
|
||||
onBackground() {
|
||||
// Ability has back to background
|
||||
console.log("[Demo] MainAbility onBackground")
|
||||
logInfo(TAG, "onBackground")
|
||||
}
|
||||
|
||||
private requestPermissions(callback: Callback<void>) {
|
||||
@@ -59,10 +54,10 @@ export default class MainAbility extends Ability {
|
||||
"ohos.permission.WRITE_MEDIA"
|
||||
]
|
||||
globalThis.context.requestPermissionsFromUser(permissionList).then(function (data) {
|
||||
LogInfo(TAG, 'filePicker_MainAbility: request permission data result = ' + data.authResults)
|
||||
logInfo(TAG, 'request permission data result = ' + data.authResults)
|
||||
callback()
|
||||
}, (error) => {
|
||||
LogInfo(TAG, 'filePicker_MainAbility: fail to request permission error code = ' + error.code)
|
||||
logError(TAG, 'fail to request permission error code = ' + error.code)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -76,10 +71,10 @@ export default class MainAbility extends Ability {
|
||||
globalThis.mainDialogWidth = dis.width
|
||||
globalThis.mainDialogHeight = (((displayHeight) - 240) * 0.7)
|
||||
|
||||
LogInfo(TAG, "cjl displayWidth = " + displayWidth + " displayHeight = " + displayHeight)
|
||||
logInfo(TAG, "displayWidth = " + displayWidth + " displayHeight = " + displayHeight)
|
||||
|
||||
windowStage.getMainWindow().then(win => {
|
||||
LogInfo(TAG, "cjl windowStage.getMainWindow()")
|
||||
logInfo(TAG, "windowStage.getMainWindow()")
|
||||
|
||||
win.resetSize(displayWidth - 30, displayHeight - 168)
|
||||
|
||||
@@ -87,25 +82,25 @@ export default class MainAbility extends Ability {
|
||||
|
||||
win.setBackgroundColor("#00FFFFFF", (err, data) => {
|
||||
if (err.code) {
|
||||
LogInfo(TAG, "Fail to set the background color" + JSON.stringify(err))
|
||||
logWarn(TAG, "Fail to set the background color" + JSON.stringify(err))
|
||||
} else {
|
||||
LogInfo(TAG, "Success to set the background color" + JSON.stringify(data))
|
||||
logInfo(TAG, "Success to set the background color" + JSON.stringify(data))
|
||||
}
|
||||
})
|
||||
|
||||
win.disableWindowDecor((err, data) => {
|
||||
if (err.code) {
|
||||
LogInfo(TAG, 'Failed to set the disableWindowDecor. Data: ' + JSON.stringify(data))
|
||||
logWarn(TAG, 'Failed to set the disableWindowDecor. Data: ' + JSON.stringify(data))
|
||||
} else {
|
||||
LogInfo(TAG, 'Succeeded in setting the disableWindowDecor. Data: ' + JSON.stringify(data))
|
||||
logInfo(TAG, "Success to disable Window Decor" + JSON.stringify(data))
|
||||
}
|
||||
})
|
||||
|
||||
win.setWindowMode(102, (err, data) => {
|
||||
if (err.code) {
|
||||
LogInfo(TAG, 'Failed to set the setWindowMode. Data: ' + JSON.stringify(data))
|
||||
logWarn(TAG, 'Failed to set the setWindowMode. Data: ' + JSON.stringify(data))
|
||||
} else {
|
||||
LogInfo(TAG, 'Succeeded in setting the setWindowMode. Data: ' + JSON.stringify(data))
|
||||
logInfo(TAG, 'Succeeded in setting the setWindowMode. Data: ' + JSON.stringify(data))
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@@ -1,91 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import display from '@ohos.display'
|
||||
import featureAbility from '@ohos.ability.featureAbility'
|
||||
import { LogInfo } from '../module/LogUtils.ets'
|
||||
import { DisplayInfo } from './DisplayInfo.ets'
|
||||
|
||||
var TAG: string = 'AbilityUtils'
|
||||
|
||||
export function terminateSelfWithResult(resultCode: number, result: string): void {
|
||||
LogInfo(TAG, 'terminateSelfWithResult')
|
||||
let startMode: string = AppStorage.Get<string>('startMode')
|
||||
var abilityResult = {
|
||||
resultCode: resultCode,
|
||||
want: {
|
||||
parameters: {
|
||||
'startMode': startMode,
|
||||
'result': result
|
||||
}
|
||||
}
|
||||
}
|
||||
globalThis.context.terminateSelfWithResult(abilityResult, (error) => {
|
||||
if (error.code) {
|
||||
LogInfo(TAG, 'Operation failed. Cause: ' + JSON.stringify(error))
|
||||
return
|
||||
}
|
||||
LogInfo(TAG, 'Operation succeeded')
|
||||
})
|
||||
}
|
||||
|
||||
export function initData(): void {
|
||||
LogInfo(TAG, 'initData')
|
||||
initWindowScale()
|
||||
|
||||
getWantFromHap()
|
||||
}
|
||||
|
||||
function initWindowScale(): void {
|
||||
display.getDefaultDisplay().then(dis => {
|
||||
LogInfo(TAG, 'width = ' + dis.width + ';height= ' + dis.height)
|
||||
let displayInfo: DisplayInfo = new DisplayInfo()
|
||||
|
||||
if (dis.width > dis.height) { // 横屏
|
||||
displayInfo.width = dis.width
|
||||
displayInfo.height = dis.height * 0.6 // 需要减去信号栏和导航栏的高度
|
||||
displayInfo.mainDialogHeight = displayInfo.height - vp2px(64 + 76)
|
||||
displayInfo.mainDialogWidth = displayInfo.width
|
||||
|
||||
} else { // 竖屏
|
||||
displayInfo.width = dis.width
|
||||
displayInfo.height = dis.height * 0.65 // 需要减去信号栏和导航栏的高度
|
||||
displayInfo.mainDialogHeight = displayInfo.height - vp2px(64 + 76)
|
||||
//displayInfo.mainDialogHeight = displayInfo.height - (64 + 76) * 2
|
||||
displayInfo.mainDialogWidth = displayInfo.width
|
||||
}
|
||||
|
||||
LogInfo(TAG, 'mainDialogWidth = ' + displayInfo.mainDialogWidth)
|
||||
LogInfo(TAG, 'mainDialogHeight = ' + displayInfo.mainDialogHeight)
|
||||
AppStorage.SetOrCreate('displayInfo', displayInfo)
|
||||
})
|
||||
}
|
||||
|
||||
function getWantFromHap(): void {
|
||||
featureAbility.getWant()
|
||||
.then((Want) => {
|
||||
var mode: string = Want.parameters['startMode']
|
||||
if (mode == undefined) {
|
||||
AppStorage.SetOrCreate<string>('startMode', 'choose')
|
||||
} else {
|
||||
AppStorage.SetOrCreate<string>('startMode', mode)
|
||||
}
|
||||
let save_name: string = Want.parameters['file_name']
|
||||
AppStorage.Set<string>('saveName', save_name)
|
||||
LogInfo(TAG, 'saveName = ' + save_name)
|
||||
}).catch((error) => {
|
||||
LogInfo(TAG, 'fail Data: ' + JSON.stringify(error))
|
||||
})
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export enum menuLevel {
|
||||
MENU_FIRST_LEVEL_BY_TYPE = 1,
|
||||
MENU_SECOND_LEVEL_BY_FOLD = 2,
|
||||
MENU_THIRD_LEVEL_HAS_PIC = 3,
|
||||
MENU_THIRD_LEVEL_HAS_DETAIL = 4,
|
||||
}
|
||||
|
||||
export enum media_type {
|
||||
MEDIA_TYPE_FILE = 1,
|
||||
MEDIA_TYPE_IMAGE = 3,
|
||||
MEDIA_TYPE_VIDEO = 4,
|
||||
MEDIA_TYPE_AUDIO = 5,
|
||||
MEDIA_TYPE_ALBUM = 8
|
||||
}
|
||||
|
||||
export enum GridItemSize {
|
||||
GRID_ITEM_HEIGHT = 126,
|
||||
//GRID_ITEM_WIDTH = 112,
|
||||
GRID_ITEM_WIDTH = 96,
|
||||
GRID_ITEM_COLUMNS_GAP = 8,
|
||||
GRID_ITEM_ROWS_GAP = 8,
|
||||
}
|
||||
|
||||
export enum terminate_reason {
|
||||
SUCCESS = 0,
|
||||
NO_ACTION = -1,
|
||||
}
|
||||
@@ -1,110 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { FileInfo } from './FileInfo.ets'
|
||||
|
||||
@CustomDialog
|
||||
export struct WarningDialog {
|
||||
@Link code: number
|
||||
controller: CustomDialogController
|
||||
cancel: () => void
|
||||
confirm: () => void
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
Text('Warning Title').fontSize(20).margin(10)
|
||||
if (this.code == 1) {
|
||||
Text($r("app.string.save_file_has_same_file")).fontSize(16).margin(10)
|
||||
} else if (this.code == 2) {
|
||||
Text($r("app.string.save_file_no_media_permission")).fontSize(16).margin(10)
|
||||
} else {
|
||||
Text($r("app.string.save_file_unknown_reason")).fontSize(16).margin(10)
|
||||
}
|
||||
Flex({ justifyContent: FlexAlign.SpaceAround }) {
|
||||
Button('cancel')
|
||||
.onClick(() => {
|
||||
this.controller.close()
|
||||
this.cancel()
|
||||
}).backgroundColor(0xffffff).fontColor(Color.Black)
|
||||
Button('confirm')
|
||||
.onClick(() => {
|
||||
this.controller.close()
|
||||
this.confirm()
|
||||
}).backgroundColor(0xffffff).fontColor(Color.Red)
|
||||
}.margin({ bottom: 10 })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@CustomDialog
|
||||
export struct ChooseDialog {
|
||||
controller: CustomDialogController
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
Row() {
|
||||
Text('选择该文件')
|
||||
}
|
||||
Row() {
|
||||
Button() {
|
||||
Text('取消')
|
||||
.height('100%')
|
||||
.fontSize(24)
|
||||
.fontColor(Color.Blue)
|
||||
}
|
||||
.width(px2vp(200))
|
||||
.height(px2vp(50))
|
||||
.backgroundColor(Color.White)
|
||||
.onClick(() => {
|
||||
this.controller.close()
|
||||
})
|
||||
|
||||
Divider()
|
||||
.vertical(true)
|
||||
.color(Color.Gray)
|
||||
.height(40)
|
||||
.margin({top: 0, right: 10, bottom: 0, left: 10})
|
||||
|
||||
Button() {
|
||||
Text('确定')
|
||||
.height('100%')
|
||||
.fontSize(24)
|
||||
.fontColor(Color.Blue)
|
||||
}
|
||||
.width(px2vp(200))
|
||||
.height(px2vp(50))
|
||||
.backgroundColor(Color.White)
|
||||
.onClick(() => {
|
||||
let item: FileInfo = AppStorage.Get<FileInfo>('selectedFileInfo')
|
||||
if (item != null) {
|
||||
let files: Array<FileInfo> = AppStorage.Get('choseFiles')
|
||||
if (files.indexOf(item) == -1) {
|
||||
files.push(item)
|
||||
AppStorage.Set('choseFiles', files)
|
||||
}
|
||||
}
|
||||
this.controller.close()
|
||||
})
|
||||
}
|
||||
.padding(20)
|
||||
}
|
||||
.padding({
|
||||
top: 25,
|
||||
right: 0,
|
||||
bottom: 15,
|
||||
left: 0
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { media_type } from './Constants.ets'
|
||||
|
||||
export class FileInfo {
|
||||
name: string
|
||||
path: string
|
||||
type: number= media_type.MEDIA_TYPE_ALBUM
|
||||
size: string
|
||||
dataAdded_time: string
|
||||
modified_time: string
|
||||
mediaType: string
|
||||
thumbnail: Resource
|
||||
font_color: Color | string | Resource
|
||||
opacity: number
|
||||
list_background: string | Resource
|
||||
|
||||
constructor(name: string) {
|
||||
this.name = name
|
||||
}
|
||||
}
|
||||
|
||||
export class TopPathInfo {
|
||||
name: string
|
||||
path: string
|
||||
opacity: number = 1
|
||||
|
||||
constructor(name: string, path: string) {
|
||||
this.name = name
|
||||
this.path = path
|
||||
}
|
||||
}
|
||||
@@ -1,341 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { media_type } from './Constants.ets';
|
||||
import { FileInfo } from '../module/FileInfo.ets'
|
||||
import { LogInfo } from '../module/LogUtils.ets'
|
||||
|
||||
var TAG = 'FileManagerServiceUtils'
|
||||
var isDebug: boolean = true;
|
||||
|
||||
export function getFirstMenu(deviceName: string): Array<FileInfo> {
|
||||
let fileList: Array<FileInfo> = [];
|
||||
if (isDebug) {
|
||||
let file1: FileInfo = new FileInfo('image_album');
|
||||
file1.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
file1.path = 'dataability:///album';
|
||||
file1.size = '';
|
||||
file1.dataAdded_time = 'xxx';
|
||||
file1.modified_time = 'xxx';
|
||||
fileList.push(file1);
|
||||
|
||||
let file2: FileInfo = new FileInfo('video_album');
|
||||
file2.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
file2.path = 'dataability:///album';
|
||||
file2.size = '';
|
||||
file2.dataAdded_time = 'xxx';
|
||||
file2.modified_time = 'xxx';
|
||||
fileList.push(file2);
|
||||
|
||||
let file4: FileInfo = new FileInfo('file_folder');
|
||||
file4.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
file4.path = 'dataability:///album';
|
||||
file4.size = '';
|
||||
file4.dataAdded_time = 'xxx';
|
||||
file4.modified_time = 'xxx';
|
||||
fileList.push(file4);
|
||||
|
||||
let file3: FileInfo = new FileInfo('audio_album');
|
||||
file3.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
file3.path = 'dataability:///album';
|
||||
file3.size = '';
|
||||
file3.dataAdded_time = 'xxx';
|
||||
file3.modified_time = 'xxx';
|
||||
fileList.push(file3);
|
||||
} else {
|
||||
// var fileInfo = filemanager.getRoot(deviceName);
|
||||
}
|
||||
|
||||
fileList.forEach(item => {
|
||||
if (item.name == 'image_album') {
|
||||
item.name = "图片";
|
||||
item.mediaType = 'image';
|
||||
item.thumbnail = $r("app.media.ic_photo")
|
||||
} else if (item.name == 'video_album') {
|
||||
item.name = "视频";
|
||||
item.mediaType = 'video';
|
||||
item.thumbnail = $r("app.media.ic_video")
|
||||
} else if (item.name == 'audio_album') {
|
||||
item.name = "音频";
|
||||
item.mediaType = 'audio';
|
||||
item.thumbnail = $r("app.media.ic_audio")
|
||||
} else if (item.name == 'file_folder') {
|
||||
item.name = "文档";
|
||||
item.mediaType = 'file';
|
||||
item.thumbnail = $r("app.media.ic_document")
|
||||
}
|
||||
});
|
||||
|
||||
return fileList;
|
||||
}
|
||||
|
||||
export function getListFile(deviceName: string, mediaType: string, path: string): Array<FileInfo> {
|
||||
LogInfo(TAG, "getListFile mediaType = " + mediaType + ';path = ' + path);
|
||||
let fileList: Array<FileInfo> = [];
|
||||
if (isDebug) {
|
||||
if (path == 'dataability:///album') {
|
||||
if (mediaType == 'image') {
|
||||
let fileInfo1: FileInfo = new FileInfo("微信的图片");
|
||||
fileInfo1.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
fileInfo1.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/01';
|
||||
fileInfo1.dataAdded_time = 'xxx';
|
||||
fileInfo1.modified_time = 'xxx';
|
||||
fileList.push(fileInfo1);
|
||||
let fileInfo2: FileInfo = new FileInfo("图片1");
|
||||
fileInfo2.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
fileInfo2.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/02';
|
||||
fileInfo2.dataAdded_time = 'xxx';
|
||||
fileInfo2.modified_time = 'xxx';
|
||||
fileList.push(fileInfo2);
|
||||
let fileInfo3: FileInfo = new FileInfo("图片2");
|
||||
fileInfo3.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
fileInfo3.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/03';
|
||||
fileInfo3.dataAdded_time = 'xxx';
|
||||
fileInfo3.modified_time = 'xxx';
|
||||
fileList.push(fileInfo3);
|
||||
let fileInfo4: FileInfo = new FileInfo("图片3");
|
||||
fileInfo4.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
fileInfo4.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/04';
|
||||
fileInfo4.dataAdded_time = 'xxx';
|
||||
fileInfo4.modified_time = 'xxx';
|
||||
fileList.push(fileInfo4);
|
||||
let fileInfo5: FileInfo = new FileInfo("图片4");
|
||||
fileInfo5.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
fileInfo5.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/05';
|
||||
fileInfo5.dataAdded_time = 'xxx';
|
||||
fileInfo5.modified_time = 'xxx';
|
||||
fileList.push(fileInfo5);
|
||||
let fileInfo6: FileInfo = new FileInfo("图片5");
|
||||
fileInfo6.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
fileInfo6.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/06';
|
||||
fileInfo6.dataAdded_time = 'xxx';
|
||||
fileInfo6.modified_time = 'xxx';
|
||||
fileList.push(fileInfo6);
|
||||
let fileInfo7: FileInfo = new FileInfo("图片6");
|
||||
fileInfo7.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
fileInfo7.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/07';
|
||||
fileInfo7.dataAdded_time = 'xxx';
|
||||
fileInfo7.modified_time = 'xxx';
|
||||
fileList.push(fileInfo7);
|
||||
let fileInfo8: FileInfo = new FileInfo("图片7");
|
||||
fileInfo8.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
fileInfo8.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/08';
|
||||
fileInfo8.dataAdded_time = 'xxx';
|
||||
fileInfo8.modified_time = 'xxx';
|
||||
fileList.push(fileInfo8);
|
||||
let fileInfo9: FileInfo = new FileInfo("图片8");
|
||||
fileInfo1.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
fileInfo1.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/09';
|
||||
fileInfo1.dataAdded_time = 'xxx';
|
||||
fileInfo1.modified_time = 'xxx';
|
||||
fileList.push(fileInfo9);
|
||||
let fileInfo10: FileInfo = new FileInfo("图片9");
|
||||
fileInfo10.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
fileInfo10.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/10';
|
||||
fileInfo10.dataAdded_time = 'xxx';
|
||||
fileInfo10.modified_time = 'xxx';
|
||||
fileList.push(fileInfo10);
|
||||
let fileInfo11: FileInfo = new FileInfo("图片10");
|
||||
fileInfo11.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
fileInfo11.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/11';
|
||||
fileInfo11.dataAdded_time = 'xxx';
|
||||
fileInfo11.modified_time = 'xxx';
|
||||
fileList.push(fileInfo11);
|
||||
} else if (mediaType == 'video') {
|
||||
let fileInfo1: FileInfo = new FileInfo("视频0");
|
||||
fileInfo1.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
fileInfo1.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/12';
|
||||
fileInfo1.dataAdded_time = 'xxx';
|
||||
fileInfo1.modified_time = 'xxx';
|
||||
fileList.push(fileInfo1);
|
||||
let fileInfo2: FileInfo = new FileInfo("视频1");
|
||||
fileInfo2.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
fileInfo2.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/13';
|
||||
fileInfo2.dataAdded_time = 'xxx';
|
||||
fileInfo2.modified_time = 'xxx';
|
||||
fileList.push(fileInfo2);
|
||||
let fileInfo3: FileInfo = new FileInfo("视频2");
|
||||
fileInfo3.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
fileInfo3.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/14';
|
||||
fileInfo3.dataAdded_time = 'xxx';
|
||||
fileInfo3.modified_time = 'xxx';
|
||||
fileList.push(fileInfo3);
|
||||
let fileInfo4: FileInfo = new FileInfo("视频3");
|
||||
fileInfo4.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
fileInfo4.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/15';
|
||||
fileInfo4.dataAdded_time = 'xxx';
|
||||
fileInfo4.modified_time = 'xxx';
|
||||
fileList.push(fileInfo4);
|
||||
let fileInfo5: FileInfo = new FileInfo("视频4");
|
||||
fileInfo5.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
fileInfo5.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/16';
|
||||
fileInfo5.dataAdded_time = 'xxx';
|
||||
fileInfo5.modified_time = 'xxx';
|
||||
fileList.push(fileInfo5);
|
||||
} else if (mediaType == 'audio') {
|
||||
let fileInfo1: FileInfo = new FileInfo("音频0");
|
||||
fileInfo1.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
fileInfo1.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/17';
|
||||
fileInfo1.dataAdded_time = 'xxx';
|
||||
fileInfo1.modified_time = 'xxx';
|
||||
fileList.push(fileInfo1);
|
||||
let fileInfo2: FileInfo = new FileInfo("音频1");
|
||||
fileInfo2.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
fileInfo2.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/18';
|
||||
fileInfo2.dataAdded_time = 'xxx';
|
||||
fileInfo2.modified_time = 'xxx';
|
||||
fileList.push(fileInfo2);
|
||||
let fileInfo3: FileInfo = new FileInfo("音频2");
|
||||
fileInfo3.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
fileInfo3.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/19';
|
||||
fileInfo3.dataAdded_time = 'xxx';
|
||||
fileInfo3.modified_time = 'xxx';
|
||||
fileList.push(fileInfo3);
|
||||
let fileInfo4: FileInfo = new FileInfo("音频3");
|
||||
fileInfo4.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
fileInfo4.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/20';
|
||||
fileInfo4.dataAdded_time = 'xxx';
|
||||
fileInfo4.modified_time = 'xxx';
|
||||
fileList.push(fileInfo4);
|
||||
let fileInfo5: FileInfo = new FileInfo("音频4");
|
||||
fileInfo5.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
fileInfo5.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/21';
|
||||
fileInfo5.dataAdded_time = 'xxx';
|
||||
fileInfo5.modified_time = 'xxx';
|
||||
fileList.push(fileInfo5);
|
||||
} else if (mediaType == 'file') {
|
||||
let fileInfo1: FileInfo = new FileInfo("文件夹0");
|
||||
fileInfo1.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
fileInfo1.mediaType = mediaType;
|
||||
fileInfo1.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/22';
|
||||
fileInfo1.dataAdded_time = 'xxx';
|
||||
fileInfo1.modified_time = 'xxx';
|
||||
fileList.push(fileInfo1);
|
||||
let fileInfo2: FileInfo = new FileInfo("文件夹1");
|
||||
fileInfo2.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
fileInfo2.mediaType = mediaType;
|
||||
fileInfo2.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/23';
|
||||
fileInfo2.dataAdded_time = 'xxx';
|
||||
fileInfo2.modified_time = 'xxx';
|
||||
fileList.push(fileInfo2);
|
||||
let fileInfo3: FileInfo = new FileInfo("文件夹2");
|
||||
fileInfo3.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
fileInfo3.mediaType = mediaType;
|
||||
fileInfo3.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/24';
|
||||
fileInfo3.dataAdded_time = 'xxx';
|
||||
fileInfo3.modified_time = 'xxx';
|
||||
fileList.push(fileInfo3);
|
||||
let fileInfo4: FileInfo = new FileInfo("文件夹3");
|
||||
fileInfo4.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
fileInfo4.mediaType = mediaType;
|
||||
fileInfo4.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/25';
|
||||
fileInfo4.dataAdded_time = 'xxx';
|
||||
fileInfo4.modified_time = 'xxx';
|
||||
fileList.push(fileInfo4);
|
||||
let fileInfo5: FileInfo = new FileInfo("文件夹4");
|
||||
fileInfo5.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
fileInfo5.mediaType = mediaType;
|
||||
fileInfo5.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/26';
|
||||
fileInfo5.dataAdded_time = 'xxx';
|
||||
fileInfo5.modified_time = 'xxx';
|
||||
fileList.push(fileInfo5);
|
||||
let fileInfo6: FileInfo = new FileInfo("文本文档.txt");
|
||||
fileInfo6.type = media_type.MEDIA_TYPE_FILE;
|
||||
fileInfo6.mediaType = mediaType;
|
||||
fileInfo6.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/27';
|
||||
fileInfo6.dataAdded_time = 'xxx';
|
||||
fileInfo6.modified_time = 'xxx';
|
||||
fileInfo6.size = '1,024 KB'
|
||||
fileList.push(fileInfo6);
|
||||
let fileInfo7: FileInfo = new FileInfo("验收文稿.ppt");
|
||||
fileInfo7.type = media_type.MEDIA_TYPE_FILE;
|
||||
fileInfo7.mediaType = mediaType;
|
||||
fileInfo7.path = 'dataability:///com.ohos.medialibrary.MediaLibraryDataAbility/file/28';
|
||||
fileInfo7.dataAdded_time = 'xxx';
|
||||
fileInfo7.modified_time = 'xxx';
|
||||
fileInfo7.size = '4,562,000 KB'
|
||||
fileList.push(fileInfo7);
|
||||
}
|
||||
} else {
|
||||
if (mediaType == 'image') {
|
||||
for (var index = 0; index < 10; index++) {
|
||||
let file: FileInfo = new FileInfo("" + index + ".png");
|
||||
file.type = media_type.MEDIA_TYPE_IMAGE;
|
||||
file.path = path + index;
|
||||
file.dataAdded_time = 'xxx';
|
||||
file.modified_time = 'xxx';
|
||||
fileList.push(file);
|
||||
}
|
||||
} else if (mediaType == 'video') {
|
||||
for (var index = 0; index < 15; index++) {
|
||||
let file: FileInfo = new FileInfo("" + index + ".wmv");
|
||||
file.type = media_type.MEDIA_TYPE_VIDEO;
|
||||
file.path = path + index;
|
||||
file.dataAdded_time = 'xxx';
|
||||
file.modified_time = 'xxx';
|
||||
fileList.push(file);
|
||||
}
|
||||
} else if (mediaType == 'audio') {
|
||||
for (var index = 0; index < 18; index++) {
|
||||
let file: FileInfo = new FileInfo("" + index + ".mp3");
|
||||
file.type = media_type.MEDIA_TYPE_AUDIO;
|
||||
file.path = path + index;
|
||||
file.dataAdded_time = 'xxx';
|
||||
file.modified_time = 'xxx';
|
||||
fileList.push(file);
|
||||
}
|
||||
} else if (mediaType == 'file') {
|
||||
let fileInfo4: FileInfo = new FileInfo("文件夹3");
|
||||
fileInfo4.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
fileInfo4.path = path + '5';
|
||||
fileInfo4.dataAdded_time = 'xxx';
|
||||
fileInfo4.modified_time = 'xxx';
|
||||
fileList.push(fileInfo4);
|
||||
let fileInfo5: FileInfo = new FileInfo("文件夹4");
|
||||
fileInfo5.type = media_type.MEDIA_TYPE_ALBUM;
|
||||
fileInfo5.path = path + '6';
|
||||
fileInfo5.dataAdded_time = 'xxx';
|
||||
fileInfo5.modified_time = 'xxx';
|
||||
fileList.push(fileInfo5);
|
||||
let fileInfo6: FileInfo = new FileInfo("文本文档.txt");
|
||||
fileInfo6.type = media_type.MEDIA_TYPE_FILE;
|
||||
fileInfo6.path = path + '7';
|
||||
fileInfo6.size = '1,000 KB'
|
||||
fileInfo6.dataAdded_time = 'xxx';
|
||||
fileInfo6.modified_time = 'xxx';
|
||||
fileList.push(fileInfo6);
|
||||
let fileInfo7: FileInfo = new FileInfo("验收文稿.ppt");
|
||||
fileInfo7.type = media_type.MEDIA_TYPE_FILE;
|
||||
fileInfo7.path = path + '8';
|
||||
fileInfo7.size = '520,000 KB'
|
||||
fileInfo7.dataAdded_time = 'xxx';
|
||||
fileInfo7.modified_time = 'xxx';
|
||||
fileList.push(fileInfo7);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// fileList = filemanager.listfile(deviceName, mediaType, path);
|
||||
}
|
||||
LogInfo(TAG, "get file list is " + fileList.length)
|
||||
return fileList;
|
||||
}
|
||||
|
||||
//保存某个文件,返回是否保存成功,或有错误提示,还需要增加三方应用包名
|
||||
export function saveFile(deviceName: string, name: string, path: string): boolean {
|
||||
LogInfo(TAG, 'saveFile');
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export function LogInfo(TAG: string, message: string | number): void {
|
||||
console.info('filePicker_' + TAG + ': ' + message)
|
||||
}
|
||||
|
||||
export function LogDebug(TAG: string, message: string | number): void {
|
||||
console.debug('filePicker_' + TAG + ': ' + message)
|
||||
}
|
||||
@@ -1,126 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { TopPathInfo } from '../module/FileInfo.ets'
|
||||
import { LogInfo } from '../module/LogUtils.ets'
|
||||
|
||||
var TAG: string = 'Utils'
|
||||
|
||||
export function getRootPath(): Array<TopPathInfo> {
|
||||
var root_path: Array<TopPathInfo> = []
|
||||
root_path.push(new TopPathInfo('文件类型', ''))
|
||||
return root_path
|
||||
}
|
||||
|
||||
var strTypeArr = [
|
||||
['image', '图片'],
|
||||
['video', '视频'],
|
||||
['audio', '音频'],
|
||||
['file', '文档'],
|
||||
]
|
||||
|
||||
export function changeTypeToString(type: string): string {
|
||||
LogInfo(TAG, 'changeTypeToString type = ' + type)
|
||||
for (var i = 0; i < strTypeArr.length; i++) {
|
||||
if (strTypeArr[i][0] == type) {
|
||||
return strTypeArr[i][1]
|
||||
}
|
||||
}
|
||||
return ''
|
||||
}
|
||||
|
||||
export function changeStringToType(type: string): string {
|
||||
LogInfo(TAG, 'changeStringToType type = ' + type)
|
||||
for (var i = 0; i < strTypeArr.length; i++) {
|
||||
if (strTypeArr[i][1] == type) {
|
||||
return strTypeArr[i][0]
|
||||
}
|
||||
}
|
||||
return ''
|
||||
}
|
||||
|
||||
export function getItemNumberInGrid(itemWidth: number, itemGap: number, parentWidth: number): string {
|
||||
LogInfo(TAG, 'getItemNumberInGrid')
|
||||
let columnTemples: string = ''
|
||||
let remainderWidth: number = parentWidth - itemWidth
|
||||
columnTemples += '1fr'
|
||||
while (itemWidth + itemGap < remainderWidth) {
|
||||
remainderWidth = remainderWidth - (itemWidth + itemGap)
|
||||
columnTemples += ' 1fr'
|
||||
}
|
||||
LogInfo(TAG, 'columnTemples = ' + columnTemples)
|
||||
return columnTemples
|
||||
}
|
||||
|
||||
var fileSuffixAndType = [
|
||||
['.doc', $r("app.media.ic_file_doc"), $r("app.string.file_docx")],
|
||||
['.html', $r("app.media.ic_file_html"), $r("app.string.file_html")],
|
||||
['.pdf', $r("app.media.ic_file_pdf"), $r("app.string.file_pdf")],
|
||||
['.pptx', $r("app.media.ic_file_pptx"), $r("app.string.file_pptx")],
|
||||
['.ppt', $r("app.media.ic_file_pptx"), $r("app.string.file_pptx")],
|
||||
['.rar', $r("app.media.ic_file_rar"), $r("app.string.file_rar")],
|
||||
['.txt', $r("app.media.ic_file_txt"), $r("app.string.file_txt")],
|
||||
['.xls', $r("app.media.ic_file_xls"), $r("app.string.file_xls")],
|
||||
['.xml', $r("app.media.ic_file_xml"), $r("app.string.file_xml")],
|
||||
['.zip', $r("app.media.ic_file_zip"), $r("app.string.file_zip")],
|
||||
]
|
||||
|
||||
export function getShowIconBySuffix(suffix: string): string | Resource {
|
||||
LogInfo(TAG, 'getShowIconBySuffix suffix = ' + suffix)
|
||||
for (var i = 0; i < fileSuffixAndType.length; i++) {
|
||||
if (isTwoStringEqual(fileSuffixAndType[i][0].toString(),suffix)) {
|
||||
return fileSuffixAndType[i][1]
|
||||
}
|
||||
}
|
||||
return $r("app.media.ic_file_unknown")
|
||||
}
|
||||
|
||||
export function getShowTextBySuffix(suffix: string): string | Resource {
|
||||
LogInfo(TAG, 'getShowTextBySuffix suffix = ' + suffix)
|
||||
for (var i = 0; i < fileSuffixAndType.length; i++) {
|
||||
if (fileSuffixAndType[i][0] == suffix) {
|
||||
return fileSuffixAndType[i][2]
|
||||
}
|
||||
}
|
||||
return $r("app.string.file_unknown")
|
||||
}
|
||||
|
||||
export function getWarningDialogMessage(code: number): string | Resource {
|
||||
switch (code) {
|
||||
case 1:
|
||||
return $r("app.string.save_file_has_same_file")
|
||||
case 2:
|
||||
return $r("app.string.save_file_no_media_permission")
|
||||
default:
|
||||
return $r("app.string.save_file_unknown_reason")
|
||||
}
|
||||
}
|
||||
|
||||
export function isTwoStringEqual(src: string, tar: string) {
|
||||
if (src.indexOf(tar) == 0 && tar.indexOf(src) == 0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export function updateTopPathInfo(currentPathInfo: Array<TopPathInfo>, name: string, path: string) {
|
||||
currentPathInfo.forEach((item: TopPathInfo) => {
|
||||
item.opacity = 0.4
|
||||
})
|
||||
|
||||
currentPathInfo.push(new TopPathInfo(name, path))
|
||||
AppStorage.Set('topPathInfo', currentPathInfo)
|
||||
return currentPathInfo
|
||||
}
|
||||
@@ -13,78 +13,77 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { FileInfo } from '../module/FileInfo'
|
||||
import { LogInfo } from '../module/LogUtils'
|
||||
import { menuLevel } from '../module/Constants'
|
||||
import { FileInfo } from '../../../../../../common/src/main/ets/components/Data/FileInfo'
|
||||
import { MenuLevel } from '../../../../../../common/src/main/ets/components/Data/Constants'
|
||||
|
||||
@Component
|
||||
export struct FirstLevelByType {
|
||||
private TAG: string = 'FirstLevelByType'
|
||||
private mWorker
|
||||
private mFileList: FileInfo[]
|
||||
@Link mType: string
|
||||
@Link mMenuLevel: number
|
||||
@Link mCurrentPath: string
|
||||
private TAG: string = 'FirstLevelByType'
|
||||
private mWorker
|
||||
private mFileList: FileInfo[]
|
||||
@Link mType: string
|
||||
@Link mMenuLevel: number
|
||||
@Link mCurrentPath: string
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
ForEach(this.mFileList, (item: FileInfo, index: number) => {
|
||||
build() {
|
||||
Column() {
|
||||
RowView({
|
||||
item: item,
|
||||
mMenuLevel: $mMenuLevel,
|
||||
mType: $mType,
|
||||
mCurrentPath: $mCurrentPath
|
||||
})
|
||||
ForEach(this.mFileList, (item: FileInfo, index: number) => {
|
||||
Column() {
|
||||
RowView({
|
||||
item: item,
|
||||
mMenuLevel: $mMenuLevel,
|
||||
mType: $mType,
|
||||
mCurrentPath: $mCurrentPath
|
||||
})
|
||||
|
||||
Divider()
|
||||
.color('#000000')
|
||||
.opacity(0.1)
|
||||
.visibility(this.mFileList.length == index + 1 ? Visibility.Hidden : Visibility.Visible)
|
||||
.margin({ left: 40 })
|
||||
Divider()
|
||||
.color('#000000')
|
||||
.opacity(0.1)
|
||||
.visibility(this.mFileList.length == index + 1 ? Visibility.Hidden : Visibility.Visible)
|
||||
.margin({ left: 40 })
|
||||
}
|
||||
.width('100%')
|
||||
.height(56)
|
||||
}, item => item.name.toString())
|
||||
}
|
||||
.padding({ top: 4, bottom: 4, right: 12, left: 12 })
|
||||
.alignItems(HorizontalAlign.Start) // 导致圆角消失
|
||||
.border({ radius: 24 })
|
||||
.opacity(0.9)
|
||||
.backgroundColor('#FFFFFF')
|
||||
.width('100%')
|
||||
.height(56)
|
||||
}, item => item.name.toString())
|
||||
}
|
||||
.padding({ top: 4, bottom: 4, right: 12, left: 12 })
|
||||
.alignItems(HorizontalAlign.Start) // 导致圆角消失
|
||||
.border({ radius: 24 })
|
||||
.opacity(0.9)
|
||||
.backgroundColor('#FFFFFF')
|
||||
.width('100%')
|
||||
}
|
||||
}
|
||||
|
||||
@Component
|
||||
struct RowView {
|
||||
private item: FileInfo = new FileInfo('')
|
||||
@Link mMenuLevel: number
|
||||
@Link mType: string
|
||||
@Link mCurrentPath: string
|
||||
private item: FileInfo = new FileInfo('')
|
||||
@Link mMenuLevel: number
|
||||
@Link mType: string
|
||||
@Link mCurrentPath: string
|
||||
|
||||
build() {
|
||||
Row() {
|
||||
Image($r("app.media.ic_type_smallfile"))
|
||||
.width(24)
|
||||
.height(24)
|
||||
Text(this.item.name)
|
||||
.fontSize(16)
|
||||
.fontColor('#182431')
|
||||
.fontWeight(FontWeight.Medium)
|
||||
.margin({ left: 16 })
|
||||
Blank()
|
||||
Image($r("app.media.ic_right"))
|
||||
.width(12)
|
||||
.height(24)
|
||||
build() {
|
||||
Row() {
|
||||
Image($r("app.media.ic_type_smallfile"))
|
||||
.width(24)
|
||||
.height(24)
|
||||
Text(this.item.name)
|
||||
.fontSize(16)
|
||||
.fontColor('#182431')
|
||||
.fontWeight(FontWeight.Medium)
|
||||
.margin({ left: 16 })
|
||||
Blank()
|
||||
Image($r("app.media.ic_right"))
|
||||
.width(12)
|
||||
.height(24)
|
||||
}
|
||||
.height(56)
|
||||
.width('100%') // TODO
|
||||
.backgroundColor(this.item.list_background)
|
||||
.onClick(() => {
|
||||
this.mType = this.item.mediaType
|
||||
this.mCurrentPath = this.item.path
|
||||
this.mMenuLevel = MenuLevel.MENU_SECOND_LEVEL_BY_FOLD
|
||||
})
|
||||
}
|
||||
.height(56)
|
||||
.width('100%') // TODO
|
||||
.backgroundColor(this.item.list_background)
|
||||
.onClick(() => {
|
||||
this.mType = this.item.mediaType
|
||||
this.mCurrentPath = this.item.path
|
||||
this.mMenuLevel = menuLevel.MENU_SECOND_LEVEL_BY_FOLD
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -13,125 +13,125 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { FileInfo } from '../module/FileInfo'
|
||||
import { changeTypeToString, updateTopPathInfo } from '../module/Utils'
|
||||
import { LogInfo, LogDebug } from '../module/LogUtils'
|
||||
import { menuLevel } from '../module/Constants'
|
||||
import { getListFile } from '../module/FileManagerServiceUtils'
|
||||
import { MenuLevel } from '../../../../../../common/src/main/ets/components/Data/Constants'
|
||||
import { FileInfo } from '../../../../../../common/src/main/ets/components/Data/FileInfo'
|
||||
import { getListFile } from '../../../../../../common/src/main/ets/components/Utils/FileManagerServiceUtils'
|
||||
import { logDebug, logInfo } from '../../../../../../common/src/main/ets/components/Utils/LogUtils'
|
||||
import { changeTypeToString, updateTopPathInfo } from '../../../../../../common/src/main/ets/components/utils/Utils'
|
||||
|
||||
let TAG: string = 'SecondLevelByFold'
|
||||
|
||||
@Component
|
||||
export struct SecondLevelByFold {
|
||||
private mWorker
|
||||
@Link mFileList: FileInfo[]
|
||||
@Link @Watch('fileTypeChange') mType: string
|
||||
@Link mMenuLevel: number
|
||||
@Link mCurrentPath: string
|
||||
private mWorker
|
||||
@Link mFileList: FileInfo[]
|
||||
@Link @Watch('fileTypeChange') mType: string
|
||||
@Link mMenuLevel: number
|
||||
@Link mCurrentPath: string
|
||||
|
||||
aboutToAppear(): void{
|
||||
LogInfo(TAG, 'aboutToAppear')
|
||||
if (globalThis.debugMode) {
|
||||
this.mFileList = getListFile('local', this.mType, this.mCurrentPath)
|
||||
LogDebug(TAG, 'mFileList length = ' + this.mFileList.length)
|
||||
} else {
|
||||
this.mWorker.postMessage({
|
||||
request_data: 'listFile',
|
||||
device_name: 'local',
|
||||
menu_level: this.mMenuLevel,
|
||||
media_type: this.mType,
|
||||
path: this.mCurrentPath
|
||||
})
|
||||
}
|
||||
|
||||
updateTopPathInfo([], '文件类型', '')
|
||||
updateTopPathInfo(AppStorage.Get('topPathInfo'), changeTypeToString(this.mType), this.mCurrentPath)
|
||||
}
|
||||
|
||||
fileTypeChange() {
|
||||
LogInfo(TAG, 'fileTypeChange ' + this.mType)
|
||||
if (globalThis.debugMode) {
|
||||
this.mFileList = getListFile('local', this.mType, this.mCurrentPath)
|
||||
} else {
|
||||
this.mWorker.postMessage({
|
||||
request_data: 'listFile',
|
||||
device_name: 'local',
|
||||
menu_level: this.mMenuLevel,
|
||||
media_type: this.mType,
|
||||
path: this.mCurrentPath
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
ForEach(this.mFileList, (item: FileInfo, index: number) => {
|
||||
Column() {
|
||||
SecondRowView({
|
||||
item: item,
|
||||
mMenuLevel: $mMenuLevel,
|
||||
mCurrentPath: $mCurrentPath,
|
||||
isType: $mType
|
||||
})
|
||||
|
||||
Divider()
|
||||
.color('#000000')
|
||||
.opacity(0.05)
|
||||
.visibility(this.mFileList.length == index + 1 ? Visibility.Hidden : Visibility.Visible)
|
||||
.margin({ left: 40 })
|
||||
aboutToAppear(): void{
|
||||
logInfo(TAG, 'aboutToAppear')
|
||||
if (globalThis.debugMode) {
|
||||
this.mFileList = getListFile('local', this.mType, this.mCurrentPath)
|
||||
logDebug(TAG, 'mFileList length = ' + this.mFileList.length)
|
||||
} else {
|
||||
this.mWorker.postMessage({
|
||||
request_data: 'listFile',
|
||||
device_name: 'local',
|
||||
menu_level: this.mMenuLevel,
|
||||
MediaType: this.mType,
|
||||
path: this.mCurrentPath
|
||||
})
|
||||
}
|
||||
.width('100%')
|
||||
.height(56)
|
||||
}, item => item.name.toString())
|
||||
|
||||
updateTopPathInfo([], '文件类型', '')
|
||||
updateTopPathInfo(AppStorage.Get('topPathInfo'), changeTypeToString(this.mType), this.mCurrentPath)
|
||||
}
|
||||
|
||||
fileTypeChange() {
|
||||
logInfo(TAG, 'fileTypeChange ' + this.mType)
|
||||
if (globalThis.debugMode) {
|
||||
this.mFileList = getListFile('local', this.mType, this.mCurrentPath)
|
||||
} else {
|
||||
this.mWorker.postMessage({
|
||||
request_data: 'listFile',
|
||||
device_name: 'local',
|
||||
menu_level: this.mMenuLevel,
|
||||
MediaType: this.mType,
|
||||
path: this.mCurrentPath
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
ForEach(this.mFileList, (item: FileInfo, index: number) => {
|
||||
Column() {
|
||||
SecondRowView({
|
||||
item: item,
|
||||
mMenuLevel: $mMenuLevel,
|
||||
mCurrentPath: $mCurrentPath,
|
||||
isType: $mType
|
||||
})
|
||||
|
||||
Divider()
|
||||
.color('#000000')
|
||||
.opacity(0.05)
|
||||
.visibility(this.mFileList.length == index + 1 ? Visibility.Hidden : Visibility.Visible)
|
||||
.margin({ left: 40 })
|
||||
}
|
||||
.width('100%')
|
||||
.height(56)
|
||||
}, item => item.name.toString())
|
||||
}
|
||||
.padding({ top: 4, bottom: 4, left: 12, right: 12 })
|
||||
.width('100%')
|
||||
.alignItems(HorizontalAlign.Start)
|
||||
.border({ radius: 24 })
|
||||
.opacity(0.9)
|
||||
.backgroundColor(Color.White)
|
||||
}
|
||||
.padding({ top: 4, bottom: 4, left: 12, right: 12 })
|
||||
.width('100%')
|
||||
.alignItems(HorizontalAlign.Start)
|
||||
.border({ radius: 24 })
|
||||
.opacity(0.9)
|
||||
.backgroundColor(Color.White)
|
||||
}
|
||||
}
|
||||
|
||||
@Component
|
||||
struct SecondRowView {
|
||||
private item: FileInfo = new FileInfo('')
|
||||
@Link mMenuLevel: number
|
||||
@Link mCurrentPath: string
|
||||
@Link isType: string
|
||||
private item: FileInfo = new FileInfo('')
|
||||
@Link mMenuLevel: number
|
||||
@Link mCurrentPath: string
|
||||
@Link isType: string
|
||||
|
||||
build() {
|
||||
Row() {
|
||||
Image($r("app.media.ic_type_smallfile"))
|
||||
.width(24)
|
||||
.height(24)
|
||||
Text(this.item.name)
|
||||
.fontSize(16)
|
||||
.fontColor('#182431')
|
||||
.fontWeight(FontWeight.Medium)
|
||||
.margin({ left: 17 })
|
||||
Blank()
|
||||
Image($r("app.media.ic_right"))
|
||||
.width(12)
|
||||
.height(24)
|
||||
}
|
||||
.height(56)
|
||||
.width('100%') // TODO
|
||||
.backgroundColor(this.item.list_background)
|
||||
.onClick(() => {
|
||||
LogInfo(TAG, 'onClick this.mCurrentPath = ' + this.mCurrentPath)
|
||||
this.mCurrentPath = this.item.path
|
||||
updateTopPathInfo(AppStorage.Get('topPathInfo'), this.item.name, this.mCurrentPath)
|
||||
|
||||
if (this.item.path.includes('dataability:///album') == false) {
|
||||
if (this.isType != 'file') {
|
||||
LogInfo(TAG, 'MENU_THIRD_LEVEL_HAS_PIC - onClick')
|
||||
this.mMenuLevel = menuLevel.MENU_THIRD_LEVEL_HAS_PIC
|
||||
} else {
|
||||
this.mMenuLevel = menuLevel.MENU_THIRD_LEVEL_HAS_DETAIL
|
||||
LogInfo(TAG, 'MENU_THIRD_LEVEL_HAS_DETAIL - onClick')
|
||||
build() {
|
||||
Row() {
|
||||
Image($r("app.media.ic_type_smallfile"))
|
||||
.width(24)
|
||||
.height(24)
|
||||
Text(this.item.name)
|
||||
.fontSize(16)
|
||||
.fontColor('#182431')
|
||||
.fontWeight(FontWeight.Medium)
|
||||
.margin({ left: 17 })
|
||||
Blank()
|
||||
Image($r("app.media.ic_right"))
|
||||
.width(12)
|
||||
.height(24)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
.height(56)
|
||||
.width('100%') // TODO
|
||||
.backgroundColor(this.item.list_background)
|
||||
.onClick(() => {
|
||||
logInfo(TAG, 'onClick this.mCurrentPath = ' + this.mCurrentPath)
|
||||
this.mCurrentPath = this.item.path
|
||||
updateTopPathInfo(AppStorage.Get('topPathInfo'), this.item.name, this.mCurrentPath)
|
||||
|
||||
if (this.item.path.includes('dataability:///album') == false) {
|
||||
if (this.isType != 'file') {
|
||||
logInfo(TAG, 'MENU_THIRD_LEVEL_HAS_PIC - onClick')
|
||||
this.mMenuLevel = MenuLevel.MENU_THIRD_LEVEL_HAS_PIC
|
||||
} else {
|
||||
this.mMenuLevel = MenuLevel.MENU_THIRD_LEVEL_HAS_DETAIL
|
||||
logInfo(TAG, 'MENU_THIRD_LEVEL_HAS_DETAIL - onClick')
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||