mirror of
https://gitee.com/openharmony/applications_photos
synced 2024-11-23 07:00:09 +00:00
Signed-off-by: liujuan <liujuan76@h-partners.com>
Changes to be committed:
This commit is contained in:
parent
2179c9b780
commit
7684e29e1d
@ -12,8 +12,9 @@
|
||||
* 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,
|
||||
@ -50,6 +51,22 @@ 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) {
|
||||
|
@ -85,6 +85,16 @@ export abstract class BrowserDataImpl implements BrowserDataInterface {
|
||||
return result;
|
||||
}
|
||||
|
||||
async getItemsCountOfAlbum(album: Album, filterMediaType?: string): Promise<number> {
|
||||
let count = 0;
|
||||
// 当前相册count始终为0,先通过查全部图片获取count
|
||||
let fetchOpt = AlbumDefine.getFileFetchOptWithEmptyColumn(Constants.INVALID, Constants.INVALID, filterMediaType);
|
||||
let fetchResult = await album.getPhotoAssets(fetchOpt);
|
||||
count = fetchResult.getCount();
|
||||
fetchResult.close();
|
||||
return count;
|
||||
}
|
||||
|
||||
async getItemsCount(albumUri?: string, filterMediaType?: string): Promise<number> {
|
||||
let count = 0;
|
||||
if (albumUri) {
|
||||
@ -132,7 +142,6 @@ export abstract class BrowserDataImpl implements BrowserDataInterface {
|
||||
Log.debug(TAG, `getItemIndexByUri count: ${allObject.length}`);
|
||||
index = allObject.findIndex((item: FileAsset) => item.uri == realUri);
|
||||
}
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
|
@ -22,6 +22,7 @@ import { UserFileManagerAccess } from '../../../access/UserFileManagerAccess';
|
||||
import { Log } from '../../../utils/Log';
|
||||
import { Constants } from '../../common/Constants';
|
||||
import { MediaItem } from '../photo/MediaItem';
|
||||
import { ImageUtil } from '../../../utils/ImageUtil';
|
||||
|
||||
const TAG: string = 'common_AlbumDataImpl';
|
||||
|
||||
@ -139,53 +140,58 @@ export class AlbumDataImpl extends BrowserDataImpl {
|
||||
}
|
||||
|
||||
private async getUserAlbumsInfo(albumArray: Array<AlbumInfo>, filterMediaType?: string): Promise<void> {
|
||||
Log.debug(TAG, 'getUserAlbumsInfo');
|
||||
|
||||
Log.info(TAG, 'getUserAlbumsInfo start');
|
||||
let albums: Album[] = await UserFileManagerAccess.getInstance().getUserAlbums();
|
||||
Log.debug(TAG, `getUserAlbumsInfo albums is : ${albums}`);
|
||||
if (albums) {
|
||||
if (!albums) {
|
||||
Log.error(TAG, 'getUserAlbumsInfo, albums undefined');
|
||||
}
|
||||
Log.info(TAG, `getUserAlbumsInfo fetch albums length : ${albums.length}`);
|
||||
try {
|
||||
for (let album of albums) {
|
||||
let albumInfo: AlbumInfo = new AlbumInfo(album);
|
||||
let albumName: string = await UserFileManagerAccess.getInstance().getAlbumName(album);
|
||||
albumInfo.setAlbumName(albumName);
|
||||
albumInfo.setFilterMediaType(filterMediaType);
|
||||
// 没有相册,设置为第一张
|
||||
if (!album.coverUri) {
|
||||
await UserFileManagerAccess.getInstance().getAlbumFirstObject(album).then((obj) => {
|
||||
if (obj) {
|
||||
let mediaItem = new MediaItem(obj);
|
||||
mediaItem.setThumbnail(this.getThumbnailSafe(obj.uri, String(obj.get(Constants.KEY_FILE_DATA))));
|
||||
albumInfo.setMediaItem(mediaItem);
|
||||
albumInfo.setCoverUri(this.getThumbnailSafe(obj.uri, String(obj.get(Constants.KEY_FILE_DATA))));
|
||||
}
|
||||
});
|
||||
} else {
|
||||
await UserFileManagerAccess.getInstance().getFirstObject(AlbumDefine.getFileFetchOptByUri(album.coverUri)).then((obj) => {
|
||||
if (obj) {
|
||||
let mediaItem = new MediaItem(obj.obj);
|
||||
mediaItem.setThumbnail(this.getThumbnailSafe(obj.obj.uri, String(obj.obj.get(Constants.KEY_FILE_DATA))));
|
||||
albumInfo.setMediaItem(mediaItem);
|
||||
albumInfo.setCoverUri(this.getThumbnailSafe(obj.obj.uri, String(obj.obj.get(Constants.KEY_FILE_DATA))));
|
||||
}
|
||||
});
|
||||
albumInfo.setFilterMediaType(filterMediaType as string);
|
||||
let count = albumInfo.count;
|
||||
albumInfo.setCount(count); // Waiting: album.count不为0时,在构造函数里直接获取
|
||||
let videoCount = 0;
|
||||
if (count > 0) {
|
||||
// 没有相册,设置为第一张
|
||||
let hasCoverUri: Boolean = false;
|
||||
if (album.coverUri) {
|
||||
await UserFileManagerAccess.getInstance().getFirstObject(AlbumDefine.getFileFetchOptByUri(album.coverUri)).then((obj) => {
|
||||
if (obj && obj.obj) {
|
||||
let mediaItem = new MediaItem(obj.obj);
|
||||
mediaItem.setThumbnail(this.getThumbnailSafe(obj.obj.uri, String(obj.obj.get(Constants.KEY_FILE_DATA))));
|
||||
albumInfo.setMediaItem(mediaItem);
|
||||
albumInfo.setCoverUri(ImageUtil.calcThumbnail(obj.obj.uri, mediaItem.height, mediaItem.width));
|
||||
hasCoverUri = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
if (!hasCoverUri) {
|
||||
await UserFileManagerAccess.getInstance().getAlbumFirstObject(album).then((obj) => {
|
||||
if (obj) {
|
||||
let mediaItem = new MediaItem(obj);
|
||||
mediaItem.setThumbnail(this.getThumbnailSafe(obj.uri, String(obj.get(Constants.KEY_FILE_DATA))));
|
||||
albumInfo.setMediaItem(mediaItem);
|
||||
albumInfo.setCoverUri(ImageUtil.calcThumbnail(obj.uri, mediaItem.height, mediaItem.width));
|
||||
}
|
||||
});
|
||||
}
|
||||
// 相册的视频数量
|
||||
videoCount = await this.getItemsCountOfAlbum(album, AlbumDefine.FILTER_MEDIA_TYPE_VIDEO);
|
||||
}
|
||||
let count = await this.getItemsCount(album.albumUri);
|
||||
albumInfo.setCount(count); // TODO album.count不为0时,在构造函数里直接获取
|
||||
// 相册的视频数量
|
||||
let videoCount = await this.getItemsCount(album.albumUri, AlbumDefine.FILTER_MEDIA_TYPE_VIDEO);
|
||||
albumInfo.setVideoCount(videoCount);
|
||||
Log.debug(TAG, `getUserAlbumsInfo albumInfo is : ${albumInfo}`);
|
||||
albumArray.push(albumInfo);
|
||||
Log.debug(TAG, `getUserAlbumsInfo albumArray length is : ${albumArray.length}`);
|
||||
Log.info(TAG, `getUserAlbumsInfo done, albumInfo : ${JSON.stringify(albumInfo)}, albumArray length: ${albumArray.length}`);
|
||||
}
|
||||
} else {
|
||||
Log.error(TAG, 'Failed getUserAlbumsInfo');
|
||||
} catch (error) {
|
||||
Log.error(TAG, `getUserAlbumsInfo error occured: ${error}`);
|
||||
}
|
||||
|
||||
Log.debug(TAG, 'getUserAlbumsInfo done');
|
||||
Log.info(TAG, 'getUserAlbumsInfo done');
|
||||
}
|
||||
|
||||
|
||||
private async getSystemAlbumsInfo(albumArray: Array<AlbumInfo>, filterMediaType?: string): Promise<void> {
|
||||
Log.debug(TAG, 'getSystemAlbumsInfo');
|
||||
|
||||
@ -239,23 +245,23 @@ export class AlbumDataImpl extends BrowserDataImpl {
|
||||
}
|
||||
|
||||
private async getTrashAlbumInfo(albumArray: Array<AlbumInfo>, filterMediaType?: string): Promise<void> {
|
||||
Log.debug(TAG, 'getTrashAlbumInfo');
|
||||
let album: Album = await UserFileManagerAccess.getInstance().getTrashAlbum();
|
||||
Log.debug(TAG, `getTrashAlbumInfo albums is : ${album}`);
|
||||
Log.info(TAG, 'getTrashAlbumInfo start');
|
||||
let album: Album = await UserFileManagerAccess.getInstance().getTrashAlbum() as Album;
|
||||
if (!album) {
|
||||
Log.error(TAG, 'getTrashAlbumInfo, get album undefined');
|
||||
}
|
||||
let albumInfo: AlbumInfo = new AlbumInfo(album);
|
||||
let count = await this.getItemsCount(album.albumUri);
|
||||
let count = albumInfo.count;
|
||||
// 系统相册为空时不展示
|
||||
if (count === 0) {
|
||||
Log.warn(TAG, 'getTrashAlbumInfo count is 0');
|
||||
return;
|
||||
}
|
||||
albumInfo.setCount(count);
|
||||
let albumName: string = await UserFileManagerAccess.getInstance().getAlbumName(album);
|
||||
let albumName: string = await UserFileManagerAccess.getInstance().getAlbumName(album) as string;
|
||||
albumInfo.setAlbumName(albumName);
|
||||
albumInfo.setFilterMediaType(filterMediaType);
|
||||
Log.debug(TAG, `getTrashAlbumInfo albumArray albumInfo is : ${albumInfo}`);
|
||||
albumInfo.setFilterMediaType(filterMediaType as string);
|
||||
albumArray.push(albumInfo);
|
||||
Log.debug(TAG, `getTrashAlbumInfo albumArray length is : ${albumArray.length}`);
|
||||
Log.debug(TAG, 'getSystemAlbumsInfo done');
|
||||
Log.info(TAG, `getTrashAlbumInfo done, albumInfo : ${JSON.stringify(albumInfo)}, albumArray length: ${albumArray.length}`);
|
||||
}
|
||||
}
|
@ -33,8 +33,10 @@ export class AlbumInfo {
|
||||
dateModified: number;
|
||||
videoCount: number;
|
||||
mediaItem: MediaItem;
|
||||
deviceName: string;
|
||||
deviceId: string;
|
||||
|
||||
constructor(album: Album) {
|
||||
constructor(album?: Album) {
|
||||
if (album) {
|
||||
this.uri = album.albumUri;
|
||||
this.coverUri = album.coverUri;
|
||||
|
@ -43,7 +43,9 @@ export class AlbumSetDataSource extends AbsDataSource {
|
||||
super();
|
||||
|
||||
Log.debug(TAG, `constructor ${JSON.stringify(param)}`);
|
||||
this.broadCast_ = broadCast;
|
||||
if (broadCast) {
|
||||
this.broadCast_ = broadCast;
|
||||
}
|
||||
this.albumDataImpl = BrowserDataFactory.getFeature(BrowserDataFactory.TYPE_ALBUM, param);
|
||||
|
||||
if (param && param.deviceId) {
|
||||
@ -62,7 +64,8 @@ export class AlbumSetDataSource extends AbsDataSource {
|
||||
if (this.albumDataImpl != null) {
|
||||
let callback: AlbumSetCallback = new AlbumSetCallback(this);
|
||||
this.albumDataImpl.getData(callback,
|
||||
(this.filterMediaType == undefined) ? null : { filterMediaType: this.filterMediaType });
|
||||
(this.filterMediaType === undefined || this.filterMediaType === null) ?
|
||||
null : { filterMediaType: this.filterMediaType });
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -24,10 +24,10 @@ export class MediaObserver {
|
||||
callbacks: Set<MediaObserverCallback> = new Set<MediaObserverCallback>();
|
||||
|
||||
static getInstance(): MediaObserver {
|
||||
if (AppStorage.Get(Constants.APP_KEY_MENU_USER_FILE_MANAGER_OBSERVER) == null) {
|
||||
if (AppStorage.get(Constants.APP_KEY_MENU_USER_FILE_MANAGER_OBSERVER) == null) {
|
||||
AppStorage.SetOrCreate(Constants.APP_KEY_MENU_USER_FILE_MANAGER_OBSERVER, new MediaObserver());
|
||||
}
|
||||
return AppStorage.Get(Constants.APP_KEY_MENU_USER_FILE_MANAGER_OBSERVER);
|
||||
return AppStorage.get(Constants.APP_KEY_MENU_USER_FILE_MANAGER_OBSERVER);
|
||||
}
|
||||
|
||||
registerObserver(callback: MediaObserverCallback) {
|
||||
|
@ -28,7 +28,7 @@ import { ImageUtil } from '../../../utils/ImageUtil';
|
||||
import { ScreenManager } from '../../common/ScreenManager';
|
||||
|
||||
import display from '@ohos.display';
|
||||
import { UserFileManagerAccess } from '../../../access/UserFileManagerAccess';
|
||||
import { FileAsset, UserFileManagerAccess } from '../../../access/UserFileManagerAccess';
|
||||
|
||||
const TAG: string = 'common_PhotoDataSource';
|
||||
|
||||
@ -285,8 +285,9 @@ export class PhotoDataSource implements IDataSource, LoadingListener {
|
||||
}
|
||||
}
|
||||
|
||||
async getDataByUri(uri) {
|
||||
return await this.photoDataImpl.getDataByUri(uri);
|
||||
async getDataByUri(uri: string): Promise<FileAsset> {
|
||||
let tmp: FileAsset = await this.photoDataImpl.getDataByUri(uri) as FileAsset;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
getItemByUri(uri: string): any {
|
||||
|
@ -18,7 +18,7 @@ export class TimelineData {
|
||||
startDate: number;
|
||||
endDate: number;
|
||||
|
||||
constructor(startDate: number, endDate: number, count: number) {
|
||||
constructor(startDate?: number, endDate?: number, count?: number) {
|
||||
this.startDate = startDate;
|
||||
this.endDate = endDate;
|
||||
this.count = count;
|
||||
|
@ -29,10 +29,10 @@ export class BroadCastManager {
|
||||
}
|
||||
|
||||
public static getInstance(): BroadCastManager {
|
||||
if (AppStorage.Get(Constants.APP_KEY_EVENT_BUS) == null) {
|
||||
if (AppStorage.get(Constants.APP_KEY_EVENT_BUS) == null) {
|
||||
AppStorage.SetOrCreate(Constants.APP_KEY_EVENT_BUS, new BroadCastManager());
|
||||
}
|
||||
return AppStorage.Get(Constants.APP_KEY_EVENT_BUS);
|
||||
return AppStorage.get(Constants.APP_KEY_EVENT_BUS);
|
||||
}
|
||||
|
||||
public getBroadCast(): BroadCast {
|
||||
|
@ -74,6 +74,9 @@ export class Constants {
|
||||
static readonly IS_SHOW_MOVE_COPY_DIALOG: string = 'is_show_move_copy_dialog';
|
||||
static readonly INSTANCE_MOVE_OR_COPY_BROADCAST_PROP: string = 'instance_move_or_copy_broadcast_prop';
|
||||
|
||||
// used as album uri for creating album from picker page
|
||||
static readonly APP_NEW_ALBUM_SOURCE_PICKER: string = 'picker_page';
|
||||
|
||||
// BroadCast
|
||||
static readonly APP_KEY_EVENT_BUS: string = 'app_key_event_bus';
|
||||
|
||||
|
@ -198,7 +198,7 @@ export class HistogramManager {
|
||||
*/
|
||||
private initializePixelArray(): void {
|
||||
Log.info(TAG, 'get pixel array by deserialize');
|
||||
let serializedBuffer = AppStorage.Get<string>(Constants.HISTOGRAM_ARRAY_BUFFER_KEY);
|
||||
let serializedBuffer = AppStorage.get<string>(Constants.HISTOGRAM_ARRAY_BUFFER_KEY);
|
||||
if (!serializedBuffer) {
|
||||
Log.error(TAG, 'initializePixelArray: serializedBuffer is undefined');
|
||||
return;
|
||||
|
@ -30,10 +30,10 @@ export class PixelMapManager {
|
||||
}
|
||||
|
||||
public static getInstance(): PixelMapManager {
|
||||
if (AppStorage.Get(Constants.PIXEL_MAP_MANAGER) == null) {
|
||||
if (AppStorage.get(Constants.PIXEL_MAP_MANAGER) == null) {
|
||||
AppStorage.SetOrCreate(Constants.PIXEL_MAP_MANAGER, new PixelMapManager());
|
||||
}
|
||||
return AppStorage.Get(Constants.PIXEL_MAP_MANAGER);
|
||||
return AppStorage.get(Constants.PIXEL_MAP_MANAGER);
|
||||
}
|
||||
|
||||
public getFifoCache(): FifoCache<Thumbnail> {
|
||||
|
@ -79,10 +79,10 @@ export class ScreenManager {
|
||||
}
|
||||
|
||||
static getInstance(): ScreenManager {
|
||||
if (AppStorage.Get(Constants.APP_KEY_SCREEN_MANAGER) == null) {
|
||||
if (AppStorage.get(Constants.APP_KEY_SCREEN_MANAGER) == null) {
|
||||
AppStorage.SetOrCreate(Constants.APP_KEY_SCREEN_MANAGER, new ScreenManager());
|
||||
}
|
||||
let manager: ScreenManager = AppStorage.Get(Constants.APP_KEY_SCREEN_MANAGER);
|
||||
let manager: ScreenManager = AppStorage.get(Constants.APP_KEY_SCREEN_MANAGER);
|
||||
return manager;
|
||||
}
|
||||
|
||||
@ -157,7 +157,7 @@ export class ScreenManager {
|
||||
|
||||
// Returns the height of the layout area (LayoutHeight = WindowHeight - WindowDecorHeight).
|
||||
getWinLayoutHeight(): number {
|
||||
let deviceTp: string = AppStorage.Get('deviceType') as string;
|
||||
let deviceTp: string = AppStorage.get('deviceType') as string;
|
||||
Log.debug(TAG, `deviceTp=${deviceTp}, isFull=${this.isFullScreen}, winH=${this.winHeight}`);
|
||||
if (deviceTp === Constants.DEFAULT_DEVICE_TYPE) {
|
||||
return this.winHeight;
|
||||
@ -191,7 +191,9 @@ export class ScreenManager {
|
||||
|
||||
async checkWindowMode(): Promise<void> {
|
||||
let before = this.windowMode;
|
||||
let mode = await globalThis.photosWindowStage.getWindowMode();
|
||||
let windowStage: window.WindowStage = AppStorage.get<window.WindowStage>('photosWindowStage');
|
||||
// @ts-ignore
|
||||
let mode: WindowMode = await windowStage.getWindowMode() as WindowMode;
|
||||
Log.info(TAG, `photos application before/current window mode: ${before}/${mode}`);
|
||||
|
||||
if (before == mode) {
|
||||
@ -241,7 +243,7 @@ export class ScreenManager {
|
||||
try {
|
||||
topWindow.setLayoutFullScreen(true, () => {
|
||||
Log.debug(TAG, 'setFullScreen true Succeeded');
|
||||
if (AppStorage.Get('deviceType') as string !== Constants.DEFAULT_DEVICE_TYPE) {
|
||||
if (AppStorage.get('deviceType') as string !== Constants.DEFAULT_DEVICE_TYPE) {
|
||||
this.hideStatusBar();
|
||||
} else {
|
||||
this.setWindowBackgroundColorDefault(true);
|
||||
@ -308,7 +310,7 @@ export class ScreenManager {
|
||||
}
|
||||
|
||||
setSystemUi(isShowBar: boolean): void {
|
||||
let deviceTp: string = AppStorage.Get('deviceType') as string;
|
||||
let deviceTp: string = AppStorage.get('deviceType') as string;
|
||||
Log.debug(TAG, `setSystemUi start, isShowBar=${isShowBar}, deviceType=${deviceTp}`);
|
||||
let topWindow: window.Window = this.getMainWindow();
|
||||
Log.debug(TAG, 'getTopWindow start');
|
||||
@ -336,17 +338,17 @@ export class ScreenManager {
|
||||
}
|
||||
|
||||
isHorizontal(): boolean {
|
||||
if (AppStorage.Get(Constants.SCREEN_ORIENTATION_HORIZONTAL) == null) {
|
||||
if (AppStorage.get(Constants.SCREEN_ORIENTATION_HORIZONTAL) == null) {
|
||||
AppStorage.SetOrCreate(Constants.SCREEN_ORIENTATION_HORIZONTAL, this.horizontal);
|
||||
}
|
||||
return AppStorage.Get(Constants.SCREEN_ORIENTATION_HORIZONTAL);
|
||||
return AppStorage.get(Constants.SCREEN_ORIENTATION_HORIZONTAL);
|
||||
}
|
||||
|
||||
isSidebar(): boolean {
|
||||
if (AppStorage.Get(Constants.SCREEN_SIDEBAR) == null) {
|
||||
if (AppStorage.get(Constants.SCREEN_SIDEBAR) == null) {
|
||||
AppStorage.SetOrCreate(Constants.SCREEN_SIDEBAR, this.sidebar);
|
||||
}
|
||||
return AppStorage.Get(Constants.SCREEN_SIDEBAR);
|
||||
return AppStorage.get(Constants.SCREEN_SIDEBAR);
|
||||
}
|
||||
|
||||
getColumnsWidth(count: number): number {
|
||||
@ -370,7 +372,7 @@ export class ScreenManager {
|
||||
}
|
||||
|
||||
private getMainWindow(): window.Window {
|
||||
return AppStorage.Get<window.Window>('mainWindow');
|
||||
return AppStorage.get<window.Window>('mainWindow');
|
||||
}
|
||||
|
||||
private emit(event: string, argument: unknown[]): void {
|
||||
|
@ -42,11 +42,11 @@ export class StatusBarColorController {
|
||||
}
|
||||
|
||||
public static getInstance(): StatusBarColorController {
|
||||
if (AppStorage.Get(Constants.APP_KEY_STATUS_BAR_COLOR_CONTROLLER) == null) {
|
||||
if (AppStorage.get(Constants.APP_KEY_STATUS_BAR_COLOR_CONTROLLER) == null) {
|
||||
AppStorage.SetOrCreate(
|
||||
Constants.APP_KEY_STATUS_BAR_COLOR_CONTROLLER, new StatusBarColorController());
|
||||
}
|
||||
return AppStorage.Get(Constants.APP_KEY_STATUS_BAR_COLOR_CONTROLLER);
|
||||
return AppStorage.get(Constants.APP_KEY_STATUS_BAR_COLOR_CONTROLLER);
|
||||
}
|
||||
|
||||
public setMode(mode: StatusBarColorMode): void {
|
||||
|
@ -20,7 +20,7 @@ export class TabItem {
|
||||
iconResource: Resource;
|
||||
iconSelectedResource: Resource;
|
||||
iconDefault: Resource = $r('sys.color.ohos_id_color_bottom_tab_icon_off');
|
||||
iconSelected: Resource;
|
||||
iconSelected: Resource | null = null;
|
||||
textColorDefault: Resource = $r('sys.color.ohos_id_color_text_primary');
|
||||
textColorSelected: Resource = $r('sys.color.ohos_id_color_bottom_tab_text_on');
|
||||
textFamilyDefault: Resource = $r('sys.string.ohos_id_text_font_family_medium');
|
||||
@ -38,7 +38,7 @@ export class TabItem {
|
||||
}
|
||||
|
||||
getConditionIcon(isSelected: boolean): Resource {
|
||||
return isSelected ? this.iconSelected : this.iconDefault;
|
||||
return isSelected ? this.iconSelected as Resource : this.iconDefault;
|
||||
}
|
||||
|
||||
getIcon(isSelected: boolean): Resource {
|
||||
|
@ -117,7 +117,7 @@ export class WorkerThreadPool {
|
||||
Log.info(TAG, 'thread pool start running, capacity: ' + WorkerThreadPool.CAPACITY);
|
||||
let groupCount = data.byteLength / byteLengthOfOneGroup;
|
||||
let byteLengthOfOneWorker = Math.floor(groupCount / WorkerThreadPool.CAPACITY) * byteLengthOfOneGroup;
|
||||
let deviceType: string = AppStorage.Get('deviceType');
|
||||
let deviceType: string = AppStorage.get('deviceType');
|
||||
const FIRST_INDEX = 0;
|
||||
for (let i = WorkerThreadPool.CAPACITY - 1; i >= 0; i--) {
|
||||
let workerInstance = WorkerThreadPool.createWorker(path, deviceType);
|
||||
|
@ -16,6 +16,7 @@ import { Log } from './Log';
|
||||
import { Constants } from '../model/common/Constants';
|
||||
import data_preferences from '@ohos.data.preferences';
|
||||
import contextConstant from '@ohos.app.ability.contextConstant';
|
||||
import common from '@ohos.app.ability.common';
|
||||
|
||||
const TAG: string = 'common_DataStoreUtil';
|
||||
|
||||
@ -28,10 +29,10 @@ export class DataStoreUtil {
|
||||
}
|
||||
|
||||
public static getInstance(): DataStoreUtil {
|
||||
if (AppStorage.Get(Constants.FROM_DATA_STORE_UTIL) == null) {
|
||||
if (AppStorage.get(Constants.FROM_DATA_STORE_UTIL) == null) {
|
||||
AppStorage.SetOrCreate(Constants.FROM_DATA_STORE_UTIL, new DataStoreUtil());
|
||||
}
|
||||
return AppStorage.Get(Constants.FROM_DATA_STORE_UTIL);
|
||||
return AppStorage.get(Constants.FROM_DATA_STORE_UTIL);
|
||||
}
|
||||
|
||||
public async init(): Promise<void> {
|
||||
@ -40,7 +41,7 @@ export class DataStoreUtil {
|
||||
Log.debug(TAG, 'init already!');
|
||||
return;
|
||||
}
|
||||
let context = globalThis.photosGlobalContext;
|
||||
let context: common.AbilityStageContext = AppStorage.get<common.AbilityStageContext>('photosGlobalContext');
|
||||
let area: contextConstant.AreaMode = context.area;
|
||||
context.area = contextConstant.AreaMode.EL1;
|
||||
try {
|
||||
@ -130,7 +131,7 @@ export class DataStoreUtil {
|
||||
|
||||
public async removeCache() {
|
||||
Log.debug(TAG, 'removeCache start!');
|
||||
let context = globalThis.photosGlobalContext;
|
||||
let context: common.AbilityStageContext = AppStorage.get<common.AbilityStageContext>('photosGlobalContext');
|
||||
let area: contextConstant.AreaMode = context.area;
|
||||
context.area = contextConstant.AreaMode.EL1;
|
||||
try {
|
||||
|
44
common/src/main/ets/default/utils/ErrUtil.ts
Normal file
44
common/src/main/ets/default/utils/ErrUtil.ts
Normal file
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (c) Huawei Technologies Co., Ltd. 2023-2023. All rights reserved.
|
||||
*/
|
||||
import { Log } from './Log';
|
||||
|
||||
const TAG: string = 'ErrUtil';
|
||||
|
||||
export function tryFunc(getValue: Function, ...args): any {
|
||||
if (typeof getValue !== 'function') {
|
||||
Log.e(TAG, typeof getValue, 'is not a func ', ...args);
|
||||
return;
|
||||
}
|
||||
let res;
|
||||
try {
|
||||
res = getValue(...args);
|
||||
} catch (error) {
|
||||
Log.e(TAG, {
|
||||
function: getValue.name,
|
||||
args: args,
|
||||
error,
|
||||
errMsg: String(error)
|
||||
});
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
export async function tryFuncAsync(getValue: Function, ...args): Promise<any> {
|
||||
if (typeof getValue !== 'function') {
|
||||
Log.e(TAG, 'not a func ', ...args);
|
||||
return;
|
||||
}
|
||||
let res;
|
||||
try {
|
||||
res = await getValue(...args);
|
||||
} catch (error) {
|
||||
Log.e(TAG, {
|
||||
function: getValue.name,
|
||||
args: args,
|
||||
error,
|
||||
errMsg: String(error)
|
||||
});
|
||||
}
|
||||
return res;
|
||||
}
|
@ -18,6 +18,7 @@ import HiLog from '@ohos.hilog';
|
||||
const DOMAIN: number = 0x0220;
|
||||
const TAG: string = 'Photos';
|
||||
const COLON = ': ';
|
||||
const SEPARATOR = ' ';
|
||||
|
||||
export class Log {
|
||||
static debug(className: string, message: string, ...args: string[]): boolean {
|
||||
@ -59,4 +60,69 @@ export class Log {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用方法 直接逗号分隔开:
|
||||
```
|
||||
Log.debug(TAG, `params = , ${JSON.stringify(param1)}, ${JSON.stringify(param2)...`)
|
||||
简化为 Log.d(TAG, 'params = ', param1, param2...)
|
||||
Log.error(TAG, `${JSON.stringify(err)obj = key1: ${JSON.stringify(v1)}, key2: ${JSON.stringify(v2)...`)
|
||||
简化为 Log.e(TAG, err, 'obj = ', { key1: v1, key2: v2 })
|
||||
```
|
||||
*/
|
||||
static d(className: string, ...args): void {
|
||||
return HiLog.debug(DOMAIN, TAG, className + COLON + this.join(...args));
|
||||
}
|
||||
|
||||
static i(className: string, ...args): void {
|
||||
return HiLog.info(DOMAIN, TAG, className + COLON + this.join(...args));
|
||||
}
|
||||
|
||||
static w(className: string, ...args): void {
|
||||
return HiLog.warn(DOMAIN, TAG, className + COLON + this.join(...args));
|
||||
}
|
||||
|
||||
static e(className: string, ...args): void {
|
||||
return HiLog.error(DOMAIN, TAG, className + COLON + this.join(...args));
|
||||
}
|
||||
|
||||
static f(className: string, ...args): void {
|
||||
return HiLog.fatal(DOMAIN, TAG, className + COLON + this.join(...args));
|
||||
}
|
||||
|
||||
static stringify(a): string {
|
||||
let res: string;
|
||||
if (typeof a !== 'string') {
|
||||
try {
|
||||
res = JSON.stringify(a);
|
||||
HiLog.debug(DOMAIN, TAG, a);
|
||||
} catch (e) {
|
||||
if (e) {
|
||||
HiLog.error(DOMAIN, TAG, `${e} type: ${typeof a}, ${a}, catch error: ${JSON.stringify(e)}`);
|
||||
}
|
||||
res = e;
|
||||
}
|
||||
}
|
||||
if (res === '{}') {
|
||||
try {
|
||||
res = String(a);
|
||||
} catch (e) {
|
||||
if (e) {
|
||||
HiLog.warn(DOMAIN, TAG, `${e} type: ${typeof a}, ${a}, catch error: ${JSON.stringify(e)}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
return res ?? a;
|
||||
}
|
||||
|
||||
static join(...args): string {
|
||||
for (let i = 0; i < args.length; i++) {
|
||||
try {
|
||||
args[i] = this.stringify(args[i]);
|
||||
} catch (e) {
|
||||
HiLog.warn(DOMAIN, TAG, `${e} type: ${typeof args[i]}, ${args[i]}, catch error: ${JSON.stringify(e)}`);
|
||||
}
|
||||
}
|
||||
return args.join(SEPARATOR);
|
||||
}
|
||||
}
|
||||
|
5
common/src/main/ets/default/utils/Matrix4x4.ets
Normal file
5
common/src/main/ets/default/utils/Matrix4x4.ets
Normal file
@ -0,0 +1,5 @@
|
||||
import Matrix4 from '@ohos.matrix4';
|
||||
|
||||
export interface Matrix4x4 extends Matrix4.Matrix4Transit {
|
||||
matrix4x4?: Array<number>;
|
||||
}
|
@ -25,7 +25,7 @@ export class ReportToBigDataUtil {
|
||||
private static PREFIX_NUMBER: number = 4;
|
||||
static readonly PHOTOS_DFX_DOMAIN: string = 'PHOTOS';
|
||||
|
||||
public static report(eventId: string, eventMsg: object): void {
|
||||
public static report(eventId: string, eventMsg?: object): void {
|
||||
hiSysEvent.write({
|
||||
domain: ReportToBigDataUtil.PHOTOS_DFX_DOMAIN,
|
||||
name: eventId,
|
||||
@ -38,7 +38,7 @@ export class ReportToBigDataUtil {
|
||||
Log.info(TAG, `report, eventId: ${eventId} msg: ${JSON.stringify(eventMsg)}`);
|
||||
}
|
||||
|
||||
public static statisticReport(eventId: string, eventMsg: object): void {
|
||||
public static statisticReport(eventId: string, eventMsg?: object): void {
|
||||
hiSysEvent.write({
|
||||
domain: ReportToBigDataUtil.PHOTOS_DFX_DOMAIN,
|
||||
name: eventId,
|
||||
@ -51,7 +51,7 @@ export class ReportToBigDataUtil {
|
||||
Log.info(TAG, `report, eventId: ${eventId} msg: ${JSON.stringify(eventMsg)}`);
|
||||
}
|
||||
|
||||
public static errEventReport(eventId: string, eventMsg: object): void {
|
||||
public static errEventReport(eventId: string, eventMsg?: object): void {
|
||||
hiSysEvent.write({
|
||||
domain: ReportToBigDataUtil.PHOTOS_DFX_DOMAIN,
|
||||
name: eventId,
|
||||
|
@ -21,6 +21,7 @@ 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 common from '@ohos.app.ability.common';
|
||||
|
||||
const TAG: string = 'common_UiUtil';
|
||||
|
||||
@ -130,11 +131,12 @@ export class UiUtil {
|
||||
static async getResourceString(resource: Resource): Promise<string> {
|
||||
try {
|
||||
Log.info(TAG, `getResourceString: ${JSON.stringify(resource)}`);
|
||||
if (globalThis.photosAbilityContext == null || globalThis.photosAbilityContext === 'undefined') {
|
||||
if (AppStorage.get('photosAbilityContext') === null || AppStorage.get('photosAbilityContext') === 'undefined') {
|
||||
Log.error(TAG, 'getResourceString error: context is null');
|
||||
return null;
|
||||
}
|
||||
let mgr = await globalThis.photosAbilityContext.resourceManager.getString(resource.id);
|
||||
let context: common.UIAbilityContext = AppStorage.get<common.UIAbilityContext>('photosAbilityContext');
|
||||
let mgr: string = await context.resourceManager.getString(resource.id);
|
||||
if (mgr) {
|
||||
return mgr;
|
||||
} else {
|
||||
@ -156,11 +158,12 @@ export class UiUtil {
|
||||
static async getResourceNumber(resource: Resource): Promise<number> {
|
||||
try {
|
||||
Log.info(TAG, `getResourceNumber: ${JSON.stringify(resource)}`);
|
||||
if (globalThis.photosAbilityContext == null || globalThis.photosAbilityContext === 'undefined') {
|
||||
if (AppStorage.get('photosAbilityContext') === null || AppStorage.get('photosAbilityContext') === 'undefined') {
|
||||
Log.error(TAG, 'getResourceNumber error: context is null');
|
||||
return null;
|
||||
}
|
||||
let mgr = await globalThis.photosAbilityContext.resourceManager.getNumber(resource.id);
|
||||
let context: common.UIAbilityContext = AppStorage.get<common.UIAbilityContext>('photosAbilityContext');
|
||||
let mgr: number = context.resourceManager.getNumber(resource.id);
|
||||
if (mgr) {
|
||||
return mgr;
|
||||
} else {
|
||||
|
@ -14,11 +14,13 @@
|
||||
*/
|
||||
import { Log } from './Log';
|
||||
import window from '@ohos.window';
|
||||
import { Router, UIContext } from '@ohos.arkui.UIContext';
|
||||
import common from '@ohos.app.ability.common';
|
||||
|
||||
const TAG: string = 'common_WindowUtil';
|
||||
|
||||
export class WindowUtil {
|
||||
static setWindowKeepScreenOn(context, isKeepScreenOn: boolean) {
|
||||
static setWindowKeepScreenOn(context: common.UIAbilityContext, isKeepScreenOn: boolean): void {
|
||||
try {
|
||||
window.getLastWindow(context).then((windows) => {
|
||||
windows.setWindowKeepScreenOn(isKeepScreenOn).then(() => {
|
||||
@ -34,7 +36,7 @@ export class WindowUtil {
|
||||
}
|
||||
}
|
||||
|
||||
static setPreferredOrientation(context, orientation: number) {
|
||||
static setPreferredOrientation(context: common.UIAbilityContext, orientation: number): void {
|
||||
try {
|
||||
window.getLastWindow(context, (err, data) => {
|
||||
if (err.code || !data) {
|
||||
@ -54,4 +56,22 @@ export class WindowUtil {
|
||||
Log.error(TAG, 'Failed to set window orientation. Cause: ' + JSON.stringify(exception));
|
||||
}
|
||||
}
|
||||
|
||||
static prepareWinRouter(): void {
|
||||
Log.debug(TAG, `prepareWinRouter AppStorage.get<Router>('router')=${AppStorage.get<Router>('router')}`);
|
||||
if (AppStorage.get('router')) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
AppStorage.setOrCreate('uiContext', (AppStorage.get<window.Window>('mainWindow') as window.Window).getUIContext());
|
||||
} catch (error) {
|
||||
Log.error(TAG, `Failed to get UIContext, error: ${error}`);
|
||||
return;
|
||||
}
|
||||
if (AppStorage.get('uiContext')) {
|
||||
Log.info(TAG, `prepareWinRouter AppStorage.get<window.Window>('uiContext')=${AppStorage.get<window.Window>('uiContext')}`);
|
||||
AppStorage.setOrCreate('router', (AppStorage.get<UIContext>('uiContext')).getRouter());
|
||||
Log.info(TAG, `prepareWinRouter localRouter=${AppStorage.get<Router>('router')}`);
|
||||
}
|
||||
}
|
||||
}
|
@ -24,11 +24,11 @@ export class BrowserController {
|
||||
public geometryTransitionEnable: boolean = false;
|
||||
public isAnimating: boolean = false;
|
||||
public isBrowserShow: boolean = false;
|
||||
public browserParam: Object = undefined;
|
||||
public browserBackFunc: Function;
|
||||
public browserParam?: Object;
|
||||
public browserBackFunc: Function = (): void => {};
|
||||
public isSelectBrowserShow: boolean = false;
|
||||
public selectBrowserParam: Object = undefined;
|
||||
public pageFrom: string = undefined;
|
||||
public selectBrowserParam?: Object;
|
||||
public pageFrom: string = '';
|
||||
|
||||
constructor(isGeometryEnable: boolean) {
|
||||
this.geometryTransitionEnable = isGeometryEnable;
|
||||
@ -73,10 +73,10 @@ export class BrowserController {
|
||||
}
|
||||
}, () => {
|
||||
this.isBrowserShow = false;
|
||||
this.browserParam = undefined;
|
||||
this.browserParam;
|
||||
this.isAnimating = true;
|
||||
AppStorage.SetOrCreate<number>('placeholderIndex', -1);
|
||||
Log.info(TAG, `placeholderIndex ${AppStorage.get('placeholderIndex')}`);
|
||||
Log.info(TAG, `placeholderIndex ${AppStorage.get<number>('placeholderIndex')}`);
|
||||
});
|
||||
}
|
||||
|
||||
@ -109,7 +109,7 @@ export class BrowserController {
|
||||
}
|
||||
}, () => {
|
||||
this.isSelectBrowserShow = false;
|
||||
this.selectBrowserParam = undefined;
|
||||
this.selectBrowserParam;
|
||||
this.isAnimating = true;
|
||||
AppStorage.SetOrCreate<number>('placeholderIndex', -1);
|
||||
});
|
||||
|
@ -16,8 +16,8 @@ import { Constants } from '../model/common/Constants';
|
||||
|
||||
@Component
|
||||
export struct DetailsDialogComponent {
|
||||
title: Resource;
|
||||
content: string | Resource;
|
||||
title?: Resource;
|
||||
content: string | Resource = '';
|
||||
colon: string = ': ';
|
||||
isLast: boolean = false;
|
||||
keyForAutoTest: string = '';
|
||||
|
@ -19,11 +19,11 @@ const TAG: string = 'common_GridScrollBar';
|
||||
|
||||
@Component
|
||||
export struct GridScrollBar {
|
||||
scroller: Scroller;
|
||||
scroller: Scroller | null = null;
|
||||
@State isClickScrollBar: boolean = false;
|
||||
|
||||
build() {
|
||||
ScrollBar({ scroller: this.scroller, direction: ScrollBarDirection.Vertical,
|
||||
ScrollBar({ scroller: this.scroller as Scroller, direction: ScrollBarDirection.Vertical,
|
||||
state: BarState.Auto }) {
|
||||
Row() {
|
||||
if (this.isClickScrollBar) {
|
||||
@ -46,12 +46,12 @@ export struct GridScrollBar {
|
||||
x: this.isClickScrollBar ? $r('app.float.scroll_bar_big_width') : $r('app.float.scroll_bar_small_width'),
|
||||
y: 0
|
||||
})
|
||||
.onTouch((event: TouchEvent) => {
|
||||
if (event.type == TouchType.Move && !this.isClickScrollBar) {
|
||||
.onTouch((event?: TouchEvent) => {
|
||||
if (event?.type == TouchType.Move && !this.isClickScrollBar) {
|
||||
Log.debug(TAG, `scrollBar first TouchType.Move`);
|
||||
this.isClickScrollBar = true;
|
||||
} else if (event.type == TouchType.Up || event.type == TouchType.Cancel) {
|
||||
Log.debug(TAG, `scrollBar TouchType.Up or Cancel. type=${event.type}`);
|
||||
} else if (event?.type == TouchType.Up || event?.type == TouchType.Cancel) {
|
||||
Log.debug(TAG, `scrollBar TouchType.Up or Cancel. type=${event?.type}`);
|
||||
this.isClickScrollBar = false;
|
||||
}
|
||||
})
|
||||
|
@ -37,15 +37,19 @@ const TAG: string = 'common_ImageGridItemComponent';
|
||||
@Extend(Image) function focusSetting(uri: string, handleEvent: Function) {
|
||||
.key('ImageGridFocus_' + uri)
|
||||
.focusable(true)
|
||||
.onKeyEvent((event: KeyEvent) => {
|
||||
handleEvent(event);
|
||||
.onKeyEvent((event?: KeyEvent) => {
|
||||
handleEvent((event as KeyEvent));
|
||||
})
|
||||
}
|
||||
|
||||
interface Msg {
|
||||
from: string;
|
||||
}
|
||||
|
||||
// General grid picture control
|
||||
@Component
|
||||
export struct ImageGridItemComponent {
|
||||
item: MediaItem;
|
||||
item: MediaItem | null = null;
|
||||
@StorageLink('isHorizontal') isHorizontal: boolean = ScreenManager.getInstance().isHorizontal();
|
||||
@Consume @Watch('onModeChange') isSelectedMode: boolean;
|
||||
@State isSelected: boolean = false;
|
||||
@ -55,44 +59,26 @@ export struct ImageGridItemComponent {
|
||||
@Link selectedCount: number;
|
||||
@State autoResize: boolean = true;
|
||||
loaded = false;
|
||||
mPosition: number;
|
||||
mPosition: number = 0;
|
||||
pageName = '';
|
||||
@State isLoadImageError: boolean = false;
|
||||
@State pressAnimScale: number = 1.0;
|
||||
@State recycleDays: number = 0;
|
||||
@Consume rightClickMenuList: Array<Action>;
|
||||
onMenuClicked: Function;
|
||||
onMenuClickedForSingleItem: Function;
|
||||
onMenuClicked: Function = (): void => {};
|
||||
onMenuClickedForSingleItem: Function = (): void => {};
|
||||
@State geometryTransitionString: string = 'default_id';
|
||||
@State isTap: boolean = false;
|
||||
@StorageLink('placeholderIndex') @Watch('verifyTapStatus') placeholderIndex: number = -1;
|
||||
@StorageLink('geometryTransitionBrowserId') @Watch('verifyTapStatus') geometryTransitionBrowserId: string = '';
|
||||
private imageThumbnail: string = undefined;
|
||||
private transitionId: string;
|
||||
private imageThumbnail: string = '';
|
||||
private transitionId: string = '';
|
||||
private isEnteringPhoto = false;
|
||||
private isThird = false;
|
||||
private isThirdMultiPick: boolean = false;
|
||||
private OPTS = {
|
||||
'sampleSize': 1,
|
||||
'rotateDegrees': 0,
|
||||
'editable': false,
|
||||
'desiredSize': {
|
||||
'width': 0,
|
||||
'height': 0
|
||||
},
|
||||
'desiredRegion': {
|
||||
'size': {
|
||||
'width': 0,
|
||||
'height': 0
|
||||
},
|
||||
'x': 0,
|
||||
'y': 0
|
||||
},
|
||||
'desiredPixelFormat': 3,
|
||||
};
|
||||
private albumUri: string = '';
|
||||
private dataSource: MediaDataSource;
|
||||
private geometryTapIndex: number;
|
||||
private dataSource: MediaDataSource | null = null;
|
||||
private geometryTapIndex: number = 0;
|
||||
private isTapStatusChange: boolean = false;
|
||||
|
||||
verifyTapStatus() {
|
||||
@ -116,12 +102,14 @@ export struct ImageGridItemComponent {
|
||||
}
|
||||
|
||||
aboutToAppear(): void {
|
||||
this.imageThumbnail = this.item?.thumbnail;
|
||||
this.albumUri = AppStorage.Get<string>(Constants.KEY_OF_ALBUM_URI);
|
||||
if (this.isSelected) {
|
||||
this.transitionId = `${this.item.hashCode}_${this.albumUri}_${this.isSelected}`;
|
||||
} else {
|
||||
this.transitionId = `${this.item.hashCode}_${this.albumUri}`;
|
||||
this.imageThumbnail = this.item?.thumbnail ?? '';
|
||||
this.albumUri = AppStorage.get<string>(Constants.KEY_OF_ALBUM_URI) as string;
|
||||
if (this.item != null) {
|
||||
if (this.isSelected) {
|
||||
this.transitionId = `${this.item.hashCode}_${this.albumUri}_${this.isSelected}`;
|
||||
} else {
|
||||
this.transitionId = `${this.item.hashCode}_${this.albumUri}`;
|
||||
}
|
||||
}
|
||||
if (this.isRecycle) {
|
||||
this.calculateRecycleDays();
|
||||
@ -131,7 +119,6 @@ export struct ImageGridItemComponent {
|
||||
}
|
||||
|
||||
aboutToDisappear(): void {
|
||||
Log.debug(TAG, `aboutToDisappear: ${this.item.uri}`);
|
||||
this.resetPressAnim();
|
||||
}
|
||||
|
||||
@ -176,12 +163,13 @@ export struct ImageGridItemComponent {
|
||||
Log.info(TAG, 'change selected.');
|
||||
let newState = !this.isSelected;
|
||||
AppStorage.SetOrCreate('focusUpdate', true);
|
||||
if (this.item.uri) {
|
||||
if (this.item != null && this.item.uri) {
|
||||
this.mPosition = this.getPosition();
|
||||
this.broadCast.emit(BroadCastConstants.SELECT, [this.mPosition, this.item.uri, newState, function(isSelected){
|
||||
Log.info(TAG, `enter callback, select status ${this.mPosition} ${this.item.uri} ${newState} ${this.isSelected}`);
|
||||
this.broadCast.emit(BroadCastConstants.SELECT, [this.mPosition, this.item.uri, newState, (isSelected: boolean): void => {
|
||||
let itemUri: string = this.item == null ? '' : this.item.uri;
|
||||
Log.info(TAG, `enter callback, select status ${this.mPosition} ${itemUri} ${newState} ${this.isSelected}`);
|
||||
this.isSelected = isSelected == undefined ? newState : isSelected;
|
||||
}.bind(this)]);
|
||||
}]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -211,7 +199,7 @@ export struct ImageGridItemComponent {
|
||||
}
|
||||
}
|
||||
})
|
||||
}, menu => menu.actionID.toString())
|
||||
}, (item: Action) => JSON.stringify(item))
|
||||
}
|
||||
.width(ScreenManager.getInstance().getColumnsWidth(ColumnSize.COLUMN_TWO))
|
||||
.borderRadius($r('sys.float.ohos_id_corner_radius_card'))
|
||||
@ -228,6 +216,7 @@ export struct ImageGridItemComponent {
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
if (this.isTap) {
|
||||
@ -252,7 +241,7 @@ export struct ImageGridItemComponent {
|
||||
.rotate({ x: 0, y: 0, z: 1, angle: 0 })
|
||||
.objectFit(ImageFit.Cover)
|
||||
.autoResize(false)
|
||||
.focusSetting(this.item.uri, this.handleKeyEvent.bind(this))
|
||||
.focusSetting(this.item == null ? '' : this.item.uri, (event: KeyEvent): void => this.handleKeyEvent(event))
|
||||
.onError(() => {
|
||||
this.isLoadImageError = true;
|
||||
AppStorage.SetOrCreate('focusUpdate', true);
|
||||
@ -265,11 +254,8 @@ export struct ImageGridItemComponent {
|
||||
this.requestFocus('ImageGridFocus_');
|
||||
})
|
||||
.geometryTransition(this.geometryTransitionString)
|
||||
// @ts-ignore
|
||||
.transition(TransitionEffect.asymmetric(
|
||||
// @ts-ignore
|
||||
TransitionEffect.scale({ x: AppStorage.Get('geometryScale'), y: AppStorage.Get('geometryScale') }),
|
||||
// @ts-ignore
|
||||
TransitionEffect.scale({ x: AppStorage.get('geometryScale'), y: AppStorage.get('geometryScale') }),
|
||||
TransitionEffect.opacity(0.99)))
|
||||
|
||||
if (this.geometryTransitionBrowserId === '' || !this.isTapStatusChange) {
|
||||
@ -279,10 +265,10 @@ export struct ImageGridItemComponent {
|
||||
|
||||
@Builder
|
||||
buildIcon() {
|
||||
if (this.item.mediaType == UserFileManagerAccess.MEDIA_TYPE_VIDEO || this.isRecycle) {
|
||||
if (this.item != null && this.item.mediaType == UserFileManagerAccess.MEDIA_TYPE_VIDEO || this.isRecycle) {
|
||||
Row() {
|
||||
// 缩略图左下角视频时长
|
||||
if (this.item.mediaType == UserFileManagerAccess.MEDIA_TYPE_VIDEO) {
|
||||
if (this.item != null && this.item.mediaType == UserFileManagerAccess.MEDIA_TYPE_VIDEO) {
|
||||
Text(DateUtil.getFormattedDuration(this.item.duration))
|
||||
.fontSize($r('sys.float.ohos_id_text_size_caption'))
|
||||
.fontFamily($r('app.string.id_text_font_family_regular'))
|
||||
@ -317,7 +303,7 @@ export struct ImageGridItemComponent {
|
||||
[[$r('app.color.album_cover_gradient_start_color'), 0], [$r('app.color.transparent'), 1.0]] })
|
||||
}
|
||||
|
||||
if (this.item.isFavor) {
|
||||
if (this.item != null && this.item.isFavor) {
|
||||
Image($r('app.media.ic_favorite_overlay'))
|
||||
.height($r('app.float.overlay_icon_size'))
|
||||
.width($r('app.float.overlay_icon_size'))
|
||||
@ -377,13 +363,13 @@ export struct ImageGridItemComponent {
|
||||
Stack({ alignContent: Alignment.Start }) {
|
||||
// 缩略图
|
||||
if (this.isLoadImageError) {
|
||||
Image((this.item.mediaType == UserFileManagerAccess.MEDIA_TYPE_VIDEO)
|
||||
Image((this.item != null && this.item.mediaType == UserFileManagerAccess.MEDIA_TYPE_VIDEO)
|
||||
? $r('app.media.alt_video_placeholder') : $r('app.media.alt_placeholder'))
|
||||
.aspectRatio(1)
|
||||
.rotate({ x: 0, y: 0, z: 1, angle: 0 })
|
||||
.objectFit(ImageFit.Cover)
|
||||
.autoResize(false)
|
||||
.focusSetting(this.item.uri, this.handleKeyEvent.bind(this))
|
||||
.focusSetting(this.item == null ? '' : this.item.uri, (event: KeyEvent): void => this.handleKeyEvent(event))
|
||||
.onAppear(() => {
|
||||
Log.debug(TAG, `appear the default image!`);
|
||||
})
|
||||
@ -422,7 +408,7 @@ export struct ImageGridItemComponent {
|
||||
}
|
||||
|
||||
// Press animation
|
||||
if (event.type == TouchType.Down) {
|
||||
if (event?.type === TouchType.Down) {
|
||||
animateTo({
|
||||
duration: Constants.PRESS_ANIM_DURATION,
|
||||
curve: Curve.Ease
|
||||
@ -431,7 +417,7 @@ export struct ImageGridItemComponent {
|
||||
})
|
||||
}
|
||||
|
||||
if ((event.type == TouchType.Up || event.type == TouchType.Cancel) && this.pressAnimScale != 1) {
|
||||
if ((event?.type == TouchType.Up || event?.type == TouchType.Cancel) && this.pressAnimScale != 1) {
|
||||
animateTo({
|
||||
duration: Constants.PRESS_ANIM_DURATION,
|
||||
curve: Curve.Ease
|
||||
@ -441,19 +427,20 @@ export struct ImageGridItemComponent {
|
||||
}
|
||||
})
|
||||
.gesture(GestureGroup(GestureMode.Exclusive,
|
||||
TapGesture().onAction((event: GestureEvent) => {
|
||||
let ret: Boolean = focusControl.requestFocus('ImageGridFocus_' + this.item.uri);
|
||||
TapGesture().onAction((event?: GestureEvent) => {
|
||||
let ret: boolean = focusControl.requestFocus('ImageGridFocus_' + (this.item == null ? '' : this.item.uri));
|
||||
if (ret !== true) {
|
||||
Log.error(TAG, `requestFocus${'ImageGridFocus_' + this.item.uri}, ret:${ret}`);
|
||||
let itemUri: string = this.item == null ? '' : this.item.uri;
|
||||
Log.error(TAG, `requestFocus${'ImageGridFocus_' + itemUri}, ret:${ret}`);
|
||||
}
|
||||
let msg = {
|
||||
'From': BigDataConstants.BY_CLICK,
|
||||
let msg: Msg = {
|
||||
from: BigDataConstants.BY_CLICK,
|
||||
}
|
||||
ReportToBigDataUtil.report(BigDataConstants.ENTER_PHOTO_BROWSER_WAY, msg);
|
||||
this.openPhotoBrowser();
|
||||
}),
|
||||
LongPressGesture().onAction((event: GestureEvent) => {
|
||||
Log.info(TAG, `LongPressGesture ${event}`);
|
||||
LongPressGesture().onAction((event?: GestureEvent) => {
|
||||
Log.info(TAG, `LongPressGesture ${event as GestureEvent}`);
|
||||
this.selectStateChange();
|
||||
this.pressAnimScale = 1;
|
||||
})
|
||||
@ -504,24 +491,25 @@ export struct ImageGridItemComponent {
|
||||
// 获取最近删除中,待回收照片倒计天数
|
||||
private calculateRecycleDays(): void {
|
||||
let currentTimeSeconds: number = new Date().getTime() / 1000;
|
||||
let trashedDay = DateUtil.convertSecondsToDays(currentTimeSeconds - this.item.dateTrashed);
|
||||
Log.debug(TAG, `currentSec=${currentTimeSeconds}, trashedSec=${this.item.dateTrashed}, trashedDay=${trashedDay}`);
|
||||
let itemDateTrashed: number = this.item == null ? 0 : this.item.dateTrashed;
|
||||
let trashedDay = DateUtil.convertSecondsToDays(currentTimeSeconds - itemDateTrashed);
|
||||
Log.debug(TAG, `currentSec=${currentTimeSeconds}, trashedSec=${itemDateTrashed}, trashedDay=${trashedDay}`);
|
||||
if (trashedDay > Constants.RECYCLE_DAYS_MAX) {
|
||||
this.recycleDays = 0;
|
||||
} else if (trashedDay <= 0) {
|
||||
this.recycleDays = Constants.RECYCLE_DAYS_MAX - 1;
|
||||
} else {
|
||||
this.recycleDays = parseInt((Constants.RECYCLE_DAYS_MAX - trashedDay) + '');
|
||||
this.recycleDays = Number.parseInt((Constants.RECYCLE_DAYS_MAX - trashedDay) + '');
|
||||
}
|
||||
}
|
||||
|
||||
private requestFocus(keyName: string): void {
|
||||
if (AppStorage.Get('deviceType') == Constants.DEFAULT_DEVICE_TYPE) {
|
||||
if (AppStorage.get<string>('deviceType') == Constants.DEFAULT_DEVICE_TYPE) {
|
||||
return;
|
||||
}
|
||||
let positionUri = AppStorage.Get('focusPosition');
|
||||
let isUpdate = AppStorage.Get('focusUpdate');
|
||||
if (isUpdate && positionUri === this.item.uri) {
|
||||
let positionUri = AppStorage.get<string>('focusPosition');
|
||||
let isUpdate = AppStorage.get<boolean>('focusUpdate');
|
||||
if (this.item !== null && isUpdate && positionUri === this.item.uri) {
|
||||
let ret: Boolean = focusControl.requestFocus(keyName + this.item.uri);
|
||||
if (ret !== true) {
|
||||
Log.error(TAG, `requestFocus${keyName + this.item.uri}, ret:${ret}`);
|
||||
@ -552,8 +540,8 @@ export struct ImageGridItemComponent {
|
||||
if (KeyType.Up == event.type) {
|
||||
switch (event.keyCode) {
|
||||
case MultimodalInputManager.KEY_CODE_KEYBOARD_ENTER:
|
||||
let msg = {
|
||||
'From': BigDataConstants.BY_KEYBOARD,
|
||||
let msg: Msg = {
|
||||
from: BigDataConstants.BY_KEYBOARD,
|
||||
}
|
||||
ReportToBigDataUtil.report(BigDataConstants.ENTER_PHOTO_BROWSER_WAY, msg);
|
||||
this.openPhotoBrowser();
|
||||
@ -573,6 +561,7 @@ export struct ImageGridItemComponent {
|
||||
}
|
||||
|
||||
private getPosition(): number {
|
||||
if (this.dataSource == null || this.item == null) return 0;
|
||||
return this.dataSource.getDataIndex(this.item) + this.dataSource.getGroupCountBeforeItem(this.item);
|
||||
}
|
||||
}
|
@ -21,7 +21,7 @@ const TAG: string = 'common_NoPhotoComponent';
|
||||
|
||||
@Component
|
||||
export struct NoPhotoComponent {
|
||||
title: Resource;
|
||||
title?: Resource;
|
||||
|
||||
// set an initial value temporarily, later change to 0.
|
||||
@State offSetY: number = Constants.EMPTY_PAGE_DEFAULT_OFFSET;
|
||||
@ -33,15 +33,13 @@ export struct NoPhotoComponent {
|
||||
|
||||
aboutToAppear(): void {
|
||||
Log.info(TAG, `aboutToAppear`);
|
||||
this.updateImageLayout = this.updateImageLayout.bind(this);
|
||||
ScreenManager.getInstance().on(ScreenManager.ON_WIN_SIZE_CHANGED, this.updateImageLayout);
|
||||
ScreenManager.getInstance().on(ScreenManager.ON_WIN_SIZE_CHANGED, (): void => this.updateImageLayout());
|
||||
this.updateImageLayout();
|
||||
}
|
||||
|
||||
aboutToDisappear(): void {
|
||||
Log.info(TAG, 'aboutToDisappear');
|
||||
ScreenManager.getInstance().off(ScreenManager.ON_WIN_SIZE_CHANGED, this.updateImageLayout);
|
||||
this.updateImageLayout = null;
|
||||
ScreenManager.getInstance().off(ScreenManager.ON_WIN_SIZE_CHANGED, (): void => this.updateImageLayout());
|
||||
}
|
||||
|
||||
build() {
|
||||
|
@ -22,12 +22,12 @@ const TAG: string = 'common_NoPhotoIndexComponent';
|
||||
|
||||
@Component
|
||||
export struct NoPhotoIndexComponent {
|
||||
index: number;
|
||||
hasBarSpace: boolean;
|
||||
index: number = 0;
|
||||
hasBarSpace: boolean = false;
|
||||
|
||||
// set an initial value temporarily, later change to 0.
|
||||
@State imageSize: number = 0;
|
||||
private reSizeFunc = this.reSizeLayout.bind(this);
|
||||
private reSizeFunc = (): void => this.reSizeLayout();
|
||||
|
||||
aboutToAppear(): void {
|
||||
Log.info(TAG, 'aboutToAppear');
|
||||
@ -35,14 +35,13 @@ export struct NoPhotoIndexComponent {
|
||||
this.updateImageSize();
|
||||
}
|
||||
|
||||
reSizeLayout() {
|
||||
reSizeLayout() {
|
||||
this.updateImageSize();
|
||||
}
|
||||
|
||||
aboutToDisappear(): void {
|
||||
Log.info(TAG, 'aboutToDisappear');
|
||||
ScreenManager.getInstance().off(ScreenManager.ON_WIN_SIZE_CHANGED, this.reSizeFunc);
|
||||
this.reSizeFunc = null;
|
||||
}
|
||||
|
||||
updateImageSize() {
|
||||
|
@ -31,12 +31,13 @@ import { BigDataConstants, ReportToBigDataUtil } from '../utils/ReportToBigDataU
|
||||
import { MultimodalInputManager } from '../model/common/MultimodalInputManager';
|
||||
import { BroadCastConstants } from '../model/common/BroadCastConstants';
|
||||
import { PhotoDataSource } from '../model/browser/photo/PhotoDataSource';
|
||||
import { Matrix4x4 } from '../utils/Matrix4x4';
|
||||
|
||||
const TAG: string = 'common_PhotoItem';
|
||||
|
||||
@Component
|
||||
export struct PhotoItem {
|
||||
@State @Watch('onViewDataChanged') item: MediaItem = new MediaItem(null);
|
||||
@State @Watch('onViewDataChanged') item: MediaItem = new MediaItem();
|
||||
@State matrix: Matrix4.Matrix4Transit = Matrix4.identity().copy();
|
||||
@State mDirection: PanDirection = PanDirection.Vertical;
|
||||
// @Consume broadCast: BroadCast;
|
||||
@ -49,12 +50,13 @@ export struct PhotoItem {
|
||||
@State lcdPixelMapUpdate: boolean = false;
|
||||
@Consume pageFrom: number;
|
||||
@Consume('transitionIndex') @Watch('onTransitionChange') updateTransition: number;
|
||||
mPosition: number;
|
||||
transitionTag: string;
|
||||
mPosition: number = 0;
|
||||
transitionTag: string = '';
|
||||
@State isLoading: boolean = true;
|
||||
@State usePixmap: boolean = false;
|
||||
@Provide listCardWidth: number = 0;
|
||||
verifyPhotoScaled: (matrix: Matrix4.Matrix4Transit) => void;
|
||||
verifyPhotoScaled: (matrix: Matrix4.Matrix4Transit) => void = (matrix: Matrix4.Matrix4Transit): void => {
|
||||
};
|
||||
@Consume currentIndex: number;
|
||||
@StorageLink('geometryScale') geometryScale: number = 1;
|
||||
@StorageLink('geometryOffsetX') geometryOffsetX: number = 0;
|
||||
@ -66,21 +68,21 @@ export struct PhotoItem {
|
||||
= ScreenManager.getInstance().isHorizontal();
|
||||
@State isPhotoScaled: boolean = false;
|
||||
@State justifyWidth: boolean = true;
|
||||
@State imageWidth: string = Constants.PERCENT_100;
|
||||
@State imageHeight: string = Constants.PERCENT_100;
|
||||
@State imageWidth?: string = Constants.PERCENT_100;
|
||||
@State imageHeight?: string = Constants.PERCENT_100;
|
||||
@State isEdgeTop: boolean = true;
|
||||
@Link isRunningAnimation: boolean;
|
||||
@State geometryTransitionId: string = 'default_id';
|
||||
@StorageLink('geometryTransitionBrowserId') @Watch('onGeometryIdChange') geometryTransitionBrowserId: string = '';
|
||||
private lastUpdateTransition: number = -1;
|
||||
private eventPipeline: EventPipeline;
|
||||
private animationOption: AnimationParam = null;
|
||||
private animationEndMatrix: Matrix4.Matrix4Transit = null;
|
||||
private eventPipeline: EventPipeline | null = null;
|
||||
private animationOption?: AnimationParam;
|
||||
private animationEndMatrix?: Matrix4.Matrix4Transit;
|
||||
private isHandlingTap: boolean = false;
|
||||
private timerCounter: number;
|
||||
private timerCounter: number = 0;
|
||||
private imgScale: number = 1;
|
||||
private firstLoad: boolean = true;
|
||||
private preItem = { height: 0, width: 0 };
|
||||
private preItem: PreItem = { height: 0, width: 0 };
|
||||
private albumUri: string = '';
|
||||
private imagePropertyComponentHeight: number = 578;
|
||||
private propertyHeightHorizontal: number = 300;
|
||||
@ -92,12 +94,12 @@ export struct PhotoItem {
|
||||
private windowLayoutHeight: number = ScreenManager.getInstance().getWinLayoutHeight();
|
||||
private windowColumns: number = ScreenManager.getInstance().getScreenColumns();
|
||||
private isFromFACard: boolean = false;
|
||||
private dataSource: PhotoDataSource;
|
||||
private dataSource: PhotoDataSource | null = null;
|
||||
private isDefaultFA: boolean = false;
|
||||
private onWindowSizeChangeCallBack = () => this.onWindowSizeChanged();
|
||||
private onDataReloadFunc: Function = this.onDataReload.bind(this);
|
||||
private resetDefaultScaleFunc: Function = this.resetDefaultScale.bind(this);
|
||||
private saveScaleFunc: Function = this.saveScale.bind(this);
|
||||
private onDataReloadFunc: Function = (addCount: KeyEvent): void => this.onDataReload(addCount);
|
||||
private resetDefaultScaleFunc: Function = (): void => this.resetDefaultScale();
|
||||
private saveScaleFunc: Function = (): void => this.saveScale();
|
||||
|
||||
onGeometryIdChange() {
|
||||
this.geometryTransitionId = (this.mPosition === this.currentIndex) ? this.geometryTransitionBrowserId : 'default_id';
|
||||
@ -107,7 +109,7 @@ export struct PhotoItem {
|
||||
|
||||
private onDataReload(addCount: KeyEvent): void {
|
||||
Log.info(TAG, `onDataReload ${this.item.uri}`);
|
||||
let item: MediaItem = this.dataSource.getItemByUri(this.item.uri) as MediaItem;
|
||||
let item: MediaItem | null = this.dataSource?.getItemByUri(this.item.uri) as MediaItem ?? null;
|
||||
if (item) {
|
||||
this.item = item;
|
||||
Log.debug(TAG, `Item[${this.item.uri}] is changed`);
|
||||
@ -130,7 +132,6 @@ export struct PhotoItem {
|
||||
this.matrix = Matrix4.identity().copy();
|
||||
this.isPhotoScaled = false;
|
||||
this.firstLoad = true;
|
||||
this.eventPipelineSizeChange = this.eventPipelineSizeChange.bind(this)
|
||||
if (this.dataSource) {
|
||||
this.broadCast.on(BroadCastConstants.ON_DATA_RELOADED, this.onDataReloadFunc);
|
||||
}
|
||||
@ -143,7 +144,7 @@ export struct PhotoItem {
|
||||
this.calculateImagePos();
|
||||
this.onGeometryIdChange();
|
||||
|
||||
let matrix: Matrix4.Matrix4Transit = AppStorage.Get(PhotoConstants.MATRIX);
|
||||
let matrix: Matrix4.Matrix4Transit = AppStorage.get<Matrix4.Matrix4Transit>(PhotoConstants.MATRIX) as Matrix4.Matrix4Transit;
|
||||
if (this.currentIndex == this.mPosition && matrix) {
|
||||
this.matrix = matrix;
|
||||
this.updatePhotoScaledStatus();
|
||||
@ -165,13 +166,13 @@ export struct PhotoItem {
|
||||
duration: Constants.SCREEN_ROTATE_DURATION,
|
||||
curve: PhotoConstants.PHOTO_TRANSITION_CURVE,
|
||||
onFinish: () => {
|
||||
this.eventPipeline.onAnimationEnd(this.animationEndMatrix);
|
||||
this.animationOption = null;
|
||||
this.animationEndMatrix = null;
|
||||
this.eventPipeline?.onAnimationEnd(this.animationEndMatrix);
|
||||
this.animationOption = undefined;
|
||||
this.animationEndMatrix = undefined;
|
||||
}
|
||||
}, () => {
|
||||
this.eventPipelineSizeChange();
|
||||
this.matrix = this.animationEndMatrix;
|
||||
this.matrix = this.animationEndMatrix as Matrix4.Matrix4Transit;
|
||||
this.calculateImagePos();
|
||||
this.updateListCardWidth();
|
||||
});
|
||||
@ -179,7 +180,7 @@ export struct PhotoItem {
|
||||
}
|
||||
|
||||
eventPipelineSizeChange(): void {
|
||||
this.eventPipeline.onComponentSizeChanged(vp2px(this.windowLayoutWidth), vp2px(this.windowLayoutHeight));
|
||||
this.eventPipeline?.onComponentSizeChanged(vp2px(this.windowLayoutWidth), vp2px(this.windowLayoutHeight));
|
||||
}
|
||||
|
||||
aboutToDisappear(): void {
|
||||
@ -191,7 +192,6 @@ export struct PhotoItem {
|
||||
this.broadCast.off(BroadCastConstants.ON_DATA_RELOADED, this.onDataReloadFunc);
|
||||
}
|
||||
ScreenManager.getInstance().off(ScreenManager.ON_WIN_SIZE_CHANGED, this.onWindowSizeChangeCallBack);
|
||||
this.onWindowSizeChangeCallBack = null;
|
||||
this.broadCast.off(PhotoConstants.RESET_DEFAULT_SCALE + this.item.uri, this.resetDefaultScaleFunc);
|
||||
this.broadCast.off(PhotoConstants.SAVE_SCALE, this.saveScaleFunc);
|
||||
this.lcdPixelMapUpdate = false;
|
||||
@ -241,20 +241,20 @@ export struct PhotoItem {
|
||||
}
|
||||
|
||||
resetScaleAnimation(matrix: Matrix4.Matrix4Transit): void {
|
||||
if (this.eventPipeline.isDefaultScale()) {
|
||||
if (this.eventPipeline?.isDefaultScale()) {
|
||||
return;
|
||||
}
|
||||
this.eventPipeline.startAnimation(matrix);
|
||||
this.eventPipeline?.startAnimation(matrix);
|
||||
animateTo({
|
||||
duration: this.animationOption.duration,
|
||||
curve: this.animationOption.curve,
|
||||
onFinish: () => {
|
||||
this.eventPipeline.onAnimationEnd(this.animationEndMatrix);
|
||||
this.animationOption = null;
|
||||
this.animationEndMatrix = null;
|
||||
duration: (this.animationOption as AnimationParam).duration,
|
||||
curve: (this.animationOption as AnimationParam).curve as Curve,
|
||||
onFinish: (): void => {
|
||||
this.eventPipeline?.onAnimationEnd(this.animationEndMatrix as Matrix4.Matrix4Transit);
|
||||
this.animationOption = undefined;
|
||||
this.animationEndMatrix = undefined;
|
||||
}
|
||||
}, () => {
|
||||
this.matrix = this.animationEndMatrix;
|
||||
this.matrix = this.animationEndMatrix as Matrix4.Matrix4Transit;
|
||||
this.updatePhotoScaledStatus();
|
||||
})
|
||||
}
|
||||
@ -266,13 +266,15 @@ export struct PhotoItem {
|
||||
}
|
||||
|
||||
updatePhotoScaledStatus() {
|
||||
let matrix: any = this.matrix;
|
||||
let matrix: Matrix4.Matrix4Transit = this.matrix;
|
||||
if (!!matrix) {
|
||||
let mat = matrix.copy().matrix4x4;
|
||||
let xScale = mat[Constants.NUMBER_0];
|
||||
let yScale = mat[Constants.NUMBER_5];
|
||||
Log.debug(TAG, `photo in PhotoItem has Scaled x scale: ${xScale}, y scale: ${yScale}, mat: ${mat}`);
|
||||
this.isPhotoScaled = (xScale != 1 || yScale != 1);
|
||||
let mat: number[] | undefined = (matrix.copy() as Matrix4x4).matrix4x4;
|
||||
if (mat) {
|
||||
let xScale: number = mat[Constants.NUMBER_0];
|
||||
let yScale: number = mat[Constants.NUMBER_5];
|
||||
Log.debug(TAG, `photo in PhotoItem has Scaled x scale: ${xScale}, y scale: ${yScale}, mat: ${mat}`);
|
||||
this.isPhotoScaled = (xScale != 1 || yScale != 1);
|
||||
}
|
||||
} else {
|
||||
this.isPhotoScaled = false;
|
||||
}
|
||||
@ -302,11 +304,11 @@ export struct PhotoItem {
|
||||
this.broadCast.emit(PhotoConstants.PHOTO_SHOW_STATE, [false]);
|
||||
}
|
||||
})
|
||||
.onKeyEvent((event: KeyEvent) => {
|
||||
this.handleKeyEvent(event);
|
||||
.onKeyEvent((event?: KeyEvent) => {
|
||||
this.handleKeyEvent(event as KeyEvent);
|
||||
})
|
||||
.width(this.imageWidth)
|
||||
.height(this.imageHeight)
|
||||
.width(this.imageWidth as string)
|
||||
.height(this.imageHeight as string)
|
||||
.scale({
|
||||
x: this.geometryScale,
|
||||
y: this.geometryScale
|
||||
@ -316,15 +318,12 @@ export struct PhotoItem {
|
||||
y: this.geometryOffsetY
|
||||
})
|
||||
.geometryTransition(this.geometryTransitionId)
|
||||
// @ts-ignore
|
||||
.transition(TransitionEffect.asymmetric(TransitionEffect.opacity(0.99),
|
||||
// @ts-ignore
|
||||
TransitionEffect.scale({
|
||||
x: 1 / this.geometryScale,
|
||||
y: 1 / this.geometryScale,
|
||||
centerX: '50%',
|
||||
centerY: '50%' })
|
||||
// @ts-ignore
|
||||
.combine(TransitionEffect.opacity(0.99))
|
||||
))
|
||||
.onAppear(() => {
|
||||
@ -377,8 +376,8 @@ export struct PhotoItem {
|
||||
this.broadCast.emit(PhotoConstants.PHOTO_SHOW_STATE, [false]);
|
||||
}
|
||||
})
|
||||
.onKeyEvent((event: KeyEvent) => {
|
||||
this.handleKeyEvent(event);
|
||||
.onKeyEvent((event?: KeyEvent) => {
|
||||
this.handleKeyEvent(event as KeyEvent);
|
||||
})
|
||||
.onAppear(() => {
|
||||
if (this.currentIndex == this.mPosition) {
|
||||
@ -407,38 +406,38 @@ export struct PhotoItem {
|
||||
fingers: 2,
|
||||
distance: 1
|
||||
})
|
||||
.onActionStart((event: GestureEvent) => {
|
||||
.onActionStart((event?: GestureEvent) => {
|
||||
Log.info(TAG, 'PinchGesture onActionStart');
|
||||
Log.info(TAG, `PinchGesture onActionStart scale:\
|
||||
${event.scale}, cx: ${event.pinchCenterX}, cy: ${event.pinchCenterY}`);
|
||||
${(event as GestureEvent).scale}, cx: ${(event as GestureEvent).pinchCenterX}, cy: ${(event as GestureEvent).pinchCenterY}`);
|
||||
if (this.item.mediaType == UserFileManagerAccess.MEDIA_TYPE_IMAGE
|
||||
|| this.item.mediaType == UserFileManagerAccess.MEDIA_TYPE_VIDEO) {
|
||||
this.eventPipeline.onScaleStart(event.scale, event.pinchCenterX, event.pinchCenterY);
|
||||
this.eventPipeline?.onScaleStart((event as GestureEvent).scale, (event as GestureEvent).pinchCenterX, (event as GestureEvent).pinchCenterY);
|
||||
}
|
||||
})
|
||||
.onActionUpdate((event) => {
|
||||
Log.info(TAG, `PinchGesture onActionUpdate scale: ${event.scale}`);
|
||||
.onActionUpdate((event?: GestureEvent) => {
|
||||
Log.debug(TAG, `PinchGesture onActionUpdate scale: ${(event as GestureEvent).scale}`);
|
||||
if (this.item.mediaType == UserFileManagerAccess.MEDIA_TYPE_IMAGE
|
||||
|| this.item.mediaType == UserFileManagerAccess.MEDIA_TYPE_VIDEO) {
|
||||
this.eventPipeline.onScale(event.scale);
|
||||
this.eventPipeline?.onScale((event as GestureEvent).scale);
|
||||
}
|
||||
})
|
||||
.onActionEnd(() => {
|
||||
Log.info(TAG, 'PinchGesture onActionEnd');
|
||||
if (this.item.mediaType == UserFileManagerAccess.MEDIA_TYPE_IMAGE
|
||||
|| this.item.mediaType == UserFileManagerAccess.MEDIA_TYPE_VIDEO) {
|
||||
this.eventPipeline.onScaleEnd();
|
||||
this.eventPipeline?.onScaleEnd();
|
||||
if (this.animationOption != null) {
|
||||
animateTo({
|
||||
duration: this.animationOption.duration,
|
||||
curve: this.animationOption.curve,
|
||||
onFinish: () => {
|
||||
this.eventPipeline.onAnimationEnd(this.animationEndMatrix);
|
||||
this.animationOption = null;
|
||||
this.animationEndMatrix = null;
|
||||
this.eventPipeline?.onAnimationEnd(this.animationEndMatrix);
|
||||
this.animationOption = undefined;
|
||||
this.animationEndMatrix = undefined;
|
||||
}
|
||||
}, () => {
|
||||
this.matrix = this.animationEndMatrix;
|
||||
this.matrix = this.animationEndMatrix as Matrix4.Matrix4Transit;
|
||||
})
|
||||
if (!!this.verifyPhotoScaled) {
|
||||
this.verifyPhotoScaled(this.matrix)
|
||||
@ -451,50 +450,50 @@ export struct PhotoItem {
|
||||
PanGesture({
|
||||
direction: this.mDirection
|
||||
})
|
||||
.onActionStart((event: GestureEvent) => {
|
||||
.onActionStart((event?: GestureEvent) => {
|
||||
Log.info(TAG, `PanGesture start offsetX:\
|
||||
${vp2px(event.offsetX)}, offsetY: ${vp2px(event.offsetY)}`);
|
||||
if (this.isNeedShieldPullUpEvent(event)) {
|
||||
${vp2px((event as GestureEvent).offsetX)}, offsetY: ${vp2px((event as GestureEvent).offsetY)}`);
|
||||
if (this.isNeedShieldPullUpEvent((event as GestureEvent))) {
|
||||
Log.info(TAG, `shield pullup event, is album recycle = ${this.albumUri == UserFileManagerAccess.getInstance()
|
||||
.getSystemAlbumUri(UserFileManagerAccess.TRASH_ALBUM_SUB_TYPE)},\
|
||||
is photo scaled = ${this.isPhotoScaled}, is pull Up = ${event.offsetY < 0}`);
|
||||
is photo scaled = ${this.isPhotoScaled}, is pull Up = ${(event as GestureEvent).offsetY < 0}`);
|
||||
return;
|
||||
}
|
||||
this.eventPipeline.onMoveStart(vp2px(event.offsetX), vp2px(event.offsetY));
|
||||
this.eventPipeline?.onMoveStart(vp2px((event as GestureEvent).offsetX), vp2px((event as GestureEvent).offsetY));
|
||||
})
|
||||
.onActionUpdate((event: GestureEvent) => {
|
||||
.onActionUpdate((event?: GestureEvent) => {
|
||||
Log.info(TAG, `PanGesture update offsetX:\
|
||||
${vp2px(event.offsetX)}, offsetY: ${vp2px(event.offsetY)}`);
|
||||
if (this.isNeedShieldPullUpEvent(event)) {
|
||||
${vp2px((event as GestureEvent).offsetX)}, offsetY: ${vp2px((event as GestureEvent).offsetY)}`);
|
||||
if (this.isNeedShieldPullUpEvent((event as GestureEvent))) {
|
||||
return;
|
||||
}
|
||||
this.eventPipeline.onMove(vp2px(event.offsetX), vp2px(event.offsetY));
|
||||
this.isPullDownAndDragPhoto = this.eventPipeline.canPullDownAndDragPhoto();
|
||||
this.eventPipeline?.onMove(vp2px((event as GestureEvent).offsetX), vp2px((event as GestureEvent).offsetY));
|
||||
this.isPullDownAndDragPhoto = this.eventPipeline?.canPullDownAndDragPhoto() ?? false;
|
||||
if (this.isPullDownAndDragPhoto && this.geometryTransitionEnable &&
|
||||
!this.isOnSwiperAnimation && !this.isFromFACard) {
|
||||
this.doDragPhoto(event.offsetX, event.offsetY);
|
||||
this.doDragPhoto((event as GestureEvent).offsetX, (event as GestureEvent).offsetY);
|
||||
}
|
||||
})
|
||||
.onActionEnd((event: GestureEvent) => {
|
||||
.onActionEnd((event?: GestureEvent) => {
|
||||
Log.info(TAG, `PanGesture end offsetX:\
|
||||
${vp2px(event.offsetX)}, offsetY: ${vp2px(event.offsetY)} \
|
||||
${vp2px((event as GestureEvent).offsetX)}, offsetY: ${vp2px((event as GestureEvent).offsetY)} \
|
||||
this.isOnSwiperAnimation ${this.isOnSwiperAnimation}`);
|
||||
if (this.isOnSwiperAnimation || this.isNeedShieldPullUpEvent(event)) {
|
||||
if (this.isOnSwiperAnimation || this.isNeedShieldPullUpEvent((event as GestureEvent))) {
|
||||
return;
|
||||
}
|
||||
this.eventPipeline.onMoveEnd(vp2px(event.offsetX), vp2px(event.offsetY));
|
||||
this.isPullDownAndDragPhoto = this.eventPipeline.canPullDownAndDragPhoto();
|
||||
this.eventPipeline?.onMoveEnd(vp2px((event as GestureEvent).offsetX), vp2px((event as GestureEvent).offsetY));
|
||||
this.isPullDownAndDragPhoto = this.eventPipeline?.canPullDownAndDragPhoto() ?? false;
|
||||
if (this.animationOption != null) {
|
||||
animateTo({
|
||||
duration: this.animationOption.duration,
|
||||
curve: this.animationOption.curve,
|
||||
onFinish: () => {
|
||||
this.eventPipeline.onAnimationEnd(this.animationEndMatrix);
|
||||
this.animationOption = null;
|
||||
this.animationEndMatrix = null;
|
||||
this.eventPipeline?.onAnimationEnd(this.animationEndMatrix);
|
||||
this.animationOption = undefined;
|
||||
this.animationEndMatrix = undefined;
|
||||
}
|
||||
}, () => {
|
||||
this.matrix = this.animationEndMatrix;
|
||||
this.matrix = this.animationEndMatrix as Matrix4.Matrix4Transit;
|
||||
})
|
||||
if (!!this.verifyPhotoScaled) {
|
||||
this.verifyPhotoScaled(this.matrix)
|
||||
@ -506,11 +505,11 @@ export struct PhotoItem {
|
||||
TapGesture({
|
||||
count: 1
|
||||
})
|
||||
.onAction((event: GestureEvent) => {
|
||||
.onAction((event?: GestureEvent) => {
|
||||
if (this.isHandlingTap) {
|
||||
if (this.timerCounter != null) {
|
||||
clearTimeout(this.timerCounter)
|
||||
this.timerCounter = null;
|
||||
this.timerCounter = 0;
|
||||
this.isHandlingTap = false;
|
||||
}
|
||||
} else {
|
||||
@ -522,19 +521,19 @@ export struct PhotoItem {
|
||||
return;
|
||||
}
|
||||
Log.info(TAG, `onDoubleTap event: ${JSON.stringify(event)}`);
|
||||
this.eventPipeline.onDoubleTap(event.fingerList[0].localX, event.fingerList[0].localY);
|
||||
this.eventPipeline?.onDoubleTap((event as GestureEvent).fingerList[0].localX, (event as GestureEvent).fingerList[0].localY);
|
||||
if (this.animationOption != null) {
|
||||
Log.info(TAG, 'TapGesture animateTo start');
|
||||
animateTo({
|
||||
duration: this.animationOption.duration,
|
||||
curve: this.animationOption.curve,
|
||||
onFinish: () => {
|
||||
this.eventPipeline.onAnimationEnd(this.animationEndMatrix);
|
||||
this.animationOption = null;
|
||||
this.animationEndMatrix = null;
|
||||
this.eventPipeline?.onAnimationEnd(this.animationEndMatrix);
|
||||
this.animationOption = undefined;
|
||||
this.animationEndMatrix = undefined;
|
||||
}
|
||||
}, () => {
|
||||
this.matrix = this.animationEndMatrix;
|
||||
this.matrix = this.animationEndMatrix as Matrix4.Matrix4Transit;
|
||||
})
|
||||
if (!!this.verifyPhotoScaled) {
|
||||
this.verifyPhotoScaled(this.matrix)
|
||||
@ -545,9 +544,9 @@ export struct PhotoItem {
|
||||
)
|
||||
)
|
||||
.clip(true)
|
||||
.onTouch((event) => {
|
||||
this.dealTouchEvent(event);
|
||||
this.eventPipeline.onTouch(event);
|
||||
.onTouch((event?: TouchEvent) => {
|
||||
this.dealTouchEvent(event as TouchEvent);
|
||||
this.eventPipeline?.onTouch(event as TouchEvent);
|
||||
})
|
||||
// TODO Remind users when pictures of other devices cannot be show
|
||||
if ((this.showError || this.item.mediaType == UserFileManagerAccess.MEDIA_TYPE_VIDEO) &&
|
||||
@ -585,9 +584,13 @@ export struct PhotoItem {
|
||||
previewUri: this.thumbnail
|
||||
}
|
||||
})
|
||||
let msg = {
|
||||
'PhotoButton': BigDataConstants.PHOTO_BUTTON_VIDEO,
|
||||
'From': BigDataConstants.LOCAL_MEDIA,
|
||||
interface Msg {
|
||||
photoButton: string;
|
||||
from: string;
|
||||
}
|
||||
let msg: Msg = {
|
||||
photoButton: BigDataConstants.PHOTO_BUTTON_VIDEO,
|
||||
from: BigDataConstants.LOCAL_MEDIA,
|
||||
}
|
||||
ReportToBigDataUtil.report(BigDataConstants.CLICK_PHOTO_BUTTON_ID, msg);
|
||||
}
|
||||
@ -686,6 +689,7 @@ export struct PhotoItem {
|
||||
}
|
||||
|
||||
private dealTouchEvent(event: TouchEvent): void {
|
||||
if (this.eventPipeline === null) return;
|
||||
if (!this.eventPipeline.canTouch() || this.isOnSwiperAnimation || event.touches.length > 1 || this.isPhotoScaled || this.isInSelectedMode || this.isDefaultFA) {
|
||||
return;
|
||||
}
|
||||
@ -707,11 +711,14 @@ export struct PhotoItem {
|
||||
|
||||
private handleKeyEvent(event: KeyEvent): void {
|
||||
Log.info(TAG, `type=${event.type}, keyCode=${event.keyCode}`);
|
||||
interface Msg {
|
||||
from: string;
|
||||
}
|
||||
if (KeyType.Up == event.type) {
|
||||
switch (event.keyCode) {
|
||||
case MultimodalInputManager.KEY_CODE_KEYBOARD_ESC:
|
||||
let msg = {
|
||||
'From': BigDataConstants.BY_KEYBOARD,
|
||||
let msg: Msg = {
|
||||
from: BigDataConstants.BY_KEYBOARD,
|
||||
}
|
||||
ReportToBigDataUtil.report(BigDataConstants.ESC_PHOTO_BROWSER_WAY, msg);
|
||||
this.broadCast.emit(PhotoConstants.PULL_DOWN_END, []);
|
||||
@ -726,10 +733,6 @@ export struct PhotoItem {
|
||||
previewUri: this.thumbnail
|
||||
}
|
||||
})
|
||||
let msg = {
|
||||
'PhotoButton': BigDataConstants.PHOTO_BUTTON_VIDEO,
|
||||
'From': BigDataConstants.LOCAL_MEDIA,
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@ -744,3 +747,8 @@ export struct PhotoItem {
|
||||
!this.isPhotoScaled;
|
||||
}
|
||||
}
|
||||
|
||||
interface PreItem {
|
||||
height: number;
|
||||
width: number;
|
||||
}
|
||||
|
@ -21,46 +21,59 @@ import { BroadCast } from '../utils/BroadCast';
|
||||
import Curves from '@ohos.curves';
|
||||
import { Constants } from '../model/common/Constants';
|
||||
import { Constants as BrowserConstants } from '../model/browser/photo/Constants';
|
||||
import { PhotoDataSource } from '../model/browser/photo/PhotoDataSource';
|
||||
import { MediaItem } from '../model/browser/photo/MediaItem';
|
||||
|
||||
const TAG: string = 'common_PhotoSwiper';
|
||||
|
||||
export interface Results {
|
||||
data: MediaItem;
|
||||
pos: number;
|
||||
thumbnail: string;
|
||||
};
|
||||
|
||||
@Component
|
||||
export struct PhotoSwiper {
|
||||
mTransition: string;
|
||||
mTransition: string = '';
|
||||
@Consume currentIndex: number;
|
||||
@Link broadCast: BroadCast;
|
||||
@State mDuration: number = 300;
|
||||
onPhotoChanged: Function;
|
||||
swiperController: SwiperController;
|
||||
isInSelectedMode: boolean;
|
||||
onPhotoChanged: Function = (): void => {};
|
||||
swiperController?: SwiperController;
|
||||
isInSelectedMode: boolean = false;
|
||||
@Consume canSwipe: boolean;
|
||||
swiperItemSpace: number = Constants.NUMBER_8;
|
||||
verifyPhotoScaledFunc: (matrix: Matrix4.Matrix4Transit) => void
|
||||
verifyPhotoScaledFunc: (matrix?: Matrix4.Matrix4Transit) => void = (matrix?: Matrix4.Matrix4Transit): void => {}
|
||||
@Link isRunningAnimation: boolean;
|
||||
isLeftSwiper: boolean = false;
|
||||
@Consume isDeleting: boolean;
|
||||
@State isOnSwiperAnimation: boolean = false;
|
||||
private dataSource;
|
||||
private dataSource?: PhotoDataSource;
|
||||
private geometryTransitionEnable: boolean = false;
|
||||
private isFromFACard: boolean = false;
|
||||
private SWIPE_CACHE_COUNT: number = 2;
|
||||
private onDataReloadFunc: Function = (addCount: number): void => this.onDataReload(addCount);
|
||||
private onChangeSwiperDurationFunc: Function = (value: number): void => this.onChangeSwiperDuration(value);
|
||||
|
||||
aboutToAppear() {
|
||||
this.broadCast.on(BroadCastConstants.ON_DATA_RELOADED, (addCount) => {
|
||||
let totalCount = this.dataSource.totalCount();
|
||||
if (addCount > Constants.NUMBER_0) {
|
||||
private onDataReload(addCount: number): void {
|
||||
let totalCount = this.dataSource == null ? 0 : this.dataSource.totalCount();
|
||||
let add = addCount;
|
||||
if (add > Constants.NUMBER_0) {
|
||||
if (this.dataSource != null) {
|
||||
this.dataSource.onDataReloaded();
|
||||
if (this.currentIndex + addCount < totalCount) {
|
||||
this.currentIndex += addCount;
|
||||
}
|
||||
Log.info(TAG, `ON_DATA_RELOADED: ${this.currentIndex}, ${addCount}`);
|
||||
return;
|
||||
}
|
||||
Log.debug(TAG, 'animate to data reloaded start');
|
||||
animateTo({
|
||||
duration: 300, // 删除动画时长
|
||||
curve: Curves.cubicBezier(0.0, 0.0, 0.2, 1.0), // 减速曲线参数
|
||||
onFinish: () => {
|
||||
if (this.currentIndex + add < totalCount) {
|
||||
this.currentIndex += add;
|
||||
}
|
||||
Log.info(TAG, `ON_DATA_RELOADED: ${this.currentIndex}, ${add}`);
|
||||
return;
|
||||
}
|
||||
Log.debug(TAG, 'animate to data reloaded start');
|
||||
animateTo({
|
||||
duration: 300, // 删除动画时长
|
||||
curve: Curves.cubicBezier(0.0, 0.0, 0.2, 1.0), // 减速曲线参数
|
||||
onFinish: () => {
|
||||
if (this.dataSource != null) {
|
||||
let totalCount = this.dataSource.totalCount();
|
||||
this.dataSource.onDataChanged(this.currentIndex);
|
||||
// UPDATE NEXT TWO DATA FOR AVOID NOT LOADING DATA
|
||||
@ -71,30 +84,37 @@ export struct PhotoSwiper {
|
||||
this.dataSource.onDataChanged(this.currentIndex + 2);
|
||||
}
|
||||
this.dataSource.onDataReloaded();
|
||||
} }, () => {
|
||||
if (this.isDeleting) {
|
||||
this.dataSource.deleteData(this.currentIndex);
|
||||
}
|
||||
if (this.currentIndex === this.dataSource.totalCount() || (this.isDeleting && this.isLeftSwiper && this.currentIndex > 0)) {
|
||||
this.currentIndex--;
|
||||
}
|
||||
this.isDeleting = false;
|
||||
})
|
||||
});
|
||||
} }, () => {
|
||||
if (this.dataSource != null && this.isDeleting) {
|
||||
this.dataSource.deleteData(this.currentIndex);
|
||||
}
|
||||
if (this.dataSource != null && this.currentIndex === this.dataSource.totalCount() || (this.isDeleting && this.isLeftSwiper && this.currentIndex > 0)) {
|
||||
this.currentIndex--;
|
||||
}
|
||||
this.isDeleting = false;
|
||||
})
|
||||
}
|
||||
|
||||
this.broadCast.on(BroadCastConstants.CHANGE_SWIPER_DURATION, (value) => {
|
||||
Log.debug(TAG, `change duration start ${value}`);
|
||||
this.mDuration = value;
|
||||
});
|
||||
private onChangeSwiperDuration(value: number): void {
|
||||
Log.debug(TAG, `change duration start ${value}`);
|
||||
this.mDuration = value;
|
||||
}
|
||||
|
||||
aboutToAppear() {
|
||||
this.broadCast.on(BroadCastConstants.ON_DATA_RELOADED, this.onDataReloadFunc);
|
||||
this.broadCast.on(BroadCastConstants.CHANGE_SWIPER_DURATION, this.onChangeSwiperDurationFunc);
|
||||
}
|
||||
|
||||
aboutToDisappear(): void {
|
||||
this.swiperController = undefined;
|
||||
this.broadCast.off(BroadCastConstants.ON_DATA_RELOADED, this.onDataReloadFunc);
|
||||
this.broadCast.off(BroadCastConstants.CHANGE_SWIPER_DURATION, this.onChangeSwiperDurationFunc);
|
||||
}
|
||||
|
||||
build() {
|
||||
Swiper(this.swiperController) {
|
||||
LazyForEach(this.dataSource, (item, index?: number) => {
|
||||
LazyForEach(this.dataSource as PhotoDataSource, (item: Results, index?: number) => {
|
||||
if (!!item) {
|
||||
Column() {
|
||||
PhotoItem({
|
||||
@ -103,7 +123,7 @@ export struct PhotoSwiper {
|
||||
thumbnail: item.thumbnail,
|
||||
transitionTag: this.mTransition ? this.mTransition : 'default_id',
|
||||
verifyPhotoScaled: this.verifyPhotoScaledFunc,
|
||||
albumUri: this.dataSource.getAlbumUri(),
|
||||
albumUri: (this.dataSource == null ? '' : this.dataSource.getAlbumUri()),
|
||||
geometryTransitionEnable: this.geometryTransitionEnable,
|
||||
broadCast: $broadCast,
|
||||
isRunningAnimation: $isRunningAnimation,
|
||||
@ -114,7 +134,7 @@ export struct PhotoSwiper {
|
||||
})
|
||||
}.zIndex(item.pos == this.currentIndex ? 2 : 1)
|
||||
}
|
||||
}, (item, index) => {
|
||||
}, (item: Results, index?: number) => {
|
||||
if (item == null || item == undefined) {
|
||||
return JSON.stringify(item) + index;
|
||||
}
|
||||
@ -127,7 +147,7 @@ export struct PhotoSwiper {
|
||||
.parallelGesture(PanGesture({
|
||||
direction: PanDirection.Horizontal
|
||||
})
|
||||
.onActionStart((event: GestureEvent) => {
|
||||
.onActionStart((event?: GestureEvent) => {
|
||||
if (!this.canSwipe) {
|
||||
this.isOnSwiperAnimation = true;
|
||||
}
|
||||
|
@ -28,34 +28,35 @@ export enum DEVICE_TYPE {
|
||||
PC_LIKE
|
||||
}
|
||||
|
||||
const TabMap = {
|
||||
0: BigDataConstants.PHOTO_TAB,
|
||||
1: BigDataConstants.ALBUM_TAB,
|
||||
}
|
||||
const TabMap = [
|
||||
BigDataConstants.PHOTO_TAB,
|
||||
BigDataConstants.ALBUM_TAB
|
||||
]
|
||||
|
||||
@Component
|
||||
export struct TabBar {
|
||||
@Consume isSelectedMode: boolean;
|
||||
@Consume isAlbumSetSelectedMode: boolean;
|
||||
@Consume isShowSideBar: boolean;
|
||||
@Link @Watch('updateCurrentIndex') currentIndex: number;
|
||||
@Link @Watch('updateCurrentIndex') currentIndex: 0 | 1;
|
||||
@Link isSidebar: boolean;
|
||||
@StorageLink('sideBarBoundaryLineOpacity') sideBarBoundaryLineOpacity: number = 1;
|
||||
@StorageLink('sideBarOpacity') sideBarOpacity: number = 1;
|
||||
private tabs: TabItem[] = [];
|
||||
private controller: TabsController;
|
||||
private controller: TabsController | null = null;
|
||||
private appBroadCast: BroadCast = BroadCastManager.getInstance().getBroadCast();
|
||||
private deviceType: DEVICE_TYPE = DEVICE_TYPE.PC_LIKE;
|
||||
private funcOnTabSelected?: Function;
|
||||
|
||||
aboutToAppear(): void {
|
||||
this.onTabSelected = this.onTabSelected.bind(this);
|
||||
this.funcOnTabSelected = (index: number): void => this.onTabSelected(index);
|
||||
this.tabs[this.currentIndex].isSelected = true;
|
||||
this.tabs.forEach((tab: TabItem) => {
|
||||
Log.info(TAG, `${JSON.stringify(tab.name)} , ${tab.iconSelected}`)
|
||||
Log.info(TAG, `${JSON.stringify(tab.name)} , ${tab.iconSelected}`);
|
||||
});
|
||||
}
|
||||
|
||||
updateCurrentIndex() {
|
||||
updateCurrentIndex(): void {
|
||||
this.onTabSelected(this.currentIndex);
|
||||
}
|
||||
|
||||
@ -72,23 +73,25 @@ export struct TabBar {
|
||||
Tab({
|
||||
tabItem: tab,
|
||||
index: this.tabs.indexOf(tab),
|
||||
onTabSelected: this.onTabSelected,
|
||||
onTabSelected: this.funcOnTabSelected,
|
||||
isSidebar: $isSidebar,
|
||||
deviceType: this.deviceType
|
||||
})
|
||||
}, tab => tab.name.id)
|
||||
}, (tab: TabItem): string => {
|
||||
return (tab.name.id).toString();
|
||||
})
|
||||
}
|
||||
.padding({ left: Constants.NUMBER_16, top: Constants.NUMBER_96, right: Constants.NUMBER_16 })
|
||||
.flexGrow(Constants.NUMBER_1)
|
||||
.padding({ left: 16, top: 96, right: 16 })
|
||||
.flexGrow(1)
|
||||
.backgroundColor($r('app.color.default_background_color'))
|
||||
|
||||
// Sidebar boundary line
|
||||
if (this.isShowSideBar) {
|
||||
Row() {
|
||||
}
|
||||
.width(Constants.NUMBER_0)
|
||||
.width(0)
|
||||
.height(Constants.PERCENT_100)
|
||||
.border({ width: Constants.NUMBER_0_5, color: $r('app.color.album_cover_gradient_start_color') })
|
||||
.border({ width: 0.5, color: $r('app.color.album_cover_gradient_start_color') })
|
||||
.opacity(this.sideBarBoundaryLineOpacity)
|
||||
}
|
||||
}
|
||||
@ -104,13 +107,15 @@ export struct TabBar {
|
||||
Tab({
|
||||
tabItem: tab,
|
||||
index: this.tabs.indexOf(tab),
|
||||
onTabSelected: this.onTabSelected,
|
||||
onTabSelected: this.funcOnTabSelected,
|
||||
isSidebar: $isSidebar,
|
||||
deviceType: this.deviceType
|
||||
})
|
||||
}
|
||||
.layoutWeight(Constants.NUMBER_1)
|
||||
}, tab => tab.name.id)
|
||||
.layoutWeight(1)
|
||||
}, (tab: TabItem): string => {
|
||||
return (tab.name.id).toString();
|
||||
})
|
||||
}
|
||||
.height($r('app.float.horizontal_width'))
|
||||
}
|
||||
@ -126,14 +131,22 @@ export struct TabBar {
|
||||
}) {
|
||||
ForEach(this.tabs, (tab: TabItem) => {
|
||||
Stack() {
|
||||
TabPhone({ tabItem: tab, index: this.tabs.indexOf(tab), onTabSelected: this.onTabSelected })
|
||||
TabPhone({ tabItem: tab, index: this.tabs.indexOf(tab), onTabSelected: this.funcOnTabSelected })
|
||||
}
|
||||
.layoutWeight(1)
|
||||
.onClick(() => {
|
||||
this.onTabSelected && this.onTabSelected(this.tabs.indexOf(tab));
|
||||
if (this.funcOnTabSelected) {
|
||||
if (this.currentIndex == this.tabs.indexOf(tab)) {
|
||||
Log.debug(TAG, `it is same: ${this.currentIndex}`);
|
||||
this.appBroadCast.emit(BroadCastConstants.RESET_ZERO, [this.currentIndex]);
|
||||
}
|
||||
this.funcOnTabSelected(this.tabs.indexOf(tab));
|
||||
}
|
||||
tab.isSelected = true;
|
||||
})
|
||||
}, tab => tab.name.id)
|
||||
}, (tab: TabItem): string => {
|
||||
return (tab.name.id).toString();
|
||||
})
|
||||
}
|
||||
.visibility((this.isSelectedMode || this.isAlbumSetSelectedMode) ? Visibility.None : Visibility.Visible)
|
||||
.height($r('app.float.tab_bar_vertical_height'))
|
||||
@ -143,13 +156,9 @@ export struct TabBar {
|
||||
}
|
||||
|
||||
private onTabSelected(index: number): void {
|
||||
Log.debug(TAG, `this.currentIndex: ${this.currentIndex} index: ${index}`);
|
||||
if (this.currentIndex == index) {
|
||||
Log.error(TAG, `it is same: ${index}`);
|
||||
this.appBroadCast.emit(BroadCastConstants.RESET_ZERO, [index]);
|
||||
}
|
||||
this.currentIndex = index;
|
||||
this.controller.changeIndex(this.currentIndex);
|
||||
Log.debug(TAG, `TabBar this.currentIndex: ${this.currentIndex} index: ${index}`);
|
||||
this.currentIndex = index as 0 | 1;
|
||||
if (this.controller != null) this.controller.changeIndex(this.currentIndex);
|
||||
this.tabs.forEach((tab: TabItem) => {
|
||||
if (this.tabs.indexOf(tab) == index) {
|
||||
tab.isSelected = true;
|
||||
@ -157,10 +166,14 @@ export struct TabBar {
|
||||
tab.isSelected = false;
|
||||
}
|
||||
})
|
||||
let currentTab = TabMap[this.currentIndex] ? TabMap[this.currentIndex] : BigDataConstants.PHOTO_TAB;
|
||||
let msg = {
|
||||
'SwitchTab': BigDataConstants.CLICK_SWITCH,
|
||||
'Current': currentTab,
|
||||
let currentTab: string = TabMap[this.currentIndex] ? TabMap[this.currentIndex] : BigDataConstants.PHOTO_TAB;
|
||||
interface Msg {
|
||||
switchTab: string;
|
||||
current: string;
|
||||
}
|
||||
let msg: Msg = {
|
||||
switchTab: BigDataConstants.CLICK_SWITCH,
|
||||
current: currentTab,
|
||||
}
|
||||
ReportToBigDataUtil.report(BigDataConstants.TAB_SWITCH_ID, msg);
|
||||
Log.info(TAG, `select ${this.currentIndex}`);
|
||||
@ -172,9 +185,9 @@ export struct TabBar {
|
||||
struct Tab {
|
||||
@ObjectLink tabItem: TabItem;
|
||||
@Link isSidebar: boolean;
|
||||
index: number;
|
||||
onTabSelected: Function;
|
||||
private deviceType: number;
|
||||
index: number = 0;
|
||||
onTabSelected?: Function;
|
||||
private deviceType: number = 0;
|
||||
|
||||
build() {
|
||||
if (this.deviceType == DEVICE_TYPE.PC_LIKE) {
|
||||
@ -185,6 +198,7 @@ struct Tab {
|
||||
}) {
|
||||
Stack() {
|
||||
Image(this.tabItem.getIcon(this.tabItem.isSelected))
|
||||
.draggable(false)
|
||||
.height($r('app.float.icon_size'))
|
||||
.width($r('app.float.icon_size'))
|
||||
.objectFit(ImageFit.Fill)
|
||||
@ -206,7 +220,7 @@ struct Tab {
|
||||
}
|
||||
.backgroundColor(this.tabItem.isSelected ? '#DAE2F5' : $r('app.color.transparent'))
|
||||
.borderRadius($r('app.float.single_tab_margin'))
|
||||
.onClick(() => {
|
||||
.onClick((): void => {
|
||||
this.onTabSelected && this.onTabSelected(this.index);
|
||||
this.tabItem.isSelected = true;
|
||||
})
|
||||
@ -218,12 +232,13 @@ struct Tab {
|
||||
}) {
|
||||
Stack() {
|
||||
Image(this.tabItem.getIcon(this.tabItem.isSelected))
|
||||
.draggable(false)
|
||||
.height($r('app.float.icon_size'))
|
||||
.width($r('app.float.icon_size'))
|
||||
.objectFit(ImageFit.Fill)
|
||||
}
|
||||
.padding({
|
||||
left: this.isSidebar ? Constants.NUMBER_0 : $r('app.float.tab_bar_text_padding_left'),
|
||||
left: this.isSidebar ? 0 : $r('app.float.tab_bar_text_padding_left'),
|
||||
})
|
||||
|
||||
Text(this.tabItem.name)
|
||||
@ -236,7 +251,7 @@ struct Tab {
|
||||
right: $r('app.float.tab_bar_text_padding_horizontal')
|
||||
})
|
||||
}
|
||||
.onClick(() => {
|
||||
.onClick((): void => {
|
||||
this.onTabSelected && this.onTabSelected(this.index);
|
||||
this.tabItem.isSelected = true;
|
||||
})
|
||||
@ -248,8 +263,8 @@ struct Tab {
|
||||
@Component
|
||||
struct TabPhone {
|
||||
@ObjectLink tabItem: TabItem;
|
||||
index: number;
|
||||
onTabSelected: Function;
|
||||
index: number = 0;
|
||||
onTabSelected?: Function;
|
||||
|
||||
build() {
|
||||
Flex({
|
||||
@ -258,6 +273,7 @@ struct TabPhone {
|
||||
justifyContent: FlexAlign.Center
|
||||
}) {
|
||||
Image(this.tabItem.getIcon(this.tabItem.isSelected))
|
||||
.draggable(false)
|
||||
.height($r('app.float.icon_size'))
|
||||
.width($r('app.float.icon_size'))
|
||||
.objectFit(ImageFit.Fill)
|
||||
@ -285,12 +301,13 @@ struct TabPhone {
|
||||
@Component
|
||||
export struct TabBarForAlbumSet {
|
||||
@Consume isTabBarShow: boolean;
|
||||
private currentIndex: number;
|
||||
private currentIndex: number = 0;
|
||||
private tabs: TabItemWithText[] = [];
|
||||
private controller: TabsController;
|
||||
private controller: TabsController | null = null;
|
||||
private funcOnTabSelected?: Function;
|
||||
|
||||
aboutToAppear(): void {
|
||||
this.onTabSelected = this.onTabSelected.bind(this);
|
||||
this.funcOnTabSelected = (index: number): void => this.onTabSelected(index);
|
||||
this.tabs[this.currentIndex].isSelected = true;
|
||||
this.tabs.forEach((tab: TabItemWithText) => {
|
||||
Log.info(TAG, `${JSON.stringify(tab.name)}, ${tab.isSelected}`);
|
||||
@ -305,8 +322,10 @@ export struct TabBarForAlbumSet {
|
||||
alignItems: ItemAlign.Start
|
||||
}) {
|
||||
ForEach(this.tabs, (tab: TabItemWithText) => {
|
||||
TabWithText({ tabItemWithText: tab, index: this.tabs.indexOf(tab), onTabSelected: this.onTabSelected })
|
||||
}, tab => tab.name.id)
|
||||
TabWithText({ tabItemWithText: tab, index: this.tabs.indexOf(tab), onTabSelected: this.funcOnTabSelected })
|
||||
}, (tab: TabItemWithText): string => {
|
||||
return (tab.name.id).toString();
|
||||
})
|
||||
}
|
||||
.width('100%')
|
||||
.height($r('app.float.album_set_tab_bar_height'))
|
||||
@ -315,10 +334,10 @@ export struct TabBarForAlbumSet {
|
||||
}
|
||||
}
|
||||
|
||||
private onTabSelected(index: number) {
|
||||
Log.info(TAG, `this.currentIndex: ${this.currentIndex} index: ${index}`);
|
||||
private onTabSelected(index: number): void {
|
||||
Log.info(TAG, `TabBarForAlbumSet this.currentIndex: ${this.currentIndex} index: ${index}`);
|
||||
this.currentIndex = index;
|
||||
this.controller.changeIndex(this.currentIndex);
|
||||
if (this.controller != null) this.controller.changeIndex(this.currentIndex);
|
||||
this.tabs.forEach((tab: TabItemWithText) => {
|
||||
tab.isSelected = false;
|
||||
})
|
||||
@ -333,8 +352,8 @@ struct TabWithText {
|
||||
@Consume isAlbumSetSelectedMode: boolean;
|
||||
@ObjectLink tabItemWithText: TabItemWithText;
|
||||
@State TabWidth: number = 0;
|
||||
index: number;
|
||||
onTabSelected: Function;
|
||||
index: number = 0;
|
||||
onTabSelected?: Function;
|
||||
|
||||
aboutToAppear(): void {
|
||||
// Determine the length of the underline based on the font length
|
||||
@ -371,7 +390,7 @@ struct TabWithText {
|
||||
.height('100%')
|
||||
.onClick(() => {
|
||||
if (!this.isAlbumSetSelectedMode) {
|
||||
this.onTabSelected && this.onTabSelected(this.index)
|
||||
this.onTabSelected && this.onTabSelected(this.index);
|
||||
this.tabItemWithText.isSelected = true
|
||||
}
|
||||
})
|
||||
|
@ -28,7 +28,7 @@ export struct ThirdSelectPhotoBrowserActionBar {
|
||||
= [0, ScreenManager.getInstance().getStatusBarHeight(), 0, ScreenManager.getInstance().getNaviBarHeight()];
|
||||
@State isMultiPick: boolean = false;
|
||||
@Consume @Watch('createActionBar') isSelected: boolean;
|
||||
onMenuClicked: Function;
|
||||
onMenuClicked: Function = (): void => {};
|
||||
@StorageLink('isHorizontal') @Watch('createActionBar') isHorizontal: boolean = ScreenManager.getInstance()
|
||||
.isHorizontal();
|
||||
@State actionBarProp: ActionBarProp = new ActionBarProp();
|
||||
@ -38,7 +38,7 @@ export struct ThirdSelectPhotoBrowserActionBar {
|
||||
@Link @Watch('onSelectedCountChanged') totalSelectedCount: number;
|
||||
@Provide moreMenuList: Action[] = new Array<Action>();
|
||||
@Provide hidePopup: boolean = false;
|
||||
private title: string | Resource;
|
||||
private title: string | Resource = '';
|
||||
private isThird: boolean = false;
|
||||
|
||||
aboutToAppear() {
|
||||
|
@ -32,11 +32,11 @@ const TAG: string = 'common_ActionBar';
|
||||
@Component
|
||||
export struct ActionBar {
|
||||
@Link actionBarProp: ActionBarProp;
|
||||
onMenuClicked: Function;
|
||||
onMenuClicked: Function = (): void => {};
|
||||
isVideoPage: boolean = false;
|
||||
isFromPhotoBrowser: boolean = false;
|
||||
@StorageLink('isHorizontal') isHorizontal: boolean = ScreenManager.getInstance().isHorizontal();
|
||||
@Prop isNeedPlaceholder: boolean;
|
||||
@Prop isNeedPlaceholder: boolean = false;
|
||||
|
||||
createArray(): ActionBarProp[] {
|
||||
let actionBarProps = new Array<ActionBarProp>();
|
||||
@ -57,7 +57,7 @@ export struct ActionBar {
|
||||
.height(Constants.NUMBER_32)
|
||||
}
|
||||
if (!this.actionBarProp.getLeftAction().equals(Action.NONE)) {
|
||||
ForEach(this.createArray(), (item) => {
|
||||
ForEach(this.createArray(), (item: ActionBarProp) => {
|
||||
ActionBarButton({
|
||||
res: item.getLeftAction().iconRes,
|
||||
action: item.getLeftAction(),
|
||||
|
@ -21,20 +21,20 @@ import { Constants } from '../../model/common/Constants';
|
||||
@Component
|
||||
export struct ActionBarButton {
|
||||
@StorageLink('isHorizontal') isHorizontal: boolean = ScreenManager.getInstance().isHorizontal();
|
||||
@State res: Resource = undefined;
|
||||
action: Action;
|
||||
onMenuClicked: Function;
|
||||
@State res: Resource | undefined = undefined;
|
||||
action: Action = Action.NONE;
|
||||
onMenuClicked: Function = (): void => {};
|
||||
isLeft = true;
|
||||
isFirst = false;
|
||||
isAutoTint = true;
|
||||
colorMode: ActionBarColorMode;
|
||||
colorMode: ActionBarColorMode = ActionBarColorMode.NORMAL;
|
||||
@State showPopup: boolean = false;
|
||||
@Consume moreMenuList: Action[];
|
||||
@Consume @Watch("isNeedHidePopup") hidePopup: boolean;
|
||||
private isPadDeviceType: boolean;
|
||||
private isPadDeviceType: boolean = false;
|
||||
|
||||
aboutToAppear(): void {
|
||||
this.isPadDeviceType = AppStorage.Get('deviceType') !== Constants.DEFAULT_DEVICE_TYPE;
|
||||
this.isPadDeviceType = AppStorage.get<string>('deviceType') !== Constants.DEFAULT_DEVICE_TYPE;
|
||||
}
|
||||
|
||||
isNeedHidePopup(): void {
|
||||
@ -62,7 +62,7 @@ export struct ActionBarButton {
|
||||
.color($r('sys.color.ohos_id_color_list_separator'))
|
||||
.key('ActionBarButton_Divider_' + menu.componentKey)
|
||||
}
|
||||
}, menu => menu.actionID.toString())
|
||||
}, (menu: Action) => menu.actionID.toString())
|
||||
}
|
||||
.width(ScreenManager.getInstance().getColumnsWidth(ColumnSize.COLUMN_TWO))
|
||||
.borderRadius($r('sys.float.ohos_id_corner_radius_default_l'))
|
||||
|
@ -25,7 +25,7 @@ const TAG: string = 'common_DetailMenuPanel';
|
||||
export struct DetailMenuPanel {
|
||||
@Consume menuList: Action[];
|
||||
actionBarProp: ActionBarProp = new ActionBarProp();
|
||||
onMenuClicked: Function;
|
||||
onMenuClicked: Function = (): void => {};
|
||||
isLeft = false;
|
||||
|
||||
build() {
|
||||
@ -41,7 +41,7 @@ export struct DetailMenuPanel {
|
||||
colorMode: this.actionBarProp.getColorMode()
|
||||
})
|
||||
.margin({ right: $r('app.float.max_padding_end') })
|
||||
}, menu => menu.actionID.toString())
|
||||
}, (menu: Action) => menu.actionID.toString())
|
||||
}
|
||||
.key('DetailMenuPanel')
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ const TAG: string = 'common_MenuPanel';
|
||||
export struct MenuPanel {
|
||||
@Link @Watch('onActionBarPropChanged') actionBarProp: ActionBarProp;
|
||||
@State menuList: Action[] = [];
|
||||
onMenuClicked: Function;
|
||||
onMenuClicked: Function = (): void => {};
|
||||
|
||||
aboutToAppear(): void {
|
||||
Log.info(TAG, 'aboutToAppear.');
|
||||
@ -44,7 +44,7 @@ export struct MenuPanel {
|
||||
colorMode: this.actionBarProp.getColorMode()
|
||||
})
|
||||
.margin({ right: $r('app.float.max_padding_end') })
|
||||
}, menu => String(menu.actionID))
|
||||
}, (menu: Action) => String(menu.actionID))
|
||||
}
|
||||
.alignItems(VerticalAlign.Center)
|
||||
}
|
||||
|
@ -21,8 +21,8 @@ import { Action } from '../browserOperation/Action';
|
||||
import { ActionBarMode } from '../browserOperation/ActionBarMode';
|
||||
|
||||
export class MenuItem {
|
||||
value: string;
|
||||
action: () => void;
|
||||
value?: string;
|
||||
action?: () => void;
|
||||
}
|
||||
|
||||
@Component
|
||||
@ -35,7 +35,7 @@ export struct ToolBar {
|
||||
@Consume moreMenuList: Action[];
|
||||
@StorageLink('isHorizontal') isHorizontal: boolean = ScreenManager.getInstance().isHorizontal();
|
||||
@State showPopup: boolean = false;
|
||||
onMenuClicked: Function;
|
||||
onMenuClicked: Function = (): void => {};
|
||||
@State actionBarProp: ActionBarProp = new ActionBarProp();
|
||||
@Consume @Watch("isNeedHidePopup") hidePopup: boolean;
|
||||
private isFromPhotoBrowser = false;
|
||||
@ -69,7 +69,7 @@ export struct ToolBar {
|
||||
.strokeWidth(Constants.MENU_DIVIDER_STROKE_WIDTH)
|
||||
.color($r('sys.color.ohos_id_color_list_separator'))
|
||||
}
|
||||
}, menu => menu.actionID.toString())
|
||||
}, (menu: Action) => menu.actionID.toString())
|
||||
}
|
||||
.width(ScreenManager.getInstance().getColumnsWidth(ColumnSize.COLUMN_TWO))
|
||||
.borderRadius($r('sys.float.ohos_id_corner_radius_card'))
|
||||
@ -157,7 +157,7 @@ export struct ToolBar {
|
||||
.width(`${100 / this.toolMenuList.length}%`)
|
||||
.height(Constants.PERCENT_100)
|
||||
}
|
||||
}, menu => menu.actionID.toString())
|
||||
}, (menu: Action) => menu.actionID.toString())
|
||||
}
|
||||
.width(Constants.PERCENT_100)
|
||||
.height(Constants.ActionBarHeight)
|
||||
|
@ -18,11 +18,11 @@ import { ActionBarColorMode } from '../browserOperation/ActionBarMode';
|
||||
|
||||
@Component
|
||||
export struct ToolBarButton {
|
||||
@State res: Resource = undefined;
|
||||
action: Action;
|
||||
@State res: Resource | undefined = undefined;
|
||||
action: Action = Action.NONE;
|
||||
isLeft = true;
|
||||
isAutoTint = true;
|
||||
colorMode: ActionBarColorMode;
|
||||
colorMode: ActionBarColorMode = ActionBarColorMode.NORMAL;
|
||||
|
||||
build() {
|
||||
Flex({
|
||||
|
@ -25,8 +25,8 @@ export struct AlbumListCard {
|
||||
@State isEmptyAlbum: boolean = false;
|
||||
@State useAlt: boolean = false;
|
||||
@Consume broadCast: BroadCast;
|
||||
item: AlbumInfo;
|
||||
index: number;
|
||||
item: AlbumInfo | null = null;
|
||||
index: number = 0;
|
||||
readonly imageCenterLength: number = 28;
|
||||
private dividerMarginRight = 12;
|
||||
|
||||
@ -35,21 +35,25 @@ export struct AlbumListCard {
|
||||
}
|
||||
|
||||
mediaOperation() {
|
||||
this.broadCast.emit(BroadCastConstants.MEDIA_OPERATION, [this.item.albumName, this.item.uri]);
|
||||
}
|
||||
if (this.broadCast != null && this.item != null) {
|
||||
this.broadCast.emit(BroadCastConstants.MEDIA_OPERATION, [this.item.albumName, this.item.uri]);
|
||||
} }
|
||||
|
||||
showMediaRes(): Resource {
|
||||
if (this.item.videoCount == 0) {
|
||||
return $r('app.plural.show_photo_num', this.item.count, this.item.count);
|
||||
} else if (this.item.videoCount == this.item.count) {
|
||||
return $r('app.plural.show_video_num', this.item.count, this.item.count);
|
||||
} else if (this.item.videoCount == 1) {
|
||||
return $r('app.plural.show_one_video_with_photo_num', this.item.count - this.item.videoCount,
|
||||
this.item.count - this.item.videoCount, this.item.videoCount);
|
||||
} else {
|
||||
return $r('app.plural.show_multi_video_with_photo_num', this.item.count - this.item.videoCount,
|
||||
this.item.count - this.item.videoCount, this.item.videoCount)
|
||||
showMediaRes(): Resource | undefined {
|
||||
if (this.item != null) {
|
||||
if (this.item.videoCount == 0) {
|
||||
return $r('app.plural.show_photo_num', this.item.count, this.item.count);
|
||||
} else if (this.item.videoCount == this.item.count) {
|
||||
return $r('app.plural.show_video_num', this.item.count, this.item.count);
|
||||
} else if (this.item.videoCount == 1) {
|
||||
return $r('app.plural.show_one_video_with_photo_num', this.item.count - this.item.videoCount,
|
||||
this.item.count - this.item.videoCount, this.item.videoCount);
|
||||
} else {
|
||||
return $r('app.plural.show_multi_video_with_photo_num', this.item.count - this.item.videoCount,
|
||||
this.item.count - this.item.videoCount, this.item.videoCount)
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
build() {
|
||||
@ -80,7 +84,7 @@ export struct AlbumListCard {
|
||||
.border({ radius: $r('sys.float.ohos_id_corner_radius_default_m') })
|
||||
.flexShrink(0)
|
||||
} else {
|
||||
Image(this.item.coverUri)
|
||||
Image(this.item == null ? '' : this.item.coverUri)
|
||||
.aspectRatio(1)
|
||||
.autoResize(false)
|
||||
.objectFit(ImageFit.Cover)
|
||||
@ -101,7 +105,7 @@ export struct AlbumListCard {
|
||||
}
|
||||
|
||||
Column() {
|
||||
Text(this.item.albumName)
|
||||
Text(this.item == null ? '' : this.item.albumName)
|
||||
.fontSize($r('sys.float.ohos_id_text_size_body1'))
|
||||
.fontColor($r('sys.color.ohos_id_color_primary'))
|
||||
.maxLines(1)
|
||||
@ -109,7 +113,7 @@ export struct AlbumListCard {
|
||||
.padding({
|
||||
bottom: $r('sys.float.ohos_id_text_margin_vertical')
|
||||
})
|
||||
if (this.item.count != 0) {
|
||||
if (this.item != null && this.item.count != 0) {
|
||||
Text(this.showMediaRes())
|
||||
.fontSize($r('sys.float.ohos_id_text_size_body2'))
|
||||
.fontColor($r('sys.color.ohos_id_color_text_secondary'))
|
||||
|
@ -17,7 +17,7 @@ import { Log } from '../../utils/Log';
|
||||
import { BroadCastConstants } from '../../model/common/BroadCastConstants';
|
||||
import { MenuOperationCallback } from './MenuOperationCallback';
|
||||
import { MenuOperation } from './MenuOperation';
|
||||
import { MenuContext } from './MenuContext';
|
||||
import { MenuContext, SourceSceneType } from './MenuContext';
|
||||
import { JumpSourceToMain } from '../../model/browser/photo/JumpSourceToMain';
|
||||
import { AlbumInfo } from '../../model/browser/album/AlbumInfo';
|
||||
import router from '@ohos.router';
|
||||
@ -26,13 +26,14 @@ import { AlbumDefine } from '../../model/browser/AlbumDefine';
|
||||
import { BrowserDataFactory } from '../../interface/BrowserDataFactory';
|
||||
import { BigDataConstants, ReportToBigDataUtil } from '../../utils/ReportToBigDataUtil';
|
||||
import { Album, UserFileManagerAccess } from '../../access/UserFileManagerAccess';
|
||||
import common from '@ohos.app.ability.common';
|
||||
|
||||
const TAG: string = 'common_AlbumSetNewMenuOperation';
|
||||
|
||||
export class AlbumSetNewMenuOperation implements MenuOperation, MenuOperationCallback {
|
||||
private menuContext: MenuContext;
|
||||
private defaultAlbumName: string;
|
||||
private onOperationEnd: Function;
|
||||
private defaultAlbumName: string = '';
|
||||
private onOperationEnd: Function = (): void => {};
|
||||
|
||||
constructor(menuContext: MenuContext) {
|
||||
this.menuContext = menuContext;
|
||||
@ -43,8 +44,11 @@ export class AlbumSetNewMenuOperation implements MenuOperation, MenuOperationCal
|
||||
Log.error(TAG, 'menuContext is null, return');
|
||||
return;
|
||||
}
|
||||
let msg = {
|
||||
'Type': BigDataConstants.ALBUM_CREATE
|
||||
interface Msg1 {
|
||||
type: string
|
||||
}
|
||||
let msg: Msg1 = {
|
||||
type: BigDataConstants.ALBUM_CREATE
|
||||
};
|
||||
ReportToBigDataUtil.report(BigDataConstants.ALBUM_OPERATION_ID, msg);
|
||||
|
||||
@ -52,8 +56,10 @@ export class AlbumSetNewMenuOperation implements MenuOperation, MenuOperationCal
|
||||
Log.info(TAG, `The display name from resource ${JSON.stringify(a)}`);
|
||||
this.defaultAlbumName = '';
|
||||
try {
|
||||
let context = globalThis.photosAbilityContext;
|
||||
if (context == null || context === 'undefined') {
|
||||
let contextName: string = this.menuContext.sourceScene === SourceSceneType.BIG_PHOTO_COMPONENT ?
|
||||
'photoLibraryContext' : 'photosAbilityContext';
|
||||
let context: common.UIAbilityContext = AppStorage.get<common.UIAbilityContext>(contextName) as common.UIAbilityContext;
|
||||
if (context == null || context === undefined) {
|
||||
Log.info(TAG, 'context is null!');
|
||||
} else {
|
||||
this.defaultAlbumName = await context.resourceManager.getString(a.id);
|
||||
@ -62,16 +68,18 @@ export class AlbumSetNewMenuOperation implements MenuOperation, MenuOperationCal
|
||||
= this.getNewAlbumDefaultName(this.defaultAlbumName);
|
||||
Log.info(TAG, `The display name of new album is ${newAlbumDisplayName}`);
|
||||
|
||||
this.confirmCallback = this.confirmCallback.bind(this);
|
||||
this.cancelCallback = this.cancelCallback.bind(this);
|
||||
|
||||
this.menuContext.broadCast.emit(BroadCastConstants.SHOW_NEW_ALBUM_PHOTO_DIALOG,
|
||||
[newAlbumDisplayName, this.confirmCallback, this.cancelCallback]);
|
||||
[newAlbumDisplayName, async (displayName: string): Promise<boolean> => await this.confirmCallbackBindImpl(displayName),
|
||||
(): void => this.cancelCallbackBindImpl()]);
|
||||
}
|
||||
} catch (error) {
|
||||
let msg = {
|
||||
'Type': BigDataConstants.ALBUM_CREATE_ERROR,
|
||||
'errMsg': JSON.stringify(error)
|
||||
interface Msg2 {
|
||||
type: string
|
||||
errMsg: string
|
||||
}
|
||||
let msg: Msg2 = {
|
||||
type: BigDataConstants.ALBUM_CREATE_ERROR,
|
||||
errMsg: JSON.stringify(error)
|
||||
};
|
||||
ReportToBigDataUtil.errEventReport(BigDataConstants.ALBUM_OPERATION_ERROR_ID, msg);
|
||||
Log.info(TAG, `The display name error ${error}`);
|
||||
@ -89,6 +97,10 @@ export class AlbumSetNewMenuOperation implements MenuOperation, MenuOperationCal
|
||||
}
|
||||
|
||||
private async confirmCallback(displayName: string): Promise<boolean> {
|
||||
return await this.confirmCallbackBindImpl(displayName);
|
||||
}
|
||||
|
||||
private async confirmCallbackBindImpl(displayName: string): Promise<boolean> {
|
||||
Log.info(TAG, `AlbumSet new album confirm and the new name is: ${displayName}`);
|
||||
if (displayName) {
|
||||
// 过滤用户相册
|
||||
@ -109,7 +121,7 @@ export class AlbumSetNewMenuOperation implements MenuOperation, MenuOperationCal
|
||||
if (this.menuContext.jumpSourceToMain == JumpSourceToMain.ALBUM) {
|
||||
Log.info(TAG, 'go back to photo grid');
|
||||
this.menuContext.broadCast.emit(BroadCastConstants.MEDIA_OPERATION,
|
||||
[displayName, album.albumUri, this.onCompleted.bind(this)]);
|
||||
[displayName, album.albumUri, (): void => this.onCompleted()]);
|
||||
} else {
|
||||
router.pushUrl({
|
||||
url: 'pages/AlbumSelect',
|
||||
@ -125,15 +137,25 @@ export class AlbumSetNewMenuOperation implements MenuOperation, MenuOperationCal
|
||||
}
|
||||
|
||||
private cancelCallback(): void {
|
||||
this.cancelCallbackBindImpl();
|
||||
}
|
||||
|
||||
private cancelCallbackBindImpl(): void {
|
||||
Log.info(TAG, 'AlbumSet new album cancel');
|
||||
}
|
||||
|
||||
private checkAndAddNumber(albumInfo: AlbumInfo, prefixName: string, numbers: number[]): void {
|
||||
let res = albumInfo.albumName.match(new RegExp('^' + prefixName + '[1-9][0-9]*$'));
|
||||
if (!albumInfo || !albumInfo.albumName) {
|
||||
Log.warn(TAG, 'album is empty');
|
||||
return;
|
||||
}
|
||||
let res: string[] = albumInfo.albumName.match(new RegExp('^' + prefixName + '[1-9][0-9]*$')) as string[];
|
||||
Log.info(TAG, `check name res ${res}`)
|
||||
if (res) {
|
||||
let number = res[0].match(new RegExp(`[1-9][0-9]*`));
|
||||
numbers.push(parseInt(number[0]));
|
||||
let number: string[] = res[0].match(new RegExp('[1-9][0-9]*')) as string[];
|
||||
if (number != null && number[0] != null) {
|
||||
numbers.push(Number.parseInt(number[0]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -159,7 +181,7 @@ export class AlbumSetNewMenuOperation implements MenuOperation, MenuOperationCal
|
||||
}
|
||||
}
|
||||
|
||||
numbers.sort(function (a, b) {
|
||||
numbers.sort((a: number, b: number) => {
|
||||
return a - b;
|
||||
});
|
||||
|
||||
|
@ -28,7 +28,7 @@ const TAG: string = 'common_MediaOperationActionBar';
|
||||
export struct MediaOperationActionBar {
|
||||
@Consume pageType: string;
|
||||
@Consume @Watch('createActionBar') loadingFinish: boolean;
|
||||
onMenuClicked: Function;
|
||||
onMenuClicked: Function = (): void => {};
|
||||
@StorageLink('isHorizontal') @Watch('createActionBar') isHorizontal: boolean
|
||||
= ScreenManager.getInstance().isHorizontal();
|
||||
@State actionBarProp: ActionBarProp = new ActionBarProp();
|
||||
|
@ -38,6 +38,15 @@ import { UiUtil } from '../../utils/UiUtil';
|
||||
|
||||
const TAG: string = 'common_MediaOperationBasePage';
|
||||
|
||||
interface Params {
|
||||
pageType: string;
|
||||
pageFrom: string;
|
||||
albumInfo: AlbumInfo;
|
||||
mediaType: number;
|
||||
selectedItems: Array<MediaItem>;
|
||||
mediaUri?: string;
|
||||
};
|
||||
|
||||
@Component
|
||||
export struct MediaOperationBasePage {
|
||||
@StorageLink('leftBlank') leftBlank: number[]
|
||||
@ -49,15 +58,36 @@ export struct MediaOperationBasePage {
|
||||
@State listCardWidth: number = 0;
|
||||
@State listCardPaddingBottom: number = 24;
|
||||
scroller: Scroller = new Scroller();
|
||||
albums: AlbumSetDataSource;
|
||||
albums: AlbumSetDataSource | null = null;
|
||||
isActive: boolean = false; // Whether the page is in the foreground
|
||||
sourceAlbumUri: string;
|
||||
currentAlbum: AlbumInfo;
|
||||
private pageFrom: string;
|
||||
sourceAlbumUri: string = '';
|
||||
currentAlbum: AlbumInfo | null = null;
|
||||
private pageFrom: string = '';
|
||||
private selectedItems: Array<MediaItem> = [];
|
||||
private mediaType: number;
|
||||
private mediaType: number = 0;
|
||||
private listCardBorderRadius: number = 16;
|
||||
onWindowSizeChangeCallBack = () => this.updateListCardWidth();
|
||||
private onWindowSizeChangeCallBack: Function = () => this.updateListCardWidth();
|
||||
private funcOnMenuClicked: Function = (action: Action): void => this.onMenuClicked(action);
|
||||
private onLoadingFinishedFunc: Function = (): void => this.onLoadingFinished();
|
||||
private mediaOperationFunc: Function = (displayName: string, albumUri: string, completedFunc?: Function): void =>
|
||||
this.mediaOperation(displayName, albumUri, completedFunc);
|
||||
|
||||
private onLoadingFinished(): void {
|
||||
this.loadingFinish = true;
|
||||
}
|
||||
|
||||
private mediaOperation(displayName: string, albumUri: string, completedFunc?: Function): void {
|
||||
Log.info(TAG, `broadCast on mediaOperation, albumName: ${displayName}, albumUri: ${albumUri}`);
|
||||
router.back({
|
||||
url: '',
|
||||
params: {
|
||||
pageType: this.pageType,
|
||||
albumName: displayName,
|
||||
albumUri: albumUri
|
||||
}
|
||||
});
|
||||
completedFunc && completedFunc();
|
||||
}
|
||||
|
||||
aboutToAppear(): void {
|
||||
Log.info(TAG, `aboutToAppear`);
|
||||
@ -66,7 +96,7 @@ export struct MediaOperationBasePage {
|
||||
});
|
||||
this.albums = new AlbumSetDataSource(this.broadCast, { moreInfo: true });
|
||||
this.albums.setMultiParameter(true);
|
||||
let param: any = router.getParams();
|
||||
let param: Params = router.getParams() as Params;
|
||||
if (param) {
|
||||
Log.info(TAG, `router getParams ${JSON.stringify(param)}`);
|
||||
this.pageType = param.pageType;
|
||||
@ -75,42 +105,22 @@ export struct MediaOperationBasePage {
|
||||
if (this.currentAlbum != null) {
|
||||
this.sourceAlbumUri = this.currentAlbum.uri;
|
||||
}
|
||||
switch (this.pageFrom) {
|
||||
case Constants.MEDIA_OPERATION_FROM_PHOTO_BROWSER:
|
||||
this.mediaType = param.mediaType;
|
||||
break;
|
||||
case Constants.MEDIA_OPERATION_FROM_TIMELINE:
|
||||
this.selectedItems = param.selectedItems;
|
||||
break;
|
||||
case Constants.MEDIA_OPERATION_FROM_PHOTO_GRID:
|
||||
this.selectedItems = param.selectedItems;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
if (this.pageFrom === Constants.MEDIA_OPERATION_FROM_PHOTO_BROWSER) {
|
||||
this.mediaType = param.mediaType;
|
||||
} else if (this.pageFrom === Constants.MEDIA_OPERATION_FROM_TIMELINE) {
|
||||
this.selectedItems = param.selectedItems;
|
||||
}else if (this.pageFrom === Constants.MEDIA_OPERATION_FROM_PHOTO_GRID) {
|
||||
this.selectedItems = param.selectedItems;
|
||||
}
|
||||
}
|
||||
this.albums.setFilterAlbumsFunction(this.filterAlbumInList.bind(this));
|
||||
this.albums.setFilterAlbumsFunction((mediaSetList: AlbumInfo[]): Array<AlbumInfo> => this.filterAlbumInList(mediaSetList));
|
||||
this.onActive();
|
||||
this.onMenuClicked = this.onMenuClicked.bind(this);
|
||||
|
||||
this.broadCast.on(Constants.ON_LOADING_FINISHED, (totalCount) => {
|
||||
this.loadingFinish = true;
|
||||
});
|
||||
this.broadCast.on(Constants.ON_LOADING_FINISHED, this.onLoadingFinishedFunc);
|
||||
|
||||
ScreenManager.getInstance().on(ScreenManager.ON_WIN_SIZE_CHANGED, this.onWindowSizeChangeCallBack);
|
||||
|
||||
this.broadCast.on(BroadCastConstants.MEDIA_OPERATION, (displayName: string, albumUri: string, completedFunc?: Function) => {
|
||||
Log.info(TAG, `broadCast on mediaOperation, albumName: ${displayName}, albumUri: ${albumUri}`);
|
||||
router.back({
|
||||
url: '',
|
||||
params: {
|
||||
pageType: this.pageType,
|
||||
albumName: displayName,
|
||||
albumUri: albumUri
|
||||
}
|
||||
});
|
||||
completedFunc && completedFunc();
|
||||
});
|
||||
this.broadCast.on(BroadCastConstants.MEDIA_OPERATION, this.mediaOperationFunc);
|
||||
this.albums.updateAlbumMediaCount();
|
||||
this.updateListCardWidth();
|
||||
Log.info(TAG, `album mediaSet ${this.albums.mediaSetList}`);
|
||||
@ -118,37 +128,31 @@ export struct MediaOperationBasePage {
|
||||
|
||||
aboutToDisappear(): void {
|
||||
Log.info(TAG, 'aboutToDisappear');
|
||||
this.broadCast.off(null, null);
|
||||
if(this.broadCast) {
|
||||
this.broadCast.off(Constants.ON_LOADING_FINISHED, this.onLoadingFinishedFunc);
|
||||
this.broadCast.off(BroadCastConstants.MEDIA_OPERATION, this.mediaOperationFunc);
|
||||
}
|
||||
ScreenManager.getInstance().off(ScreenManager.ON_WIN_SIZE_CHANGED, this.onWindowSizeChangeCallBack);
|
||||
this.onWindowSizeChangeCallBack = null;
|
||||
}
|
||||
|
||||
onMenuClicked(action: Action) {
|
||||
Log.info(TAG, `onMenuClicked, actionID: ${action.actionID}`);
|
||||
|
||||
switch (action.actionID) {
|
||||
case Action.CANCEL.actionID:
|
||||
router.back({
|
||||
url: '',
|
||||
params: {}
|
||||
});
|
||||
break;
|
||||
case Action.NEW.actionID:
|
||||
this.createNewAlbum();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
if (action.actionID === Action.CANCEL.actionID) {
|
||||
router.back({
|
||||
url: '',
|
||||
params: {}
|
||||
});
|
||||
} else if (action.actionID === Action.NEW.actionID) {
|
||||
this.createNewAlbum();
|
||||
}
|
||||
}
|
||||
|
||||
createNewAlbum() {
|
||||
Log.info(TAG, 'createNewAlbum');
|
||||
let menuContext = new MenuContext();
|
||||
this.onOperationStart = this.onOperationStart.bind(this);
|
||||
this.onOperationEnd = this.onOperationEnd.bind(this);
|
||||
menuContext
|
||||
.withOperationStartCallback(this.onOperationStart)
|
||||
.withOperationEndCallback(this.onOperationEnd)
|
||||
.withOperationStartCallback((): void => this.onOperationStart())
|
||||
.withOperationEndCallback((): void => this.onOperationEnd())
|
||||
.withAlbumSetDataSource(this.albums)
|
||||
.withAlbumInfo(this.currentAlbum)
|
||||
.withBroadCast(this.broadCast)
|
||||
@ -212,28 +216,29 @@ export struct MediaOperationBasePage {
|
||||
return res;
|
||||
}
|
||||
|
||||
getBorderRadius(index: number): BorderRadiuses {
|
||||
if (index === 0 && index + 1 === this.albums.totalCount()) {
|
||||
getBorderRadius(index: number): BorderRadiuses | undefined {
|
||||
if (this.albums != null && index === 0 && index + 1 === this.albums.totalCount()) {
|
||||
return {
|
||||
topLeft: this.listCardBorderRadius,
|
||||
topRight: this.listCardBorderRadius,
|
||||
bottomLeft: this.listCardBorderRadius,
|
||||
bottomRight: this.listCardBorderRadius
|
||||
};
|
||||
} else if (index + 1 === this.albums.totalCount()) {
|
||||
} else if (this.albums != null && index + 1 === this.albums.totalCount()) {
|
||||
return { bottomLeft: this.listCardBorderRadius, bottomRight: this.listCardBorderRadius };
|
||||
} else if (index === 0) {
|
||||
return { topLeft: this.listCardBorderRadius, topRight: this.listCardBorderRadius };
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
MediaOperationActionBar({ onMenuClicked: this.onMenuClicked })
|
||||
MediaOperationActionBar({ onMenuClicked: this.funcOnMenuClicked })
|
||||
|
||||
Stack() {
|
||||
List({ scroller: this.scroller }) {
|
||||
LazyForEach(this.albums, (albumSetDataInfo: AlbumSetDataInfo, index?: number) => {
|
||||
LazyForEach(this.albums as AlbumSetDataSource, (albumSetDataInfo: AlbumSetDataInfo, index?: number) => {
|
||||
ListItem() {
|
||||
AlbumListCard({
|
||||
item: albumSetDataInfo.data,
|
||||
@ -246,8 +251,10 @@ export struct MediaOperationBasePage {
|
||||
.padding({
|
||||
left: $r('app.float.list_card_margin')
|
||||
})
|
||||
.borderRadius(this.getBorderRadius(index))
|
||||
}, (item) => item.data.id)
|
||||
.borderRadius(this.getBorderRadius(index as number) as BorderRadiuses)
|
||||
}, (item: AlbumSetDataInfo): string => {
|
||||
return item.data.uri;
|
||||
});
|
||||
}
|
||||
.alignListItem(ListItemAlign.Center)
|
||||
.padding({
|
||||
@ -255,10 +262,10 @@ export struct MediaOperationBasePage {
|
||||
bottom: this.leftBlank[3] + this.listCardPaddingBottom
|
||||
})
|
||||
.scrollBar(BarState.Auto)
|
||||
.height(Constants.PERCENT_100)
|
||||
.width(Constants.PERCENT_100)
|
||||
.height(Constants.PERCENT_100 as string)
|
||||
.width(Constants.PERCENT_100 as string)
|
||||
}
|
||||
.height(Constants.PERCENT_100)
|
||||
.height(Constants.PERCENT_100 as string)
|
||||
|
||||
CustomDialogView({ broadCast: $broadCast })
|
||||
}
|
||||
|
@ -19,6 +19,14 @@ import { BroadCast } from '../../utils/BroadCast';
|
||||
import { AlbumSetDataSource } from '../../model/browser/album/AlbumSetDataSource';
|
||||
import { AlbumInfo } from '../../model/browser/album/AlbumInfo';
|
||||
|
||||
export enum SourceSceneType {
|
||||
INVALID,
|
||||
SYSTEM_ALBUM,
|
||||
USER_ALBUM,
|
||||
PICKER,
|
||||
BIG_PHOTO_COMPONENT
|
||||
}
|
||||
|
||||
export class MenuContext {
|
||||
mediaItem: MediaItem;
|
||||
albumUri: string;
|
||||
@ -34,6 +42,7 @@ export class MenuContext {
|
||||
albumInfo: AlbumInfo;
|
||||
fromSelectMode: boolean;
|
||||
targetAlbumName: string;
|
||||
sourceScene: SourceSceneType = SourceSceneType.INVALID;
|
||||
|
||||
withMediaItem(mediaItem: MediaItem): MenuContext {
|
||||
this.mediaItem = mediaItem;
|
||||
@ -80,7 +89,7 @@ export class MenuContext {
|
||||
return this;
|
||||
}
|
||||
|
||||
withAlbumSetDataSource(albumSetDataSource: AlbumSetDataSource): MenuContext {
|
||||
withAlbumSetDataSource(albumSetDataSource: AlbumSetDataSource | null): MenuContext {
|
||||
this.albumSetDataSource = albumSetDataSource;
|
||||
return this;
|
||||
}
|
||||
@ -90,7 +99,7 @@ export class MenuContext {
|
||||
return this;
|
||||
}
|
||||
|
||||
withAlbumInfo(albumInfo) {
|
||||
withAlbumInfo(albumInfo: AlbumInfo | null | undefined): MenuContext {
|
||||
this.albumInfo = albumInfo;
|
||||
return this;
|
||||
}
|
||||
|
@ -112,7 +112,7 @@ export class MoveMenuOperation extends ProcessMenuOperation {
|
||||
Log.debug(TAG, 'move file.mediaType:' + JSON.stringify(sourceAsset.fileType));
|
||||
try {
|
||||
TraceControllerUtils.startTraceWithTaskId('move', this.currentBatch);
|
||||
let sourceAlbumUri: string = AppStorage.Get(Constants.APP_KEY_NEW_ALBUM_SOURCE);
|
||||
let sourceAlbumUri: string = AppStorage.get(Constants.APP_KEY_NEW_ALBUM_SOURCE);
|
||||
let sourceAlbum: Album = await UserFileManagerAccess.getInstance().getAlbumByUri(sourceAlbumUri);
|
||||
await sourceAlbum.removePhotoAssets([sourceAsset]); // TODO 媒体库支持批量移除,传参后续整改
|
||||
|
||||
|
@ -29,8 +29,13 @@ import { AlbumDefine } from '../../model/browser/AlbumDefine';
|
||||
|
||||
const TAG: string = 'common_MoveOrCopyBroadCastProp';
|
||||
|
||||
interface ParamAlbumInfo {
|
||||
item: string;
|
||||
isFromFACard?: boolean;
|
||||
}
|
||||
|
||||
export class MoveOrCopyBroadCastProp {
|
||||
private broadCast: BroadCast;
|
||||
private broadCast: BroadCast | null = null;
|
||||
|
||||
private constructor() {
|
||||
}
|
||||
@ -39,10 +44,10 @@ export class MoveOrCopyBroadCastProp {
|
||||
* Get MoveOrCopyBroadCastProp instance
|
||||
*/
|
||||
public static getInstance(): MoveOrCopyBroadCastProp {
|
||||
if (AppStorage.Get(Constants.INSTANCE_MOVE_OR_COPY_BROADCAST_PROP) == null) {
|
||||
if (AppStorage.get<MoveOrCopyBroadCastProp>(Constants.INSTANCE_MOVE_OR_COPY_BROADCAST_PROP) == null) {
|
||||
AppStorage.SetOrCreate(Constants.INSTANCE_MOVE_OR_COPY_BROADCAST_PROP, new MoveOrCopyBroadCastProp());
|
||||
}
|
||||
return AppStorage.Get(Constants.INSTANCE_MOVE_OR_COPY_BROADCAST_PROP);
|
||||
return AppStorage.get<MoveOrCopyBroadCastProp>(Constants.INSTANCE_MOVE_OR_COPY_BROADCAST_PROP) as MoveOrCopyBroadCastProp;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -50,28 +55,32 @@ export class MoveOrCopyBroadCastProp {
|
||||
*
|
||||
* @param broadCast broadCast
|
||||
*/
|
||||
public sendMoveOrAddBroadCast(broadCast: BroadCast) {
|
||||
public sendMoveOrAddBroadCast(broadCast: BroadCast): void {
|
||||
if (broadCast === null || broadCast === undefined) {
|
||||
Log.error(TAG, 'sendMoveOrAddBroadCast error: null or undefined broadcast');
|
||||
return;
|
||||
}
|
||||
this.setBroadCast(broadCast);
|
||||
|
||||
// 如果是系统相册,则直接添加到,而不是弹窗选择添加还是移动
|
||||
let isSystemAlbumSource: boolean = false;
|
||||
let sourceAlbumUri: string = AppStorage.Get(Constants.APP_KEY_NEW_ALBUM_SOURCE);
|
||||
let systemAlbumUris: IterableIterator<string> = UserFileManagerAccess.getInstance().getSystemAlbumUriMap().values();
|
||||
for (let uri of systemAlbumUris) {
|
||||
if (sourceAlbumUri === uri) {
|
||||
isSystemAlbumSource = true;
|
||||
break;
|
||||
}
|
||||
/// 如果是系统相册,或者是新建相册从PickerPage界面添加图片的场景,直接添加到,而不是弹窗选择添加还是移动
|
||||
let sourceAlbumUri = AppStorage.get<string>(Constants.APP_KEY_NEW_ALBUM_SOURCE);
|
||||
let isOnlyAddAlbumSource: boolean = sourceAlbumUri === Constants.APP_NEW_ALBUM_SOURCE_PICKER;
|
||||
if (!isOnlyAddAlbumSource) {
|
||||
UserFileManagerAccess.getInstance().getSystemAlbumUriMap().forEach(
|
||||
(value: string) => {
|
||||
if (sourceAlbumUri === value) {
|
||||
isOnlyAddAlbumSource = true;
|
||||
return;
|
||||
}
|
||||
});
|
||||
}
|
||||
if (isSystemAlbumSource) {
|
||||
if (isOnlyAddAlbumSource) {
|
||||
this.addOperation();
|
||||
} else {
|
||||
this.broadCast.emit(BroadCastConstants.SHOW_COPY_OR_MOVE_DIALOG,
|
||||
[this.moveOperation.bind(this), this.addOperation.bind(this)]);
|
||||
if (this.broadCast != null) {
|
||||
this.broadCast.emit(BroadCastConstants.SHOW_COPY_OR_MOVE_DIALOG,
|
||||
[async (): Promise<void> => await this.moveOperation(), async (): Promise<void> => await this.addOperation()]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -94,21 +103,19 @@ export class MoveOrCopyBroadCastProp {
|
||||
}
|
||||
|
||||
private async addOperation() {
|
||||
let selectManager: SelectManager = AppStorage.Get(Constants.APP_KEY_NEW_ALBUM_SELECTED);
|
||||
let targetAlbumName: string = AppStorage.Get(Constants.APP_KEY_NEW_ALBUM_TARGET);
|
||||
let targetAlbumUri: string = AppStorage.Get(Constants.APP_KEY_NEW_ALBUM_TARGET_URI);
|
||||
let selectManager: SelectManager = AppStorage.get<SelectManager>(Constants.APP_KEY_NEW_ALBUM_SELECTED) as SelectManager;;
|
||||
let targetAlbumName: string = AppStorage.get<string>(Constants.APP_KEY_NEW_ALBUM_TARGET) as string;;
|
||||
let targetAlbumUri: string = AppStorage.get<string>(Constants.APP_KEY_NEW_ALBUM_TARGET_URI)as string;
|
||||
if (this.broadCast === null || this.broadCast === undefined) {
|
||||
Log.error(TAG, 'addOperation error: null or undefined broadcast');
|
||||
return;
|
||||
}
|
||||
|
||||
let menuContext = new MenuContext();
|
||||
this.onOperationStart = this.onOperationStart.bind(this);
|
||||
this.onOperationEnd = this.onOperationEnd.bind(this);
|
||||
menuContext
|
||||
.withSelectManager(selectManager)
|
||||
.withOperationStartCallback(this.onOperationStart)
|
||||
.withOperationEndCallback(this.onOperationEnd)
|
||||
.withOperationStartCallback((): void => this.onOperationStartBindImpl())
|
||||
.withOperationEndCallback(async (): Promise<void> => await this.onOperationEndBindImpl())
|
||||
.withBroadCast(this.broadCast)
|
||||
menuContext.withTargetAlbumName(targetAlbumName).withAlbumUri(targetAlbumUri);
|
||||
let menuOperation = MenuOperationFactory.getInstance().createMenuOperation(AddMenuOperation, menuContext);
|
||||
@ -116,21 +123,19 @@ export class MoveOrCopyBroadCastProp {
|
||||
}
|
||||
|
||||
private async moveOperation() {
|
||||
let selectManager: SelectManager = AppStorage.Get(Constants.APP_KEY_NEW_ALBUM_SELECTED);
|
||||
let targetAlbumName: string = AppStorage.Get(Constants.APP_KEY_NEW_ALBUM_TARGET);
|
||||
let targetAlbumUri: string = AppStorage.Get(Constants.APP_KEY_NEW_ALBUM_TARGET_URI);
|
||||
let selectManager: SelectManager = AppStorage.get<SelectManager>(Constants.APP_KEY_NEW_ALBUM_SELECTED) as SelectManager;
|
||||
let targetAlbumName: string = AppStorage.get<string>(Constants.APP_KEY_NEW_ALBUM_TARGET) as string;
|
||||
let targetAlbumUri: string = AppStorage.get<string>(Constants.APP_KEY_NEW_ALBUM_TARGET_URI) as string;
|
||||
if (this.broadCast === null || this.broadCast === undefined) {
|
||||
Log.error(TAG, 'moveOperation error: null or undefined broadcast');
|
||||
return;
|
||||
}
|
||||
|
||||
let menuContext = new MenuContext();
|
||||
this.onOperationStart = this.onOperationStart.bind(this);
|
||||
this.onOperationEnd = this.onOperationEnd.bind(this);
|
||||
menuContext
|
||||
.withSelectManager(selectManager)
|
||||
.withOperationStartCallback(this.onOperationStart)
|
||||
.withOperationEndCallback(this.onOperationEnd)
|
||||
.withOperationStartCallback((): void => this.onOperationStartBindImpl())
|
||||
.withOperationEndCallback(async (): Promise<void> => await this.onOperationEndBindImpl())
|
||||
.withBroadCast(this.broadCast)
|
||||
menuContext.withTargetAlbumName(targetAlbumName).withAlbumUri(targetAlbumUri);
|
||||
let menuOperation = MenuOperationFactory.getInstance().createMenuOperation(MoveMenuOperation, menuContext);
|
||||
@ -138,14 +143,14 @@ export class MoveOrCopyBroadCastProp {
|
||||
}
|
||||
|
||||
private onOperationStart(): void {
|
||||
AppStorage.SetOrCreate(Constants.IS_DATA_FREEZE, true);
|
||||
this.onOperationStartBindImpl();
|
||||
}
|
||||
|
||||
private async onOperationEnd(): Promise<void> {
|
||||
private async onOperationEndBindImpl(): Promise<void> {
|
||||
AppStorage.SetOrCreate(Constants.IS_DATA_FREEZE, false);
|
||||
let isNewAlbum: boolean = AppStorage.Get(Constants.APP_KEY_NEW_ALBUM);
|
||||
let selectManager: SelectManager = AppStorage.Get(Constants.APP_KEY_NEW_ALBUM_SELECTED);
|
||||
let targetAlbumName: string = AppStorage.Get(Constants.APP_KEY_NEW_ALBUM_TARGET);
|
||||
let isNewAlbum: boolean = AppStorage.get<boolean>(Constants.APP_KEY_NEW_ALBUM) as boolean;
|
||||
let selectManager: SelectManager = AppStorage.get<SelectManager>(Constants.APP_KEY_NEW_ALBUM_SELECTED) as SelectManager;
|
||||
let targetAlbumName: string = AppStorage.get<string>(Constants.APP_KEY_NEW_ALBUM_TARGET) as string;
|
||||
|
||||
let album = await UserFileManagerAccess.getInstance().getAlbumByName(targetAlbumName);
|
||||
let albumInfo: AlbumInfo = new AlbumInfo(album);
|
||||
@ -169,11 +174,21 @@ export class MoveOrCopyBroadCastProp {
|
||||
}
|
||||
});
|
||||
} else {
|
||||
AppStorage.SetOrCreate(Constants.KEY_OF_PHOTO_GRID_VIEW_ALBUM_ITEM, { item: JSON.stringify(albumInfo) });
|
||||
AppStorage.setOrCreate<ParamAlbumInfo>(Constants.KEY_OF_PHOTO_GRID_VIEW_ALBUM_ITEM, {
|
||||
item: JSON.stringify(albumInfo)
|
||||
});
|
||||
AppStorage.SetOrCreate(Constants.KEY_OF_ALBUM_URI, albumInfo.uri);
|
||||
router.back({
|
||||
url: 'pages/index',
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private onOperationStartBindImpl(): void {
|
||||
AppStorage.SetOrCreate(Constants.IS_DATA_FREEZE, true);
|
||||
}
|
||||
|
||||
private async onOperationEnd(): Promise<void> {
|
||||
await this.onOperationEndBindImpl();
|
||||
}
|
||||
}
|
@ -23,6 +23,7 @@ import { MediaItem } from '../../model/browser/photo/MediaItem';
|
||||
import { UserFileManagerAccess } from '../../access/UserFileManagerAccess';
|
||||
import { UiUtil } from '../../utils/UiUtil';
|
||||
import { BigDataConstants, ReportToBigDataUtil } from '../../utils/ReportToBigDataUtil';
|
||||
import common from '@ohos.app.ability.common';
|
||||
|
||||
const TAG: string = 'common_ShareMenuOperation';
|
||||
|
||||
@ -114,13 +115,14 @@ export class ShareMenuOperation implements MenuOperation, AsyncCallback<MediaIte
|
||||
}
|
||||
let want = this.getParameters();
|
||||
this.reportToBigData(want.parameters['ability.picker.type'], imageCount, videoCount);
|
||||
globalThis.photosAbilityContext?.startAbility(want);
|
||||
let context: common.UIAbilityContext = AppStorage.get<common.UIAbilityContext>('photosAbilityContext');
|
||||
context.startAbility(want);
|
||||
}
|
||||
|
||||
private reportToBigData(shareType: string, imageCount: number, videoCount: number): void {
|
||||
let count: number = 1;
|
||||
if (AppStorage.Get('click_share_count') != null) {
|
||||
let oldCount: number = AppStorage.Get('click_share_count');
|
||||
if (AppStorage.get('click_share_count') != null) {
|
||||
let oldCount: number = AppStorage.get('click_share_count');
|
||||
count = oldCount + 1;
|
||||
}
|
||||
AppStorage.SetOrCreate('click_share_count', count);
|
||||
|
@ -28,7 +28,7 @@ export struct AddNotesDialog {
|
||||
@StorageLink('isSidebar') isSidebar: boolean = ScreenManager.getInstance().isSidebar();
|
||||
@StorageLink('leftBlank') leftBlank: number[]
|
||||
= [0, ScreenManager.getInstance().getStatusBarHeight(), 0, ScreenManager.getInstance().getNaviBarHeight()];
|
||||
controller: CustomDialogController;
|
||||
controller?: CustomDialogController;
|
||||
@Consume dialogCallback: DialogCallback;
|
||||
@State isNull: boolean = false;
|
||||
private inputNote: string = '';
|
||||
@ -49,7 +49,7 @@ export struct AddNotesDialog {
|
||||
.width($r('app.float.icon_size'))
|
||||
.onClick(() => {
|
||||
this.dialogCallback && this.dialogCallback.cancelCallback();
|
||||
this.controller.close()
|
||||
this.controller?.close();
|
||||
})
|
||||
}.margin({ right: $r('app.float.dialog_icon_margin_horizontal') })
|
||||
|
||||
@ -80,11 +80,11 @@ export struct AddNotesDialog {
|
||||
let passCheck = StringUtil.checkNameInvalid(this.inputNote);
|
||||
if (passCheck) {
|
||||
UiUtil.showToast($r('app.string.specific_characters_not_supported'));
|
||||
this.controller.close()
|
||||
this.controller?.close();
|
||||
return
|
||||
}
|
||||
this.dialogCallback && this.dialogCallback.confirmCallback(this.inputNote);
|
||||
this.controller.close()
|
||||
this.controller?.close();
|
||||
})
|
||||
}
|
||||
}.margin({ top: $r('sys.float.ohos_id_text_paragraph_margin_s'),
|
||||
|
@ -22,8 +22,8 @@ const TAG: string = 'common_CancelOperationDialog';
|
||||
|
||||
@Observed
|
||||
export class CancelParam {
|
||||
continueFunc: Function
|
||||
cancelFunc: Function
|
||||
continueFunc: Function = (): void => {};
|
||||
cancelFunc: Function = (): void => {};
|
||||
}
|
||||
|
||||
@CustomDialog
|
||||
@ -32,12 +32,12 @@ export struct CancelOperationDialog {
|
||||
@StorageLink('isSidebar') isSidebar: boolean = ScreenManager.getInstance().isSidebar();
|
||||
@StorageLink('leftBlank') leftBlank: number[]
|
||||
= [0, ScreenManager.getInstance().getStatusBarHeight(), 0, ScreenManager.getInstance().getNaviBarHeight()];
|
||||
controller: CustomDialogController;
|
||||
controller?: CustomDialogController;
|
||||
@Consume cancelMessage: Resource;
|
||||
@Consume broadCast: BroadCast;
|
||||
@Consume deleteProgress: number;
|
||||
@Consume cancelParam: CancelParam;
|
||||
private isPcDevice: boolean = AppStorage.Get('deviceType') === Constants.PC_DEVICE_TYPE;
|
||||
private isPcDevice: boolean = AppStorage.get<string>('deviceType') === Constants.PC_DEVICE_TYPE;
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
@ -66,7 +66,7 @@ export struct CancelOperationDialog {
|
||||
.onClick(() => {
|
||||
Log.info(TAG, 'click continue')
|
||||
this.cancelParam.continueFunc();
|
||||
this.controller.close()
|
||||
this.controller?.close();
|
||||
})
|
||||
.margin({
|
||||
right: $r('app.float.dialog_double_buttons_margin_right')
|
||||
@ -88,7 +88,7 @@ export struct CancelOperationDialog {
|
||||
.onClick(() => {
|
||||
Log.info(TAG, 'click cancel')
|
||||
this.cancelParam.cancelFunc();
|
||||
this.controller.close()
|
||||
this.controller?.close();
|
||||
})
|
||||
.margin({
|
||||
left: $r('app.float.dialog_double_buttons_margin_left')
|
||||
|
@ -21,8 +21,8 @@ const TAG: string = 'common_CopyOrMoveDialog';
|
||||
|
||||
@Observed
|
||||
export class OperateParam {
|
||||
moveFunc: Function
|
||||
copyFunc: Function
|
||||
moveFunc: Function = (): void => {};
|
||||
copyFunc: Function = (): void => {};
|
||||
}
|
||||
|
||||
@CustomDialog
|
||||
@ -33,10 +33,10 @@ export struct CopyOrMoveDialog {
|
||||
@StorageLink('isSidebar') isSidebar: boolean = ScreenManager.getInstance().isSidebar();
|
||||
@StorageLink('leftBlank') leftBlank: number[]
|
||||
= [0, ScreenManager.getInstance().getStatusBarHeight(), 0, ScreenManager.getInstance().getNaviBarHeight()];
|
||||
controller: CustomDialogController;
|
||||
dataTime: string;
|
||||
controller?: CustomDialogController;
|
||||
dataTime: string = '';
|
||||
@Consume operateParam: OperateParam;
|
||||
private isPcDevice: boolean = AppStorage.Get('deviceType') === Constants.PC_DEVICE_TYPE;
|
||||
private isPcDevice: boolean = AppStorage.get<string>('deviceType') === Constants.PC_DEVICE_TYPE;
|
||||
|
||||
aboutToAppear() {
|
||||
|
||||
@ -65,7 +65,7 @@ export struct CopyOrMoveDialog {
|
||||
.width('100%')
|
||||
.key('Copy')
|
||||
.onClick(() => {
|
||||
this.controller.close()
|
||||
this.controller?.close();
|
||||
this.operateParam.copyFunc();
|
||||
})
|
||||
|
||||
@ -87,7 +87,7 @@ export struct CopyOrMoveDialog {
|
||||
.height($r('app.float.dialog_list_card_height'))
|
||||
.width('100%')
|
||||
.onClick(() => {
|
||||
this.controller.close()
|
||||
this.controller?.close();
|
||||
this.operateParam.moveFunc();
|
||||
})
|
||||
|
||||
@ -105,7 +105,7 @@ export struct CopyOrMoveDialog {
|
||||
.height($r('app.float.details_dialog_button_height'))
|
||||
.key('Cancel')
|
||||
.onClick(() => {
|
||||
this.controller.close()
|
||||
this.controller?.close();
|
||||
})
|
||||
.margin({
|
||||
left: $r('app.float.dialog_single_button_indent_margin'),
|
||||
|
@ -37,6 +37,7 @@ import { NewAlbumDialog } from './NewAlbumDialog';
|
||||
import { CopyOrMoveDialog, OperateParam } from './CopyOrMoveDialog';
|
||||
import { ScreenManager } from '../../model/common/ScreenManager';
|
||||
import { SaveImageDialog } from './SaveImageDialog';
|
||||
import { tryFunc } from '../../utils/ErrUtil';
|
||||
|
||||
const TAG: string = 'common_CustomDialogView';
|
||||
|
||||
@ -47,15 +48,15 @@ export struct CustomDialogView {
|
||||
@Provide progressMessage: Resource = $r('app.string.common_place_holder', String(''));
|
||||
@Provide deleteProgress: number = 0;
|
||||
@Provide removeProgress: number = 0;
|
||||
@Provide dialogCallback: DialogCallback = { confirmCallback: null, cancelCallback: null };
|
||||
@Provide saveDialogCallback: SaveDialogCallback = { saveAsNewCallback: null, replaceOriginalCallback: null };
|
||||
@Provide editExitDialogCallback: EditExitDialogCallback = { discardCallback: null };
|
||||
@Provide dialogCallback: DialogCallback = { confirmCallback: (): void => {}, cancelCallback: () => {} };
|
||||
@Provide saveDialogCallback: SaveDialogCallback = { saveAsNewCallback: (): void => {}, replaceOriginalCallback: () => {} };
|
||||
@Provide editExitDialogCallback: EditExitDialogCallback = { discardCallback: (): void => {} };
|
||||
@Link broadCast: BroadCast;
|
||||
@Provide progressParam: ProgressParam = { cancelFunc: null, operationType: '' };
|
||||
@Provide deleteProgressParam: DeleteProgressParam = { currentCount: 0, totalCount: 0, message: null };
|
||||
@Provide removeProgressParam: RemoveProgressParam = { currentCount: 0, totalCount: 0, message: null };
|
||||
@Provide cancelParam: CancelParam = { continueFunc: null, cancelFunc: null };
|
||||
@Provide operateParam: OperateParam = { moveFunc: null, copyFunc: null };
|
||||
@Provide progressParam: ProgressParam = { cancelFunc: (): void => {}, operationType: '' };
|
||||
@Provide deleteProgressParam: DeleteProgressParam = { currentCount: 0, totalCount: 0, message: undefined };
|
||||
@Provide removeProgressParam: RemoveProgressParam = { currentCount: 0, totalCount: 0, message: undefined };
|
||||
@Provide cancelParam: CancelParam = { continueFunc: (): void => {}, cancelFunc: () => {} };
|
||||
@Provide operateParam: OperateParam = { moveFunc: (): void => {}, copyFunc: () => {} };
|
||||
@Provide cancelMessage: Resource = $r('app.string.common_place_holder', String(''));
|
||||
@Provide renameFileName: string = '';
|
||||
@Provide isDistributedAlbum: boolean = false;
|
||||
@ -87,28 +88,90 @@ export struct CustomDialogView {
|
||||
count: 500,
|
||||
size: 256,
|
||||
};
|
||||
@StorageLink('isHorizontal') @Watch('buildDialogs') isHorizontal: boolean = ScreenManager.getInstance()
|
||||
@StorageLink('isHorizontal') @Watch('refreshDialogs') isHorizontal: boolean = ScreenManager.getInstance()
|
||||
.isHorizontal();
|
||||
@StorageLink('isSidebar') @Watch('buildDialogs') isSidebar: boolean = ScreenManager.getInstance().isSidebar();
|
||||
dialogController: CustomDialogController;
|
||||
multiSelectDialog: CustomDialogController;
|
||||
deleteDialogController: CustomDialogController;
|
||||
thirdDeleteDialogController: CustomDialogController;
|
||||
removeDialogController: CustomDialogController;
|
||||
deleteProgressDialogController: CustomDialogController;
|
||||
removeProgressDialogController: CustomDialogController;
|
||||
progressDialogController: CustomDialogController;
|
||||
cancelDialogController: CustomDialogController;
|
||||
renameFileDialogController: CustomDialogController;
|
||||
saveDialogController: CustomDialogController;
|
||||
editExitDialogController: CustomDialogController;
|
||||
addNotesDialogController: CustomDialogController;
|
||||
newAlbumDialogController: CustomDialogController;
|
||||
copyOrMoveDialogController: CustomDialogController;
|
||||
downloadCancelOperationDialog: CustomDialogController;
|
||||
saveImageDialogController: CustomDialogController;
|
||||
@StorageLink('isSidebar') @Watch('refreshDialogs') isSidebar: boolean = ScreenManager.getInstance().isSidebar();
|
||||
dialogController?: CustomDialogController | null;
|
||||
multiSelectDialog?: CustomDialogController | null;
|
||||
deleteDialogController?: CustomDialogController | null;
|
||||
thirdDeleteDialogController?: CustomDialogController | null;
|
||||
removeDialogController?: CustomDialogController | null;
|
||||
deleteProgressDialogController?: CustomDialogController | null;
|
||||
removeProgressDialogController?: CustomDialogController | null;
|
||||
progressDialogController?: CustomDialogController | null;
|
||||
cancelDialogController?: CustomDialogController | null;
|
||||
renameFileDialogController?: CustomDialogController | null;
|
||||
saveDialogController?: CustomDialogController | null;
|
||||
editExitDialogController?: CustomDialogController | null;
|
||||
addNotesDialogController?: CustomDialogController | null;
|
||||
newAlbumDialogController?: CustomDialogController | null;
|
||||
copyOrMoveDialogController?: CustomDialogController | null;
|
||||
downloadCancelOperationDialog?: CustomDialogController | null;
|
||||
saveImageDialogController?: CustomDialogController | null;
|
||||
|
||||
buildDialogs(): void {
|
||||
private showDetailDialogFunc: Function =
|
||||
(item: MediaItem, isDistributed: boolean): void => this.showDetailDialog(item,isDistributed);
|
||||
|
||||
private showMultiSelectDialogFunc: Function =
|
||||
(count: number, size: number): void => this.showMultiSelectDialog(count, size);
|
||||
|
||||
private showDeleteDialogFunc: Function =
|
||||
(deleteMessage: Resource, confirmCallback: Function, cancelCallback: Function, isAlbumDelete: boolean): void =>
|
||||
this.showDeleteDialog(deleteMessage, confirmCallback, cancelCallback);
|
||||
|
||||
private showThirdDeleteDialogFunc: Function =
|
||||
(deleteMessage: Resource, confirmCallback: Function, cancelCallback?: Function): void =>
|
||||
this.showThirdDeleteDialog(deleteMessage, confirmCallback, cancelCallback);
|
||||
|
||||
private showRemoveDialogFunc: Function =
|
||||
(removeMessage: Resource, confirmCallback: Function, cancelCallback?: Function): void =>
|
||||
this.showRemoveDialog(removeMessage, confirmCallback, cancelCallback);
|
||||
|
||||
private showRenamePhotoDialogFunc:Function = (fileName: string, confirmCallback: Function, cancelCallback?: Function): void =>
|
||||
this.showRenamePhotoDialog(fileName, confirmCallback, cancelCallback);
|
||||
|
||||
private showAddNotePhotoDialogFunc: Function = (confirmCallback: Function, cancelCallback?: Function): void =>
|
||||
this.showAddNotePhotoDialog(confirmCallback, cancelCallback);
|
||||
|
||||
private showProgressDialogFunc: Function = (message: Resource, operationType: string, cancelFunc?: Function): void =>
|
||||
this.showProgressDialog(message, operationType,cancelFunc);
|
||||
|
||||
private updateProgressFunc: Function = (progress: number, currentCount: number): void =>
|
||||
this.updateProgress(progress, currentCount);
|
||||
|
||||
private cancelOperateFunc: Function = (cancelMessage: Resource, continueFunc: Function, cancelFunc: Function): void =>
|
||||
this.cancelOperate(cancelMessage, continueFunc, cancelFunc);
|
||||
|
||||
private downloadCancelOperateFunc: Function =
|
||||
(cancelMessage: Resource, continueFunc: Function, cancelFunc: Function): void =>
|
||||
this.downloadCancelOperate(cancelMessage, continueFunc, cancelFunc);
|
||||
|
||||
private showSavePhotoDialogFunc: Function =
|
||||
(saveAsNewCallback: Function, replaceOriginalCallback: Function): void =>
|
||||
this.showSavePhotoDialog(saveAsNewCallback, replaceOriginalCallback);
|
||||
|
||||
private showEditExitPhotoDialogFunc: Function = (discardCallback: Function): void =>
|
||||
this.showEditExitPhotoDialog(discardCallback);
|
||||
|
||||
private showEditSaveProgressDialogFunc: Function = (): void => this.showEditSaveProgressDialog();
|
||||
|
||||
private showNewAlbumDialogFunc: Function =
|
||||
(fileName: string, confirmCallback: Function, cancelCallback?: Function): void => this.showNewAlbumDialog(fileName, confirmCallback, cancelCallback);
|
||||
|
||||
private showCopyOrMoveDialogFunc: Function = (moveFunc: Function, copyFunc: Function): void =>
|
||||
this.showCopyOrMoveDialog(moveFunc, copyFunc);
|
||||
|
||||
private deleteProgressDialogFunc: Function = (message: Resource, totalCount: number): void =>
|
||||
this.deleteProgressDialog(message, totalCount)
|
||||
|
||||
private removeProgressDialogFunc: Function = (message: Resource, totalCount: number): void =>
|
||||
this.removeProgressDialog(message, totalCount);
|
||||
|
||||
refreshDialogs(): void {
|
||||
this.buildDialogs(true);
|
||||
}
|
||||
|
||||
buildDialogs(refreshFlag: boolean): void {
|
||||
this.dialogController = new CustomDialogController({
|
||||
builder: DetailsDialog(),
|
||||
autoCancel: false,
|
||||
@ -283,224 +346,226 @@ export struct CustomDialogView {
|
||||
|
||||
aboutToDisappear(): void {
|
||||
Log.info(TAG, 'aboutToDisappear');
|
||||
this.broadCast.off(null, null);
|
||||
delete this.dialogController;
|
||||
this.dialogController = undefined;
|
||||
delete this.multiSelectDialog;
|
||||
this.multiSelectDialog = undefined;
|
||||
delete this.deleteDialogController;
|
||||
this.deleteDialogController = undefined;
|
||||
delete this.thirdDeleteDialogController;
|
||||
this.thirdDeleteDialogController = undefined;
|
||||
delete this.removeDialogController;
|
||||
this.removeDialogController = undefined;
|
||||
delete this.deleteProgressDialogController;
|
||||
this.deleteProgressDialogController = undefined;
|
||||
delete this.removeProgressDialogController;
|
||||
this.removeProgressDialogController = undefined;
|
||||
delete this.progressDialogController;
|
||||
this.progressDialogController = undefined;
|
||||
delete this.cancelDialogController;
|
||||
this.cancelDialogController = undefined;
|
||||
delete this.renameFileDialogController;
|
||||
this.renameFileDialogController = undefined;
|
||||
delete this.saveDialogController;
|
||||
this.saveDialogController = undefined;
|
||||
delete this.editExitDialogController;
|
||||
this.editExitDialogController = undefined;
|
||||
delete this.addNotesDialogController;
|
||||
this.addNotesDialogController = undefined;
|
||||
delete this.newAlbumDialogController;
|
||||
this.newAlbumDialogController = undefined;
|
||||
delete this.copyOrMoveDialogController;
|
||||
this.copyOrMoveDialogController = undefined;
|
||||
delete this.downloadCancelOperationDialog;
|
||||
this.downloadCancelOperationDialog = undefined;
|
||||
delete this.saveImageDialogController;
|
||||
this.saveImageDialogController = undefined;
|
||||
this.buildDialogs(false);
|
||||
this.dialogController = null;
|
||||
this.multiSelectDialog = null;
|
||||
this.deleteDialogController = null;
|
||||
this.thirdDeleteDialogController = null;
|
||||
this.removeDialogController = null;
|
||||
this.deleteProgressDialogController = null;
|
||||
this.removeProgressDialogController = null;
|
||||
this.progressDialogController = null;
|
||||
this.cancelDialogController = null;
|
||||
this.renameFileDialogController = null;
|
||||
this.saveDialogController = null;
|
||||
this.editExitDialogController = null;
|
||||
this.addNotesDialogController = null;
|
||||
this.newAlbumDialogController = null;
|
||||
this.copyOrMoveDialogController = null;
|
||||
this.downloadCancelOperationDialog = null;
|
||||
this.saveImageDialogController = null;
|
||||
|
||||
this.broadCast.off(BroadCastConstants.SHOW_DETAIL_DIALOG, this.showDetailDialogFunc);
|
||||
this.broadCast.off(BroadCastConstants.SHOW_MULTI_SELECT_DIALOG, this.showMultiSelectDialogFunc);
|
||||
this.broadCast.off(BroadCastConstants.SHOW_DELETE_DIALOG, this.showDeleteDialogFunc);
|
||||
this.broadCast.off(BroadCastConstants.SHOW_THIRD_DELETE_DIALOG, this.showThirdDeleteDialogFunc);
|
||||
this.broadCast.off(BroadCastConstants.SHOW_REMOVE_DIALOG, this.showRemoveDialogFunc);
|
||||
this.broadCast.off(BroadCastConstants.SHOW_RENAME_PHOTO_DIALOG, this.showRenamePhotoDialogFunc);
|
||||
this.broadCast.off(BroadCastConstants.SHOW_ADD_NOTES_PHOTO_DIALOG, this.showAddNotePhotoDialogFunc);
|
||||
this.broadCast.off(BroadCastConstants.SHOW_PROGRESS_DIALOG, this.showProgressDialogFunc);
|
||||
this.broadCast.off(BroadCastConstants.UPDATE_PROGRESS, this.updateProgressFunc);
|
||||
this.broadCast.off(BroadCastConstants.CANCEL_OPERATE, this.cancelOperateFunc);
|
||||
this.broadCast.off(BroadCastConstants.DOWNLOAD_CANCEL_OPERATE, this.downloadCancelOperateFunc);
|
||||
this.broadCast.off(BroadCastConstants.SHOW_SAVE_PHOTO_DIALOG, this.showSavePhotoDialogFunc);
|
||||
this.broadCast.off(BroadCastConstants.SHOW_NEW_ALBUM_PHOTO_DIALOG, this.showNewAlbumDialogFunc);
|
||||
this.broadCast.off(BroadCastConstants.SHOW_COPY_OR_MOVE_DIALOG, this.showCopyOrMoveDialogFunc);
|
||||
this.broadCast.off(BroadCastConstants.DELETE_PROGRESS_DIALOG, this.deleteProgressDialogFunc);
|
||||
this.broadCast.off(BroadCastConstants.REMOVE_PROGRESS_DIALOG, this.removeProgressDialogFunc);
|
||||
}
|
||||
|
||||
private showDetailDialog(item: MediaItem, isDistributed: boolean): void {
|
||||
Log.info(TAG, item.uri, ' SHOW_DETAIL_DIALOG ');
|
||||
let title: string = item.getTitle ? tryFunc(((): string => item.getTitle())) : undefined;
|
||||
let dateTaken: number = item.getDataTaken ? tryFunc(((): number => item.getDataTaken())) : undefined;
|
||||
let dateModified: number = item.getDateModified ? tryFunc(((): number => item.getDateModified())) : undefined;
|
||||
this.mediaDetails = {
|
||||
mediaType: item.mediaType,
|
||||
height: item.height,
|
||||
width: item.width,
|
||||
size: item.size,
|
||||
duration: item.duration,
|
||||
title,
|
||||
dateTaken,
|
||||
uri: item.uri,
|
||||
displayName: item.displayName,
|
||||
dateModified
|
||||
};
|
||||
this.isDistributedAlbum = isDistributed;
|
||||
(this.dialogController as CustomDialogController).open();
|
||||
}
|
||||
|
||||
private showMultiSelectDialog(count: number, size: number): void {
|
||||
Log.info(TAG, 'SHOW_MULTI_SELECT_DIALOG ');
|
||||
this.multiSelectDetails = {
|
||||
size: size,
|
||||
count: count
|
||||
};
|
||||
(this.multiSelectDialog as CustomDialogController).open();
|
||||
}
|
||||
|
||||
private showDeleteDialog(deleteMessage: Resource, confirmCallback: Function, cancelCallback: Function): void {
|
||||
Log.info(TAG, 'SHOW_DELETE_DIALOG ');
|
||||
this.dialogMessage = deleteMessage;
|
||||
this.dialogCallback = { confirmCallback: confirmCallback, cancelCallback: cancelCallback as Function };
|
||||
(this.deleteDialogController as CustomDialogController).open();
|
||||
}
|
||||
|
||||
private showThirdDeleteDialog(deleteMessage: Resource, confirmCallback: Function, cancelCallback?: Function): void {
|
||||
Log.info(TAG, 'SHOW_THIRD_DELETE_DIALOG ');
|
||||
this.dialogMessage = deleteMessage;
|
||||
this.dialogCallback = { confirmCallback: confirmCallback, cancelCallback: cancelCallback as Function };
|
||||
(this.thirdDeleteDialogController as CustomDialogController).open();
|
||||
}
|
||||
|
||||
private showRemoveDialog(removeMessage: Resource, confirmCallback: Function, cancelCallback?: Function): void {
|
||||
Log.info(TAG, 'SHOW_REMOVE_DIALOG ');
|
||||
this.dialogMessage = removeMessage;
|
||||
this.dialogCallback = { confirmCallback: confirmCallback, cancelCallback: cancelCallback as Function };
|
||||
(this.removeDialogController as CustomDialogController).open();
|
||||
}
|
||||
|
||||
private showRenamePhotoDialog(fileName: string, confirmCallback: Function, cancelCallback?: Function): void {
|
||||
Log.info(TAG, 'SHOW_RENAME_PHOTO_DIALOG ');
|
||||
this.renameFileName = fileName;
|
||||
this.dialogCallback = { confirmCallback: confirmCallback, cancelCallback: cancelCallback as Function };
|
||||
(this.renameFileDialogController as CustomDialogController).open();
|
||||
}
|
||||
|
||||
private showAddNotePhotoDialog(confirmCallback: Function, cancelCallback?: Function): void {
|
||||
Log.info(TAG, 'SHOW_ADD_NOTES_PHOTO_DIALOG ');
|
||||
this.dialogCallback = { confirmCallback: confirmCallback, cancelCallback: cancelCallback as Function };
|
||||
(this.addNotesDialogController as CustomDialogController).open();
|
||||
}
|
||||
|
||||
private showProgressDialog(message: Resource, operationType: string, cancelFunc?: Function): void {
|
||||
Log.info(TAG, 'SHOW_PROGRESS_DIALOG');
|
||||
if (message != null) {
|
||||
this.progressMessage = message;
|
||||
}
|
||||
if (operationType) {
|
||||
this.progressParam.operationType = operationType;
|
||||
}
|
||||
|
||||
if (cancelFunc) {
|
||||
this.progressParam.cancelFunc = cancelFunc;
|
||||
}
|
||||
this.deleteProgress = 0;
|
||||
this.removeProgress = 0;
|
||||
(this.progressDialogController as CustomDialogController).open();
|
||||
}
|
||||
|
||||
private updateProgress(progress: number, currentCount: number): void {
|
||||
Log.info(TAG, `UPDATE_PROGRESS ${progress}`);
|
||||
this.deleteProgress = progress;
|
||||
this.removeProgress = progress;
|
||||
this.deleteProgressParam.currentCount = currentCount;
|
||||
this.removeProgressParam.currentCount = currentCount;
|
||||
if (progress == 100) {
|
||||
Log.info(TAG, 'Update progress 100%');
|
||||
(this.progressDialogController as CustomDialogController).close();
|
||||
(this.deleteProgressDialogController as CustomDialogController).close();
|
||||
this.deleteProgressParam.currentCount = 0;
|
||||
(this.removeProgressDialogController as CustomDialogController).close();
|
||||
this.removeProgressParam.currentCount = 0;
|
||||
}
|
||||
}
|
||||
|
||||
private cancelOperate(cancelMessage: Resource, continueFunc: Function, cancelFunc: Function): void {
|
||||
this.cancelMessage = cancelMessage;
|
||||
this.cancelParam.continueFunc = continueFunc;
|
||||
this.cancelParam.cancelFunc = cancelFunc;
|
||||
Log.info(TAG, 'CANCEL_OPERATE');
|
||||
(this.cancelDialogController as CustomDialogController).open();
|
||||
}
|
||||
|
||||
private downloadCancelOperate(cancelMessage: Resource, continueFunc: Function, cancelFunc: Function): void {
|
||||
this.cancelMessage = cancelMessage;
|
||||
this.cancelParam.continueFunc = continueFunc;
|
||||
this.cancelParam.cancelFunc = cancelFunc;
|
||||
Log.info(TAG, 'DOWNLOAD_CANCEL_OPERATE');
|
||||
(this.downloadCancelOperationDialog as CustomDialogController).open();
|
||||
}
|
||||
|
||||
private showSavePhotoDialog(saveAsNewCallback: Function, replaceOriginalCallback: Function): void {
|
||||
Log.info(TAG, 'SHOW_SAVE_PHOTO_DIALOG');
|
||||
this.saveDialogCallback = {
|
||||
saveAsNewCallback: saveAsNewCallback,
|
||||
replaceOriginalCallback: replaceOriginalCallback };
|
||||
(this.saveDialogController as CustomDialogController).open();
|
||||
}
|
||||
|
||||
private showEditExitPhotoDialog(discardCallback: Function): void {
|
||||
Log.info(TAG, 'SHOW_EDIT_EXIT_PHOTO_DIALOG');
|
||||
this.editExitDialogCallback = { discardCallback: discardCallback };
|
||||
(this.editExitDialogController as CustomDialogController).open();
|
||||
}
|
||||
|
||||
private showEditSaveProgressDialog(): void {
|
||||
Log.info(TAG, 'SHOW_EDIT_SAVE_PROGRESS_DIALOG');
|
||||
(this.saveImageDialogController as CustomDialogController).open();
|
||||
}
|
||||
|
||||
private showNewAlbumDialog(fileName: string, confirmCallback: Function, cancelCallback?: Function): void {
|
||||
Log.info(TAG, 'SHOW_NEW_ALBUM_PHOTO_DIALOG');
|
||||
this.renameFileName = fileName;
|
||||
this.dialogCallback = { confirmCallback: confirmCallback, cancelCallback: cancelCallback as Function };
|
||||
(this.newAlbumDialogController as CustomDialogController).open();
|
||||
}
|
||||
|
||||
private showCopyOrMoveDialog(moveFunc: Function, copyFunc: Function): void {
|
||||
Log.info(TAG, 'SHOW_COPY_OR_MOVE_DIALOG');
|
||||
this.operateParam.moveFunc = moveFunc;
|
||||
this.operateParam.copyFunc = copyFunc;
|
||||
(this.copyOrMoveDialogController as CustomDialogController).open();
|
||||
}
|
||||
|
||||
private deleteProgressDialog(message: Resource, totalCount: number): void {
|
||||
Log.info(TAG, 'DELETE_PROGRESS_DIALOG');
|
||||
this.deleteProgressParam.currentCount = 0;
|
||||
this.deleteProgressParam.totalCount = totalCount;
|
||||
this.deleteProgressParam.message = message;
|
||||
(this.deleteProgressDialogController as CustomDialogController).open();
|
||||
}
|
||||
|
||||
private removeProgressDialog(message: Resource, totalCount: number): void {
|
||||
Log.info(TAG, 'REMOVE_PROGRESS_DIALOG');
|
||||
this.removeProgressParam.currentCount = 0;
|
||||
this.removeProgressParam.totalCount = totalCount;
|
||||
this.removeProgressParam.message = message;
|
||||
(this.removeProgressDialogController as CustomDialogController).open();
|
||||
}
|
||||
|
||||
aboutToAppear(): void {
|
||||
Log.info(TAG, 'aboutToAppear');
|
||||
let self = this;
|
||||
this.buildDialogs();
|
||||
this.broadCast.on(BroadCastConstants.SHOW_DETAIL_DIALOG,
|
||||
function (item: MediaItem, isDistributed: boolean) {
|
||||
Log.info(TAG, 'SHOW_DETAIL_DIALOG ');
|
||||
self.mediaDetails = {
|
||||
mediaType: item.mediaType,
|
||||
height: item.height,
|
||||
width: item.width,
|
||||
size: item.size,
|
||||
duration: item.duration,
|
||||
title: item.getTitle(),
|
||||
dateTaken: item.getDataTaken(),
|
||||
uri: item.uri,
|
||||
displayName: item.displayName,
|
||||
dateModified: item.getDateModified()
|
||||
};
|
||||
self.isDistributedAlbum = isDistributed;
|
||||
self.dialogController.open();
|
||||
});
|
||||
|
||||
this.broadCast.on(BroadCastConstants.SHOW_MULTI_SELECT_DIALOG,
|
||||
function (count: number, size: number) {
|
||||
Log.info(TAG, 'SHOW_MULTI_SELECT_DIALOG ');
|
||||
self.multiSelectDetails = {
|
||||
size: size,
|
||||
count: count
|
||||
};
|
||||
|
||||
self.multiSelectDialog.open();
|
||||
});
|
||||
|
||||
this.broadCast.on(BroadCastConstants.SHOW_DELETE_DIALOG,
|
||||
function (deleteMessage: Resource, confirmCallback: Function, cancelCallback?: Function) {
|
||||
Log.info(TAG, 'SHOW_DELETE_DIALOG ');
|
||||
self.dialogMessage = deleteMessage;
|
||||
self.dialogCallback = { confirmCallback: confirmCallback, cancelCallback: cancelCallback };
|
||||
self.deleteDialogController.open();
|
||||
});
|
||||
|
||||
this.broadCast.on(BroadCastConstants.SHOW_THIRD_DELETE_DIALOG,
|
||||
function (deleteMessage: Resource, confirmCallback: Function, cancelCallback?: Function) {
|
||||
Log.info(TAG, 'SHOW_THIRD_DELETE_DIALOG ');
|
||||
self.dialogMessage = deleteMessage;
|
||||
self.dialogCallback = { confirmCallback: confirmCallback, cancelCallback: cancelCallback };
|
||||
self.thirdDeleteDialogController.open();
|
||||
});
|
||||
|
||||
this.broadCast.on(BroadCastConstants.SHOW_REMOVE_DIALOG,
|
||||
function (removeMessage: Resource, confirmCallback: Function, cancelCallback?: Function) {
|
||||
Log.info(TAG, 'SHOW_REMOVE_DIALOG ');
|
||||
self.dialogMessage = removeMessage;
|
||||
self.dialogCallback = { confirmCallback: confirmCallback, cancelCallback: cancelCallback };
|
||||
self.removeDialogController.open();
|
||||
});
|
||||
|
||||
this.broadCast.on(BroadCastConstants.SHOW_RENAME_PHOTO_DIALOG,
|
||||
function (fileName: string, confirmCallback: Function, cancelCallback?: Function) {
|
||||
Log.info(TAG, 'SHOW_RENAME_PHOTO_DIALOG ');
|
||||
self.renameFileName = fileName;
|
||||
self.dialogCallback = { confirmCallback: confirmCallback, cancelCallback: cancelCallback };
|
||||
self.renameFileDialogController.open();
|
||||
});
|
||||
|
||||
this.broadCast.on(BroadCastConstants.SHOW_ADD_NOTES_PHOTO_DIALOG,
|
||||
function (confirmCallback: Function, cancelCallback?: Function) {
|
||||
Log.info(TAG, 'SHOW_ADD_NOTES_PHOTO_DIALOG ');
|
||||
self.dialogCallback = { confirmCallback: confirmCallback, cancelCallback: cancelCallback };
|
||||
self.addNotesDialogController.open();
|
||||
});
|
||||
|
||||
this.broadCast.on(BroadCastConstants.SHOW_PROGRESS_DIALOG,
|
||||
function (message: Resource, operationType: string, cancelFunc?: Function) {
|
||||
Log.info(TAG, 'SHOW_PROGRESS_DIALOG');
|
||||
if (message != null) {
|
||||
self.progressMessage = message;
|
||||
}
|
||||
|
||||
if (operationType) {
|
||||
self.progressParam.operationType = operationType;
|
||||
}
|
||||
|
||||
if (cancelFunc) {
|
||||
self.progressParam.cancelFunc = cancelFunc;
|
||||
}
|
||||
self.deleteProgress = 0;
|
||||
self.removeProgress = 0;
|
||||
self.progressDialogController.open();
|
||||
});
|
||||
|
||||
this.broadCast.on(BroadCastConstants.UPDATE_PROGRESS,
|
||||
function (progress: number, currentCount: number) {
|
||||
Log.info(TAG, `UPDATE_PROGRESS ${progress}`);
|
||||
self.deleteProgress = progress;
|
||||
self.removeProgress = progress;
|
||||
self.deleteProgressParam.currentCount = currentCount;
|
||||
self.removeProgressParam.currentCount = currentCount;
|
||||
if (progress == 100) {
|
||||
Log.info(TAG, 'Update progress 100%');
|
||||
self.progressDialogController.close();
|
||||
self.deleteProgressDialogController.close();
|
||||
self.deleteProgressParam.currentCount = 0;
|
||||
self.removeProgressDialogController.close();
|
||||
self.removeProgressParam.currentCount = 0;
|
||||
}
|
||||
});
|
||||
|
||||
this.broadCast.on(BroadCastConstants.CANCEL_OPERATE,
|
||||
function (cancelMessage: Resource, continueFunc: Function, cancelFunc: Function) {
|
||||
self.cancelMessage = cancelMessage;
|
||||
self.cancelParam.continueFunc = continueFunc;
|
||||
self.cancelParam.cancelFunc = cancelFunc;
|
||||
Log.info(TAG, 'CANCEL_OPERATE');
|
||||
self.cancelDialogController.open();
|
||||
});
|
||||
|
||||
this.broadCast.on(BroadCastConstants.DOWNLOAD_CANCEL_OPERATE,
|
||||
function (cancelMessage: Resource, continueFunc: Function, cancelFunc: Function) {
|
||||
self.cancelMessage = cancelMessage;
|
||||
self.cancelParam.continueFunc = continueFunc;
|
||||
self.cancelParam.cancelFunc = cancelFunc;
|
||||
Log.info(TAG, 'DOWNLOAD_CANCEL_OPERATE');
|
||||
self.downloadCancelOperationDialog.open();
|
||||
});
|
||||
|
||||
this.broadCast.on(BroadCastConstants.SHOW_SAVE_PHOTO_DIALOG,
|
||||
function (saveAsNewCallback: Function, replaceOriginalCallback: Function) {
|
||||
Log.info(TAG, 'SHOW_SAVE_PHOTO_DIALOG');
|
||||
self.saveDialogCallback
|
||||
= { saveAsNewCallback: saveAsNewCallback, replaceOriginalCallback: replaceOriginalCallback };
|
||||
self.saveDialogController.open();
|
||||
});
|
||||
|
||||
this.broadCast.on(BroadCastConstants.SHOW_EDIT_EXIT_PHOTO_DIALOG,
|
||||
function (discardCallback: Function) {
|
||||
Log.info(TAG, 'SHOW_EDIT_EXIT_PHOTO_DIALOG');
|
||||
self.editExitDialogCallback = { discardCallback: discardCallback };
|
||||
self.editExitDialogController.open();
|
||||
});
|
||||
|
||||
this.broadCast.on(BroadCastConstants.SHOW_EDIT_SAVE_PROGRESS_DIALOG,
|
||||
function () {
|
||||
Log.info(TAG, 'SHOW_EDIT_SAVE_PROGRESS_DIALOG');
|
||||
self.saveImageDialogController.open();
|
||||
});
|
||||
|
||||
this.broadCast.on(BroadCastConstants.SHOW_NEW_ALBUM_PHOTO_DIALOG,
|
||||
function (fileName: string, confirmCallback: Function, cancelCallback?: Function) {
|
||||
Log.info(TAG, 'SHOW_NEW_ALBUM_PHOTO_DIALOG');
|
||||
self.renameFileName = fileName;
|
||||
self.dialogCallback = { confirmCallback: confirmCallback, cancelCallback: cancelCallback };
|
||||
self.newAlbumDialogController.open();
|
||||
});
|
||||
|
||||
this.broadCast.on(BroadCastConstants.SHOW_COPY_OR_MOVE_DIALOG,
|
||||
function (moveFunc: Function, copyFunc: Function) {
|
||||
Log.info(TAG, 'SHOW_COPY_OR_MOVE_DIALOG');
|
||||
self.operateParam.moveFunc = moveFunc;
|
||||
self.operateParam.copyFunc = copyFunc;
|
||||
self.copyOrMoveDialogController.open();
|
||||
});
|
||||
|
||||
this.broadCast.on(BroadCastConstants.DELETE_PROGRESS_DIALOG,
|
||||
function (message: Resource, totalCount: number) {
|
||||
Log.info(TAG, 'DELETE_PROGRESS_DIALOG');
|
||||
self.deleteProgressParam.currentCount = 0;
|
||||
self.deleteProgressParam.totalCount = totalCount;
|
||||
self.deleteProgressParam.message = message;
|
||||
self.deleteProgressDialogController.open();
|
||||
});
|
||||
|
||||
this.broadCast.on(BroadCastConstants.REMOVE_PROGRESS_DIALOG,
|
||||
function (message: Resource, totalCount: number) {
|
||||
Log.info(TAG, 'DELETE_PROGRESS_DIALOG');
|
||||
self.removeProgressParam.currentCount = 0;
|
||||
self.removeProgressParam.totalCount = totalCount;
|
||||
self.removeProgressParam.message = message;
|
||||
self.removeProgressDialogController.open();
|
||||
});
|
||||
this.buildDialogs(false);
|
||||
this.broadCast.on(BroadCastConstants.SHOW_DETAIL_DIALOG, this.showDetailDialogFunc);
|
||||
this.broadCast.on(BroadCastConstants.SHOW_MULTI_SELECT_DIALOG,this.showMultiSelectDialogFunc);
|
||||
this.broadCast.on(BroadCastConstants.SHOW_DELETE_DIALOG, this.showDeleteDialogFunc);
|
||||
this.broadCast.on(BroadCastConstants.SHOW_THIRD_DELETE_DIALOG, this.showThirdDeleteDialogFunc);
|
||||
this.broadCast.on(BroadCastConstants.SHOW_REMOVE_DIALOG, this.showRemoveDialogFunc);
|
||||
this.broadCast.on(BroadCastConstants.SHOW_RENAME_PHOTO_DIALOG, this.showRenamePhotoDialogFunc);
|
||||
this.broadCast.on(BroadCastConstants.SHOW_ADD_NOTES_PHOTO_DIALOG, this.showAddNotePhotoDialogFunc);
|
||||
this.broadCast.on(BroadCastConstants.SHOW_PROGRESS_DIALOG, this.showProgressDialogFunc);
|
||||
this.broadCast.on(BroadCastConstants.UPDATE_PROGRESS, this.updateProgressFunc);
|
||||
this.broadCast.on(BroadCastConstants.CANCEL_OPERATE, this.cancelOperateFunc);
|
||||
this.broadCast.on(BroadCastConstants.DOWNLOAD_CANCEL_OPERATE, this.downloadCancelOperateFunc);
|
||||
this.broadCast.on(BroadCastConstants.SHOW_SAVE_PHOTO_DIALOG, this.showSavePhotoDialogFunc);
|
||||
this.broadCast.on(BroadCastConstants.SHOW_EDIT_EXIT_PHOTO_DIALOG, this.showEditExitPhotoDialogFunc);
|
||||
this.broadCast.on(BroadCastConstants.SHOW_EDIT_SAVE_PROGRESS_DIALOG, this.showEditSaveProgressDialogFunc);
|
||||
this.broadCast.on(BroadCastConstants.SHOW_NEW_ALBUM_PHOTO_DIALOG, this.showNewAlbumDialogFunc);
|
||||
this.broadCast.on(BroadCastConstants.SHOW_COPY_OR_MOVE_DIALOG, this.showCopyOrMoveDialogFunc);
|
||||
this.broadCast.on(BroadCastConstants.DELETE_PROGRESS_DIALOG, this.deleteProgressDialogFunc);
|
||||
this.broadCast.on(BroadCastConstants.REMOVE_PROGRESS_DIALOG, this.removeProgressDialogFunc);
|
||||
}
|
||||
|
||||
build() {
|
||||
|
@ -17,6 +17,7 @@ import { Log } from '../../utils/Log';
|
||||
import { ColumnSize, ScreenManager } from '../../model/common/ScreenManager';
|
||||
import { Constants } from '../../model/common/Constants';
|
||||
import data_preferences from '@ohos.data.preferences';
|
||||
import { BusinessError } from '@ohos.base';
|
||||
|
||||
const TAG: string = 'common_DeleteDialog';
|
||||
|
||||
@ -28,19 +29,19 @@ export struct DeleteDialog {
|
||||
= [0, ScreenManager.getInstance().getStatusBarHeight(), 0, ScreenManager.getInstance().getNaviBarHeight()];
|
||||
@Consume dialogCallback: DialogCallback;
|
||||
@Consume dialogMessage: Resource;
|
||||
controller: CustomDialogController;
|
||||
controller?: CustomDialogController;
|
||||
@StorageLink('isFirstTimeDelete') isFirstTimeDelete: boolean = false;
|
||||
@StorageLink('confirmText') confirmText: Resource = $r('app.string.dialog_delete');
|
||||
private isPcDevice: boolean = AppStorage.Get('deviceType') === Constants.PC_DEVICE_TYPE;
|
||||
private isPcDevice: boolean = AppStorage.get<string>('deviceType') === Constants.PC_DEVICE_TYPE;
|
||||
|
||||
aboutToDisappear() {
|
||||
if (this.isFirstTimeDelete) {
|
||||
AppStorage.SetOrCreate(Constants.IS_FIRST_TIME_DELETE, false);
|
||||
let pref: data_preferences.Preferences = AppStorage.Get(Constants.PHOTOS_STORE_KEY);
|
||||
let pref: data_preferences.Preferences = AppStorage.get<data_preferences.Preferences>(Constants.PHOTOS_STORE_KEY) as data_preferences.Preferences;
|
||||
pref.put(Constants.IS_FIRST_TIME_DELETE, false).then(() => {
|
||||
Log.debug(TAG, `Succeeded in putting the value of '${Constants.IS_FIRST_TIME_DELETE}'.`);
|
||||
pref.flush();
|
||||
}).catch((err) => {
|
||||
}).catch((err: BusinessError) => {
|
||||
Log.error(TAG, `Failed to put the value of '${Constants.IS_FIRST_TIME_DELETE}'. Cause: ${err}`);
|
||||
});
|
||||
}
|
||||
@ -102,7 +103,7 @@ export struct DeleteDialog {
|
||||
.height($r('app.float.details_dialog_button_height'))
|
||||
.onClick(() => {
|
||||
Log.debug(TAG, `cancelCallback`);
|
||||
this.controller.close();
|
||||
this.controller?.close();
|
||||
this.dialogCallback && this.dialogCallback.cancelCallback();
|
||||
})
|
||||
}.width('50%')
|
||||
@ -132,7 +133,7 @@ export struct DeleteDialog {
|
||||
.height($r('app.float.details_dialog_button_height'))
|
||||
.onClick(() => {
|
||||
Log.debug(TAG, `confirmCallback`);
|
||||
this.controller.close();
|
||||
this.controller?.close();
|
||||
this.dialogCallback && this.dialogCallback.confirmCallback();
|
||||
})
|
||||
}.width('50%')
|
||||
|
@ -21,9 +21,9 @@ const TAG: string = 'common_DeleteProgressDialog';
|
||||
|
||||
@Observed
|
||||
export class DeleteProgressParam {
|
||||
currentCount: number
|
||||
totalCount: number
|
||||
message: Resource
|
||||
currentCount: number = 0;
|
||||
totalCount: number = 0;
|
||||
message?: Resource
|
||||
}
|
||||
|
||||
@CustomDialog
|
||||
@ -32,10 +32,10 @@ export struct DeleteProgressDialog {
|
||||
@StorageLink('isSidebar') isSidebar: boolean = ScreenManager.getInstance().isSidebar();
|
||||
@StorageLink('leftBlank') leftBlank: number[]
|
||||
= [0, ScreenManager.getInstance().getStatusBarHeight(), 0, ScreenManager.getInstance().getNaviBarHeight()];
|
||||
controller: CustomDialogController
|
||||
controller?: CustomDialogController
|
||||
@Consume deleteProgress: number;
|
||||
@Consume deleteProgressParam: DeleteProgressParam;
|
||||
private isPcDevice: boolean = AppStorage.Get('deviceType') === Constants.PC_DEVICE_TYPE;
|
||||
private isPcDevice: boolean = AppStorage.get<string>('deviceType') === Constants.PC_DEVICE_TYPE;
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
|
@ -24,16 +24,16 @@ const TAG: string = 'common_DetailsDialog';
|
||||
|
||||
@Observed
|
||||
export class MediaDetails {
|
||||
mediaType: number
|
||||
height: number
|
||||
width: number
|
||||
size: number
|
||||
duration: number
|
||||
title: string
|
||||
dateTaken: number
|
||||
uri: string
|
||||
displayName: string
|
||||
dateModified: number
|
||||
mediaType: number = 0;
|
||||
height: number = 0;
|
||||
width: number = 0;
|
||||
size: number = 0;
|
||||
duration: number = 0;
|
||||
title: string = '';
|
||||
dateTaken: number = 0;
|
||||
uri: string = '';
|
||||
displayName: string = '';
|
||||
dateModified: number = 0;
|
||||
}
|
||||
|
||||
@CustomDialog
|
||||
@ -45,13 +45,13 @@ export struct DetailsDialog {
|
||||
@StorageLink('leftBlank') leftBlank: number[]
|
||||
= [0, ScreenManager.getInstance().getStatusBarHeight(), 0, ScreenManager.getInstance().getNaviBarHeight()];
|
||||
sizeConvert = 1024;
|
||||
controller: CustomDialogController;
|
||||
dataTime: string;
|
||||
controller?: CustomDialogController;
|
||||
dataTime: string = '';
|
||||
@Consume mediaDetails: MediaDetails;
|
||||
@Consume isDistributedAlbum: boolean;
|
||||
@State refresh: boolean = false;
|
||||
private isPcDevice: boolean = AppStorage.Get('deviceType') === Constants.PC_DEVICE_TYPE;
|
||||
onWindowSizeChangeCallBack = () => this.updateDialogSize();
|
||||
private isPcDevice: boolean = AppStorage.get<string>('deviceType') === Constants.PC_DEVICE_TYPE;
|
||||
onWindowSizeChangeCallBack = (): void => this.updateDialogSize();
|
||||
|
||||
aboutToAppear() {
|
||||
let localizedDate = DateUtil.getLocalizedDate(this.mediaDetails.dateTaken);
|
||||
@ -65,7 +65,6 @@ export struct DetailsDialog {
|
||||
aboutToDisappear(): void {
|
||||
Log.info(TAG, 'aboutToDisappear');
|
||||
ScreenManager.getInstance().off(ScreenManager.ON_WIN_SIZE_CHANGED, this.onWindowSizeChangeCallBack);
|
||||
this.onWindowSizeChangeCallBack = null;
|
||||
}
|
||||
|
||||
getResolution(height: number, width: number): string {
|
||||
@ -151,7 +150,7 @@ export struct DetailsDialog {
|
||||
.backgroundColor(this.isPcDevice ? $r('sys.color.ohos_id_color_button_normal') : $r('app.color.transparent'))
|
||||
.height($r('app.float.details_dialog_button_height'))
|
||||
.onClick(() => {
|
||||
this.controller.close()
|
||||
this.controller?.close();
|
||||
})
|
||||
.margin({
|
||||
left: $r('app.float.dialog_single_button_indent_margin'),
|
||||
|
@ -22,8 +22,8 @@ const TAG: string = 'common_DownloadCancelOperationDialog';
|
||||
|
||||
@Observed
|
||||
export class CancelParam {
|
||||
continueFunc: Function
|
||||
cancelFunc: Function
|
||||
continueFunc: Function = (): void => {};
|
||||
cancelFunc: Function = (): void => {};
|
||||
}
|
||||
|
||||
@CustomDialog
|
||||
@ -32,11 +32,11 @@ export struct DownloadCancelOperationDialog {
|
||||
@StorageLink('isSidebar') isSidebar: boolean = ScreenManager.getInstance().isSidebar();
|
||||
@StorageLink('leftBlank') leftBlank: number[]
|
||||
= [0, ScreenManager.getInstance().getStatusBarHeight(), 0, ScreenManager.getInstance().getNaviBarHeight()];
|
||||
controller: CustomDialogController;
|
||||
controller?: CustomDialogController;
|
||||
@Consume broadCast: BroadCast;
|
||||
@Consume deleteProgress: number;
|
||||
@Consume cancelParam: CancelParam;
|
||||
private isPcDevice: boolean = AppStorage.Get('deviceType') === Constants.PC_DEVICE_TYPE;
|
||||
private isPcDevice: boolean = AppStorage.get<string>('deviceType') === Constants.PC_DEVICE_TYPE;
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
@ -71,7 +71,7 @@ export struct DownloadCancelOperationDialog {
|
||||
.onClick(() => {
|
||||
Log.info(TAG, 'click continue')
|
||||
this.cancelParam.continueFunc();
|
||||
this.controller.close()
|
||||
this.controller?.close();
|
||||
})
|
||||
}.width('50%')
|
||||
|
||||
@ -93,7 +93,7 @@ export struct DownloadCancelOperationDialog {
|
||||
.onClick(() => {
|
||||
Log.info(TAG, 'click cancel')
|
||||
this.cancelParam.cancelFunc();
|
||||
this.controller.close()
|
||||
this.controller?.close();
|
||||
})
|
||||
}.width('50%')
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ import { Constants } from '../../model/common/Constants';
|
||||
|
||||
@Observed
|
||||
export class EditExitDialogCallback {
|
||||
discardCallback: Function
|
||||
discardCallback: Function = (): void => {};
|
||||
}
|
||||
|
||||
@CustomDialog
|
||||
@ -29,8 +29,8 @@ export struct EditExitDialog {
|
||||
@StorageLink('isSidebar') isSidebar: boolean = ScreenManager.getInstance().isSidebar();
|
||||
@StorageLink('leftBlank') leftBlank: number[]
|
||||
= [0, ScreenManager.getInstance().getStatusBarHeight(), 0, ScreenManager.getInstance().getNaviBarHeight()];
|
||||
controller: CustomDialogController;
|
||||
private isPcDevice: boolean = AppStorage.Get('deviceType') === Constants.PC_DEVICE_TYPE;
|
||||
controller?: CustomDialogController;
|
||||
private isPcDevice: boolean = AppStorage.get<string>('deviceType') === Constants.PC_DEVICE_TYPE;
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
@ -65,7 +65,7 @@ export struct EditExitDialog {
|
||||
.borderRadius($r('sys.float.ohos_id_corner_radius_button'))
|
||||
.height($r('app.float.details_dialog_button_height'))
|
||||
.onClick(() => {
|
||||
this.controller.close()
|
||||
this.controller?.close();
|
||||
})
|
||||
}.width('50%')
|
||||
|
||||
@ -93,7 +93,7 @@ export struct EditExitDialog {
|
||||
.borderRadius($r('sys.float.ohos_id_corner_radius_button'))
|
||||
.height($r('app.float.details_dialog_button_height'))
|
||||
.onClick(() => {
|
||||
this.controller.close()
|
||||
this.controller?.close();
|
||||
this.editExitDialogCallback && this.editExitDialogCallback.discardCallback()
|
||||
router.back()
|
||||
})
|
||||
|
@ -22,8 +22,8 @@ const TAG: string = 'common_MultiSelectDialog';
|
||||
|
||||
@Observed
|
||||
export class MultiSelectDetails {
|
||||
count: number;
|
||||
size: number
|
||||
count: number = 0;
|
||||
size: number = 0;
|
||||
}
|
||||
|
||||
@CustomDialog
|
||||
@ -34,9 +34,9 @@ export struct MultiSelectDialog {
|
||||
@StorageLink('isSidebar') isSidebar: boolean = ScreenManager.getInstance().isSidebar();
|
||||
@StorageLink('leftBlank') leftBlank: number[]
|
||||
= [0, ScreenManager.getInstance().getStatusBarHeight(), 0, ScreenManager.getInstance().getNaviBarHeight()];
|
||||
controller: CustomDialogController;
|
||||
controller?: CustomDialogController;
|
||||
@Consume multiSelectDetails: MultiSelectDetails;
|
||||
private isPcDevice: boolean = AppStorage.Get('deviceType') === Constants.PC_DEVICE_TYPE;
|
||||
private isPcDevice: boolean = AppStorage.get<string>('deviceType') === Constants.PC_DEVICE_TYPE;
|
||||
|
||||
aboutToAppear() {
|
||||
}
|
||||
@ -95,7 +95,7 @@ export struct MultiSelectDialog {
|
||||
.backgroundColor($r('sys.color.ohos_id_color_button_normal'))
|
||||
.height($r('app.float.details_dialog_button_height'))
|
||||
.onClick(() => {
|
||||
this.controller.close()
|
||||
this.controller?.close();
|
||||
})
|
||||
.margin({
|
||||
left: $r('app.float.dialog_single_button_indent_margin'),
|
||||
|
@ -28,7 +28,7 @@ export struct NewAlbumDialog {
|
||||
@StorageLink('isSidebar') isSidebar: boolean = ScreenManager.getInstance().isSidebar();
|
||||
@StorageLink('leftBlank') leftBlank: number[]
|
||||
= [0, ScreenManager.getInstance().getStatusBarHeight(), 0, ScreenManager.getInstance().getNaviBarHeight()];
|
||||
controller: CustomDialogController;
|
||||
controller?: CustomDialogController;
|
||||
@Consume renameFileName: string;
|
||||
@Consume dialogCallback: DialogCallback;
|
||||
@State isNull: boolean = false;
|
||||
@ -36,7 +36,7 @@ export struct NewAlbumDialog {
|
||||
@State dividerWidth: string = '1vp';
|
||||
@State isFocusable: boolean = true;
|
||||
private inputName: string = '';
|
||||
private isPcDevice: boolean = AppStorage.Get('deviceType') === Constants.PC_DEVICE_TYPE;
|
||||
private isPcDevice: boolean = AppStorage.get<string>('deviceType') === Constants.PC_DEVICE_TYPE;
|
||||
|
||||
aboutToAppear(): void {
|
||||
Log.info(TAG, 'aboutToAppear');
|
||||
@ -71,8 +71,8 @@ export struct NewAlbumDialog {
|
||||
.maxLength(Constants.RENAME_MAX_LENGTH)
|
||||
.enterKeyType(EnterKeyType.Done)
|
||||
.backgroundColor($r('app.color.transparent'))
|
||||
.onTouch((event: TouchEvent) => {
|
||||
if (event.type == TouchType.Down && !this.isFocusable) {
|
||||
.onTouch((event?: TouchEvent) => {
|
||||
if ((event as TouchEvent).type == TouchType.Down && !this.isFocusable) {
|
||||
this.isFocusable = true;
|
||||
}
|
||||
})
|
||||
@ -115,7 +115,7 @@ export struct NewAlbumDialog {
|
||||
.height($r('app.float.details_dialog_button_height'))
|
||||
.onClick(() => {
|
||||
this.dialogCallback && this.dialogCallback.cancelCallback();
|
||||
this.controller.close();
|
||||
this.controller?.close();
|
||||
})
|
||||
}.width('50%')
|
||||
|
||||
@ -178,12 +178,13 @@ export struct NewAlbumDialog {
|
||||
|
||||
private handleConfirmCallback() {
|
||||
if (this.dialogCallback === null || this.dialogCallback === undefined) {
|
||||
this.controller.close();
|
||||
this.controller?.close();
|
||||
return;
|
||||
}
|
||||
this.dialogCallback.confirmCallback(this.inputName).then((res) => {
|
||||
let confirmCb: Promise<Function> = (this.dialogCallback as DialogCallback).confirmCallback(this.inputName) as Promise<Function>;
|
||||
confirmCb.then((res: Function): void => {
|
||||
if (res) {
|
||||
this.controller.close();
|
||||
this.controller?.close();
|
||||
return;
|
||||
}
|
||||
Log.warn(TAG, 'new album name is not available!');
|
||||
|
@ -22,8 +22,8 @@ const TAG: string = 'common_ProgressDialog';
|
||||
|
||||
@Observed
|
||||
export class ProgressParam {
|
||||
cancelFunc: Function
|
||||
operationType: string
|
||||
cancelFunc: Function = (): void => {};
|
||||
operationType: string = '';
|
||||
}
|
||||
|
||||
@CustomDialog
|
||||
@ -32,7 +32,7 @@ export struct ProgressDialog {
|
||||
@StorageLink('isSidebar') isSidebar: boolean = ScreenManager.getInstance().isSidebar();
|
||||
@StorageLink('leftBlank') leftBlank: number[]
|
||||
= [0, ScreenManager.getInstance().getStatusBarHeight(), 0, ScreenManager.getInstance().getNaviBarHeight()];
|
||||
controller: CustomDialogController
|
||||
controller?: CustomDialogController
|
||||
@Consume progressMessage: Resource;
|
||||
@Consume deleteProgress: number;
|
||||
@Consume progressParam: ProgressParam;
|
||||
|
@ -28,9 +28,9 @@ export struct RemoveDialog {
|
||||
= [0, ScreenManager.getInstance().getStatusBarHeight(), 0, ScreenManager.getInstance().getNaviBarHeight()];
|
||||
@Consume dialogCallback: DialogCallback;
|
||||
@Consume dialogMessage: Resource;
|
||||
controller: CustomDialogController;
|
||||
controller?: CustomDialogController;
|
||||
@StorageLink('confirmText') confirmText: Resource = $r('app.string.dialog_remove');
|
||||
private isPcDevice: boolean = AppStorage.Get('deviceType') === Constants.PC_DEVICE_TYPE;
|
||||
private isPcDevice: boolean = AppStorage.get<string>('deviceType') === Constants.PC_DEVICE_TYPE;
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
@ -69,7 +69,7 @@ export struct RemoveDialog {
|
||||
.height($r('app.float.details_dialog_button_height'))
|
||||
.onClick(() => {
|
||||
Log.debug(TAG, `cancelCallback`);
|
||||
this.controller.close();
|
||||
this.controller?.close();
|
||||
this.dialogCallback && this.dialogCallback.cancelCallback();
|
||||
})
|
||||
}.width('50%')
|
||||
@ -99,7 +99,7 @@ export struct RemoveDialog {
|
||||
.height($r('app.float.details_dialog_button_height'))
|
||||
.onClick(() => {
|
||||
Log.debug(TAG, `confirmCallback`);
|
||||
this.controller.close();
|
||||
this.controller?.close();
|
||||
this.dialogCallback && this.dialogCallback.confirmCallback();
|
||||
})
|
||||
}.width('50%')
|
||||
|
@ -21,9 +21,9 @@ const TAG: string = 'common_RemoveProgressDialog';
|
||||
|
||||
@Observed
|
||||
export class RemoveProgressParam {
|
||||
currentCount: number
|
||||
totalCount: number
|
||||
message: Resource
|
||||
currentCount: number = 0;
|
||||
totalCount: number = 0;
|
||||
message?: Resource
|
||||
}
|
||||
|
||||
@CustomDialog
|
||||
@ -32,10 +32,10 @@ export struct RemoveProgressDialog {
|
||||
@StorageLink('isSidebar') isSidebar: boolean = ScreenManager.getInstance().isSidebar();
|
||||
@StorageLink('leftBlank') leftBlank: number[]
|
||||
= [0, ScreenManager.getInstance().getStatusBarHeight(), 0, ScreenManager.getInstance().getNaviBarHeight()];
|
||||
controller: CustomDialogController
|
||||
controller?: CustomDialogController
|
||||
@Consume removeProgress: number;
|
||||
@Consume removeProgressParam: RemoveProgressParam;
|
||||
private isPcDevice: boolean = AppStorage.Get('deviceType') === Constants.PC_DEVICE_TYPE;
|
||||
private isPcDevice: boolean = AppStorage.get<string>('deviceType') === Constants.PC_DEVICE_TYPE;
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
|
@ -28,14 +28,14 @@ export struct RenameDialog {
|
||||
@StorageLink('isSidebar') isSidebar: boolean = ScreenManager.getInstance().isSidebar();
|
||||
@StorageLink('leftBlank') leftBlank: number[]
|
||||
= [0, ScreenManager.getInstance().getStatusBarHeight(), 0, ScreenManager.getInstance().getNaviBarHeight()];
|
||||
controller: CustomDialogController;
|
||||
controller?: CustomDialogController;
|
||||
@Consume renameFileName: string;
|
||||
@Consume dialogCallback: DialogCallback;
|
||||
@State isNull: boolean = false;
|
||||
@State dividerColor: Resource = $r('app.color.dialog_divider_h_color_182431');
|
||||
@State dividerWidth: string = '1vp';
|
||||
private inputName: string = '';
|
||||
private isPcDevice: boolean = AppStorage.Get('deviceType') === Constants.PC_DEVICE_TYPE;
|
||||
private isPcDevice: boolean = AppStorage.get<string>('deviceType') === Constants.PC_DEVICE_TYPE;
|
||||
|
||||
aboutToAppear(): void {
|
||||
Log.info(TAG, 'aboutToAppear');
|
||||
@ -108,7 +108,7 @@ export struct RenameDialog {
|
||||
.height($r('app.float.details_dialog_button_height'))
|
||||
.onClick(() => {
|
||||
this.dialogCallback && this.dialogCallback.cancelCallback();
|
||||
this.controller.close()
|
||||
this.controller?.close();
|
||||
})
|
||||
}.width('50%')
|
||||
|
||||
@ -142,11 +142,11 @@ export struct RenameDialog {
|
||||
return;
|
||||
}
|
||||
if (this.inputName == this.renameFileName) {
|
||||
this.controller.close();
|
||||
this.controller?.close();
|
||||
return;
|
||||
}
|
||||
this.dialogCallback && this.dialogCallback.confirmCallback(this.inputName);
|
||||
this.controller.close();
|
||||
this.controller?.close();
|
||||
})
|
||||
}.width('50%')
|
||||
}
|
||||
|
@ -20,8 +20,8 @@ import { Constants } from '../../model/common/Constants';
|
||||
|
||||
@Observed
|
||||
export class SaveDialogCallback {
|
||||
saveAsNewCallback: Function
|
||||
replaceOriginalCallback: Function
|
||||
saveAsNewCallback: Function = (): void => {};
|
||||
replaceOriginalCallback: Function = (): void => {};
|
||||
}
|
||||
|
||||
@Extend(Text) function buttonTextExtend() {
|
||||
@ -31,7 +31,7 @@ export class SaveDialogCallback {
|
||||
.fontWeight(FontWeight.Medium)
|
||||
}
|
||||
|
||||
@Extend(Button) function verticalButtonExtend(isPcDevice) {
|
||||
@Extend(Button) function verticalButtonExtend(isPcDevice: boolean) {
|
||||
.width('100%')
|
||||
.height($r('app.float.details_dialog_button_height'))
|
||||
.borderRadius($r('sys.float.ohos_id_corner_radius_button'))
|
||||
@ -46,9 +46,9 @@ export struct SaveDialog {
|
||||
= [0, ScreenManager.getInstance().getStatusBarHeight(), 0, ScreenManager.getInstance().getNaviBarHeight()];
|
||||
@Consume broadCast: BroadCast;
|
||||
@Consume saveDialogCallback: SaveDialogCallback;
|
||||
controller: CustomDialogController;
|
||||
controller?: CustomDialogController;
|
||||
readonly buttonWidth: number = 100 / 3;
|
||||
private isPcDevice: boolean = AppStorage.Get('deviceType') === Constants.PC_DEVICE_TYPE;
|
||||
private isPcDevice: boolean = AppStorage.get<string>('deviceType') === Constants.PC_DEVICE_TYPE;
|
||||
|
||||
@Builder horizontalThreeButtons() {
|
||||
Stack({ alignContent: Alignment.Top }) {
|
||||
@ -64,7 +64,7 @@ export struct SaveDialog {
|
||||
.backgroundColor($r('app.color.transparent'))
|
||||
.height($r('app.float.details_dialog_button_height'))
|
||||
.onClick(() => {
|
||||
this.controller.close()
|
||||
this.controller?.close();
|
||||
})
|
||||
}.width(`${this.buttonWidth}%`)
|
||||
|
||||
@ -83,7 +83,7 @@ export struct SaveDialog {
|
||||
.height($r('app.float.details_dialog_button_height'))
|
||||
.onClick(() => {
|
||||
this.broadCast.emit(BroadCastConstants.SHOW_EDIT_SAVE_PROGRESS_DIALOG, []);
|
||||
this.controller.close()
|
||||
this.controller?.close();
|
||||
this.saveDialogCallback && this.saveDialogCallback.replaceOriginalCallback()
|
||||
})
|
||||
}.width(`${this.buttonWidth}%`)
|
||||
@ -101,7 +101,7 @@ export struct SaveDialog {
|
||||
.backgroundColor($r('app.color.transparent'))
|
||||
.height($r('app.float.details_dialog_button_height'))
|
||||
.onClick(() => {
|
||||
this.controller.close()
|
||||
this.controller?.close();
|
||||
this.broadCast.emit(BroadCastConstants.SHOW_EDIT_SAVE_PROGRESS_DIALOG, []);
|
||||
this.saveDialogCallback && this.saveDialogCallback.saveAsNewCallback()
|
||||
})
|
||||
@ -126,7 +126,7 @@ export struct SaveDialog {
|
||||
.verticalButtonExtend(this.isPcDevice)
|
||||
.margin({ bottom: $r('app.float.vertical_three_buttons_margin_bottom') })
|
||||
.onClick(() => {
|
||||
this.controller.close()
|
||||
this.controller?.close();
|
||||
this.broadCast.emit(BroadCastConstants.SHOW_EDIT_SAVE_PROGRESS_DIALOG, []);
|
||||
this.saveDialogCallback && this.saveDialogCallback.saveAsNewCallback()
|
||||
})
|
||||
@ -142,7 +142,7 @@ export struct SaveDialog {
|
||||
.margin({ bottom: $r('app.float.vertical_three_buttons_margin_bottom') })
|
||||
.onClick(() => {
|
||||
this.broadCast.emit(BroadCastConstants.SHOW_EDIT_SAVE_PROGRESS_DIALOG, []);
|
||||
this.controller.close()
|
||||
this.controller?.close();
|
||||
this.saveDialogCallback && this.saveDialogCallback.replaceOriginalCallback()
|
||||
})
|
||||
}
|
||||
@ -155,7 +155,7 @@ export struct SaveDialog {
|
||||
.key('Cancel')
|
||||
.verticalButtonExtend(this.isPcDevice)
|
||||
.onClick(() => {
|
||||
this.controller.close()
|
||||
this.controller?.close();
|
||||
})
|
||||
}.width('100%')
|
||||
}
|
||||
|
@ -25,19 +25,19 @@ export struct SaveImageDialog {
|
||||
@StorageLink('isSidebar') isSidebar: boolean = ScreenManager.getInstance().isSidebar();
|
||||
@StorageLink('leftBlank') leftBlank: number[]
|
||||
= [0, ScreenManager.getInstance().getStatusBarHeight(), 0, ScreenManager.getInstance().getNaviBarHeight()];
|
||||
controller: CustomDialogController;
|
||||
private isPcDevice: boolean = AppStorage.Get('deviceType') === Constants.PC_DEVICE_TYPE;
|
||||
controller?: CustomDialogController;
|
||||
private isPcDevice: boolean = AppStorage.get<string>('deviceType') === Constants.PC_DEVICE_TYPE;
|
||||
|
||||
controllerClose() {
|
||||
this.controller.close()
|
||||
this.controller?.close();
|
||||
}
|
||||
|
||||
aboutToAppear() {
|
||||
this.broadCast.on(BroadCastConstants.EXIT_SAVE_PROGRESS_CLOSE, this.controllerClose.bind(this));
|
||||
this.broadCast.on(BroadCastConstants.EXIT_SAVE_PROGRESS_CLOSE, (): void => this.controllerClose());
|
||||
}
|
||||
|
||||
aboutToDisappear(): void {
|
||||
this.broadCast.off(null, null);
|
||||
this.broadCast.off(BroadCastConstants.EXIT_SAVE_PROGRESS_CLOSE, (): void => {});
|
||||
}
|
||||
|
||||
build() {
|
||||
|
@ -26,14 +26,15 @@ export struct ThirdDeleteDialog {
|
||||
@Consume dialogCallback: DialogCallback;
|
||||
@Consume dialogMessage: Resource;
|
||||
@StorageLink('confirmText') confirmText: Resource = $r('app.string.dialog_delete');
|
||||
controller: CustomDialogController;
|
||||
controller?: CustomDialogController;
|
||||
|
||||
private uris: any;
|
||||
private thirdAppName: string;
|
||||
private uris: string[] = [];
|
||||
private thirdAppName: string | undefined = '';
|
||||
|
||||
aboutToAppear() {
|
||||
this.uris = AppStorage.Get("uris");
|
||||
this.thirdAppName = AppStorage.Get("appName");
|
||||
let stored = AppStorage.get<string[]>('uris');
|
||||
this.uris = stored === undefined ? [] : stored;
|
||||
this.thirdAppName = AppStorage.get<string>('appName');
|
||||
}
|
||||
|
||||
build() {
|
||||
@ -94,7 +95,7 @@ export struct ThirdDeleteDialog {
|
||||
.height($r('app.float.details_dialog_button_height'))
|
||||
.onClick(() => {
|
||||
Log.debug(this.TAG, `cancelCallback`);
|
||||
this.controller.close();
|
||||
this.controller?.close();
|
||||
this.dialogCallback && this.dialogCallback.cancelCallback();
|
||||
})
|
||||
}.width('50%')
|
||||
@ -121,7 +122,7 @@ export struct ThirdDeleteDialog {
|
||||
.height($r('app.float.details_dialog_button_height'))
|
||||
.onClick(() => {
|
||||
Log.debug(this.TAG, `confirmCallback`);
|
||||
this.controller.close();
|
||||
this.controller?.close();
|
||||
this.dialogCallback && this.dialogCallback.confirmCallback();
|
||||
})
|
||||
}.width('50%')
|
||||
|
@ -38,6 +38,11 @@ const TAG: string = 'browser_AlbumGridItemNewStyle';
|
||||
.focusable(true)
|
||||
}
|
||||
|
||||
interface ParamAlbumInfo {
|
||||
item: string;
|
||||
isFromFACard?: boolean;
|
||||
}
|
||||
|
||||
// The item of album grid, and it's new style.
|
||||
@Component
|
||||
export struct AlbumGridItemNewStyle {
|
||||
@ -54,20 +59,21 @@ export struct AlbumGridItemNewStyle {
|
||||
@Consume('selectedCount') selectedCount: number;
|
||||
@Consume @Watch('onModeChange') isAlbumSetSelectedMode: boolean;
|
||||
@Consume rightClickMenuList: Array<Action>;
|
||||
currentRightClickMenuList: Array<Action>;
|
||||
onMenuClicked: Function;
|
||||
onMenuClickedForSingleItem: Function;
|
||||
currentRightClickMenuList: Array<Action> = [];
|
||||
onMenuClicked: Function = (): void => {};
|
||||
onMenuClickedForSingleItem: Function = (): void => {};
|
||||
gridAspectRatio = Constants.CARD_ASPECT_RATIO;
|
||||
albumCountMarginRight = Constants.ALBUM_SET_NEW_ICON_SIZE + Constants.ALBUM_SET_NEW_ICON_MARGIN * 2;
|
||||
iconMarkAnchorX = Constants.ALBUM_SET_NEW_ICON_SIZE + Constants.ALBUM_SET_NEW_ICON_MARGIN;
|
||||
iconMarkAnchorY = Constants.ALBUM_SET_NEW_ICON_SIZE + Constants.ALBUM_SET_NEW_ICON_MARGIN;
|
||||
@StorageLink('deviceType') deviceType: string = AppStorage.Get('deviceType');
|
||||
@StorageLink('deviceType') deviceType: string | undefined = AppStorage.get<string>('deviceType') ;
|
||||
@State transitionId: string = '';
|
||||
@StorageLink('isShowPhotoGridView') isShowPhotoGridView: boolean = false;
|
||||
private appBroadCast: BroadCast = BroadCastManager.getInstance().getBroadCast();
|
||||
private keyIndex?: number;
|
||||
private fp2vpUnit: number = px2vp(fp2px(Constants.NUMBER_1));
|
||||
private recycleAlbumOfPhoneHeight: number = Constants.RECYCLE_ALBUM_OF_PHONE_HEIGHT;
|
||||
private updateCardSizeFunc: Function = (): void => this.updateCardSize();
|
||||
|
||||
doAnimation(): void {
|
||||
let albumToPhotoGridDuration: number;
|
||||
@ -93,14 +99,14 @@ export struct AlbumGridItemNewStyle {
|
||||
curve: Curve.Friction,
|
||||
}, () => {
|
||||
AppStorage.SetOrCreate<boolean>(Constants.KEY_OF_IS_SHOW_PHOTO_GRID_VIEW,!this.isShowPhotoGridView);
|
||||
AppStorage.SetOrCreate<number>(Constants.KEY_OF_SELECTED_ALBUM_INDEX, this.keyIndex);
|
||||
AppStorage.SetOrCreate<number>(Constants.KEY_OF_SELECTED_ALBUM_INDEX, this.keyIndex ? this.keyIndex : -1);
|
||||
AppStorage.SetOrCreate<string>(Constants.KEY_OF_SELECTED_ALBUM_URI, this.item.uri);
|
||||
})
|
||||
animateTo({
|
||||
duration: albumActionBarDuration,
|
||||
curve: Curve.Sharp
|
||||
}, () => {
|
||||
if (AppStorage.Get('deviceType') !== Constants.PC_DEVICE_TYPE) {
|
||||
if (AppStorage.get<string>('deviceType') !== Constants.PC_DEVICE_TYPE) {
|
||||
AppStorage.SetOrCreate<number>(Constants.KEY_OF_ALBUM_OPACITY, 0);
|
||||
}
|
||||
AppStorage.SetOrCreate<number>(Constants.KEY_OF_ALBUM_ACTIONBAR_OPACITY, 0);
|
||||
@ -110,7 +116,7 @@ export struct AlbumGridItemNewStyle {
|
||||
curve: Curve.Sharp,
|
||||
delay: BrowserConstants.LINK_IN_PHOTO_GRID_DELAY,
|
||||
}, () => {
|
||||
if (AppStorage.Get('deviceType') !== Constants.PC_DEVICE_TYPE) {
|
||||
if (AppStorage.get<string>('deviceType') !== Constants.PC_DEVICE_TYPE) {
|
||||
AppStorage.SetOrCreate<number>(Constants.KEY_OF_PHOTO_GRID_VIEW_OPACITY, 1);
|
||||
}
|
||||
})
|
||||
@ -128,7 +134,7 @@ export struct AlbumGridItemNewStyle {
|
||||
AppStorage.SetOrCreate<number>(Constants.KEY_OF_PHOTO_GRID_ACTIONBAR_OPACITY, 1);
|
||||
})
|
||||
|
||||
if (AppStorage.Get('deviceType') === Constants.PC_DEVICE_TYPE) {
|
||||
if (AppStorage.get<string>('deviceType') !== Constants.PC_DEVICE_TYPE) {
|
||||
animateTo({
|
||||
duration: BrowserConstants.PC_LINK_IN_PHOTO_GRID_DURATION,
|
||||
delay: BrowserConstants.LINK_IN_PHOTO_GRID_DELAY,
|
||||
@ -157,15 +163,14 @@ export struct AlbumGridItemNewStyle {
|
||||
aboutToAppear(): void {
|
||||
Log.debug(TAG, `aboutToAppear`);
|
||||
this.selectable = !this.item.isTrashAlbum;
|
||||
this.updateCardSize = this.updateCardSize.bind(this)
|
||||
|
||||
// 后续phone缩略图支持横竖屏后再放开
|
||||
if (AppStorage.Get('deviceType') as string !== Constants.DEFAULT_DEVICE_TYPE) {
|
||||
ScreenManager.getInstance().on(ScreenManager.ON_WIN_SIZE_CHANGED, this.updateCardSize);
|
||||
if (AppStorage.get('deviceType') as string !== Constants.DEFAULT_DEVICE_TYPE) {
|
||||
ScreenManager.getInstance().on(ScreenManager.ON_WIN_SIZE_CHANGED, this.updateCardSizeFunc);
|
||||
}
|
||||
let isFirstPhotoItem = AppStorage.Get<boolean>(Constants.KEY_OF_IS_FIRST_PHOTO_ITEM);
|
||||
let lastTransitionId = AppStorage.Get<string>(Constants.KEY_OF_GEOMETRY_TRANSITION_ID_HEIGHT);
|
||||
if (!isFirstPhotoItem && this.item.uri === AppStorage.Get<string>(Constants.KEY_OF_ALBUM_URI)) {
|
||||
let isFirstPhotoItem = AppStorage.get<boolean>(Constants.KEY_OF_IS_FIRST_PHOTO_ITEM);
|
||||
let lastTransitionId = AppStorage.get<string>(Constants.KEY_OF_GEOMETRY_TRANSITION_ID_HEIGHT) as string;
|
||||
if (!isFirstPhotoItem && this.item.uri === AppStorage.get<string>(Constants.KEY_OF_ALBUM_URI)) {
|
||||
this.transitionId = lastTransitionId;
|
||||
} else {
|
||||
if (!this.isRecycleAlbumOfPhoneLikeDevice() && this.item.mediaItem) {
|
||||
@ -183,9 +188,8 @@ export struct AlbumGridItemNewStyle {
|
||||
|
||||
aboutToDisappear(): void {
|
||||
// 后续phone缩略图支持横竖屏后再放开
|
||||
if (AppStorage.Get('deviceType') as string !== Constants.DEFAULT_DEVICE_TYPE) {
|
||||
ScreenManager.getInstance().off(ScreenManager.ON_WIN_SIZE_CHANGED, this.updateCardSize);
|
||||
this.updateCardSize = null;
|
||||
if (AppStorage.get('deviceType') as string !== Constants.DEFAULT_DEVICE_TYPE) {
|
||||
ScreenManager.getInstance().off(ScreenManager.ON_WIN_SIZE_CHANGED, this.updateCardSizeFunc);
|
||||
}
|
||||
}
|
||||
|
||||
@ -197,7 +201,7 @@ export struct AlbumGridItemNewStyle {
|
||||
updateCardSize(): void {
|
||||
let sideBarWidth: number = 0;
|
||||
let count: number = 0;
|
||||
let currentBreakpoint = AppStorage.Get<string>('currentBreakpoint');
|
||||
let currentBreakpoint = AppStorage.get<string>('currentBreakpoint');
|
||||
if (currentBreakpoint === Constants.BREAKPOINT_LG && this.deviceType == Constants.PAD_DEVICE_TYPE) {
|
||||
sideBarWidth = Constants.PAD_TAB_BAR_WIDTH;
|
||||
count = UiUtil.getAlbumGridCount(true);
|
||||
@ -244,10 +248,10 @@ export struct AlbumGridItemNewStyle {
|
||||
if (this.selectable) {
|
||||
let newState: boolean = !this.isSelected;
|
||||
this.broadCast.emit(BroadCastConstants.SELECT,
|
||||
[this.item.uri, newState, this.item.isSystemAlbum, this.item.isSystemAlbum, function(){
|
||||
[this.item.uri, newState, this.item.isSystemAlbum, this.item.isSystemAlbum, (): void => {
|
||||
Log.info(TAG, 'enter callback');
|
||||
this.isSelected = newState;
|
||||
}.bind(this)]);
|
||||
}]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -288,7 +292,7 @@ export struct AlbumGridItemNewStyle {
|
||||
}
|
||||
}
|
||||
})
|
||||
}, menu => menu.actionID.toString())
|
||||
}, (menu: Action) => menu.actionID.toString())
|
||||
}
|
||||
.width(ScreenManager.getInstance().getColumnsWidth(ColumnSize.COLUMN_ONE_POINT_FIVE))
|
||||
.borderRadius($r('sys.float.ohos_id_corner_radius_card'))
|
||||
@ -449,8 +453,8 @@ export struct AlbumGridItemNewStyle {
|
||||
this.albumOnClick();
|
||||
})
|
||||
.bindContextMenu(this.RightClickMenuBuilder, this.showRightClickPopup() ? ResponseType.RightClick : -1)
|
||||
.onKeyEvent((event: KeyEvent) => {
|
||||
if (KeyType.Up == event.type) {
|
||||
.onKeyEvent((event?: KeyEvent) => {
|
||||
if (event != null && KeyType.Up == event.type) {
|
||||
switch (event.keyCode) {
|
||||
case MultimodalInputManager.KEY_CODE_KEYBOARD_ENTER:
|
||||
this.albumOnClick();
|
||||
@ -489,7 +493,7 @@ export struct AlbumGridItemNewStyle {
|
||||
this.selectStateChange();
|
||||
} else {
|
||||
Log.info(TAG, `After onClick, MediaSet is: ${JSON.stringify(this.item)}`);
|
||||
if (this.item.isTrashAlbum && AppStorage.Get('deviceType') !== Constants.PC_DEVICE_TYPE) {
|
||||
if (this.item.isTrashAlbum && (AppStorage.get<string>('deviceType') !== Constants.PC_DEVICE_TYPE)) {
|
||||
router.pushUrl({
|
||||
url: 'pages/PhotoGridPage',
|
||||
params: {
|
||||
@ -497,7 +501,8 @@ export struct AlbumGridItemNewStyle {
|
||||
}
|
||||
});
|
||||
} else if (!this.isShowPhotoGridView) {
|
||||
AppStorage.SetOrCreate(Constants.KEY_OF_PHOTO_GRID_VIEW_ALBUM_ITEM, { item: JSON.stringify(this.item) });
|
||||
let albumInfo: ParamAlbumInfo = { item: JSON.stringify(this.item) }
|
||||
AppStorage.setOrCreate<ParamAlbumInfo>(Constants.KEY_OF_PHOTO_GRID_VIEW_ALBUM_ITEM, albumInfo);
|
||||
AppStorage.SetOrCreate(Constants.KEY_OF_GEOMETRY_TRANSITION_ID_HEIGHT, this.transitionId);
|
||||
AppStorage.SetOrCreate(Constants.KEY_OF_ALBUM_URI, this.item.uri);
|
||||
this.doAnimation();
|
||||
|
@ -34,7 +34,7 @@ export struct AlbumSelectActionBar {
|
||||
@State actionBarProp: ActionBarProp = new ActionBarProp();
|
||||
@Link @Watch('createActionBar') totalSelectedCount: number;
|
||||
@Provide selectedCount: number = 0;
|
||||
onMenuClicked: Function;
|
||||
onMenuClicked: Function = (): void => {};
|
||||
@Link @Watch('updateMenu') menuList: Action[];
|
||||
@Provide moreMenuList: Action[] = new Array<Action>();
|
||||
@Provide hidePopup: boolean = false;
|
||||
|
@ -22,12 +22,12 @@ const TAG: string = 'browser_AlbumSelectGridItemNewStyle';
|
||||
// The item of album grid, and it's new style.
|
||||
@Component
|
||||
export struct AlbumSelectGridItemNewStyle {
|
||||
@State @Watch('updateCard') item: AlbumInfo = undefined;
|
||||
@State @Watch('updateCard') item: AlbumInfo = new AlbumInfo();
|
||||
@State isEmptyAlbum: boolean = false;
|
||||
@Provide gridHeight: number = 0;
|
||||
@Provide gridWidth: number = 0;
|
||||
@Consume broadCast: BroadCast;
|
||||
mSelectManager: SelectManager;
|
||||
mSelectManager: SelectManager | null = null;
|
||||
gridAspectRatio = Constants.CARD_ASPECT_RATIO;
|
||||
albumCountMarginRight = Constants.ALBUM_SET_NEW_ICON_SIZE + Constants.ALBUM_SET_NEW_ICON_MARGIN * 2;
|
||||
iconMarkAnchorX = Constants.ALBUM_SET_NEW_ICON_SIZE + Constants.ALBUM_SET_NEW_ICON_MARGIN;
|
||||
@ -38,22 +38,21 @@ export struct AlbumSelectGridItemNewStyle {
|
||||
[AlbumDefine.ALBUM_ID_VIDEO, $r('app.media.ic_video')],
|
||||
[AlbumDefine.ALBUM_ID_FAVOR, $r('app.media.ic_favorite_overlay')]
|
||||
]);
|
||||
private updateCardSizeFunc: Function = (): void => this.updateCardSize()
|
||||
|
||||
aboutToAppear(): void {
|
||||
Log.info(TAG, `aboutToAppear + ${this.item.coverUri}`);
|
||||
this.updateCardSize = this.updateCardSize.bind(this);
|
||||
this.updateCardSize();
|
||||
// 后续phone缩略图支持横竖屏后再放开
|
||||
if (AppStorage.Get('deviceType') as string !== Constants.DEFAULT_DEVICE_TYPE) {
|
||||
ScreenManager.getInstance().on(ScreenManager.ON_WIN_SIZE_CHANGED, this.updateCardSize);
|
||||
if (AppStorage.get('deviceType') as string !== Constants.DEFAULT_DEVICE_TYPE) {
|
||||
ScreenManager.getInstance().on(ScreenManager.ON_WIN_SIZE_CHANGED, this.updateCardSizeFunc);
|
||||
}
|
||||
}
|
||||
|
||||
aboutToDisappear(): void {
|
||||
// 后续phone缩略图支持横竖屏后再放开
|
||||
if (AppStorage.Get('deviceType') as string !== Constants.DEFAULT_DEVICE_TYPE) {
|
||||
ScreenManager.getInstance().off(ScreenManager.ON_WIN_SIZE_CHANGED, this.updateCardSize);
|
||||
this.updateCardSize = null;
|
||||
if (AppStorage.get('deviceType') as string !== Constants.DEFAULT_DEVICE_TYPE) {
|
||||
ScreenManager.getInstance().off(ScreenManager.ON_WIN_SIZE_CHANGED, this.updateCardSizeFunc);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { MenuOperation } from '@ohos/common';
|
||||
import { MenuOperation, WindowUtil } from '@ohos/common';
|
||||
import {
|
||||
Action,
|
||||
AlbumInfo,
|
||||
@ -73,7 +73,7 @@ export struct AlbumSetPage {
|
||||
@Provide rightClickMenuList: Array<Action> = new Array<Action>();
|
||||
@StorageLink('isHorizontal') isHorizontal: boolean = ScreenManager.getInstance().isHorizontal();
|
||||
@StorageLink('statusBarHeight') statusBarHeight: number = 0;
|
||||
@StorageLink('deviceType') deviceType: string = AppStorage.Get('deviceType');
|
||||
@StorageLink('deviceType') deviceType: string | undefined = AppStorage.get<string>('deviceType') ;
|
||||
@State pageStatus: boolean = false;
|
||||
@State bottomHeight: number = 0;
|
||||
@StorageLink('selectedAlbumUri') selectedAlbumUri: string = '';
|
||||
@ -90,61 +90,59 @@ export struct AlbumSetPage {
|
||||
private needNotify = false;
|
||||
private ignoreLocalNotify = false;
|
||||
private minGridColumnsCount: number = 2;
|
||||
private onWinSizeChangedFunc: Function = (): void => this.initGridRowCount();
|
||||
private onTabChangedFunc: Function = (index: number): void => this.onTabChanged(index);
|
||||
private onStateResetFunc: Function = (index: number): void => this.onStateReset(index);
|
||||
private onSendMoveCopyBroadCastFunc: Function = (index: number): void => this.onSendMoveCopyBroadCast(index);
|
||||
private onLoadingFinishedFunc: Function = (size: number): void => this.onLoadingFinished(size);
|
||||
private onResetZeroFunc: Function = (pageNumber: number): void => this.onResetZero(pageNumber);
|
||||
private onUpdateRemoteDeviceFunc: Function = (res: string, deviceId: string, size: number): void =>
|
||||
this.onUpdateRemoteDevice(res, deviceId, size);
|
||||
private onMenuClickedFunc = (action: Action, arg: Object[]): void => this.onMenuClicked(action, arg);
|
||||
private selectFunc = (
|
||||
key: string, value: boolean, isDisableRename: boolean, isDisableDelete: boolean, callback: Function): void =>
|
||||
this.select(key, value, isDisableRename, isDisableDelete, callback);
|
||||
|
||||
onMenuClicked(action: Action, arg: unknown[]) {
|
||||
onMenuClicked(action: Action, arg: Object[]) {
|
||||
Log.info(TAG, `onMenuClicked, action: ${action.actionID}`);
|
||||
let menuContext: MenuContext;
|
||||
let menuOperation: MenuOperation;
|
||||
switch (action.actionID) {
|
||||
case Action.NEW.actionID:
|
||||
menuContext = new MenuContext();
|
||||
this.onOperationStart = this.onOperationStart.bind(this);
|
||||
this.onOperationEnd = this.onOperationEnd.bind(this);
|
||||
menuContext
|
||||
.withOperationStartCallback(this.onOperationStart)
|
||||
.withOperationEndCallback(this.onOperationEnd)
|
||||
.withAlbumSetDataSource(this.albums)
|
||||
.withBroadCast(this.broadCast);
|
||||
menuOperation
|
||||
if (action.actionID === Action.NEW.actionID) {
|
||||
menuContext = new MenuContext();
|
||||
menuContext
|
||||
.withOperationStartCallback((): void => this.onOperationStart())
|
||||
.withOperationEndCallback((): void => this.onOperationEnd())
|
||||
.withAlbumSetDataSource(this.albums)
|
||||
.withBroadCast(this.broadCast);
|
||||
menuOperation
|
||||
= MenuOperationFactory.getInstance().createMenuOperation(AlbumSetNewMenuOperation, menuContext);
|
||||
menuOperation.doAction();
|
||||
break;
|
||||
case Action.CANCEL.actionID:
|
||||
this.isAlbumSetSelectedMode = false;
|
||||
break;
|
||||
case Action.MULTISELECT.actionID:
|
||||
this.isAlbumSetSelectedMode = true;
|
||||
break;
|
||||
case Action.RENAME.actionID:
|
||||
menuContext = new MenuContext();
|
||||
this.onOperationStart = this.onOperationStart.bind(this);
|
||||
this.onOperationEnd = this.onOperationEnd.bind(this);
|
||||
menuContext
|
||||
.withFromSelectMode(true)
|
||||
.withSelectManager(this.mSelectManager)
|
||||
.withOperationStartCallback(this.onOperationStart)
|
||||
.withOperationEndCallback(this.onOperationEnd)
|
||||
.withBroadCast(this.broadCast);
|
||||
menuOperation
|
||||
menuOperation.doAction();
|
||||
} else if (action.actionID === Action.CANCEL.actionID) {
|
||||
this.isAlbumSetSelectedMode = false;
|
||||
} else if (action.actionID === Action.MULTISELECT.actionID) {
|
||||
this.isAlbumSetSelectedMode = true;
|
||||
} else if (action.actionID === Action.RENAME.actionID) {
|
||||
menuContext = new MenuContext();
|
||||
menuContext
|
||||
.withFromSelectMode(true)
|
||||
.withSelectManager(this.mSelectManager)
|
||||
.withOperationStartCallback((): void => this.onOperationStart())
|
||||
.withOperationEndCallback((): void => this.onOperationEnd())
|
||||
.withBroadCast(this.broadCast);
|
||||
menuOperation
|
||||
= MenuOperationFactory.getInstance().createMenuOperation(AlbumSetRenameMenuOperation, menuContext);
|
||||
menuOperation.doAction();
|
||||
break;
|
||||
case Action.DELETE.actionID:
|
||||
menuContext = new MenuContext();
|
||||
this.onOperationStart = this.onOperationStart.bind(this);
|
||||
this.onOperationEnd = this.onOperationEnd.bind(this);
|
||||
menuContext
|
||||
.withFromSelectMode(true)
|
||||
.withSelectManager(this.mSelectManager)
|
||||
.withOperationStartCallback(this.onOperationStart)
|
||||
.withOperationEndCallback(this.onOperationEnd)
|
||||
.withBroadCast(this.broadCast);
|
||||
menuOperation
|
||||
menuOperation.doAction();
|
||||
} else if (action.actionID === Action.DELETE.actionID) {
|
||||
menuContext = new MenuContext();
|
||||
menuContext
|
||||
.withFromSelectMode(true)
|
||||
.withSelectManager(this.mSelectManager)
|
||||
.withOperationStartCallback((): void => this.onOperationStart())
|
||||
.withOperationEndCallback((): void => this.onOperationEnd())
|
||||
.withBroadCast(this.broadCast);
|
||||
menuOperation
|
||||
= MenuOperationFactory.getInstance().createMenuOperation(AlbumSetDeleteMenuOperation, menuContext);
|
||||
menuOperation.doAction();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
menuOperation.doAction();
|
||||
}
|
||||
}
|
||||
|
||||
@ -166,55 +164,48 @@ export struct AlbumSetPage {
|
||||
aboutToAppear(): void {
|
||||
TraceControllerUtils.startTrace('AlbumSetPageAboutToAppear');
|
||||
Log.info(TAG, `AlbumSetPageAboutToAppear`);
|
||||
this.appBroadCast.on(BroadCastConstants.ON_TAB_CHANGED, this.onTabChanged.bind(this));
|
||||
this.appBroadCast.on(BroadCastConstants.RESET_STATE_EVENT, this.onStateReset.bind(this));
|
||||
this.appBroadCast.on(BroadCastConstants.SEND_COPY_OR_MOVE_BROADCAST, this.onSendMoveCopyBroadCast.bind(this));
|
||||
this.appBroadCast.on(BroadCastConstants.ON_TAB_CHANGED, this.onTabChangedFunc);
|
||||
this.appBroadCast.on(BroadCastConstants.RESET_STATE_EVENT, this.onStateResetFunc);
|
||||
this.appBroadCast.on(BroadCastConstants.SEND_COPY_OR_MOVE_BROADCAST, this.onSendMoveCopyBroadCastFunc);
|
||||
AppStorage.SetOrCreate('setSelectManagerToAnother', this.mSelectManager);
|
||||
this.broadCast.on(Constants.ON_LOADING_FINISHED, (size: number) => {
|
||||
this.isEmpty = (size == 0);
|
||||
});
|
||||
|
||||
this.appBroadCast.on(BroadCastConstants.RESET_ZERO, this.onResetZero.bind(this));
|
||||
this.appBroadCast.on(BroadCastConstants.ON_REMOTE_CHANGED, this.onUpdateRemoteDevice.bind(this));
|
||||
this.broadCast.on(Constants.ON_LOADING_FINISHED, this.onLoadingFinishedFunc);
|
||||
this.appBroadCast.on(BroadCastConstants.RESET_ZERO, this.onResetZeroFunc);
|
||||
this.appBroadCast.on(BroadCastConstants.ON_REMOTE_CHANGED, this.onUpdateRemoteDeviceFunc);
|
||||
|
||||
MediaObserver.getInstance().registerObserver(this.dataObserver);
|
||||
|
||||
this.onActive();
|
||||
|
||||
this.updateRightClickMenuList();
|
||||
this.initGridRowCount = this.initGridRowCount.bind(this);
|
||||
this.initGridRowCount();
|
||||
// 后续phone缩略图支持横竖屏后再放开
|
||||
if (AppStorage.Get('deviceType') as string !== Constants.DEFAULT_DEVICE_TYPE) {
|
||||
ScreenManager.getInstance().on(ScreenManager.ON_WIN_SIZE_CHANGED, this.initGridRowCount);
|
||||
if (AppStorage.get('deviceType') as string !== Constants.DEFAULT_DEVICE_TYPE) {
|
||||
ScreenManager.getInstance().on(ScreenManager.ON_WIN_SIZE_CHANGED, this.onWinSizeChangedFunc);
|
||||
}
|
||||
|
||||
let self = this;
|
||||
this.onMenuClicked = this.onMenuClicked.bind(this);
|
||||
this.onMenuClickedForSingleItem = this.onMenuClickedForSingleItem.bind(this);
|
||||
this.broadCast.on(BroadCastConstants.SELECT, function (
|
||||
key: string, value: boolean, isDisableRename: boolean, isDisableDelete: boolean, callback: Function) {
|
||||
self.mSelectManager.toolBarStateToggle(key, value, isDisableRename, isDisableDelete);
|
||||
if (self.mSelectManager.toggle(key, value)) {
|
||||
Log.info(TAG, 'enter event process');
|
||||
callback();
|
||||
this.broadCast.on(BroadCastConstants.SELECT, this.selectFunc);
|
||||
this.mSelectManager.registerCallback('updateCount', (newState: number) => {
|
||||
Log.info(TAG, `updateSelectedCount ${newState}`);
|
||||
if (this.isDataFreeze) {
|
||||
return;
|
||||
}
|
||||
if (this.selectedAlbumsCount === 0 && newState === 0) {
|
||||
this.selectedAlbumsCount--;
|
||||
} else {
|
||||
this.selectedAlbumsCount = newState;
|
||||
}
|
||||
});
|
||||
this.mSelectManager.registerCallback('updateCount', this.freezeAdapter(function (newState: number) {
|
||||
Log.info(TAG, `updateSelectedCount ${newState}`);
|
||||
if (self.selectedAlbumsCount === 0 && newState === 0) {
|
||||
self.selectedAlbumsCount--;
|
||||
} else {
|
||||
self.selectedAlbumsCount = newState;
|
||||
}
|
||||
}));
|
||||
this.mSelectManager.registerCallback('updateToolBarState', this.freezeAdapter(
|
||||
function (isDisableRename: boolean, isDisableDelete: boolean) {
|
||||
this.mSelectManager.registerCallback('updateToolBarState',
|
||||
(isDisableRename: boolean, isDisableDelete: boolean) => {
|
||||
if (this.isDataFreeze) {
|
||||
return;
|
||||
}
|
||||
Log.info(TAG, `updateToolBarState:\
|
||||
isDisableRename: ${isDisableRename}, isDisableDelete: ${isDisableDelete}`);
|
||||
self.isDisableRename = isDisableRename
|
||||
self.isDisableDelete = isDisableDelete
|
||||
})
|
||||
this.isDisableRename = isDisableRename
|
||||
this.isDisableDelete = isDisableDelete
|
||||
}
|
||||
);
|
||||
|
||||
if (Constants.LOCAL_TAB_INDEX == this.currentIndex) {
|
||||
@ -229,18 +220,18 @@ export struct AlbumSetPage {
|
||||
|
||||
aboutToDisappear(): void {
|
||||
this.onInActive();
|
||||
this.broadCast.off(null, null);
|
||||
this.appBroadCast.off(BroadCastConstants.ON_TAB_CHANGED, null);
|
||||
this.appBroadCast.off(BroadCastConstants.RESET_STATE_EVENT, null);
|
||||
this.appBroadCast.off(BroadCastConstants.RESET_ZERO, null);
|
||||
this.appBroadCast.off(BroadCastConstants.ON_REMOTE_CHANGED, null);
|
||||
this.appBroadCast.off(BroadCastConstants.SEND_COPY_OR_MOVE_BROADCAST, null);
|
||||
this.broadCast.off(Constants.ON_LOADING_FINISHED, this.onLoadingFinishedFunc);
|
||||
this.broadCast.off(BroadCastConstants.SELECT, this.selectFunc);
|
||||
this.appBroadCast.off(BroadCastConstants.ON_TAB_CHANGED, this.onTabChangedFunc);
|
||||
this.appBroadCast.off(BroadCastConstants.RESET_STATE_EVENT, this.onStateResetFunc);
|
||||
this.appBroadCast.off(BroadCastConstants.SEND_COPY_OR_MOVE_BROADCAST, this.onSendMoveCopyBroadCastFunc);
|
||||
this.appBroadCast.off(BroadCastConstants.RESET_ZERO, this.onResetZeroFunc);
|
||||
this.appBroadCast.off(BroadCastConstants.ON_REMOTE_CHANGED, this.onUpdateRemoteDeviceFunc);
|
||||
MediaObserver.getInstance().unregisterObserver(this.dataObserver);
|
||||
this.dataObserver.clearSource();
|
||||
// 后续phone缩略图支持横竖屏后再放开
|
||||
if (AppStorage.Get('deviceType') as string !== Constants.DEFAULT_DEVICE_TYPE) {
|
||||
ScreenManager.getInstance().off(ScreenManager.ON_WIN_SIZE_CHANGED, this.initGridRowCount);
|
||||
this.initGridRowCount = null;
|
||||
if (AppStorage.get('deviceType') as string !== Constants.DEFAULT_DEVICE_TYPE) {
|
||||
ScreenManager.getInstance().off(ScreenManager.ON_WIN_SIZE_CHANGED, this.onWinSizeChangedFunc);
|
||||
}
|
||||
}
|
||||
|
||||
@ -276,18 +267,6 @@ export struct AlbumSetPage {
|
||||
}
|
||||
}
|
||||
|
||||
freezeAdapter(fn): Function {
|
||||
let self = this;
|
||||
return function () {
|
||||
if (self.isDataFreeze) {
|
||||
return;
|
||||
}
|
||||
let context = this;
|
||||
let args = arguments;
|
||||
fn.apply(context, args);
|
||||
}
|
||||
}
|
||||
|
||||
onStateReset(index: number): void {
|
||||
if (index == Constants.ALBUM_PAGE_INDEX) {
|
||||
this.isAlbumSetSelectedMode = false;
|
||||
@ -305,6 +284,18 @@ export struct AlbumSetPage {
|
||||
}
|
||||
}
|
||||
|
||||
onLoadingFinished(size: number): void {
|
||||
this.isEmpty = (size == 0);
|
||||
}
|
||||
|
||||
select(key: string, value: boolean, isDisableRename: boolean, isDisableDelete: boolean, callback: Function): void {
|
||||
this.mSelectManager.toolBarStateToggle(key, value, isDisableRename, isDisableDelete);
|
||||
if (this.mSelectManager.toggle(key, value)) {
|
||||
Log.info(TAG, 'enter event process');
|
||||
callback();
|
||||
}
|
||||
}
|
||||
|
||||
onSendMoveCopyBroadCast(index: number): void {
|
||||
if (index == Constants.ALBUM_PAGE_INDEX) {
|
||||
MoveOrCopyBroadCastProp.getInstance().sendMoveOrAddBroadCast(this.broadCast);
|
||||
@ -360,7 +351,7 @@ export struct AlbumSetPage {
|
||||
initGridRowCount(): void {
|
||||
Log.info(TAG, `get screen width is : ${ScreenManager.getInstance().getWinWidth()}`);
|
||||
Log.info(TAG, `get screen height is : ${ScreenManager.getInstance().getWinHeight()}`);
|
||||
let currentBreakpoint = AppStorage.Get<string>('currentBreakpoint');
|
||||
let currentBreakpoint = AppStorage.get<string>('currentBreakpoint');
|
||||
if (currentBreakpoint === Constants.BREAKPOINT_LG && this.deviceType == Constants.PAD_DEVICE_TYPE) {
|
||||
this.gridColumnsCount = UiUtil.getAlbumGridCount(true);
|
||||
} else {
|
||||
@ -369,7 +360,7 @@ export struct AlbumSetPage {
|
||||
Log.info(TAG, `the grid count in a line is: ${this.gridColumnsCount}`);
|
||||
}
|
||||
|
||||
onMediaLibDataChange(changeType) {
|
||||
onMediaLibDataChange(changeType: string): void {
|
||||
Log.info(TAG, `onMediaLibDataChange type: ${changeType}`);
|
||||
if (!this.ignoreLocalNotify) {
|
||||
this.albums.onChange(changeType);
|
||||
@ -390,15 +381,16 @@ export struct AlbumSetPage {
|
||||
Column() {
|
||||
}
|
||||
.width('100%')
|
||||
.height(AppStorage.Get(Constants.KEY_OF_ALBUM_WIDTH))
|
||||
.height(AppStorage.get<string>(Constants.KEY_OF_ALBUM_WIDTH) as string)
|
||||
.key('' + index)
|
||||
} else {
|
||||
AlbumGridItemNewStyle({
|
||||
item: item.data,
|
||||
isSelected: this.isAlbumSetSelectedMode ?
|
||||
this.mSelectManager.isItemSelected(item.data.uri) : false,
|
||||
onMenuClicked: this.onMenuClicked,
|
||||
onMenuClickedForSingleItem: this.onMenuClickedForSingleItem,
|
||||
onMenuClicked: this.onMenuClickedFunc,
|
||||
onMenuClickedForSingleItem: (action: Action, currentAlbum: AlbumInfo): void =>
|
||||
this.onMenuClickedForSingleItem(action, currentAlbum),
|
||||
keyIndex: index,
|
||||
bottomHeight: $bottomHeight
|
||||
})
|
||||
@ -442,7 +434,7 @@ export struct AlbumSetPage {
|
||||
}) {
|
||||
if (!this.isEmpty || this.isTabBarShow) {
|
||||
Column() {
|
||||
AlbumSetPageActionBar({ onMenuClicked: this.onMenuClicked })
|
||||
AlbumSetPageActionBar({ onMenuClicked: this.onMenuClickedFunc })
|
||||
.opacity(this.albumActionBarOpacity)
|
||||
}
|
||||
.backgroundColor($r('app.color.default_background_color'))
|
||||
@ -457,7 +449,7 @@ export struct AlbumSetPage {
|
||||
}
|
||||
|
||||
if (this.isAlbumSetSelectedMode) {
|
||||
AlbumSetPageToolBar({ onMenuClicked: this.onMenuClicked })
|
||||
AlbumSetPageToolBar({ onMenuClicked: this.onMenuClickedFunc })
|
||||
}
|
||||
|
||||
if (this.isEmpty && !this.isTabBarShow) {
|
||||
@ -476,37 +468,28 @@ export struct AlbumSetPage {
|
||||
}
|
||||
let menuContext: MenuContext;
|
||||
let menuOperation: MenuOperation;
|
||||
switch (action.actionID) {
|
||||
case Action.RENAME.actionID:
|
||||
menuContext = new MenuContext();
|
||||
this.onOperationStart = this.onOperationStart.bind(this);
|
||||
this.onOperationEnd = this.onOperationEnd.bind(this);
|
||||
menuContext
|
||||
.withFromSelectMode(false)
|
||||
.withAlbumInfo(currentAlbum)
|
||||
.withOperationStartCallback(this.onOperationStart)
|
||||
.withOperationEndCallback(this.onOperationEnd)
|
||||
.withBroadCast(this.broadCast);
|
||||
menuOperation = MenuOperationFactory.getInstance()
|
||||
.createMenuOperation(AlbumSetRenameMenuOperation, menuContext);
|
||||
menuOperation.doAction();
|
||||
break;
|
||||
case Action.DELETE.actionID:
|
||||
menuContext = new MenuContext();
|
||||
this.onOperationStart = this.onOperationStart.bind(this);
|
||||
this.onOperationEnd = this.onOperationEnd.bind(this);
|
||||
menuContext
|
||||
.withFromSelectMode(false)
|
||||
.withAlbumInfo(currentAlbum)
|
||||
.withOperationStartCallback(this.onOperationStart)
|
||||
.withOperationEndCallback(this.onOperationEnd)
|
||||
.withBroadCast(this.broadCast);
|
||||
menuOperation = MenuOperationFactory.getInstance()
|
||||
.createMenuOperation(AlbumSetDeleteMenuOperation, menuContext);
|
||||
menuOperation.doAction();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
if (action.actionID === Action.RENAME.actionID) {
|
||||
menuContext = new MenuContext();
|
||||
menuContext
|
||||
.withFromSelectMode(false)
|
||||
.withAlbumInfo(currentAlbum)
|
||||
.withOperationStartCallback((): void => this.onOperationStart())
|
||||
.withOperationEndCallback((): void => this.onOperationEnd())
|
||||
.withBroadCast(this.broadCast);
|
||||
menuOperation = MenuOperationFactory.getInstance()
|
||||
.createMenuOperation(AlbumSetRenameMenuOperation, menuContext);
|
||||
menuOperation.doAction();
|
||||
} else if (action.actionID === Action.DELETE.actionID) {
|
||||
menuContext = new MenuContext();
|
||||
menuContext
|
||||
.withFromSelectMode(false)
|
||||
.withAlbumInfo(currentAlbum)
|
||||
.withOperationStartCallback((): void => this.onOperationStart())
|
||||
.withOperationEndCallback((): void => this.onOperationEnd())
|
||||
.withBroadCast(this.broadCast);
|
||||
menuOperation = MenuOperationFactory.getInstance()
|
||||
.createMenuOperation(AlbumSetDeleteMenuOperation, menuContext);
|
||||
menuOperation.doAction();
|
||||
}
|
||||
}
|
||||
|
||||
@ -526,7 +509,7 @@ export struct AlbumSetPage {
|
||||
}
|
||||
}
|
||||
|
||||
private onUpdateRemoteDevice(res, deviceId, size): void {
|
||||
private onUpdateRemoteDevice(res: string, deviceId: string, size: number): void {
|
||||
Log.info(TAG, `onUpdateRemoteDevice size: ${size} deviceId: ${deviceId} type: ${res}`);
|
||||
|
||||
if (res == 'offline') {
|
||||
|
@ -38,11 +38,11 @@ export struct AlbumSetPageActionBar {
|
||||
= ScreenManager.getInstance().isHorizontal();
|
||||
@StorageLink('isSidebar') isSidebar: boolean = ScreenManager.getInstance().isSidebar();
|
||||
@StorageLink('statusBarHeight') statusBarHeight: number = 0;
|
||||
onMenuClicked: Function;
|
||||
onMenuClicked: Function = (): void => {};
|
||||
@State isNeedPlaceholder: boolean = true;
|
||||
@Provide moreMenuList: Action[] = new Array<Action>();
|
||||
@Provide hidePopup: boolean = false;
|
||||
private deviceType: string;
|
||||
private deviceType: string = '';
|
||||
private actionBarPaddingTop: number | Resource = 0;
|
||||
|
||||
updatePlaceholderStatus(): void {
|
||||
@ -62,7 +62,7 @@ export struct AlbumSetPageActionBar {
|
||||
}
|
||||
|
||||
aboutToAppear(): void {
|
||||
this.deviceType = AppStorage.Get<string>('deviceType');
|
||||
this.deviceType = AppStorage.get<string>('deviceType') as string;
|
||||
if (this.deviceType === Constants.PC_DEVICE_TYPE) {
|
||||
this.actionBarPaddingTop = $r('app.float.album_set_page_action_bar_padding_top');
|
||||
} else if (this.deviceType === Constants.PAD_DEVICE_TYPE) {
|
||||
@ -110,7 +110,7 @@ export struct AlbumSetPageActionBar {
|
||||
.setSelectionMode(ActionBarSelectionMode.MULTI);
|
||||
} else {
|
||||
menuList.push(Action.NEW)
|
||||
const deviceType: string = AppStorage.Get('deviceType');
|
||||
const deviceType: string = AppStorage.get('deviceType') as string;
|
||||
if (deviceType === Constants.PC_DEVICE_TYPE) {
|
||||
menuList.push(Action.MULTISELECT)
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ export struct AlbumSetPageToolBar {
|
||||
@Consume('selectedCount') @Watch('updateToolbar') selectedAlbumsCount: number;
|
||||
@Consume isDisableRename: boolean;
|
||||
@Consume isDisableDelete: boolean;
|
||||
onMenuClicked: Function;
|
||||
onMenuClicked: Function = (): void => {};
|
||||
@Provide hidePopup: boolean = false;
|
||||
|
||||
aboutToAppear(): void {
|
||||
|
@ -28,7 +28,7 @@ const TAG: string = 'browser_NewAlbumPageActionBar';
|
||||
|
||||
@Component
|
||||
export struct NewAlbumPageActionBar {
|
||||
onMenuClicked: Function;
|
||||
onMenuClicked: Function = (): void => {};
|
||||
@StorageLink('isHorizontal') @Watch('createActionBar') isHorizontal: boolean = ScreenManager.getInstance()
|
||||
.isHorizontal();
|
||||
@State actionBarProp: ActionBarProp = new ActionBarProp();
|
||||
|
@ -17,6 +17,18 @@ import { Constants, Log } from '@ohos/common';
|
||||
|
||||
const TAG: string = 'browser_RecycleAlbum';
|
||||
|
||||
interface MsgOnError {
|
||||
componentWidth: number;
|
||||
componentHeight: number;
|
||||
}
|
||||
|
||||
interface MsgOnComplete {
|
||||
width: number;
|
||||
height: number;
|
||||
componentWidth: number;
|
||||
componentHeight: number;
|
||||
}
|
||||
|
||||
@Component
|
||||
export struct RecycleAlbum {
|
||||
@State icHeight: number = 0;
|
||||
@ -41,23 +53,19 @@ export struct RecycleAlbum {
|
||||
.width($r('app.float.recycle_album_cover_icon_size'))
|
||||
.height($r('app.float.recycle_album_cover_icon_size'))
|
||||
.fillColor($r('app.color.empty_or_recycle_album_icon'))
|
||||
.onError((msg: {
|
||||
componentWidth: number,
|
||||
componentHeight: number
|
||||
}) => {
|
||||
Log.debug(TAG, `image load failed and its componentWidth is: ${msg.componentWidth}`);
|
||||
Log.debug(TAG, `image load failed and its componentHeight is: ${msg.componentHeight}`);
|
||||
.onError((msg?: MsgOnError) => {
|
||||
if(msg){
|
||||
Log.debug(TAG, `image load failed and its componentWidth is: ${msg.componentWidth}`);
|
||||
Log.debug(TAG, `image load failed and its componentHeight is: ${msg.componentHeight}`);
|
||||
}
|
||||
})
|
||||
.onComplete((msg: {
|
||||
width: number,
|
||||
height: number,
|
||||
componentWidth: number,
|
||||
componentHeight: number
|
||||
}) => {
|
||||
Log.debug(TAG, `image load successfully and its width is: ${msg.width}`);
|
||||
Log.debug(TAG, `image load successfully and its height is: ${msg.height}`);
|
||||
Log.debug(TAG, `image load successfully and its componentWidth is: ${msg.componentWidth}`);
|
||||
Log.debug(TAG, `image load successfully and its componentHeight is: ${msg.componentHeight}`);
|
||||
.onComplete((msg?: MsgOnComplete) => {
|
||||
if(msg){
|
||||
Log.debug(TAG, `image load successfully and its width is: ${msg.width}`);
|
||||
Log.debug(TAG, `image load successfully and its height is: ${msg.height}`);
|
||||
Log.debug(TAG, `image load successfully and its componentWidth is: ${msg.componentWidth}`);
|
||||
Log.debug(TAG, `image load successfully and its componentHeight is: ${msg.componentHeight}`);
|
||||
}
|
||||
})
|
||||
}
|
||||
.height(this.icHeight)
|
||||
|
@ -19,8 +19,8 @@ export struct MouseTurnPageButton {
|
||||
@State buttonBackgroundColor: Resource = $r('app.color.ohos_id_color_whiteIcon_blackPlane')
|
||||
@State isButtonHover: boolean = false
|
||||
@Consume @Watch('handleIconColor') isDefaultBackgroundColor: boolean
|
||||
private isStart: boolean
|
||||
private imageResource: Resource
|
||||
private isStart: boolean = false;
|
||||
private imageResource: Resource | null = null;
|
||||
|
||||
aboutToAppear() {
|
||||
this.imageResource = this.isStart ? $r('app.media.ic_public_arrow_left_swiper')
|
||||
@ -58,8 +58,10 @@ export struct MouseTurnPageButton {
|
||||
width: $r('app.float.mouse_turn_page_button_response_size'),
|
||||
height: $r('app.float.mouse_turn_page_button_response_size')
|
||||
})
|
||||
.onHover((isHover: boolean) => {
|
||||
this.isButtonHover = isHover
|
||||
.onHover((isHover?: boolean) => {
|
||||
if (isHover != null) {
|
||||
this.isButtonHover = isHover
|
||||
}
|
||||
this.handleIconColor()
|
||||
})
|
||||
}
|
||||
|
@ -13,7 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Constants, Log, ScreenManager } from '@ohos/common';
|
||||
import { Constants, Log, PhotoDataSource, ScreenManager } from '@ohos/common';
|
||||
import { MouseTurnPageButton } from './MouseTurnPageButton';
|
||||
|
||||
const TAG: string = 'browser_MouseTurnPageOperation';
|
||||
@ -23,11 +23,11 @@ export struct MouseTurnPageOperation {
|
||||
@State isOnLeftHover: boolean = false
|
||||
@State isOnRightHover: boolean = false
|
||||
@State isOnFirstHover: boolean = false
|
||||
isShowBar: boolean
|
||||
isShowBar: boolean = false
|
||||
@Consume('transitionIndex') currentIndex: number
|
||||
@Prop isPhotoScaled: boolean
|
||||
private controller
|
||||
private dataSource
|
||||
@Prop isPhotoScaled: boolean = false
|
||||
private controller: SwiperController | null = null;
|
||||
private dataSource: PhotoDataSource | null = null;
|
||||
|
||||
aboutToAppear(): void {
|
||||
this.isOnFirstHover = true
|
||||
@ -46,7 +46,7 @@ export struct MouseTurnPageOperation {
|
||||
bottom: $r('app.float.mouse_turn_page_button_margin')
|
||||
})
|
||||
.hitTestBehavior(HitTestMode.Transparent)
|
||||
.onMouse((event: MouseEvent) => {
|
||||
.onMouse((event?: MouseEvent) => {
|
||||
if (this.isOnFirstHover) {
|
||||
this.isOnFirstHover = false
|
||||
this.isOnLeftHover = true
|
||||
@ -68,8 +68,10 @@ export struct MouseTurnPageOperation {
|
||||
Column()
|
||||
.width('100%')
|
||||
.height('100%')
|
||||
.onHover((isHover: boolean) => {
|
||||
this.isOnLeftHover = isHover
|
||||
.onHover((isHover?: boolean) => {
|
||||
if (isHover != null) {
|
||||
this.isOnLeftHover = isHover
|
||||
}
|
||||
})
|
||||
}
|
||||
.hitTestBehavior(HitTestMode.Transparent)
|
||||
@ -84,12 +86,16 @@ export struct MouseTurnPageOperation {
|
||||
MouseTurnPageButton({ isStart: true })
|
||||
.key('LeftMouseTurnPageButton')
|
||||
.onClick(() => {
|
||||
this.controller.showPrevious();
|
||||
if (this.controller != null) {
|
||||
this.controller.showPrevious();
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
.onHover((isHover: boolean) => {
|
||||
this.isOnLeftHover = isHover
|
||||
.onHover((isHover?: boolean) => {
|
||||
if (isHover != null) {
|
||||
this.isOnLeftHover = isHover
|
||||
}
|
||||
})
|
||||
.width($r('app.float.mouse_turn_page_button_response_size'))
|
||||
.height($r('app.float.mouse_turn_page_button_response_size'))
|
||||
@ -106,8 +112,10 @@ export struct MouseTurnPageOperation {
|
||||
Column()
|
||||
.width('100%')
|
||||
.height('100%')
|
||||
.onHover((isHover: boolean) => {
|
||||
this.isOnRightHover = isHover
|
||||
.onHover((isHover?: boolean) => {
|
||||
if (isHover != null) {
|
||||
this.isOnRightHover = isHover
|
||||
}
|
||||
})
|
||||
}
|
||||
.hitTestBehavior(HitTestMode.Transparent)
|
||||
@ -117,17 +125,21 @@ export struct MouseTurnPageOperation {
|
||||
})
|
||||
|
||||
Column() {
|
||||
if (this.isOnRightHover &&
|
||||
if (this.isOnRightHover && this.dataSource != null &&
|
||||
this.currentIndex < this.dataSource.totalCount() - Constants.NUMBER_1) {
|
||||
MouseTurnPageButton({ isStart: false })
|
||||
.key('RightMouseTurnPageButton')
|
||||
.onClick(() => {
|
||||
this.controller.showNext();
|
||||
if (this.controller != null) {
|
||||
this.controller.showNext();
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
.onHover((isHover: boolean) => {
|
||||
this.isOnRightHover = isHover
|
||||
.onHover((isHover?: boolean) => {
|
||||
if (isHover != null) {
|
||||
this.isOnRightHover = isHover
|
||||
}
|
||||
})
|
||||
.width($r('app.float.mouse_turn_page_button_response_size'))
|
||||
.height($r('app.float.mouse_turn_page_button_response_size'))
|
||||
|
@ -37,7 +37,7 @@ export struct PhotoBrowserActionBar {
|
||||
@StorageLink('isSplitMode') isSplitMode: boolean = ScreenManager.getInstance().isSplitMode();
|
||||
@StorageLink('leftBlank') leftBlank: number[]
|
||||
= [0, ScreenManager.getInstance().getStatusBarHeight(), 0, ScreenManager.getInstance().getNaviBarHeight()];
|
||||
onMenuClicked: Function;
|
||||
onMenuClicked: Function = (): void => {};
|
||||
isVideoPage: boolean = false;
|
||||
@StorageLink('isHorizontal') isHorizontal: boolean
|
||||
= ScreenManager.getInstance().isHorizontal();
|
||||
|
@ -27,7 +27,7 @@ export struct PhotoBrowserToolBar {
|
||||
@State opacityValue: number = 1;
|
||||
@State isVisibility: boolean = true;
|
||||
@State currentBackgroundColor: Resource = $r('app.color.default_background_color');
|
||||
onMenuClicked: Function;
|
||||
onMenuClicked: Function = (): void => {};
|
||||
@StorageLink('isSplitMode') isSplitMode: boolean = ScreenManager.getInstance().isSplitMode();
|
||||
@StorageLink('isHorizontal') isHorizontal: boolean = ScreenManager.getInstance().isHorizontal();
|
||||
@StorageLink('leftBlank') leftBlank: number[]
|
||||
|
@ -18,18 +18,27 @@ import { BroadCast, BrowserConstants as PhotoConstants } from '@ohos/common';
|
||||
export struct TipPopup {
|
||||
@State isShowPop: boolean = false;
|
||||
@Consume broadCast: BroadCast;
|
||||
private popAppearFunc: Function = (): void => this.popAppear();
|
||||
private popDisappearFunc: Function = (): void => this.popDisappear();
|
||||
|
||||
private popAppear(): void {
|
||||
this.isShowPop = true;
|
||||
}
|
||||
|
||||
private popDisappear(): void {
|
||||
this.isShowPop = false;
|
||||
}
|
||||
|
||||
aboutToAppear() {
|
||||
this.broadCast.on(PhotoConstants.POP_APPEAR, () => {
|
||||
this.isShowPop = true;
|
||||
});
|
||||
this.broadCast.on(PhotoConstants.POP_DISAPPEAR, () => {
|
||||
this.isShowPop = false;
|
||||
});
|
||||
this.broadCast.on(PhotoConstants.POP_APPEAR, this.popAppearFunc);
|
||||
this.broadCast.on(PhotoConstants.POP_DISAPPEAR, this.popDisappearFunc);
|
||||
}
|
||||
|
||||
aboutToDisappear(): void {
|
||||
this.broadCast.off(null, null);
|
||||
if (this.broadCast) {
|
||||
this.broadCast.off(PhotoConstants.POP_APPEAR, this.popAppearFunc);
|
||||
this.broadCast.off(PhotoConstants.POP_DISAPPEAR, this.popDisappearFunc);
|
||||
}
|
||||
}
|
||||
|
||||
build() {
|
||||
|
@ -23,14 +23,17 @@ import {
|
||||
SelectManager,
|
||||
UserFileManagerAccess
|
||||
} from '@ohos/common';
|
||||
import { BusinessError } from '@ohos.base';
|
||||
|
||||
const TAG: string = 'browser_BatchRecoverMenuOperation';
|
||||
|
||||
export class BatchRecoverMenuOperation extends ProcessMenuOperation {
|
||||
private callbackFunc?: Function;
|
||||
|
||||
constructor(menuContext: MenuContext) {
|
||||
super(menuContext);
|
||||
//初始化绑定this指向
|
||||
this.callback = this.callback.bind(this)
|
||||
this.callbackFunc = (uris: string[]): void => this.callback(uris);
|
||||
}
|
||||
|
||||
doAction(): void {
|
||||
@ -87,7 +90,7 @@ export class BatchRecoverMenuOperation extends ProcessMenuOperation {
|
||||
fileAssets.push(fileItem);
|
||||
operationImpl.recoverFromTrash(fileAssets).then(() => {
|
||||
this.onCompleted()
|
||||
}).catch((error) => {
|
||||
}).catch((error: BusinessError) => {
|
||||
Log.error(TAG, `recover error: ${error}`);
|
||||
this.onError();
|
||||
})
|
||||
|
@ -46,12 +46,9 @@ export class ClearRecycleMenuOperation extends BatchDeleteMenuOperation {
|
||||
return;
|
||||
}
|
||||
|
||||
this.confirmCallback = this.confirmCallback.bind(this);
|
||||
this.cancelCallback = this.cancelCallback.bind(this);
|
||||
|
||||
AppStorage.SetOrCreate<Resource>(Constants.CONFIRM_TEXT_KEY, $r('app.string.dialog_clear'));
|
||||
this.menuContext.broadCast.emit(BroadCastConstants.SHOW_DELETE_DIALOG,
|
||||
[$r('app.string.recycleAlbum_clear_message'), this.confirmCallback, this.cancelCallback]);
|
||||
[$r('app.string.recycleAlbum_clear_message'), (): void => this.confirmCallback(), (): void => this.cancelCallback()]);
|
||||
}
|
||||
|
||||
cancelCallback(): void {
|
||||
|
@ -37,12 +37,12 @@ export struct PhotoGridPageActionBar {
|
||||
@Provide selectedCount: number = 0;
|
||||
@Link @Watch('updateActionBarProp') totalSelectedCount: number;
|
||||
@Consume isEmpty: boolean;
|
||||
title: string;
|
||||
albumInfo: AlbumInfo;
|
||||
isSystemAlbum: boolean;
|
||||
isRecycle: boolean;
|
||||
onMenuClicked: Function;
|
||||
isDistributedAlbum: boolean;
|
||||
title: string = '';
|
||||
albumInfo: AlbumInfo | null = null;
|
||||
isSystemAlbum: boolean = true;
|
||||
isRecycle: boolean = false;
|
||||
onMenuClicked: Function = (): void => {};
|
||||
isDistributedAlbum: boolean = false;
|
||||
@State actionBarProp: ActionBarProp = new ActionBarProp();
|
||||
@StorageLink('statusBarHeight') statusBarHeight: number = 0;
|
||||
|
||||
@ -141,10 +141,12 @@ export struct PhotoGridPageActionBar {
|
||||
return actionBarProp;
|
||||
}
|
||||
|
||||
private getTitle(albumInfo: AlbumInfo): Resource | string {
|
||||
let res = UiUtil.getDisplayNameResourceByAlbumInfo(albumInfo);
|
||||
if (res != null) {
|
||||
return res;
|
||||
private getTitle(albumInfo: AlbumInfo | null): Resource | string {
|
||||
if (albumInfo) {
|
||||
let res = UiUtil.getDisplayNameResourceByAlbumInfo(albumInfo);
|
||||
if (res != null) {
|
||||
return res;
|
||||
}
|
||||
}
|
||||
return this.title;
|
||||
}
|
||||
|
@ -25,9 +25,9 @@ export struct PhotoGridPageToolBar {
|
||||
@Link @Watch('updateToolbar') totalSelectedCount: number;
|
||||
@Provide selectedCount: number = 0;
|
||||
@Consume isEmpty: boolean;
|
||||
isRecycleAlbum: boolean;
|
||||
onMenuClicked: Function;
|
||||
isDistributedAlbum: boolean;
|
||||
isRecycleAlbum: boolean = false;
|
||||
onMenuClicked: Function = (): void => {};
|
||||
isDistributedAlbum: boolean = false;
|
||||
@Provide toolMenuList: Array<Action> = new Array<Action>();
|
||||
@Consume hidePopup: boolean;
|
||||
|
||||
|
@ -40,10 +40,10 @@ export class PhotoEditorManager {
|
||||
}
|
||||
|
||||
static getInstance(): PhotoEditorManager {
|
||||
if (AppStorage.Get(Constants.PHOTO_EDITOR_MANAGER) == null) {
|
||||
if (AppStorage.get(Constants.PHOTO_EDITOR_MANAGER) == null) {
|
||||
AppStorage.SetOrCreate(Constants.PHOTO_EDITOR_MANAGER, new PhotoEditorManager());
|
||||
}
|
||||
return AppStorage.Get(Constants.PHOTO_EDITOR_MANAGER);
|
||||
return AppStorage.get(Constants.PHOTO_EDITOR_MANAGER);
|
||||
}
|
||||
|
||||
initialize(item: MediaItem, albumUri: string, mode: PhotoEditMode, errCallback?: Function): void {
|
||||
|
@ -18,7 +18,7 @@ import { BroadCast, Constants } from '@ohos/common';
|
||||
@Component
|
||||
export struct ActionButton {
|
||||
src: Resource = $r('app.media.alt_placeholder');
|
||||
text: Resource = undefined;
|
||||
text: Resource | null = null;
|
||||
textSize: number | Resource = $r('app.float.buttonActionTextSize_default');
|
||||
isActive: boolean = false;
|
||||
actionID: number = Constants.NEGATIVE_1;
|
||||
@ -27,7 +27,7 @@ export struct ActionButton {
|
||||
widthOfActionButton: number | Resource = $r('app.float.actionButton_default');
|
||||
isCropStyleButton: boolean = false;
|
||||
@Consume broadCast: BroadCast;
|
||||
componentKey: string;
|
||||
componentKey: string = '';
|
||||
|
||||
aboutToAppear() {
|
||||
if (this.text == undefined) {
|
||||
|
@ -34,6 +34,7 @@ export struct CropImageShow {
|
||||
private stateMenuSize: number = ScreenManager.getInstance().getStatusBarHeight();
|
||||
private preTouch: number = Constants.NUMBER_0;
|
||||
private prePinch: number = Constants.NUMBER_0;
|
||||
private onCropResetClickedFunc: Function = (): void => this.onCropResetClicked()
|
||||
|
||||
onCropResetClicked(): void {
|
||||
Log.debug(TAG, 'crop reset is clicked');
|
||||
@ -93,8 +94,8 @@ export struct CropImageShow {
|
||||
|
||||
aboutToAppear(): void {
|
||||
Log.debug(TAG, 'Photo CropImageShow called');
|
||||
this.onCropResetClicked = this.onCropResetClicked.bind(this);
|
||||
this.broadCast.on(Constants.CROP_RESET_CLICKED, this.onCropResetClicked);
|
||||
|
||||
this.broadCast.on(Constants.CROP_RESET_CLICKED, this.onCropResetClickedFunc);
|
||||
this.adjustLayout();
|
||||
}
|
||||
|
||||
@ -106,7 +107,7 @@ export struct CropImageShow {
|
||||
|
||||
aboutToDisappear(): void {
|
||||
this.cropEdit.setCanvasReady(false);
|
||||
this.broadCast.off(Constants.CROP_RESET_CLICKED, this.onCropResetClicked);
|
||||
this.broadCast.off(Constants.CROP_RESET_CLICKED, this.onCropResetClickedFunc);
|
||||
}
|
||||
|
||||
build() {
|
||||
@ -121,18 +122,18 @@ export struct CropImageShow {
|
||||
this.cropEdit.setCanvasReady(true);
|
||||
})
|
||||
}
|
||||
.onTouch((event) => {
|
||||
this.onTouchStart(event);
|
||||
.onTouch((event?: TouchEvent) => {
|
||||
this.onTouchStart(event as TouchEvent);
|
||||
})
|
||||
.gesture(
|
||||
PinchGesture()
|
||||
.onActionStart((event: GestureEvent) => {
|
||||
this.onPinchGestureStart(event);
|
||||
.onActionStart((event?: GestureEvent) => {
|
||||
this.onPinchGestureStart(event as GestureEvent);
|
||||
})
|
||||
.onActionUpdate((event: GestureEvent) => {
|
||||
this.onPinchGestureUpdate(event);
|
||||
.onActionUpdate((event?: GestureEvent) => {
|
||||
this.onPinchGestureUpdate(event as GestureEvent);
|
||||
})
|
||||
.onActionEnd(() => {
|
||||
.onActionEnd((): void => {
|
||||
this.onPinchGestureEnd();
|
||||
})
|
||||
)
|
||||
|
@ -26,6 +26,10 @@ const TAG: string = 'editor_CropModeBar';
|
||||
|
||||
const COMPONENT_KEY_ROTATE: string = 'Rotate';
|
||||
const COMPONENT_KEY_MIRROR: string = 'Mirror';
|
||||
interface RulerProperties {
|
||||
rulerWidth: number;
|
||||
rulerHeight: number;
|
||||
}
|
||||
|
||||
@Component
|
||||
export struct CropModeBar {
|
||||
@ -39,18 +43,15 @@ export struct CropModeBar {
|
||||
@Consume screenHeight: number;
|
||||
@State rulerSwitchOn: boolean = true;
|
||||
@State frameStyleSwitchOn: boolean = true;
|
||||
@StorageLink('rulerProperties') rulerProperties: {
|
||||
rulerWidth: number,
|
||||
rulerHeight: number
|
||||
} = { rulerWidth: 0, rulerHeight: 0 }
|
||||
private rulerChanged: Function = undefined;
|
||||
private resetClicked: Function = undefined;
|
||||
@StorageLink('rulerProperties') rulerProperties: RulerProperties = { rulerWidth: 0, rulerHeight: 0 };
|
||||
private rulerChanged: Function = (): void => {};
|
||||
private resetClicked: Function = (): void => {};
|
||||
private cropRulerBarHeight: number = Constants.VERTICAL_RULER_COMPONENT_HEIGHT;
|
||||
|
||||
aboutToAppear(): void {
|
||||
this.rulerChanged = this.onRulerChanged.bind(this);
|
||||
this.broadCast.on(Constants.RULER_CHANGED, this.rulerChanged);
|
||||
this.resetClicked = this.onResetClicked.bind(this);
|
||||
this.rulerChanged = (number: number): void => this.onRulerChanged(number);
|
||||
this.broadCast.on(Constants.RULER_CHANGED, (): void => this.rulerChanged());
|
||||
this.resetClicked = (): void => this.onResetClicked();
|
||||
this.broadCast.on(Constants.CROP_RESET_CLICKED, this.resetClicked);
|
||||
}
|
||||
|
||||
|
@ -17,6 +17,11 @@ import { BroadCast, Constants, Log, ScreenManager } from '@ohos/common';
|
||||
|
||||
const TAG: string = 'editor_CropRulerBar';
|
||||
|
||||
interface RulerProperties {
|
||||
rulerWidth: number;
|
||||
rulerHeight: number;
|
||||
}
|
||||
|
||||
@Component
|
||||
export struct CropRulerBar {
|
||||
@Consume broadCast: BroadCast;
|
||||
@ -32,17 +37,14 @@ export struct CropRulerBar {
|
||||
private startPos: number = Constants.NUMBER_0;
|
||||
private setting: RenderingContextSettings = new RenderingContextSettings(true);
|
||||
private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.setting);
|
||||
private resetClicked: Function = undefined;
|
||||
private resetClicked: Function = (): void => {};
|
||||
private previous: number = Constants.NUMBER_0;
|
||||
|
||||
setRulerProperties(rulerWidth: number, rulerHeight: number) {
|
||||
AppStorage.SetOrCreate<{
|
||||
rulerWidth: number,
|
||||
rulerHeight: number
|
||||
}>('rulerProperties', {
|
||||
setRulerProperties(rulerWidth: number, rulerHeight: number): void {
|
||||
AppStorage.SetOrCreate<RulerProperties>('rulerProperties', {
|
||||
rulerWidth: rulerWidth,
|
||||
rulerHeight: rulerHeight
|
||||
})
|
||||
} as RulerProperties)
|
||||
}
|
||||
|
||||
iniSize(): void {
|
||||
@ -89,9 +91,9 @@ export struct CropRulerBar {
|
||||
|
||||
drawIntegerLine(cur_x: number, cur_num: number): void {
|
||||
if (!this.isVerticalScreen) {
|
||||
this.context.moveTo((this.rulerWidth * Constants.NUMBER_8_5) / Constants.NUMBER_15, cur_x);
|
||||
this.context.moveTo((this.rulerWidth * 8.5) / 15, cur_x);
|
||||
} else {
|
||||
this.context.moveTo(cur_x, (this.rulerWidth * Constants.NUMBER_8_5) / Constants.NUMBER_15);
|
||||
this.context.moveTo(cur_x, (this.rulerWidth * 8.5) / 15);
|
||||
}
|
||||
|
||||
if (Math.abs(cur_num) > Constants.EDGE_ANGLE) {
|
||||
@ -104,26 +106,26 @@ export struct CropRulerBar {
|
||||
this.context.shadowBlur = Constants.RULER_LINE_WIDTH
|
||||
if (Math.round(cur_num) == Math.round(this.current_def)) {
|
||||
if (!this.isVerticalScreen) {
|
||||
this.context.fillText(this.integerAngleToString(Math.round(cur_num)),
|
||||
(this.rulerWidth * Constants.NUMBER_6) / Constants.NUMBER_15, cur_x);
|
||||
this.context.fillText(this.integerAngleToString(Math.round(cur_num)) as string,
|
||||
(this.rulerWidth * 6) / 15, cur_x);
|
||||
} else {
|
||||
this.context.fillText(this.integerAngleToString(Math.round(cur_num)), cur_x,
|
||||
(this.rulerWidth * Constants.NUMBER_6) / Constants.NUMBER_15);
|
||||
this.context.fillText(this.integerAngleToString(Math.round(cur_num)) as string, cur_x,
|
||||
(this.rulerWidth * 6) / 15);
|
||||
}
|
||||
} else {
|
||||
if (!this.isVerticalScreen) {
|
||||
this.context.fillText((-cur_num).toString(),
|
||||
(this.rulerWidth * Constants.NUMBER_6) / Constants.NUMBER_15, cur_x);
|
||||
(this.rulerWidth * 6) / 15, cur_x);
|
||||
} else {
|
||||
this.context.fillText(cur_num.toString(), cur_x,
|
||||
(this.rulerWidth * Constants.NUMBER_6) / Constants.NUMBER_15);
|
||||
(this.rulerWidth * 6) / 15);
|
||||
}
|
||||
|
||||
}
|
||||
if (!this.isVerticalScreen) {
|
||||
this.context.lineTo(this.rulerWidth * Constants.NUMBER_10_5 / Constants.NUMBER_15, cur_x);
|
||||
this.context.lineTo(this.rulerWidth * 10.5 / 15, cur_x);
|
||||
} else {
|
||||
this.context.lineTo(cur_x, this.rulerWidth * Constants.NUMBER_10_5 / Constants.NUMBER_15);
|
||||
this.context.lineTo(cur_x, this.rulerWidth * 10.5 / 15);
|
||||
}
|
||||
}
|
||||
|
||||
@ -175,36 +177,30 @@ export struct CropRulerBar {
|
||||
}
|
||||
|
||||
onTouchEvent(event: TouchEvent): void {
|
||||
if (event.type == TouchType.Down) {
|
||||
if (this.isVerticalScreen) {
|
||||
this.startPos = (event.touches[0].x);
|
||||
} else {
|
||||
this.startPos = (event.touches[0].y);
|
||||
}
|
||||
let axis = this.isVerticalScreen ? 'x' : 'y';
|
||||
if (event.type === TouchType.Down) {
|
||||
this.startPos = event.touches[0][axis];
|
||||
this.previous = new Date().getTime();
|
||||
}
|
||||
|
||||
if (event.type == TouchType.Move) {
|
||||
let now = new Date().getTime();
|
||||
if (now - this.previous >= Constants.TIMEOUT) {
|
||||
this.previous = now;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
let dir = this.isVerticalScreen ? this.startPos - (event.touches[0].x) :
|
||||
this.startPos - (event.touches[0].y);
|
||||
if (Math.abs(dir / Constants.NUMBER_5) >= Constants.NUMBER_1) {
|
||||
this.current_def += parseInt((dir / Constants.NUMBER_5).toFixed(0));
|
||||
this.startPos = this.isVerticalScreen ? (event.touches[0].x) : (event.touches[0].y);
|
||||
if (Math.abs(this.current_def) > Constants.EDGE_ANGLE) {
|
||||
this.current_def = this.current_def > Constants.EDGE_ANGLE ?
|
||||
Constants.EDGE_ANGLE : -Constants.EDGE_ANGLE;
|
||||
}
|
||||
this.drawRuler();
|
||||
this.broadCast.emit(Constants.RULER_CHANGED, [this.current_def]);
|
||||
}
|
||||
if (event.type !== TouchType.Move) {
|
||||
return;
|
||||
}
|
||||
let now = new Date().getTime();
|
||||
if (now - this.previous < Constants.TIMEOUT) {
|
||||
return;
|
||||
}
|
||||
this.previous = now;
|
||||
let dir = this.startPos - event.touches[0][axis];
|
||||
if (Math.abs(dir / 5) < 1) {
|
||||
return;
|
||||
}
|
||||
this.current_def += Number.parseInt((dir / 5).toFixed(0));
|
||||
this.startPos = event.touches[0][axis];
|
||||
if (Math.abs(this.current_def) > Constants.EDGE_ANGLE) {
|
||||
this.current_def = this.current_def > Constants.EDGE_ANGLE ? Constants.EDGE_ANGLE : -Constants.EDGE_ANGLE;
|
||||
}
|
||||
this.drawRuler();
|
||||
this.broadCast.emit(Constants.RULER_CHANGED, [this.current_def]);
|
||||
}
|
||||
|
||||
onResetClicked(): void {
|
||||
@ -212,33 +208,16 @@ export struct CropRulerBar {
|
||||
this.drawRuler();
|
||||
}
|
||||
|
||||
integerAngleToString(currentAngle: number): string {
|
||||
switch (currentAngle) {
|
||||
case -Constants.NUMBER_40:
|
||||
return Constants.NEGATIVE_FORTY;
|
||||
case -Constants.NUMBER_30:
|
||||
return Constants.NEGATIVE_THIRTY;
|
||||
case -Constants.NUMBER_20:
|
||||
return Constants.NEGATIVE_TWENTY;
|
||||
case -Constants.NUMBER_10:
|
||||
return Constants.NEGATIVE_TEN;
|
||||
case Constants.NUMBER_0:
|
||||
return Constants.ZERO_STR;
|
||||
case Constants.NUMBER_10:
|
||||
return Constants.POSITIVE_TEN;
|
||||
case Constants.NUMBER_20:
|
||||
return Constants.POSITIVE_TWENTY;
|
||||
case Constants.NUMBER_30:
|
||||
return Constants.POSITIVE_THIRTY;
|
||||
case Constants.NUMBER_40:
|
||||
return Constants.POSITIVE_FORTY;
|
||||
default:
|
||||
break;
|
||||
integerAngleToString(currentAngle: number): string | undefined{
|
||||
if (currentAngle % 10 === 0 && Math.abs(currentAngle) <= 40) {
|
||||
return currentAngle.toString();
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
aboutToAppear(): void {
|
||||
this.resetClicked = this.onResetClicked.bind(this);
|
||||
this.resetClicked = (): void => this.onResetClicked();
|
||||
this.broadCast.on(Constants.CROP_RESET_CLICKED, this.resetClicked);
|
||||
this.iniSize();
|
||||
}
|
||||
@ -265,8 +244,8 @@ export struct CropRulerBar {
|
||||
this.drawRuler();
|
||||
})
|
||||
}
|
||||
.onTouch((event) => {
|
||||
this.onTouchEvent(event);
|
||||
.onTouch((event?: TouchEvent) => {
|
||||
this.onTouchEvent(event as TouchEvent);
|
||||
})
|
||||
.width(this.isVerticalScreen ? this.rulerLength : Constants.CROP_RULER_WIDTH)
|
||||
.height(this.isVerticalScreen ? this.rulerWidth : this.rulerLength)
|
||||
|
@ -34,6 +34,10 @@ const COMPONENT_KEY_EDIT_CROP_16_9: string = 'EditCrop_16_9';
|
||||
const COMPONENT_KEY_EDIT_CROP_PORT_FULL: string = 'PortFull';
|
||||
const COMPONENT_KEY_EDIT_CROP_LAND_FULL: string = 'LandFull';
|
||||
|
||||
interface Msg {
|
||||
type: string
|
||||
}
|
||||
|
||||
@Component
|
||||
export struct CropStyleBar {
|
||||
@Consume broadCast: BroadCast;
|
||||
@ -95,8 +99,8 @@ export struct CropStyleBar {
|
||||
}),
|
||||
];
|
||||
@State @Watch('clickEvent') menuChanged: RefreshActionMenu = new RefreshActionMenu(-1, this.mainMenuList);
|
||||
private menuClick: Function = undefined;
|
||||
private resetClick: Function = undefined;
|
||||
private menuClick: Function = (): void => {};
|
||||
private resetClick: Function = (): void => {};
|
||||
|
||||
clickEvent(): void {
|
||||
ActionChangedEvent.isActiveNotChanged(this.menuChanged);
|
||||
@ -127,7 +131,7 @@ export struct CropStyleBar {
|
||||
let id = -1;
|
||||
for (let i = 0; i < this.menuChanged.menuArray.length; i++) {
|
||||
if (this.menuChanged.menuArray[i].isActive) {
|
||||
id = this.menuChanged.menuArray[i].actionID;
|
||||
id = this.menuChanged.menuArray[i].actionID as number;
|
||||
}
|
||||
}
|
||||
|
||||
@ -158,8 +162,8 @@ export struct CropStyleBar {
|
||||
this.cropEdit.onRotationAngleChange();
|
||||
this.isCropReset = this.cropEdit.couldReset();
|
||||
|
||||
let msg = {
|
||||
'Type': BigDataConstants.PHOTO_EDIT_ROTATE
|
||||
let msg: Msg = {
|
||||
type: BigDataConstants.PHOTO_EDIT_ROTATE
|
||||
};
|
||||
ReportToBigDataUtil.report(BigDataConstants.PHOTO_EDIT_TYPE_ID, msg);
|
||||
}
|
||||
@ -167,8 +171,8 @@ export struct CropStyleBar {
|
||||
onMirrorClicked(): void {
|
||||
this.cropEdit.onMirrorChange();
|
||||
this.isCropReset = this.cropEdit.couldReset();
|
||||
let msg = {
|
||||
'Type': BigDataConstants.PHOTO_EDIT_MIRROR
|
||||
let msg: Msg = {
|
||||
type: BigDataConstants.PHOTO_EDIT_MIRROR
|
||||
};
|
||||
ReportToBigDataUtil.report(BigDataConstants.PHOTO_EDIT_TYPE_ID, msg);
|
||||
}
|
||||
@ -176,15 +180,15 @@ export struct CropStyleBar {
|
||||
onResetClicked(): void {
|
||||
this.menuChanged.isChanged = 0;
|
||||
this.isCropReset = this.cropEdit.couldReset();
|
||||
let msg = {
|
||||
'Type': BigDataConstants.PHOTO_EDIT_RESET
|
||||
let msg: Msg = {
|
||||
type: BigDataConstants.PHOTO_EDIT_RESET
|
||||
};
|
||||
ReportToBigDataUtil.report(BigDataConstants.PHOTO_EDIT_TYPE_ID, msg);
|
||||
}
|
||||
|
||||
aboutToAppear(): void {
|
||||
this.menuClick = this.onMenuClicked.bind(this);
|
||||
this.resetClick = this.onResetClicked.bind(this);
|
||||
this.menuClick = (actionID: number | CropRatioType): void => this.onMenuClicked(actionID);
|
||||
this.resetClick = (): void => this.onResetClicked();
|
||||
this.broadCast.on(Constants.UPDATE_MENU, this.menuClick);
|
||||
this.broadCast.on(Constants.CROP_RESET_CLICKED, this.resetClick);
|
||||
}
|
||||
|
@ -22,10 +22,10 @@ export enum ID {
|
||||
DEFAULT
|
||||
}
|
||||
|
||||
interface ActionInfo {
|
||||
export interface ActionInfo {
|
||||
src ?: Resource;
|
||||
isActive ?: boolean;
|
||||
actionID: number | PhotoEditMode;
|
||||
actionID?: number | PhotoEditMode;
|
||||
text ?: Resource;
|
||||
mode ?: number;
|
||||
height ?: Resource;
|
||||
@ -36,23 +36,23 @@ interface ActionInfo {
|
||||
}
|
||||
|
||||
export class ActionButtonInfo {
|
||||
src: Resource;
|
||||
src?: Resource;
|
||||
isActive: boolean;
|
||||
isDoubleClicked: boolean;
|
||||
actionID: number;
|
||||
text: Resource;
|
||||
mode: number;
|
||||
height: Resource;
|
||||
width: Resource
|
||||
color: Resource
|
||||
uri: string;
|
||||
actionID?: number;
|
||||
text: Resource | null = null;
|
||||
mode: number = 0;
|
||||
height: Resource | null = null;
|
||||
width: Resource | null = null;
|
||||
color: Resource | null = null;
|
||||
uri: string = '';
|
||||
componentKey: string;
|
||||
|
||||
constructor(action: ActionInfo) {
|
||||
this.src = action.src == undefined ? undefined : action.src;
|
||||
this.actionID = action.actionID;
|
||||
this.actionID = action.actionID as number;
|
||||
this.isDoubleClicked = false;
|
||||
this.componentKey = action.componentKey;
|
||||
this.componentKey = action.componentKey as string;
|
||||
if (action.isActive != undefined) {
|
||||
this.isActive = action.isActive;
|
||||
} else {
|
||||
|
@ -39,13 +39,13 @@ export struct PcCropModeBar {
|
||||
@State rulerSwitchOn: boolean = true;
|
||||
@State frameStyleSwitchOn: boolean = true;
|
||||
private rulerComponentSize: number = 0;
|
||||
private rulerChanged: Function = undefined;
|
||||
private resetClicked: Function = undefined;
|
||||
private rulerChanged: Function = (): void => {};
|
||||
private resetClicked: Function = (): void => {};
|
||||
|
||||
aboutToAppear() {
|
||||
this.rulerChanged = this.onRulerChanged.bind(this);
|
||||
this.rulerChanged = (number: number): void => this.onRulerChanged(number);
|
||||
this.broadCast.on(Constants.RULER_CHANGED, this.rulerChanged);
|
||||
this.resetClicked = this.onResetClicked.bind(this);
|
||||
this.resetClicked = (): void => this.onResetClicked();
|
||||
this.broadCast.on(Constants.CROP_RESET_CLICKED, this.resetClicked);
|
||||
this.rulerComponentSize = this.screenWidth;
|
||||
Log.debug(TAG, `this.rulerComponentSize = ${this.rulerComponentSize}`);
|
||||
@ -171,8 +171,8 @@ export struct PcCropModeBar {
|
||||
}
|
||||
.width('100%')
|
||||
.margin({ bottom: $r('app.float.crop_vertical_padding_right') })
|
||||
.onClick(() => {
|
||||
this.switchFrameStyle()
|
||||
.onClick((): void => {
|
||||
this.switchFrameStyle();
|
||||
})
|
||||
|
||||
// 剪切风格bar
|
||||
|
@ -29,7 +29,7 @@ export struct PcCropRulerBar {
|
||||
private startPos: number = 0;
|
||||
private setting: RenderingContextSettings = new RenderingContextSettings(true);
|
||||
private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.setting);
|
||||
private resetClicked: Function = undefined;
|
||||
private resetClicked: Function = (): void => {};
|
||||
private previous: number = 0;
|
||||
private rulerLength: number = 0
|
||||
private rulerWidth: number = 0
|
||||
@ -154,38 +154,31 @@ export struct PcCropRulerBar {
|
||||
}
|
||||
}
|
||||
|
||||
onTouchEvent(event: TouchEvent) {
|
||||
if (event.type == TouchType.Down) {
|
||||
if (this.isVerticalScreen) {
|
||||
this.startPos = (event.touches[0].x);
|
||||
} else {
|
||||
this.startPos = (event.touches[0].y);
|
||||
}
|
||||
onTouchEvent(event: TouchEvent): void {
|
||||
let axis = this.isVerticalScreen ? 'x' : 'y';
|
||||
if (event.type === TouchType.Down) {
|
||||
this.startPos = event.touches[0][axis];
|
||||
this.previous = new Date().getTime();
|
||||
}
|
||||
|
||||
if (event.type == TouchType.Move) {
|
||||
let now = new Date().getTime();
|
||||
if (now - this.previous >= Constants.TIMEOUT) {
|
||||
this.previous = now;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
let dir = this.isVerticalScreen ? this.startPos - (event.touches[0].x) :
|
||||
this.startPos - (event.touches[0].y);
|
||||
if (Math.abs(dir / Constants.NUMBER_5) >= Constants.NUMBER_1) {
|
||||
this.current_def += parseInt((dir / Constants.NUMBER_5).toFixed(0));
|
||||
this.startPos = this.isVerticalScreen ? (event.touches[0].x) : (event.touches[0].y)
|
||||
if (Math.abs(this.current_def) > Constants.EDGE_ANGLE) {
|
||||
this.current_def = this.current_def > Constants.EDGE_ANGLE ?
|
||||
Constants.EDGE_ANGLE : -Constants.EDGE_ANGLE;
|
||||
}
|
||||
|
||||
this.drawRuler();
|
||||
this.broadCast.emit(Constants.RULER_CHANGED, [this.current_def]);
|
||||
}
|
||||
if (event.type !== TouchType.Move) {
|
||||
return;
|
||||
}
|
||||
let now = new Date().getTime();
|
||||
if (now - this.previous < Constants.TIMEOUT) {
|
||||
return;
|
||||
}
|
||||
this.previous = now;
|
||||
let dir = this.startPos - event.touches[0][axis];
|
||||
if (Math.abs(dir / 5) < 1) {
|
||||
return;
|
||||
}
|
||||
this.current_def += Number.parseInt((dir / 5).toFixed(0));
|
||||
this.startPos = event.touches[0][axis];
|
||||
if (Math.abs(this.current_def) > Constants.EDGE_ANGLE) {
|
||||
this.current_def = this.current_def > Constants.EDGE_ANGLE ? Constants.EDGE_ANGLE : -Constants.EDGE_ANGLE;
|
||||
}
|
||||
this.drawRuler();
|
||||
this.broadCast.emit(Constants.RULER_CHANGED, [this.current_def]);
|
||||
}
|
||||
|
||||
onResetClicked() {
|
||||
@ -193,33 +186,16 @@ export struct PcCropRulerBar {
|
||||
this.drawRuler();
|
||||
}
|
||||
|
||||
integerAngleToString(currentAngle: number): string {
|
||||
switch (currentAngle) {
|
||||
case -Constants.NUMBER_40:
|
||||
return Constants.NEGATIVE_FORTY;
|
||||
case -Constants.NUMBER_30:
|
||||
return Constants.NEGATIVE_THIRTY;
|
||||
case -Constants.NUMBER_20:
|
||||
return Constants.NEGATIVE_TWENTY;
|
||||
case -Constants.NUMBER_10:
|
||||
return Constants.NEGATIVE_TEN;
|
||||
case Constants.NUMBER_0:
|
||||
return Constants.ZERO_STR;
|
||||
case Constants.NUMBER_10:
|
||||
return Constants.POSITIVE_TEN;
|
||||
case Constants.NUMBER_20:
|
||||
return Constants.POSITIVE_TWENTY;
|
||||
case Constants.NUMBER_30:
|
||||
return Constants.POSITIVE_THIRTY;
|
||||
case Constants.NUMBER_40:
|
||||
return Constants.POSITIVE_FORTY;
|
||||
default:
|
||||
break;
|
||||
integerAngleToString(currentAngle: number): string | undefined {
|
||||
if (currentAngle % 10 === 0 && Math.abs(currentAngle) <= 40) {
|
||||
return currentAngle.toString();
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
aboutToAppear() {
|
||||
this.resetClicked = this.onResetClicked.bind(this);
|
||||
this.resetClicked = (): void => this.onResetClicked();
|
||||
this.broadCast.on(Constants.CROP_RESET_CLICKED, this.resetClicked);
|
||||
this.iniSize()
|
||||
}
|
||||
@ -247,8 +223,8 @@ export struct PcCropRulerBar {
|
||||
this.drawRuler()
|
||||
})
|
||||
}
|
||||
.onTouch((event) => {
|
||||
this.onTouchEvent(event);
|
||||
.onTouch((event?: TouchEvent) => {
|
||||
this.onTouchEvent(event as TouchEvent);
|
||||
})
|
||||
.backgroundColor('#33000000')
|
||||
.borderRadius($r('app.float.edit_menu_item_radius'))
|
||||
|
@ -98,8 +98,8 @@ export struct PcCropStyleBar {
|
||||
}),
|
||||
];
|
||||
@State @Watch('clickEvent') menuChanged: RefreshActionMenu = new RefreshActionMenu(-1, this.mainMenuList);
|
||||
private menuClick: Function = undefined;
|
||||
private resetClick: Function = undefined;
|
||||
private menuClick: Function = (): void => {};
|
||||
private resetClick: Function = (): void => {};
|
||||
|
||||
clickEvent() {
|
||||
ActionChangedEvent.isActiveNotChanged(this.menuChanged);
|
||||
@ -126,11 +126,11 @@ export struct PcCropStyleBar {
|
||||
}
|
||||
}
|
||||
|
||||
onRotateClicked() {
|
||||
onRotateClicked(): void {
|
||||
let id = -1;
|
||||
for (let i = 0; i < this.menuChanged.menuArray.length; i++) {
|
||||
if (this.menuChanged.menuArray[i].isActive) {
|
||||
id = this.menuChanged.menuArray[i].actionID;
|
||||
id = this.menuChanged.menuArray[i].actionID as number;
|
||||
}
|
||||
}
|
||||
|
||||
@ -173,8 +173,8 @@ export struct PcCropStyleBar {
|
||||
}
|
||||
|
||||
aboutToAppear() {
|
||||
this.menuClick = this.onMenuClicked.bind(this);
|
||||
this.resetClick = this.onResetClicked.bind(this);
|
||||
this.menuClick = (actionID: number | CropRatioType): void => this.onMenuClicked(actionID);
|
||||
this.resetClick = (): void => this.onResetClicked();
|
||||
this.broadCast.on(Constants.UPDATE_MENU, this.menuClick);
|
||||
this.broadCast.on(Constants.CROP_RESET_CLICKED, this.resetClick);
|
||||
}
|
||||
|
@ -22,11 +22,13 @@ import {
|
||||
Constants,
|
||||
Log,
|
||||
ReportToBigDataUtil,
|
||||
UiUtil
|
||||
UiUtil,
|
||||
WindowUtil
|
||||
} from '@ohos/common';
|
||||
import { PhotoEditorManager } from '../PhotoEditorManager';
|
||||
import { PhotoEditCrop } from '../crop/PhotoEditCrop';
|
||||
import router from '@ohos.router';
|
||||
import { Router } from '@ohos.arkui.UIContext';
|
||||
|
||||
const TAG: string = 'editor_TitleBar';
|
||||
|
||||
@ -34,7 +36,7 @@ const TAG: string = 'editor_TitleBar';
|
||||
export struct TitleBar {
|
||||
@Consume isRedo: boolean;
|
||||
@Consume isUndo: boolean;
|
||||
@State name: Resource = undefined;
|
||||
@State name: Resource | undefined = undefined;
|
||||
@State isPcStyle: boolean = true;
|
||||
@Consume('selected') selectedMode: number;
|
||||
@Consume broadCast: BroadCast;
|
||||
@ -44,25 +46,31 @@ export struct TitleBar {
|
||||
@Consume cropEdit: PhotoEditCrop;
|
||||
private appBroadCast: BroadCast = BroadCastManager.getInstance().getBroadCast();
|
||||
private newImageId: number = -1;
|
||||
private immersiveClick: Function = undefined;
|
||||
private onBackAfterSaveComplete: Function = undefined;
|
||||
private immersiveClick: Function = (): void => {};
|
||||
private onBackAfterSaveComplete: Function = (): void => {};
|
||||
|
||||
saveAsNewCallback() {
|
||||
Log.debug(TAG, 'saveAsNewCallback called');
|
||||
let msg = {
|
||||
'SAVE_TYPE': BigDataConstants.SAVE_AS_NEW
|
||||
interface Msg {
|
||||
saveType: string;
|
||||
}
|
||||
let msg: Msg = {
|
||||
saveType: BigDataConstants.SAVE_AS_NEW
|
||||
}
|
||||
ReportToBigDataUtil.report(BigDataConstants.PHOTO_EDIT_SAVE_ID, msg);
|
||||
PhotoEditorManager.getInstance().save(false, this.saveImageCallback.bind(this));
|
||||
PhotoEditorManager.getInstance().save(false, (uri: string): void => this.saveImageCallback(uri));
|
||||
}
|
||||
|
||||
replaceOriginalCallback() {
|
||||
replaceOriginalCallback(): void {
|
||||
Log.debug(TAG, 'replaceOriginalCallback called');
|
||||
let msg = {
|
||||
'SAVE_TYPE': BigDataConstants.SAVE_REPLACE
|
||||
interface Msg {
|
||||
saveType: string;
|
||||
}
|
||||
let msg: Msg = {
|
||||
saveType: BigDataConstants.SAVE_REPLACE
|
||||
}
|
||||
ReportToBigDataUtil.report(BigDataConstants.PHOTO_EDIT_SAVE_ID, msg);
|
||||
PhotoEditorManager.getInstance().save(true, this.saveImageCallback.bind(this));
|
||||
PhotoEditorManager.getInstance().save(true, (uri: string): void => this.saveImageCallback(uri));
|
||||
}
|
||||
|
||||
discardCallback() {
|
||||
@ -90,9 +98,9 @@ export struct TitleBar {
|
||||
}
|
||||
|
||||
aboutToAppear() {
|
||||
this.immersiveClick = this.immersive.bind(this);
|
||||
this.immersiveClick = (isImmersive: boolean): void => this.immersive(isImmersive);
|
||||
this.broadCast.on(Constants.IS_IMMERSIVE, this.immersiveClick);
|
||||
this.onBackAfterSaveComplete = this.backAfterSaveComplete.bind(this);
|
||||
this.onBackAfterSaveComplete = (): void => this.backAfterSaveComplete();
|
||||
this.appBroadCast.on(BroadCastConstants.PHOTO_EDIT_SAVE_COMPLETE, this.onBackAfterSaveComplete);
|
||||
}
|
||||
|
||||
@ -105,27 +113,33 @@ export struct TitleBar {
|
||||
this.isImmersive = isImmersive;
|
||||
}
|
||||
|
||||
onBackClicked() {
|
||||
onBackClicked(): void {
|
||||
Log.debug(TAG, 'back clicked');
|
||||
if (this.isRedo || this.isUndo) {
|
||||
this.broadCast.emit(BroadCastConstants.SHOW_EDIT_EXIT_PHOTO_DIALOG, [this.discardCallback.bind(this)]);
|
||||
this.broadCast.emit(BroadCastConstants.SHOW_EDIT_EXIT_PHOTO_DIALOG, [(): void => this.discardCallback()]);
|
||||
} else if (this.selectedMode == PhotoEditMode.EDIT_MODE_CROP && this.cropEdit.couldReset()) {
|
||||
this.broadCast.emit(BroadCastConstants.SHOW_EDIT_EXIT_PHOTO_DIALOG, [this.discardCallback.bind(this)]);
|
||||
this.broadCast.emit(BroadCastConstants.SHOW_EDIT_EXIT_PHOTO_DIALOG, [(): void => this.discardCallback()]);
|
||||
} else {
|
||||
router.back();
|
||||
router.back({
|
||||
url: '',
|
||||
params: {}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
onSaveClicked() {
|
||||
onSaveClicked(): void {
|
||||
Log.info(TAG, 'save clicked');
|
||||
if (this.isRedo || this.isRedo) {
|
||||
this.broadCast.emit(BroadCastConstants.SHOW_SAVE_PHOTO_DIALOG,
|
||||
[this.saveAsNewCallback.bind(this), this.replaceOriginalCallback.bind(this)]);
|
||||
[(): void => this.saveAsNewCallback(), (): void => this.replaceOriginalCallback()]);
|
||||
} else if (this.selectedMode == PhotoEditMode.EDIT_MODE_CROP && this.cropEdit.couldReset()) {
|
||||
this.broadCast.emit(BroadCastConstants.SHOW_SAVE_PHOTO_DIALOG,
|
||||
[this.saveAsNewCallback.bind(this), this.replaceOriginalCallback.bind(this)]);
|
||||
[(): void => this.saveAsNewCallback(), (): void => this.replaceOriginalCallback()]);
|
||||
} else {
|
||||
router.back();
|
||||
router.back({
|
||||
url: '',
|
||||
params: {}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
import { ActionButton } from './ActionButton';
|
||||
import { BroadCast, Constants, Log } from '@ohos/common';
|
||||
import { ActionButtonInfo } from './MainMenuInfo';
|
||||
import { ActionButtonInfo, ActionInfo } from './MainMenuInfo';
|
||||
import { ActionChangedEvent, RefreshActionMenu } from './RefreshMenu';
|
||||
import { PhotoEditMode } from '../base/PhotoEditType';
|
||||
import { PhotoEditorManager } from '../PhotoEditorManager';
|
||||
@ -40,22 +40,22 @@ export struct ToolBar {
|
||||
@Consume titleSize: number;
|
||||
@Consume isRedo: boolean;
|
||||
@Consume isUndo: boolean;
|
||||
private actionInfo: ActionInfo = {
|
||||
src: $r('app.media.ic_edit_photo_toolbar_crop'),
|
||||
// 加入其它按钮时改为PhotoEditMode.EDIT_MODE_CROP
|
||||
actionID: PhotoEditMode.EDIT_MODE_CROP,
|
||||
text: $r('app.string.crop_text'),
|
||||
isActive: true,
|
||||
componentKey: COMPONENT_KEY_Edit_CROP
|
||||
};
|
||||
mainMenuList: Array<ActionButtonInfo> = [
|
||||
new ActionButtonInfo({
|
||||
src: $r('app.media.ic_edit_photo_toolbar_crop'),
|
||||
|
||||
// 加入其它按钮时改为PhotoEditMode.EDIT_MODE_CROP
|
||||
actionID: undefined,
|
||||
text: $r('app.string.crop_text'),
|
||||
isActive: true,
|
||||
componentKey: COMPONENT_KEY_Edit_CROP
|
||||
})
|
||||
new ActionButtonInfo(this.actionInfo)
|
||||
];
|
||||
// 2022年8月11日 @Watch('clickEvent')打包报错 @State @Watch('clickEvent') menuChanged: RefreshActionMenu = new RefreshActionMenu(-1, this.mainMenuList);
|
||||
@State menuChanged: RefreshActionMenu = new RefreshActionMenu(-1, this.mainMenuList);
|
||||
private textSize: number | Resource = $r('app.float.buttonActionTextSize_default');
|
||||
private menuClick: Function = undefined;
|
||||
private immersiveClick: Function = undefined;
|
||||
private menuClick: Function = (): void => {};
|
||||
private immersiveClick: Function = (): void => {};
|
||||
|
||||
clickEvent() {
|
||||
ActionChangedEvent.isActiveNotChanged(this.menuChanged);
|
||||
@ -96,8 +96,8 @@ export struct ToolBar {
|
||||
}
|
||||
|
||||
aboutToAppear() {
|
||||
this.menuClick = this.onMenuClick.bind(this);
|
||||
this.immersiveClick = this.immersive.bind(this);
|
||||
this.menuClick = (actionID: number): void => this.onMenuClick(actionID);
|
||||
this.immersiveClick = (isImmersive: boolean): void => this.immersive(isImmersive);
|
||||
this.broadCast.on(Constants.UPDATE_MENU, this.menuClick);
|
||||
this.broadCast.on(Constants.IS_IMMERSIVE, this.immersiveClick);
|
||||
|
||||
|
@ -19,6 +19,7 @@ import formBindingData from '@ohos.application.formBindingData';
|
||||
import { Constants } from '../common/Constants';
|
||||
import formProvider from '@ohos.application.formProvider';
|
||||
import type Want from '@ohos.app.ability.Want';
|
||||
import common from '@ohos.app.ability.common';
|
||||
|
||||
const TAG: string = 'formA_The_FormController';
|
||||
|
||||
@ -59,18 +60,18 @@ export class FormController implements FormListener {
|
||||
Log.info(TAG, `bindFormData start formId: ${formId} fd:${fd}`);
|
||||
let image: string = this.imageHashCode(fd, formId);
|
||||
let dataObj: object = {
|
||||
'fd': fd === -1 ? false : true,
|
||||
'image0': 'memory://' + image,
|
||||
'image1': 'memory://' + image,
|
||||
'indexValue': this.indexValue,
|
||||
'albumName': this.mediaDataManager.getCurrentAlbumName(),
|
||||
'currentIndex': this.mediaDataManager.getCurrentIndex(),
|
||||
'isShow': this.mediaDataManager.getIsShowAlbumName(),
|
||||
'formImages': JSON.parse(`{ "${image}": ${fd} }`),
|
||||
'uri': (this.mediaDataManager.getMediaData().currentUri !== '') ?
|
||||
commonConstants.ACTION_URI_FORM_ABILITY : commonConstants.ACTION_URI_FORM_ABILITY_NONE,
|
||||
'albumUri': `${this.mediaDataManager.getMediaData().albumUri}`,
|
||||
'currentUri': this.mediaDataManager.getMediaData().currentUri
|
||||
fd: fd !== -1,
|
||||
image0: 'memory://' + image,
|
||||
image1: 'memory://' + image,
|
||||
indexValue: this.indexValue,
|
||||
albumName: this.mediaDataManager.getCurrentAlbumName(),
|
||||
currentIndex: this.mediaDataManager.getCurrentIndex(),
|
||||
isShow: this.mediaDataManager.getIsShowAlbumName(),
|
||||
formImages: JSON.parse(`{ "${image}": ${fd} }`),
|
||||
uri: this.mediaDataManager.getMediaData().currentUri !==
|
||||
'' ? commonConstants.ACTION_URI_FORM_ABILITY : commonConstants.ACTION_URI_FORM_ABILITY_NONE,
|
||||
albumUri: `${this.mediaDataManager.getMediaData().albumUri}`,
|
||||
currentUri: this.mediaDataManager.getMediaData().currentUri
|
||||
};
|
||||
Log.debug(TAG, `bindFormData, createFormBindingData dataObj2.data: ${JSON.stringify(dataObj)}`);
|
||||
let obj: formBindingData.FormBindingData = formBindingData.createFormBindingData(JSON.stringify(dataObj));
|
||||
@ -135,7 +136,8 @@ export class FormController implements FormListener {
|
||||
};
|
||||
Log.debug(TAG, `routerPhotoBrowser parm ${JSON.stringify(param)}`);
|
||||
|
||||
globalThis.formContext.startAbility(param).then(() => {
|
||||
let context: common.UIAbilityContext = AppStorage.get<common.UIAbilityContext>('formContext');
|
||||
context.startAbility(param).then((): void => {
|
||||
AppStorage.Delete(Constants.FROM_CONTROLLER_MANAGER);
|
||||
})
|
||||
|
||||
|
@ -19,6 +19,7 @@ import { AlbumDefine, DataStoreUtil, Log, MediaConstants, UserFileManagerAccess,
|
||||
import resourceManager from '@ohos.resourceManager';
|
||||
import type { FormListener } from '../controller/FormController';
|
||||
import userFileManager from '@ohos.filemanagement.userFileManager';
|
||||
import common from '@ohos.app.ability.common';
|
||||
|
||||
const TAG: string = 'formA_MediaDataManager';
|
||||
|
||||
@ -45,7 +46,8 @@ export class MediaDataManager {
|
||||
await this.initShowName();
|
||||
if (this.mediaData == null || this.mediaData == undefined) {
|
||||
Log.info(TAG, `initData new MediaData! form ${formId}`);
|
||||
let mgr: resourceManager.ResourceManager = globalThis.formContext.resourceManager;
|
||||
let context = AppStorage.get<common.FormExtensionContext>('formContext');
|
||||
let mgr: resourceManager.ResourceManager = context.resourceManager as resourceManager.ResourceManager;
|
||||
let displayName = await mgr.getStringValue($r('app.string.album_photos').id);
|
||||
let albumUri = this.mediaModel.getSystemAlbumUri(UserFileManagerAccess.IMAGE_ALBUM_SUB_TYPE);
|
||||
this.mediaData = new MediaData(formId, displayName, displayName, albumUri, '', 0,
|
||||
|
@ -38,8 +38,19 @@ export class SelectParams {
|
||||
isMultiPick: boolean;
|
||||
/* caller bundle name */
|
||||
bundleName: string;
|
||||
/* whether picker from Camera */
|
||||
cameraAble: boolean;
|
||||
/* whether picker can edit */
|
||||
editAble: boolean;
|
||||
uri: string;
|
||||
itemDisplayName: unknown;
|
||||
itemId: string;
|
||||
isFirstEnter: boolean;
|
||||
itemCount: number;
|
||||
itemCoverUri: string;
|
||||
remainingOfWallpapers: number;
|
||||
|
||||
static defaultParam() {
|
||||
static defaultParam(): SelectParams {
|
||||
return {
|
||||
maxSelectCount: Constants.DEFAULT_MAX_THIRD_SELECT_COUNT,
|
||||
filterMediaType: AlbumDefine.FILTER_MEDIA_TYPE_ALL,
|
||||
@ -47,11 +58,19 @@ export class SelectParams {
|
||||
isFromFa: false,
|
||||
isFromFaPhoto: false,
|
||||
isMultiPick: false,
|
||||
bundleName: ''
|
||||
}
|
||||
bundleName: '',
|
||||
cameraAble: true,
|
||||
editAble: true,
|
||||
uri: '',
|
||||
itemDisplayName: undefined,
|
||||
itemId: '',
|
||||
isFirstEnter: false,
|
||||
itemCount: 0,
|
||||
itemCoverUri: '',
|
||||
remainingOfWallpapers: 0
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/* storage key begin */
|
||||
export const THIRD_SELECT_IS_ORIGIN = 'third_select_is_origin';
|
||||
|
||||
|
@ -16,6 +16,9 @@
|
||||
import { AlbumDefine, BigDataConstants, Constants, Log, ReportToBigDataUtil } from '@ohos/common';
|
||||
import wantConstant from '@ohos.ability.wantConstant';
|
||||
import { SelectParams } from '../utils/ThirdSelectConstants';
|
||||
import ability from '@ohos.ability.ability';
|
||||
import common from '@ohos.app.ability.common';
|
||||
import Want from '@ohos.app.ability.Want';
|
||||
|
||||
const TAG: string = 'thiSel_CameraGridItemComponent';
|
||||
|
||||
@ -24,7 +27,7 @@ export struct CameraGridItemComponent {
|
||||
selectParams: SelectParams = SelectParams.defaultParam();
|
||||
resultUri: string = '';
|
||||
@Consume @Watch('onShow') isShow: boolean;
|
||||
updateDataFunc: Function;
|
||||
updateDataFunc: Function = (): void => {};
|
||||
|
||||
aboutToAppear(): void {
|
||||
Log.info(TAG, `aboutToAppear`);
|
||||
@ -64,11 +67,19 @@ export struct CameraGridItemComponent {
|
||||
.key('PickerCamera')
|
||||
.justifyContent(FlexAlign.Center)
|
||||
.alignItems(HorizontalAlign.Center)
|
||||
.onClick((event: ClickEvent) => {
|
||||
.onClick((event?: ClickEvent) => {
|
||||
this.jumpCameraTakePhoto().then((result) => {
|
||||
Log.info(TAG, `resourceUri = ${JSON.stringify(result)}`);
|
||||
this.resultUri = result?.want?.parameters?.resourceUri;
|
||||
}).catch((err) => {
|
||||
let want: Want | null = result.want as Want;
|
||||
if(want == null || want.parameters == null) return;
|
||||
this.resultUri = want.parameters['resourceUri'] as string;
|
||||
|
||||
if (this.resultUri?.length > 0) {
|
||||
|
||||
this.isShow = true;
|
||||
this.onShow();
|
||||
}
|
||||
}).catch((err: Error) => {
|
||||
Log.error(TAG, `jumpCameraTakephoto err: ${err}`);
|
||||
});
|
||||
})
|
||||
@ -88,20 +99,26 @@ export struct CameraGridItemComponent {
|
||||
}
|
||||
}
|
||||
|
||||
private async jumpCameraTakePhoto(): Promise<any> {
|
||||
private async jumpCameraTakePhoto(): Promise<ability.AbilityResult> {
|
||||
let action = this.selectParams.filterMediaType == AlbumDefine.FILTER_MEDIA_TYPE_VIDEO
|
||||
? wantConstant.Action.ACTION_VIDEO_CAPTURE
|
||||
: wantConstant.Action.ACTION_IMAGE_CAPTURE;
|
||||
let uri = this.selectParams.filterMediaType == AlbumDefine.FILTER_MEDIA_TYPE_VIDEO
|
||||
? Constants.CAMERA_TYPE_VIDEO
|
||||
: Constants.CAMERA_TYPE_CAPTURE;
|
||||
ReportToBigDataUtil.report(BigDataConstants.SELECT_PICKER_CLICK_CAMERA_ID, { 'action': action });
|
||||
interface Msg {
|
||||
action: wantConstant.Action
|
||||
}
|
||||
let msg: Msg = {
|
||||
action: action
|
||||
}
|
||||
ReportToBigDataUtil.report(BigDataConstants.SELECT_PICKER_CLICK_CAMERA_ID, msg);
|
||||
|
||||
let supportMultiMode: boolean = (this.selectParams.filterMediaType == AlbumDefine.FILTER_MEDIA_TYPE_ALL);
|
||||
let want = {
|
||||
'action': action,
|
||||
'bundleName': Constants.CAMERA_BUNDLE_NAME,
|
||||
'parameters': {
|
||||
let want: Want = {
|
||||
action: action,
|
||||
bundleName: Constants.CAMERA_BUNDLE_NAME,
|
||||
parameters: {
|
||||
uri: uri,
|
||||
supportMultiMode: supportMultiMode,
|
||||
callBundleName: this.selectParams.bundleName
|
||||
@ -109,7 +126,8 @@ export struct CameraGridItemComponent {
|
||||
};
|
||||
|
||||
Log.debug(TAG, `jump camera want: ${JSON.stringify(want)}`);
|
||||
let result = await globalThis.photosAbilityContext.startAbilityForResult(want);
|
||||
let context: common.UIAbilityContext = AppStorage.get<common.UIAbilityContext>('photosAbilityContext') as common.UIAbilityContext;
|
||||
let result = await context.startAbilityForResult(want);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -118,16 +136,17 @@ export struct CameraGridItemComponent {
|
||||
Log.error(TAG, `no valid uri!`);
|
||||
return;
|
||||
}
|
||||
let abilityResult = {
|
||||
'resultCode': 0,
|
||||
'want': {
|
||||
'parameters': {
|
||||
let abilityResult: ability.AbilityResult = {
|
||||
resultCode: (uri == null || uri.length <= 0) ? -1 : 0,
|
||||
want: {
|
||||
parameters: {
|
||||
'select-item-list': [uri],
|
||||
}
|
||||
}
|
||||
};
|
||||
globalThis.photosAbilityContext.terminateSelfWithResult(abilityResult).then((result) => {
|
||||
Log.info(TAG, `terminateSelf result: ${result}`);
|
||||
let context: common.UIAbilityContext = AppStorage.get<common.UIAbilityContext>('photosAbilityContext') as common.UIAbilityContext;
|
||||
context.terminateSelfWithResult(abilityResult as ability.AbilityResult).then((result: void) => {
|
||||
Log.info(TAG, `terminateSelfWithResult abilityResult: ${abilityResult} result: ${result}`);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -24,10 +24,10 @@ import {
|
||||
ScreenManager,
|
||||
UiUtil
|
||||
} from '@ohos/common';
|
||||
import router from '@ohos.router';
|
||||
import { SelectParams } from '../utils/ThirdSelectConstants';
|
||||
import { EmptyAlbumComponent } from '@ohos/browser/BrowserComponents';
|
||||
import Router from '@system.router';
|
||||
import { Router } from '@ohos.arkui.UIContext';
|
||||
import router from '@ohos.router';
|
||||
|
||||
const TAG: string = 'thiSel_ThirdAlbumGridItem';
|
||||
|
||||
@ -44,7 +44,7 @@ export struct ThirdAlbumGridItem {
|
||||
MASK_LAYER_HEIGHT = '50%';
|
||||
@State transformV: number = 0;
|
||||
@State isEmptyAlbum: boolean = false;
|
||||
isFirstEnter: boolean;
|
||||
isFirstEnter: boolean = false;
|
||||
@Consume selectParams: SelectParams;
|
||||
private staticIconList = new Map([
|
||||
[AlbumDefine.ALBUM_ID_VIDEO, $r('app.media.ic_video')],
|
||||
@ -52,7 +52,7 @@ export struct ThirdAlbumGridItem {
|
||||
]);
|
||||
private appBroadCast: BroadCast = BroadCastManager.getInstance().getBroadCast();
|
||||
private fp2vpUnit: number = px2vp(fp2px(Constants.NUMBER_1));
|
||||
onWindowSizeChangeCallBack = () => this.updateCardSize();
|
||||
private onWindowSizeChangeCallBack: Function = (): void => this.updateCardSize();
|
||||
|
||||
aboutToAppear(): void {
|
||||
Log.info(TAG, `aboutToAppear + ${this.item.coverUri}, select param ${JSON.stringify(this.selectParams)}`)
|
||||
@ -66,7 +66,6 @@ export struct ThirdAlbumGridItem {
|
||||
aboutToDisappear(): void {
|
||||
Log.info(TAG, 'aboutToDisappear');
|
||||
ScreenManager.getInstance().off(ScreenManager.ON_WIN_SIZE_CHANGED, this.onWindowSizeChangeCallBack);
|
||||
this.onWindowSizeChangeCallBack = null;
|
||||
}
|
||||
|
||||
updateCardSize() {
|
||||
@ -169,15 +168,16 @@ export struct ThirdAlbumGridItem {
|
||||
.border({
|
||||
radius: $r('sys.float.ohos_id_corner_radius_default_m')
|
||||
})
|
||||
.onClick(this.handleClick.bind(this))
|
||||
.onClick((): void => this.handleClick())
|
||||
|
||||
}
|
||||
|
||||
private handleClick() {
|
||||
private handleClick(): void {
|
||||
if (this.selectParams.isFromFa && (!this.selectParams.isFromFaPhoto)) {
|
||||
this.appBroadCast.emit(BroadCastConstants.SAVE_FORM_EDITOR_DATA,
|
||||
[this.item.albumName, this.item.uri, this.item.albumName, '', true]);
|
||||
} else {
|
||||
let params: any = this.selectParams;
|
||||
let params: SelectParams = this.selectParams;
|
||||
params.isFirstEnter = false;
|
||||
params.itemDisplayName = this.item.albumName;
|
||||
params.itemCount = this.item.count;
|
||||
@ -186,7 +186,7 @@ export struct ThirdAlbumGridItem {
|
||||
router.pushUrl({
|
||||
url: 'pages/ThirdSelectPhotoGridPage',
|
||||
params: params
|
||||
}, router.RouterMode.Single);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@ -39,16 +39,29 @@ import { IS_SIDE_BAR, IS_SPLIT_MODE, LEFT_BLANK, SelectParams } from '../utils/T
|
||||
|
||||
const TAG: string = 'thiSel_ThirdSelectAlbumPageBase';
|
||||
|
||||
interface Params {
|
||||
bundleName: string;
|
||||
isMultiPick: boolean;
|
||||
isFromFa: boolean;
|
||||
isFromFaPhoto: boolean;
|
||||
filterMediaType?: string;
|
||||
isFirstEnter: boolean;
|
||||
isFromWallpaper: boolean;
|
||||
remainingOfWallpapers: number;
|
||||
maxSelectCount: number;
|
||||
};
|
||||
|
||||
// Third Select AlbumSet Page
|
||||
@Component
|
||||
export struct ThirdSelectAlbumPageBase {
|
||||
@State isEmpty: boolean = false;
|
||||
albums: AlbumSetDataSource;
|
||||
|
||||
@State totalSelectedCount: number = 0;
|
||||
@Provide broadCast: BroadCast = new BroadCast();
|
||||
private albums: AlbumSetDataSource = new AlbumSetDataSource(this.broadCast);
|
||||
@Provide isSelectedMode: boolean = true;
|
||||
@Provide moreMenuList: Array<Action> = new Array<Action>();
|
||||
selectManager: ThirdSelectManager;
|
||||
selectManager?: ThirdSelectManager;
|
||||
@Provide gridColumnsCount: number = 3;
|
||||
isActive = false;
|
||||
@StorageLink(IS_SPLIT_MODE) isSplitMode: boolean = ScreenManager.getInstance().isSplitMode();
|
||||
@ -57,15 +70,26 @@ export struct ThirdSelectAlbumPageBase {
|
||||
@StorageLink(IS_SIDE_BAR) isSidebar: boolean = ScreenManager.getInstance().isSidebar();
|
||||
dataObserver: CommonObserverCallback = new CommonObserverCallback(this);
|
||||
@State title: string = '';
|
||||
isFirstEnter: boolean;
|
||||
@Prop @Watch('onPageChanged') pageStatus: boolean;
|
||||
isFirstEnter: boolean = false;
|
||||
@Prop @Watch('onPageChanged') pageStatus: boolean = false;
|
||||
@Provide selectParams: SelectParams = SelectParams.defaultParam();
|
||||
scroller: Scroller = new Scroller();
|
||||
private appBroadCast: BroadCast = BroadCastManager.getInstance().getBroadCast();
|
||||
private initGridRowCountFunc: Function = (): void => this.initGridRowCount();
|
||||
private onLoadingFinishedFunc: Function = (size: number): void => this.onLoadingFinished(size);
|
||||
|
||||
private onLoadingFinished(size: number): void {
|
||||
Log.info(TAG, `ON_LOADING_FINISHED size: ${size}`);
|
||||
if (size === 1 && this.albums?.mediaSetList[0].albumName === AlbumDefine.ALBUM_ID_RECYCLE) {
|
||||
this.isEmpty = true;
|
||||
} else {
|
||||
this.isEmpty = size == 0;
|
||||
}
|
||||
}
|
||||
|
||||
aboutToAppear(): void {
|
||||
this.albums = new AlbumSetDataSource(this.broadCast);
|
||||
let param: any = router.getParams();
|
||||
let param: Params = router.getParams() as Params;
|
||||
this.initSelectParams(param);
|
||||
if (this.selectParams.isFromFa) {
|
||||
this.selectParams.filterMediaType = AlbumDefine.FILTER_MEDIA_TYPE_IMAGE;
|
||||
@ -77,17 +101,9 @@ export struct ThirdSelectAlbumPageBase {
|
||||
userFile.getSystemAlbumUri(UserFileManagerAccess.FAVORITE_ALBUM_SUB_TYPE)]);
|
||||
}
|
||||
this.albums.setFilterMediaType(this.selectParams.filterMediaType);
|
||||
this.selectManager = AppStorage.Get(Constants.THIRD_SELECT_MANAGER);
|
||||
this.onMenuClicked = this.onMenuClicked.bind(this);
|
||||
this.selectManager = AppStorage.get<ThirdSelectManager>(Constants.THIRD_SELECT_MANAGER) as ThirdSelectManager;
|
||||
Log.debug(TAG, `select params ${JSON.stringify(this.selectParams)}`);
|
||||
this.broadCast.on(Constants.ON_LOADING_FINISHED, (size: number) => {
|
||||
Log.info(TAG, `ON_LOADING_FINISHED size: ${size}`);
|
||||
if (size === 1 && this.albums.mediaSetList[0].albumName === AlbumDefine.ALBUM_ID_RECYCLE) {
|
||||
this.isEmpty = true;
|
||||
} else {
|
||||
this.isEmpty = size == 0;
|
||||
}
|
||||
});
|
||||
this.broadCast.on(Constants.ON_LOADING_FINISHED, this.onLoadingFinishedFunc);
|
||||
if (this.selectParams.isMultiPick) {
|
||||
this.selectManager.registerCallback('thirdSelectUpdateCount', (newState: number) => {
|
||||
Log.info(TAG, `thirdSelectUpdateCount ${newState}`);
|
||||
@ -95,11 +111,10 @@ export struct ThirdSelectAlbumPageBase {
|
||||
});
|
||||
}
|
||||
MediaObserver.getInstance().registerObserver(this.dataObserver);
|
||||
this.initGridRowCount = this.initGridRowCount.bind(this);
|
||||
this.initGridRowCount();
|
||||
// 后续phone缩略图支持横竖屏后再放开
|
||||
if (AppStorage.Get('deviceType') as string !== Constants.DEFAULT_DEVICE_TYPE) {
|
||||
ScreenManager.getInstance().on(ScreenManager.ON_WIN_SIZE_CHANGED, this.initGridRowCount);
|
||||
if (AppStorage.get('deviceType') as string !== Constants.DEFAULT_DEVICE_TYPE) {
|
||||
ScreenManager.getInstance().on(ScreenManager.ON_WIN_SIZE_CHANGED, this.initGridRowCountFunc);
|
||||
}
|
||||
let titleRes = ActionBarProp.SINGLE_TAB_ALBUM_TITLE;
|
||||
UiUtil.getResourceString(titleRes).then((stringResource) => {
|
||||
@ -123,16 +138,17 @@ export struct ThirdSelectAlbumPageBase {
|
||||
}
|
||||
|
||||
aboutToDisappear() {
|
||||
this.broadCast.off(null, null);
|
||||
ScreenManager.getInstance().off(ScreenManager.ON_WIN_SIZE_CHANGED, this.initGridRowCount);
|
||||
this.initGridRowCount = null;
|
||||
if(this.broadCast) {
|
||||
this.broadCast.off(Constants.ON_LOADING_FINISHED, this.onLoadingFinishedFunc);
|
||||
}
|
||||
ScreenManager.getInstance().off(ScreenManager.ON_WIN_SIZE_CHANGED, this.initGridRowCountFunc);
|
||||
MediaObserver.getInstance().unregisterObserver(this.dataObserver);
|
||||
this.dataObserver.clearSource();
|
||||
}
|
||||
|
||||
onMediaLibDataChange(changeType) {
|
||||
onMediaLibDataChange(changeType: string): void {
|
||||
Log.info(TAG, `onMediaLibDataChange type: ${changeType}`);
|
||||
this.albums.onChange(changeType);
|
||||
this.albums?.onChange(changeType);
|
||||
}
|
||||
|
||||
onPageHide() {
|
||||
@ -158,16 +174,12 @@ export struct ThirdSelectAlbumPageBase {
|
||||
|
||||
onMenuClicked(action: Action) {
|
||||
Log.info(TAG, `onMenuClicked, action: ${action.actionID}`);
|
||||
switch (action.actionID) {
|
||||
case Action.BACK.actionID:
|
||||
router.back();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
if (action.actionID === Action.BACK.actionID) {
|
||||
router.back();
|
||||
}
|
||||
}
|
||||
|
||||
@Builder buildItem(item) {
|
||||
@Builder buildItem(item: AlbumSetDataInfo) {
|
||||
ThirdAlbumGridItem({
|
||||
item: item.data,
|
||||
isFirstEnter: this.isFirstEnter
|
||||
@ -184,7 +196,7 @@ export struct ThirdSelectAlbumPageBase {
|
||||
leftAction: Action.BACK,
|
||||
isSelectPhotoGrid: false,
|
||||
title: $title,
|
||||
onMenuClicked: this.onMenuClicked,
|
||||
onMenuClicked: (action: Action): void => this.onMenuClicked(action),
|
||||
totalSelectedCount: $totalSelectedCount
|
||||
})
|
||||
Stack() {
|
||||
@ -198,9 +210,7 @@ export struct ThirdSelectAlbumPageBase {
|
||||
this.buildItem(item)
|
||||
}
|
||||
}
|
||||
}, (item: AlbumSetDataInfo, index: number) => {
|
||||
return item.data.getHashCode() + index;
|
||||
})
|
||||
}, (item: AlbumSetDataInfo) => 'uri:' + item.data.uri)
|
||||
}
|
||||
.edgeEffect(EdgeEffect.Spring)
|
||||
.scrollBar(BarState.Auto)
|
||||
@ -222,7 +232,7 @@ export struct ThirdSelectAlbumPageBase {
|
||||
})
|
||||
}
|
||||
|
||||
private initSelectParams(param) {
|
||||
private initSelectParams(param: Params | null): void {
|
||||
if (param != null) {
|
||||
this.selectParams.bundleName = param.bundleName;
|
||||
this.selectParams.isMultiPick = param.isMultiPick;
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user