mirror of
https://gitee.com/openharmony/applications_launcher
synced 2024-11-27 17:10:49 +00:00
服务卡片PIN桌面
Signed-off-by: liubaibao <liubaibao2@huawei.com>
This commit is contained in:
parent
dbef3259f0
commit
8fa09358b0
@ -27,6 +27,7 @@ export { SettingItemInfo } from './src/main/ets/default/bean/SettingItemInfo'
|
||||
export { RecentMissionInfo } from './src/main/ets/default/bean/RecentMissionInfo'
|
||||
export { RecentBundleMissionInfo } from './src/main/ets/default/bean/RecentBundleMissionInfo'
|
||||
export { EventConstants } from './src/main/ets/default/constants/EventConstants'
|
||||
export { FormConstants } from './src/main/ets/default/constants/FormConstants'
|
||||
export { StyleConstants } from './src/main/ets/default/constants/StyleConstants'
|
||||
export { CommonConstants } from './src/main/ets/default/constants/CommonConstants'
|
||||
export { PresetStyleConstants } from './src/main/ets/default/constants/PresetStyleConstants'
|
||||
|
31
common/src/main/ets/default/constants/FormConstants.ts
Normal file
31
common/src/main/ets/default/constants/FormConstants.ts
Normal file
@ -0,0 +1,31 @@
|
||||
/**
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Constants of events that will be registered to system.
|
||||
*/
|
||||
export const FormConstants = {
|
||||
// publish form action
|
||||
ACTION_PUBLISH_FORM: "action.form.publish",
|
||||
|
||||
// publish card parameters
|
||||
ID_PARAM: "ohos.extra.param.key.form_identity",
|
||||
NAME_PARAM: "ohos.extra.param.key.form_name",
|
||||
BUNDLE_PARAM: "ohos.extra.param.key.bundle_name",
|
||||
ABILITY_PARAM: "ohos.extra.param.key.ability_name",
|
||||
MODULE_PARAM: "ohos.extra.param.key.module_name",
|
||||
DIMENSION_PARAM: "ohos.extra.param.key.form_dimension",
|
||||
TEMPORARY_PARAM:"ohos.extra.param.key.form_temporary"
|
||||
};
|
@ -14,9 +14,11 @@
|
||||
*/
|
||||
|
||||
import formManagerAbility from '@ohos.application.formHost';
|
||||
import { FormConstants } from '@ohos/common';
|
||||
import { Log } from '../utils/Log';
|
||||
import { CardItemInfo } from '../bean/CardItemInfo';
|
||||
import { CommonConstants } from '../constants/CommonConstants';
|
||||
import { launcherAbilityManager } from './LauncherAbilityManager';
|
||||
|
||||
const TAG = 'FormManager';
|
||||
|
||||
@ -104,6 +106,50 @@ export class FormManager {
|
||||
return cardItemInfoList;
|
||||
}
|
||||
|
||||
/**
|
||||
* get formCardItem by want parameters
|
||||
*
|
||||
* @param parameters
|
||||
* @return formCardItem
|
||||
*/
|
||||
async getFormCardItemByWant(params) {
|
||||
Log.showInfo(TAG, 'getFormCardItemByWant');
|
||||
let formCardItem: any = {};
|
||||
formCardItem.id = params[FormConstants.ID_PARAM];
|
||||
formCardItem.name = params[FormConstants.NAME_PARAM];
|
||||
formCardItem.bundleName = params[FormConstants.BUNDLE_PARAM];
|
||||
formCardItem.abilityName = params[FormConstants.ABILITY_PARAM];
|
||||
formCardItem.moduleName = params[FormConstants.MODULE_PARAM];
|
||||
formCardItem.dimension = params[FormConstants.DIMENSION_PARAM];
|
||||
formCardItem.formConfigAbility = await this.getFormConfigAbility(params[FormConstants.BUNDLE_PARAM],
|
||||
params[FormConstants.MODULE_PARAM], params[FormConstants.ABILITY_PARAM], params[FormConstants.NAME_PARAM]);
|
||||
const appInfo = await launcherAbilityManager.getAppInfoByBundleName(params[FormConstants.BUNDLE_PARAM] ,
|
||||
params[FormConstants.ABILITY_PARAM]);
|
||||
formCardItem.appLabelId = appInfo.appLabelId;
|
||||
return formCardItem;
|
||||
}
|
||||
|
||||
/**
|
||||
* get formConfigAbility by bundleName moduleName abilityName and cardName
|
||||
*
|
||||
* @param bundle
|
||||
* @param moduleName
|
||||
* @param abilityName
|
||||
* @param cardName
|
||||
* @return formConfigAbility
|
||||
*/
|
||||
async getFormConfigAbility(bundle:string, moduleName:string, abilityName:string, cardName:string) : Promise<string> {
|
||||
const formList = await formManagerAbility.getFormsInfo(bundle);
|
||||
let formConfigAbility = "";
|
||||
for (const formItem of formList) {
|
||||
if(formItem.moduleName == moduleName && formItem.abilityName == abilityName && formItem.name == cardName ) {
|
||||
formConfigAbility = formItem.formConfigAbility;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return formConfigAbility;
|
||||
}
|
||||
|
||||
/**
|
||||
* get form info by bundleName and moduleName
|
||||
*
|
||||
|
@ -32,6 +32,7 @@ import { MenuInfo } from '@ohos/common';
|
||||
import { CardItemInfo } from '@ohos/common';
|
||||
import { BigFolderModel } from '@ohos/bigfolder';
|
||||
import { FormDetailLayoutConfig } from '@ohos/form';
|
||||
import { localEventManager } from '@ohos/common';
|
||||
import PageDesktopModel from '../model/PageDesktopModel';
|
||||
import PagedesktopConstants from '../common/constants/PagedesktopConstants';
|
||||
import { PageDesktopGridStyleConfig } from '../common/PageDesktopGridStyleConfig';
|
||||
@ -1342,6 +1343,17 @@ export default class PageDesktopViewModel extends BaseViewModel {
|
||||
this.jumpTo(abilityName, bundleName, moduleName);
|
||||
}
|
||||
|
||||
/**
|
||||
* other app publish card to pageDesktop
|
||||
*
|
||||
* @param parameters
|
||||
*/
|
||||
async publishCardToDesktop(parameters:any) {
|
||||
Log.showInfo(TAG, 'publishCardToDesktop');
|
||||
const formItem = await FormManager.getInstance().getFormCardItemByWant(parameters);
|
||||
localEventManager.sendLocalEventSticky(EventConstants.EVENT_REQUEST_PAGEDESK_FORM_ITEM_ADD, formItem);
|
||||
}
|
||||
|
||||
/**
|
||||
* add card to pageDesktop
|
||||
* @param appInfo
|
||||
|
@ -19,9 +19,11 @@ import Want from '@ohos.application.Want';
|
||||
import { Log } from '@ohos/common';
|
||||
import { windowManager } from '@ohos/common';
|
||||
import { RdbStoreManager } from '@ohos/common';
|
||||
import { FormConstants } from '@ohos/common';
|
||||
import { GestureNavigationManager } from '@ohos/gesturenavigation';
|
||||
import StyleConstants from '../common/constants/StyleConstants';
|
||||
import { navigationBarCommonEventManager } from '@ohos/common';
|
||||
import PageDesktopViewModel from '../../../../../../feature/pagedesktop/src/main/ets/default/viewmodel/PageDesktopViewModel';
|
||||
|
||||
const TAG = 'LauncherMainAbility';
|
||||
|
||||
@ -88,6 +90,10 @@ export default class MainAbility extends ServiceExtension {
|
||||
|
||||
onRequest(want: Want, startId: number): void {
|
||||
Log.showInfo(TAG,`onRequest, want: ${want.abilityName}`);
|
||||
// if app publish card to launcher
|
||||
if(want.action == FormConstants.ACTION_PUBLISH_FORM) {
|
||||
PageDesktopViewModel.getInstance().publishCardToDesktop(want.parameters);
|
||||
}
|
||||
windowManager.minimizeAllApps();
|
||||
windowManager.hideWindow(windowManager.RECENT_WINDOW_NAME);
|
||||
windowManager.destroyWindow(windowManager.APP_CENTER_WINDOW_NAME);
|
||||
|
@ -23,7 +23,8 @@
|
||||
],
|
||||
"actions": [
|
||||
"action.system.home",
|
||||
"com.ohos.action.main"
|
||||
"com.ohos.action.main",
|
||||
"action.form.publish"
|
||||
]
|
||||
}
|
||||
],
|
||||
|
@ -19,9 +19,11 @@ import Want from '@ohos.application.Want';
|
||||
import { Log } from '@ohos/common';
|
||||
import { windowManager } from '@ohos/common';
|
||||
import { RdbStoreManager } from '@ohos/common';
|
||||
import { FormConstants } from '@ohos/common';
|
||||
import { GestureNavigationManager } from '@ohos/gesturenavigation';
|
||||
import StyleConstants from '../common/constants/StyleConstants';
|
||||
import { navigationBarCommonEventManager } from '@ohos/common';
|
||||
import PageDesktopViewModel from '../../../../../../feature/pagedesktop/src/main/ets/default/viewmodel/PageDesktopViewModel';
|
||||
|
||||
const TAG = 'LauncherMainAbility';
|
||||
|
||||
@ -88,6 +90,10 @@ export default class MainAbility extends ServiceExtension {
|
||||
|
||||
onRequest(want: Want, startId: number): void {
|
||||
Log.showInfo(TAG,`onRequest, want:${want.abilityName}`);
|
||||
// if app publish card to launcher
|
||||
if(want.action == FormConstants.ACTION_PUBLISH_FORM) {
|
||||
PageDesktopViewModel.getInstance().publishCardToDesktop(want.parameters);
|
||||
}
|
||||
windowManager.minimizeAllApps();
|
||||
windowManager.hideWindow(windowManager.RECENT_WINDOW_NAME);
|
||||
this.closeFolder();
|
||||
|
@ -23,7 +23,8 @@
|
||||
],
|
||||
"actions": [
|
||||
"action.system.home",
|
||||
"com.ohos.action.main"
|
||||
"com.ohos.action.main",
|
||||
"action.form.publish"
|
||||
]
|
||||
}
|
||||
],
|
||||
|
Loading…
Reference in New Issue
Block a user