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