1/*
2 * Copyright (c) 2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16import { DownloadCancelOperationDialog } from './DownloadCancelOperationDialog';
17import { BroadCast } from '../../utils/BroadCast';
18import { BroadCastConstants } from '../../model/common/BroadCastConstants';
19import { Log } from '../../utils/Log';
20import { DetailsDialog, MediaDetails } from './DetailsDialog';
21import { MultiSelectDetails, MultiSelectDialog } from './MultiSelectDialog';
22import { DeleteDialog } from './DeleteDialog';
23import { ThirdDeleteDialog } from './ThirdDeleteDialog';
24import { RemoveDialog } from './RemoveDialog';
25import { DialogCallback } from '../../model/common/DialogUtil';
26import { MediaItem } from '../../model/browser/photo/MediaItem';
27
28import { CancelOperationDialog, CancelParam } from './CancelOperationDialog';
29import { RenameDialog } from './RenameDialog';
30import { AddNotesDialog } from './AddNotesDialog';
31import { ProgressDialog, ProgressParam } from './ProgressDialog';
32import { DeleteProgressDialog, DeleteProgressParam } from './DeleteProgressDialog';
33import { RemoveProgressDialog, RemoveProgressParam } from './RemoveProgressDialog';
34import { SaveDialog, SaveDialogCallback } from './SaveDialog';
35import { EditExitDialog, EditExitDialogCallback } from './EditExitDialog';
36import { NewAlbumDialog } from './NewAlbumDialog';
37import { CopyOrMoveDialog, OperateParam } from './CopyOrMoveDialog';
38import { ScreenManager } from '../../model/common/ScreenManager';
39import { SaveImageDialog } from './SaveImageDialog';
40import { tryFunc } from '../../utils/ErrUtil';
41
42const TAG: string = 'common_CustomDialogView';
43
44@Component
45export struct CustomDialogView {
46  @State isShow: boolean = false;
47  @Provide dialogMessage: Resource = $r('app.string.common_place_holder', String(''));
48  @Provide progressMessage: Resource = $r('app.string.common_place_holder', String(''));
49  @Provide deleteProgress: number = 0;
50  @Provide removeProgress: number = 0;
51  @Provide dialogCallback: DialogCallback = { confirmCallback: (): void => {}, cancelCallback: () => {} };
52  @Provide saveDialogCallback: SaveDialogCallback = { saveAsNewCallback: (): void => {},
53    replaceOriginalCallback: () => {} };
54  @Provide editExitDialogCallback: EditExitDialogCallback = { discardCallback: (): void => {} };
55  @Link broadCast: BroadCast;
56  @Provide progressParam: ProgressParam = { cancelFunc: (): void => {}, operationType: '' };
57  @Provide deleteProgressParam: DeleteProgressParam = { currentCount: 0, totalCount: 0, message: undefined };
58  @Provide removeProgressParam: RemoveProgressParam = { currentCount: 0, totalCount: 0, message: undefined };
59  @Provide cancelParam: CancelParam = { continueFunc: (): void => {}, cancelFunc: () => {} };
60  @Provide operateParam: OperateParam = { moveFunc: (): void => {}, copyFunc: () => {} };
61  @Provide cancelMessage: Resource = $r('app.string.common_place_holder', String(''));
62  @Provide renameFileName: string = '';
63  @Provide isDistributedAlbum: boolean = false;
64  @Provide mediaDetails: MediaDetails = {
65    mediaType: 0,
66    height: 256,
67    width: 256,
68    size: 256,
69    duration: 1028,
70    title: 'title',
71    dateTaken: 10280000,
72    uri: '',
73    displayName: '',
74    dateModified: 0
75  };
76  @Provide targetMediaDetails: MediaDetails = {
77    mediaType: 0,
78    height: 256,
79    width: 256,
80    size: 256,
81    duration: 1028,
82    title: 'title',
83    dateTaken: 10280000,
84    uri: '',
85    displayName: '',
86    dateModified: 0
87  };
88  @Provide multiSelectDetails: MultiSelectDetails = {
89    count: 500,
90    size: 256,
91  };
92  @StorageLink('isHorizontal') @Watch('refreshDialogs') isHorizontal: boolean = ScreenManager.getInstance()
93    .isHorizontal();
94  @StorageLink('isSidebar') @Watch('refreshDialogs') isSidebar: boolean = ScreenManager.getInstance().isSidebar();
95  dialogController?: CustomDialogController | null;
96  multiSelectDialog?: CustomDialogController | null;
97  deleteDialogController?: CustomDialogController | null;
98  thirdDeleteDialogController?: CustomDialogController | null;
99  removeDialogController?: CustomDialogController | null;
100  deleteProgressDialogController?: CustomDialogController | null;
101  removeProgressDialogController?: CustomDialogController | null;
102  progressDialogController?: CustomDialogController | null;
103  cancelDialogController?: CustomDialogController | null;
104  renameFileDialogController?: CustomDialogController | null;
105  saveDialogController?: CustomDialogController | null;
106  editExitDialogController?: CustomDialogController | null;
107  addNotesDialogController?: CustomDialogController | null;
108  newAlbumDialogController?: CustomDialogController | null;
109  copyOrMoveDialogController?: CustomDialogController | null;
110  downloadCancelOperationDialog?: CustomDialogController | null;
111  saveImageDialogController?: CustomDialogController | null;
112
113  private showDetailDialogFunc: Function =
114    (item: MediaItem, isDistributed: boolean): void => this.showDetailDialog(item,isDistributed);
115
116  private showMultiSelectDialogFunc: Function =
117    (count: number, size: number): void => this.showMultiSelectDialog(count, size);
118
119  private showDeleteDialogFunc: Function =
120    (deleteMessage: Resource, confirmCallback: Function, cancelCallback: Function, isAlbumDelete: boolean): void =>
121    this.showDeleteDialog(deleteMessage, confirmCallback, cancelCallback);
122
123  private showThirdDeleteDialogFunc: Function =
124    (deleteMessage: Resource, confirmCallback: Function, cancelCallback?: Function): void =>
125    this.showThirdDeleteDialog(deleteMessage, confirmCallback, cancelCallback);
126
127  private showRemoveDialogFunc: Function =
128    (removeMessage: Resource, confirmCallback: Function, cancelCallback?: Function): void =>
129    this.showRemoveDialog(removeMessage, confirmCallback, cancelCallback);
130
131  private showRenamePhotoDialogFunc:Function =
132    (fileName: string, confirmCallback: Function, cancelCallback?: Function): void =>
133  this.showRenamePhotoDialog(fileName, confirmCallback, cancelCallback);
134
135  private showAddNotePhotoDialogFunc: Function = (confirmCallback: Function, cancelCallback?: Function): void =>
136  this.showAddNotePhotoDialog(confirmCallback, cancelCallback);
137
138  private showProgressDialogFunc: Function = (message: Resource, operationType: string, cancelFunc?: Function): void =>
139  this.showProgressDialog(message, operationType,cancelFunc);
140
141  private updateProgressFunc: Function = (progress: number, currentCount: number): void =>
142  this.updateProgress(progress, currentCount);
143
144  private cancelOperateFunc: Function = (cancelMessage: Resource, continueFunc: Function, cancelFunc: Function): void =>
145  this.cancelOperate(cancelMessage, continueFunc, cancelFunc);
146
147  private downloadCancelOperateFunc: Function =
148    (cancelMessage: Resource, continueFunc: Function, cancelFunc: Function): void =>
149    this.downloadCancelOperate(cancelMessage, continueFunc, cancelFunc);
150
151  private showSavePhotoDialogFunc: Function =
152    (saveAsNewCallback: Function, replaceOriginalCallback: Function): void =>
153    this.showSavePhotoDialog(saveAsNewCallback, replaceOriginalCallback);
154
155  private showEditExitPhotoDialogFunc: Function = (discardCallback: Function): void =>
156  this.showEditExitPhotoDialog(discardCallback);
157
158  private showEditSaveProgressDialogFunc: Function = (): void => this.showEditSaveProgressDialog();
159
160  private showNewAlbumDialogFunc: Function =
161    (fileName: string, confirmCallback: Function, cancelCallback?: Function): void =>
162    this.showNewAlbumDialog(fileName, confirmCallback, cancelCallback);
163
164  private showCopyOrMoveDialogFunc: Function = (moveFunc: Function, copyFunc: Function): void =>
165  this.showCopyOrMoveDialog(moveFunc, copyFunc);
166
167  private deleteProgressDialogFunc: Function = (message: Resource, totalCount: number): void =>
168  this.deleteProgressDialog(message, totalCount)
169
170  private removeProgressDialogFunc: Function = (message: Resource, totalCount: number): void =>
171  this.removeProgressDialog(message, totalCount);
172
173  refreshDialogs(): void {
174    this.buildDialogs(true);
175  }
176
177  buildDialogs(refreshFlag: boolean): void {
178    this.dialogController = new CustomDialogController({
179      builder: DetailsDialog(),
180      autoCancel: false,
181      alignment: this.isHorizontal || this.isSidebar ? DialogAlignment.Center : DialogAlignment.Bottom,
182      offset: {
183        dx: 0,
184        dy: this.isHorizontal || this.isSidebar ? 0 : $r('app.float.dialog_offset_bottom')
185      },
186      customStyle: true
187    });
188
189    this.multiSelectDialog = new CustomDialogController({
190      builder: MultiSelectDialog(),
191      autoCancel: false,
192      alignment: this.isHorizontal || this.isSidebar ? DialogAlignment.Center : DialogAlignment.Bottom,
193      offset: {
194        dx: 0,
195        dy: this.isHorizontal || this.isSidebar ? 0 : $r('app.float.dialog_offset_bottom')
196      },
197      customStyle: true
198    });
199
200    this.deleteDialogController = new CustomDialogController({
201      builder: DeleteDialog(),
202      autoCancel: false,
203      alignment: this.isHorizontal || this.isSidebar ? DialogAlignment.Center : DialogAlignment.Bottom,
204      offset: {
205        dx: 0,
206        dy: this.isHorizontal || this.isSidebar ? 0 : $r('app.float.dialog_offset_bottom')
207      },
208      customStyle: true
209    });
210
211    this.thirdDeleteDialogController = new CustomDialogController({
212      builder: ThirdDeleteDialog(),
213      autoCancel: false,
214      alignment: this.isHorizontal ? DialogAlignment.Center : DialogAlignment.Bottom,
215      offset: {
216        dx: 0,
217        dy: this.isHorizontal || this.isSidebar ? 0 : $r('app.float.dialog_offset_bottom')
218      },
219      customStyle: true
220    });
221
222    this.removeDialogController = new CustomDialogController({
223      builder: RemoveDialog(),
224      autoCancel: false,
225      alignment: this.isHorizontal || this.isSidebar ? DialogAlignment.Center : DialogAlignment.Bottom,
226      offset: {
227        dx: 0,
228        dy: this.isHorizontal || this.isSidebar ? 0 : $r('app.float.dialog_offset_bottom')
229      },
230      customStyle: true
231    });
232
233    this.deleteProgressDialogController = new CustomDialogController({
234      builder: DeleteProgressDialog(),
235      autoCancel: false,
236      alignment: this.isHorizontal || this.isSidebar ? DialogAlignment.Center : DialogAlignment.Bottom,
237      offset: {
238        dx: 0,
239        dy: this.isHorizontal || this.isSidebar ? 0 : $r('app.float.dialog_offset_bottom')
240      },
241      customStyle: true
242    });
243
244    this.removeProgressDialogController = new CustomDialogController({
245      builder: RemoveProgressDialog(),
246      autoCancel: false,
247      alignment: this.isHorizontal || this.isSidebar ? DialogAlignment.Center : DialogAlignment.Bottom,
248      offset: {
249        dx: 0,
250        dy: this.isHorizontal || this.isSidebar ? 0 : $r('app.float.dialog_offset_bottom')
251      },
252      customStyle: true
253    });
254
255    this.progressDialogController = new CustomDialogController({
256      builder: ProgressDialog(),
257      autoCancel: false,
258      alignment: this.isHorizontal || this.isSidebar ? DialogAlignment.Center : DialogAlignment.Bottom,
259      offset: {
260        dx: 0,
261        dy: this.isHorizontal || this.isSidebar ? 0 : $r('app.float.dialog_offset_bottom')
262      },
263      customStyle: true
264    });
265
266    this.cancelDialogController = new CustomDialogController({
267      builder: CancelOperationDialog(),
268      autoCancel: false,
269      alignment: this.isHorizontal || this.isSidebar ? DialogAlignment.Center : DialogAlignment.Bottom,
270      offset: {
271        dx: 0,
272        dy: this.isHorizontal || this.isSidebar ? 0 : $r('app.float.dialog_offset_bottom')
273      },
274      customStyle: true
275    });
276
277    this.renameFileDialogController = new CustomDialogController({
278      builder: RenameDialog(),
279      autoCancel: false,
280      alignment: this.isHorizontal || this.isSidebar ? DialogAlignment.Center : DialogAlignment.Bottom,
281      offset: {
282        dx: 0,
283        dy: this.isHorizontal || this.isSidebar ? 0 : $r('app.float.dialog_offset_bottom')
284      },
285      customStyle: true
286    });
287
288    this.saveDialogController = new CustomDialogController({
289      builder: SaveDialog(),
290      autoCancel: false,
291      alignment: this.isHorizontal || this.isSidebar ? DialogAlignment.Center : DialogAlignment.Bottom,
292      customStyle: true
293    });
294
295    this.editExitDialogController = new CustomDialogController({
296      builder: EditExitDialog(),
297      autoCancel: false,
298      alignment: this.isHorizontal || this.isSidebar ? DialogAlignment.Center : DialogAlignment.Bottom,
299      customStyle: true
300    });
301
302    this.addNotesDialogController = new CustomDialogController({
303      builder: AddNotesDialog(),
304      autoCancel: false,
305      alignment: this.isHorizontal || this.isSidebar ? DialogAlignment.Center : DialogAlignment.Bottom,
306      customStyle: true
307    });
308
309    this.newAlbumDialogController = new CustomDialogController({
310      builder: NewAlbumDialog(),
311      autoCancel: false,
312      alignment: this.isHorizontal || this.isSidebar ? DialogAlignment.Center : DialogAlignment.Bottom,
313      offset: {
314        dx: 0,
315        dy: this.isHorizontal || this.isSidebar ? 0 : $r('app.float.dialog_offset_bottom')
316      },
317      customStyle: true
318    });
319
320    this.copyOrMoveDialogController = new CustomDialogController({
321      builder: CopyOrMoveDialog(),
322      autoCancel: false,
323      alignment: this.isHorizontal || this.isSidebar ? DialogAlignment.Center : DialogAlignment.Bottom,
324      offset: {
325        dx: 0,
326        dy: this.isHorizontal || this.isSidebar ? 0 : $r('app.float.dialog_offset_bottom')
327      },
328      customStyle: true
329    });
330
331    this.downloadCancelOperationDialog = new CustomDialogController({
332      builder: DownloadCancelOperationDialog(),
333      autoCancel: false,
334      alignment: this.isHorizontal || this.isSidebar ? DialogAlignment.Center : DialogAlignment.Bottom,
335      offset: {
336        dx: 0,
337        dy: this.isHorizontal || this.isSidebar ? 0 : $r('app.float.dialog_offset_bottom')
338      },
339      customStyle: true
340    });
341
342    this.saveImageDialogController = new CustomDialogController({
343      builder: SaveImageDialog(),
344      autoCancel: false,
345      alignment: this.isHorizontal || this.isSidebar ? DialogAlignment.Center : DialogAlignment.Bottom,
346      customStyle: true
347    });
348  }
349
350  aboutToDisappear(): void {
351    Log.info(TAG, 'aboutToDisappear');
352    this.buildDialogs(false);
353    this.dialogController = null;
354    this.multiSelectDialog = null;
355    this.deleteDialogController = null;
356    this.thirdDeleteDialogController = null;
357    this.removeDialogController = null;
358    this.deleteProgressDialogController = null;
359    this.removeProgressDialogController = null;
360    this.progressDialogController = null;
361    this.cancelDialogController = null;
362    this.renameFileDialogController = null;
363    this.saveDialogController = null;
364    this.editExitDialogController = null;
365    this.addNotesDialogController = null;
366    this.newAlbumDialogController = null;
367    this.copyOrMoveDialogController = null;
368    this.downloadCancelOperationDialog = null;
369    this.saveImageDialogController = null;
370
371    this.broadCast.off(BroadCastConstants.SHOW_DETAIL_DIALOG, this.showDetailDialogFunc);
372    this.broadCast.off(BroadCastConstants.SHOW_MULTI_SELECT_DIALOG, this.showMultiSelectDialogFunc);
373    this.broadCast.off(BroadCastConstants.SHOW_DELETE_DIALOG, this.showDeleteDialogFunc);
374    this.broadCast.off(BroadCastConstants.SHOW_THIRD_DELETE_DIALOG, this.showThirdDeleteDialogFunc);
375    this.broadCast.off(BroadCastConstants.SHOW_REMOVE_DIALOG, this.showRemoveDialogFunc);
376    this.broadCast.off(BroadCastConstants.SHOW_RENAME_PHOTO_DIALOG, this.showRenamePhotoDialogFunc);
377    this.broadCast.off(BroadCastConstants.SHOW_ADD_NOTES_PHOTO_DIALOG, this.showAddNotePhotoDialogFunc);
378    this.broadCast.off(BroadCastConstants.SHOW_PROGRESS_DIALOG, this.showProgressDialogFunc);
379    this.broadCast.off(BroadCastConstants.UPDATE_PROGRESS, this.updateProgressFunc);
380    this.broadCast.off(BroadCastConstants.CANCEL_OPERATE, this.cancelOperateFunc);
381    this.broadCast.off(BroadCastConstants.DOWNLOAD_CANCEL_OPERATE, this.downloadCancelOperateFunc);
382    this.broadCast.off(BroadCastConstants.SHOW_SAVE_PHOTO_DIALOG, this.showSavePhotoDialogFunc);
383    this.broadCast.off(BroadCastConstants.SHOW_NEW_ALBUM_PHOTO_DIALOG, this.showNewAlbumDialogFunc);
384    this.broadCast.off(BroadCastConstants.SHOW_COPY_OR_MOVE_DIALOG, this.showCopyOrMoveDialogFunc);
385    this.broadCast.off(BroadCastConstants.DELETE_PROGRESS_DIALOG, this.deleteProgressDialogFunc);
386    this.broadCast.off(BroadCastConstants.REMOVE_PROGRESS_DIALOG, this.removeProgressDialogFunc);
387  }
388
389  private showDetailDialog(item: MediaItem, isDistributed: boolean): void {
390    Log.info(TAG, item.uri, ' SHOW_DETAIL_DIALOG ');
391    let title: string = item.getTitle ? tryFunc(((): string => item.getTitle())) : undefined;
392    let dateTaken: number = item.getDataTaken ? tryFunc(((): number => item.getDataTaken())) : undefined;
393    let dateModified: number = item.getDateModified ? tryFunc(((): number => item.getDateModified())) : undefined;
394    this.mediaDetails = {
395      mediaType: item.mediaType,
396      height: item.height,
397      width: item.width,
398      size: item.size,
399      duration: item.duration,
400      title,
401      dateTaken,
402      uri: item.uri,
403      displayName: item.displayName,
404      dateModified
405    };
406    this.isDistributedAlbum = isDistributed;
407    (this.dialogController as CustomDialogController).open();
408  }
409
410  private showMultiSelectDialog(count: number, size: number): void {
411    Log.info(TAG, 'SHOW_MULTI_SELECT_DIALOG ');
412    this.multiSelectDetails = {
413      size: size,
414      count: count
415    };
416    (this.multiSelectDialog as CustomDialogController).open();
417  }
418
419  private showDeleteDialog(deleteMessage: Resource, confirmCallback: Function, cancelCallback: Function): void {
420    Log.info(TAG, 'SHOW_DELETE_DIALOG ');
421    this.dialogMessage = deleteMessage;
422    this.dialogCallback = { confirmCallback: confirmCallback, cancelCallback: cancelCallback as Function };
423    (this.deleteDialogController as CustomDialogController).open();
424  }
425
426  private showThirdDeleteDialog(deleteMessage: Resource, confirmCallback: Function, cancelCallback?: Function): void {
427    Log.info(TAG, 'SHOW_THIRD_DELETE_DIALOG ');
428    this.dialogMessage = deleteMessage;
429    this.dialogCallback = { confirmCallback: confirmCallback, cancelCallback: cancelCallback as Function };
430    (this.thirdDeleteDialogController as CustomDialogController).open();
431  }
432
433  private showRemoveDialog(removeMessage: Resource, confirmCallback: Function, cancelCallback?: Function): void {
434    Log.info(TAG, 'SHOW_REMOVE_DIALOG ');
435    this.dialogMessage = removeMessage;
436    this.dialogCallback = { confirmCallback: confirmCallback, cancelCallback: cancelCallback as Function };
437    (this.removeDialogController as CustomDialogController).open();
438  }
439
440  private showRenamePhotoDialog(fileName: string, confirmCallback: Function, cancelCallback?: Function): void {
441    Log.info(TAG, 'SHOW_RENAME_PHOTO_DIALOG ');
442    this.renameFileName = fileName;
443    this.dialogCallback = { confirmCallback: confirmCallback, cancelCallback: cancelCallback as Function };
444    (this.renameFileDialogController as CustomDialogController).open();
445  }
446
447  private showAddNotePhotoDialog(confirmCallback: Function, cancelCallback?: Function): void {
448    Log.info(TAG, 'SHOW_ADD_NOTES_PHOTO_DIALOG ');
449    this.dialogCallback = { confirmCallback: confirmCallback, cancelCallback: cancelCallback as Function };
450    (this.addNotesDialogController as CustomDialogController).open();
451  }
452
453  private showProgressDialog(message: Resource, operationType: string, cancelFunc?: Function): void {
454    Log.info(TAG, 'SHOW_PROGRESS_DIALOG');
455    if (message != null) {
456      this.progressMessage = message;
457    }
458    if (operationType) {
459      this.progressParam.operationType = operationType;
460    }
461
462    if (cancelFunc) {
463      this.progressParam.cancelFunc = cancelFunc;
464    }
465    this.deleteProgress = 0;
466    this.removeProgress = 0;
467    (this.progressDialogController as CustomDialogController).open();
468  }
469
470  private updateProgress(progress: number, currentCount: number): void {
471    Log.info(TAG, `UPDATE_PROGRESS ${progress}`);
472    this.deleteProgress = progress;
473    this.removeProgress = progress;
474    this.deleteProgressParam.currentCount = currentCount;
475    this.removeProgressParam.currentCount = currentCount;
476    if (progress == 100) {
477      Log.info(TAG, 'Update progress 100%');
478      (this.progressDialogController as CustomDialogController).close();
479      (this.deleteProgressDialogController as CustomDialogController).close();
480      this.deleteProgressParam.currentCount = 0;
481      (this.removeProgressDialogController as CustomDialogController).close();
482      this.removeProgressParam.currentCount = 0;
483    }
484  }
485
486  private cancelOperate(cancelMessage: Resource, continueFunc: Function, cancelFunc: Function): void {
487    this.cancelMessage = cancelMessage;
488    this.cancelParam.continueFunc = continueFunc;
489    this.cancelParam.cancelFunc = cancelFunc;
490    Log.info(TAG, 'CANCEL_OPERATE');
491    (this.cancelDialogController as CustomDialogController).open();
492  }
493
494  private downloadCancelOperate(cancelMessage: Resource, continueFunc: Function, cancelFunc: Function): void {
495    this.cancelMessage = cancelMessage;
496    this.cancelParam.continueFunc = continueFunc;
497    this.cancelParam.cancelFunc = cancelFunc;
498    Log.info(TAG, 'DOWNLOAD_CANCEL_OPERATE');
499    (this.downloadCancelOperationDialog as CustomDialogController).open();
500  }
501
502  private showSavePhotoDialog(saveAsNewCallback: Function, replaceOriginalCallback: Function): void {
503    Log.info(TAG, 'SHOW_SAVE_PHOTO_DIALOG');
504    this.saveDialogCallback = {
505      saveAsNewCallback: saveAsNewCallback,
506      replaceOriginalCallback: replaceOriginalCallback };
507    (this.saveDialogController as CustomDialogController).open();
508  }
509
510  private showEditExitPhotoDialog(discardCallback: Function): void {
511    Log.info(TAG, 'SHOW_EDIT_EXIT_PHOTO_DIALOG');
512    this.editExitDialogCallback = { discardCallback: discardCallback };
513    (this.editExitDialogController as CustomDialogController).open();
514  }
515
516  private showEditSaveProgressDialog(): void {
517    Log.info(TAG, 'SHOW_EDIT_SAVE_PROGRESS_DIALOG');
518    (this.saveImageDialogController as CustomDialogController).open();
519  }
520
521  private showNewAlbumDialog(fileName: string, confirmCallback: Function, cancelCallback?: Function): void {
522    Log.info(TAG, 'SHOW_NEW_ALBUM_PHOTO_DIALOG');
523    this.renameFileName = fileName;
524    this.dialogCallback = { confirmCallback: confirmCallback, cancelCallback: cancelCallback as Function };
525    (this.newAlbumDialogController as CustomDialogController).open();
526  }
527
528  private showCopyOrMoveDialog(moveFunc: Function, copyFunc: Function): void {
529    Log.info(TAG, 'SHOW_COPY_OR_MOVE_DIALOG');
530    this.operateParam.moveFunc = moveFunc;
531    this.operateParam.copyFunc = copyFunc;
532    (this.copyOrMoveDialogController as CustomDialogController).open();
533  }
534
535  private deleteProgressDialog(message: Resource, totalCount: number): void {
536    Log.info(TAG, 'DELETE_PROGRESS_DIALOG');
537    this.deleteProgressParam.currentCount = 0;
538    this.deleteProgressParam.totalCount = totalCount;
539    this.deleteProgressParam.message = message;
540    (this.deleteProgressDialogController as CustomDialogController).open();
541  }
542
543  private removeProgressDialog(message: Resource, totalCount: number): void {
544    Log.info(TAG, 'REMOVE_PROGRESS_DIALOG');
545    this.removeProgressParam.currentCount = 0;
546    this.removeProgressParam.totalCount = totalCount;
547    this.removeProgressParam.message = message;
548    (this.removeProgressDialogController as CustomDialogController).open();
549  }
550
551  aboutToAppear(): void {
552    Log.info(TAG, 'aboutToAppear');
553    this.buildDialogs(false);
554    this.broadCast.on(BroadCastConstants.SHOW_DETAIL_DIALOG, this.showDetailDialogFunc);
555    this.broadCast.on(BroadCastConstants.SHOW_MULTI_SELECT_DIALOG,this.showMultiSelectDialogFunc);
556    this.broadCast.on(BroadCastConstants.SHOW_DELETE_DIALOG, this.showDeleteDialogFunc);
557    this.broadCast.on(BroadCastConstants.SHOW_THIRD_DELETE_DIALOG, this.showThirdDeleteDialogFunc);
558    this.broadCast.on(BroadCastConstants.SHOW_REMOVE_DIALOG, this.showRemoveDialogFunc);
559    this.broadCast.on(BroadCastConstants.SHOW_RENAME_PHOTO_DIALOG, this.showRenamePhotoDialogFunc);
560    this.broadCast.on(BroadCastConstants.SHOW_ADD_NOTES_PHOTO_DIALOG, this.showAddNotePhotoDialogFunc);
561    this.broadCast.on(BroadCastConstants.SHOW_PROGRESS_DIALOG, this.showProgressDialogFunc);
562    this.broadCast.on(BroadCastConstants.UPDATE_PROGRESS, this.updateProgressFunc);
563    this.broadCast.on(BroadCastConstants.CANCEL_OPERATE, this.cancelOperateFunc);
564    this.broadCast.on(BroadCastConstants.DOWNLOAD_CANCEL_OPERATE, this.downloadCancelOperateFunc);
565    this.broadCast.on(BroadCastConstants.SHOW_SAVE_PHOTO_DIALOG, this.showSavePhotoDialogFunc);
566    this.broadCast.on(BroadCastConstants.SHOW_EDIT_EXIT_PHOTO_DIALOG, this.showEditExitPhotoDialogFunc);
567    this.broadCast.on(BroadCastConstants.SHOW_EDIT_SAVE_PROGRESS_DIALOG, this.showEditSaveProgressDialogFunc);
568    this.broadCast.on(BroadCastConstants.SHOW_NEW_ALBUM_PHOTO_DIALOG, this.showNewAlbumDialogFunc);
569    this.broadCast.on(BroadCastConstants.SHOW_COPY_OR_MOVE_DIALOG, this.showCopyOrMoveDialogFunc);
570    this.broadCast.on(BroadCastConstants.DELETE_PROGRESS_DIALOG, this.deleteProgressDialogFunc);
571    this.broadCast.on(BroadCastConstants.REMOVE_PROGRESS_DIALOG, this.removeProgressDialogFunc);
572  }
573
574  build() {
575  }
576}