• 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
16enum ActionID {
17    NONE,
18    OK,
19    OK_DISABLE,
20    CANCEL,
21    BACK,
22    INFO,
23    INFO_INVALID,
24    DELETE,
25    DELETE_RECYCLE,
26    CLEAR_RECYCLE,
27    DELETE_INVALID,
28    RECOVER,
29    RECOVER_INVALID,
30    FAVORITE,
31    NOT_FAVORITE,
32    UN_SELECTED,
33    SELECTED,
34    SELECT_ALL,
35    DESELECT_ALL,
36    SETTING,
37    NAVIGATION,
38    MATERIAL_SELECT,
39    GOTO_PHOTOS,
40    SHARE,
41    SHARE_INVALID,
42    EDIT,
43    EDIT_INVALID,
44    MORE,
45    NEW,
46    RENAME,
47    RENAME_INVALID,
48    ADD_NOTES,
49    ROTATE,
50    MOVE,
51    MOVE_INVALID,
52    COPY,
53    COPY_INVALID,
54    NAVIGATION_ALBUMS,
55    DOWNLOAD,
56    DOWNLOAD_INVALID,
57    CLEAR_RECYCLE_INVALID
58}
59
60interface ActionOptions {
61    id: number;
62    textRes: Resource;
63    iconRes?: Resource;
64    isAutoTint?: boolean;
65    fillColor?: Resource;
66    actionType?: Resource;
67}
68
69export class Action {
70    public static NONE = new Action({
71        id: ActionID.NONE,
72        iconRes: null,
73        textRes: null
74    });
75    public static OK = new Action({
76        id: ActionID.OK,
77        iconRes: $r('app.media.ic_gallery_public_ok'),
78        textRes: $r('app.string.action_ok')
79    });
80    public static OK_DISABLE = new Action({
81        id: ActionID.OK_DISABLE,
82        iconRes: $r('app.media.ic_gallery_public_ok'),
83        textRes: $r('app.string.action_ok'),
84        fillColor: $r('app.color.icon_disabled_color')
85    });
86    public static CANCEL = new Action({
87        id: ActionID.CANCEL,
88        iconRes: $r('app.media.ic_gallery_public_cancel'),
89        textRes: $r('app.string.action_cancel')
90    });
91    public static BACK = new Action({
92        id: ActionID.BACK,
93        iconRes: $r('app.media.ic_gallery_public_back'),
94        textRes: $r('app.string.action_back')
95    });
96    public static INFO = new Action({
97        id: ActionID.INFO,
98        iconRes: $r('app.media.ic_gallery_public_details'),
99        textRes: $r('app.string.action_info')
100    });
101    public static INFO_INVALID = new Action({
102        id: ActionID.INFO,
103        iconRes: $r('app.media.ic_gallery_public_details'),
104        textRes: $r('app.string.action_info'),
105        fillColor: $r('app.color.icon_disabled_color')
106    });
107    public static DELETE = new Action({
108        id: ActionID.DELETE,
109        iconRes: $r('app.media.ic_gallery_public_delete_line'),
110        textRes: $r('app.string.action_delete'),
111        actionType: $r('app.string.action_delete')
112    });
113    public static DELETE_RECYCLE = new Action({
114        id: ActionID.DELETE_RECYCLE,
115        iconRes: $r('app.media.ic_gallery_public_delete_line'),
116        textRes: $r('app.string.action_delete'),
117        actionType: $r('app.string.action_delete')
118    });
119    public static CLEAR_RECYCLE = new Action({
120        id: ActionID.CLEAR_RECYCLE,
121        iconRes: $r('app.media.ic_gallery_public_delete_line'),
122        textRes: $r('app.string.action_clear_recycle'),
123        actionType: $r('app.string.action_clear_recycle')
124    });
125    public static CLEAR_RECYCLE_INVALID = new Action({
126        id: ActionID.CLEAR_RECYCLE_INVALID,
127        iconRes: $r('app.media.ic_gallery_public_delete_line'),
128        textRes: $r('app.string.action_clear_recycle'),
129        fillColor: $r('app.color.icon_disabled_color'),
130        actionType: $r('app.string.action_delete')
131    });
132    public static DELETE_INVALID = new Action({
133        id: ActionID.DELETE_INVALID,
134        iconRes: $r('app.media.ic_gallery_public_delete_line'),
135        textRes: $r('app.string.action_delete'),
136        fillColor: $r('app.color.icon_disabled_color'),
137        actionType: $r('app.string.action_delete_invalid')
138    });
139    public static RECOVER = new Action({
140        id: ActionID.RECOVER,
141        iconRes: $r('app.media.ic_gallery_public_undo'),
142        textRes: $r('app.string.action_recover'),
143        actionType: $r('app.string.action_recover')
144    });
145    public static RECOVER_INVALID = new Action({
146        id: ActionID.RECOVER_INVALID,
147        iconRes: $r('app.media.ic_gallery_public_undo'),
148        textRes: $r('app.string.action_recover'),
149        fillColor: $r('app.color.icon_disabled_color'),
150        actionType: $r('app.string.action_recover')
151    });
152    public static FAVORITE = new Action({
153        id: ActionID.FAVORITE,
154        iconRes: $r('app.media.ic_gallery_public_Favorite_filled'),
155        textRes: $r('app.string.action_favorite'),
156        fillColor: $r('app.color.color_system_highlight'),
157        actionType: $r('app.string.action_favorite')
158    });
159    public static NOT_FAVORITE = new Action({
160        id: ActionID.NOT_FAVORITE,
161        iconRes: $r('app.media.ic_gallery_public_favorite_line'),
162        textRes: $r('app.string.action_not_favorite'),
163        actionType: $r('app.string.action_not_favorite')
164    });
165    public static UN_SELECTED = new Action({
166        id: ActionID.UN_SELECTED,
167        iconRes: $r('app.media.ic_checkbox_off'),
168        textRes: $r('app.string.action_unselected'),
169        actionType: $r('app.string.action_unselected')
170    });
171    public static SELECTED = new Action({
172        id: ActionID.SELECTED,
173        iconRes: $r('app.media.ic_gallery_public_checkbox_filled'),
174        textRes: $r('app.string.action_selected'),
175        isAutoTint: false,
176        actionType: $r('app.string.action_selected')
177    });
178    public static SELECT_ALL = new Action({
179        id: ActionID.SELECT_ALL,
180        iconRes: $r('app.media.ic_gallery_public_select_all'),
181        textRes: $r('app.string.action_select_all'),
182        actionType: $r('app.string.action_select_all')
183    });
184    public static DESELECT_ALL = new Action({
185        id: ActionID.DESELECT_ALL,
186        iconRes: $r('app.media.ic_gallery_public_select_all_action'),
187        textRes: $r('app.string.action_deselect_all'),
188        actionType: $r('app.string.action_deselect_all')
189    });
190    public static SETTING = new Action({
191        id: ActionID.SETTING,
192        textRes: $r('app.string.action_setting')
193    });
194    public static NAVIGATION = new Action({
195        id: ActionID.NAVIGATION,
196        textRes: $r('app.string.action_navigation')
197    });
198    public static MATERIAL_SELECT = new Action({
199        id: ActionID.MATERIAL_SELECT,
200        iconRes: $r('app.media.ic_checkbox_off_overlay'),
201        textRes: $r('app.string.action_material_select'),
202        isAutoTint: false,
203        actionType: $r('app.string.action_selected')
204    });
205    public static GOTO_PHOTOS = new Action({
206        id: ActionID.GOTO_PHOTOS,
207        iconRes: $r('app.media.ic_goto_photos'),
208        textRes: $r('app.string.action_goto_photos')
209    });
210    public static SHARE = new Action({
211        id: ActionID.SHARE,
212        iconRes: $r('app.media.ic_gallery_public_share'),
213        textRes: $r('app.string.action_share'),
214        actionType: $r('app.string.action_share')
215    });
216    public static SHARE_INVALID = new Action({
217        id: ActionID.SHARE_INVALID,
218        iconRes: $r('app.media.ic_gallery_public_share'),
219        fillColor: $r('app.color.icon_disabled_color'),
220        textRes: $r('app.string.action_share'),
221        actionType: $r('app.string.action_share')
222    });
223    public static EDIT = new Action({
224        id: ActionID.EDIT,
225        iconRes: $r('app.media.ic_gallery_public_edit'),
226        textRes: $r('app.string.action_edit')
227    });
228    public static EDIT_INVALID = new Action({
229        id: ActionID.EDIT_INVALID,
230        iconRes: $r('app.media.ic_gallery_public_edit_disable'),
231        textRes: $r('app.string.action_edit'),
232        fillColor: $r('app.color.icon_disabled_color')
233    });
234    public static MORE = new Action({
235        id: ActionID.MORE,
236        iconRes: $r('app.media.ic_gallery_public_more'),
237        textRes: $r('app.string.action_more')
238    });
239    public static NEW = new Action({
240        id: ActionID.NEW,
241        iconRes: $r('app.media.ic_gallery_public_new'),
242        textRes: $r('app.string.action_new')
243    });
244    public static RENAME = new Action({
245        id: ActionID.RENAME,
246        iconRes: $r('app.media.ic_gallery_public_rename'),
247        textRes: $r('app.string.action_rename'),
248        actionType: $r('app.string.action_rename')
249    });
250    public static RENAME_INVALID = new Action({
251        id: ActionID.RENAME_INVALID,
252        iconRes: $r('app.media.ic_gallery_public_rename'),
253        textRes: $r('app.string.action_rename'),
254        fillColor: $r('app.color.icon_disabled_color'),
255        actionType: $r('app.string.action_rename')
256    });
257    public static ROTATE = new Action({
258        id: ActionID.ROTATE,
259        iconRes: $r('app.media.ic_edit_photo_crop_rotate'),
260        textRes: $r('app.string.rotate_text'),
261        actionType: $r('app.string.rotate_text')
262    });
263    public static ADD_NOTES = new Action({
264        id: ActionID.ADD_NOTES,
265        iconRes: null,
266        textRes: $r('app.string.add_notes')
267    });
268    public static MOVE = new Action({
269        id: ActionID.MOVE,
270        textRes: $r('app.string.action_move_to_album')
271    });
272    public static MOVE_INVALID = new Action({
273        id: ActionID.MOVE_INVALID,
274        textRes: $r('app.string.action_move_to_album'),
275        fillColor: $r('app.color.icon_disabled_color')
276    });
277    public static COPY = new Action({
278        id: ActionID.COPY,
279        textRes: $r('app.string.action_copy_to_album')
280    });
281    public static COPY_INVALID = new Action({
282        id: ActionID.COPY_INVALID,
283        textRes: $r('app.string.action_copy_to_album'),
284        fillColor: $r('app.color.icon_disabled_color')
285    });
286    public static NAVIGATION_ALBUMS = new Action({
287        id: ActionID.NAVIGATION_ALBUMS,
288        iconRes: $r('app.media.ic_navigation_albums_line'),
289        textRes: $r('app.string.rotate_text')
290    });
291    public static DOWNLOAD = new Action({
292        id: ActionID.DOWNLOAD,
293        iconRes: $r('app.media.download'),
294        textRes: $r('app.string.save_to_local')
295    });
296    public static DOWNLOAD_INVALID = new Action({
297        id: ActionID.DOWNLOAD_INVALID,
298        iconRes: $r('app.media.download'),
299        textRes: $r('app.string.save_to_local'),
300        fillColor: $r('app.color.icon_disabled_color')
301    });
302    public static ICON_DEFAULT_COLOR: Resource = $r('app.color.icon_default_color');
303    public static ICON_DEFAULT_COLOR_CONTRARY: Resource = $r('app.color.icon_default_color_contrary');
304    readonly actionID: number;
305    readonly textRes: Resource;
306    readonly iconRes: Resource = $r('app.media.ic_gallery_public_more');
307    readonly isAutoTint: boolean = true;
308    readonly fillColor: Resource = $r('app.color.icon_default_color');
309    readonly actionType: Resource; // It is used to distinguish whether it is the same type of action
310
311    constructor(options: ActionOptions) {
312        this.actionID = options.id;
313        this.textRes = options.textRes;
314        if (options.iconRes != undefined) {
315            this.iconRes = options.iconRes;
316        }
317        if (options.isAutoTint != undefined) {
318            this.isAutoTint = options.isAutoTint;
319        }
320        if (options.fillColor != undefined) {
321            this.fillColor = options.fillColor;
322        }
323        if (options.actionType != undefined) {
324            this.actionType = options.actionType;
325        }
326    }
327
328    public equals(action: Action): boolean {
329        return (action) ? (action.actionID === this.actionID) : false;
330    }
331}
332