!450 【master】回退appfreeze修改

Merge pull request !450 from liujuan/master
This commit is contained in:
openharmony_ci 2023-10-26 06:15:29 +00:00 committed by Gitee
commit f5eb409cfb
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
12 changed files with 18 additions and 114 deletions

View File

@ -788,22 +788,6 @@ export class UserFileManagerAccess {
}
}
async getPhotoIndexByUri(photoUri: string, albumUri: string): Promise<number> {
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<Album> {
if (!this.media) {
Log.error(TAG, 'getAlbumByName media resource is null!');

View File

@ -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) {

View File

@ -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;
}

View File

@ -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');

View File

@ -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<number>('placeholderIndex', -(position + 1));
AppStorage.SetOrCreate<number>('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<number>('placeholderIndex', -(position + 1));
AppStorage.SetOrCreate<number>('placeholderIndex', -1);
});
}

View File

@ -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) {

View File

@ -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 {

View File

@ -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 {

View File

@ -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) {

View File

@ -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: '',

View File

@ -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 {

View File

@ -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: '',