1/* 2 * Copyright (c) 2023 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 { AsyncCallback, Callback } from "./basic"; 17 18/** 19 * This module provides the capabilities to use different pickers. 20 * 21 * @since 9 22 * @syscap SystemCapability.FileManagement.UserFileService 23 */ 24declare namespace picker { 25 /** 26 * PhotoViewMIMETypes represents the type of media resource that photo picker selects. 27 * @since 9 28 * @syscap SystemCapability.FileManagement.UserFileService 29 */ 30 enum PhotoViewMIMETypes { 31 IMAGE_TYPE = "image/*", 32 VIDEO_TYPE = "video/*", 33 IMAGE_VIDEO_TYPE = "*/*" 34 } 35 36 /** 37 * PhotoSelectOptions Object 38 * @since 9 39 * @syscap SystemCapability.FileManagement.UserFileService 40 */ 41 class PhotoSelectOptions { 42 /** 43 * The Type of the file in the picker window. 44 * @type {PhotoViewMIMETypes} 45 * @since 9 46 */ 47 MIMEType?: PhotoViewMIMETypes; 48 49 /** 50 * Maximum number of images for a single selection. 51 * @type {number} 52 * @since 9 53 */ 54 maxSelectNumber?: number; 55 } 56 57 /** 58 * PhotoSelectResult Object 59 * @since 9 60 * @syscap SystemCapability.FileManagement.UserFileService 61 */ 62 class PhotoSelectResult { 63 /** 64 * The uris for the selected files. 65 * @type {Array<string>} 66 * @since 9 67 */ 68 photoUris: Array<string>; 69 70 /** 71 * Original option. 72 * @type {boolean} 73 * @since 9 74 */ 75 isOriginalPhoto: boolean; 76 } 77 78 /** 79 * PhotoSaveOptions Object 80 * @since 9 81 * @syscap SystemCapability.FileManagement.UserFileService 82 */ 83 class PhotoSaveOptions { 84 /** 85 * The names of the files to be saved. 86 * @type {Array<string>} 87 * @since 9 88 */ 89 newFileNames?: Array<string>; 90 } 91 92 /** 93 * PhotoViewPicker Object 94 * @since 9 95 * @syscap SystemCapability.FileManagement.UserFileService 96 */ 97 class PhotoViewPicker { 98 /** 99 * Pull up the photo picker based on the selection mode. 100 * 101 * @since 9 102 * @syscap SystemCapability.FileManagement.UserFileService 103 * @param PhotoSelectOptions represents the options provided in select mode. 104 * @returns {(void | Promise<PhotoSelectResult>)} Returns the uris for the selected files. 105 */ 106 select(option?: PhotoSelectOptions) : Promise<PhotoSelectResult>; 107 select(option: PhotoSelectOptions, callback: AsyncCallback<PhotoSelectResult>) : void; 108 select(callback: AsyncCallback<PhotoSelectResult>) : void; 109 110 /** 111 * Pull up the photo picker based on the save mode. 112 * 113 * @since 9 114 * @syscap SystemCapability.FileManagement.UserFileService 115 * @param PhotoSaveOptions represents the options provided in save mode. 116 * @returns {(void | Promise<Array<string>>)} Returns the uris for the saved files. 117 */ 118 save(option?: PhotoSaveOptions) : Promise<Array<string>>; 119 save(option: PhotoSaveOptions, callback: AsyncCallback<Array<string>>) : void; 120 save(callback: AsyncCallback<Array<string>>) : void; 121 } 122 123 /** 124 * DocumentSelectOptions Object. Currently not supported. 125 * @since 9 126 * @syscap SystemCapability.FileManagement.UserFileService 127 */ 128 class DocumentSelectOptions { 129 } 130 131 /** 132 * DocumentSaveOptions Object 133 * @since 9 134 * @syscap SystemCapability.FileManagement.UserFileService 135 */ 136 class DocumentSaveOptions { 137 /** 138 * The names of the files to be saved. 139 * Currently, only single file is supported. 140 * @type {Array<string>} 141 * @since 9 142 */ 143 newFileNames?: Array<string>; 144 } 145 146 /** 147 * DocumentViewPicker Object 148 * @since 9 149 * @syscap SystemCapability.FileManagement.UserFileService 150 */ 151 class DocumentViewPicker { 152 /** 153 * Pull up the document picker based on the selection mode. 154 * Currently, only single file is supported. 155 * 156 * @since 9 157 * @syscap SystemCapability.FileManagement.UserFileService 158 * @param DocumentSelectOptions represents the options provided in select mode. 159 * @returns {(void | Promise<Array<string>>)} Returns the uris for the selected files. 160 */ 161 select(option?: DocumentSelectOptions) : Promise<Array<string>>; 162 select(option: DocumentSelectOptions, callback: AsyncCallback<Array<string>>) : void; 163 select(callback: AsyncCallback<Array<string>>) : void; 164 165 /** 166 * Pull up the document picker based on the save mode. 167 * Currently, only single file is supported. 168 * 169 * @since 9 170 * @syscap SystemCapability.FileManagement.UserFileService 171 * @param DocumentSaveOptions represents the options provided in save mode. 172 * @returns {(void | Promise<Array<string>>)} Returns the uris for the saved files. 173 */ 174 save(option?: DocumentSaveOptions) : Promise<Array<string>>; 175 save(option: DocumentSaveOptions, callback: AsyncCallback<Array<string>>) : void; 176 save(callback: AsyncCallback<Array<string>>) : void; 177 } 178 179 /** 180 * AudioSelectOptions Object. Currently not supported. 181 * @since 9 182 * @syscap SystemCapability.FileManagement.UserFileService 183 */ 184 class AudioSelectOptions { 185 } 186 187 /** 188 * AudioSaveOptions Object 189 * @since 9 190 * @syscap SystemCapability.FileManagement.UserFileService 191 */ 192 class AudioSaveOptions { 193 /** 194 * The names of the files to be saved. 195 * Currently, only single file is supported. 196 * @type {Array<string>} 197 * @since 9 198 */ 199 newFileNames?: Array<string>; 200 } 201 202 /** 203 * AudioViewPicker Object 204 * @since 9 205 * @syscap SystemCapability.FileManagement.UserFileService 206 */ 207 class AudioViewPicker { 208 /** 209 * Pull up the audio picker based on the selection mode. 210 * Currently, only single file is supported. 211 * 212 * @since 9 213 * @syscap SystemCapability.FileManagement.UserFileService 214 * @param AudioSelectOptions represents the options provided in select mode. 215 * @returns {(void | Promise<Array<string>>)} Returns the uris for the selected files. 216 */ 217 select(option?: AudioSelectOptions) : Promise<Array<string>>; 218 select(option: AudioSelectOptions, callback: AsyncCallback<Array<string>>) : void; 219 select(callback: AsyncCallback<Array<string>>) : void; 220 221 /** 222 * Pull up the audio picker based on the save mode. 223 * Currently, only single file is supported. 224 * 225 * @since 9 226 * @syscap SystemCapability.FileManagement.UserFileService 227 * @param AudioSaveOptions represents the options provided in save mode. 228 * @returns {(void | Promise<Array<string>>)} Returns the uris for the saved files. 229 */ 230 save(option?: AudioSaveOptions) : Promise<Array<string>>; 231 save(option: AudioSaveOptions, callback: AsyncCallback<Array<string>>) : void; 232 save(callback: AsyncCallback<Array<string>>) : void; 233 } 234} 235 236export default picker;