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 16var __decorate = this && this.__decorate || function (e, o, t, i) { 17 var n, r = arguments.length, l = r < 3 ? o : null === i ? i = Object.getOwnPropertyDescriptor(o, t) : i; 18 if ('object' === typeof Reflect && 'function' === typeof Reflect.decorate) { 19 l = Reflect.decorate(e, o, t, i); 20 } else { 21 for (let s = e.length - 1; s >= 0; s--) { 22 (n = e[s]) && (l = (r < 3 ? n(l) : r > 3 ? n(o, t, l) : n(o, t)) || l); 23 } 24 } 25 return r > 3 && l && Object.defineProperty(o, t, l), l; 26}; 27const fs = requireNapi('file.fs'); 28const fileUri = requireNapi('file.fileuri'); 29const bundleManager = requireNapi('bundle.bundleManager'); 30const photoAccessHelper = requireNapi('file.photoAccessHelper'); 31const FILTER_MEDIA_TYPE_ALL = 'FILTER_MEDIA_TYPE_ALL'; 32const FILTER_MEDIA_TYPE_IMAGE = 'FILTER_MEDIA_TYPE_IMAGE'; 33const FILTER_MEDIA_TYPE_VIDEO = 'FILTER_MEDIA_TYPE_VIDEO'; 34const FILTER_MEDIA_TYPE_IMAGE_MOVING_PHOTO = 'FILTER_MEDIA_TYPE_IMAGE_MOVING_PHOTO'; 35 36export class PhotoPickerComponent extends ViewPU { 37 constructor(e, o, t, i = -1, n = void 0) { 38 super(e, t, i); 39 'function' === typeof n && (this.paramsGenerator_ = n); 40 this.pickerOptions = void 0; 41 this.onSelect = void 0; 42 this.onDeselect = void 0; 43 this.onItemClicked = void 0; 44 this.onEnterPhotoBrowser = void 0; 45 this.onExitPhotoBrowser = void 0; 46 this.onPickerControllerReady = void 0; 47 this.onPhotoBrowserChanged = void 0; 48 this.onSelectedItemsDeleted = void 0; 49 this.onExceedMaxSelected = void 0; 50 this.onCurrentAlbumDeleted = void 0; 51 this.onVideoPlayStateChanged = void 0; 52 this.__pickerController = new SynchedPropertyNesedObjectPU(o.pickerController, this, 'pickerController'); 53 this.proxy = void 0; 54 this.setInitiallyProvidedValue(o); 55 this.declareWatch('pickerController', this.onChanged); 56 } 57 58 setInitiallyProvidedValue(e) { 59 void 0 !== e.pickerOptions && (this.pickerOptions = e.pickerOptions); 60 void 0 !== e.onSelect && (this.onSelect = e.onSelect); 61 void 0 !== e.onDeselect && (this.onDeselect = e.onDeselect); 62 void 0 !== e.onItemClicked && (this.onItemClicked = e.onItemClicked); 63 void 0 !== e.onEnterPhotoBrowser && (this.onEnterPhotoBrowser = e.onEnterPhotoBrowser); 64 void 0 !== e.onExitPhotoBrowser && (this.onExitPhotoBrowser = e.onExitPhotoBrowser); 65 void 0 !== e.onPhotoBrowserChanged && (this.onPhotoBrowserChanged = e.onPhotoBrowserChanged); 66 void 0 !== e.onPickerControllerReady && (this.onPickerControllerReady = e.onPickerControllerReady); 67 void 0 !== e.onSelectedItemsDeleted && (this.onSelectedItemsDeleted = e.onSelectedItemsDeleted); 68 void 0 !== e.onExceedMaxSelected && (this.onExceedMaxSelected = e.onExceedMaxSelected); 69 void 0 !== e.onCurrentAlbumDeleted && (this.onCurrentAlbumDeleted = e.onCurrentAlbumDeleted); 70 void 0 !== e.onVideoPlayStateChanged && (this.onVideoPlayStateChanged = e.onVideoPlayStateChanged); 71 this.__pickerController.set(e.pickerController); 72 void 0 !== e.proxy && (this.proxy = e.proxy); 73 } 74 75 updateStateVars(e) { 76 this.__pickerController.set(e.pickerController); 77 } 78 79 purgeVariableDependenciesOnElmtId(e) { 80 this.__pickerController.purgeDependencyOnElmtId(e); 81 } 82 83 aboutToBeDeleted() { 84 this.__pickerController.aboutToBeDeleted(); 85 SubscriberManager.Get().delete(this.id__()); 86 this.aboutToBeDeletedInternal(); 87 } 88 89 get pickerController() { 90 return this.__pickerController.get(); 91 } 92 93 onChanged() { 94 var e; 95 if (!this.proxy) { 96 return; 97 } 98 let o = null === (e = this.pickerController) || void 0 === e ? void 0 : e.data; 99 if (null == o ? void 0 : o.has('SET_SELECTED_URIS')) { 100 this.proxy.send({ selectUris: null == o ? void 0 : o.get('SET_SELECTED_URIS') }); 101 console.info('PhotoPickerComponent onChanged: SET_SELECTED_URIS'); 102 } else if (null == o ? void 0 : o.has('SET_ALBUM_URI')) { 103 this.proxy.send({ albumUri: null == o ? void 0 : o.get('SET_ALBUM_URI') }); 104 console.info('PhotoPickerComponent onChanged: SET_ALBUM_URI'); 105 } else if (null == o ? void 0 : o.has('SET_MAX_SELECT_COUNT')) { 106 this.onSetMaxSelectCount(o); 107 } else if (null == o ? void 0 : o.has('SET_PHOTO_BROWSER_ITEM')) { 108 this.onSetPhotoBrowserItem(o); 109 } else if (null == o ? void 0 : o.has('EXIT_PHOTO_BROWSER')) { 110 this.handleExitPhotoBrowser(); 111 } else { 112 this.otherOnChange(o); 113 } 114 } 115 116 otherOnChange(o) { 117 if (null == o ? void 0 : o.has('SET_PHOTO_BROWSER_UI_ELEMENT_VISIBILITY')) { 118 this.onSetPhotoBrowserUIElementVisibility(o); 119 } else if (null == o ? void 0 : o.has('CREATE_URI')) { 120 this.onCreateUri(o); 121 console.info('PhotoPickerComponent onChanged: CREATE_URI'); 122 } else if (null == o ? void 0 : o.has('REPLACE_URI')) { 123 this.onReplaceUri(o); 124 console.info('PhotoPickerComponent onChanged: REPLACE_URI'); 125 } else if (null == o ? void 0 : o.has('SAVE_REPLACE_PHOTO_ASSETS')) { 126 this.onSaveTrustedPhotoAssets(o); 127 console.info('PhotoPickerComponent onChanged: SAVE_REPLACE_PHOTO_ASSETS'); 128 } else { 129 console.info('PhotoPickerComponent onChanged: other case'); 130 } 131 } 132 133 onSetMaxSelectCount(o) { 134 let e = null == o ? void 0 : o.get('SET_MAX_SELECT_COUNT'); 135 let t = null == e ? void 0 : e.data; 136 this.proxy.send({ 137 totalCount: null == t ? void 0 : t.get(MaxCountType.TOTAL_MAX_COUNT), 138 photoCount: null == t ? void 0 : t.get(MaxCountType.PHOTO_MAX_COUNT), 139 videoCount: null == t ? void 0 : t.get(MaxCountType.VIDEO_MAX_COUNT) 140 }); 141 console.info('PhotoPickerComponent onChanged: SET_MAX_SELECT_COUNT'); 142 } 143 144 onSetPhotoBrowserItem(o) { 145 let e = null == o ? void 0 : o.get('SET_PHOTO_BROWSER_ITEM'); 146 this.proxy.send({ 147 itemUri: null == e ? void 0 : e.uri, 148 photoBrowserRange: null == e ? void 0 : e.photoBrowserRange 149 }); 150 console.info('PhotoPickerComponent onChanged: SET_PHOTO_BROWSER_ITEM'); 151 } 152 153 handleExitPhotoBrowser() { 154 this.proxy.send({ exitPhotoBrowser: true }); 155 console.info('PhotoPickerComponent onChanged: EXIT_PHOTO_BROWSER'); 156 } 157 158 onSetPhotoBrowserUIElementVisibility(o) { 159 let e = null == o ? void 0 : o.get('SET_PHOTO_BROWSER_UI_ELEMENT_VISIBILITY'); 160 this.proxy.send({ 161 elements: null == e ? void 0 : e.elements, 162 isVisible: null == e ? void 0 : e.isVisible 163 }); 164 console.info('PhotoPickerComponent onChanged: SET_PHOTO_BROWSER_UI_ELEMENT_VISIBILITY'); 165 } 166 167 onCreateUri(o) { 168 let e = null == o ? void 0 : o.get('CREATE_URI'); 169 this.proxy.send({ 170 selectedMediaUri: null == e ? void 0 : e[0], 171 createUri: null == e ? void 0 : e[1], 172 date: null == e ? void 0 : e[2] 173 }); 174 console.info('PhotoPickerComponent onChanged CREATE_URI '); 175 } 176 177 onReplaceUri(o) { 178 let e = null == o ? void 0 : o.get('REPLACE_URI'); 179 this.proxy.send({ 180 oriUri: null == e ? void 0 : e[0], 181 replaceUri: null == e ? void 0 : e[1], 182 date: null == e ? void 0 : e[2] 183 }); 184 console.info('PhotoPickerComponent onChanged REPLACE_URI'); 185 } 186 187 onSaveTrustedPhotoAssets(o) { 188 let e = null == o ? void 0 : o.get('SAVE_REPLACE_PHOTO_ASSETS'); 189 this.proxy.send({ 190 replaceUris: null == e ? void 0 : e[0], 191 config: null == e ? void 0 : e[1], 192 saveMode: null == e ? void 0 : e[2], 193 appName: null == e ? void 0 : e[3], 194 date: null == e ? void 0 : e[4] 195 }); 196 console.info('PhotoPickerComponent onChanged SAVE_REPLACE_PHOTO_ASSETS'); 197 } 198 199 initialRender() { 200 this.observeComponentCreation2(((e, o) => { 201 Row.create(); 202 Row.height('100%'); 203 }), Row); 204 this.observeComponentCreation2(((e, o) => { 205 Column.create(); 206 Column.width('100%'); 207 }), Column); 208 this.observeComponentCreation2(((e, o) => { 209 var t, i, n, r, l, s, c, p, a, d, h, E, C, T, m, P, _, b, d; 210 SecurityUIExtensionComponent.create({ 211 parameters: { 212 'ability.want.params.uiExtensionTargetType': 'photoPicker', 213 uri: 'multipleselect', 214 targetPage: 'photoPage', 215 filterMediaType: this.convertMIMETypeToFilterType(null === (t = this.pickerOptions) || void 0 === t ? void 0 : t.MIMEType), 216 maxSelectNumber: null === (i = this.pickerOptions) || void 0 === i ? void 0 : i.maxSelectNumber, 217 isPhotoTakingSupported: null === (n = this.pickerOptions) || void 0 === n ? void 0 : n.isPhotoTakingSupported, 218 isEditSupported: !1, 219 recommendationOptions: null === (r = this.pickerOptions) || void 0 === r ? void 0 : r.recommendationOptions, 220 preselectedUri: null === (l = this.pickerOptions) || void 0 === l ? void 0 : l.preselectedUris, 221 isFromPickerView: !0, 222 isNeedActionBar: !1, 223 isNeedSelectBar: !1, 224 isSearchSupported: null === (s = this.pickerOptions) || void 0 === s ? void 0 : s.isSearchSupported, 225 checkBoxColor: null === (c = this.pickerOptions) || void 0 === c ? void 0 : c.checkBoxColor, 226 backgroundColor: null === (p = this.pickerOptions) || void 0 === p ? void 0 : p.backgroundColor, 227 checkboxTextColor: null === (a = this.pickerOptions) || void 0 === a ? void 0 : a.checkboxTextColor, 228 photoBrowserBackgroundColorMode: null === (d = this.pickerOptions) || void 0 === d ? void 0 : d.photoBrowserBackgroundColorMode, 229 isRepeatSelectSupported: null === (h = this.pickerOptions) || void 0 === h ? void 0 : h.isRepeatSelectSupported, 230 maxSelectedReminderMode: null === (E = this.pickerOptions) || void 0 === E ? void 0 : E.maxSelectedReminderMode, 231 orientation: null === (C = this.pickerOptions) || void 0 === C ? void 0 : C.orientation, 232 selectMode: null === (T = this.pickerOptions) || void 0 === T ? void 0 : T.selectMode, 233 maxPhotoSelectNumber: null === (m = this.pickerOptions) || void 0 === m ? void 0 : m.maxPhotoSelectNumber, 234 maxVideoSelectNumber: null === (P = this.pickerOptions) || void 0 === P ? void 0 : P.maxVideoSelectNumber, 235 isOnItemClickedSet: !!this.onItemClicked, 236 isPreviewForSingleSelectionSupported: null === (_ = this.pickerOptions) || void 0 === _ ? void 0 : _.isPreviewForSingleSelectionSupported, 237 isSlidingSelectionSupported: null === (b = this.pickerOptions) || void 0 === b ? void 0 : b.isSlidingSelectionSupported, 238 photoBrowserCheckboxPosition: null === (d = this.pickerOptions) || void 0 === d ? void 0 : d.photoBrowserCheckboxPosition, 239 gridMargin: null === (_ = this.pickerOptions) || void 0 === _ ? void 0 : _.gridMargin, 240 photoBrowserMargin: null === (_ = this.pickerOptions) || void 0 === _ ? void 0 : _.photoBrowserMargin 241 } 242 }); 243 SecurityUIExtensionComponent.height('100%'); 244 SecurityUIExtensionComponent.width('100%'); 245 SecurityUIExtensionComponent.onRemoteReady((e => { 246 this.proxy = e; 247 console.info('PhotoPickerComponent onRemoteReady'); 248 })); 249 SecurityUIExtensionComponent.onReceive((e => { 250 let o = e; 251 this.handleOnReceive(o); 252 })); 253 SecurityUIExtensionComponent.onError((() => { 254 console.info('PhotoPickerComponent onError'); 255 })); 256 }), SecurityUIExtensionComponent); 257 Column.pop(); 258 Row.pop(); 259 } 260 261 handleOnReceive(e) { 262 let o = e.dataType; 263 console.info('PhotoPickerComponent onReceive: dataType = ' + o); 264 if ('selectOrDeselect' === o) { 265 this.handleSelectOrDeselect(e); 266 } else if ('itemClick' === o) { 267 this.handleItemClick(e); 268 } else if ('onPhotoBrowserStateChanged' === o) { 269 this.handleEnterOrExitPhotoBrowser(e); 270 } else if ('remoteReady' === o) { 271 if (this.onPickerControllerReady) { 272 this.onPickerControllerReady(); 273 console.info('PhotoPickerComponent onReceive: onPickerControllerReady'); 274 } 275 } else if ('replaceCallback' === o) { 276 this.handleReplaceCallback(e); 277 } else if ('createCallback' === o) { 278 this.handleCreateCallback(e); 279 } else if ('saveCallback' === o) { 280 this.handleSaveCallback(e); 281 } else if ('onPhotoBrowserChanged' === o) { 282 this.handlePhotoBrowserChange(e); 283 } else if ('onVideoPlayStateChanged' === o) { 284 this.handleVideoPlayStateChanged(e); 285 } else { 286 this.handleOtherOnReceive(e); 287 console.info('PhotoPickerComponent onReceive: other case'); 288 } 289 console.info('PhotoPickerComponent onReceive' + JSON.stringify(e)); 290 } 291 292 handleOtherOnReceive(e) { 293 let o = e.dataType; 294 if ('exceedMaxSelected' === o) { 295 if (this.onExceedMaxSelected) { 296 this.onExceedMaxSelected(e.maxCountType); 297 } 298 } else if ('selectedItemsDeleted' === o) { 299 if (this.onSelectedItemsDeleted) { 300 this.onSelectedItemsDeleted(e.selectedItemInfos); 301 } 302 } else if ('currentAlbumDeleted' === o) { 303 if (this.onCurrentAlbumDeleted) { 304 this.onCurrentAlbumDeleted(); 305 } 306 } else { 307 console.info('PhotoPickerComponent onReceive: other case'); 308 } 309 } 310 311 handleSelectOrDeselect(e) { 312 if (e.isSelect) { 313 if (this.onSelect) { 314 this.onSelect(e['select-item-list']); 315 console.info('PhotoPickerComponent onReceive: onSelect'); 316 } 317 } else if (this.onDeselect) { 318 this.onDeselect(e['select-item-list']); 319 console.info('PhotoPickerComponent onReceive: onDeselect'); 320 } 321 } 322 323 handleItemClick(e) { 324 if (this.onItemClicked) { 325 let o = ClickType.SELECTED; 326 let t = e.clickType; 327 'select' === t ? o = ClickType.SELECTED : 'deselect' === t ? o = ClickType.DESELECTED : console.info('PhotoPickerComponent onReceive: other clickType'); 328 let i = new ItemInfo; 329 let n = e.itemType; 330 'thumbnail' === n ? i.itemType = ItemType.THUMBNAIL : 'camera' === n ? i.itemType = ItemType.CAMERA : console.info('PhotoPickerComponent onReceive: other itemType'); 331 i.uri = e.uri; 332 i.mimeType = e.mimeType; 333 i.width = e.width; 334 i.height = e.height; 335 i.size = e.size; 336 i.duration = e.duration; 337 let r = this.onItemClicked(i, o); 338 console.info('PhotoPickerComponent onReceive: onItemClicked = ' + o); 339 if (this.proxy) { 340 if ('thumbnail' === n && o === ClickType.SELECTED) { 341 this.proxy.send({ clickConfirm: i.uri, isConfirm: r }); 342 console.info('PhotoPickerComponent onReceive: click confirm: uri = ' + i.uri + 'isConfirm = ' + r); 343 } 344 if ('camera' === n) { 345 this.proxy.send({ enterCamera: r }); 346 console.info('PhotoPickerComponent onReceive: enter camera ' + r); 347 } 348 } 349 } 350 } 351 352 handleEnterOrExitPhotoBrowser(e) { 353 let o = e.isEnter; 354 let t = new PhotoBrowserInfo; 355 t.animatorParams = new AnimatorParams; 356 t.animatorParams.duration = e.duration; 357 t.animatorParams.curve = e.curve; 358 o ? this.onEnterPhotoBrowser && this.onEnterPhotoBrowser(t) : this.onExitPhotoBrowser && this.onExitPhotoBrowser(t); 359 console.info('PhotoPickerComponent onReceive: onPhotoBrowserStateChanged = ' + o); 360 } 361 362 handlePhotoBrowserChange(e) { 363 let o = new BaseItemInfo(); 364 o.uri = e.uri; 365 if (this.onPhotoBrowserChanged) { 366 this.onPhotoBrowserChanged(o); 367 } 368 console.info('PhotoPickerComponent onReceive: onPhotoBrowserChanged = ' + o.uri); 369 } 370 371 handleVideoPlayStateChanged(e) { 372 if (this.onVideoPlayStateChanged) { 373 this.onVideoPlayStateChanged(e.state); 374 console.info('PhotoPickerComponent onReceive: onVideoPlayStateChanged = ' + JSON.stringify(e)); 375 } 376 } 377 378 handleCreateCallback(e) { 379 this.pickerController.actionCreateCallback(e.grantUri, e.date, e.code, e.message); 380 console.info('PhotoPickerComponent onReceive: handleCreateCallback'); 381 } 382 383 handleReplaceCallback(e) { 384 this.pickerController.actionReplaceCallback(e.date, {'name': '', 'code': e.code, 'message': e.message}); 385 console.info('PhotoPickerComponent onReceive: handleReplaceCallback'); 386 } 387 388 handleSaveCallback(e) { 389 this.pickerController.actionSaveCallback(e.date, {'name': '', 'code': e.code, 'message': e.message}, e.data); 390 console.info('PhotoPickerComponent onReceive: handleSaveCallback'); 391 } 392 393 convertMIMETypeToFilterType(e) { 394 let o; 395 if (e === photoAccessHelper.PhotoViewMIMETypes.IMAGE_TYPE) { 396 o = FILTER_MEDIA_TYPE_IMAGE; 397 } else if (e === photoAccessHelper.PhotoViewMIMETypes.VIDEO_TYPE) { 398 o = FILTER_MEDIA_TYPE_VIDEO; 399 } else if (e === photoAccessHelper.PhotoViewMIMETypes.MOVING_PHOTO_IMAGE_TYPE) { 400 o = FILTER_MEDIA_TYPE_IMAGE_MOVING_PHOTO; 401 } else { 402 o = FILTER_MEDIA_TYPE_ALL; 403 } 404 console.info('PhotoPickerComponent convertMIMETypeToFilterType: ' + JSON.stringify(o)); 405 return o; 406 } 407 408 rerender() { 409 this.updateDirtyElements(); 410 } 411} 412let PickerController = class { 413 constructor() { 414 this.replaceCallbackMap = new Map(); 415 this.saveCallbackMap = new Map(); 416 this.createCallbackMap = new Map(); 417 } 418 setData(e, o) { 419 if (o === undefined) { 420 return; 421 } 422 if (e === DataType.SET_SELECTED_URIS) { 423 if (o instanceof Array) { 424 let e = o; 425 if (e) { 426 this.data = new Map([['SET_SELECTED_URIS', [...e]]]); 427 console.info('PhotoPickerComponent SET_SELECTED_URIS' + JSON.stringify(e)); 428 } 429 } 430 } else if (e === DataType.SET_ALBUM_URI) { 431 let e = o; 432 if (e !== undefined) { 433 this.data = new Map([['SET_ALBUM_URI', e]]); 434 console.info('PhotoPickerComponent SET_ALBUM_URI' + JSON.stringify(e)); 435 } 436 } else { 437 console.info('PhotoPickerComponent setData: other case'); 438 } 439 } 440 441 setMaxSelected(e) { 442 if (e) { 443 this.data = new Map([['SET_MAX_SELECT_COUNT', e]]); 444 console.info('PhotoPickerComponent SET_MAX_SELECT_COUNT' + JSON.stringify(e)); 445 } 446 } 447 448 setPhotoBrowserItem(e, o) { 449 let l = new PhotoBrowserRangeInfo; 450 l.uri = e; 451 let m = o ? o : PhotoBrowserRange.ALL; 452 l.photoBrowserRange = m; 453 this.data = new Map([['SET_PHOTO_BROWSER_ITEM', l]]); 454 console.info('PhotoPickerComponent SET_PHOTO_BROWSER_ITEM ' + JSON.stringify(l)); 455 } 456 457 exitPhotoBrowser() { 458 this.data = new Map([['EXIT_PHOTO_BROWSER', true]]); 459 console.info('PhotoPickerComponent EXIT_PHOTO_BROWSER '); 460 } 461 462 async getAppName() { 463 let flags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_ABILITY | 464 bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_HAP_MODULE | 465 bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_SIGNATURE_INFO | 466 bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION; 467 let c2 = bundleManager.getBundleInfoForSelfSync(flags); 468 let labelId = c2.appInfo.labelId; 469 let appName = ''; 470 let moduleName = ''; 471 for (let d2 of c2.hapModulesInfo) { 472 if (labelId === d2.labelId) { 473 moduleName = d2.name; 474 } 475 } 476 appName = await getContext(this).createModuleContext(moduleName).resourceManager.getStringValue(labelId); 477 return appName; 478 } 479 480 replacePhotoPickerPreview(e, o, callback) { 481 try { 482 let fd = fs.openSync(o).fd; 483 fs.close(fd); 484 } catch (err) { 485 callback({'code': 13900002, 'message': 'No such file', name: ''}); 486 return; 487 } 488 let date = Math.random(); 489 this.data = new Map([['CREATE_URI', [e, o, date]]]); 490 this.createCallbackMap.set(date, (grantUri, code, message)=>{ 491 if (code !== 0) { 492 callback({'code': code, 'message': message, name: ''}); 493 return; 494 } 495 let createFd = 0; 496 let replaceFd = 0; 497 try { 498 createFd = fs.openSync(grantUri, fs.OpenMode.READ_WRITE).fd; 499 replaceFd = fs.openSync(o, fs.OpenMode.READ_ONLY).fd; 500 fs.copyFileSync(replaceFd, createFd); 501 this.data = new Map([['REPLACE_URI', [e, grantUri, date]]]); 502 this.replaceCallbackMap.set(date, callback); 503 } catch (err) { 504 callback({'code': 14000011, 'message': 'System inner fail', name: ''}); 505 } finally { 506 fs.close(createFd); 507 fs.close(replaceFd); 508 } 509 }); 510 } 511 512 saveTrustedPhotoAssets(e, callback, config, saveMode) { 513 if (!e || e.length === 0) { 514 callback({'code': 14000002, 'message': 'Invalid URI', name: ''}, []); 515 return; 516 } 517 this.getAppName().then((appName) => { 518 let date = Math.random(); 519 this.data = new Map([['SAVE_REPLACE_PHOTO_ASSETS', [e, config, saveMode, appName, date]]]); 520 this.saveCallbackMap.set(date, callback); 521 console.info('PhotoPickerComponent SAVE_TRUSTED_PHOTO_ASSETS '); 522 }); 523 } 524 525 actionCreateCallback(grantUri, date, code, message) { 526 if (this.createCallbackMap.has(date)) { 527 let callback = this.createCallbackMap.get(date); 528 if (callback) { 529 callback(grantUri, code, message); 530 this.createCallbackMap.delete(date); 531 } 532 } 533 } 534 535 actionReplaceCallback(date, err) { 536 if (this.replaceCallbackMap.has(date)) { 537 let callback = this.replaceCallbackMap.get(date); 538 if (callback) { 539 callback(err); 540 this.replaceCallbackMap.delete(date); 541 } 542 } 543 } 544 545 actionSaveCallback(date, err, data) { 546 if (this.saveCallbackMap.has(date)) { 547 let callback = this.saveCallbackMap.get(date); 548 if (callback) { 549 callback(err, data); 550 this.saveCallbackMap.delete(date); 551 } 552 } 553 } 554 555 setPhotoBrowserUIElementVisibility(e, o) { 556 let m = new PhotoBrowserUIElementVisibility; 557 m.elements = e; 558 m.isVisible = o; 559 this.data = new Map([['SET_PHOTO_BROWSER_UI_ELEMENT_VISIBILITY', m]]); 560 console.info('PhotoPickerComponent SET_PHOTO_BROWSER_UI_ELEMENT_VISIBILITY ' + JSON.stringify(m)); 561 } 562}; 563PickerController = __decorate([Observed], PickerController); 564 565export class PickerOptions extends photoAccessHelper.BaseSelectOptions { 566} 567 568export class BaseItemInfo { 569} 570 571export class ItemInfo extends BaseItemInfo { 572} 573 574export class PhotoBrowserInfo { 575} 576 577export class AnimatorParams { 578} 579 580export class MaxSelected { 581} 582 583class PhotoBrowserRangeInfo { 584} 585 586class PhotoBrowserUIElementVisibility { 587} 588 589export var DataType; 590!function(e) { 591 e[e.SET_SELECTED_URIS = 1] = 'SET_SELECTED_URIS'; 592 e[e.SET_ALBUM_URI = 2] = 'SET_ALBUM_URI'; 593}(DataType || (DataType = {})); 594 595export var ItemType; 596!function(e) { 597 e[e.THUMBNAIL = 0] = 'THUMBNAIL'; 598 e[e.CAMERA = 1] = 'CAMERA'; 599}(ItemType || (ItemType = {})); 600 601export var ClickType; 602!function(e) { 603 e[e.SELECTED = 0] = 'SELECTED'; 604 e[e.DESELECTED = 1] = 'DESELECTED'; 605}(ClickType || (ClickType = {})); 606 607export var PickerOrientation; 608!function(e) { 609 e[e.VERTICAL = 0] = 'VERTICAL'; 610 e[e.HORIZONTAL = 1] = 'HORIZONTAL'; 611}(PickerOrientation || (PickerOrientation = {})); 612 613export var SelectMode; 614!function(e) { 615 e[e.SINGLE_SELECT = 0] = 'SINGLE_SELECT'; 616 e[e.MULTI_SELECT = 1] = 'MULTI_SELECT'; 617}(SelectMode || (SelectMode = {})); 618 619export var PickerColorMode; 620!function(e) { 621 e[e.AUTO = 0] = 'AUTO'; 622 e[e.LIGHT = 1] = 'LIGHT'; 623 e[e.DARK = 2] = 'DARK'; 624}(PickerColorMode || (PickerColorMode = {})); 625 626export var ReminderMode; 627!function(e) { 628 e[e.NONE = 0] = 'NONE'; 629 e[e.TOAST = 1] = 'TOAST'; 630 e[e.MASK = 2] = 'MASK'; 631}(ReminderMode || (ReminderMode = {})); 632 633export var MaxCountType; 634!function(e) { 635 e[e.TOTAL_MAX_COUNT = 0] = 'TOTAL_MAX_COUNT'; 636 e[e.PHOTO_MAX_COUNT = 1] = 'PHOTO_MAX_COUNT'; 637 e[e.VIDEO_MAX_COUNT = 2] = 'VIDEO_MAX_COUNT'; 638}(MaxCountType || (MaxCountType = {})); 639 640export var PhotoBrowserRange; 641!function(e) { 642 e[e.ALL = 0] = 'ALL'; 643 e[e.SELECTED_ONLY = 1] = 'SELECTED_ONLY'; 644}(PhotoBrowserRange || (PhotoBrowserRange = {})); 645 646export var PhotoBrowserUIElement; 647!function(e) { 648 e[e.CHECKBOX = 0] = 'CHECKBOX'; 649 e[e.BACK_BUTTON = 1] = 'BACK_BUTTON'; 650}(PhotoBrowserUIElement || (PhotoBrowserUIElement = {})); 651 652export var VideoPlayerState; 653!function(e) { 654 e[e.PLAYING = 0] = 'PLAYING'; 655 e[e.PAUSED = 1] = 'PAUSED'; 656 e[e.STOPPED = 2] = 'STOPPED'; 657 e[e.SEEK_START = 3] = 'SEEK_START'; 658 e[e.SEEK_FINISH = 4] = 'SEEK_FINISH'; 659}(VideoPlayerState || (VideoPlayerState = {})); 660 661export var SaveMode; 662!function(e) { 663 e[e.SAVE_AS = 0] = 'SAVE_AS'; 664 e[e.OVERWRITE = 1] = 'OVERWRITE'; 665}(SaveMode || (SaveMode = {})); 666 667export default { PhotoPickerComponent, PickerController, PickerOptions, DataType, BaseItemInfo, ItemInfo, PhotoBrowserInfo, AnimatorParams, 668 MaxSelected, ItemType, ClickType, PickerOrientation, SelectMode, PickerColorMode, ReminderMode, MaxCountType, PhotoBrowserRange, PhotoBrowserUIElement, 669 VideoPlayerState, SaveMode};