Signed-off-by: zhangchao <zhangchao338@huawei.com>
This commit is contained in:
zhangchao 2022-08-19 14:55:00 +08:00
parent 894a78b788
commit 88aa27f9fb
12 changed files with 74 additions and 56 deletions

View File

@ -15,6 +15,7 @@
import bundleMgr from '@ohos.bundle';
import osaccount from '@ohos.account.osAccount';
import hiAppEvent from '@ohos.hiAppEvent';
import launcherBundleMgr from '@ohos.bundle.innerBundleManager';
import { LauncherAbilityInfo } from 'bundle/launcherAbilityInfo';
import { Log } from '../utils/Log';
@ -55,9 +56,9 @@ class LauncherAbilityManager {
private readonly mLauncherAbilityChangeListeners: any[] = [];
/**
*
* Get desktop application information management object
*
* @return
* @return Desktop application information management object instance
*/
static getInstance(): LauncherAbilityManager {
if (globalThis.LauncherAbilityManagerInstance == null) {
@ -73,6 +74,10 @@ class LauncherAbilityManager {
Log.showDebug(TAG, `getOsAccountLocalIdFromProcess localId ${localId}`);
this.mUserId = localId;
});
hiAppEvent.configure({
disable: true,
maxStorage: "15M"
})
}
getUserId(): number {
@ -80,9 +85,9 @@ class LauncherAbilityManager {
}
/**
* .
* Monitor system application status.
*
* @params listener
* @params listener: listening object
*/
registerLauncherAbilityChangeListener(listener: any): void {
if (listener != null) {
@ -101,9 +106,9 @@ class LauncherAbilityManager {
}
/**
* .
* Cancel monitoring system application status.
*
* @params listener
* @params listener: listening object
*/
unregisterLauncherAbilityChangeListener(listener: any): void {
if (listener != null) {
@ -155,8 +160,8 @@ class LauncherAbilityManager {
/**
* get AbilityInfos by bundleName from BMS
*
* @params bundleName
* @return Ability信息列表
* @params bundleName Application package name
* @return List of entry capabilities information of the target application
*/
async getLauncherAbilityInfo(bundleName: string): Promise<AppItemInfo[]> {
let abilityInfos: LauncherAbilityInfo[];
@ -265,10 +270,10 @@ class LauncherAbilityManager {
}
/**
*
* start the app
*
* @params paramAbilityName Ability名
* @params paramBundleName
* @params paramAbilityName: Ability name
* @params paramBundleName: Application package name
*/
startLauncherAbility(paramAbilityName: string, paramBundleName: string, paramModuleName: string) {
Log.showInfo(TAG, `startApplication abilityName: ${paramAbilityName}, bundleName: ${paramBundleName}, moduleName ${paramModuleName}`);
@ -282,6 +287,14 @@ class LauncherAbilityManager {
Log.showError(TAG, `startApplication promise error: ${JSON.stringify(err)}`);
});
Log.showDebug(TAG, `startApplication AceApplication : startAbility : ${result}`);
hiAppEvent.write('APPLICATION_LAUNCHER', hiAppEvent.EventType.BEHAVIOR, {"name": [paramBundleName, paramAbilityName, paramModuleName].join(",")},
(err, value) => {
if (err) {
Log.showError(TAG, `startApplication hiAppEvent write error: ${err.code}`);
} else {
Log.showInfo(TAG, 'startApplication hiAppEvent write success');
}
})
Trace.end(Trace.CORE_METHOD_LAUNCH_APP);
}

View File

@ -50,7 +50,7 @@ export struct AppBubble {
AppMenu({
menuInfoList: this.menuInfo,
closeMenu: () => {
ContextMenu.close();
AppStorage.SetOrCreate('contextMenuState', false);
}
})
}

View File

@ -112,9 +112,6 @@ export struct FolderComponent {
Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
AppMenu({
menuInfoList: this.buildMenu(this.mFolderItem),
closeMenu: () => {
ContextMenu.close();
}
})
}
.width(StyleConstants.CONTEXT_MENU_WIDTH)

View File

@ -52,9 +52,6 @@ export struct FormItemComponent {
Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
AppMenu({
menuInfoList: this.menuInfo,
closeMenu: () => {
ContextMenu.close();
}
})
}
.width(StyleConstants.CONTEXT_MENU_WIDTH)

View File

@ -141,7 +141,7 @@ export default struct FolderAppListDialog {
}
}
.width(this.mFolderStyleConfig.mAddFolderItemSize)
.height(this.mFolderStyleConfig.mAddFolderItemSize)
.height(this.mFolderStyleConfig.mAddFolderIconSize + this.mFolderStyleConfig.mAddFolderTextLines + this.mFolderStyleConfig.mFolderToggleSize)
}, (item) => JSON.stringify(item))
}
.columnsTemplate(this.getColumnsTemplate())
@ -212,6 +212,9 @@ export default struct FolderAppListDialog {
if (!this.navigationBarStatusValue){
Stack().width(this.mFolderStyleConfig.mAddFolderDialogWidth).height(BigFolderStyleConstants.DEFAULT_APP_GRID_TOGGLE_SIZE)
}
}.width('100%').height('100%').justifyContent(this.isPad ? FlexAlign.Center : FlexAlign.End)
}
.width('100%')
.height('100%')
.justifyContent(this.isPad ? FlexAlign.Center : FlexAlign.End)
}
}

