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