mirror of
https://gitee.com/openharmony/applications_launcher
synced 2024-11-23 14:59:42 +00:00
sync launcher code
Signed-off-by: zhoujing <zhoujing96@huawei.com>
This commit is contained in:
parent
c4ab9e2368
commit
79f110f422
@ -68,7 +68,7 @@ class AmsMissionManager {
|
|||||||
recentMissionInfo.bundleName = recentItem.want.bundleName;
|
recentMissionInfo.bundleName = recentItem.want.bundleName;
|
||||||
recentMissionInfo.abilityName = recentItem.want.abilityName;
|
recentMissionInfo.abilityName = recentItem.want.abilityName;
|
||||||
recentMissionInfo.lockedState = recentItem.lockedState;
|
recentMissionInfo.lockedState = recentItem.lockedState;
|
||||||
const appInfo = await launcherAbilityManager.getAppInfoByBundleName(recentMissionInfo.bundleName);
|
const appInfo = await launcherAbilityManager.getAppInfoByBundleAndAbility(recentMissionInfo.bundleName, recentMissionInfo.abilityName);
|
||||||
if (appInfo == undefined) {
|
if (appInfo == undefined) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -103,6 +103,7 @@ class AmsMissionManager {
|
|||||||
for (let i = 0; i < missionInfos.length; i++) {
|
for (let i = 0; i < missionInfos.length; i++) {
|
||||||
let missionInfo = missionInfos[i];
|
let missionInfo = missionInfos[i];
|
||||||
let bundleName = missionInfo.want.bundleName!;
|
let bundleName = missionInfo.want.bundleName!;
|
||||||
|
let abilityName = missionInfo.want.abilityName!;
|
||||||
let localMissionInfo = recentMissionsList.find((item) => item.bundleName === bundleName);
|
let localMissionInfo = recentMissionsList.find((item) => item.bundleName === bundleName);
|
||||||
if (localMissionInfo) {
|
if (localMissionInfo) {
|
||||||
let missionInfoAdd = new MissionInfo();
|
let missionInfoAdd = new MissionInfo();
|
||||||
@ -111,7 +112,7 @@ class AmsMissionManager {
|
|||||||
} else {
|
} else {
|
||||||
let recentTaskInfo = new RecentBundleMissionInfo();
|
let recentTaskInfo = new RecentBundleMissionInfo();
|
||||||
recentTaskInfo.bundleName = bundleName;
|
recentTaskInfo.bundleName = bundleName;
|
||||||
const appInfo = await launcherAbilityManager.getAppInfoByBundleName(bundleName);
|
const appInfo = await launcherAbilityManager.getAppInfoByBundleAndAbility(bundleName, abilityName);
|
||||||
if (appInfo == undefined) {
|
if (appInfo == undefined) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -323,6 +323,42 @@ class LauncherAbilityManager {
|
|||||||
});
|
});
|
||||||
Log.showInfo(TAG, `startLauncherAbilityByUri AceApplication : startAbility : ${result}`);
|
Log.showInfo(TAG, `startLauncherAbilityByUri AceApplication : startAbility : ${result}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get AppItemInfo from BMS with bundleName and abilityName
|
||||||
|
* @params bundleName
|
||||||
|
* @params abilityName
|
||||||
|
* @return AppItemInfo
|
||||||
|
*/
|
||||||
|
async getAppInfoByBundleAndAbility(bundleName: string, abilityName: string): Promise<AppItemInfo | undefined> {
|
||||||
|
let appItemInfo: AppItemInfo | undefined = undefined;
|
||||||
|
|
||||||
|
// get from system
|
||||||
|
let abilityInfos = new Array<LauncherAbilityInfo>();
|
||||||
|
await launcherBundleMgr.getLauncherAbilityInfos(bundleName, LauncherAbilityManager.CURRENT_USER_ID)
|
||||||
|
.then((res)=>{
|
||||||
|
if (res != undefined) {
|
||||||
|
Log.showInfo(TAG, `getAppInfoByBundleAndAbility res length: ${res.length}`);
|
||||||
|
abilityInfos = res;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((err)=>{
|
||||||
|
Log.showInfo(TAG, `getAppInfoByBundleName launcherBundleMgr getLauncherAbilityInfos error: ${JSON.stringify(err)}`);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (CheckEmptyUtils.isEmptyArr(abilityInfos)) {
|
||||||
|
Log.showInfo(TAG, `bundleName: ${bundleName} abilityName: ${abilityName} get appInfo from BMS empty!`);
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
let appInfo = abilityInfos.find(item => {
|
||||||
|
return item.elementName.abilityName === abilityName;
|
||||||
|
});
|
||||||
|
Log.showInfo(TAG, `getAppInfoByBundleAndAbility appInfo: ${JSON.stringify(appInfo)}`);
|
||||||
|
const data = await this.convertToAppItemInfo(appInfo);
|
||||||
|
Log.showInfo(TAG, `getAppInfoByBundleAndAbility from BMS: ${JSON.stringify(data)}`);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const launcherAbilityManager = LauncherAbilityManager.getInstance();
|
const launcherAbilityManager = LauncherAbilityManager.getInstance();
|
||||||
|
@ -285,10 +285,13 @@ export default class PageDesktopDragHandler extends BaseDragHandler {
|
|||||||
console.info('Launcher PageDesktop onDragDrop insertIndex: ' + insertIndex + ' ,mIsInEffectArea: ' + this.mIsInEffectArea);
|
console.info('Launcher PageDesktop onDragDrop insertIndex: ' + insertIndex + ' ,mIsInEffectArea: ' + this.mIsInEffectArea);
|
||||||
AppStorage.SetOrCreate('overlayMode', CommonConstants.OVERLAY_TYPE_HIDE);
|
AppStorage.SetOrCreate('overlayMode', CommonConstants.OVERLAY_TYPE_HIDE);
|
||||||
let isDragSuccess = false;
|
let isDragSuccess = false;
|
||||||
|
const startPosition = this.copyPosition(this.mStartPosition);
|
||||||
|
let endPosition = null;
|
||||||
if (this.mIsInEffectArea) {
|
if (this.mIsInEffectArea) {
|
||||||
const moveAppX = event.touches[0].screenX;
|
const moveAppX = event.touches[0].screenX;
|
||||||
const moveAppY = event.touches[0].screenY;
|
const moveAppY = event.touches[0].screenY;
|
||||||
this.mEndPosition = this.getTouchPosition(moveAppX, moveAppY);
|
this.mEndPosition = this.getTouchPosition(moveAppX, moveAppY);
|
||||||
|
endPosition = this.copyPosition(this.mEndPosition);
|
||||||
const dragItemInfo = this.getDragItemInfo();
|
const dragItemInfo = this.getDragItemInfo();
|
||||||
const info = this.mPageDesktopViewModel.getLayoutInfo();
|
const info = this.mPageDesktopViewModel.getLayoutInfo();
|
||||||
const layoutInfo = info.layoutInfo;
|
const layoutInfo = info.layoutInfo;
|
||||||
@ -299,7 +302,7 @@ export default class PageDesktopDragHandler extends BaseDragHandler {
|
|||||||
} else if(dragItemInfo.type === CommonConstants.TYPE_APP) {
|
} else if(dragItemInfo.type === CommonConstants.TYPE_APP) {
|
||||||
// end position is the same as start position
|
// end position is the same as start position
|
||||||
if (this.isMoveToSamePosition(dragItemInfo)) {
|
if (this.isMoveToSamePosition(dragItemInfo)) {
|
||||||
this.deleteBlankPageAfterDragging();
|
this.deleteBlankPageAfterDragging(startPosition, endPosition);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
const endLayoutInfo = this.getEndLayoutInfo(layoutInfo);
|
const endLayoutInfo = this.getEndLayoutInfo(layoutInfo);
|
||||||
@ -308,15 +311,16 @@ export default class PageDesktopDragHandler extends BaseDragHandler {
|
|||||||
const appInfo = this.createNewAppInfo(dragItemInfo);
|
const appInfo = this.createNewAppInfo(dragItemInfo);
|
||||||
// add app to folder
|
// add app to folder
|
||||||
this.mFolderViewModel.addOneAppToFolder(appInfo, endLayoutInfo.folderId);
|
this.mFolderViewModel.addOneAppToFolder(appInfo, endLayoutInfo.folderId);
|
||||||
this.deleteBlankPageAfterDragging();
|
this.deleteBlankPageAfterDragging(startPosition, endPosition);
|
||||||
return true;
|
return true;
|
||||||
} else if (endLayoutInfo.type === CommonConstants.TYPE_APP) {
|
} else if (endLayoutInfo.type === CommonConstants.TYPE_APP) {
|
||||||
// create a new folder
|
// create a new folder
|
||||||
const appListInfo = [endLayoutInfo];
|
const appListInfo = [endLayoutInfo];
|
||||||
const startLayoutInfo = this.getStartLayoutInfo(layoutInfo, dragItemInfo);
|
const startLayoutInfo = this.getStartLayoutInfo(layoutInfo, dragItemInfo);
|
||||||
appListInfo.push(startLayoutInfo);
|
appListInfo.push(startLayoutInfo);
|
||||||
this.mFolderViewModel.addNewFolder(appListInfo);
|
this.mFolderViewModel.addNewFolder(appListInfo).then(()=> {
|
||||||
this.deleteBlankPageAfterDragging();
|
this.deleteBlankPageAfterDragging(startPosition, endPosition);
|
||||||
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -331,7 +335,7 @@ export default class PageDesktopDragHandler extends BaseDragHandler {
|
|||||||
console.info('Launcher PageDesktop onDragEnd not selfDrag');
|
console.info('Launcher PageDesktop onDragEnd not selfDrag');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.deleteBlankPageAfterDragging();
|
this.deleteBlankPageAfterDragging(startPosition, endPosition);
|
||||||
return isDragSuccess;
|
return isDragSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -348,26 +352,53 @@ export default class PageDesktopDragHandler extends BaseDragHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* delete blank page after dragging
|
* copy a new position object by original position
|
||||||
|
*
|
||||||
|
* @param position - original position
|
||||||
*/
|
*/
|
||||||
private deleteBlankPageAfterDragging(): void {
|
private copyPosition(position) {
|
||||||
|
if (CheckEmptyUtils.isEmpty(position)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
const directionPosition = {
|
||||||
|
page: position.page,
|
||||||
|
row: position.row,
|
||||||
|
column: position.column,
|
||||||
|
X: position.X,
|
||||||
|
Y: position.Y
|
||||||
|
};
|
||||||
|
return directionPosition;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* delete blank page after dragging
|
||||||
|
*
|
||||||
|
* @param startPosition - drag start position
|
||||||
|
* @param endPosition - drag end position
|
||||||
|
*/
|
||||||
|
private deleteBlankPageAfterDragging(startPosition, endPosition): void {
|
||||||
const layoutInfo = this.mPageDesktopViewModel.getLayoutInfo();
|
const layoutInfo = this.mPageDesktopViewModel.getLayoutInfo();
|
||||||
const pageCount = layoutInfo.layoutDescription.pageCount;
|
const pageCount = layoutInfo.layoutDescription.pageCount;
|
||||||
const isAddByDraggingFlag = this.mPageDesktopViewModel.isAddByDragging();
|
const isAddByDraggingFlag = this.mPageDesktopViewModel.isAddByDragging();
|
||||||
let deleteLastFlag = false;
|
let deleteLastFlag = false;
|
||||||
if (isAddByDraggingFlag && (CheckEmptyUtils.isEmpty(this.mEndPosition) ||
|
if (isAddByDraggingFlag && (CheckEmptyUtils.isEmpty(endPosition) ||
|
||||||
!CheckEmptyUtils.isEmpty(this.mEndPosition) && this.mEndPosition.page != pageCount - 1 )) {
|
!CheckEmptyUtils.isEmpty(endPosition) && endPosition.page != pageCount - 1 )) {
|
||||||
layoutInfo.layoutDescription.pageCount = pageCount - 1;
|
layoutInfo.layoutDescription.pageCount = pageCount - 1;
|
||||||
deleteLastFlag = true;
|
deleteLastFlag = true;
|
||||||
}
|
}
|
||||||
let deleteStartFlag = false;
|
let deleteStartFlag = false;
|
||||||
if (!CheckEmptyUtils.isEmpty(this.mStartPosition)) {
|
if (!CheckEmptyUtils.isEmpty(startPosition)) {
|
||||||
deleteStartFlag = this.mPageDesktopViewModel.deleteBlankPageFromLayoutInfo(layoutInfo, this.mStartPosition.page);
|
deleteStartFlag = this.mPageDesktopViewModel.deleteBlankPageFromLayoutInfo(layoutInfo, startPosition.page);
|
||||||
}
|
}
|
||||||
if (CheckEmptyUtils.isEmpty(this.mEndPosition)) {
|
if (CheckEmptyUtils.isEmpty(endPosition)) {
|
||||||
this.mPageDesktopViewModel.changeIndex(this.mStartPosition.page);
|
this.mPageDesktopViewModel.changeIndex(startPosition.page);
|
||||||
} else if (deleteStartFlag && this.mStartPosition.page > this.mEndPosition.page) {
|
} else if (deleteStartFlag) {
|
||||||
this.mPageDesktopViewModel.changeIndex(this.mEndPosition.page);
|
if (startPosition.page > endPosition.page) {
|
||||||
|
this.mPageDesktopViewModel.changeIndex(endPosition.page);
|
||||||
|
} else if (endPosition.page > startPosition.page &&
|
||||||
|
endPosition.page < layoutInfo.layoutDescription.pageCount) {
|
||||||
|
this.mPageDesktopViewModel.changeIndex(endPosition.page - 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (deleteLastFlag || deleteStartFlag) {
|
if (deleteLastFlag || deleteStartFlag) {
|
||||||
this.mPageDesktopViewModel.setLayoutInfo(layoutInfo);
|
this.mPageDesktopViewModel.setLayoutInfo(layoutInfo);
|
||||||
|
Loading…
Reference in New Issue
Block a user