From 3fb001d05f2a700ea677556c9aa081e4693d1dfa Mon Sep 17 00:00:00 2001 From: aziztek Date: Fri, 15 Aug 2025 19:26:13 +0300 Subject: [PATCH 1/4] Add UpdatablePickerOptions support to dynamically update picker settings at runtime Signed-off-by: aziztek --- api/@ohos.file.PhotoPickerComponent.d.ets | 162 ++++++++++++++++++++++ kits/@kit.MediaLibraryKit.d.ts | 4 +- 2 files changed, 164 insertions(+), 2 deletions(-) diff --git a/api/@ohos.file.PhotoPickerComponent.d.ets b/api/@ohos.file.PhotoPickerComponent.d.ets index 52885ab0e0..35c7db4ff7 100644 --- a/api/@ohos.file.PhotoPickerComponent.d.ets +++ b/api/@ohos.file.PhotoPickerComponent.d.ets @@ -301,6 +301,16 @@ export declare class PickerController { */ saveTrustedPhotoAssets(trustedUris: Array, callback: AsyncCallback>, configs?: Array, saveMode?: SaveMode): void; + + /** + * Update picker options + * + * @param { UpdatablePickerOptions } updatablePickerOptions - for update picker options + * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core + * @atomicservice + * @since 20 + */ + updatePickerOptions(updatablePickerOptions: UpdatablePickerOptions): Promise; } /** @@ -688,6 +698,158 @@ export declare class SingleLineConfig { itemGap?: Length; } +/** + * UpdatablePickerOptions + * + * Dynamic options that can be applied to PhotoPickerComponent at runtime. + * Use this to adjust filtering, selection limits, visuals and behavior without + * recreating the component. + * + * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core + * @atomicservice + * @since 20 + */ +export declare class UpdatablePickerOptions { + /** + * MIME types to display in the picker (photos, videos or both). + * + * @type { ?photoAccessHelper.PhotoViewMIMETypes } + * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core + * @atomicservice + * @since 20 + */ + MIMEType?: photoAccessHelper.PhotoViewMIMETypes; + + /** + * Fine-grained MIME type filter. When set, only items matching the filter are shown. + * Takes effect together with MIMEType; the intersection is applied. + * + * @type { ?photoAccessHelper.MimeTypeFilter } + * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core + * @atomicservice + * @since 20 + */ + mimeTypeFilter?: photoAccessHelper.MimeTypeFilter; + + /** + * Maximum total number of selectable items (photos + videos). + * If both per-type limits and this value are set, the strictest limit applies. + * + * @type { ?number } + * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core + * @atomicservice + * @since 20 + */ + maxSelectNumber?: number; + + /** + * Maximum number of selectable photos. + * + * @type { ?number } + * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core + * @atomicservice + * @since 20 + */ + maxPhotoSelectNumber?: number; + + /** + * Maximum number of selectable videos. + * + * @type { ?number } + * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core + * @atomicservice + * @since 20 + */ + maxVideoSelectNumber?: number; + + /** + * Selection mode for the picker grid and detail pages. + * Controls whether selection happens in grid, browser, or both. + * + * @type { ?SelectMode } + * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core + * @atomicservice + * @since 20 + */ + selectMode?: SelectMode; + + /** + * Single-selection behavior when SelectMode enforces single item selection. + * Defines how single selection is presented and toggled. + * + * @type { ?SingleSelectMode } + * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core + * @atomicservice + * @since 20 + */ + singleSelectionMode?: photoAccessHelper.SingleSelectionMode; + + /** + * Whether the same item can be selected repeatedly. If disabled, selecting an + * already-selected item has no effect; if enabled, re-selection may trigger + * selection callbacks again. + * + * @type { ?boolean } + * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core + * @atomicservice + * @since 20 + */ + isRepeatSelectSupported?: boolean; + + /** + * Initial or updated list of preselected item URIs. + * When set, the picker will reflect these items as selected. + * Behavior with existing selections depends on component policy (merge/replace). + * + * @type { ?Array } + * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core + * @atomicservice + * @since 20 + */ + preselectedUris?: Array; + + /** + * Checkbox fill/border color used for selection indicators. + * + * @type { ?string } + * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core + * @atomicservice + * @since 20 + */ + checkBoxColor?: string; + + /** + * Checkbox text/label color (e.g., count badges). + * + * @type { ?string } + * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core + * @atomicservice + * @since 20 + */ + checkBoxTextColor?: string; + + /** + * Background color of the picker grid surfaces. + * + * @type { ?string } + * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core + * @atomicservice + * @since 20 + */ + backgroundColor?: string; + + /** + * Background color mode for the photo browser (detail view). + * Useful for switching between light/dark/adaptive modes. + * + * @type { ?PickerColorMode } + * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core + * @atomicservice + * @since 20 + */ + photoBrowserBackgroundColorMode?: PickerColorMode; +} + /** * DataType represents the type of the data set to picker component * diff --git a/kits/@kit.MediaLibraryKit.d.ts b/kits/@kit.MediaLibraryKit.d.ts index 901d6bec14..a0c03acc66 100644 --- a/kits/@kit.MediaLibraryKit.d.ts +++ b/kits/@kit.MediaLibraryKit.d.ts @@ -27,7 +27,7 @@ import { DataType, BaseItemInfo, ItemInfo, PhotoBrowserInfo, AnimatorParams, MaxSelected, ItemType, ClickType, PickerOrientation, SelectMode, PickerColorMode, ReminderMode, MaxCountType, PhotoBrowserRange, - PhotoBrowserUIElement, ItemsDeletedCallback, ExceedMaxSelectedCallback, CurrentAlbumDeletedCallback + PhotoBrowserUIElement, ItemsDeletedCallback, ExceedMaxSelectedCallback, CurrentAlbumDeletedCallback, UpdatablePickerOptions } from '@ohos.file.PhotoPickerComponent'; import { RecentPhotoComponent, RecentPhotoCheckResultCallback, @@ -43,5 +43,5 @@ export { AlbumPickerComponent, AlbumPickerOptions, AlbumInfo, EmptyAreaClickCallback, AlbumPickerController, RecentPhotoComponent, RecentPhotoCheckResultCallback, RecentPhotoClickCallback, RecentPhotoOptions, PhotoSource, - PhotoBrowserUIElement, ItemsDeletedCallback, ExceedMaxSelectedCallback, CurrentAlbumDeletedCallback + PhotoBrowserUIElement, ItemsDeletedCallback, ExceedMaxSelectedCallback, CurrentAlbumDeletedCallback, UpdatablePickerOptions }; -- Gitee From 0e3e85444d3f9083b34b318a5ffb0da96d52d2eb Mon Sep 17 00:00:00 2001 From: aziztek Date: Mon, 25 Aug 2025 11:46:59 +0300 Subject: [PATCH 2/4] update comments in UpdatablaPickerOptions Signed-off-by: aziztek --- api/@ohos.file.PhotoPickerComponent.d.ets | 84 ++++++++++------------- 1 file changed, 36 insertions(+), 48 deletions(-) diff --git a/api/@ohos.file.PhotoPickerComponent.d.ets b/api/@ohos.file.PhotoPickerComponent.d.ets index 35c7db4ff7..e51baa8c4c 100644 --- a/api/@ohos.file.PhotoPickerComponent.d.ets +++ b/api/@ohos.file.PhotoPickerComponent.d.ets @@ -302,13 +302,13 @@ export declare class PickerController { saveTrustedPhotoAssets(trustedUris: Array, callback: AsyncCallback>, configs?: Array, saveMode?: SaveMode): void; - /** - * Update picker options + /** + * Update options of the PhotoPicker component. * - * @param { UpdatablePickerOptions } updatablePickerOptions - for update picker options + * @param { UpdatablePickerOptions } updateConfig - Subset of PickerOptions * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core * @atomicservice - * @since 20 + * @since 21 */ updatePickerOptions(updatablePickerOptions: UpdatablePickerOptions): Promise; } @@ -701,151 +701,139 @@ export declare class SingleLineConfig { /** * UpdatablePickerOptions * - * Dynamic options that can be applied to PhotoPickerComponent at runtime. - * Use this to adjust filtering, selection limits, visuals and behavior without - * recreating the component. - * * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core * @atomicservice - * @since 20 + * @since 21 */ export declare class UpdatablePickerOptions { + /** - * MIME types to display in the picker (photos, videos or both). + * The type of the file in the recent photo window. * * @type { ?photoAccessHelper.PhotoViewMIMETypes } * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core * @atomicservice - * @since 20 + * @since 21 */ - MIMEType?: photoAccessHelper.PhotoViewMIMETypes; + mimeType?: photoAccessHelper.PhotoViewMIMETypes; /** - * Fine-grained MIME type filter. When set, only items matching the filter are shown. - * Takes effect together with MIMEType; the intersection is applied. + * Media file filtering configuration. * * @type { ?photoAccessHelper.MimeTypeFilter } * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core * @atomicservice - * @since 20 + * @since 21 */ mimeTypeFilter?: photoAccessHelper.MimeTypeFilter; /** - * Maximum total number of selectable items (photos + videos). - * If both per-type limits and this value are set, the strictest limit applies. + * Maximum number of assets for a single selection. * * @type { ?number } * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core * @atomicservice - * @since 20 + * @since 21 */ maxSelectNumber?: number; /** - * Maximum number of selectable photos. + * Maximum number of photos for a single selection. * * @type { ?number } * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core * @atomicservice - * @since 20 + * @since 21 */ maxPhotoSelectNumber?: number; - /** - * Maximum number of selectable videos. + /** + * Maximum number of videos for a single selection. * * @type { ?number } * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core * @atomicservice - * @since 20 + * @since 21 */ maxVideoSelectNumber?: number; /** - * Selection mode for the picker grid and detail pages. - * Controls whether selection happens in grid, browser, or both. + * Select mode of the picker. * * @type { ?SelectMode } * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core * @atomicservice - * @since 20 + * @since 21 */ selectMode?: SelectMode; /** - * Single-selection behavior when SelectMode enforces single item selection. - * Defines how single selection is presented and toggled. + * The mode of single selection. * - * @type { ?SingleSelectMode } + * @type { ?photoAccessHelper.SingleSelectionMode } * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core * @atomicservice - * @since 20 + * @since 21 */ singleSelectionMode?: photoAccessHelper.SingleSelectionMode; /** - * Whether the same item can be selected repeatedly. If disabled, selecting an - * already-selected item has no effect; if enabled, re-selection may trigger - * selection callbacks again. + * Support repeat select. * * @type { ?boolean } * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core * @atomicservice - * @since 20 + * @since 21 */ isRepeatSelectSupported?: boolean; /** - * Initial or updated list of preselected item URIs. - * When set, the picker will reflect these items as selected. - * Behavior with existing selections depends on component policy (merge/replace). + * The uri for the preselected files. * * @type { ?Array } * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core * @atomicservice - * @since 20 + * @since 21 */ preselectedUris?: Array; /** - * Checkbox fill/border color used for selection indicators. + * The checkbox color of the picker. * * @type { ?string } * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core * @atomicservice - * @since 20 + * @since 21 */ checkBoxColor?: string; /** - * Checkbox text/label color (e.g., count badges). + * The checkbox text color of the picker. * * @type { ?string } * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core * @atomicservice - * @since 20 + * @since 21 */ checkBoxTextColor?: string; /** - * Background color of the picker grid surfaces. + * The background color of the picker. * * @type { ?string } * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core * @atomicservice - * @since 20 + * @since 21 */ backgroundColor?: string; - /** - * Background color mode for the photo browser (detail view). - * Useful for switching between light/dark/adaptive modes. + /** + * Support to set photo browser background color mode. * * @type { ?PickerColorMode } * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core * @atomicservice - * @since 20 + * @since 21 */ photoBrowserBackgroundColorMode?: PickerColorMode; } -- Gitee From 0ae2e1faf8da81b8b5e394ddcb87c27d1f67973f Mon Sep 17 00:00:00 2001 From: aziztek Date: Tue, 2 Sep 2025 09:21:25 +0300 Subject: [PATCH 3/4] refactor: rename variables Signed-off-by: aziztek --- api/@ohos.file.PhotoPickerComponent.d.ets | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/@ohos.file.PhotoPickerComponent.d.ets b/api/@ohos.file.PhotoPickerComponent.d.ets index e51baa8c4c..3465f3fa0f 100644 --- a/api/@ohos.file.PhotoPickerComponent.d.ets +++ b/api/@ohos.file.PhotoPickerComponent.d.ets @@ -715,7 +715,7 @@ export declare class UpdatablePickerOptions { * @atomicservice * @since 21 */ - mimeType?: photoAccessHelper.PhotoViewMIMETypes; + MIMEType?: photoAccessHelper.PhotoViewMIMETypes; /** * Media file filtering configuration. @@ -815,7 +815,7 @@ export declare class UpdatablePickerOptions { * @atomicservice * @since 21 */ - checkBoxTextColor?: string; + checkboxTextColor?: string; /** * The background color of the picker. -- Gitee From 93b51d9747d9fd105c50632e1c4fddd14a8192ec Mon Sep 17 00:00:00 2001 From: aziztek Date: Mon, 8 Sep 2025 16:49:47 +0300 Subject: [PATCH 4/4] Add orientation, photoSubType and dynamicRangeType fields to BaseItemInfo Signed-off-by: aziztek --- api/@ohos.file.PhotoPickerComponent.d.ets | 31 +++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/api/@ohos.file.PhotoPickerComponent.d.ets b/api/@ohos.file.PhotoPickerComponent.d.ets index 3465f3fa0f..1130b7e6e6 100644 --- a/api/@ohos.file.PhotoPickerComponent.d.ets +++ b/api/@ohos.file.PhotoPickerComponent.d.ets @@ -569,6 +569,37 @@ export declare class BaseItemInfo { * @since 12 */ duration?: number; + + /** + * PhotoSubtype. Asset subtype, non-special type images default to DEFAULT(0). + * + * @type { ?photoAccessHelper.PhotoSubtype } + * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core + * @atomicservice + * @since 20 + */ + photoSubType?: photoAccessHelper.PhotoSubtype + + /** + * DynamicRangeType. Dynamic range type of media files. + * For movingPhoto, this specifically refers to the dynamic range type of the cover image. + * + * @type { ?photoAccessHelper.DynamicRangeType } + * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core + * @atomicservice + * @since 20 + */ + dynamicRangeType?: photoAccessHelper.DynamicRangeType + + /** + * Orientation. Image/Video orientation information. + * + * @type { ?number } + * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core + * @atomicservice + * @since 20 + */ + orientation?: number } /** -- Gitee