!419 【图库】删除弹窗需求合入

Merge pull request !419 from yangweiyi/master
This commit is contained in:
openharmony_ci 2023-08-07 02:34:57 +00:00 committed by Gitee
commit 8601b70101
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
15 changed files with 633 additions and 10 deletions

View File

@ -188,6 +188,8 @@ export { AlbumSetNewMenuOperation } from './src/main/ets/default/view/browserOpe
export { BatchDeleteMenuOperation } from './src/main/ets/default/view/browserOperation/BatchDeleteMenuOperation';
export { ThirdDeleteOperation } from './src/main/ets/default/view/browserOperation/ThirdDeleteOperation';
export { DeleteMenuOperation } from './src/main/ets/default/view/browserOperation/DeleteMenuOperation';
export { AddMenuOperation } from './src/main/ets/default/view/browserOperation/AddMenuOperation';

View File

@ -18,6 +18,7 @@ export class BroadCastConstants {
static readonly GROUP_SELECT: string = 'groupSelect';
static readonly JUMP_PHOTO_BROWSER: string = 'JumpPhotoPage';
static readonly SHOW_DELETE_DIALOG: string = 'showDeleteDialog';
static readonly SHOW_THIRD_DELETE_DIALOG = 'showThirdDeleteDialog';
static readonly SHOW_REMOVE_DIALOG: string = 'showRemoveDialog';
static readonly UPDATE_PROGRESS: string = 'updateProgress';
static readonly CANCEL_DELETE: string = 'cancelDelete';

View File

@ -175,6 +175,9 @@ export class Constants {
// Other equipment tab index
static readonly OTHER_EQUIPMENT_TAB_INDEX: number = 1;
//the constant for action of the want
static readonly ACTION_DELETE_DATA: string = 'ohos.want.action.deleteDialog';
// editor used
static readonly UPDATE_MENU: string = 'updateMenu';
static readonly UPDATE_DOODLE_STYLE: string = 'update_doodle_style';

View File

@ -74,12 +74,8 @@ export class ScreenManager {
private constructor() {
Log.info(TAG, 'constructor');
UiUtil.getResourceString($r('app.string.init_horizontal')).then((value: string) => {
this.horizontal = 'true' === value;
})
UiUtil.getResourceString($r('app.string.init_sidebar')).then((value: string) => {
this.sidebar = 'true' === value;
})
this.horizontal = false;
this.sidebar = false;
}
static getInstance(): ScreenManager {
@ -140,6 +136,10 @@ export class ScreenManager {
this.broadcast.off(event, fn);
}
setWinWidth(width: number): void{
this.winWidth = width;
}
// Unitvp
getWinWidth(): number {
return this.winWidth;
@ -350,9 +350,10 @@ export class ScreenManager {
}
getColumnsWidth(count: number): number {
Log.info(TAG, `getColumnsWidth count is ${count} colunms is ${this.columns}`);
let columnWidth: number = (this.winWidth - Constants.COLUMN_MARGIN) / this.columns;
return parseInt((columnWidth * count - Constants.COLUMN_GUTTER) + '');
columnWidth = parseInt((columnWidth * count - Constants.COLUMN_GUTTER) + '');
Log.info(TAG, `getColumnsWidth count is ${count} colunms is ${this.columns}, columnWidth is ${columnWidth} `);
return columnWidth;
}
getScreenColumns(): number {

View File

@ -24,6 +24,7 @@ export class MenuContext {
albumUri: string;
selectManager: SelectManager;
onOperationStart: Function;
onOperationCancel: Function;
onOperationEnd: Function;
broadCast: BroadCast
latlng: number[];
@ -54,6 +55,11 @@ export class MenuContext {
return this;
}
withOperationCancelCallback(onOperationCancel: Function): MenuContext {
this.onOperationCancel = onOperationCancel;
return this;
}
withOperationEndCallback(onOperationEnd: Function): MenuContext {
this.onOperationEnd = onOperationEnd;
return this;

View File

@ -0,0 +1,131 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Log } from '../../utils/Log';
import { SelectManager } from '../../model/browser/SelectManager';
import { MenuContext } from './MenuContext';
import { BrowserOperationFactory } from '../../interface/BrowserOperationFactory';
import { BroadCastConstants } from '../../model/common/BroadCastConstants';
import { ProcessMenuOperation } from './ProcessMenuOperation';
import { TraceControllerUtils } from '../../utils/TraceControllerUtils';
import { BigDataConstants, ReportToBigDataUtil } from '../../utils/ReportToBigDataUtil';
import { Constants } from '../../model/common/Constants';
const TAG = "ThirdDeleteMenuOperation"
export class ThirdDeleteOperation extends ProcessMenuOperation {
private isTrash = true;
constructor(menuContext: MenuContext) {
super(menuContext);
this.callback = this.callback.bind(this);
}
setConfirmText(): void {
if (!this.isTrash) {
AppStorage.SetOrCreate<Resource>(Constants.CONFIRM_TEXT_KEY, $r('app.string.dialog_delete_permanently'));
} else {
AppStorage.SetOrCreate<Resource>(Constants.CONFIRM_TEXT_KEY, $r('app.string.dialog_delete'));
}
}
doAction(): void {
if (this.menuContext == null) {
Log.warn(TAG, 'menuContext is null, return');
return;
}
let selectManager: SelectManager = this.menuContext.selectManager;
if (selectManager == null) {
Log.warn(TAG, 'selectManager is null, return');
return;
}
this.count = selectManager.getSelectedCount();
if (this.count <= 0) {
Log.warn(TAG, 'count <= 0, return');
return;
}
this.confirmCallback = this.confirmCallback.bind(this);
this.cancelCallback = this.cancelCallback.bind(this);
this.setConfirmText();
this.menuContext.broadCast.emit(BroadCastConstants.SHOW_THIRD_DELETE_DIALOG,
[(this.count == 1 ? $r('app.string.recycle_single_file_tips') :
$r('app.string.recycle_files_tips', this.count)), this.confirmCallback, this.cancelCallback]);
}
// Asynchronous callback for getSelection
callback(uris: string[]): void {
if (this.isCancelled) {
return;
}
this.uris = uris;
this.processOperation();
}
// Delete a batch of data
async requestOneBatchOperation(): Promise<void> {
Log.info(TAG, `requestOneBatchOperation`);
if (this.isCancelled) {
return;
}
this.currentBatch++;
let startIndex: number = (this.currentBatch - 1) * this.BATCH_SIZE;
let endIndex: number = this.currentBatch * this.BATCH_SIZE;
let batchUris: string[] = this.uris.slice(startIndex, Math.min(endIndex, this.uris.length));
let operationImpl = BrowserOperationFactory.getFeature(BrowserOperationFactory.TYPE_PHOTO);
TraceControllerUtils.startTraceWithTaskId('trash', this.currentBatch)
operationImpl.trash(batchUris[0], true).then(() => {
TraceControllerUtils.finishTraceWithTaskId('trash', this.currentBatch)
this.onCompleted()
}).catch((error) => {
Log.error(TAG, `delete error: ${error}`);
this.onError();
})
}
confirmCallback(): void {
Log.info(TAG, 'Batch delete confirm');
// 1. Variable initialization
this.onOperationEnd = this.menuContext.onOperationEnd;
// 2. selectManager gets the URI of the data and starts processing deletion in the callback
if (this.menuContext.albumInfo && this.menuContext.albumInfo.isTrashAlbum) {
this.menuContext.selectManager.getDeleteSelection(this);
} else {
this.menuContext.selectManager.getSelection(this);
}
// 3. onDeleteStart exit selection mode
let onOperationStart: Function = this.menuContext.onOperationStart;
onOperationStart && onOperationStart();
let msg = {
'type': BigDataConstants.DELETE_LOCAL_ONLY,
'FovMode': 0
}
ReportToBigDataUtil.report(BigDataConstants.DELETE_TYPE_ID, msg);
this.menuContext.broadCast.emit(BroadCastConstants.DELETE_PROGRESS_DIALOG,
[$r('app.string.action_delete'), this.count]);
}
cancelCallback(): void {
Log.info(TAG, 'Batch delete cancel');
let onOperationCancel: Function = this.menuContext.onOperationCancel;
onOperationCancel && onOperationCancel();
}
}

View File

@ -20,6 +20,7 @@ import { Log } from '../../utils/Log';
import { DetailsDialog, MediaDetails } from './DetailsDialog';
import { MultiSelectDetails, MultiSelectDialog } from './MultiSelectDialog';
import { DeleteDialog } from './DeleteDialog';
import { ThirdDeleteDialog } from './ThirdDeleteDialog';
import { RemoveDialog } from './RemoveDialog';
import type { DialogCallback } from '../../model/common/DialogUtil';
import { MediaItem } from '../../model/browser/photo/MediaItem';
@ -92,6 +93,7 @@ export struct CustomDialogView {
dialogController: CustomDialogController;
multiSelectDialog: CustomDialogController;
deleteDialogController: CustomDialogController;
thirdDeleteDialogController: CustomDialogController;
removeDialogController: CustomDialogController;
deleteProgressDialogController: CustomDialogController;
removeProgressDialogController: CustomDialogController;
@ -140,6 +142,17 @@ export struct CustomDialogView {
customStyle: true
});
this.thirdDeleteDialogController = new CustomDialogController({
builder: ThirdDeleteDialog(),
autoCancel: false,
alignment: this.isHorizontal ? DialogAlignment.Center : DialogAlignment.Bottom,
offset: {
dx: 0,
dy: this.isHorizontal || this.isSidebar ? 0 : $r('app.float.dialog_offset_bottom')
},
customStyle: true
});
this.removeDialogController = new CustomDialogController({
builder: RemoveDialog(),
autoCancel: false,
@ -277,6 +290,8 @@ export struct CustomDialogView {
this.multiSelectDialog = undefined;
delete this.deleteDialogController;
this.deleteDialogController = undefined;
delete this.thirdDeleteDialogController;
this.thirdDeleteDialogController = undefined;
delete this.removeDialogController;
this.removeDialogController = undefined;
delete this.deleteProgressDialogController;
@ -347,6 +362,14 @@ export struct CustomDialogView {
self.deleteDialogController.open();
});
this.broadCast.on(BroadCastConstants.SHOW_THIRD_DELETE_DIALOG,
function (deleteMessage: Resource, confirmCallback: Function, cancelCallback?: Function) {
Log.info(TAG, 'SHOW_THIRD_DELETE_DIALOG ');
self.dialogMessage = deleteMessage;
self.dialogCallback = { confirmCallback: confirmCallback, cancelCallback: cancelCallback };
self.thirdDeleteDialogController.open();
});
this.broadCast.on(BroadCastConstants.SHOW_REMOVE_DIALOG,
function (removeMessage: Resource, confirmCallback: Function, cancelCallback?: Function) {
Log.info(TAG, 'SHOW_REMOVE_DIALOG ');

View File

@ -0,0 +1,150 @@
/*
* 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 type { DialogCallback } from '../../model/common/DialogUtil';
import { Log } from '../../utils/Log';
import { ColumnSize, ScreenManager } from '../../model/common/ScreenManager';
import { Constants } from '../../model/common/Constants';
@CustomDialog
export struct ThirdDeleteDialog {
private TAG: string = 'DeleteDialog'
@StorageLink('isHorizontal') isHorizontal: boolean = ScreenManager.getInstance().isHorizontal();
@StorageLink('leftBlank') leftBlank: [number, number, number, number] = [0, 0, 0, 0];
@Consume dialogCallback: DialogCallback;
@Consume dialogMessage: Resource;
@StorageLink('confirmText') confirmText: Resource = $r('app.string.dialog_delete');
controller: CustomDialogController;
private uris: any;
private thirdAppName: string;
aboutToAppear() {
this.uris = AppStorage.Get("uris");
this.thirdAppName = AppStorage.Get("appName");
}
build() {
Column() {
Column() {
Stack({ alignContent: Alignment.Bottom}) {
if(this.uris.length > 1) {
Image(this.uris[1])
.objectFit(ImageFit.Cover)
.border({ radius: $r('sys.float.ohos_id_corner_radius_default_m')})
.height($r('app.float.third_delete_dialog_ico_height'))
.width('100%')
.opacity(0.4)
.padding({ left: $r('app.float.third_delete_dialog_second_ico_margin'),
right: $r('app.float.third_delete_dialog_second_ico_margin')})
}
Image(this.uris[0])
.objectFit(ImageFit.Cover)
.border({ radius: $r('sys.float.ohos_id_corner_radius_default_m')})
.height(this.uris.length > 1 ? $r('app.float.third_delete_dialog_ico_height_multi'):
$r('app.float.third_delete_dialog_ico_height'))
.width('100%')
.margin({ bottom: this.uris.length > 1 ? $r('app.float.dialog_button_and_text_margin') :
$r('app.float.dialog_offset_bottom')})
}
Text($r('app.string.third_delete_dialog_message', this.thirdAppName, this.uris.length))
.textAlign(TextAlign.Center)
.fontSize($r('sys.float.ohos_id_text_size_body1'))
.fontWeight(FontWeight.Regular)
.fontColor($r('sys.color.ohos_id_color_text_primary'))
.margin({ top: $r('app.float.first_delete_dialog_ico_margin_bottom')})
}
.alignItems(HorizontalAlign.Center)
.width('100%')
.margin({
top: $r('app.float.dialog_content_margin'),
bottom: $r('app.float.dialog_button_and_text_margin'),
})
Stack({ alignContent: Alignment.Top }) {
Row() {
Column() {
Button() {
Text($r('app.string.dialog_cancel'))
.fontSize($r('sys.float.ohos_id_text_size_button1'))
.fontColor($r('app.color.color_control_highlight'))
.fontWeight(FontWeight.Medium)
.width('100%')
.textAlign(TextAlign.Center)
}
.margin({
right: $r('app.float.dialog_double_buttons_margin')
})
.backgroundColor($r('app.color.transparent'))
.height($r('app.float.details_dialog_button_height'))
.onClick(() => {
Log.debug(this.TAG, `cancelCallback`);
this.controller.close();
this.dialogCallback && this.dialogCallback.cancelCallback();
})
}.width('50%')
Divider()
.vertical(true)
.height(Constants.DEFAULT_DIVIDER_HEIGHT)
.color(Constants.DEFAULT_DIVIDER_COLOR)
Column() {
Button() {
Text(this.confirmText)
.fontSize($r('sys.float.ohos_id_text_size_button1'))
.fontColor($r('sys.color.ohos_id_color_warning'))
.fontWeight(FontWeight.Medium)
.width('100%')
.textAlign(TextAlign.Center)
}
.margin({
left: $r('app.float.dialog_double_buttons_margin'),
})
.backgroundColor($r('app.color.transparent'))
.height($r('app.float.details_dialog_button_height'))
.onClick(() => {
Log.debug(this.TAG, `confirmCallback`);
this.controller.close();
this.dialogCallback && this.dialogCallback.confirmCallback();
})
}.width('50%')
}
}
.width('100%')
.height($r('app.float.details_dialog_button_area_height'))
}
.borderRadius($r('sys.float.ohos_id_corner_radius_default_m'))
.width(ScreenManager.getInstance().getColumnsWidth(ColumnSize.COLUMN_FOUR))
.backgroundColor($r('app.color.white'))
.margin({
right: $r('app.float.dialog_window_margin'),
left: $r('app.float.dialog_window_margin'),
bottom: this.isHorizontal ? 0 : Constants.DIALOG_BOTTOM_OFFSET + px2vp(this.leftBlank[3])
})
.padding({ left: $r('app.float.dialog_content_margin'), right: $r('app.float.dialog_content_margin') })
.alignItems(HorizontalAlign.Center)
.shadow({
radius: $r('app.float.dialog_defult_shadow_m_radio'),
color: $r('app.color.dialog_defult_shadow_m_color'),
offsetX: $r('app.float.dialog_defult_shadow_m_offsetX'),
offsetY: $r('app.float.dialog_defult_shadow_m_offsetY')
})
}
}

View File

@ -1307,6 +1307,26 @@
{
"name": "FA_ListCard_toggle_height",
"value": "20vp"
},
{
"name": "third_delete_dialog_ico_height",
"value": "180vp"
},
{
"name": "third_delete_dialog_ico_height_multi",
"value": "172vp"
},
{
"name": "third_delete_dialog_second_ico_margin",
"value": "16vp"
},
{
"name": "third_delete_dialog_button_area_height",
"value": "56vp"
},
{
"name": "ohos_id_corner_radius_default_m",
"value": "12vp"
}
]
}

View File

@ -723,6 +723,10 @@
{
"name":"album_photos",
"value":"Photos"
},
{
"name": "third_delete_dialog_message",
"value": "Whether allow %s to delete %d files"
}
]
}

View File

@ -723,6 +723,10 @@
{
"name":"album_photos",
"value":"图片"
},
{
"name": "third_delete_dialog_message",
"value": "是否允许 %s 删除 %d 个文件?"
}
]
}

View File

@ -0,0 +1,146 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {
Constants,
ScreenManager,
UserFileManagerAccess,
MediaObserver,
Log
} from '@ohos/common';
import display from '@ohos.display';
import Extension from '@ohos.app.ability.ServiceExtensionAbility';
import Window from '@ohos.window';
import dialogRequest from '@ohos.app.ability.dialogRequest';
const TAG: string = 'ServiceExtAbility';
export default class ServiceExtAbility extends Extension {
onCreate(want) {
Log.info(TAG, `ServiceExtAbility want param : ${JSON.stringify(want)}`);
globalThis.windowClass = null;
globalThis.photoAbilityContext = this.context;
AppStorage.SetOrCreate(Constants.SCREEN_SIDEBAR, false);
AppStorage.SetOrCreate("deviceType", Constants.DEFAULT_DEVICE_TYPE);
}
onRequest(want, startId) {
if (want.action != Constants.ACTION_DELETE_DATA) {
return;
}
UserFileManagerAccess.getInstance().onCreate(globalThis.photosAbilityContext);
MediaObserver.getInstance().registerForAllPhotos();
MediaObserver.getInstance().registerForAllAlbums();
let wantParam: {[key:string]: object} = want.parameters;
let uris: any = wantParam?.uris;
let appName: string = wantParam?.appName as unknown as string;
Log.info(TAG, `get delete data : ${JSON.stringify(wantParam)}}`);
if (uris == undefined || uris.length ===0) {
return;
}
AppStorage.SetOrCreate("uris", uris);
AppStorage.SetOrCreate("appName", appName);
let windowClass = globalThis.windowClassg;
try {
let config = {
name: "DeleteDialog " + appName + Math.random(), windowType: Window.WindowType.TYPE_DIALOG, ctx: this.context
}
try {
Window.createWindow(config, (err, data) => {
if (err.code) {
Log.info(TAG, `Failed to create the window. Cause : ${JSON.stringify(err)}`);
return;
}
windowClass = data;
Log.info(TAG, `Success ded in creating the window. Data : ${JSON.stringify(data)}`);
try {
let requestInfo = dialogRequest.getRequestInfo(want);
Log.info(TAG, `requestInfo param : ${JSON.stringify(requestInfo)}`);
var requestCallback = dialogRequest.getRequestCallback(want);
AppStorage.SetOrCreate("requestCallback", requestCallback);
Log.info(TAG, `Succeeded in get requestCallback`);
windowClass.bindDialogTarget(requestInfo, () => {
Log.info(TAG, 'Dialog Window Need Destroy.');
}, (err) => {
Log.error(TAG, 'Dialog bindDialogTarget err');
if (err.code) {
Log.error(TAG, `Failed to bind dialog target. Cause : ${JSON.stringify(err)}`);
return;
}
Log.error(TAG, 'Succeeded in binding dialog target.');
try {
windowClass.setUIContent('pages/ResourceDeletePage', (err) => {
if (err.code) {
Log.error(TAG, `Failed to load the content. Cause : ${JSON.stringify(err)}`);
return;
}
Log.error(TAG, `Succeeded in loading the content`);
let promise = display.getDefaultDisplay();
promise.then((data) => {
Log.error(TAG, `Succeeded in loading the content, width : ${data.width}, height : ${data.height}`);
ScreenManager.getInstance().setWinWidth(px2vp(data.width));
windowClass.resetSize(data.width, data.height);
windowClass.setBackgroundColor('#00000000');
windowClass.show();
})
})
} catch (err) {
Log.error(TAG, `getDefaultDisplay fail : ${JSON.stringify(err)}`);
}
})
Log.info(TAG, 'bindDialogTarget done');
} catch (exception) {
Log.error(TAG, `Failed to load the content. Cause : ${JSON.stringify(exception)}`);
}
})
} catch (exception) {
Log.error(TAG, `Failed to bind the window. Cause : ${JSON.stringify(exception)}`);
}
} catch {
Log.error(TAG, `Failed`);
}
globalThis.onStart1 = (() => {
try {
Log.info(TAG, 'test start1');
windowClass.destroyWindow((err) => {
if (err.code) {
Log.info(TAG, `Failed to destroy the window. Cause : ${JSON.stringify(err)}`);
return;
}
Log.info(TAG, `Succeeded in destroying the window.`);
windowClass = null;
});
} catch (e) {
Log.info(TAG, `Failed 1 : ${JSON.stringify(e)}`);
}
});
}
onDisconnect(want) {
Log.info(TAG, `onDisconnect, want: ${want.abilityName}`);
}
onDestroy() {
Log.info(TAG, 'onDestroy');
}
}

View File

@ -0,0 +1,112 @@
/*
* Copyright (c) 2023 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 {
MenuContext ,
ThirdDeleteOperation ,
MenuOperationFactory,
Log ,
CustomDialogView ,
BroadCast,
SelectManager ,
MediaObserver
} from '@ohos/common';
import type { MenuOperation } from '@ohos/common';
import dialogRequest from '@ohos.app.ability.dialogRequest';
import uri from '@ohos.uri';
const TAG: string = 'ResourceDeletePage';
@Entry
@Component
struct ResourceDeletePage {
@Provide broadCast: BroadCast = new BroadCast();
isShow: boolean = false;
selectManager: SelectManager;
onPageShow() {
if (this.isShow) {
return;
}
this.isShow = true;
Log.info(TAG, 'onPageShow');
let menuOperation: MenuOperation;
let menuContext: MenuContext = new MenuContext();
this.onOperationEnd = this.onOperationEnd.bind(this);
this.onOperationCancel = this.onOperationCancel.bind(this);
menuContext
.withSelectManager(this.selectManager)
.withOperationEndCallback(this.onOperationEnd)
.withOperationCancelCallback(this.onOperationCancel)
.withBroadCast(this.broadCast);
menuOperation = MenuOperationFactory.getInstance()
.createMenuOperation(ThirdDeleteOperation, menuContext);
menuOperation.doAction()
}
aboutToAppear() {
this.selectManager = new SelectManager();
let uris: [] = AppStorage.Get("uris");
Log.info(TAG, `aboutToAppear uris : ${JSON.stringify(uris)}`);
if (uris != undefined && uris.length > 0) {
uris.forEach(uri => {
if (!this.selectManager.clickedSet.has(uri)) {
this.selectManager.clickedSet.add(uri);
}
})
}
}
aboutToDisappear() {
Log.info(TAG, 'aboutToDisappear');
MediaObserver.getInstance().unregisterForAllPhotos();
MediaObserver.getInstance().unregisterForAllAlbums();
}
build() {
Column() {
CustomDialogView({ broadCast: $broadCast})
.width('100%')
.height('100%');
}
.backgroundColor("#00000000")
.height('100%');
}
onOperationEnd () {
this.setDeleteResult(dialogRequest.ResultCode.RESULT_OK);
}
onOperationCancel () {
this.setDeleteResult(dialogRequest.ResultCode.RESULT_CANCEL);
}
private setDeleteResult(result: dialogRequest.ResultCode) {
Log.info(TAG, `start to setDeleteResult : ${result}}`);
try {
var requestCallback = AppStorage.Get("requestCallback");
let myResult = {
result: result,
}
// @ts-ignore
requestCallback.setRequestResult(myResult);
globalThis.photoAbilityContext.terminateSelf();
} catch(err) {
Log.info(TAG, `getRequestInfo err : ${JSON.stringify(err)}`);
}
}
}

View File

@ -92,7 +92,26 @@
"name": "ohos.extension.form",
"resource": "$profile:form_config"
}
]
],
},
{
"name": "com.ohos.photos.ServiceExtAbility",
"srcEntrance": "./ets/ServiceExt/ServiceExtAbility.ts",
"icon": "$media:ohos_gallery",
"description": "$string:app_name",
"type": "service",
"visible": true,
"skills": [
{
"actions": [
"ohos.want.action.deleteDialog"
],
"uris": [
{
"type": "image/*"
}
],
}]
}
]
},

View File

@ -13,6 +13,7 @@
"pages/NewAlbumPage",
"pages/AlbumSelect",
"pages/EditMain",
"pages/FormEditorPage"
"pages/FormEditorPage",
"pages/ResourceDeletePage"
]
}