!440 fix:update open bigfolder app display badgenumber

Merge pull request !440 from giteewzp/master07
This commit is contained in:
openharmony_ci 2023-12-12 09:30:43 +00:00 committed by Gitee
commit 4b106d4341
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
49 changed files with 687 additions and 497 deletions

View File

@ -65,7 +65,7 @@ export {
} from './src/main/ets/default/manager'
export {
DragArea, DragItemPosition
DragArea, DragItemPosition, GridLayoutInfo, FolderData
} from './src/main/ets/default/interface'
export {

View File

@ -19,6 +19,7 @@ import { AppModel } from '../model/AppModel';
import { ResourceManager } from '../manager/ResourceManager';
import { CommonConstants } from '../constants/CommonConstants';
import { launcherAbilityManager } from '../manager/LauncherAbilityManager';
import { AsyncCallback } from '@ohos.base';
const TAG = 'BaseViewModel';
@ -27,7 +28,7 @@ const KEY_NAME = 'name';
/**
* Base class for view models.
*/
export class BaseViewModel {
export class BaseViewModel {
protected mAppModel: AppModel;
protected mResourceManager: ResourceManager;
private readonly listener;
@ -66,6 +67,10 @@ const KEY_NAME = 'name';
this.jumpTo(CommonConstants.SETTING_ABILITY, CommonConstants.LAUNCHER_BUNDLE, CommonConstants.SETTING_MODULE);
}
private uninstallAppCallback = (resultCode: number): void => {
this.informUninstallResult(resultCode);
}
/**
* Uninstall target app by bundle name.
*
@ -76,14 +81,10 @@ const KEY_NAME = 'name';
if (!isUninstallable) {
this.informUninstallResult(CommonConstants.UNINSTALL_FORBID);
} else {
void launcherAbilityManager.uninstallLauncherAbility(uninstallBundleName, this.uninstallAppCallback.bind(this));
void launcherAbilityManager.uninstallLauncherAbility(uninstallBundleName, this.uninstallAppCallback);
}
}
private uninstallAppCallback(resultData: {code: number}): void {
this.informUninstallResult(resultData.code);
}
registerAppListChangeCallback(): void {
this.mAppModel.registerStateChangeListener(this.listener);
}
@ -101,7 +102,7 @@ const KEY_NAME = 'name';
}
informUninstallResult(resultCode: number): void {
Log.showDebug(TAG, `Launcher AppListView getUninstallApp uninstallationResult: ${resultCode}`);
Log.showDebug(TAG, `Launcher AppListView getUninstallApp uninstallationResult: ${resultCode}`);
if (resultCode === CommonConstants.UNINSTALL_FORBID) {
Prompt.showToast({
message: $r("app.string.disable_uninstall")

View File

@ -62,9 +62,9 @@ export class AppItemInfo {
*/
badgeNumber: number | undefined;
checked?: boolean | undefined;
checked: boolean | undefined;
installTime?: string | undefined;
installTime: string | undefined;
moduleName: string | undefined;

View File

@ -12,6 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { AppItemInfo } from './AppItemInfo';
import GridLayoutItemBuilder from './GridLayoutItemBuilder';
@ -96,7 +97,7 @@ export default class GridLayoutItemInfo {
/**
* GridLayoutItemInfo: bigFolder apps info
*/
layoutInfo: any | undefined;
layoutInfo: AppItemInfo[][] | undefined;
/**
* GridLayoutItemInfo: extend1

View File

@ -56,4 +56,5 @@ export class LauncherDragItemInfo {
layoutInfo?: AppItemInfo[][];
itemType?: number;
editable?: boolean;
enterEditing?: boolean;
}

View File

@ -0,0 +1,24 @@
/**
* Copyright (c) 2023 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.
*/
import { AppItemInfo } from '../bean';
export class FolderData {
layoutInfo: AppItemInfo[][];
enterEditing: boolean;
folderName: string;
folderId: string;
badgeNumber?: number;
}

View File

@ -0,0 +1,25 @@
/**
* Copyright (c) 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.
*/
import { LauncherDragItemInfo } from '../bean/LauncherDragItemInfo';
export interface GridLayoutInfo {
layoutDescription: {
pageCount: number;
row: number;
column: number;
} | undefined;
layoutInfo: LauncherDragItemInfo[];
}

View File

@ -13,6 +13,10 @@
* limitations under the License.
*/
export { DragArea } from './DragArea'
export { DragArea } from './DragArea';
export { DragItemPosition } from './DragItemPosition'
export { DragItemPosition } from './DragItemPosition';
export { GridLayoutInfo } from './GridLayoutInfo';
export { FolderData } from './FolderData';

View File

@ -17,6 +17,7 @@ import { Log } from '../utils/Log';
import { ILayoutConfig } from './ILayoutConfig';
import { CommonConstants } from '../constants/CommonConstants';
import FileUtils from '../utils/FileUtils';
import { GridLayoutInfo } from '../interface';
const TAG = 'PageDesktopLayoutConfig';
@ -35,7 +36,7 @@ export class PageDesktopLayoutConfig extends ILayoutConfig {
private static readonly DEFAULT_COLUMN_COUNT = 4;
private static readonly DEFAULT_LAYOUT_INFO: any = {
private static readonly DEFAULT_LAYOUT_INFO: GridLayoutInfo = {
layoutDescription: {
pageCount: PageDesktopLayoutConfig.DEFAULT_PAGE_COUNT,
row: PageDesktopLayoutConfig.DEFAULT_ROW_COUNT,
@ -44,7 +45,7 @@ export class PageDesktopLayoutConfig extends ILayoutConfig {
layoutInfo: []
};
private mGridLayoutInfo: any = PageDesktopLayoutConfig.DEFAULT_LAYOUT_INFO;
private mGridLayoutInfo: GridLayoutInfo = PageDesktopLayoutConfig.DEFAULT_LAYOUT_INFO;
locked: boolean = false;
@ -88,7 +89,7 @@ export class PageDesktopLayoutConfig extends ILayoutConfig {
*
* @params gridLayoutInfo
*/
updateGridLayoutInfo(gridLayoutInfo: any): void {
updateGridLayoutInfo(gridLayoutInfo: GridLayoutInfo): void {
const temp = gridLayoutInfo;
FileUtils.writeStringToFile(JSON.stringify(temp), this.getConfigFileAbsPath());
this.mGridLayoutInfo = gridLayoutInfo;
@ -116,7 +117,7 @@ export class PageDesktopLayoutConfig extends ILayoutConfig {
*
* @return Workspace layout data
*/
getGridLayoutInfo(): any {
getGridLayoutInfo(): GridLayoutInfo {
return this.mGridLayoutInfo;
}

View File

@ -13,10 +13,8 @@
* limitations under the License.
*/
import CommonEvent from '@ohos.commonEvent';
import { AsyncCallback } from '@ohos.base';
import { CommonEventData } from 'commonEvent/commonEventData';
import { CommonEventSubscriber } from 'commonEvent/commonEventSubscriber';
import commonEventMgr from '@ohos.commonEventManager';
const TAG = 'CommonEventManager';
@ -27,8 +25,8 @@ class CommonEventManager {
RECENT_FULL_SCREEN = 'CREATE_RECENT_WINDOW_EVENT';
RECENT_SPLIT_SCREEN = 'common.event.SPLIT_SCREEN';
private callbackList: AsyncCallback<CommonEventData>[] = [];
private subscriberList: CommonEventSubscriber[] = [];
private callbackList: AsyncCallback<commonEventMgr.CommonEventData>[] = [];
private subscriberList: commonEventMgr.CommonEventSubscriber[] = [];
/**
* get CommonEventManager instance
@ -48,11 +46,12 @@ class CommonEventManager {
/**
* Register common event listener.
*/
public registerCommonEvent(subscriber: CommonEventSubscriber, eventCallback: AsyncCallback<CommonEventData>): void {
if (this.subscriberList.indexOf(subscriber) != -1) {
public registerCommonEvent(subscriber: commonEventMgr.CommonEventSubscriber,
eventCallback: AsyncCallback<commonEventMgr.CommonEventData>): void {
if (this.subscriberList.indexOf(subscriber) !== -1) {
return;
}
CommonEvent.subscribe(subscriber, eventCallback);
commonEventMgr.subscribe(subscriber, eventCallback);
this.subscriberList.push(subscriber);
this.callbackList.push(eventCallback);
}
@ -60,14 +59,15 @@ class CommonEventManager {
/**
* Unregister common event listener.
*/
public unregisterCommonEvent(subscriber: CommonEventSubscriber, eventCallback: AsyncCallback<CommonEventData>): void {
public unregisterCommonEvent(subscriber: commonEventMgr.CommonEventSubscriber,
eventCallback: AsyncCallback<commonEventMgr.CommonEventData>): void {
const subscriberIndex: number = this.subscriberList.indexOf(subscriber);
const callbackIndex: number = this.callbackList.indexOf(eventCallback);
if (subscriberIndex != -1) {
CommonEvent.unsubscribe(subscriber);
if (subscriberIndex !== -1) {
commonEventMgr.unsubscribe(subscriber);
this.subscriberList.splice(subscriberIndex, 1);
}
callbackIndex != -1 && this.callbackList.splice(callbackIndex, 1);
callbackIndex !== -1 && this.callbackList.splice(callbackIndex, 1);
}
}

View File

@ -28,6 +28,6 @@ export class InputMethodManager {
}
stopInput(): void {
inputMethod.getInputMethodController()?.stopInput();
inputMethod.getController()?.stopInputSession();
}
}

View File

@ -13,43 +13,48 @@
* limitations under the License.
*/
import bundleMgr from '@ohos.bundle';
import installer from '@ohos.bundle.installer';
import bundleMonitor from '@ohos.bundle.bundleMonitor';
import osAccount from '@ohos.account.osAccount';
import hiSysEvent from '@ohos.hiSysEvent';
import launcherBundleMgr from '@ohos.bundle.innerBundleManager';
import { LauncherAbilityInfo } from 'bundle/launcherAbilityInfo';
import launcherBundleManager from '@ohos.bundle.launcherBundleManager';
import { Log } from '../utils/Log';
import { Trace } from '../utils/Trace';
import { CheckEmptyUtils } from '../utils/CheckEmptyUtils';
import { AppItemInfo } from '../bean/AppItemInfo';
import { CommonConstants } from '../constants/CommonConstants';
import { ResourceManager } from './ResourceManager';
import { EventConstants } from '../constants/EventConstants';
import { BadgeManager } from '../manager/BadgeManager';
import { BusinessError } from '@ohos.base';
const TAG = 'LauncherAbilityManager';
interface BundleStatusCallback {
add: (bundleName: string, userId: number) => void;
remove: (bundleName: string, userId: number) => void;
update: (bundleName: string, userId: number) => void;
}
/**
* Wrapper class for innerBundleManager and formManager interfaces.
*/
class LauncherAbilityManager {
private static readonly CURRENT_USER_ID = -2;
private static readonly BUNDLE_STATUS_CHANGE_KEY = 'BundleStatusChange';
private readonly mAppMap = new Map<string, AppItemInfo>();
private mUserId: number = 100;
private readonly mBundleStatusCallback: any = {
private readonly mBundleStatusCallback: BundleStatusCallback = {
add: (bundleName, userId) => {
Log.showDebug(TAG, `mBundleStatusCallback add bundleName: ${bundleName}, userId: ${userId}, mUserId ${this.mUserId}`);
this.mUserId == userId && this.notifyLauncherAbilityChange(EventConstants.EVENT_PACKAGE_ADDED, bundleName, userId);
Log.showDebug(TAG, `PACKAGE_ADDED bundleName: ${bundleName}, userId: ${userId}, mUserId ${this.mUserId}`);
this.mUserId === userId && this.notifyLauncherAbilityChange(EventConstants.EVENT_PACKAGE_ADDED, bundleName, userId);
},
remove: (bundleName, userId) => {
Log.showDebug(TAG, `mBundleStatusCallback remove bundleName: ${bundleName}, userId: ${userId}, mUserId ${this.mUserId}`);
this.mUserId == userId && this.notifyLauncherAbilityChange(EventConstants.EVENT_PACKAGE_REMOVED, bundleName, userId);
Log.showDebug(TAG, `PACKAGE_REMOVED bundleName: ${bundleName}, userId: ${userId}, mUserId ${this.mUserId}`);
this.mUserId === userId && this.notifyLauncherAbilityChange(EventConstants.EVENT_PACKAGE_REMOVED, bundleName, userId);
},
update: (bundleName, userId) => {
Log.showDebug(TAG, `mBundleStatusCallback update bundleName: ${bundleName}, userId: ${userId}, mUserId ${this.mUserId}`);
this.mUserId == userId && this.notifyLauncherAbilityChange(EventConstants.EVENT_PACKAGE_CHANGED, bundleName, userId);
Log.showDebug(TAG, `PACKAGE_CHANGED bundleName: ${bundleName}, userId: ${userId}, mUserId ${this.mUserId}`);
this.mUserId === userId && this.notifyLauncherAbilityChange(EventConstants.EVENT_PACKAGE_CHANGED, bundleName, userId);
}
};
@ -87,11 +92,25 @@ class LauncherAbilityManager {
registerLauncherAbilityChangeListener(listener: any): void {
if (listener != null) {
if (this.mLauncherAbilityChangeListeners.length == 0) {
launcherBundleMgr.on(LauncherAbilityManager.BUNDLE_STATUS_CHANGE_KEY, this.mBundleStatusCallback).then(data => {
Log.showDebug(TAG, `registerCallback success: ${JSON.stringify(data)}`);
}).catch(err => {
Log.showError(TAG, `registerCallback fail: ${JSON.stringify(err)}`);
});
try {
bundleMonitor.on('add', (bundleChangeInfo) => {
Log.showInfo(TAG, `add bundleName: ${bundleChangeInfo.bundleName} userId: ${bundleChangeInfo.userId}`);
this.mBundleStatusCallback.add(bundleChangeInfo.bundleName, bundleChangeInfo.userId);
});
bundleMonitor.on('update', (bundleChangeInfo) => {
Log.showInfo(TAG, `update bundleName: ${bundleChangeInfo.bundleName} userId: ${bundleChangeInfo.userId}`);
this.mBundleStatusCallback.update(bundleChangeInfo.bundleName, bundleChangeInfo.userId);
});
bundleMonitor.on('remove', (bundleChangeInfo) => {
Log.showInfo(TAG, `remove bundleName: ${bundleChangeInfo.bundleName} userId: ${bundleChangeInfo.userId}`);
this.mBundleStatusCallback.remove(bundleChangeInfo.bundleName, bundleChangeInfo.userId);
});
Log.showInfo(TAG, `registerCallback success`);
} catch (errData) {
let message = (errData as BusinessError).message;
let errCode = (errData as BusinessError).code;
Log.showError(TAG, `registerCallback fail errCode:${errCode}, message:${message}`);
}
}
const index = this.mLauncherAbilityChangeListeners.indexOf(listener);
if (index == CommonConstants.INVALID_VALUE) {
@ -112,11 +131,16 @@ class LauncherAbilityManager {
this.mLauncherAbilityChangeListeners.splice(index, 1);
}
if (this.mLauncherAbilityChangeListeners.length == 0) {
launcherBundleMgr.off(LauncherAbilityManager.BUNDLE_STATUS_CHANGE_KEY).then(data => {
Log.showDebug(TAG, 'unregisterCallback success');
}).catch(err => {
Log.showError(TAG, `unregisterCallback fail: ${JSON.stringify(err)}`);
});
try {
bundleMonitor.off('add');
bundleMonitor.off('update');
bundleMonitor.off('remove');
Log.showInfo(TAG, 'unregisterCallback success');
} catch (errData) {
let message = (errData as BusinessError).message;
let errCode = (errData as BusinessError).code;
Log.showError(TAG, `unregisterCallback fail errCode:${errCode}, message:${message}`);
}
}
}
}
@ -132,7 +156,7 @@ class LauncherAbilityManager {
*/
async getLauncherAbilityList(): Promise<AppItemInfo[]> {
let abilityList = null;
await launcherBundleMgr.getAllLauncherAbilityInfos(LauncherAbilityManager.CURRENT_USER_ID)
await launcherBundleManager.getAllLauncherAbilityInfo(LauncherAbilityManager.CURRENT_USER_ID)
.then((res) => {
abilityList = res;
})
@ -158,8 +182,8 @@ class LauncherAbilityManager {
* @return List of entry capabilities information of the target application
*/
async getLauncherAbilityInfo(bundleName: string): Promise<AppItemInfo[]> {
let abilityInfos: LauncherAbilityInfo[];
await launcherBundleMgr.getLauncherAbilityInfos(bundleName, this.mUserId)
let abilityInfos: launcherBundleManager.LauncherAbilityInfo[];
await launcherBundleManager.getLauncherAbilityInfo(bundleName, this.mUserId)
.then((res) => {
abilityInfos = res;
})
@ -193,15 +217,15 @@ class LauncherAbilityManager {
return appItemInfo;
}
// get from system
let abilityInfos = new Array<LauncherAbilityInfo>();
await launcherBundleMgr.getLauncherAbilityInfos(bundleName, LauncherAbilityManager.CURRENT_USER_ID)
let abilityInfos = new Array<launcherBundleManager.LauncherAbilityInfo>();
await launcherBundleManager.getLauncherAbilityInfo(bundleName, LauncherAbilityManager.CURRENT_USER_ID)
.then((res)=>{
if (res && res.length) {
abilityInfos = res;
}
})
.catch((err)=>{
Log.showError(TAG, `getAppInfoByBundleName launcherBundleMgr getLauncherAbilityInfos error: ${JSON.stringify(err)}`);
Log.showError(TAG, `getAppInfoByBundleName getLauncherAbilityInfo error: ${JSON.stringify(err)}`);
});
if (!abilityInfos || abilityInfos.length === 0) {
Log.showDebug(TAG, `${bundleName} has no launcher ability`);
@ -247,17 +271,28 @@ class LauncherAbilityManager {
* @params bundleName application bundleName
* @params callback to get result
*/
async uninstallLauncherAbility(bundleName: string, callback): Promise<void> {
async uninstallLauncherAbility(bundleName: string, callback: (resultCode: number) => void): Promise<void> {
Log.showInfo(TAG, `uninstallLauncherAbility bundleName: ${bundleName}`);
const bundlerInstaller = await bundleMgr.getBundleInstaller();
bundlerInstaller.uninstall(bundleName, {
userId: this.mUserId,
installFlag: 0,
isKeepData: false
}, (result) => {
Log.showDebug(TAG, `uninstallLauncherAbility result => ${JSON.stringify(result)}`);
callback(result);
});
try {
const bundlerInstaller = await installer.getBundleInstaller();
bundlerInstaller.uninstall(bundleName, {
userId: this.mUserId,
installFlag: 0,
isKeepData: false
}, (err: BusinessError) => {
if (err) {
callback(CommonConstants.INVALID_VALUE);
Log.showError(TAG, `uninstallLauncherAbility failed: ${JSON.stringify(err)}`);
} else {
callback(CommonConstants.UNINSTALL_SUCCESS);
Log.showDebug(TAG, `uninstallLauncherAbility successfully: ${JSON.stringify(err)}`);
}
});
} catch (err) {
let errCode = (err as BusinessError).code;
let errMsg = (err as BusinessError).message;
Log.showError(TAG, `uninstallLauncherAbility errCode: ${errCode}, errMsg: ${errMsg}`);
}
}
/**
@ -321,9 +356,9 @@ class LauncherAbilityManager {
});
}
async getShortcutInfo(paramBundleName, callback) {
async getShortcutInfo(paramBundleName: string, callback) {
Log.showDebug(TAG, `getShortcutInfo bundleName: ${paramBundleName}`);
await launcherBundleMgr.getShortcutInfos(paramBundleName)
await launcherBundleManager.getShortcutInfo(paramBundleName)
.then(shortcutInfo => {
callback(paramBundleName, shortcutInfo);
})
@ -337,7 +372,7 @@ class LauncherAbilityManager {
* @params paramBundleName application bundle name
* @params paramAbilityName application abilit uri
*/
startLauncherAbilityByUri(paramBundleName, abilityUri) {
startLauncherAbilityByUri(paramBundleName: string, abilityUri) {
Log.showInfo(TAG, `startLauncherAbilityByUri bundleName:${paramBundleName} abilityUri:${abilityUri}`);
const result = globalThis.desktopContext.startAbility({
bundleName: paramBundleName,

View File

@ -13,11 +13,8 @@
* limitations under the License.
*/
import CommonEvent from '@ohos.commonEvent';
import { AsyncCallback, BusinessError} from '@ohos.base';
import { CommonEventData } from 'commonEvent/commonEventData';
import { CommonEventSubscriber } from 'commonEvent/commonEventSubscriber';
import { CommonEventSubscribeInfo } from 'commonEvent/commonEventSubscribeInfo';
import commonEventMgr from '@ohos.commonEventManager';
import { EventConstants } from '../constants/EventConstants';
import { localEventManager } from './LocalEventManager';
import commonEventManager from './CommonEventManager';
@ -29,71 +26,74 @@ const TAG = 'NavigationBarCommonEventManager';
* Wrapper class for NavigationBarCommonEvent interfaces.
*/
class NavigationBarCommonEventManager {
private static NAVIGATION_BAR_HIDE = 'systemui.event.NAVIGATIONBAR_HIDE';
private static subscriber: CommonEventSubscriber;
private static eventCallback: AsyncCallback<CommonEventData>;
private static NAVIGATION_BAR_HIDE = 'systemui.event.NAVIGATIONBAR_HIDE';
private static subscriber: commonEventMgr.CommonEventSubscriber;
private static eventCallback: AsyncCallback<commonEventMgr.CommonEventData>;
/**
* get NavigationBarCommonEvent instance
*
* @return NavigationBarCommonEvent singleton
*/
static getInstance(): NavigationBarCommonEventManager {
if (globalThis.NavigationBarCommonEvent == null) {
globalThis.NavigationBarCommonEvent = new NavigationBarCommonEventManager();
this.eventCallback = this.navigationBarEventCallback.bind(this);
this.initSubscriber();
}
return globalThis.NavigationBarCommonEvent;
/**
* get NavigationBarCommonEvent instance
*
* @return NavigationBarCommonEvent singleton
*/
static getInstance(): NavigationBarCommonEventManager {
if (globalThis.NavigationBarCommonEvent == null) {
globalThis.NavigationBarCommonEvent = new NavigationBarCommonEventManager();
this.eventCallback = this.navigationBarEventCallback.bind(this);
this.initSubscriber();
}
return globalThis.NavigationBarCommonEvent;
}
private static initSubscriber() {
if (NavigationBarCommonEventManager.subscriber != null) {
return;
}
const subscribeInfo: CommonEventSubscribeInfo = {
events: [NavigationBarCommonEventManager.NAVIGATION_BAR_HIDE]
};
CommonEvent.createSubscriber(subscribeInfo).then((commonEventSubscriber: CommonEventSubscriber) => {
Log.showDebug(TAG, "init SPLIT_SCREEN subscriber success");
NavigationBarCommonEventManager.subscriber = commonEventSubscriber;
}, (err) => {
Log.showError(TAG, `Failed to createSubscriber ${err}`)
})
private static initSubscriber() {
if (NavigationBarCommonEventManager.subscriber != null) {
return;
}
const subscribeInfo: commonEventMgr.CommonEventSubscribeInfo = {
events: [NavigationBarCommonEventManager.NAVIGATION_BAR_HIDE]
};
commonEventMgr.createSubscriber(subscribeInfo).then(
(commonEventSubscriber: commonEventMgr.CommonEventSubscriber) => {
Log.showDebug(TAG, "init SPLIT_SCREEN subscriber success");
NavigationBarCommonEventManager.subscriber = commonEventSubscriber;
}, (err) => {
Log.showError(TAG, `Failed to createSubscriber ${err}`);
})
}
/**
* Register navigationBar event listener.
*/
public registerNavigationBarEvent() {
commonEventManager.registerCommonEvent(NavigationBarCommonEventManager.subscriber, NavigationBarCommonEventManager.eventCallback);
}
/**
* Register navigationBar event listener.
*/
public registerNavigationBarEvent() {
commonEventManager.registerCommonEvent(NavigationBarCommonEventManager.subscriber,
NavigationBarCommonEventManager.eventCallback);
}
/**
* Unregister navigationBar event listener.
*/
public unregisterNavigationBarEvent() {
commonEventManager.unregisterCommonEvent(NavigationBarCommonEventManager.subscriber, NavigationBarCommonEventManager.eventCallback);
}
/**
* Unregister navigationBar event listener.
*/
public unregisterNavigationBarEvent() {
commonEventManager.unregisterCommonEvent(NavigationBarCommonEventManager.subscriber,
NavigationBarCommonEventManager.eventCallback);
}
/**
* navigationBar event handler.
*/
private static async navigationBarEventCallback(error: BusinessError, data: CommonEventData) {
Log.showDebug(TAG,`navigationBarEventCallback receive data: ${JSON.stringify(data)}.`);
if (error.code != 0) {
Log.showError(TAG, `navigationBarEventCallback error: ${JSON.stringify(error)}`);
return;
}
switch (data.event) {
case NavigationBarCommonEventManager.NAVIGATION_BAR_HIDE:
setTimeout(() => {
localEventManager.sendLocalEventSticky(EventConstants.EVENT_NAVIGATOR_BAR_STATUS_CHANGE, '0');
}, 30)
default:
break;
}
/**
* navigationBar event handler.
*/
private static async navigationBarEventCallback(error: BusinessError, data: commonEventMgr.CommonEventData) {
Log.showDebug(TAG,`navigationBarEventCallback receive data: ${JSON.stringify(data)}.`);
if (data.code !== 0) {
Log.showError(TAG, `navigationBarEventCallback error: ${JSON.stringify(error)}`);
return;
}
switch (data.event) {
case NavigationBarCommonEventManager.NAVIGATION_BAR_HIDE:
setTimeout(() => {
localEventManager.sendLocalEventSticky(EventConstants.EVENT_NAVIGATOR_BAR_STATUS_CHANGE, '0');
}, 30)
default:
break;
}
}
}
export const navigationBarCommonEventManager = NavigationBarCommonEventManager.getInstance();

View File

@ -13,7 +13,9 @@
* limitations under the License.
*/
import dataRdb from '@ohos.data.rdb';
import relationalStore from '@ohos.data.relationalStore';
import { BusinessError } from '@ohos.base';
import deviceInfo from '@ohos.deviceInfo';
import hiSysEvent from '@ohos.hiSysEvent';
import { Log } from '../utils/Log';
import { CheckEmptyUtils } from '../utils/CheckEmptyUtils';
@ -27,6 +29,8 @@ import GridLayoutItemInfo from '../bean/GridLayoutItemInfo';
import GridLayoutItemBuilder from '../bean/GridLayoutItemBuilder';
import GridLayoutInfoColumns from '../bean/GridLayoutInfoColumns';
import DesktopApplicationColumns from '../bean/DesktopApplicationColumns';
import { GridLayoutInfo } from '../interface';
import { LauncherDragItemInfo } from '../bean';
const TAG = 'RdbStoreManager';
@ -34,7 +38,7 @@ const TAG = 'RdbStoreManager';
* Wrapper class for rdb interfaces.
*/
export class RdbStoreManager {
private mRdbStore;
private mRdbStore: relationalStore.RdbStore;
private constructor() {
}
@ -52,20 +56,23 @@ export class RdbStoreManager {
async initRdbConfig(): Promise<void> {
Log.showInfo(TAG, 'initRdbConfig start');
await dataRdb.getRdbStore(globalThis.desktopContext, {
name: RdbStoreConfig.DB_NAME
}, RdbStoreConfig.DB_VERSION)
.then((rdbStore) => {
this.mRdbStore = rdbStore;
})
.catch((error) => {
Log.showError(TAG, `initRdbConfig Failed to obtain the rdbStore. Cause: ${error.message}`);
});
try {
const STORE_CONFIG: relationalStore.StoreConfig = {
name: RdbStoreConfig.DB_NAME,
securityLevel: relationalStore.SecurityLevel.S3
};
this.mRdbStore = await relationalStore.getRdbStore(globalThis.desktopContext, STORE_CONFIG);
} catch (error) {
let err = error as BusinessError;
Log.showError(TAG, `initRdbConfig Failed. code: ${err.code}, message: ${err.message}`);
}
}
async createTable(): Promise<void> {
Log.showDebug(TAG, 'create table start');
try {
await this.mRdbStore.executeSql(RdbStoreConfig.Settings.CREATE_TABLE);
await this.mRdbStore.executeSql(RdbStoreConfig.Badge.CREATE_TABLE);
await this.mRdbStore.executeSql(RdbStoreConfig.Form.CREATE_TABLE);
await this.mRdbStore.executeSql(RdbStoreConfig.SmartDock.CREATE_TABLE);
@ -75,24 +82,24 @@ export class RdbStoreManager {
// set default settings data
await this.updateSettings();
} catch (error) {
Log.showError(TAG, `create table error: ${error}`);
Log.showError(TAG, `createTable error: ${JSON.stringify(error)}`);
}
Log.showDebug(TAG, 'create table end');
}
async getAllBadge(): Promise<BadgeItemInfo[]> {
Log.showDebug(TAG, 'getAllBadge start');
const predicates = new dataRdb.RdbPredicates(RdbStoreConfig.Badge.TABLE_NAME);
const predicates = new relationalStore.RdbPredicates(RdbStoreConfig.Badge.TABLE_NAME);
const resultList: BadgeItemInfo[] = [];
try {
let resultSet = await this.mRdbStore.query(predicates, []);
let resultSet = await this.mRdbStore.query(predicates);
let isLast = resultSet.goToFirstRow();
while (isLast) {
const itemInfo: BadgeItemInfo = new BadgeItemInfo();
itemInfo.id = resultSet.getLong(resultSet.getColumnIndex('id'));
itemInfo.id = resultSet.getString(resultSet.getColumnIndex('id'));
itemInfo.bundleName = resultSet.getString(resultSet.getColumnIndex('bundle_name'));
itemInfo.badgeNumber = resultSet.getLong(resultSet.getColumnIndex('badge_number'));
itemInfo.display = resultSet.getLong(resultSet.getColumnIndex('display'));
itemInfo.display = this.numberToBoolean(resultSet.getLong(resultSet.getColumnIndex('display')));
itemInfo.userId = resultSet.getLong(resultSet.getColumnIndex('user_id'));
resultList.push(itemInfo);
isLast = resultSet.goToNextRow();
@ -112,16 +119,16 @@ export class RdbStoreManager {
return resultList;
}
try {
const predicates = new dataRdb.RdbPredicates(RdbStoreConfig.Badge.TABLE_NAME);
const predicates = new relationalStore.RdbPredicates(RdbStoreConfig.Badge.TABLE_NAME);
predicates.equalTo('bundle_name', bundleName);
let resultSet = await this.mRdbStore.query(predicates, []);
let resultSet = await this.mRdbStore.query(predicates);
let isLast = resultSet.goToFirstRow();
while (isLast) {
const itemInfo: BadgeItemInfo = new BadgeItemInfo();
itemInfo.id = resultSet.getLong(resultSet.getColumnIndex('id'));
itemInfo.id = resultSet.getString(resultSet.getColumnIndex('id'));
itemInfo.bundleName = resultSet.getString(resultSet.getColumnIndex('bundle_name'));
itemInfo.badgeNumber = resultSet.getLong(resultSet.getColumnIndex('badge_number'));
itemInfo.display = resultSet.getLong(resultSet.getColumnIndex('display'));
itemInfo.display = this.numberToBoolean(resultSet.getLong(resultSet.getColumnIndex('display')));
itemInfo.userId = resultSet.getLong(resultSet.getColumnIndex('user_id'));
resultList.push(itemInfo);
isLast = resultSet.goToNextRow();
@ -141,7 +148,7 @@ export class RdbStoreManager {
return result;
}
try {
const predicates = new dataRdb.RdbPredicates(RdbStoreConfig.Badge.TABLE_NAME);
const predicates = new relationalStore.RdbPredicates(RdbStoreConfig.Badge.TABLE_NAME);
predicates.equalTo('bundle_name', bundleName);
const updateBucket = {
'badge_number': badgeNum
@ -172,7 +179,7 @@ export class RdbStoreManager {
return result;
}
try {
const predicates = new dataRdb.RdbPredicates(RdbStoreConfig.Badge.TABLE_NAME);
const predicates = new relationalStore.RdbPredicates(RdbStoreConfig.Badge.TABLE_NAME);
predicates.equalTo('bundle_name', bundleName);
const changeRows = await this.mRdbStore.delete(predicates);
if (changeRows == 1) {
@ -192,13 +199,13 @@ export class RdbStoreManager {
*/
async getAllFormInfos(cardId = CommonConstants.INVALID_VALUE): Promise<CardItemInfo[]> {
Log.showDebug(TAG, 'getAllFormInfos start');
const predicates = new dataRdb.RdbPredicates(RdbStoreConfig.Form.TABLE_NAME);
const predicates = new relationalStore.RdbPredicates(RdbStoreConfig.Form.TABLE_NAME);
if (cardId != CommonConstants.INVALID_VALUE) {
predicates.equalTo('card_id', cardId);
}
const resultList: CardItemInfo[] = [];
try {
let resultSet = await this.mRdbStore.query(predicates, []);
let resultSet = await this.mRdbStore.query(predicates);
let isLast = resultSet.goToFirstRow();
while (isLast) {
const itemInfo: CardItemInfo = new CardItemInfo();
@ -237,7 +244,7 @@ export class RdbStoreManager {
Log.showDebug(TAG, 'updateFormInfoById start');
let result = false;
try {
const predicates = new dataRdb.RdbPredicates(RdbStoreConfig.Form.TABLE_NAME);
const predicates = new relationalStore.RdbPredicates(RdbStoreConfig.Form.TABLE_NAME);
predicates.equalTo('card_id', cardItemInfo.cardId);
const updateBucket = {
'card_name': cardItemInfo.cardName,
@ -275,7 +282,7 @@ export class RdbStoreManager {
Log.showDebug(TAG, 'deleteFormInfoById start');
let result = false;
try {
const predicates = new dataRdb.RdbPredicates(RdbStoreConfig.Form.TABLE_NAME);
const predicates = new relationalStore.RdbPredicates(RdbStoreConfig.Form.TABLE_NAME);
predicates.equalTo('card_id', cardId);
const changeRows = await this.mRdbStore.delete(predicates);
if (changeRows == 1) {
@ -291,7 +298,7 @@ export class RdbStoreManager {
Log.showDebug(TAG, 'deleteFormInfoByBundle start');
let result = false;
try {
const predicates = new dataRdb.RdbPredicates(RdbStoreConfig.Form.TABLE_NAME);
const predicates = new relationalStore.RdbPredicates(RdbStoreConfig.Form.TABLE_NAME);
predicates.equalTo('bundle_name', bundleName);
const changeRows = await this.mRdbStore.delete(predicates);
if (changeRows == 1) {
@ -315,7 +322,7 @@ export class RdbStoreManager {
let result = false;
try {
// get deviceType
let deviceType = AppStorage.get('deviceType');
let deviceType = deviceInfo.deviceType;
// init default settings config
if (CheckEmptyUtils.isEmpty(key) || CheckEmptyUtils.isEmpty(value)) {
@ -329,10 +336,12 @@ export class RdbStoreManager {
};
// insert sql
let ret = await this.mRdbStore.insert(RdbStoreConfig.Settings.TABLE_NAME, firstDbData);
Log.showDebug(TAG, `updateSettings insert successful. ${ret}`);
} else {
// update settings by key and value
let sql = `UPDATE ${RdbStoreConfig.Settings.TABLE_NAME} SET ${key} = '${value}' WHERE id = 1`;
await this.mRdbStore.executeSql(sql)
await this.mRdbStore.executeSql(sql);
Log.showDebug(TAG, `updateSettings update successful.`);
}
} catch (e) {
Log.showError(TAG, 'updateSettings error:' + JSON.stringify(e));
@ -348,22 +357,23 @@ export class RdbStoreManager {
await this.deleteTable(RdbStoreConfig.SmartDock.TABLE_NAME);
// insert into smartdock
for (let i in dockInfoList) {
let smartdockDbItem = {
'item_type': dockInfoList[i].itemType,
'editable': this.booleanToNumber(dockInfoList[i].editable),
'bundle_name': dockInfoList[i].bundleName,
'ability_name': dockInfoList[i].abilityName,
'module_name': dockInfoList[i].moduleName,
'app_icon_id': dockInfoList[i].appIconId,
'app_label_id': dockInfoList[i].appLabelId,
'app_name': dockInfoList[i].appName,
'is_system_app': this.booleanToNumber(dockInfoList[i].isSystemApp),
'is_uninstallAble': this.booleanToNumber(dockInfoList[i].isUninstallAble),
'key_name': dockInfoList[i].keyName,
'install_time': dockInfoList[i].installTime
for (const element of dockInfoList) {
let smartDockDbItem = {
'item_type': element.itemType,
'editable': this.booleanToNumber(element.editable),
'bundle_name': element.bundleName,
'ability_name': element.abilityName,
'module_name': element.moduleName,
'app_icon_id': element.appIconId,
'app_label_id': element.appLabelId,
'app_name': element.appName,
'is_system_app': this.booleanToNumber(element.isSystemApp),
'is_uninstallAble': this.booleanToNumber(element.isUninstallAble),
'key_name': element.keyName,
'install_time': element.installTime
}
let ret = await this.mRdbStore.insert(RdbStoreConfig.SmartDock.TABLE_NAME, smartdockDbItem);
let ret = await this.mRdbStore.insert(RdbStoreConfig.SmartDock.TABLE_NAME, smartDockDbItem);
Log.showDebug(TAG, `insertIntoSmartdock insert successful. ${ret}-${element.keyName}`);
}
} catch (e) {
Log.showError(TAG, 'insertIntoSmartdock error:' + JSON.stringify(e));
@ -381,10 +391,11 @@ export class RdbStoreManager {
async deleteTable(tableName: string): Promise<void> {
Log.showDebug(TAG, 'deleteTable start');
try {
let detelSql = `DELETE FROM ${tableName};`
let detelSequenceSql = `UPDATE sqlite_sequence SET seq=0 WHERE name = '${tableName}';`
await this.mRdbStore.executeSql(detelSql, function () {})
await this.mRdbStore.executeSql(detelSequenceSql, function () {})
let detelSql = `DELETE FROM ${tableName};`;
let detelSequenceSql = `UPDATE sqlite_sequence SET seq=0 WHERE name = '${tableName}';`;
await this.mRdbStore.executeSql(detelSql);
await this.mRdbStore.executeSql(detelSequenceSql);
Log.showDebug(TAG, 'deleteTable successful.');
} catch (e) {
Log.showError(TAG, `deleteTable err: ${JSON.stringify(e)}`);
}
@ -402,6 +413,7 @@ export class RdbStoreManager {
let dropSql = `DROP TABLE IF EXISTS ${tableName}`;
await this.mRdbStore.executeSql(dropSql);
await this.mRdbStore.executeSql(RdbStoreConfig.GridLayoutInfo.CREATE_TABLE);
Log.showDebug(TAG, 'dropTable successful.');
} catch (e) {
Log.showError(TAG, `dropTable err: ${JSON.stringify(e)}`);
}
@ -410,8 +422,8 @@ export class RdbStoreManager {
async querySmartDock(): Promise<DockItemInfo[]> {
const resultList: DockItemInfo[] = [];
try {
const predicates = new dataRdb.RdbPredicates(RdbStoreConfig.SmartDock.TABLE_NAME);
let resultSet = await this.mRdbStore.query(predicates, []);
const predicates = new relationalStore.RdbPredicates(RdbStoreConfig.SmartDock.TABLE_NAME);
let resultSet = await this.mRdbStore.query(predicates);
let isLast = resultSet.goToFirstRow();
while (isLast) {
const itemInfo: DockItemInfo = new DockItemInfo();
@ -430,7 +442,7 @@ export class RdbStoreManager {
resultList.push(itemInfo);
isLast = resultSet.goToNextRow();
}
resultSet.close()
resultSet.close();
resultSet = null;
} catch (e) {
Log.showError(TAG, 'querySmartDock error:' + JSON.stringify(e));
@ -503,8 +515,8 @@ export class RdbStoreManager {
async queryDesktopApplication(): Promise<AppItemInfo[]> {
const resultList: AppItemInfo[] = [];
try {
const predicates = new dataRdb.RdbPredicates(RdbStoreConfig.DesktopApplicationInfo.TABLE_NAME);
let resultSet = await this.mRdbStore.query(predicates, []);
const predicates = new relationalStore.RdbPredicates(RdbStoreConfig.DesktopApplicationInfo.TABLE_NAME);
let resultSet = await this.mRdbStore.query(predicates);
let isLast = resultSet.goToFirstRow();
while (isLast) {
let appItemInfo: AppItemInfo = new AppItemInfo();
@ -530,9 +542,9 @@ export class RdbStoreManager {
return resultList;
}
async insertGridLayoutInfo(gridlayoutinfo: any): Promise<void> {
async insertGridLayoutInfo(gridLayoutInfo: GridLayoutInfo): Promise<void> {
Log.showDebug(TAG, 'insertGridLayoutInfo start');
if (CheckEmptyUtils.isEmpty(gridlayoutinfo) || CheckEmptyUtils.isEmptyArr(gridlayoutinfo.layoutInfo)) {
if (CheckEmptyUtils.isEmpty(gridLayoutInfo) || CheckEmptyUtils.isEmptyArr(gridLayoutInfo.layoutInfo)) {
Log.showError(TAG, 'insertGridLayoutInfo gridlayoutinfo is empty');
return;
}
@ -541,9 +553,8 @@ export class RdbStoreManager {
// delete gridlayoutinfo table
await this.dropTable(RdbStoreConfig.GridLayoutInfo.TABLE_NAME);
// insert into gridlayoutinfo
let layoutinfo: any[] = gridlayoutinfo.layoutInfo;
for (let i in layoutinfo) {
let element = layoutinfo[i];
let layoutInfo: Array<LauncherDragItemInfo> = gridLayoutInfo.layoutInfo;
for (const element of layoutInfo) {
let item = {};
if (element.typeId === CommonConstants.TYPE_APP) {
item = {
@ -558,10 +569,8 @@ export class RdbStoreManager {
'row': element.row,
'container': -100,
'badge_number': element.badgeNumber
}
let ret = await this.mRdbStore.insert(RdbStoreConfig.GridLayoutInfo.TABLE_NAME, item);
};
await this.mRdbStore.insert(RdbStoreConfig.GridLayoutInfo.TABLE_NAME, item);
} else if (element.typeId === CommonConstants.TYPE_CARD) {
item = {
'bundle_name':element.bundleName,
@ -576,7 +585,7 @@ export class RdbStoreManager {
'row': element.row,
'container': -100,
'badge_number': element.badgeNumber
}
};
await this.mRdbStore.insert(RdbStoreConfig.GridLayoutInfo.TABLE_NAME, item);
} else {
item = {
@ -592,10 +601,11 @@ export class RdbStoreManager {
'row': element.row,
'container': -100,
'badge_number': element.badgeNumber
}
};
Log.showDebug(TAG, `element prev: ${JSON.stringify(element)}`);
let ret: number = await this.mRdbStore.insert(RdbStoreConfig.GridLayoutInfo.TABLE_NAME, item);
if (ret > 0) {
Log.showDebug(TAG, `element ret: ${JSON.stringify(ret)}`);
if (ret !== -1) {
await this.insertLayoutInfo(element.layoutInfo, ret);
}
}
@ -606,7 +616,7 @@ export class RdbStoreManager {
}
}
private async insertLayoutInfo(layoutInfo: [[]], container: number): Promise<boolean> {
private async insertLayoutInfo(layoutInfo: AppItemInfo[][], container: number): Promise<boolean> {
Log.showDebug(TAG, 'insertLayoutInfo start');
let result: boolean = true;
if (CheckEmptyUtils.isEmptyArr(layoutInfo)) {
@ -614,10 +624,8 @@ export class RdbStoreManager {
result = false;
return result;
}
for (var i in layoutInfo) {
let curItem = layoutInfo[i];
for (let j in curItem) {
let bigFolderApp: any = curItem[j];
for (const curItem of layoutInfo) {
for (const bigFolderApp of curItem) {
let item = {
'container': container,
'app_name': bigFolderApp.appName,
@ -636,8 +644,9 @@ export class RdbStoreManager {
'column': bigFolderApp.column,
'row': bigFolderApp.row,
'badge_number': bigFolderApp.badgeNumber
}
};
let ret: number = await this.mRdbStore.insert(RdbStoreConfig.GridLayoutInfo.TABLE_NAME, item);
Log.showDebug(TAG, `insertLayoutInfo ret ${container}-${ret}`);
if (ret === -1) {
result = false;
}
@ -649,9 +658,9 @@ export class RdbStoreManager {
async queryGridLayoutInfo(): Promise<GridLayoutItemInfo[]> {
const resultList: GridLayoutItemInfo[] = [];
try {
const predicates = new dataRdb.RdbPredicates(RdbStoreConfig.GridLayoutInfo.TABLE_NAME);
const predicates = new relationalStore.RdbPredicates(RdbStoreConfig.GridLayoutInfo.TABLE_NAME);
predicates.equalTo(GridLayoutInfoColumns.CONTAINER, -100);
let resultSet = await this.mRdbStore.query(predicates, []);
let resultSet = await this.mRdbStore.query(predicates);
let isLast = resultSet.goToFirstRow();
while (isLast) {
let typeId: number = resultSet.getLong(resultSet.getColumnIndex(GridLayoutInfoColumns.TYPE_ID));
@ -664,7 +673,7 @@ export class RdbStoreManager {
resultList.push(builder.buildGridLayoutItem());
isLast = resultSet.goToNextRow();
}
resultSet.close()
resultSet.close();
resultSet = null;
} catch (e) {
Log.showError(TAG, 'queryGridLayoutInfo error:' + JSON.stringify(e));
@ -675,7 +684,7 @@ export class RdbStoreManager {
private async queryLayoutInfo(container: number): Promise<AppItemInfo[]> {
const resultList: AppItemInfo[] = [];
try {
let layoutPredicates = new dataRdb.RdbPredicates(RdbStoreConfig.GridLayoutInfo.TABLE_NAME);
let layoutPredicates = new relationalStore.RdbPredicates(RdbStoreConfig.GridLayoutInfo.TABLE_NAME);
layoutPredicates.equalTo("container", container);
let columns = [GridLayoutInfoColumns.APP_NAME,
GridLayoutInfoColumns.IS_SYSTEM_APP,
@ -687,11 +696,14 @@ export class RdbStoreManager {
GridLayoutInfoColumns.MODULE_NAME,
GridLayoutInfoColumns.KEY_NAME,
GridLayoutInfoColumns.CONTAINER,
GridLayoutInfoColumns.INSTALL_TIME,
GridLayoutInfoColumns.TYPE_ID,
GridLayoutInfoColumns.AREA,
GridLayoutInfoColumns.PAGE,
GridLayoutInfoColumns.COLUMN,
GridLayoutInfoColumns.ROW];
// columns - The columns to query. If the value is null, the query applies to all columns.
let resultSet = await this.mRdbStore.query(layoutPredicates, columns);
let isLast = resultSet.goToFirstRow();
while (isLast) {
@ -699,7 +711,7 @@ export class RdbStoreManager {
resultList.push(itemInfo);
isLast = resultSet.goToNextRow();
}
resultSet.close()
resultSet.close();
resultSet = null;
} catch (e) {
Log.showError(TAG, 'queryLayoutInfo error:' + JSON.stringify(e));

View File

@ -15,9 +15,10 @@
*/
import { Log } from '../utils/Log';
import { DataAbilityHelper } from 'ability/dataAbilityHelper';
import settings from '@ohos.settings';
import dataShare from '@ohos.data.dataShare';
import common from '@ohos.app.ability.common';
import { Context } from '@ohos.abilityAccessCtrl';
const TAG = 'SettingsDataManager'
/**
@ -25,7 +26,7 @@ const TAG = 'SettingsDataManager'
*/
class SettingsDataManager {
private readonly uriShare: string = 'datashare:///com.ohos.settingsdata/entry/settingsdata/SETTINGSDATA?Proxy=true&key=';
private dataShareHelper;
private dataShareHelper: dataShare.DataShareHelper | null = null;
private constructor() {
}
@ -54,9 +55,13 @@ class SettingsDataManager {
/**
* Update settingData by settingDataKey.
*/
setValue(helper: any, settingDataKey: string, value: string): void {
setValue(helper: dataShare.DataShareHelper | null, settingDataKey: string, value: string): void {
Log.showInfo(TAG, "setValue:" + value)
settings.setValueSync(globalThis.desktopContext, settingDataKey, value);
if (typeof globalThis.desktopContext === 'undefined') {
settings.setValueSync(globalThis.settingsContext as Context, settingDataKey, value);
} else {
settings.setValueSync(globalThis.desktopContext as Context, settingDataKey, value);
}
}
/**
@ -64,8 +69,13 @@ class SettingsDataManager {
*
* @return settingsDataValue by settingDataKey.
*/
getValue(helper: any, settingDataKey: string, defaultValue: string): string {
let value: string = settings.getValueSync(globalThis.desktopContext, settingDataKey, defaultValue);
getValue(helper: dataShare.DataShareHelper | null, settingDataKey: string, defaultValue: string): string {
let value: string = '1';
if (typeof globalThis.desktopContext === 'undefined') {
value = settings.getValueSync(globalThis.settingsContext as Context, settingDataKey, defaultValue);
} else {
value = settings.getValueSync(globalThis.desktopContext as Context, settingDataKey, defaultValue);
}
Log.showInfo(TAG, "getValue:" + value);
return value;
}
@ -84,8 +94,7 @@ class SettingsDataManager {
*
* @return settingDataHelper by settingDataUri.
*/
getHelper(context: any, uri: string): any{
// @ts-ignore api8 d.ts
getHelper(context: common.Context, uri: string): dataShare.DataShareHelper | null {
return this.dataShareHelper;
}
}

View File

@ -15,14 +15,10 @@
import Window from '@ohos.window';
import display from '@ohos.display';
import CommonEvent from '@ohos.commonEvent';
import featureAbility from '@ohos.ability.featureAbility';
import ServiceExtensionContext from 'application/ServiceExtensionContext';
import { AsyncCallback, BusinessError} from '@ohos.base';
import { CommonEventData } from 'commonEvent/commonEventData';
import { CommonEventSubscriber } from 'commonEvent/commonEventSubscriber';
import { CommonEventSubscribeInfo } from 'commonEvent/commonEventSubscribeInfo';
import commonEventMgr from '@ohos.commonEventManager';
import common from '@ohos.app.ability.common';
import { AsyncCallback, BusinessError } from '@ohos.base';
import AbilityConstant from '@ohos.app.ability.AbilityConstant';
import commonEventManager from './CommonEventManager'
import { Log } from '../utils/Log';
import { StyleConstants } from '../constants/StyleConstants';
@ -33,11 +29,11 @@ const TAG = 'WindowManager';
* Wrapper class for window interfaces.
*/
class WindowManager {
private mDisplayData = null;
private mDisplayData: display.Display | null = null;
private static subscriber: CommonEventSubscriber;
private static subscriber: commonEventMgr.CommonEventSubscriber;
private static eventCallback: AsyncCallback<CommonEventData>;
private static eventCallback: AsyncCallback<commonEventMgr.CommonEventData>;
RECENT_WINDOW_NAME = 'RecentView';
@ -76,11 +72,11 @@ class WindowManager {
*
* @return windowWidth
*/
async getWindowWidth() {
getWindowWidth(): number {
if (this.mDisplayData == null) {
this.mDisplayData = await this.getWindowDisplayData();
this.mDisplayData = this.getWindowDisplayData();
}
return px2vp(this.mDisplayData.width);
return this.mDisplayData?.width as number;
}
/**
@ -88,27 +84,26 @@ class WindowManager {
*
* @return windowHeight
*/
async getWindowHeight() {
getWindowHeight(): number {
if (this.mDisplayData == null) {
this.mDisplayData = await this.getWindowDisplayData();
this.mDisplayData = this.getWindowDisplayData();
}
return px2vp(this.mDisplayData.height);
return this.mDisplayData?.height as number;
}
private async getWindowDisplayData() {
let displayData = null;
await display.getDefaultDisplay()
.then((res)=>{
displayData = res;
}).catch((err)=>{
Log.showError(TAG, 'getWindowDisplayData error:' + err);
});
private getWindowDisplayData(): display.Display | null {
let displayData: display.Display | null = null;
try {
displayData = display.getDefaultDisplaySync();
} catch(err) {
Log.showError(TAG, `display.getDefaultDisplaySync error: ${JSON.stringify(err)}`);
}
return displayData;
}
isSplitWindowMode(mode): boolean {
if ((mode == featureAbility.AbilityWindowConfiguration.WINDOW_MODE_SPLIT_PRIMARY) ||
(mode == featureAbility.AbilityWindowConfiguration.WINDOW_MODE_SPLIT_SECONDARY)) {
if ((mode === AbilityConstant.WindowMode.WINDOW_MODE_SPLIT_PRIMARY) ||
(mode === AbilityConstant.WindowMode.WINDOW_MODE_SPLIT_SECONDARY)) {
return true;
}
return false;
@ -121,8 +116,8 @@ class WindowManager {
* @param height window height
*/
async setWindowSize(width: number, height: number): Promise<void> {
const abilityWindow = await Window.getTopWindow();
void abilityWindow.resetSize(width, height);
const abilityWindow = await Window.getLastWindow(globalThis.desktopContext as common.BaseContext);
void abilityWindow.resize(width, height);
}
/**
@ -132,8 +127,8 @@ class WindowManager {
* @param y coordinate y
*/
async setWindowPosition(x: number, y: number): Promise<void> {
const abilityWindow = await Window.getTopWindow();
void abilityWindow.moveTo(x, y);
const abilityWindow = await Window.getLastWindow(globalThis.desktopContext as common.BaseContext);
void abilityWindow.moveWindowTo(x, y);
}
/**
@ -172,7 +167,7 @@ class WindowManager {
})
}
createWindow(context: ServiceExtensionContext, name: string, windowType: number, loadContent: string,
createWindow(context: common.ServiceExtensionContext, name: string, windowType: number, loadContent: string,
isShow: boolean, callback?: Function) {
Window.create(context, name, windowType).then((win) => {
void win.setPreferredOrientation(Window.Orientation.AUTO_ROTATION_RESTRICTED);
@ -203,7 +198,7 @@ class WindowManager {
});
}
createWindowIfAbsent(context: ServiceExtensionContext, name: string, windowType: number, loadContent: string): void {
createWindowIfAbsent(context: common.ServiceExtensionContext, name: string, windowType: number, loadContent: string): void {
Log.showDebug(TAG, `create, name ${name}`);
Window.find(name).then(win => {
void win.show().then(() => {
@ -258,11 +253,16 @@ class WindowManager {
}
minimizeAllApps(): void {
display.getDefaultDisplay().then(dis => {
try {
let dis: display.Display = display.getDefaultDisplaySync();
Window.minimizeAll(dis.id).then(() => {
Log.showDebug(TAG, 'Launcher minimizeAll');
});
});
} catch (err) {
let errCode = (err as BusinessError).code;
let errMsg = (err as BusinessError).message;
Log.showError(TAG, `minimizeAllApps errCode: ${errCode}, errMsg: ${errMsg}`);
}
this.destroyWindow(this.FORM_MANAGER_WINDOW_NAME);
this.destroyWindow(this.FORM_SERVICE_WINDOW_NAME);
}
@ -297,7 +297,7 @@ class WindowManager {
windowManager.recentMode = mode;
win.setWindowMode(mode).then();
} : (win) => {
windowManager.recentMode = featureAbility.AbilityWindowConfiguration.WINDOW_MODE_FULLSCREEN;
windowManager.recentMode = AbilityConstant.WindowMode.WINDOW_MODE_FULLSCREEN;
win.setFullScreen(true).then(() => {
Log.showDebug(TAG, `${this.RECENT_WINDOW_NAME} setFullScreen`);
});
@ -346,10 +346,10 @@ class WindowManager {
if (WindowManager.subscriber != null) {
return;
}
const subscribeInfo: CommonEventSubscribeInfo = {
const subscribeInfo: commonEventMgr.CommonEventSubscribeInfo = {
events: [commonEventManager.RECENT_FULL_SCREEN, commonEventManager.RECENT_SPLIT_SCREEN]
};
CommonEvent.createSubscriber(subscribeInfo).then((commonEventSubscriber: CommonEventSubscriber) => {
commonEventMgr.createSubscriber(subscribeInfo).then((commonEventSubscriber: commonEventMgr.CommonEventSubscriber) => {
Log.showDebug(TAG, "init SPLIT_SCREEN subscriber success");
WindowManager.subscriber = commonEventSubscriber;
}, (err) => {
@ -374,9 +374,9 @@ class WindowManager {
/**
* Window event handler.
*/
private static async winEventCallback(error: BusinessError, data: CommonEventData) {
private static async winEventCallback(error: BusinessError, data: commonEventMgr.CommonEventData) {
Log.showDebug(TAG,`Launcher WindowManager winEventCallback receive data: ${JSON.stringify(data)}.`);
if (error.code != 0) {
if (data.code !== 0) {
Log.showError(TAG, `get winEventCallback error: ${JSON.stringify(error)}`);
return;
}
@ -389,15 +389,15 @@ class WindowManager {
case commonEventManager.RECENT_SPLIT_SCREEN:
// split window mode
const windowModeMap = {
'Primary': featureAbility.AbilityWindowConfiguration.WINDOW_MODE_SPLIT_PRIMARY,
'Secondary': featureAbility.AbilityWindowConfiguration.WINDOW_MODE_SPLIT_SECONDARY
'Primary': AbilityConstant.WindowMode.WINDOW_MODE_SPLIT_PRIMARY,
'Secondary': AbilityConstant.WindowMode.WINDOW_MODE_SPLIT_SECONDARY
};
if (data.parameters.windowMode != 'Primary' && data.parameters.windowMode != 'Secondary') {
if (data.parameters.windowMode !== 'Primary' && data.parameters.windowMode !== 'Secondary') {
break;
}
windowManager.createRecentWindow(windowModeMap[data.parameters.windowMode]);
globalThis.splitMissionId = data.parameters.missionId;
await WindowManager.subscriber.setCode(0)
await WindowManager.subscriber.setCode(0);
await WindowManager.subscriber.finishCommonEvent();
break;
default:

View File

@ -22,6 +22,7 @@ import { FormManager } from '../manager/FormManager';
import { RdbStoreManager } from '../manager/RdbStoreManager';
import { FormListInfoCacheManager } from '../cache/FormListInfoCacheManager';
import {PageDesktopModel} from './PageDesktopModel';
import { GridLayoutInfo } from '../interface';
const TAG = 'FormModel';
@ -254,7 +255,8 @@ export class FormModel {
*/
async deleteForm(cardId) {
Log.showDebug(TAG, 'deleteForm start');
let gridLayoutInfo = {
let gridLayoutInfo: GridLayoutInfo = {
layoutDescription: undefined,
layoutInfo: []
};
gridLayoutInfo = SettingsModel.getInstance().getLayoutInfo();

View File

@ -12,7 +12,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { DataAbilityHelper } from 'ability/dataAbilityHelper';
import { Log } from '../utils/Log';
import FileUtils from '../utils/FileUtils';
@ -26,6 +25,8 @@ import { PageDesktopLayoutConfig } from '../layoutconfig/PageDesktopLayoutConfig
import { PageDesktopAppModeConfig } from '../layoutconfig/PageDesktopAppModeConfig';
import { SettingsModelObserver } from './SettingsModelObserver';
import GridLayoutConfigs from '../configs/GridLayoutConfigs';
import dataShare from '@ohos.data.dataShare';
import { GridLayoutInfo } from '../interface';
const TAG = 'SettingsModel';
@ -41,12 +42,12 @@ export class SettingsModel {
private readonly mPageDesktopAppModeConfig: PageDesktopAppModeConfig;
private mGridConfig = 1;
private mGridLayoutTable = GridLayoutConfigs.GridLayoutTable;
private readonly uri: string = null;
private helper: any = null;
private readonly uri: string = '';
private helper: dataShare.DataShareHelper | null = null;
private readonly mObserverList: SettingsModelObserver[] = [];
private constructor() {
this.mPageDesktopModeConfig = layoutConfigManager.getModeConfig(PageDesktopModeConfig.DESKTOP_MODE_CONFIG);
this.mPageDesktopModeConfig = PageDesktopModeConfig.getInstance();
const deviceType = this.mPageDesktopModeConfig.getDeviceType();
if (deviceType == CommonConstants.DEFAULT_DEVICE_TYPE) {
this.mGridLayoutTable = GridLayoutConfigs.GridLayoutTable;
@ -228,7 +229,7 @@ export class SettingsModel {
*
* @return {object} layout information.
*/
getLayoutInfo(): any {
getLayoutInfo(): GridLayoutInfo {
this.updateMenuId();
return this.mPageDesktopLayoutConfig.getGridLayoutInfo();
}
@ -236,7 +237,7 @@ export class SettingsModel {
/**
* Set layout information of grid view.
*/
setLayoutInfo(layoutInfo): void {
setLayoutInfo(layoutInfo: GridLayoutInfo): void {
this.mPageDesktopLayoutConfig.updateGridLayoutInfo(layoutInfo);
}
@ -287,7 +288,9 @@ export class SettingsModel {
*/
registerListenForDataChanges(callback): void {
this.helper = settingsDataManager.getHelper(globalThis.desktopContext, this.uri);
this.helper.on('dataChange', this.uri, callback);
if (this.helper !== null) {
this.helper.on('dataChange', this.uri, callback);
}
}
private updateMenuId(): void {

View File

@ -17,17 +17,19 @@ import { Log } from '../utils/Log';
import { BadgeManager } from '../manager/BadgeManager';
import { StyleConstants } from '../constants/StyleConstants';
import { ResourceManager } from '../manager/ResourceManager';
import { LauncherDragItemInfo } from '../bean/LauncherDragItemInfo';
const TAG = 'AppIcon';
@Component
export struct AppIcon {
@StorageLink('dragItemInfo') @Watch('updateAppIcon') mDragItemInfo: LauncherDragItemInfo = new LauncherDragItemInfo();
iconSize: number = 0;
iconId: number = 0;
bundleName: string = '';
moduleName: string = '';
@State icon: string = '';
badgeNumber: number = 0;
@State badgeNumber: number = 0;
@State iconScale: number = 1;
useCache: boolean = true;
badgeFontSize: number = StyleConstants.DEFAULT_BADGE_FONT_SIZE;
@ -35,6 +37,13 @@ export struct AppIcon {
private mBadgeManager = BadgeManager.getInstance();
private mDefaultAppIcon: ResourceStr = '';
updateAppIcon() {
// 拖动图标到无效区域,松手后图标缩放恢复原有尺寸
if (!this.mDragItemInfo.isDragging) {
this.iconScale = 1;
}
}
aboutToAppear(): void {
this.mResourceManager = ResourceManager.getInstance();
this.mBadgeManager = BadgeManager.getInstance();
@ -90,9 +99,9 @@ export struct AppIcon {
}
})
.onMouse((event: MouseEvent) => {
if (event.button == MouseButton.Left && event.action == MouseAction.Press) {
if (event.button === MouseButton.Left && event.action === MouseAction.Press) {
this.iconScale = 0.9;
} else if (event.button == MouseButton.Left && event.action == MouseAction.Release) {
} else if (event.button === MouseButton.Left && event.action === MouseAction.Release) {
this.iconScale = 1;
}
})

View File

@ -26,6 +26,7 @@ import { LauncherDragItemInfo } from '../bean/LauncherDragItemInfo';
import { AppItemInfo } from '../bean/AppItemInfo';
import { FolderItemInfo } from '../bean/FolderItemInfo';
import { MenuInfo } from '../bean';
import { FolderData } from '../interface/FolderData';
const TAG = 'FolderComponent';
@ -75,8 +76,8 @@ export struct FolderComponent {
private mShowAppList: AppItemInfo[] = [];
private mSuperposeAppList: SuperposeApp[] = [];
onAppIconClick: Function = (event: ClickEvent, item: AppItemInfo) => {};
onOpenFolderClick: Function = (event: ClickEvent, folderItem: FolderItemInfo) => {};
onFolderTouch: Function = (event: ClickEvent, folderItem: FolderItemInfo) => {};
onOpenFolderClick: Function = (event: ClickEvent, folderItem: FolderData) => {};
onFolderTouch: Function = (event: ClickEvent, folderItem: FolderData) => {};
onGetPosition: Function = (callback: (x: number, y: number) => void) => {};
buildMenu: (item: LauncherDragItemInfo) => MenuInfo[] = (item: LauncherDragItemInfo) => [];
folderNameLines: number = PresetStyleConstants.DEFAULT_APP_NAME_LINES;

View File

@ -12,6 +12,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { GridLayoutInfo } from '../interface';
import BitSet from './BitSet';
export default class GridLayoutUtil {
@ -23,7 +25,8 @@ export default class GridLayoutUtil {
*
* @return new GridLayoutInfo
*/
static updateGridLayoutInfo(gridLayoutInfo: any, newLayoutRows: number, newLayoutColumns: number): any {
static updateGridLayoutInfo(gridLayoutInfo: GridLayoutInfo, newLayoutRows: number,
newLayoutColumns: number): GridLayoutInfo {
gridLayoutInfo.layoutDescription.pageCount = GridLayoutUtil.updateLayoutInfo(
gridLayoutInfo.layoutInfo, newLayoutRows, newLayoutColumns);
gridLayoutInfo.layoutDescription.row = newLayoutRows;

View File

@ -23,6 +23,11 @@ import AppCenterGridStyleConfig from '../common/AppCenterGridStyleConfig';
const TAG = 'AppListViewModel';
interface AnimationInfo {
appScaleX: number;
appScaleY: number;
}
const KEY_NAME = "name";
export class AppListViewModel extends BaseViewModel {
@ -62,7 +67,7 @@ export class AppListViewModel extends BaseViewModel {
onFinish: () => {
}
}, () => {
let animationInfo:any = {
let animationInfo: AnimationInfo = {
appScaleX: 0.97,
appScaleY: 0.97
}

View File

@ -16,7 +16,7 @@
export class BigFolderStyleConstants {
// image resources
static readonly DEFAULT_ICON: any = $r('app.media.icon');
static readonly DEFAULT_ICON = $r('app.media.icon');
static readonly DEFAULT_BACKGROUND_IMAGE = '$media:ic_wallpaper_folder';
static readonly DEFAULT_ADD_FOLDER_APP_IMAGE = '/common/pics/ic_public_add.svg';
static readonly DEFAULT_CANCEL_APP_IMAGE = '/common/pics/ic_public_cancel.svg';

View File

@ -13,7 +13,7 @@
* limitations under the License.
*/
import { AppItemInfo, Log } from '@ohos/common';
import { AppItemInfo, FolderData, Log } from '@ohos/common';
import { AppIcon } from '@ohos/common/component';
import { AppName } from '@ohos/common/component';
import { CommonConstants } from '@ohos/common';
@ -49,7 +49,7 @@ export default struct FolderAppListDialog {
controller?: CustomDialogController;
cancel = () => {};
confirm = (isDestory: boolean) => {};
folderItem: FolderItemType = { layoutInfo: [], folderName: '', folderId: '' };
folderItem: FolderData = { layoutInfo: [], folderName: '', folderId: '', enterEditing: false };
addToString: string = '';
aboutToAppear(): void {

View File

@ -13,7 +13,7 @@
* limitations under the License.
*/
import { Log , CheckEmptyUtils, AppItemInfo, FolderItemInfo, CardItemInfo } from '@ohos/common';
import { Log , CheckEmptyUtils, AppItemInfo, FolderItemInfo, CardItemInfo, FolderData } from '@ohos/common';
import { Trace } from '@ohos/common';
import { EventConstants } from '@ohos/common';
import { StyleConstants } from '@ohos/common';
@ -47,13 +47,6 @@ interface FolderOpenLayoutTable {
checked: boolean;
}
interface FolderInfo {
layoutInfo: AppItemInfo[][];
enterEditing: boolean;
folderName: string;
folderId: string;
}
const FOLDER_CLOSE_DELAY = 500;
let mBigFolderViewModel: BigFolderViewModel;
let mBigFolderStyleConfig: BigFolderStyleConfig;
@ -82,7 +75,7 @@ export struct FolderOpenComponent {
@StorageLink('openFolderStatus') @Watch('updateFolderData') openFolderStatus: number = BigFolderConstants.OPEN_FOLDER_STATUS_CLOSE;
@State overLayAlpha: number = 0.3;
@State isRenaming: boolean = false;
@StorageLink('openFolderData') mFolderInfo: FolderInfo = { layoutInfo: [], enterEditing: false, folderName: '', folderId: '' };
@StorageLink('openFolderData') mFolderInfo: FolderData = { layoutInfo: [], enterEditing: false, folderName: '', folderId: '' };
@State newFolderName: string = '';
aboutToAppear(): void {
@ -306,15 +299,19 @@ struct FolderSwiperPage {
@StorageLink('isDraging') isDraging: boolean = false;
@Link isRenaming: boolean;
@Prop newFolderName: string;
private mFolderInfo: FolderInfo = { layoutInfo: [], enterEditing: false, folderName: '', folderId: '' };
private mFolderInfo: FolderData = { layoutInfo: [], enterEditing: false, folderName: '', folderId: '' };
private mAppInfo: AppItemInfo[] = [];
private ColumnsTemplate: string = '';
private RowsTemplate: string = '';
private mGridGap = BigFolderStyleConfig.getInstance().mOpenFolderGridGap;
@State mBigFolderViewModel: BigFolderViewModel = mBigFolderViewModel;
@State appNameAdd: string = '';
aboutToAppear(): void {
aboutToAppear(): void {
mFolderModel = BigFolderModel.getInstance();
ResourceManager.getInstance().getStringByResource($r('app.string.add')).then((resName) => {
this.appNameAdd = resName;
});
this.updateConfig();
}
@ -378,15 +375,17 @@ struct FolderSwiperPage {
.height(BigFolderStyleConstants.DEFAULT_ADD_APP_ICON_SIZE)
}.margin({ top: mGridIconTopPadding })
AppName({
nameHeight: mAppNameHeight,
nameSize: mAppNameSize,
nameFontColor: BigFolderStyleConstants.DEFAULT_FONT_COLOR,
appName: item.appName,
useCache: false,
nameLines: mNameLines,
marginTop: mIconNameMargin
})
if (this.appNameAdd) {
AppName({
nameHeight: mAppNameHeight,
nameSize: mAppNameSize,
nameFontColor: BigFolderStyleConstants.DEFAULT_FONT_COLOR,
appName: this.appNameAdd,
useCache: false,
nameLines: mNameLines,
marginTop: mIconNameMargin
})
}
}
.width(BigFolderStyleConstants.PERCENTAGE_100)
.height(BigFolderStyleConstants.PERCENTAGE_100)
@ -456,7 +455,7 @@ struct FolderAppItem {
private RowsTemplate: string = '';
private isSwappingPage = false;
private willCloseFolder: boolean = false;
private mFolderInfo: FolderItemInfo = new FolderItemInfo();
private mFolderInfo: FolderData = { layoutInfo: [], enterEditing: false, folderName: '', folderId: '' };
private mouseClick: number = 0;
private dialogName: string = "";
private clearForm: Function = () => {};

View File

@ -26,12 +26,17 @@ import {
localEventManager,
layoutConfigManager,
FolderLayoutConfig,
AppItemInfo
AppItemInfo,
GridLayoutInfo,
FolderData,
LauncherDragItemInfo
} from '@ohos/common';
import { BigFolderModel } from '../model/BigFolderModel';
import { BigFolderStyleConfig } from '../common/BigFolderStyleConfig';
import { BigFolderConstants } from '../common/constants/BigFolderConstants';
import { BigFolderStyleConstants } from '../common/constants/BigFolderStyleConstants';
import GridLayoutItemInfo from '@ohos/common/src/main/ets/default/bean/GridLayoutItemInfo';
import GridLayoutItemBuilder from '@ohos/common/src/main/ets/default/bean/GridLayoutItemBuilder';
const TAG = 'BigFolderViewModel';
const HEXADECIMAL_VALUE = 36;
@ -50,9 +55,7 @@ export class BigFolderViewModel extends BaseViewModel {
Log.showDebug(TAG, `onReceiveEvent receive event: ${event}, params: ${JSON.stringify(params)}`);
const openStatus = AppStorage.get('openFolderStatus');
if (event === EventConstants.EVENT_BADGE_UPDATE && (openStatus == BigFolderConstants.OPEN_FOLDER_STATUS_OPEN || openStatus == BigFolderConstants.OPEN_FOLDER_STATUS_STATIC)) {
const openFolderData: {
layoutInfo: [[]]
} = AppStorage.get('openFolderData');
const openFolderData: FolderData = AppStorage.get('openFolderData');
this.updateBadge(openFolderData, params);
} else if (event === EventConstants.EVENT_FOLDER_PACKAGE_REMOVED) {
this.deleteAppFromFolderByUninstall(params);
@ -63,12 +66,12 @@ export class BigFolderViewModel extends BaseViewModel {
};
// badge will be designed lastly
private updateBadge(openFolderData, params): void {
private updateBadge(openFolderData: FolderData, params: AppItemInfo): void {
for (let i = 0; i < openFolderData.layoutInfo.length; i++) {
const appInfo: any = openFolderData.layoutInfo[i].find(item => {
return item.bundleName == params.bundleName;
const appInfo: AppItemInfo = openFolderData.layoutInfo[i].find(item => {
return item.bundleName === params.bundleName;
});
if (appInfo != undefined && appInfo.bundleName.length > 0) {
if (appInfo !== undefined && appInfo.bundleName.length > 0) {
const index = openFolderData.layoutInfo[i].indexOf(appInfo);
appInfo.badgeNumber = params.badgeNumber;
openFolderData.layoutInfo[i][index] = appInfo;
@ -116,12 +119,12 @@ export class BigFolderViewModel extends BaseViewModel {
/**
* add new folder
*
* @param {any} appLayoutInfo (two app for create new folder).
* @param {AppItemInfo[]} appLayoutInfo (two app for create new folder).
*/
async addNewFolder(appLayoutInfo) {
async addNewFolder(appLayoutInfo: AppItemInfo[]) {
const gridLayoutInfo = this.mSettingsModel.getLayoutInfo();
const settingAppInfoList = this.mSettingsModel.getAppListInfo();
const folderAppInfo = [];
const folderAppInfo: AppItemInfo[] = [];
for (let j = 0; j < appLayoutInfo.length; j++) {
Log.showDebug(TAG, `addNewFolder appLayoutInfo: ${JSON.stringify(appLayoutInfo[j])}`)
for (let i = 0; i < settingAppInfoList.length; i++) {
@ -142,7 +145,7 @@ export class BigFolderViewModel extends BaseViewModel {
// Delete {the app list} from desktop app list
for (let i = 0; i < appLayoutInfo.length; i++) {
const index = gridLayoutInfo.layoutInfo.indexOf(appLayoutInfo[i]);
const index = gridLayoutInfo.layoutInfo.indexOf(appLayoutInfo[i] as LauncherDragItemInfo);
if (index != CommonConstants.INVALID_VALUE) {
gridLayoutInfo.layoutInfo.splice(index, 1);
}
@ -163,7 +166,7 @@ export class BigFolderViewModel extends BaseViewModel {
}
// Push folder into the layoutInfo,include {the app list}
gridLayoutInfo.layoutInfo.push(folderInfo);
gridLayoutInfo.layoutInfo.push(folderInfo as LauncherDragItemInfo);
this.deleteAppLayoutItems(gridLayoutInfo, appLayoutInfo);
if (needNewPage) {
this.mPageDesktopModel.setPageIndex(this.mPageDesktopModel.getPageIndex() + 1);
@ -228,10 +231,10 @@ export class BigFolderViewModel extends BaseViewModel {
/**
* Delete app from folder by dragging
*
* @param {any} folderAppList.
* @param {AppItemInfo[]} folderAppList.
* @param {number} index.
*/
deleteAppByDraging(folderAppList, index): boolean {
deleteAppByDraging(folderAppList: AppItemInfo[], index: number): boolean {
const gridLayoutInfo = this.mSettingsModel.getLayoutInfo();
if (folderAppList.length == 0 || folderAppList.length <= index) {
return false;
@ -250,10 +253,7 @@ export class BigFolderViewModel extends BaseViewModel {
folderAppList.pop();
}
const folderLayoutInfo = this.filterFolderPage(folderAppList);
const openFolderData: {
folderId: string,
layoutInfo: any
} = AppStorage.get('openFolderData');
const openFolderData: FolderData = AppStorage.get('openFolderData');
const removeAppInfos = [dragAppInfo];
const folderIndex = gridLayoutInfo.layoutInfo.findIndex(item => {
return item.typeId === CommonConstants.TYPE_FOLDER && item.folderId === openFolderData.folderId;
@ -272,7 +272,7 @@ export class BigFolderViewModel extends BaseViewModel {
for (let i = 0; i < removeAppInfos.length; i++) {
this.mPageDesktopModel.updatePageDesktopLayoutInfo(gridLayoutInfo, removeAppInfos[i]);
const gridLayout = this.createAppLayoutInfo(removeAppInfos[i]);
gridLayoutInfo.layoutInfo.push(gridLayout);
gridLayoutInfo.layoutInfo.push(gridLayout as LauncherDragItemInfo);
appListInfo.push(removeAppInfos[i]);
}
this.mSettingsModel.setAppListInfo(appListInfo);
@ -285,18 +285,17 @@ export class BigFolderViewModel extends BaseViewModel {
*
* @param appInfo
*/
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,
column: appInfo.column,
row: appInfo.row
};
private createAppLayoutInfo(appInfo: AppItemInfo): AppItemInfo {
const appLayout: AppItemInfo = new AppItemInfo();
appLayout.bundleName = appInfo.bundleName;
appLayout.abilityName = appInfo.abilityName;
appLayout.moduleName = appInfo.moduleName;
appLayout.keyName = appInfo.keyName;
appLayout.typeId = appInfo.typeId;
appLayout.area = appInfo.area;
appLayout.page = appInfo.page;
appLayout.column = appInfo.column;
appLayout.row = appInfo.row;
return appLayout;
}
@ -320,13 +319,10 @@ export class BigFolderViewModel extends BaseViewModel {
/**
* Delete app from open folder
*
* @param {any} appInfo.
* @param {AppItemInfo} appInfo.
*/
deleteAppFromOpenFolder(appInfo): any {
let openFolderData: {
folderId: string,
layoutInfo: any
} = AppStorage.get('openFolderData');
deleteAppFromOpenFolder(appInfo: AppItemInfo): FolderData {
let openFolderData: FolderData = AppStorage.get('openFolderData');
const folderLayoutInfo = this.getFolderLayoutInfo(openFolderData, appInfo);
// Delete app from the folder
@ -349,11 +345,11 @@ export class BigFolderViewModel extends BaseViewModel {
column: gridLayoutInfo.layoutInfo[folderIndex].column,
row: gridLayoutInfo.layoutInfo[folderIndex].row
};
gridLayoutInfo.layoutInfo.push(appLayout);
gridLayoutInfo.layoutInfo.push(appLayout as LauncherDragItemInfo);
appListInfo.push(folderLayoutInfo[0][0]);
gridLayoutInfo.layoutInfo.splice(folderIndex, 1);
openFolderData = {
folderId: '', layoutInfo: []
folderId: '',folderName: '', enterEditing: false, layoutInfo: []
};
} else {
this.updateBadgeNumber(gridLayoutInfo.layoutInfo[folderIndex], appInfo);
@ -367,13 +363,13 @@ export class BigFolderViewModel extends BaseViewModel {
/**
* update folder app list info
*
* @param {any} appInfos.
* @param {any} folderItem.
* @param {AppItemInfo[]} appInfos.
* @param {FolderData} folderItem.
*/
async updateFolderAppList(appInfos, folderItem) {
async updateFolderAppList(appInfos: AppItemInfo[], folderItem: FolderData): Promise<void> {
Log.showDebug(TAG, 'updateFolderAppList start');
let removeFolderApp = [];
let gridLayoutInfoTemp: any;
let removeFolderApp: AppItemInfo[] = [];
let gridLayoutInfoTemp: GridLayoutInfo;
let gridLayoutInfo = {
layoutInfo: []
};
@ -393,7 +389,7 @@ export class BigFolderViewModel extends BaseViewModel {
localEventManager.sendLocalEventSticky(EventConstants.EVENT_REQUEST_PAGEDESK_ITEM_ADD, removeFolderApp[i]);
this.mPageDesktopModel.updatePageDesktopLayoutInfo(gridLayoutInfoTemp, removeFolderApp[i]);
const gridLayout = this.createAppLayoutInfo(removeFolderApp[i]);
gridLayoutInfoTemp.layoutInfo.push(gridLayout);
gridLayoutInfoTemp.layoutInfo.push(gridLayout as LauncherDragItemInfo);
}
this.mSettingsModel.setLayoutInfo(gridLayoutInfoTemp);
} else {
@ -455,7 +451,7 @@ export class BigFolderViewModel extends BaseViewModel {
* @param appInfos
* @param folderAppList
*/
getAppRemainInOtherFolder(appInfos, folderAppList): any[] {
getAppRemainInOtherFolder(appInfos: AppItemInfo[], folderAppList: AppItemInfo[]): AppItemInfo[] {
const appInfosRemaining = [];
for (let m = 0; m < folderAppList.length; m++) {
const appIndex = appInfos.findIndex(item => {
@ -475,7 +471,7 @@ export class BigFolderViewModel extends BaseViewModel {
* @param folderItem
* @param gridLayoutInfo
*/
private updateFolderBadgeNumber(appInfos, folderItem, gridLayoutInfo, gridLayoutInfoTemp): void {
private updateFolderBadgeNumber(appInfos: AppItemInfo[], folderItem: FolderData, gridLayoutInfo, gridLayoutInfoTemp): void {
for (let i = 0; i < gridLayoutInfo.layoutInfo.length; i++) {
if (gridLayoutInfo.layoutInfo[i].typeId === CommonConstants.TYPE_FOLDER
&& gridLayoutInfo.layoutInfo[i].folderId === folderItem.folderId) {
@ -661,14 +657,14 @@ export class BigFolderViewModel extends BaseViewModel {
* @param {number} folderId
*
*/
async getFolderAddAppList(folderId) {
async getFolderAddAppList(folderId: string): Promise<AppItemInfo[]> {
Log.showDebug(TAG, 'getFolderAddAppList start');
if (CheckEmptyUtils.checkStrIsEmpty(folderId)) {
Log.showDebug(TAG, 'getFolderAddAppList folderId is Empty');
return;
}
let allAppList = [];
let appInfos: any;
let allAppList: AppItemInfo[] = [];
let appInfos: AppItemInfo[] = [];
let gridLayoutInfo = {
layoutInfo: []
};
@ -708,7 +704,7 @@ export class BigFolderViewModel extends BaseViewModel {
}
}
if (!this.getIsPad()) {
let bottomAppList: any = AppStorage.get('residentList');
let bottomAppList: AppItemInfo[] = AppStorage.get('residentList') as AppItemInfo[];
if (!CheckEmptyUtils.isEmptyArr(bottomAppList)) {
for (let i = 0; i < bottomAppList.length; i++) {
allAppList = allAppList.filter((item) => {
@ -727,9 +723,9 @@ export class BigFolderViewModel extends BaseViewModel {
/**
* open folder
*
* @param {any} folderInfo.
* @param {FolderData} folderInfo.
*/
addAddIcon(folderItem: any): any {
addAddIcon(folderItem: FolderData): FolderData {
Log.showDebug(TAG, 'addAddIcon start');
if (folderItem.layoutInfo.length == 0) {
@ -743,13 +739,9 @@ export class BigFolderViewModel extends BaseViewModel {
const openFolderConfig = this.mBigFolderModel.getFolderOpenLayout();
const column = openFolderConfig.column;
const row = openFolderConfig.row;
const addInfo = {
typeId: CommonConstants.TYPE_ADD,
appName: $r('app.string.add'),
bundleName: '',
appIconId: BigFolderStyleConstants.DEFAULT_ADD_FOLDER_APP_IMAGE,
appLabelId: 0
};
const addInfo: AppItemInfo = new AppItemInfo();
addInfo.typeId = CommonConstants.TYPE_ADD;
addInfo.appName = '';
if (folderItem.layoutInfo[folderItem.layoutInfo.length - 1].length === column * row) {
folderItem.layoutInfo.push([addInfo]);
} else {
@ -763,9 +755,9 @@ export class BigFolderViewModel extends BaseViewModel {
/**
* open folder
*
* @param {any} folderInfo.
* @param {FolderData} folderInfo.
*/
delAddIcon(folderItem: any): any {
delAddIcon(folderItem: FolderData): FolderData {
Log.showDebug(TAG, 'delAddIcon start');
if (folderItem.layoutInfo.length == 0) {
@ -789,9 +781,10 @@ export class BigFolderViewModel extends BaseViewModel {
/**
* open folder
*
* @param {any} folderInfo.
* @param {boolean} isRename.
* @param {FolderData} folderItem.
*/
async openFolder(isRename: boolean, folderItem: any) {
async openFolder(isRename: boolean, folderItem: FolderData) {
Log.showDebug(TAG, 'openFolder start');
folderItem.enterEditing = isRename;
@ -818,7 +811,7 @@ export class BigFolderViewModel extends BaseViewModel {
*
* @param folderItem
*/
async refreshFolder(folderItem: any) {
async refreshFolder(folderItem: FolderData) {
Log.showDebug(TAG, 'refreshFolder start');
folderItem.enterEditing = false;
this.updateOpenFolderStatus(folderItem);
@ -837,10 +830,11 @@ export class BigFolderViewModel extends BaseViewModel {
/**
* modify folder name
*
* @param {any} folderModel.
* @param {FolderData} folderModel.
*/
modifyFolderName(folderModel): void {
let gridLayoutInfo = {
modifyFolderName(folderModel: FolderData): void {
let gridLayoutInfo: GridLayoutInfo = {
layoutDescription: undefined,
layoutInfo: []
};
gridLayoutInfo = this.mSettingsModel.getLayoutInfo();
@ -859,7 +853,7 @@ export class BigFolderViewModel extends BaseViewModel {
*
* @param appInfos
*/
filterFolderPage(appInfos): any[] {
filterFolderPage(appInfos: AppItemInfo[]): AppItemInfo[][] {
const folderLayoutInfo = [];
const appListInfo = JSON.parse(JSON.stringify(appInfos));
const openFolderConfig = this.mBigFolderModel.getFolderOpenLayout();
@ -885,10 +879,10 @@ export class BigFolderViewModel extends BaseViewModel {
/**
* make the folder layoutInfo into list
*
* @param folderInfo
* @param {FolderData} folderInfo
*/
private layoutInfoToList(folderInfo): any[] {
let appInfo = [];
private layoutInfoToList(folderInfo: FolderData): AppItemInfo[] {
let appInfo: AppItemInfo[] = [];
for (let i = 0; i < folderInfo.layoutInfo.length; i++) {
for (let j = 0; j < folderInfo.layoutInfo[i].length; j++) {
if (folderInfo.layoutInfo[i][j].typeId != CommonConstants.TYPE_ADD) {
@ -902,7 +896,7 @@ export class BigFolderViewModel extends BaseViewModel {
/**
* create folder info
*
* @return {any} folderInfo.
* @return {LauncherDragItemInfo} folderInfo.
*/
private async createNewFolderInfo() {
const folderConfig = this.mBigFolderModel.getFolderLayout();
@ -916,7 +910,7 @@ export class BigFolderViewModel extends BaseViewModel {
area: folderConfig.area,
badgeNumber: 0
};
return folderInfo;
return folderInfo as LauncherDragItemInfo;
}
/**
@ -1020,7 +1014,7 @@ export class BigFolderViewModel extends BaseViewModel {
const layoutInfo = gridLayoutInfo.layoutInfo;
for (let i = 0; i < layoutInfo.length; i++) {
if (layoutInfo[i].typeId == CommonConstants.TYPE_FOLDER) {
let folderAppList = this.layoutInfoToList(layoutInfo[i]);
let folderAppList = this.layoutInfoToList(layoutInfo[i] as FolderData);
folderAppList = folderAppList.filter(item => item.bundleName != bundleName);
this.updateFolderInfo(folderAppList, gridLayoutInfo, i);
}
@ -1066,13 +1060,10 @@ export class BigFolderViewModel extends BaseViewModel {
/**
* remove app from folder
*
* @param {any} appInfo.
* @param {AppItemInfo} appInfo.
*/
removeAppOutOfFolder(appInfo): void {
let openFolderData: {
folderId: string,
layoutInfo: any
} = AppStorage.get('openFolderData');
removeAppOutOfFolder(appInfo: AppItemInfo): void {
let openFolderData: FolderData = AppStorage.get('openFolderData');
const folderAppList = this.getAppListInFolder(openFolderData);
this.deleteAppFromFolderAppList(appInfo, folderAppList);
@ -1089,7 +1080,7 @@ export class BigFolderViewModel extends BaseViewModel {
removeAppInfos.push(folderLayoutInfo[0][0]);
gridLayoutInfo.layoutInfo.splice(folderIndex, 1);
openFolderData = {
folderId: '', layoutInfo: []
folderId: '',enterEditing: false, folderName: '', layoutInfo: []
};
} else {
this.updateBadgeNumber(gridLayoutInfo.layoutInfo[folderIndex], appInfo);
@ -1108,7 +1099,7 @@ export class BigFolderViewModel extends BaseViewModel {
}
}
const gridLayout = this.createAppLayoutInfo(removeAppInfos[i]);
gridLayoutInfo.layoutInfo.push(gridLayout);
gridLayoutInfo.layoutInfo.push(gridLayout as LauncherDragItemInfo);
const appIndex = appListInfo.findIndex(item => {
return item.keyName === removeAppInfos[i].keyName;
})
@ -1127,7 +1118,7 @@ export class BigFolderViewModel extends BaseViewModel {
*
* @param openFolderData
*/
private updateOpenFolderStatus(openFolderData): void {
private updateOpenFolderStatus(openFolderData: FolderData): void {
AppStorage.setOrCreate('openFolderData', openFolderData);
if (openFolderData.folderId == '') {
AppStorage.setOrCreate('openFolderStatus', BigFolderConstants.OPEN_FOLDER_STATUS_CLOSE);
@ -1156,12 +1147,12 @@ export class BigFolderViewModel extends BaseViewModel {
*
* @param openFolderData
*/
private getAppListInFolder(openFolderData): any[] {
private getAppListInFolder(openFolderData: FolderData): AppItemInfo[] {
let folderAppList = [];
for (let i = 0; i < openFolderData.layoutInfo.length; i++) {
folderAppList = folderAppList.concat(openFolderData.layoutInfo[i]);
}
if (folderAppList.length > 0 && folderAppList[folderAppList.length - 1].typeId == CommonConstants.TYPE_ADD) {
if (folderAppList.length > 0 && folderAppList[folderAppList.length - 1].typeId === CommonConstants.TYPE_ADD) {
folderAppList.pop();
}
return folderAppList;
@ -1173,7 +1164,7 @@ export class BigFolderViewModel extends BaseViewModel {
* @param openFolderData
* @param appInfo
*/
private getFolderLayoutInfo(openFolderData, appInfo): any {
private getFolderLayoutInfo(openFolderData: FolderData, appInfo: AppItemInfo): AppItemInfo[][] {
let folderAppList = this.getAppListInFolder(openFolderData);
const index = folderAppList.findIndex(item => {
return item.keyName === appInfo.keyName;

View File

@ -19,6 +19,10 @@
{
"name": "confirm_dialog",
"value": "确认"
},
{
"name": "add",
"value": "添加"
}
]
}

View File

@ -328,6 +328,7 @@ export struct FormServiceComponent {
}
}, (item: AppItemInfo) => JSON.stringify(item))
}
.scrollBar(BarState.Off)
.divider({
strokeWidth: ThisStyleConstants.SERVICE_FORM_APP_ITEM_GROUP_DIVIDER_WIDTH,
color: ThisStyleConstants.FORM_SERVICE_APP_LIST_DIVIDER_COLOR,

View File

@ -19,7 +19,10 @@ import {
PageDesktopModel,
CommonConstants,
layoutConfigManager,
FormListInfoCacheManager
FormListInfoCacheManager,
CardItemInfo,
LauncherDragItemInfo,
GridLayoutInfo
} from '@ohos/common';
import { FormStyleConfig } from '../common/FormStyleConfig';
import FeatureConstants from '../common/constants/FeatureConstants';
@ -36,7 +39,7 @@ export class FormViewModel {
private readonly mPageDesktopModel: PageDesktopModel;
private readonly mFormStyleConfig: FormStyleConfig;
private readonly mFormListInfoCacheManager: FormListInfoCacheManager;
private mAllFormsInfo;
private mAllFormsInfo?: CardItemInfo[];
private constructor() {
Log.showInfo(TAG, 'constructor start');
@ -74,15 +77,15 @@ export class FormViewModel {
*
* @param {any} appInfo
*/
async isSupportForm(appInfo) {
async isSupportForm(appInfo: LauncherDragItemInfo) {
const formInfoList = await this.mFormModel.getAllFormsInfo();
const formInfo: any = formInfoList.find(item => {
const formInfo: CardItemInfo = formInfoList.find(item => {
if (item.bundleName === appInfo.bundleName) {
return true;
}
});
let isSupportForm = false;
if (formInfo.length > 0) {
if (formInfo) {
isSupportForm = true;
}
return isSupportForm;
@ -104,7 +107,8 @@ export class FormViewModel {
*/
async deleteForm(cardId) {
Log.showDebug(TAG, 'deleteForm start');
let gridLayoutInfo = {
let gridLayoutInfo: GridLayoutInfo = {
layoutDescription: undefined,
layoutInfo: []
};
gridLayoutInfo = this.mSettingsModel.getLayoutInfo();

View File

@ -199,7 +199,7 @@ export default class GestureNavigationExecutors {
private recentEventCall() {
Log.showInfo(TAG, 'recentEventCall recentEvent start');
globalThis.createWindowWithName(windowManager.RECENT_WINDOW_NAME, windowManager.RECENT_RANK);
windowManager.createWindowWithName(windowManager.RECENT_WINDOW_NAME, windowManager.RECENT_RANK);
}
private isRecentsViewShowOfDistanceLimit(eventY: number) {

View File

@ -18,15 +18,19 @@ import inputMonitor from '@ohos.multimodalInput.inputMonitor';
import {
Log,
CommonConstants,
settingsDataManager
settingsDataManager,
localEventManager,
EventConstants
} from '@ohos/common';
import dataShare from '@ohos.data.dataShare';
import GestureNavigationExecutors from './GestureNavigationExecutors';
import display from '@ohos.display';
const TAG = 'GestureNavigationManage';
export class GestureNavigationManager {
private readonly uri: string | null = null;
private helper: any = null;
private helper: dataShare.DataShareHelper;
private readonly sGestureNavigationExecutors: GestureNavigationExecutors = GestureNavigationExecutors.getInstance();
private touchEventCallback: inputMonitor.TouchEventReceiver | null = null;
@ -53,7 +57,7 @@ export class GestureNavigationManager {
this.helper.on('dataChange', this.uri, callback);
}
initWindowSize(display: any) {
initWindowSize(display: display.Display) {
if (globalThis.sGestureNavigationExecutors) {
globalThis.sGestureNavigationExecutors.setScreenWidth(display.width);
globalThis.sGestureNavigationExecutors.setScreenHeight(display.height);
@ -66,12 +70,16 @@ export class GestureNavigationManager {
private getGestureNavigationStatus() {
Log.showDebug(TAG, 'getGestureNavigationStatus enter');
let gestureNavigationStatus = null;
try{
try {
gestureNavigationStatus = this.getValue();
Log.showDebug(TAG, `getGestureNavigationStatus gestureNavigationStatus: ${gestureNavigationStatus}`);
this.handleEventSwitches(gestureNavigationStatus);
// 初始化时保持弹窗的距离底部的位置和(打开/关闭)三键时的位置一致
AppStorage.setOrCreate('NavigationBarStatusValue', gestureNavigationStatus === '0' ? true : false);
this.registerListenForDataChanges(this.dataChangesCallback.bind(this));
}catch (error) {
} catch (error) {
Log.showError(TAG, `getGestureNavigationStatus error: ${JSON.stringify(error)}`);
}
}
@ -80,7 +88,8 @@ export class GestureNavigationManager {
Log.showInfo(TAG, "dataChangesCallback data:" + data);
const getRetValue = this.getValue();
this.handleEventSwitches(getRetValue);
AppStorage.setOrCreate('NavigationBarStatusValue', getRetValue == '0' ? true : false);
AppStorage.setOrCreate('NavigationBarStatusValue', getRetValue === '0' ? true : false);
localEventManager.sendLocalEventSticky(EventConstants.EVENT_NAVIGATOR_BAR_STATUS_CHANGE, getRetValue);
}
private turnOnTouchEventCallback() {

View File

@ -291,7 +291,8 @@ export class PageDesktopDragHandler extends BaseDragHandler {
"column": this.getColumn(endIndex),
"row": this.getRow(endIndex),
"x": 0,
"installTime": dragItemInfo.installTime
"installTime": dragItemInfo.installTime,
"badgeNumber": dragItemInfo.badgeNumber
})
this.mSettingsModel.setAppListInfo(appInfoList);
}
@ -326,9 +327,10 @@ export class PageDesktopDragHandler extends BaseDragHandler {
"area": dragItemInfo.area,
"page": dragItemInfo.page,
"column": this.getColumn(endIndex),
"row": this.getRow(endIndex)
"row": this.getRow(endIndex),
"badgeNumber": dragItemInfo.badgeNumber
};
layoutInfo.push(appInfoTemp);
layoutInfo.push(appInfoTemp as LauncherDragItemInfo);
localEventManager.sendLocalEventSticky(EventConstants.EVENT_REQUEST_RESIDENT_DOCK_ITEM_DELETE, dragItemInfo);
} else {
this.checkAndMove(this.mStartPosition, this.mEndPosition, layoutInfo, dragItemInfo);

View File

@ -25,7 +25,8 @@ import {
PresetStyleConstants,
AppItemInfo,
FolderItemInfo,
MenuInfo
MenuInfo,
FolderData
} from '@ohos/common';
import {
BigFolderViewModel,
@ -118,11 +119,11 @@ export default struct FolderItem {
private renameClick = () => {
Log.showInfo(TAG, 'click menu folder rename');
AppStorage.setOrCreate('overlayMode', CommonConstants.OVERLAY_TYPE_HIDE);
this.mBigFolderViewModel?.openFolder(true, this.folderItem);
this.mBigFolderViewModel?.openFolder(true, this.folderItem as FolderData);
}
private getOpenFolder(): string {
let openFolderData: FolderItemType = AppStorage.get('openFolderData') as FolderItemType;
let openFolderData: FolderData = AppStorage.get('openFolderData') as FolderData;
return openFolderData.folderId;
}
@ -167,12 +168,12 @@ export default struct FolderItem {
this.setStartAppInfo(appItem);
this.mPageDesktopViewModel?.openApplication(appItem.abilityName, appItem.bundleName, appItem.moduleName);
},
onOpenFolderClick: (event: ClickEvent, folderItem: FolderItemInfo) => {
onOpenFolderClick: (event: ClickEvent, folderItem: FolderData) => {
Log.showInfo(TAG, "onOpenFolderClick");
Trace.start(Trace.CORE_METHOD_OPEN_FOLDER);
this.mBigFolderViewModel?.openFolder(false, folderItem);
},
onFolderTouch: (event: TouchEvent, folderItem: FolderItemInfo) => {
onFolderTouch: (event: TouchEvent, folderItem: FolderData) => {
if (event.type === CommonConstants.TOUCH_TYPE_UP && this.pageDesktopDragItemInfo.isDragging) {
let mIsDragEffectArea = PageDesktopDragHandler.getInstance().isDragEffectArea(event.touches[0].windowX, event.touches[0].windowY);
Log.showInfo(TAG, `onTouch mIsDragEffectArea: ${mIsDragEffectArea}`);
@ -215,7 +216,7 @@ export default struct FolderItem {
TapGesture({ count: 2 })
.onAction((event: GestureEvent) => {
Log.showInfo(TAG, 'TapGesture double click');
this.mBigFolderViewModel?.openFolder(false, this.folderItem);
this.mBigFolderViewModel?.openFolder(false, this.folderItem as FolderData);
})
)
)

View File

@ -140,7 +140,7 @@ export default struct GridSwiper {
.gesture(
LongPressGesture({ repeat: false })
.onAction((event: GestureEvent) => {
this.dialogController?.open()
this.dialogController?.open();
})
)
.bindContextMenu(this.MenuBuilder, ResponseType.RightClick)

View File

@ -20,7 +20,8 @@ import {
PresetStyleConstants,
localEventManager,
EventConstants,
CardItemInfo
CardItemInfo,
FolderData
} from '@ohos/common';
import AppItem from './AppItem';
import FormItem from './FormItem';
@ -71,6 +72,19 @@ export default struct SwiperPage {
private updateAppListInfo(): void {
this.mAppListInfo = this.appListInfo.appGridInfo[this.swiperPage];
this.updateOpenFolderData();
}
/**
* 监听桌面元素变化时,更新打开的大文件的数据。
* eg应用角标更新时大文件内的应用角标同步更新。
*/
updateOpenFolderData() {
const openFolderData = AppStorage.get('openFolderData') as FolderData;
if (openFolderData?.folderId && this.mAppListInfo.length) {
let temp = this.mAppListInfo.find((item: LauncherDragItemInfo) => item?.folderId === openFolderData.folderId);
AppStorage.setOrCreate('openFolderData', temp as FolderData);
}
}
aboutToAppear(): void {
@ -220,13 +234,10 @@ export default struct SwiperPage {
left: this.mMargin
})
.onMouse((event: MouseEvent) => {
if (event.button == MouseButton.Right) {
if (event.button === MouseButton.Right || event.button === MouseButton.Left) {
AppStorage.setOrCreate('selectDesktopAppItem', '');
}
})
.onClick((event: ClickEvent) => {
AppStorage.setOrCreate('selectDesktopAppItem', '')
})
.onDragEnter((event: DragEvent, extraParams: string) => {
Log.showInfo(TAG, `onDragEnter extraParams: ${extraParams}, event: [${event.getWindowX()}, ${event.getWindowY()}]`);
})

View File

@ -118,7 +118,7 @@ export struct PageDesktopLayout {
@CustomDialog
struct settingDialog {
@StorageLink('NavigationBarStatusValue') navigationBarStatusValue: boolean = false;
controller?: CustomDialogController
controller?: CustomDialogController;
cancel = () => {};
confirm = () => {};
onAccept = () => {};

View File

@ -33,7 +33,9 @@ import {
PageDesktopModel,
MenuInfo,
CardItemInfo,
localEventManager
localEventManager,
GridLayoutInfo,
LauncherDragItemInfo
} from '@ohos/common';
import { BigFolderModel } from '@ohos/bigfolder';
import { FormDetailLayoutConfig } from '@ohos/form';
@ -67,7 +69,7 @@ export class PageDesktopViewModel extends BaseViewModel {
private desktopSwiperController: SwiperController;
async showFormManager(params) {
globalThis.createWindowWithName(windowManager.FORM_MANAGER_WINDOW_NAME, windowManager.RECENT_RANK);
windowManager.createWindowWithName(windowManager.FORM_MANAGER_WINDOW_NAME, windowManager.RECENT_RANK);
}
setSwiperController(swiperController: SwiperController): void {
@ -783,8 +785,8 @@ export class PageDesktopViewModel extends BaseViewModel {
const layoutNum = this.mBundleInfoList.length;
const maxPerPage = column * row;
const pageNum = Math.ceil(layoutNum / maxPerPage);
const newLayoutInfo = {
layoutDescription: {},
const newLayoutInfo: GridLayoutInfo = {
layoutDescription: undefined,
layoutInfo: []
};
newLayoutInfo.layoutDescription = {
@ -804,8 +806,8 @@ export class PageDesktopViewModel extends BaseViewModel {
const layoutNum = info.layoutInfo.length;
const maxPerPage = column * row;
const pageNum = Math.ceil(layoutNum / maxPerPage);
const newLayoutInfo = {
layoutDescription: {},
const newLayoutInfo: GridLayoutInfo = {
layoutDescription: undefined,
layoutInfo: []
};
newLayoutInfo.layoutDescription = {
@ -1045,7 +1047,7 @@ export class PageDesktopViewModel extends BaseViewModel {
let menuInfoList = new Array<MenuInfo>();
const shortcutInfo: any = this.mAppModel.getShortcutInfo(appInfo.bundleName);
if (shortcutInfo) {
let menu = null;
let menu: MenuInfo | null = null;
shortcutInfo.forEach((value) => {
menu = new MenuInfo();
menu.menuType = CommonConstants.MENU_TYPE_DYNAMIC;
@ -1110,7 +1112,7 @@ export class PageDesktopViewModel extends BaseViewModel {
formCenterMenu.onMenuClick = (): void => {
Log.showInfo(TAG, 'Launcher click menu into form center view.');
if (!this.isPad) {
globalThis.createWindowWithName(windowManager.FORM_SERVICE_WINDOW_NAME, windowManager.RECENT_RANK);
windowManager.createWindowWithName(windowManager.FORM_SERVICE_WINDOW_NAME, windowManager.RECENT_RANK);
}
};
menuInfoList.push(formCenterMenu);
@ -1204,7 +1206,7 @@ export class PageDesktopViewModel extends BaseViewModel {
formCenterMenu.onMenuClick = (): void => {
Log.showInfo(TAG, 'Launcher click menu into form center view.');
if (!this.isPad) {
globalThis.createWindowWithName(windowManager.FORM_SERVICE_WINDOW_NAME, windowManager.RECENT_RANK);
windowManager.createWindowWithName(windowManager.FORM_SERVICE_WINDOW_NAME, windowManager.RECENT_RANK);
}
};
menuInfoList.push(formCenterMenu);
@ -1345,7 +1347,7 @@ export class PageDesktopViewModel extends BaseViewModel {
}
// Push card into the layoutInfo
gridLayoutInfo.layoutInfo.push(cardItemLayoutInfo);
gridLayoutInfo.layoutInfo.push(cardItemLayoutInfo as LauncherDragItemInfo);
this.mSettingsModel.setLayoutInfo(gridLayoutInfo);
if (needNewPage) {
this.mPageDesktopModel.setPageIndex(curPageIndex + 1);

View File

@ -55,7 +55,6 @@ export struct RecentMissionsSingleLayout {
}
}, (item: RecentMissionInfo) => JSON.stringify(item))
}
.cachedCount(3)
.scrollBar(BarState.Off)
.listDirection(Axis.Horizontal)
.height(RecentsStyleConstants.SINGLE_LIST_MISSION_HEIGHT)

View File

@ -205,21 +205,17 @@ export default class SettingsPresenter {
sendLocalEvent(value: string) {
Log.showDebug(TAG, `setValue value: ${value}`);
if (value != '1' && value != '0') {
if (value !== '1' && value !== '0') {
Log.showDebug(TAG, 'setValue error');
return;
}
if (value == '0') {
this.mSettingsModel.setValue(value);
} else {
localEventManager.sendLocalEventSticky(EventConstants.EVENT_NAVIGATOR_BAR_STATUS_CHANGE, value);
}
this.mSettingsModel.setValue(value);
}
initNavigationBarStatusValue() {
try {
const initValue = this.mSettingsModel.getValue();
const navigationBarStatusValue = initValue == '0' ? true : false;
const navigationBarStatusValue = initValue === '0' ? true : false;
Log.showDebug(TAG, `initNavigationBarStatusValue initValue:${initValue}, navigationBarStatusValue:${navigationBarStatusValue}`);
AppStorage.setOrCreate('NavigationBarStatusValue', navigationBarStatusValue);
} catch (e) {

View File

@ -28,15 +28,16 @@ const TAG = 'Settings';
@Entry
@Component
struct Index {
private mSettingsStage = new SettingsStage();
private mSettingsStage: SettingsStage = new SettingsStage();
private mDevice = SettingsStyleConstants.DEFAULT_DEVICE_TYPE_PHONE;
@State mSettingsPresenter: SettingsPresenter | null = null;
onPageShow(): void { }
aboutToAppear(): void {
this.getDeviceType();
this.mSettingsStage.onCreate();
mSettingsPresenter = SettingsPresenter.getInstance();
this.mSettingsPresenter = SettingsPresenter.getInstance();
}
aboutToDisappear(): void {
@ -45,13 +46,13 @@ struct Index {
async getDeviceType() {
try {
let sysWidth = await windowManager.getWindowWidth();
let sysHeigh = await windowManager.getWindowHeight();
if (sysWidth > sysHeigh) {
let sysWidth = px2vp(windowManager.getWindowWidth());
let sysHeight = px2vp(windowManager.getWindowHeight());
if (sysWidth > sysHeight) {
this.mDevice = SettingsStyleConstants.DEFAULT_DEVICE_TYPE_PAD;
}
} catch (e) {
Log.showError(TAG, 'getWindowWidth or getWindowHeight error:' + e);
Log.showError(TAG, `getWindowWidth or getWindowHeight error: ${JSON.stringify(e)}`);
}
}
@ -109,7 +110,7 @@ struct top_bar {
.width(SettingsStyleConstants.DEFAULT_VP_24)
.height(SettingsStyleConstants.DEFAULT_VP_24)
.onClick(() => {
mSettingsPresenter.backToTheDesktop();
SettingsPresenter.getInstance().backToTheDesktop();
})
Text($r('app.string.into_settings'))
@ -128,14 +129,10 @@ struct SettingPage {
@State SettingList: SettingItemInfo[] = [];
aboutToAppear(): void {
this.SettingList = mSettingsPresenter.getSettingList();
this.SettingList = SettingsPresenter.getInstance().getSettingList();
Log.showInfo(TAG, `aboutToAppear SettingList length: ${this.SettingList.length}`);
}
onPageShow(): void {
this.SettingList = mSettingsPresenter.getSettingList();
}
build() {
Column() {
ForEach(this.SettingList, (item: SettingItemInfo) => {
@ -177,9 +174,9 @@ struct SettingItem {
}
aboutToAppear(): void {
mSettingsPresenter.initNavigationBarStatusValue();
SettingsPresenter.getInstance().initNavigationBarStatusValue();
if (this.settingType == 1) {
mSettingsPresenter.registerValueCallback(this.ida, this.callback);
SettingsPresenter.getInstance().registerValueCallback(this.ida, this.callback);
}
}
@ -232,7 +229,7 @@ struct SettingItem {
.height(40)
.onChange((isOn: boolean) => {
Log.showDebug(TAG, `SettingItemToggle onChange for GestureNavigation Enable: ${isOn}`);
mSettingsPresenter.sendLocalEvent(isOn ? '0' : '1');
SettingsPresenter.getInstance().sendLocalEvent(isOn ? '0' : '1');
})
}
}
@ -278,8 +275,8 @@ struct SettingsDialog {
}.width(SettingsStyleConstants.PERCENTAGE_100)
.height(SettingsStyleConstants.DEFAULT_VP_80)
.onClick(() => {
mSettingsPresenter.changeSettingValue(this.ida, item.name);
mSettingsPresenter.setSettingsValue(this.ida, item.value);
SettingsPresenter.getInstance().changeSettingValue(this.ida, item.name);
SettingsPresenter.getInstance().setSettingsValue(this.ida, item.value);
if (this.controller) {
this.controller.close();
}

View File

@ -188,6 +188,8 @@ export default struct RecentLayout {
})
}, (item: DockItemInfo) => JSON.stringify(item))
}
.enableScrollInteraction(false)
.scrollBar(BarState.Off)
.padding(this.dockPadding)
.width(this.getListWidth())
.height(this.mSmartDockStyleConfig?.mDockHeight as number)

View File

@ -94,12 +94,13 @@ export default struct ResidentLayout {
}
}, (item: DockItemInfo) => JSON.stringify(item))
}
.enableScrollInteraction(false)
.scrollBar(BarState.Off)
.height('100%')
.animation({
curve: Curve.Friction
})
.listDirection(Axis[this.mSmartDockStyleConfig.mListDirection])
.editMode(false)
}
.backgroundColor(this.mSmartDockStyleConfig.mBackgroundColor)
.borderRadius(this.mSmartDockStyleConfig.mDockRadius)

View File

@ -39,7 +39,7 @@ interface DockRecentPopup {
@Component
export struct SmartDock {
popup: DockRecentPopup = { show: false, showItem: '', popup: null };
showAppCenter: Function = () => {};
showAppCenter: () => void = () => {};
@StorageLink('showDock') showDock: boolean = false;
@StorageLink('recentList') recentList: Array<RecentBundleMissionInfo> = [];
@StorageLink('missionInfoList') missionInfoList: Array<RecentBundleMissionInfo> = [];
@ -97,7 +97,7 @@ export struct SmartDock {
this.mSmartDockViewModel?.deleteDockItem({
bundleName: undefined,
keyName: this.mSelectedItem?.keyName
}, this.mSelectedDockType);
} as DockItemInfo, this.mSelectedDockType);
} else {
this.mSmartDockViewModel?.uninstallApp(this.mSelectedItem?.bundleName, this.mSelectedItem?.isUninstallAble);
}
@ -105,8 +105,8 @@ export struct SmartDock {
}
showDialog = () => {
this.mSelectedItem = this.mSmartDockViewModel?.getSelectedItem();
this.mSelectedDockType = this.mSmartDockViewModel?.getSelectedDockType();
this.mSelectedItem = this.mSmartDockViewModel?.getSelectedItem() as DockItemInfo|null;
this.mSelectedDockType = this.mSmartDockViewModel?.getSelectedDockType() as number;
this.mDialogController?.open();
}
@ -186,6 +186,8 @@ export struct SmartDock {
})
}
}
.enableScrollInteraction(false)
.scrollBar(BarState.Off)
.hitTestBehavior(this.desktopEventResponse ? HitTestMode.Default : HitTestMode.Block)
.alignListItem(ListItemAlign.Center)
.height(SmartDockConstants.PERCENTAGE_100)

View File

@ -36,6 +36,7 @@ import { SmartDockStyleConfig } from '../config/SmartDockStyleConfig';
import { SmartDockLayoutConfig } from '../config/SmartDockLayoutConfig';
import SmartDockConstants from '../common/constants/SmartDockConstants';
import { RecentMissionInfo } from '@ohos/common';
import launcherBundleManager from '@ohos.bundle.launcherBundleManager';
const TAG = 'SmartDockModel';
const KEY_NAME = 'name';
@ -115,6 +116,7 @@ export default class SmartDockModel {
dockItemInfo.isSystemApp = typeof (appData) === 'undefined' ? dockItemInfo.isSystemApp : appData.isSystemApp;
dockItemInfo.isUninstallAble = typeof (appData) === 'undefined' ? dockItemInfo.isUninstallAble : appData.isUninstallAble;
dockItemInfo.installTime = typeof (appData) === 'undefined' ? dockItemInfo.installTime : appData.installTime;
dockItemInfo.badgeNumber = typeof (appData) === 'undefined' ? dockItemInfo.badgeNumber : appData.badgeNumber;
residentList.push(dockItemInfo);
} else if (dockDataList[i].itemType == CommonConstants.TYPE_CARD) {
} else {
@ -129,6 +131,8 @@ export default class SmartDockModel {
dockItemInfo.appLabelId = typeof (dockDataList[i].appLabelId) != 'undefined' ? dockDataList[i].appLabelId : dockDataList[i].labelId.id;
dockItemInfo.isSystemApp = typeof (dockDataList[i].isSystemApp) === 'undefined' ? true : dockDataList[i].isSystemApp;
dockItemInfo.isUninstallAble = typeof (dockDataList[i].isUninstallAble) === 'undefined' ? true : dockDataList[i].isUninstallAble;
dockItemInfo.badgeNumber = typeof (dockDataList[i].badgeNumber) === 'undefined' ?
CommonConstants.BADGE_DISPLAY_HIDE : dockDataList[i].badgeNumber;
const loadAppName = await this.mResourceManager
.getAppNameSync(dockItemInfo.appLabelId, dockItemInfo.bundleName, dockItemInfo.moduleName, '');
dockItemInfo.appName = loadAppName;
@ -197,7 +201,7 @@ export default class SmartDockModel {
* @param dockItem
* @param dockType
*/
deleteDockItem(dockItem: {bundleName: string | undefined, keyName: string | undefined}, dockType: number): boolean {
deleteDockItem(dockItem: DockItemInfo, dockType: number): boolean {
if (SmartDockConstants.RESIDENT_DOCK_TYPE === dockType) {
return this.deleteResistDockItem(dockItem);
}
@ -221,7 +225,7 @@ export default class SmartDockModel {
if (this.checkDockNum(dockItemCount)) {
return false;
}
const flag = this.idDuplicate(this.mResidentList, appInfo);
const flag = this.idDuplicate(this.mResidentList, appInfo as AppItemInfo);
if (flag) {
const dockItemInfo = new DockItemInfo();
dockItemInfo.itemType = CommonConstants.TYPE_APP;
@ -236,6 +240,7 @@ export default class SmartDockModel {
dockItemInfo.appLabelId = appInfo.appLabelId;
dockItemInfo.isSystemApp = appInfo.isSystemApp;
dockItemInfo.isUninstallAble = appInfo.isUninstallAble;
dockItemInfo.badgeNumber = appInfo.badgeNumber;
if (dockItemCount == 0 || index == undefined || index >= dockItemCount || index < 0) {
this.mResidentList.push(dockItemInfo);
} else {
@ -521,7 +526,7 @@ export default class SmartDockModel {
* get ShortcutInfo by bundleName
* @param bundleName
*/
getShortcutInfo(bundleName: string): any {
getShortcutInfo(bundleName: string): launcherBundleManager.ShortcutInfo[] | undefined {
return this.mAppModel.getShortcutInfo(bundleName);
}
@ -647,6 +652,7 @@ export default class SmartDockModel {
dockItemInfo.installTime = appInfo.installTime;
dockItemInfo.isSystemApp = appInfo.isSystemApp;
dockItemInfo.isUninstallAble = appInfo.isUninstallAble;
dockItemInfo.badgeNumber = appInfo.badgeNumber;
resistDockItem[i] = dockItemInfo;
AppStorage.setOrCreate('residentList', resistDockItem);
}

View File

@ -13,7 +13,7 @@
* limitations under the License.
*/
import { Log } from '@ohos/common';
import { LauncherDragItemInfo, Log, RecentBundleMissionInfo, ResourceManager } from '@ohos/common';
import { Trace } from '@ohos/common';
import { CheckEmptyUtils } from '@ohos/common';
import { MenuInfo } from '@ohos/common';
@ -34,6 +34,10 @@ import { SmartDockLayoutConfig } from '../config/SmartDockLayoutConfig';
const TAG = 'SmartDockViewModel';
class StartAppItemInfo extends LauncherDragItemInfo {
icon?: ResourceStr;
}
/**
* SmartDock Viewmodel
*/
@ -43,7 +47,7 @@ export default class SmartDockViewModel extends BaseViewModel {
private readonly mSmartDockDragHandler: SmartDockDragHandler;
private readonly mSmartDockStartAppHandler: SmartDockStartAppHandler;
private readonly mSmartDockModel: SmartDockModel;
private mSelectedItem: DockItemInfo;
private mSelectedItem: DockItemInfo | null = null;
private mSelectedDockType = 0;
private mDevice = CommonConstants.DEFAULT_DEVICE_TYPE;
@ -76,7 +80,7 @@ export default class SmartDockViewModel extends BaseViewModel {
* @param item
* @param callback
*/
residentOnClick(event, item, callback?) {
residentOnClick(event: ClickEvent | null, item: DockItemInfo, callback?: () => void) {
// AppCenter entry
AppStorage.setOrCreate('startAppTypeFromPageDesktop', CommonConstants.OVERLAY_TYPE_APP_RESIDENTIAL);
if (item.abilityName == CommonConstants.APPCENTER_ABILITY && callback != null) {
@ -84,13 +88,13 @@ export default class SmartDockViewModel extends BaseViewModel {
return;
}
if (item.abilityName == CommonConstants.RECENT_ABILITY) {
globalThis.createWindowWithName(windowManager.RECENT_WINDOW_NAME, windowManager.RECENT_RANK);
windowManager.createWindowWithName(windowManager.RECENT_WINDOW_NAME, windowManager.RECENT_RANK);
Trace.start(Trace.CORE_METHOD_START_RECENTS);
return;
}
// app entry
Trace.start(Trace.CORE_METHOD_START_APP_ANIMATION);
this.setStartAppInfo(item);
this.setStartAppInfo(item as StartAppItemInfo);
launcherAbilityManager.startLauncherAbility(item.abilityName, item.bundleName, item.moduleName);
}
@ -99,9 +103,9 @@ export default class SmartDockViewModel extends BaseViewModel {
* @param event
* @param item
*/
public recentOnClick(event, item, callback?) {
public recentOnClick(event: ClickEvent | null, item: DockItemInfo, callback?: () => void) {
AppStorage.setOrCreate('startAppTypeFromPageDesktop', CommonConstants.OVERLAY_TYPE_APP_RECENT);
let missionInfoList = [];
let missionInfoList: RecentBundleMissionInfo[] = [];
missionInfoList = AppStorage.get('missionInfoList');
Log.showDebug(TAG, `recentOnClick missionInfoList.length: ${missionInfoList.length}`);
if (!CheckEmptyUtils.isEmptyArr(missionInfoList)) {
@ -117,7 +121,7 @@ export default class SmartDockViewModel extends BaseViewModel {
amsMissionManager.moveMissionToFront(missionId).then(() => {}, () => {});
// set start app info
Trace.start(Trace.CORE_METHOD_START_APP_ANIMATION);
this.setStartAppInfo(item);
this.setStartAppInfo(item as StartAppItemInfo);
}
break;
}
@ -136,14 +140,16 @@ export default class SmartDockViewModel extends BaseViewModel {
* update drag effective area when dockList changed
*/
async updateDockParams() {
const screenWidth: number = AppStorage.get('screenWidth');
const screenHeight: number = AppStorage.get('screenHeight');
const sysUIBottomHeight: number = AppStorage.get('sysUIBottomHeight');
const dockHeight: number = AppStorage.get('dockHeight');
const screenWidth: number = AppStorage.get('screenWidth') as number;
const screenHeight: number = AppStorage.get('screenHeight') as number;
const sysUIBottomHeight: number = AppStorage.get('sysUIBottomHeight') as number;
const dockHeight: number = AppStorage.get('dockHeight') as number;
let mResidentWidth: number = this.getListWidth(AppStorage.get('residentList'));
if (AppStorage.get("deviceType") === CommonConstants.DEFAULT_DEVICE_TYPE) {
if ((AppStorage.get('deviceType') as string) === CommonConstants.DEFAULT_DEVICE_TYPE) {
const maxDockNum = this.getStyleConfig().mMaxDockNum;
mResidentWidth = this.mSmartDockStyleConfig.mDockPadding * 2 + maxDockNum * (this.mSmartDockStyleConfig.mListItemWidth) + (maxDockNum - 1) * (this.mSmartDockStyleConfig.mListItemGap);
mResidentWidth = this.mSmartDockStyleConfig.mDockPadding * 2 +
maxDockNum * (this.mSmartDockStyleConfig.mListItemWidth) +
(maxDockNum - 1) * (this.mSmartDockStyleConfig.mListItemGap);
}
AppStorage.setOrCreate('residentWidth', mResidentWidth);
AppStorage.setOrCreate("dockPadding", this.getDockPadding(mResidentWidth));
@ -152,7 +158,7 @@ export default class SmartDockViewModel extends BaseViewModel {
if (typeof (this.mSmartDockDragHandler) != 'undefined') {
let left = mResidentWidth === 0 ? 0 : (screenWidth - mResidentWidth - (mRecentWidth === 0 ? 0 : (this.mSmartDockStyleConfig.mDockGap + mRecentWidth))) / 2;
let right = mResidentWidth === 0 ? screenWidth : (screenWidth - mResidentWidth - (mRecentWidth === 0 ? 0 : (this.mSmartDockStyleConfig.mDockGap + mRecentWidth))) / 2 + mResidentWidth;
if (AppStorage.get('deviceType') == CommonConstants.DEFAULT_DEVICE_TYPE) {
if ((AppStorage.get('deviceType') as string) == CommonConstants.DEFAULT_DEVICE_TYPE) {
left = (screenWidth - mResidentWidth) / 2;
right = screenWidth - left;
}
@ -181,11 +187,11 @@ export default class SmartDockViewModel extends BaseViewModel {
* @param dockType
* @param callback
*/
buildMenuInfoList(appInfo, dockType, showAppcenter, callback?) {
buildMenuInfoList(appInfo: DockItemInfo, dockType: number, showAppcenter: () => void, callback?: () => void) {
const menuInfoList = new Array<MenuInfo>();
const shortcutInfo = this.mSmartDockModel.getShortcutInfo(appInfo.bundleName);
if (shortcutInfo) {
let menu = null;
let menu: MenuInfo | null = null;
shortcutInfo.forEach((value) => {
menu = new MenuInfo();
menu.menuType = CommonConstants.MENU_TYPE_DYNAMIC;
@ -197,7 +203,8 @@ export default class SmartDockViewModel extends BaseViewModel {
menu.moduleName = value.moduleName;
menu.onMenuClick = () => {
Trace.start(Trace.CORE_METHOD_START_APP_ANIMATION);
launcherAbilityManager.startLauncherAbility(value.wants[0].targetClass, value.wants[0].targetBundle, value.wants[0].targetModule);
launcherAbilityManager.startLauncherAbility(value.wants[0].targetAbility,
value.wants[0].targetBundle, value.wants[0].targetModule);
};
value.bundleName == appInfo.bundleName && value.moduleName == appInfo.moduleName && menuInfoList.push(menu);
});
@ -213,7 +220,7 @@ export default class SmartDockViewModel extends BaseViewModel {
menuInfoList.push(open);
if (appInfo.itemType != CommonConstants.TYPE_FUNCTION) {
this.mDevice = AppStorage.get('deviceType');
this.mDevice = AppStorage.get('deviceType') as string;
if (this.mDevice === CommonConstants.PAD_DEVICE_TYPE && dockType === SmartDockConstants.RESIDENT_DOCK_TYPE) {
const addToWorkSpaceMenu = new MenuInfo();
addToWorkSpaceMenu.menuType = CommonConstants.MENU_TYPE_FIXED;
@ -250,16 +257,16 @@ export default class SmartDockViewModel extends BaseViewModel {
return menuInfoList;
}
deleteDockItem(dockItem: {bundleName: string | undefined, keyName: string | undefined}, dockType: number) {
deleteDockItem(dockItem: DockItemInfo, dockType: number) {
this.mSmartDockModel.deleteDockItem(dockItem, dockType);
}
getSelectedItem(): any {
getSelectedItem(): DockItemInfo | null {
Log.showDebug(TAG, `getSelectedItem: ${JSON.stringify(this.mSelectedItem)}`);
return this.mSelectedItem;
}
getSelectedDockType(): any {
getSelectedDockType(): number {
Log.showDebug(TAG, `getSelectedDockType: ${JSON.stringify(this.mSelectedDockType)}`);
return this.mSelectedDockType;
}
@ -268,7 +275,7 @@ export default class SmartDockViewModel extends BaseViewModel {
* calcaulate dock list width after list change
* @param itemList
*/
private getListWidth(itemList: []): number {
private getListWidth(itemList: RecentBundleMissionInfo[]): number {
let width = 0;
if (typeof itemList === 'undefined' || itemList == null || itemList.length === 0) {
return width;
@ -300,12 +307,12 @@ export default class SmartDockViewModel extends BaseViewModel {
/**
* set start app info
*/
private setStartAppInfo(item) {
private setStartAppInfo(item: StartAppItemInfo) {
if (CheckEmptyUtils.isEmpty(item)) {
Log.showError(TAG, `setStartAppInfo with item`)
return;
}
item.icon = globalThis.ResourceManager.getCachedAppIcon(item.appIconId, item.bundleName, item.moduleName)
item.icon = ResourceManager.getInstance().getCachedAppIcon(item.appIconId, item.bundleName, item.moduleName)
AppStorage.setOrCreate('startAppItemInfo', item);
this.mSmartDockStartAppHandler.setAppIconSize(this.mSmartDockStyleConfig.mIconSize);
this.mSmartDockStartAppHandler.setAppIconInfo();

View File

@ -110,7 +110,7 @@ export default class MainAbility extends ServiceExtension {
isFinalKeyDown: true
}, () => {
Log.showInfo(TAG, 'RECENT inputConsumer recentEvent start');
globalThis.createWindowWithName(windowManager.RECENT_WINDOW_NAME, windowManager.RECENT_RANK);
windowManager.createWindowWithName(windowManager.RECENT_WINDOW_NAME, windowManager.RECENT_RANK);
});
}

View File

@ -33,6 +33,7 @@ import { FormStyleConfig } from '@ohos/form';
import AppCenterGridStyleConfig from '@ohos/appcenter/src/main/ets/default/common/AppCenterGridStyleConfig';
import PadPageDesktopGridStyleConfig from '../common/PadPageDesktopGridStyleConfig';
import { SmartDockStyleConfig } from '@ohos/smartdock';
import display from '@ohos.display';
const RAW_IMAGE_CACHE_SIZE = 20000000;
const TAG = 'EntryView';
@ -57,16 +58,34 @@ struct EntryView {
@State mAppScaleY: number = 1.0;
@State mAppAlpha: number = 1.0;
@StorageLink('IsSetImageRawDataCacheSize') IsSetImageRawDataCacheSize?: boolean = undefined;
async onPortrait(mediaQueryResult: mediaquery.MediaQueryResult) {
if (mediaQueryResult.matches) {
Log.showInfo(TAG, 'screen change to landscape');
AppStorage.setOrCreate('isPortrait', false);
} else {
Log.showInfo(TAG, 'screen change to portrait');
AppStorage.setOrCreate('isPortrait', true);
}
let dis: display.Display | null = null;
try {
dis = display.getDefaultDisplaySync();
Log.showInfo(TAG, `change to display: ${JSON.stringify(dis)}`);
AppStorage.setOrCreate('screenWidth', px2vp(dis.width));
AppStorage.setOrCreate('screenHeight', px2vp(dis.height));
Log.showDebug(TAG, `screenWidth and screenHeight: ${AppStorage.get('screenWidth')},${AppStorage.get('screenHeight')}`);
} catch (err) {
Log.showError(TAG, `display.getDefaultDisplaySync err: ${JSON.stringify(err)}`)
}
}
aboutToAppear(): void {
Log.showInfo(TAG, 'aboutToAppear');
this.mStage.onCreate();
this.navigationBarStatus = SettingsModel.getInstance().getValue();
this.getWindowSize();
this.updateScreenSize();
this.mOrientationListener.on('change', windowManager.onPortrait);
this.mOrientationListener.on('change', this.onPortrait);
this.registerPageDesktopNavigatorStatusChangeEvent(this.mLocalEventListener);
this.navigationBarStatus = SettingsModel.getInstance().getValue();
}
registerPageDesktopNavigatorStatusChangeEvent(listener: LocalEventListener): void {
@ -139,10 +158,10 @@ struct EntryView {
}
}
private async getWindowSize(): Promise<void> {
private getWindowSize(): void {
try {
this.screenWidth = await windowManager.getWindowWidth();
this.screenHeight = await windowManager.getWindowHeight();
this.screenWidth = px2vp(windowManager.getWindowWidth());
this.screenHeight = px2vp(windowManager.getWindowHeight());
AppStorage.setOrCreate('screenWidth', this.screenWidth);
AppStorage.setOrCreate('screenHeight', this.screenHeight);
} catch (error) {
@ -161,7 +180,7 @@ struct EntryView {
}
aboutToDisappear(): void {
this.mOrientationListener.off('change', windowManager.onPortrait);
this.mOrientationListener.off('change', this.onPortrait);
this.mStage.onDestroy();
}

View File

@ -110,7 +110,7 @@ export default class MainAbility extends ServiceExtension {
isFinalKeyDown: true
}, () => {
Log.showInfo(TAG, 'RECENT inputConsumer recentEvent start');
globalThis.createWindowWithName(windowManager.RECENT_WINDOW_NAME, windowManager.RECENT_RANK);
windowManager.createWindowWithName(windowManager.RECENT_WINDOW_NAME, windowManager.RECENT_RANK);
});
}

View File

@ -59,11 +59,12 @@ struct EntryView {
aboutToAppear(): void {
Log.showInfo(TAG, 'aboutToAppear');
this.mStage.onCreate();
this.navigationBarStatus = SettingsModel.getInstance().getValue();
this.getWindowSize();
this.updateScreenSize();
this.registerPageDesktopNavigatorStatusChangeEvent(this.mLocalEventListener);
this.navigationBarStatus = SettingsModel.getInstance().getValue();
}
registerPageDesktopNavigatorStatusChangeEvent(listener: LocalEventListener): void {
@ -105,10 +106,10 @@ struct EntryView {
}
}
private async getWindowSize(): Promise<void> {
private getWindowSize(): void {
try {
this.screenWidth = await windowManager.getWindowWidth();
this.screenHeight = await windowManager.getWindowHeight();
this.screenWidth = px2vp(windowManager.getWindowWidth());
this.screenHeight = px2vp(windowManager.getWindowHeight());
AppStorage.setOrCreate('screenWidth', this.screenWidth);
AppStorage.setOrCreate('screenHeight', this.screenHeight);
} catch (error) {