1/*
2 * Copyright (C) 2024 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
16/**
17 * @file A component which support other applications to select recent photos or videos
18 * @kit MediaLibraryKit
19 */
20
21import photoAccessHelper from '@ohos.file.photoAccessHelper';
22import { BaseItemInfo } from '@ohos.file.PhotoPickerComponent';
23
24/**
25 * Declare struct RecentPhotoComponent
26 *
27 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core
28 * @atomicservice
29 * @since 12
30 */
31@Component
32export declare struct RecentPhotoComponent {
33  /**
34   * recentPhotoOptions
35   *
36   * @type { ?recentPhotoOptions }
37   * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core
38   * @atomicservice
39   * @since 12
40   */
41  recentPhotoOptions?: RecentPhotoOptions;
42
43  /**
44   * Callback when check whether photos or videos exists
45   *
46   * @type { ?function }
47   * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core
48   * @atomicservice
49   * @since 12
50   */
51  onRecentPhotoCheckResult?: RecentPhotoCheckResultCallback;
52
53  /**
54   * Callback when select photos or videos
55   *
56   * @type { ?function }
57   * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core
58   * @atomicservice
59   * @since 12
60   */
61  onRecentPhotoClick: RecentPhotoClickCallback;
62
63  /**
64   * Callback when check whether photos or videos exists and return the recent photo info
65   *
66   * @type { ?function }
67   * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core
68   * @atomicservice
69   * @since 13
70   */
71  onRecentPhotoCheckInfo?: RecentPhotoCheckInfoCallback;
72}
73
74/**
75 * The callback of onRecentPhotoCheckResult event
76 *
77 * @typedef { function } RecentPhotoCheckResultCallback
78 * @param { boolean } recentPhotoExists - Does the recent photo exist?
79 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core
80 * @atomicservice
81 * @since 12
82 */
83export type RecentPhotoCheckResultCallback = (recentPhotoExists: boolean) => void;
84
85/**
86 * The callback of onRecentPhotoClick event
87 *
88 * @typedef { function } RecentPhotoClickCallback
89 * @param { BaseItemInfo } recentPhotoInfo - The item information of recent photo
90 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core
91 * @atomicservice
92 * @since 12
93 */
94export type RecentPhotoClickCallback = (recentPhotoInfo: BaseItemInfo) => boolean;
95
96/**
97 * The callback of onRecentPhotoCheckInfo event
98 *
99 * @typedef { function } RecentPhotoCheckInfoCallback
100 * @param { boolean } recentPhotoExists - Does the recent photo exist?
101 * @param { RecentPhotoInfo } info - the recent photo info
102 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core
103 * @atomicservice
104 * @since 13
105 */
106export type RecentPhotoCheckInfoCallback = (recentPhotoExists: boolean, info: RecentPhotoInfo) => void;
107
108/**
109 * RecentPhotoOptions Object
110 *
111 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core
112 * @atomicservice
113 * @since 12
114 */
115export declare class RecentPhotoOptions {
116  /**
117   * Support set period time
118   *
119   * @type { ?number }
120   * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core
121   * @atomicservice
122   * @since 12
123   */
124  period?: number;
125
126  /**
127   * The Type of the file in the recent photo window.
128   *
129   * @type { ?photoAccessHelper.PhotoViewMIMETypes }
130   * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core
131   * @atomicservice
132   * @since 12
133   */
134  MIMEType?: photoAccessHelper.PhotoViewMIMETypes;
135
136  /**
137   * PhotoSource
138   *
139   * @type { ?PhotoSource }
140   * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core
141   * @atomicservice
142   * @since 12
143   */
144  photoSource?: PhotoSource;
145}
146
147/**
148 * Recent photo info
149 *
150 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core
151 * @atomicservice
152 * @since 13
153 */
154export declare class RecentPhotoInfo {
155  /**
156   * The dateTaken of photos or videos
157   *
158   * @type { ?number }
159   * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core
160   * @atomicservice
161   * @since 13
162   */
163  dateTaken?: number;
164
165  /**
166   * The identifier of photos or videos
167   *
168   * @type { ?string }
169   * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core
170   * @atomicservice
171   * @since 13
172   */
173  identifier?: string;
174}
175
176/**
177 * Enumeration of PhotoSource type
178 *
179 * @enum { number } PhotoSource
180 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core
181 * @atomicservice
182 * @since 12
183 */
184export declare enum PhotoSource {
185  /**
186   * all resource
187   *
188   * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core
189   * @atomicservice
190   * @since 12
191   */
192  ALL = 0,
193
194  /**
195   * camera resource
196   *
197   * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core
198   * @atomicservice
199   * @since 12
200   */
201  CAMERA = 1,
202  
203  /**
204   * screenshot resource
205   *
206   * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core
207   * @atomicservice
208   * @since 12
209   */
210  SCREENSHOT = 2
211}