View File

@ -23,7 +23,6 @@ import { AppName } from '@ohos/common';
import { AppBubble } from '@ohos/common';
import { UninstallDialog } from '@ohos/common';
import { FormManagerDialog } from '@ohos/common';
import { windowManager } from '@ohos/common';
import { ResourceManager } from '@ohos/common';
import { localEventManager } from '@ohos/common';
import { InputMethodManager } from '@ohos/common';
@ -41,7 +40,6 @@ const FOLDER_CLOSE_DELAY = 500;
let mBigFolderViewModel: BigFolderViewModel;
let mBigFolderStyleConfig: BigFolderStyleConfig;
let mFolderModel: BigFolderModel;
let isOpenFolderDialog: boolean = false;
let mAppNameHeight = BigFolderStyleConstants.DEFAULT_APP_NAME_HEIGHT;
let mAppItemWidth = BigFolderStyleConstants.DEFAULT_APP_ITEM_WIDTH;
let mAppNameSize = BigFolderStyleConstants.DEFAULT_APP_NAME_SIZE;
@ -278,7 +276,11 @@ export struct FolderOpenComponent {
mBigFolderViewModel.modifyFolderName(this.mFolderInfo)
}
} else {
if (!isOpenFolderDialog) {
const contextFlag: boolean = AppStorage.Get('contextMenuState');
Log.showInfo(TAG, 'saveText contextFlag: ' + contextFlag);
if (contextFlag) {
AppStorage.SetOrCreate('contextMenuState', false);
} else {
mBigFolderViewModel.closeFolder();
}
}
@ -419,7 +421,11 @@ struct FolderSwiperPage {
mBigFolderViewModel.modifyFolderName(this.mFolderInfo);
}
} else {
if (!isOpenFolderDialog) {
const contextFlag: boolean = AppStorage.Get('contextMenuState');
Log.showInfo(TAG, 'saveText contextFlag: ' + contextFlag);
if (contextFlag) {
AppStorage.SetOrCreate('contextMenuState', false);
} else {
mBigFolderViewModel.closeFolder();
}
}

View File

@ -993,7 +993,7 @@ export class BigFolderViewModel extends BaseViewModel {
if (num <= row) {
height = styleConfig.mAddFolderDialogHeight;
} else {
const gridHeight = num * styleConfig.mAddFolderItemSize + num * styleConfig.mAddFolderGridGap +
const gridHeight = num * (this.mFolderStyleConfig.mAddFolderIconSize + this.mFolderStyleConfig.mAddFolderTextLines) + num * styleConfig.mAddFolderGridGap +
styleConfig.mAddFolderGridMargin * 2;
height = gridHeight + BigFolderStyleConstants.DEFAULT_APP_ADD_TITLE_SIZE +
BigFolderStyleConstants.DEFAULT_BUTTON_HEIGHT + BigFolderStyleConstants.DEFAULT_DIALOG_BOTTOM_MARGIN;

View File

@ -187,30 +187,25 @@ export default struct AppItem {
AppStorage.SetOrCreate('selectDesktopAppItem', this.item.keyName);
}
})
.gesture(
GestureGroup(GestureMode.Exclusive,
TapGesture()
.onAction((event: GestureEvent) => {
Log.showInfo(TAG, `tap action ${JSON.stringify(event)}`);
if (event.source == SourceType.Mouse) {
this.mouseClick++;
if (this.mouseClick == DOUBLE_CLICK_COUNT) {
Log.showInfo(TAG, 'mouse double click');
this.mouseClick = 0;
this.launchApp();
} else {
this.mPageDesktopViewModel.onAppClick(this.item.abilityName, this.item.bundleName, this.item.moduleName);
setTimeout(() => {
this.mouseClick = 0;
}, 300)
}
} else {
Log.showInfo(TAG, 'tap click');
this.launchApp();
}
})
)
)
.onClick((event) => {
Log.showInfo(TAG, `tap action ${JSON.stringify(event)}`);
if (event.source == SourceType.Mouse) {
this.mouseClick++;
if (this.mouseClick == DOUBLE_CLICK_COUNT) {
Log.showInfo(TAG, 'mouse double click');
this.mouseClick = 0;
this.launchApp();
} else {
this.mPageDesktopViewModel.onAppClick(this.item.abilityName, this.item.bundleName, this.item.moduleName);
setTimeout(() => {
this.mouseClick = 0;
}, 300)
}
} else {
Log.showInfo(TAG, 'tap click');
this.launchApp();
}
})
.onTouch((event: TouchEvent) => {
Log.showDebug(TAG, `onTouch event type: ${event.type}, x: ${event.touches[0].screenX}, y: ${event.touches[0].screenY}`);
if (event.type === CommonConstants.TOUCH_TYPE_UP && AppStorage.Get('isDrag')) {

View File

@ -134,9 +134,6 @@ export struct PageDesktopLayout {
Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
AppMenu({
getMenuInfoList: this.getMenu,
closeMenu: () => {
ContextMenu.close();
}
})
}
.width(StyleConstants.CONTEXT_MENU_WIDTH)

View File

@ -142,7 +142,7 @@ export default struct RecentLayout {
this.updateData = () => {
}
}
}
},
})
.onHover((isHover) => {
this.autoCancel = false;
@ -253,6 +253,7 @@ struct AppItem {
builder: this.MenuBuilder,
placement: Placement.Top,
popupColor: Color.White,
arrowOffset: 3 * (mSmartDockStyleConfig.mIconSize / 2) + mSmartDockStyleConfig.mListItemGap,
onStateChange: (e) => {
if (!e.isVisible) {
this.isShow = false;

View File

@ -1,3 +1,4 @@
// @ts-nocheck
/**
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
@ -74,7 +75,11 @@ export default struct ResidentLayout {
})
}
.onClick((event: ClickEvent) => {
this.onItemClick(event, item);
const popupIsShow: boolean = AppStorage.Get('popupIsShow');
if (!popupIsShow) {
this.onItemClick(event, item);
}
AppStorage.SetOrCreate('popupIsShow', false);
})
}, (item) => JSON.stringify(item))
}
@ -181,12 +186,15 @@ struct AppItem {
Log.showInfo(TAG, 'onAction start');
this.isShow = true;
AppStorage.SetOrCreate('isLongPress', true);
// Control whether the onClick method is executed or not.
AppStorage.SetOrCreate('popupIsShow', true);
})
)
.bindPopup(this.isShow, {
builder: this.MenuBuilder,
placement: Placement.Top,
popupColor: Color.White,
arrowOffset: 3 * (mSmartDockStyleConfig.mIconSize / 2) + mSmartDockStyleConfig.mListItemGap,
onStateChange: (e) => {
if (!e.isVisible) {
this.isShow = false;

View File

@ -50,11 +50,11 @@ struct AppCenterView {
onPageHide(): void {
Log.showInfo(TAG, 'onPageHide');
this.mAppGridViewModel.unregisterAppListChange();
}
aboutToDisappear(): void {
Log.showInfo(TAG, 'aboutToDisappear');
this.mAppGridViewModel.unregisterAppListChange();
}
private async updateScreenSize() {
@ -103,7 +103,8 @@ struct AppCenterView {
.height('100%')
.onClick(() => {
Log.showInfo(TAG, 'click appcenter area');
let contextFlag = AppStorage.Get('contextMenuState');
const contextFlag: boolean = AppStorage.Get('contextMenuState');
Log.showInfo(TAG, 'onClick contextFlag: ' + contextFlag);
if (contextFlag) {
AppStorage.SetOrCreate('contextMenuState', false);
}else {