From 88aa27f9fb509ddee69b4f7115004be9c04e9f1d Mon Sep 17 00:00:00 2001 From: zhangchao Date: Fri, 19 Aug 2022 14:55:00 +0800 Subject: [PATCH] bugfix Signed-off-by: zhangchao --- .../default/manager/LauncherAbilityManager.ts | 35 ++++++++++----- .../ets/default/uicomponents/AppBubble.ets | 2 +- .../default/uicomponents/FolderComponent.ets | 3 -- .../uicomponents/FormItemComponent.ets | 3 -- .../uicomponents/FolderAppListDialog.ets | 7 ++- .../ets/default/view/FolderOpenComponent.ets | 14 ++++-- .../default/viewModel/BigFolderViewModel.ts | 2 +- .../ets/default/common/components/AppItem.ets | 43 ++++++++----------- .../ets/default/layout/PageDesktopLayout.ets | 3 -- .../main/ets/default/layout/RecentLayout.ets | 3 +- .../ets/default/layout/ResidentLayout.ets | 10 ++++- .../pad/src/main/ets/pages/AppCenterView.ets | 5 ++- 12 files changed, 74 insertions(+), 56 deletions(-) diff --git a/common/src/main/ets/default/manager/LauncherAbilityManager.ts b/common/src/main/ets/default/manager/LauncherAbilityManager.ts index da14543c..93f20061 100644 --- a/common/src/main/ets/default/manager/LauncherAbilityManager.ts +++ b/common/src/main/ets/default/manager/LauncherAbilityManager.ts @@ -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 { 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); } diff --git a/common/src/main/ets/default/uicomponents/AppBubble.ets b/common/src/main/ets/default/uicomponents/AppBubble.ets index 46d17203..7b6cb9d3 100644 --- a/common/src/main/ets/default/uicomponents/AppBubble.ets +++ b/common/src/main/ets/default/uicomponents/AppBubble.ets @@ -50,7 +50,7 @@ export struct AppBubble { AppMenu({ menuInfoList: this.menuInfo, closeMenu: () => { - ContextMenu.close(); + AppStorage.SetOrCreate('contextMenuState', false); } }) } diff --git a/common/src/main/ets/default/uicomponents/FolderComponent.ets b/common/src/main/ets/default/uicomponents/FolderComponent.ets index 8e3e951a..faf52415 100644 --- a/common/src/main/ets/default/uicomponents/FolderComponent.ets +++ b/common/src/main/ets/default/uicomponents/FolderComponent.ets @@ -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) diff --git a/common/src/main/ets/default/uicomponents/FormItemComponent.ets b/common/src/main/ets/default/uicomponents/FormItemComponent.ets index 04fbf416..9e8e6013 100644 --- a/common/src/main/ets/default/uicomponents/FormItemComponent.ets +++ b/common/src/main/ets/default/uicomponents/FormItemComponent.ets @@ -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) diff --git a/feature/bigfolder/src/main/ets/default/common/uicomponents/FolderAppListDialog.ets b/feature/bigfolder/src/main/ets/default/common/uicomponents/FolderAppListDialog.ets index 29d671ad..b0730969 100644 --- a/feature/bigfolder/src/main/ets/default/common/uicomponents/FolderAppListDialog.ets +++ b/feature/bigfolder/src/main/ets/default/common/uicomponents/FolderAppListDialog.ets @@ -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) } } diff --git a/feature/bigfolder/src/main/ets/default/view/FolderOpenComponent.ets b/feature/bigfolder/src/main/ets/default/view/FolderOpenComponent.ets index 8e66011b..46b96d05 100644 --- a/feature/bigfolder/src/main/ets/default/view/FolderOpenComponent.ets +++ b/feature/bigfolder/src/main/ets/default/view/FolderOpenComponent.ets @@ -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(); } } diff --git a/feature/bigfolder/src/main/ets/default/viewModel/BigFolderViewModel.ts b/feature/bigfolder/src/main/ets/default/viewModel/BigFolderViewModel.ts index c12b3e31..513ee68b 100644 --- a/feature/bigfolder/src/main/ets/default/viewModel/BigFolderViewModel.ts +++ b/feature/bigfolder/src/main/ets/default/viewModel/BigFolderViewModel.ts @@ -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; diff --git a/feature/pagedesktop/src/main/ets/default/common/components/AppItem.ets b/feature/pagedesktop/src/main/ets/default/common/components/AppItem.ets index 3925712e..b0c9731c 100644 --- a/feature/pagedesktop/src/main/ets/default/common/components/AppItem.ets +++ b/feature/pagedesktop/src/main/ets/default/common/components/AppItem.ets @@ -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')) { diff --git a/feature/pagedesktop/src/main/ets/default/layout/PageDesktopLayout.ets b/feature/pagedesktop/src/main/ets/default/layout/PageDesktopLayout.ets index 681fc4f9..6c0393c3 100644 --- a/feature/pagedesktop/src/main/ets/default/layout/PageDesktopLayout.ets +++ b/feature/pagedesktop/src/main/ets/default/layout/PageDesktopLayout.ets @@ -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) diff --git a/feature/smartdock/src/main/ets/default/layout/RecentLayout.ets b/feature/smartdock/src/main/ets/default/layout/RecentLayout.ets index 5217094f..72a4835f 100644 --- a/feature/smartdock/src/main/ets/default/layout/RecentLayout.ets +++ b/feature/smartdock/src/main/ets/default/layout/RecentLayout.ets @@ -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; diff --git a/feature/smartdock/src/main/ets/default/layout/ResidentLayout.ets b/feature/smartdock/src/main/ets/default/layout/ResidentLayout.ets index 32e84668..a85134d0 100644 --- a/feature/smartdock/src/main/ets/default/layout/ResidentLayout.ets +++ b/feature/smartdock/src/main/ets/default/layout/ResidentLayout.ets @@ -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; diff --git a/product/pad/src/main/ets/pages/AppCenterView.ets b/product/pad/src/main/ets/pages/AppCenterView.ets index 588d58d3..0db83e9a 100644 --- a/product/pad/src/main/ets/pages/AppCenterView.ets +++ b/product/pad/src/main/ets/pages/AppCenterView.ets @@ -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 {