From 96e79cbf4ee550511ddcd3f117fe74ba3f732bd9 Mon Sep 17 00:00:00 2001 From: liujuan Date: Thu, 26 Oct 2023 03:29:59 +0000 Subject: [PATCH 01/12] update common/src/main/ets/default/view/BrowserController.ets. Signed-off-by: liujuan --- common/src/main/ets/default/view/BrowserController.ets | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/common/src/main/ets/default/view/BrowserController.ets b/common/src/main/ets/default/view/BrowserController.ets index 5a7a481e..1f09e203 100644 --- a/common/src/main/ets/default/view/BrowserController.ets +++ b/common/src/main/ets/default/view/BrowserController.ets @@ -62,7 +62,7 @@ export class BrowserController { }); } - hideBrowser(position: number): void { + hideBrowser(): void { Log.debug(TAG, 'call hide browser'); animateTo({ curve: Constants.SPRING_MOTION_CURVE, // 大图进出阻尼曲线参数 @@ -75,7 +75,7 @@ export class BrowserController { this.isBrowserShow = false; this.browserParam = undefined; this.isAnimating = true; - AppStorage.SetOrCreate('placeholderIndex', -(position + 1)); + AppStorage.SetOrCreate('placeholderIndex', -1); Log.info(TAG, `placeholderIndex ${AppStorage.get('placeholderIndex')}`); }); } @@ -98,7 +98,7 @@ export class BrowserController { }); } - hideSelectBrowser(position: number): void { + hideSelectBrowser(): void { Log.debug(TAG, 'call hide select browser'); animateTo({ curve: Constants.SPRING_MOTION_CURVE, // 大图进出阻尼曲线参数 @@ -111,7 +111,7 @@ export class BrowserController { this.isSelectBrowserShow = false; this.selectBrowserParam = undefined; this.isAnimating = true; - AppStorage.SetOrCreate('placeholderIndex', -(position + 1)); + AppStorage.SetOrCreate('placeholderIndex', -1); }); } From 10da0f0858d8e151fe2d455508e82e782984dc40 Mon Sep 17 00:00:00 2001 From: liujuan Date: Thu, 26 Oct 2023 03:30:52 +0000 Subject: [PATCH 02/12] update common/src/main/ets/default/utils/UiUtil.ts. Signed-off-by: liujuan --- common/src/main/ets/default/utils/UiUtil.ts | 46 --------------------- 1 file changed, 46 deletions(-) diff --git a/common/src/main/ets/default/utils/UiUtil.ts b/common/src/main/ets/default/utils/UiUtil.ts index 407eb745..1ff57f16 100644 --- a/common/src/main/ets/default/utils/UiUtil.ts +++ b/common/src/main/ets/default/utils/UiUtil.ts @@ -21,10 +21,6 @@ import prompt from '@system.prompt'; import type window from '@ohos.window'; import type { Action } from '../view/browserOperation/Action'; import { AlbumInfo } from '../model/browser/album/AlbumInfo'; -import { MediaDataSource } from '../model/browser/photo/MediaDataSource'; -import { BroadCast } from './BroadCast'; -import { ViewData } from '../model/browser/photo/ViewData'; -import { ViewType } from '../model/browser/photo/ViewType'; const TAG: string = 'common_UiUtil'; @@ -219,48 +215,6 @@ export class UiUtil { ', placeholderIndex = ' + geometryTapIndex); } - static getGeometryTransitionUri(geometryTransitionBrowserId: string, - geometryTransitionUri: string, broadCast: BroadCast): string { - if (geometryTransitionBrowserId === '') { - broadCast.emit(geometryTransitionUri + Constants.KEY_OF_GEOMETRY_TRANSITION_ID_HEIGHT, ['']); - return ''; - } - - let uriStartIndex = geometryTransitionBrowserId.indexOf('file'); - let uriEndIndex = geometryTransitionBrowserId.indexOf('????'); - let uri = geometryTransitionBrowserId.substring(uriStartIndex, uriEndIndex); - if (geometryTransitionUri !== '' && geometryTransitionUri !== uri) { - broadCast.emit(geometryTransitionUri + Constants.KEY_OF_GEOMETRY_TRANSITION_ID_HEIGHT, ['']); - } - broadCast.emit(uri + Constants.KEY_OF_GEOMETRY_TRANSITION_ID_HEIGHT, [geometryTransitionBrowserId]); - return uri; - } - - static emitByPlaceholderIndex(placeholderIndex: number, dataSource: MediaDataSource, broadCast: BroadCast): void { - if (placeholderIndex >= 0) { - let viewData: ViewData = dataSource.getWrappedData(placeholderIndex) as ViewData; - if (viewData && viewData.viewType === ViewType.ITEM && viewData.mediaItem) { - broadCast.emit(viewData.mediaItem.uri + Constants.KEY_OF_PLACE_HOLDER_INDEX, [true]); - } - - let leftData: ViewData = dataSource.getWrappedData(placeholderIndex - 1) as ViewData; - if (leftData && leftData.viewType === ViewType.ITEM && leftData.mediaItem) { - broadCast.emit(leftData.mediaItem.uri + Constants.KEY_OF_PLACE_HOLDER_INDEX, [false]); - } - - let rightData: ViewData = dataSource.getWrappedData(placeholderIndex + 1) as ViewData; - if (rightData && rightData.viewType === ViewType.ITEM && rightData.mediaItem) { - broadCast.emit(rightData.mediaItem.uri + Constants.KEY_OF_PLACE_HOLDER_INDEX, [false]); - } - } else { - let pos = -placeholderIndex - 1; - let viewData: ViewData = dataSource.getWrappedData(pos) as ViewData; - if (viewData && viewData.viewType === ViewType.ITEM && viewData.mediaItem) { - broadCast.emit(viewData.mediaItem.uri + Constants.KEY_OF_PLACE_HOLDER_INDEX, [false]); - } - } - } - static getRouterParams(params: Object): Object { let fakeRouterParam: Object = AppStorage.Get('fakeRouterParam'); AppStorage.Delete('fakeRouterParam'); From eafc47a9616359db9aaa3dbf81f7df112ef8a4bc Mon Sep 17 00:00:00 2001 From: liujuan Date: Thu, 26 Oct 2023 03:42:53 +0000 Subject: [PATCH 03/12] update feature/thirdselect/src/main/ets/default/view/ThirdSelectPhotoBrowserBase.ets. Signed-off-by: liujuan --- .../src/main/ets/default/view/ThirdSelectPhotoBrowserBase.ets | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/feature/thirdselect/src/main/ets/default/view/ThirdSelectPhotoBrowserBase.ets b/feature/thirdselect/src/main/ets/default/view/ThirdSelectPhotoBrowserBase.ets index 4d63a53b..add7df61 100644 --- a/feature/thirdselect/src/main/ets/default/view/ThirdSelectPhotoBrowserBase.ets +++ b/feature/thirdselect/src/main/ets/default/view/ThirdSelectPhotoBrowserBase.ets @@ -382,8 +382,7 @@ export struct ThirdSelectPhotoBrowserBase { } private onBackPressInner(): void { - let timelineIndex = this.dataSource.getPositionByIndex(this.currentIndex) as number; - this.browserController.hideBrowser(timelineIndex); + this.browserController.hideBrowser(); } private jumpBrowserCallback(name: string, item: MediaItem, isSelectMode = false) { From 69bfcb63d099982b6ad1cf42f155ff4ca8fd60b5 Mon Sep 17 00:00:00 2001 From: liujuan Date: Thu, 26 Oct 2023 03:58:16 +0000 Subject: [PATCH 04/12] update feature/thirdselect/src/main/ets/default/view/ThirdSelectPhotoGridBase.ets. Signed-off-by: liujuan --- .../src/main/ets/default/view/ThirdSelectPhotoGridBase.ets | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/feature/thirdselect/src/main/ets/default/view/ThirdSelectPhotoGridBase.ets b/feature/thirdselect/src/main/ets/default/view/ThirdSelectPhotoGridBase.ets index 5910a230..7bbf3d56 100644 --- a/feature/thirdselect/src/main/ets/default/view/ThirdSelectPhotoGridBase.ets +++ b/feature/thirdselect/src/main/ets/default/view/ThirdSelectPhotoGridBase.ets @@ -97,10 +97,9 @@ export struct ThirdSelectPhotoGridBase { onPlaceholderChanged() { Log.debug(TAG, 'onPlaceholderChanged placeholderIndex is ' + this.placeholderIndex); - if (this.placeholderIndex >= 0) { + if (this.placeholderIndex != -1) { this.scroller.scrollToIndex(this.placeholderIndex); } - UiUtil.emitByPlaceholderIndex(this.placeholderIndex, this.dataSource, this.broadCast); } onBrowserControllerChanged(): void { From 629647a3b4a26d93411c1f7f43bd6c7f1b3e0d69 Mon Sep 17 00:00:00 2001 From: liujuan Date: Thu, 26 Oct 2023 03:59:51 +0000 Subject: [PATCH 05/12] update feature/timeline/src/main/ets/view/TimelinePage.ets. Signed-off-by: liujuan --- .../timeline/src/main/ets/view/TimelinePage.ets | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/feature/timeline/src/main/ets/view/TimelinePage.ets b/feature/timeline/src/main/ets/view/TimelinePage.ets index ffb7a1a5..4f93f690 100644 --- a/feature/timeline/src/main/ets/view/TimelinePage.ets +++ b/feature/timeline/src/main/ets/view/TimelinePage.ets @@ -89,8 +89,6 @@ export struct TimelinePage { @Provide dateText: string = ''; @Provide isShowBar: boolean = true; @StorageLink('placeholderIndex') @Watch('onPlaceholderChanged') placeholderIndex: number = -1; - @StorageLink('geometryTransitionBrowserId') @Watch('onGeometryIdChange') geometryTransitionBrowserId: string = ''; - private geometryTransitionUri: string = ''; @ObjectLink browserController: BrowserController; @Provide hidePopup: boolean = false; // 选择模式下,鼠标对着未勾选项按右键弹框时,移动和复制菜单点击事件的标识位 @@ -100,20 +98,9 @@ export struct TimelinePage { onPlaceholderChanged() { Log.debug(TAG, 'onPlaceholderChanged placeholderIndex is ' + this.placeholderIndex); - if (this.placeholderIndex >= 0) { - // 照片页顶部信息也占一个GridItem,目标index应为图片的index+1 - this.scroller.scrollToIndex(this.placeholderIndex + 1); + if (this.placeholderIndex != -1) { + this.scroller.scrollToIndex(this.placeholderIndex); } - UiUtil.emitByPlaceholderIndex(this.placeholderIndex, this.dataSource, this.broadCast); - } - - onGeometryIdChange(): void { - if (!this.isInCurrentTab && !this.isActive) { - return; - } - Log.debug(TAG, 'onGeometryIdChange geometryTransitionBrowserId is ' + this.geometryTransitionBrowserId); - this.geometryTransitionUri = - UiUtil.getGeometryTransitionUri(this.geometryTransitionBrowserId, this.geometryTransitionUri, this.broadCast); } aboutToAppear(): void { From 23124b2e5feafe23f4c23e5305fd6c09a70e2051 Mon Sep 17 00:00:00 2001 From: liujuan Date: Thu, 26 Oct 2023 04:07:28 +0000 Subject: [PATCH 06/12] update product/phone/src/main/ets/pages/NewAlbumPage.ets. Signed-off-by: liujuan --- product/phone/src/main/ets/pages/NewAlbumPage.ets | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/product/phone/src/main/ets/pages/NewAlbumPage.ets b/product/phone/src/main/ets/pages/NewAlbumPage.ets index a542e891..ed33b6eb 100644 --- a/product/phone/src/main/ets/pages/NewAlbumPage.ets +++ b/product/phone/src/main/ets/pages/NewAlbumPage.ets @@ -91,10 +91,9 @@ export struct NewAlbumPage { onPlaceholderChanged() { Log.debug(TAG, 'onPlaceholderChanged placeholderIndex is ' + this.placeholderIndex); - if (this.placeholderIndex >= 0) { + if (this.placeholderIndex != -1) { this.scroller.scrollToIndex(this.placeholderIndex); } - UiUtil.emitByPlaceholderIndex(this.placeholderIndex, this.dataSource, this.broadCast); } onMenuClicked(action: Action) { From bbc670433f81511a5979be28d40a0b7b64fa1d19 Mon Sep 17 00:00:00 2001 From: liujuan Date: Thu, 26 Oct 2023 04:08:05 +0000 Subject: [PATCH 07/12] update product/phone/src/main/ets/view/PhotoBrowserComponent.ets. Signed-off-by: liujuan --- product/phone/src/main/ets/view/PhotoBrowserComponent.ets | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/product/phone/src/main/ets/view/PhotoBrowserComponent.ets b/product/phone/src/main/ets/view/PhotoBrowserComponent.ets index 70c5e6be..0d4b9119 100644 --- a/product/phone/src/main/ets/view/PhotoBrowserComponent.ets +++ b/product/phone/src/main/ets/view/PhotoBrowserComponent.ets @@ -662,8 +662,7 @@ export struct PhotoBrowserComponent { break } if (this.geometryTransitionEnable) { - let timelineIndex = this.dataSource.getPositionByIndex(this.currentIndex) as number; - this.browserController.hideBrowser(timelineIndex); + this.browserController.hideBrowser(); } else { router.back({ url: '', From b1127d04b39f1ba2044246e47b628422669a909f Mon Sep 17 00:00:00 2001 From: liujuan Date: Thu, 26 Oct 2023 04:08:33 +0000 Subject: [PATCH 08/12] update product/phone/src/main/ets/view/PhotoGridView.ets. Signed-off-by: liujuan --- product/phone/src/main/ets/view/PhotoGridView.ets | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/product/phone/src/main/ets/view/PhotoGridView.ets b/product/phone/src/main/ets/view/PhotoGridView.ets index b45928af..ce903386 100644 --- a/product/phone/src/main/ets/view/PhotoGridView.ets +++ b/product/phone/src/main/ets/view/PhotoGridView.ets @@ -122,10 +122,9 @@ export struct PhotoGridView { onPlaceholderChanged() { Log.debug(TAG, 'onPlaceholderChanged placeholderIndex is ' + this.placeholderIndex); - if (this.placeholderIndex >= 0) { + if (this.placeholderIndex != -1) { this.scroller.scrollToIndex(this.placeholderIndex); } - UiUtil.emitByPlaceholderIndex(this.placeholderIndex, this.dataSource, this.broadCast); } initParams(): void { From 5f40688a89f050c7db7a34965346a0d3a0908e0a Mon Sep 17 00:00:00 2001 From: liujuan Date: Thu, 26 Oct 2023 04:09:01 +0000 Subject: [PATCH 09/12] update product/phone/src/main/ets/view/SelectPhotoBrowserView.ets. Signed-off-by: liujuan --- product/phone/src/main/ets/view/SelectPhotoBrowserView.ets | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/product/phone/src/main/ets/view/SelectPhotoBrowserView.ets b/product/phone/src/main/ets/view/SelectPhotoBrowserView.ets index e0b56ceb..d29a462c 100644 --- a/product/phone/src/main/ets/view/SelectPhotoBrowserView.ets +++ b/product/phone/src/main/ets/view/SelectPhotoBrowserView.ets @@ -237,8 +237,7 @@ export struct SelectPhotoBrowserView { onBackPress() { Log.info(TAG, 'onBackPress'); if (this.geometryTransitionEnable) { - let dataIndex = this.dataSource.getPositionByIndex(this.currentIndex) as number; - this.browserController.hideSelectBrowser(dataIndex); + this.browserController.hideSelectBrowser(); } else { router.back({ url: '', From 7316630307e914716558c8a25f067609c73cd879 Mon Sep 17 00:00:00 2001 From: liujuan Date: Thu, 26 Oct 2023 04:10:04 +0000 Subject: [PATCH 10/12] update common/src/main/ets/default/model/browser/AlbumDefine.ts. Signed-off-by: liujuan --- .../ets/default/model/browser/AlbumDefine.ts | 20 +------------------ 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/common/src/main/ets/default/model/browser/AlbumDefine.ts b/common/src/main/ets/default/model/browser/AlbumDefine.ts index da2caa91..e9bca9ef 100644 --- a/common/src/main/ets/default/model/browser/AlbumDefine.ts +++ b/common/src/main/ets/default/model/browser/AlbumDefine.ts @@ -12,10 +12,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import userFileManager from '@ohos.filemanagement.userFileManager'; -import dataSharePredicates from '@ohos.data.dataSharePredicates'; - import type { FetchOptions } from '../../access/UserFileManagerAccess'; + import { AlbumFetchOptionBuilder, FileFetchOptionBuilder, @@ -52,22 +50,6 @@ export class AlbumDefine { return builder.build(); } - static getFileFetchOptWithEmptyColumn(startIndex?: number, count?: number, filterMediaType?: string): FetchOptions { - let fetchOption: userFileManager.FetchOptions = { - predicates: new dataSharePredicates.DataSharePredicates(), - fetchColumns: [] - }; - let builder = new FileFetchOptionBuilder(fetchOption); - builder.order(UserFileManagerAccess.FILE_KEY_DATE_TAKEN.toString(), false); - if (filterMediaType) { - AlbumDefine.setFilterMediaType(builder, filterMediaType); - } - if (startIndex != undefined && count != undefined && startIndex >= 0 && count >= 0) { - builder.select(startIndex, count); - } - return builder.build(); - } - static getFavoriteFetchOpt(filterMediaType?: string) { let builder = new FileFetchOptionBuilder(); if (filterMediaType == undefined) { From 317604a1e4387a46b78519bf996796ef5950d565 Mon Sep 17 00:00:00 2001 From: liujuan Date: Thu, 26 Oct 2023 04:14:40 +0000 Subject: [PATCH 11/12] update common/src/main/ets/default/model/browser/BrowserDataImpl.ts. Signed-off-by: liujuan --- .../src/main/ets/default/model/browser/BrowserDataImpl.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/common/src/main/ets/default/model/browser/BrowserDataImpl.ts b/common/src/main/ets/default/model/browser/BrowserDataImpl.ts index 8160dcd6..95e57a35 100644 --- a/common/src/main/ets/default/model/browser/BrowserDataImpl.ts +++ b/common/src/main/ets/default/model/browser/BrowserDataImpl.ts @@ -127,8 +127,11 @@ export abstract class BrowserDataImpl implements BrowserDataInterface { realAlbumUri = ""; } Log.debug(TAG, `getItemIndexByUri real album uri: ${realAlbumUri}`); - index = await UserFileManagerAccess.getInstance().getPhotoIndexByUri(realUri, realAlbumUri); - Log.debug(TAG, `getItemIndexByUri index: ${index}`); + allObject = await this.getItems(realAlbumUri); + if (allObject) { + Log.debug(TAG, `getItemIndexByUri count: ${allObject.length}`); + index = allObject.findIndex((item: FileAsset) => item.uri == realUri); + } return index; } From 00f03994053b981ab59508803154022cbeef19b7 Mon Sep 17 00:00:00 2001 From: liujuan Date: Thu, 26 Oct 2023 04:15:15 +0000 Subject: [PATCH 12/12] update common/src/main/ets/default/access/UserFileManagerAccess.ts. Signed-off-by: liujuan --- .../ets/default/access/UserFileManagerAccess.ts | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/common/src/main/ets/default/access/UserFileManagerAccess.ts b/common/src/main/ets/default/access/UserFileManagerAccess.ts index 68f93b01..38ecd16e 100644 --- a/common/src/main/ets/default/access/UserFileManagerAccess.ts +++ b/common/src/main/ets/default/access/UserFileManagerAccess.ts @@ -788,22 +788,6 @@ export class UserFileManagerAccess { } } - async getPhotoIndexByUri(photoUri: string, albumUri: string): Promise { - Log.debug(TAG, 'getPhotoIndexByUri albumUri is ' + albumUri + ', photoUri is ' + photoUri); - if (!this.media) { - Log.error(TAG, 'getPhotoIndexByUri media resource is null!'); - return undefined; - } - try { - let fileFetchOpt = AlbumDefine.getFileFetchOptWithEmptyColumn(Constants.INVALID, Constants.INVALID, undefined); - let index: number = await this.media.getPhotoIndex(photoUri, albumUri, fileFetchOpt); - return index - 1; - } catch (err) { - Log.error(TAG, `getAlbumByUri Get Album by uri exception! msg: ${err}`); - return 0; - } - } - async getAlbumByName(albumName: string): Promise { if (!this.media) { Log.error(TAG, 'getAlbumByName media resource is null!');