mirror of
https://gitee.com/openharmony/applications_launcher
synced 2024-11-27 00:51:34 +00:00
moduleName适配
Signed-off-by: qano <nimaosen1@huawei.com>
This commit is contained in:
parent
99cd00e3e2
commit
5904bff376
@ -24,7 +24,7 @@ const EventConstants = {
|
||||
EVENT_REQUEST_PAGEDESK_ITEM_ADD: 'launcher.event.REQUEST_PAGEDESK_ITEM_ADD', //request add item to pageDesk
|
||||
EVENT_REQUEST_PAGEDESK_ITEM_UPDATE: 'launcher.event.EVENT_REQUEST_PAGEDESK_ITEM_UPDATE', //request update item to pageDesk
|
||||
EVENT_REQUEST_PAGEDESK_ITEM_DELETE: 'launcher.event.REQUEST_PAGEDESK_ITEM_DELETE', //request delete item to pageDesk
|
||||
EVENT_REQUEST_RESIDENT_DOCK_ITEM_UPDATE: 'launcher.event.EVENT_REQUEST_RESIDENT_DOCK_ITEM_UPDATE', //request update item to smartdock
|
||||
EVENT_REQUEST_RESIDENT_DOCK_ITEM_UPDATE: 'launcher.event.EVENT_REQUEST_RESIDENT_DOCK_ITEM_UPDATE', //request update item to smartDock
|
||||
EVENT_REQUEST_RESIDENT_DOCK_ITEM_INIT: 'launcher.event.EVENT_REQUEST_RESIDENT_DOCK_ITEM_INIT', //request reset resident item to pageDesk
|
||||
EVENT_REQUEST_RESIDENT_DOCK_ITEM_DELETE: 'launcher.event.REQUEST_DOCK_ITEM_DELETE', //request delete resident item
|
||||
EVENT_REQUEST_RECENT_DOCK_ITEM_DELETE: 'launcher.event.RECENT_DOCK_ITEM_DELETE', //request delete recent item
|
||||
|
@ -54,6 +54,7 @@ export default class FolderViewModel extends BaseAppPresenter {
|
||||
}
|
||||
};
|
||||
|
||||
// badge will be designed lastly
|
||||
private updateBadge(openFolderData, params): void {
|
||||
for (let i = 0; i < openFolderData.layoutInfo.length; i++) {
|
||||
const appInfo: any = openFolderData.layoutInfo[i].find(item => {
|
||||
@ -107,7 +108,7 @@ export default class FolderViewModel extends BaseAppPresenter {
|
||||
const folderAppInfo = [];
|
||||
for (let j = 0; j < appListInfo.length; j++) {
|
||||
for (let i = 0; i < settingAppInfoList.length; i++) {
|
||||
Log.showInfo(TAG, "addNewFolder" + JSON.stringify(settingAppInfoList[i]) + " applistinfo" + JSON.stringify(appListInfo[j]))
|
||||
Log.showInfo(TAG, `addNewFolder ${JSON.stringify(settingAppInfoList[i])} applistinfo: ${JSON.stringify(appListInfo[j])}`)
|
||||
if (settingAppInfoList[i].keyName === appListInfo[j].keyName) {
|
||||
folderAppInfo.push(settingAppInfoList[i]);
|
||||
break;
|
||||
@ -305,6 +306,9 @@ export default class FolderViewModel extends BaseAppPresenter {
|
||||
private createAppLayoutInfo(appInfo): any {
|
||||
const appLayout = {
|
||||
bundleName: appInfo.bundleName,
|
||||
abilityName: appInfo.abilityName,
|
||||
moduleName: appInfo.moduleName,
|
||||
keyName: appInfo.keyName,
|
||||
typeId: appInfo.typeId,
|
||||
area: appInfo.area,
|
||||
page: appInfo.page,
|
||||
@ -354,6 +358,9 @@ export default class FolderViewModel extends BaseAppPresenter {
|
||||
// delete from folder and add app to desktop
|
||||
const appLayout = {
|
||||
bundleName: folderLayoutInfo[0][0].bundleName,
|
||||
abilityName: folderLayoutInfo[0][0].abilityName,
|
||||
moduleName: folderLayoutInfo[0][0].moduleName,
|
||||
keyName: folderLayoutInfo[0][0].keyName,
|
||||
typeId: folderLayoutInfo[0][0].typeId,
|
||||
area: folderLayoutInfo[0][0].area,
|
||||
page: gridLayoutInfo.layoutInfo[folderIndex].page,
|
||||
@ -567,7 +574,7 @@ export default class FolderViewModel extends BaseAppPresenter {
|
||||
const appInfosRemaining = [];
|
||||
for (let m = 0; m < folderAppList.length; m++) {
|
||||
const appIndex = appInfos.findIndex(item => {
|
||||
return item.bundleName === folderAppList[m].bundleName;
|
||||
return item.keyName === folderAppList[m].keyName;
|
||||
});
|
||||
if (appIndex == CommonConstants.INVALID_VALUE) {
|
||||
appInfosRemaining.push(folderAppList[m]);
|
||||
@ -657,7 +664,7 @@ export default class FolderViewModel extends BaseAppPresenter {
|
||||
for (let i = 0; i < appInfos.length; i++) {
|
||||
for (let j = 0; j < gridLayoutInfo.layoutInfo.length; j++) {
|
||||
if (gridLayoutInfo.layoutInfo[j].typeId == CommonConstants.TYPE_APP &&
|
||||
appInfos[i].bundleName == gridLayoutInfo.layoutInfo[j].bundleName) {
|
||||
appInfos[i].keyName == gridLayoutInfo.layoutInfo[j].keyName) {
|
||||
appDesktopToFolder.push(gridLayoutInfo.layoutInfo[j]);
|
||||
break;
|
||||
}
|
||||
@ -686,7 +693,7 @@ export default class FolderViewModel extends BaseAppPresenter {
|
||||
for (let i = 0; i < removeFolderApp.length; i++) {
|
||||
let remainFlag = false;
|
||||
for (let j = 0; j < appInfos.length; j++) {
|
||||
if (appInfos[j].bundleName == removeFolderApp[i].bundleName) {
|
||||
if (appInfos[j].keyName == removeFolderApp[i].keyName) {
|
||||
remainFlag = true;
|
||||
break;
|
||||
}
|
||||
@ -839,7 +846,7 @@ export default class FolderViewModel extends BaseAppPresenter {
|
||||
for (let i = 0; i < appListInfo.length; i++) {
|
||||
let isExist = false;
|
||||
for (let j = 0; j < allAppList.length; j++) {
|
||||
if (appListInfo[i].bundleName === allAppList[j].bundleName) {
|
||||
if (appListInfo[i].keyName === allAppList[j].keyName) {
|
||||
isExist = true;
|
||||
break;
|
||||
}
|
||||
@ -1161,20 +1168,12 @@ export default class FolderViewModel extends BaseAppPresenter {
|
||||
Log.showDebug(TAG, 'deleteAppFromFolderByUninstall start');
|
||||
const gridLayoutInfo = this.mSettingsModel.getLayoutInfo();
|
||||
const layoutInfo = gridLayoutInfo.layoutInfo;
|
||||
let changeFlag = false;
|
||||
for (let i = 0; i < layoutInfo.length; i++) {
|
||||
if (changeFlag) {
|
||||
break;
|
||||
}
|
||||
if (layoutInfo[i].typeId == CommonConstants.TYPE_FOLDER) {
|
||||
const folderAppList = this.layoutInfoToList(layoutInfo[i]);
|
||||
let folderAppList = this.layoutInfoToList(layoutInfo[i]);
|
||||
for (let m = 0; m < folderAppList.length; m++) {
|
||||
if (folderAppList[m].bundleName == bundleName) {
|
||||
folderAppList.splice(m, 1);
|
||||
this.updateFolderInfo(folderAppList, gridLayoutInfo, i);
|
||||
changeFlag = true;
|
||||
break;
|
||||
}
|
||||
folderAppList = folderAppList.filter(item => item.bundleName != bundleName);
|
||||
this.updateFolderInfo(folderAppList, gridLayoutInfo, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1189,14 +1188,21 @@ export default class FolderViewModel extends BaseAppPresenter {
|
||||
* @param index
|
||||
*/
|
||||
private updateFolderInfo(folderAppList, gridLayoutInfo, index): void {
|
||||
if (folderAppList.length == 1) {
|
||||
if (folderAppList.length == 0) {
|
||||
gridLayoutInfo.layoutInfo.splice(index, 1);
|
||||
this.mSettingsModel.setLayoutInfo(gridLayoutInfo);
|
||||
this.mPageDesktopViewModel.getGridList();
|
||||
} else if (folderAppList.length == 1) {
|
||||
const appLayoutInfo = {
|
||||
'bundleName': folderAppList[0].bundleName,
|
||||
'typeId': CommonConstants.TYPE_APP,
|
||||
'area': [1, 1],
|
||||
'page': gridLayoutInfo.layoutInfo[index].page,
|
||||
'column': gridLayoutInfo.layoutInfo[index].column,
|
||||
'row': gridLayoutInfo.layoutInfo[index].row
|
||||
bundleName: folderAppList[0].bundleName,
|
||||
abilityName: folderAppList[0].abilityName,
|
||||
moduleName: folderAppList[0].moduleName,
|
||||
keyName: folderAppList[0].keyName,
|
||||
typeId: CommonConstants.TYPE_APP,
|
||||
area: [1, 1],
|
||||
page: gridLayoutInfo.layoutInfo[index].page,
|
||||
column: gridLayoutInfo.layoutInfo[index].column,
|
||||
row: gridLayoutInfo.layoutInfo[index].row
|
||||
};
|
||||
gridLayoutInfo.layoutInfo.splice(index, 1);
|
||||
gridLayoutInfo.layoutInfo.push(appLayoutInfo);
|
||||
@ -1256,7 +1262,7 @@ export default class FolderViewModel extends BaseAppPresenter {
|
||||
const gridLayout = this.createAppLayoutInfo(removeAppInfos[i]);
|
||||
gridLayoutInfo.layoutInfo.push(gridLayout);
|
||||
const appIndex = appListInfo.findIndex(item => {
|
||||
return item.bundleName === removeAppInfos[i].bundleName && item.abilityName === removeAppInfos[i].abilityName;
|
||||
return item.keyName === removeAppInfos[i].keyName;
|
||||
})
|
||||
if (appIndex == CommonConstants.INVALID_VALUE) {
|
||||
appListInfo.push(removeAppInfos[i]);
|
||||
@ -1292,7 +1298,7 @@ export default class FolderViewModel extends BaseAppPresenter {
|
||||
*/
|
||||
private deleteAppFromFolderAppList(appInfo, folderAppList): void {
|
||||
const appIndex = folderAppList.findIndex(item => {
|
||||
return item.bundleName === appInfo.bundleName;
|
||||
return item.keyName === appInfo.keyName;
|
||||
});
|
||||
folderAppList.splice(appIndex, 1);
|
||||
}
|
||||
@ -1322,7 +1328,7 @@ export default class FolderViewModel extends BaseAppPresenter {
|
||||
private getFolderLayoutInfo(openFolderData, appInfo): any {
|
||||
let folderAppList = this.getAppListInFolder(openFolderData);
|
||||
const index = folderAppList.findIndex(item => {
|
||||
return item.bundleName === appInfo.bundleName;
|
||||
return item.keyName === appInfo.keyName;
|
||||
});
|
||||
folderAppList.splice(index, 1);
|
||||
return this.filterFolderPage(folderAppList);
|
||||
|
@ -188,7 +188,6 @@ export default class SmartDockModel {
|
||||
deleteDockItem(dockItem: {bundleName: string | undefined, keyName: string | undefined}, dockType: number): boolean {
|
||||
if (SmartDockConstants.RESIDENT_DOCK_TYPE === dockType) {
|
||||
return this.deleteResistDockItem(dockItem);
|
||||
|
||||
}
|
||||
else if (SmartDockConstants.RECENT_DOCK_TYPE === dockType) {
|
||||
return this.deleteRecentDockItem(dockItem);
|
||||
@ -459,28 +458,31 @@ export default class SmartDockModel {
|
||||
}
|
||||
|
||||
private deleteResistDockItem(dockItem: {bundleName: string | undefined, keyName: string | undefined}): boolean {
|
||||
let res = false;
|
||||
this.mResidentList = AppStorage.Get('residentList');
|
||||
Log.showError(TAG, `deleteResistDockItem residentList length ${this.mResidentList.length}`);
|
||||
if (!CheckEmptyUtils.isEmptyArr(this.mResidentList)) {
|
||||
for (let i = 0; i < this.mResidentList.length; i++) {
|
||||
if (dockItem.bundleName === this.mResidentList[i].bundleName
|
||||
|| dockItem.keyName === this.mResidentList[i].keyName) {
|
||||
// check right to delete
|
||||
if (!this.mResidentList[i].editable) {
|
||||
Prompt.showToast({
|
||||
message: $r('app.string.disable_add_to_delete')
|
||||
});
|
||||
} else {
|
||||
this.mResidentList.splice(i, 1);
|
||||
AppStorage.SetOrCreate('residentList', this.mResidentList);
|
||||
globalThis.RdbStoreManagerInstance.insertIntoSmartdock(this.mResidentList);
|
||||
Log.showDebug(TAG, `deleteResistDockItem resist dockItem: ${JSON.stringify(dockItem)}`);
|
||||
res = true;
|
||||
}
|
||||
}
|
||||
const findResidentList = this.mResidentList.find(item => {
|
||||
return dockItem.bundleName == item.bundleName || dockItem.keyName == item.keyName;
|
||||
})
|
||||
// check right to delete
|
||||
if (!findResidentList.editable) {
|
||||
Prompt.showToast({
|
||||
message: $r('app.string.disable_add_to_delete')
|
||||
});
|
||||
return false;
|
||||
}
|
||||
this.mResidentList = this.mResidentList.filter(item => {
|
||||
if (dockItem.bundleName) {
|
||||
return dockItem.bundleName != item.bundleName;
|
||||
} else if (dockItem.keyName) {
|
||||
return dockItem.keyName != item.keyName;
|
||||
}
|
||||
})
|
||||
AppStorage.SetOrCreate('residentList', this.mResidentList);
|
||||
globalThis.RdbStoreManagerInstance.insertIntoSmartdock(this.mResidentList);
|
||||
Log.showDebug(TAG, `deleteResistDockItem resist dockItem: ${JSON.stringify(dockItem)}`);
|
||||
}
|
||||
return res;
|
||||
return true;
|
||||
}
|
||||
|
||||
private deleteRecentDockItem(dockItem: {bundleName: string | undefined, keyName: string | undefined}): boolean {
|
||||
@ -491,11 +493,11 @@ export default class SmartDockModel {
|
||||
if (dockItem.bundleName === this.mResidentList[i].bundleName
|
||||
|| dockItem.keyName === this.mResidentList[i].keyName) {
|
||||
this.mRecentDataList.splice(i, 1);
|
||||
AppStorage.SetOrCreate('recentList', this.mRecentDataList);
|
||||
Log.showDebug(TAG, `deleteRecentDockItem recent dockItem: ${JSON.stringify(dockItem)}`);
|
||||
res = true;
|
||||
}
|
||||
}
|
||||
AppStorage.SetOrCreate('recentList', this.mRecentDataList);
|
||||
Log.showDebug(TAG, `deleteRecentDockItem recent dockItem: ${JSON.stringify(dockItem)}`);
|
||||
res = true;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user