!132 同步Launcher代码

Merge pull request !132 from 周靖/master
This commit is contained in:
openharmony_ci 2022-05-23 12:19:39 +00:00 committed by Gitee
commit db67ea6a87
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
39 changed files with 518 additions and 213 deletions

View File

@ -16,6 +16,10 @@
/**
* Stage base class
*/
import Log from '../utils/Log';
const TAG = 'BaseStage';
export default class BaseStage {
constructor() {
}
@ -24,13 +28,13 @@ export default class BaseStage {
* Callback when Stage starts
*/
onCreate(): void {
console.info('Launcher BaseStage onCreate!');
Log.showInfo(TAG, 'onCreate!');
}
/**
* Callback when stage exits
*/
onDestroy(): void {
console.info('Launcher BaseStage onDestroy!');
Log.showInfo(TAG, 'onDestroy!');
}
}

View File

@ -54,7 +54,7 @@ export default class RecentMissionInfo {
lockedState: boolean | undefined;
/**
* Recent mission: snapShot info
* Recent mission: trigger snapShot update
*/
snapShotInfo: SnapShotInfo | undefined;
snapShotTime: string | undefined;
}

View File

@ -0,0 +1,55 @@
/**
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import SettingItemOption from './SettingItemOption';
/**
* Item info for launcher settings db data.
*/
export default class SettingDbInfo {
/**
* Index for setting db item.
*/
id: number | undefined;
/**
* appStartPageType for setting db item.
*/
appStartPageType: string | undefined;
/**
* gridConfig for setting db item.
*/
gridConfig: number | undefined;
/**
* deviceType for setting db item.
*/
deviceType: string | undefined;
/**
* pageCount for setting db item.
*/
pageCount: number | undefined;
/**
* row for setting db item.
*/
row: number | undefined;
/**
* column for setting db item.
*/
column: number | undefined;
}

View File

@ -35,7 +35,6 @@ export default class DiskLruCache {
* Init the cache whether the file has data.
*/
initMap(): void {
console.info('Launcher DiskLruCache initMap start execution');
}
/**

View File

@ -38,6 +38,32 @@ const RdbStoreConfig = {
'config_ability TEXT, ' +
'app_label_id INTEGER, ' +
'dimension INTEGER)'
},
Settings: {
TABLE_NAME: 'SETTINGS',
CREATE_TABLE: 'CREATE TABLE IF NOT EXISTS SETTINGS ' +
'(id INTEGER PRIMARY KEY AUTOINCREMENT, ' +
'app_start_page_type TEXT, ' +
'grid_config INTEGER, ' +
'device_type TEXT, ' +
'page_count INTEGER, ' +
'row INTEGER, ' +
'column INTEGER)'
},
SmartDock: {
TABLE_NAME: 'SMARTDOCK',
CREATE_TABLE: 'CREATE TABLE IF NOT EXISTS SMARTDOCK ' +
'(id INTEGER PRIMARY KEY AUTOINCREMENT, ' +
'item_type INTEGER, ' +
'editable INTEGER, ' +
'bundle_name TEXT, ' +
'ability_name TEXT, ' +
'app_icon_id INTEGER, ' +
'app_label_id INTEGER, ' +
'app_name TEXT, ' +
'install_time TEXT)'
}
};

View File

@ -59,7 +59,6 @@ class LayoutConfigManager {
if (globalThis.LayoutConfigManager == null) {
globalThis.LayoutConfigManager = new LayoutConfigManager();
}
console.info('Launcher LayoutConfigManager constructor!');
return globalThis.LayoutConfigManager;
}

View File

@ -86,7 +86,7 @@ export default class PageDesktopModeConfig extends ILayoutConfig {
*/
updateAppStartPageType(startPageType: string): void {
this.mAppStartPageType = startPageType;
super.persistConfig();
globalThis.RdbStoreManagerInstance.updateSettings('app_start_page_type', startPageType);
}
/**
@ -105,7 +105,7 @@ export default class PageDesktopModeConfig extends ILayoutConfig {
*/
updateGridConfig(gridConfig: number): void {
this.mGridConfig = gridConfig;
super.persistConfig();
globalThis.RdbStoreManagerInstance.updateSettings('grid_config', gridConfig);
}
/**
@ -124,7 +124,7 @@ export default class PageDesktopModeConfig extends ILayoutConfig {
*/
updateDeviceType(deviceType: string): void {
this.mDeviceType = deviceType;
super.persistConfig();
globalThis.RdbStoreManagerInstance.updateSettings('device_type', deviceType);
}
/**

View File

@ -42,7 +42,6 @@ export default class SmartDockLayoutConfig extends ILayoutConfig {
globalThis.SmartDockLayoutConfig = new SmartDockLayoutConfig();
globalThis.SmartDockLayoutConfig.initConfig();
}
console.info('Launcher SmartDockLayoutConfig getInstance!');
return globalThis.SmartDockLayoutConfig;
}

View File

@ -186,7 +186,7 @@ class AmsMissionManager {
* @param missionId mission id to unlock.
*/
async unlockMission(missionId: number): Promise<void> {
console.info(`unlockMission start! missionId: ${missionId}`);
Log.showInfo(TAG, `unlockMission start! missionId: ${missionId}`);
await missionManager.unlockMission(missionId)
.then((data) => {
Log.showInfo(TAG, `unlockMission data: ${JSON.stringify(data)}`);

View File

@ -86,7 +86,7 @@ class LauncherAbilityManager {
launcherBundleMgr.on(LauncherAbilityManager.BUNDLE_STATUS_CHANGE_KEY, this.mBundleStatusCallback).then(data => {
Log.showInfo(TAG, `registerCallback success: ${JSON.stringify(data)}`);
}).catch(err => {
Log.showError(TAG, `registerCallback fail: ${JSON.stringify(err)}`);
Log.showInfo(TAG, `registerCallback fail: ${JSON.stringify(err)}`);
});
}
const index = this.mLauncherAbilityChangeListeners.indexOf(listener);
@ -111,7 +111,7 @@ class LauncherAbilityManager {
launcherBundleMgr.off(LauncherAbilityManager.BUNDLE_STATUS_CHANGE_KEY).then(data => {
Log.showInfo(TAG, 'unregisterCallback success');
}).catch(err => {
Log.showError(TAG, `unregisterCallback fail: ${JSON.stringify(err)}`);
Log.showInfo(TAG, `unregisterCallback fail: ${JSON.stringify(err)}`);
});
}
}
@ -138,7 +138,7 @@ class LauncherAbilityManager {
});
const appItemInfoList = new Array<AppItemInfo>();
if (CheckEmptyUtils.isEmpty(abilityList)) {
Log.showError(TAG, 'getLauncherAbilityList Empty');
Log.showInfo(TAG, 'getLauncherAbilityList Empty');
return appItemInfoList;
}
for (let i = 0; i < abilityList.length; i++) {
@ -166,7 +166,7 @@ class LauncherAbilityManager {
});
const appItemInfoList = new Array<AppItemInfo>();
if (CheckEmptyUtils.isEmpty(abilityInfos)) {
console.error('getLauncherAbilityInfo Empty');
Log.showInfo(TAG, 'getLauncherAbilityInfo Empty');
return appItemInfoList;
}
for (let i = 0; i < abilityInfos.length; i++) {
@ -205,7 +205,7 @@ class LauncherAbilityManager {
});
if (abilityInfos == undefined || abilityInfos.length == 0) {
Log.showError(TAG, `${bundleName} has no launcher ability`);
Log.showInfo(TAG, `${bundleName} has no launcher ability`);
return undefined;
}
const data = await this.convertToAppItemInfo(abilityInfos[0]);
@ -265,7 +265,7 @@ class LauncherAbilityManager {
}).then(() => {
Log.showInfo(TAG, 'startApplication promise success');
}, (err) => {
Log.showError(TAG, `startApplication promise error: ${JSON.stringify(err)}`);
Log.showInfo(TAG, `startApplication promise error: ${JSON.stringify(err)}`);
});
Log.showInfo(TAG, `startApplication AceApplication : startAbility : ${result}`);
Trace.end(Trace.CORE_METHOD_LAUNCH_APP);
@ -302,7 +302,7 @@ class LauncherAbilityManager {
callback(paramBundleName, shortcutInfo);
})
.catch(err => {
Log.showError(TAG, `getShortcutInfo ${JSON.stringify(err)}`);
Log.showInfo(TAG, `getShortcutInfo ${JSON.stringify(err)}`);
});
}
@ -320,7 +320,7 @@ class LauncherAbilityManager {
}).then(() => {
Log.showInfo(TAG, 'startLauncherAbilityByUri promise success');
}, (err) => {
Log.showError(TAG, `startLauncherAbilityByUri promise error: ${JSON.stringify(err)}`);
Log.showInfo(TAG, `startLauncherAbilityByUri promise error: ${JSON.stringify(err)}`);
});
Log.showInfo(TAG, `startLauncherAbilityByUri AceApplication : startAbility : ${result}`);
}

View File

@ -15,9 +15,11 @@
import dataRdb from '@ohos.data.rdb';
import CommonConstants from '../constants/CommonConstants';
import CheckEmptyUtils from '../utils/CheckEmptyUtils';
import RdbStoreConfig from '../configs/RdbStoreConfig';
import BadgeItemInfo from '../bean/BadgeItemInfo';
import CardItemInfo from '../bean/CardItemInfo';
import DockItemInfo from '../bean/DockItemInfo';
import Log from '../utils/Log';
const TAG = 'RdbStoreManager';
@ -44,26 +46,37 @@ export default class RdbStoreManager {
async initRdbConfig(): Promise<void> {
Log.showInfo(TAG, 'initRdbConfig start');
const promise = dataRdb.getRdbStore(globalThis.desktopContext,
{
name: RdbStoreConfig.DB_NAME
}, RdbStoreConfig.DB_VERSION);
promise.then(async (rdbStore) => {
Log.showInfo(TAG, 'initRdbConfig dataRdb.getRdbStore:' + rdbStore);
this.mRdbStore = rdbStore;
void this.createTable();
}).catch((error) => {
Log.showError(TAG, `initRdbConfig Failed to obtain the rdbStore. Cause: ${error.message}`);
});
await dataRdb.getRdbStore(globalThis.desktopContext, {
name: RdbStoreConfig.DB_NAME
}, RdbStoreConfig.DB_VERSION)
.then((rdbStore) => {
Log.showInfo(TAG, 'initRdbConfig dataRdb.getRdbStore:' + rdbStore);
this.mRdbStore = rdbStore;
})
.catch((error) => {
Log.showError(TAG, `initRdbConfig Failed to obtain the rdbStore. Cause: ${error.message}`);
});
Log.showInfo(TAG, 'initRdbConfig end');
}
private async createTable(): Promise<void> {
async createTable(): Promise<void> {
Log.showInfo(TAG, 'create table start');
Log.showInfo(TAG, `RdbStoreConfig.Badge.CREATE_TABLE: ${RdbStoreConfig.Badge.CREATE_TABLE}`);
await this.mRdbStore.executeSql(RdbStoreConfig.Badge.CREATE_TABLE, []);
Log.showInfo(TAG, `RdbStoreConfig.Form.CREATE_TABLE: ${RdbStoreConfig.Form.CREATE_TABLE}`);
await this.mRdbStore.executeSql(RdbStoreConfig.Form.CREATE_TABLE, []);
try {
Log.showInfo(TAG, `RdbStoreConfig.Badge.CREATE_TABLE: ${RdbStoreConfig.Badge.CREATE_TABLE}`);
await this.mRdbStore.executeSql(RdbStoreConfig.Badge.CREATE_TABLE, []);
Log.showInfo(TAG, `RdbStoreConfig.Form.CREATE_TABLE: ${RdbStoreConfig.Form.CREATE_TABLE}`);
await this.mRdbStore.executeSql(RdbStoreConfig.Form.CREATE_TABLE, []);
Log.showInfo(TAG, `RdbStoreConfig.Settings.CREATE_TABLE: ${RdbStoreConfig.Settings.CREATE_TABLE}`);
await this.mRdbStore.executeSql(RdbStoreConfig.Settings.CREATE_TABLE, []);
Log.showInfo(TAG, `RdbStoreConfig.SmartDock.CREATE_TABLE: ${RdbStoreConfig.SmartDock.CREATE_TABLE}`);
await this.mRdbStore.executeSql(RdbStoreConfig.SmartDock.CREATE_TABLE, []);
Log.showInfo(TAG, 'create table end');
// set default settings data
await this.updateSettings();
} catch (error) {
Log.showInfo(TAG, `create table error: ${error}`);
}
Log.showInfo(TAG, 'create table end');
}
@ -72,7 +85,7 @@ export default class RdbStoreManager {
const predicates = new dataRdb.RdbPredicates(RdbStoreConfig.Badge.TABLE_NAME);
const resultList: BadgeItemInfo[] = [];
try {
const resultSet = await this.mRdbStore.query(predicates, []);
let resultSet = await this.mRdbStore.query(predicates, []);
let isLast = resultSet.goToFirstRow();
Log.showInfo(TAG, `getAllBadge before isLast: ${isLast}`);
while (isLast) {
@ -86,8 +99,10 @@ export default class RdbStoreManager {
isLast = resultSet.goToNextRow();
Log.showInfo(TAG, `getAllBadge while isLast: ${isLast}`);
}
resultSet.close()
resultSet = null;
} catch (e) {
Log.showInfo(TAG, 'getAllBadge error:' + e);
Log.showError(TAG, 'getAllBadge error:' + e);
}
Log.showInfo(TAG, 'getAllBadge end');
return resultList;
@ -102,7 +117,7 @@ export default class RdbStoreManager {
try {
const predicates = new dataRdb.RdbPredicates(RdbStoreConfig.Badge.TABLE_NAME);
predicates.equalTo('bundle_name', bundleName);
const resultSet = await this.mRdbStore.query(predicates, []);
let resultSet = await this.mRdbStore.query(predicates, []);
let isLast = resultSet.goToFirstRow();
Log.showInfo(TAG, `getBadgeByBundle before isLast: ${isLast}`);
while (isLast) {
@ -116,8 +131,10 @@ export default class RdbStoreManager {
isLast = resultSet.goToNextRow();
Log.showInfo(TAG, `getBadgeByBundle while isLast: ${isLast}`);
}
resultSet.close()
resultSet = null;
} catch (e) {
Log.showInfo(TAG, 'getBadgeByBundle error:' + e);
Log.showError(TAG, 'getBadgeByBundle error:' + e);
}
return resultList;
}
@ -151,7 +168,7 @@ export default class RdbStoreManager {
result = (changeRows != CommonConstants.INVALID_VALUE);
}
} catch (e) {
Log.showInfo(TAG, 'updateBadgeByBundle error:' + e);
Log.showError(TAG, 'updateBadgeByBundle error:' + e);
}
return result;
}
@ -171,7 +188,7 @@ export default class RdbStoreManager {
result = true;
}
} catch (e) {
Log.showInfo(TAG, 'deleteBadgeByBundle error:' + e);
Log.showError(TAG, 'deleteBadgeByBundle error:' + e);
}
return result;
}
@ -190,7 +207,7 @@ export default class RdbStoreManager {
}
const resultList: CardItemInfo[] = [];
try {
const resultSet = await this.mRdbStore.query(predicates, []);
let resultSet = await this.mRdbStore.query(predicates, []);
let isLast = resultSet.goToFirstRow();
Log.showInfo(TAG, `getAllFormInfos before isLast:${isLast}`);
while (isLast) {
@ -207,8 +224,10 @@ export default class RdbStoreManager {
isLast = resultSet.goToNextRow();
Log.showInfo(TAG, `getAllFormInfos while isLast:${isLast}`);
}
resultSet.close()
resultSet = null;
} catch (e) {
Log.showInfo(TAG, 'getAllFormInfos error:' + e);
Log.showError(TAG, 'getAllFormInfos error:' + e);
}
Log.showInfo(TAG, 'getAllFormInfos end');
return resultList;
@ -263,7 +282,7 @@ export default class RdbStoreManager {
result = (changeRows != CommonConstants.INVALID_VALUE);
}
} catch (e) {
Log.showInfo(TAG, 'updateFormInfoById error:' + e);
Log.showError(TAG, 'updateFormInfoById error:' + e);
}
return result;
}
@ -280,7 +299,7 @@ export default class RdbStoreManager {
result = true;
}
} catch (e) {
Log.showInfo(TAG, 'deleteFormInfoById error:' + e);
Log.showError(TAG, 'deleteFormInfoById error:' + e);
}
return result;
}
@ -297,7 +316,7 @@ export default class RdbStoreManager {
result = true;
}
} catch (e) {
Log.showInfo(TAG, 'deleteFormInfoByBundle error:' + e);
Log.showError(TAG, 'deleteFormInfoByBundle error:' + e);
}
Log.showInfo(TAG, 'deleteFormInfoByBundle end');
return result;
@ -309,4 +328,118 @@ export default class RdbStoreManager {
}
return false;
}
async updateSettings(key?: string, value?: any): Promise<boolean> {
Log.showInfo(TAG, 'updateSettings start');
let result = false;
try {
// get deviceType
let deviceType = AppStorage.Get('device');
// init default settings config
if (CheckEmptyUtils.isEmpty(key) || CheckEmptyUtils.isEmpty(value)) {
const firstDbData = {
'app_start_page_type': 'Grid',
'grid_config': 0,
'device_type': deviceType,
'page_count': 1,
'row': 5,
'column': 11
};
Log.showInfo(TAG, `updateSettings firstDbData: ${firstDbData}`);
// insert sql
let ret = await this.mRdbStore.insert(RdbStoreConfig.Settings.TABLE_NAME, firstDbData);
Log.showInfo(TAG, `updateSettings ret: ${ret}`);
} else {
// update settings by key and value
let sql = `UPDATE ${RdbStoreConfig.Settings.TABLE_NAME} SET ${key} = '${value}' WHERE id = 1`;
Log.showInfo(TAG, `updateSettings sql: ${sql}`);
await this.mRdbStore.executeSql(sql, function () {})
}
} catch (e) {
Log.showError(TAG, 'updateSettings error:' + e);
}
return result;
}
async insertIntoSmartdock(dockInfoList: DockItemInfo[]): Promise<boolean> {
Log.showInfo(TAG, 'insertIntoSmartdock start');
let result = false;
try {
// delete smartdock table
await this.deleteTable(RdbStoreConfig.SmartDock.TABLE_NAME);
// insert into smartdock
Log.showInfo(TAG, `insertIntoSmartdock dockInfoList: ${dockInfoList.length}`);
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,
'app_icon_id': dockInfoList[i].appIconId,
'app_label_id': dockInfoList[i].appLabelId,
'app_name': dockInfoList[i].appName,
'install_time': dockInfoList[i].installTime
}
let ret = await this.mRdbStore.insert(RdbStoreConfig.SmartDock.TABLE_NAME, smartdockDbItem);
Log.showInfo(TAG, `insertIntoSmartdock ${i} ret: ${ret}`);
}
} catch (e) {
Log.showError(TAG, 'insertIntoSmartdock error:' + e);
}
return result;
}
async deleteTable(tableName: string): Promise<void> {
Log.showInfo(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 () {})
Log.showInfo(TAG, 'deleteTable end');
} catch (e) {
Log.showError(TAG, `deleteTable err: ${e}`);
}
}
async querySmartDock(): Promise<DockItemInfo[]> {
const resultList: DockItemInfo[] = [];
try {
const predicates = new dataRdb.RdbPredicates(RdbStoreConfig.SmartDock.TABLE_NAME);
let resultSet = await this.mRdbStore.query(predicates, []);
let isLast = resultSet.goToFirstRow();
Log.showInfo(TAG, `querySmartDock before isLast:${isLast}`);
while (isLast) {
const itemInfo: DockItemInfo = new DockItemInfo();
itemInfo.itemType = resultSet.getLong(resultSet.getColumnIndex('item_type'));
itemInfo.editable = this.numberToBoolean(resultSet.getLong(resultSet.getColumnIndex('editable')));
itemInfo.bundleName = resultSet.getString(resultSet.getColumnIndex('bundle_name'));
itemInfo.abilityName = resultSet.getString(resultSet.getColumnIndex('ability_name'));
itemInfo.appIconId = resultSet.getLong(resultSet.getColumnIndex('app_icon_id'));
itemInfo.appLabelId = resultSet.getLong(resultSet.getColumnIndex('app_label_id'));
itemInfo.appName = resultSet.getString(resultSet.getColumnIndex('app_name'));
itemInfo.installTime = resultSet.getString(resultSet.getColumnIndex('install_time'));
resultList.push(itemInfo);
isLast = resultSet.goToNextRow();
Log.showInfo(TAG, `querySmartDock while isLast:${isLast}`);
}
resultSet.close()
resultSet = null;
} catch (e) {
Log.showError(TAG, 'querySmartDock error:' + e);
}
Log.showInfo(TAG, `querySmartDock resultList.length: ${resultList.length}`);
return resultList;
}
booleanToNumber(data: boolean): number {
return data ? 1 : 0;
}
numberToBoolean(data: number): boolean {
return data === 1;
}
}

View File

@ -24,6 +24,9 @@ import PageDesktopAppModeConfig from '../layoutconfig/PageDesktopAppModeConfig';
import RecentsModeConfig from '../layoutconfig/RecentsModeConfig';
import settingsDataManager from '../manager/SettingsDataManager';
import SettingsModelObserver from './SettingsModelObserver';
import Log from '../utils/Log';
const TAG = 'SettingsModel';
const defaultLayoutInfoFilePath = globalThis.desktopContext.filesDir + '/layoutInfo.json';
@ -68,12 +71,12 @@ export default class SettingsModel {
}
addObserver(observer: SettingsModelObserver): void {
console.info('addObserver');
Log.showInfo(TAG, 'addObserver');
this.mObserverList.push(observer);
}
private notifyObservers(event: number): void {
console.info('notifyObservers');
Log.showInfo(TAG, 'notifyObservers');
for (let i = 0; i < this.mObserverList.length; i++) {
this.mObserverList[i](event);
}
@ -189,7 +192,7 @@ export default class SettingsModel {
* @param {string} deviceType - device type.
*/
setDevice(deviceType): void {
console.log(`setDevice ${deviceType}`);
Log.showInfo(TAG, `setDevice ${deviceType}`);
if (deviceType == CommonConstants.DEFAULT_DEVICE_TYPE) {
this.mGridLayoutTable = GridLayoutConfigs.GridLayoutTable;
} else if (deviceType == CommonConstants.PAD_DEVICE_TYPE) {

View File

@ -16,6 +16,9 @@ import SettingItemOptionsChecker from './SettingItemOptionsChecker';
import SettingItemsConfig from '../configs/SettingItemsConfig';
import SettingItemInfo from '../bean/SettingItemInfo';
import SettingItemOption from '../bean/SettingItemOption';
import Log from '../utils/Log';
const TAG = 'SettingItemsManager';
/**
* Manager class for launcher settings item.
@ -37,9 +40,9 @@ export default class SettingItemsManager {
/**
* Get corresponding functions for the given name.
*/
withChecker(SettingName: string, func: SettingItemOptionsChecker): SettingItemsManager {
console.info('Launcher SettingItemsManager withChecker SettingName is ' + SettingName);
this.settingName2CheckerFuncMap[SettingName] = func;
withChecker(settingName: string, func: SettingItemOptionsChecker): SettingItemsManager {
Log.showInfo(TAG, `withChecker settingName: ${settingName}`);
this.settingName2CheckerFuncMap[settingName] = func;
return this;
}

View File

@ -17,6 +17,9 @@
* An util that provides io functionality between file and JSON object.
*/
import Fileio from '@ohos.fileio';
import Log from './Log';
const TAG = 'FileUtils';
const writeFilePath = globalThis.desktopContext.cacheDir + '/';
const READ_DATA_SIZE = 4096;
@ -30,15 +33,15 @@ export default class FileUtils {
* @return {any} - read object from file
*/
static readJsonFile(path: string): any {
console.info('Launcher FileUtil readJsonFile start execution');
Log.showInfo(TAG, 'readJsonFile start execution');
let readStreamSync = null;
try {
readStreamSync = Fileio.createStreamSync(path, 'r');
const content = this.getContent(readStreamSync);
console.info('Launcher FileUtil readJsonFile finish execution' + content);
Log.showInfo(TAG, `readJsonFile finish execution content: ${content}`);
return JSON.parse(content);
} catch (e) {
console.info('Launcher FileUtil readJsonFile ' + e);
Log.showInfo(TAG, `readJsonFile error: ${e}`);
} finally {
readStreamSync.closeSync();
}
@ -51,16 +54,16 @@ export default class FileUtils {
* @return {string} - read string from file
*/
static readStringFromFile(bundleName: string): string {
console.info('Launcher FileUtil readStringFromFile start execution');
Log.showInfo(TAG, 'readStringFromFile start execution');
const filePath = writeFilePath + bundleName + '.json';
let readStreamSync = null;
try {
readStreamSync = Fileio.createStreamSync(filePath, 'r');
const content = this.getContent(readStreamSync);
console.info('Launcher FileUtil readStringFromFile finish execution' + content);
Log.showInfo(TAG, 'readStringFromFile finish execution' + content);
return content;
} catch (e) {
console.info('Launcher FileUtil readStringFromFile ' + e);
Log.showInfo(TAG, 'readStringFromFile ' + e);
} finally {
readStreamSync.closeSync();
}
@ -73,17 +76,17 @@ export default class FileUtils {
* @param {string} bundleName - bundleName as target file name
*/
static writeStringToFile(string: string, bundleName: string): void {
console.info('Launcher FileUtil writeStringToFile start execution');
Log.showInfo(TAG, 'writeStringToFile start execution');
const filePath = writeFilePath + bundleName + '.json';
let writeStreamSync = null;
try {
writeStreamSync = Fileio.createStreamSync(filePath, 'w+');
writeStreamSync.writeSync(string);
} catch (e) {
console.info('Launcher FileUtil writeStringToFile error: ' + e);
Log.showInfo(TAG, 'writeStringToFile error: ' + e);
} finally {
writeStreamSync.closeSync();
console.info('Launcher FileUtil writeStringToFile close sync');
Log.showInfo(TAG, 'writeStringToFile close sync');
}
}
@ -94,13 +97,13 @@ export default class FileUtils {
* @return {object} - object read from file stream
*/
static getContent(readStreamSync) {
console.info('Launcher FileUtil getContent start');
Log.showInfo(TAG, 'getContent start');
const bufArray = [];
let totalLength = 0;
let buf = new ArrayBuffer(READ_DATA_SIZE);
let len = readStreamSync.readSync(buf);
while (len != 0) {
console.info(`Launcher FileUtil getContent FileIO reading ${len}`);
Log.showInfo(TAG, `getContent FileIO reading ${len}`);
totalLength += len;
if (len < READ_DATA_SIZE) {
buf = buf.slice(0, len);
@ -111,11 +114,11 @@ export default class FileUtils {
buf = new ArrayBuffer(READ_DATA_SIZE);
len = readStreamSync.readSync(buf);
}
console.info('Launcher FileUtil getContent read finished ' + totalLength);
Log.showInfo(TAG, `getContent read finished: ${totalLength}`);
const contentBuf = new Uint8Array(totalLength);
let offset = 0;
for (const bufArr of bufArray) {
console.info('Launcher FileUtil getContent collecting ' + offset);
Log.showInfo(TAG, `getContent collecting: ${offset}`);
const uInt8Arr = new Uint8Array(bufArr);
contentBuf.set(uInt8Arr, offset);
offset += uInt8Arr.byteLength;

View File

@ -18,6 +18,9 @@ import BaseAppPresenter from '../../../../../../../../common/src/main/ets/defaul
import PinyinSort from '../../../../../../../../common/src/main/ets/default/utils/PinyinSort';
import CommonConstants from '../../../../../../../../common/src/main/ets/default/constants/CommonConstants';
import AppItemInfo from '../../../../../../../../common/src/main/ets/default/bean/AppItemInfo';
import Log from '../../../../../../../../common/src/main/ets/default/utils/Log';
const TAG = 'AppListPresenter';
const KEY_APP_LIST = "appListInfo";
const KEY_NAME = "name";
@ -47,12 +50,12 @@ export default class AppListPresenter extends BaseAppPresenter {
for (let item of callbackList) {
let cacheKey = item.appLabelId + item.bundleName;
let appName = this.mResourceManager.getAppResourceCache(cacheKey, KEY_NAME);
console.info("Launcher AppListPresenter regroupDataAppListChange + appName = " + appName);
Log.showInfo(TAG, `regroupDataAppListChange appName: ${appName}`);
if (appName != null) {
item.appName = appName;
} else {
let loadAppName = await this.mResourceManager.getAppNameSync(item.appLabelId, item.bundleName, item.appName);
console.info("Launcher AppListPresenter regroupDataAppListChange loadAppName:" + loadAppName);
Log.showInfo(TAG, `regroupDataAppListChange loadAppName: ${loadAppName}`);
item.appName = loadAppName;
}
}
@ -72,7 +75,7 @@ export default class AppListPresenter extends BaseAppPresenter {
}
public informUninstallResult(resultCode) {
console.info("Launcher AppListView getUninstallApp uninstallationResult:" + resultCode);
Log.showInfo(TAG, `Launcher AppListView getUninstallApp uninstallationResult: ${resultCode}`);
if (resultCode === CommonConstants.UNINSTALL_FORBID) {
Prompt.showToast({
message: $r("app.string.disable_uninstall")
@ -89,7 +92,7 @@ export default class AppListPresenter extends BaseAppPresenter {
}
public intoSetting() {
console.info("Launcher AppListView intoSetting");
Log.showInfo(TAG, 'intoSetting');
this.jumpToSetting();
}
@ -100,7 +103,7 @@ export default class AppListPresenter extends BaseAppPresenter {
* @param {string} bundleName - bundle name of the application to be jump to.
*/
public openApplication(abilityName, bundleName) {
console.info("Launcher AppListView openApplication abilityName:" + abilityName);
Log.showInfo(TAG, `openApplication abilityName: ${abilityName}`);
this.jumpTo(abilityName, bundleName);
}
}

View File

@ -123,7 +123,7 @@ export default struct AppGridLayout {
addToDeskMenu.menuImgSrc = "/common/pics/ic_public_copy.svg";
addToDeskMenu.menuText = $r('app.string.app_center_menu_add_desktop');
addToDeskMenu.onMenuClick = () => {
Log.showInfo(TAG, "Launcher click menu item add to pageDesk entry");
Log.showInfo(TAG, 'click menu item add to pageDesk entry');
localEventManager.sendLocalEventSticky(EventConstants.EVENT_REQUEST_PAGEDESK_ITEM_ADD, appInfo);
};
menuInfoList.push(addToDeskMenu);
@ -133,10 +133,10 @@ export default struct AppGridLayout {
uninstallMenu.menuImgSrc = "/common/pics/ic_public_delete.svg";
uninstallMenu.menuText = $r('app.string.uninstall');
uninstallMenu.onMenuClick = () => {
Log.showInfo(TAG, "Launcher click menu item uninstall" + JSON.stringify(appInfo));
Log.showInfo(TAG, `click menu item uninstall: ${JSON.stringify(appInfo)}`);
let cacheKey = appInfo.appLabelId + appInfo.bundleName;
let appName = this.mAppGridPresenter.getAppName(cacheKey);
Log.showInfo(TAG, "Launcher AppGridLayout buildMenuInfoList appName" + appName);
Log.showInfo(TAG, `buildMenuInfoList appName: ${appName}`);
if (appName != null) {
appInfo.appName = appName;
}

View File

@ -21,6 +21,9 @@ import AppList from '../../../../../../../common/src/main/ets/default/uicomponen
import StyleConstants from '../../../../../../../common/src/main/ets/default/constants/StyleConstants';
import ResourceManager from '../../../../../../../common/src/main/ets/default/manager/ResourceManager';
import UninstallDialog from '../../../../../../../common/src/main/ets/default/uicomponents/UninstallDialog.ets';
import Log from '../../../../../../../common/src/main/ets/default/utils/Log';
const TAG = 'ListLayout';
let mAppListPresenter: AppListPresenter;
@ -68,7 +71,7 @@ export default struct ListLayout {
}
cancelDialog() {
console.info('Launcher Grid Cancel Dialog');
Log.showInfo(TAG, 'Cancel Dialog');
}
build() {

View File

@ -501,7 +501,7 @@ struct FolderAppItem {
},
confirm: (formCardItem) => {
// add form to desktop
Log.showInfo(TAG, "createCardToDeskTop formCardItem: " + JSON.stringify(formCardItem));
Log.showInfo(TAG, `createCardToDeskTop formCardItem: ${JSON.stringify(formCardItem)}`);
mPageDesktopViewModel.createCardToDeskTop(formCardItem);
},
bundleName: this.item.bundleName,

View File

@ -57,7 +57,7 @@ export default class PageDesktopDragHandler extends BaseDragHandler {
}
setDragEffectArea(effectArea): void {
console.info(`Launcher PageDesktopDragHandler setDragEffectArea:${JSON.stringify(effectArea)}`);
Log.showInfo(TAG, `setDragEffectArea:${JSON.stringify(effectArea)}`)
super.setDragEffectArea(effectArea);
this.updateGridParam(effectArea);
}
@ -65,7 +65,7 @@ export default class PageDesktopDragHandler extends BaseDragHandler {
private updateGridParam(effectArea) {
const gridWidth = effectArea.right - effectArea.left;
const gridHeight = effectArea.bottom - effectArea.top;
console.info(`Launcher PageDesktop updateGridParam gridWidth: ${gridWidth}, gridHeight: ${gridHeight}`);
Log.showInfo(TAG, `updateGridParam gridWidth: ${gridWidth}, gridHeight: ${gridHeight}`);
this.mGridConfig = this.mPageDesktopViewModel.getGridConfig();
const column = this.mGridConfig.column;
const row = this.mGridConfig.row;
@ -73,7 +73,7 @@ export default class PageDesktopDragHandler extends BaseDragHandler {
const rowGap = this.mPageDesktopViewModel.getPageDesktopStyleConfig().mRowsGap;
this.mGridItemHeight = row > 0 ? (gridHeight + columnsGap) / row : 0;
this.mGridItemWidth = column > 0 ? (gridWidth + rowGap) / column : 0;
console.info(`Launcher PageDesktop updateGridParam column: ${column}, row: ${row}`);
Log.showInfo(TAG, `updateGridParam column: ${column}, row: ${row}`);
this.mPageCoordinateData.gridYAxis = [];
for (let i = 1; i <= row; i++) {
const touchPositioningY = (gridHeight / row) * i + effectArea.top;
@ -97,7 +97,7 @@ export default class PageDesktopDragHandler extends BaseDragHandler {
protected getItemIndex(event: any): number {
const x = event.touches[0].screenX;
const y = event.touches[0].screenY;
console.info(`Launcher PageDesktop getItemIndex x: ${x}, y: ${y}`);
Log.showInfo(TAG, `getItemIndex x: ${x}, y: ${y}`);
let rowVal = CommonConstants.INVALID_VALUE;
for (let index = 0; index < this.mPageCoordinateData.gridYAxis.length; index++) {
if (this.mPageCoordinateData.gridYAxis[index] > y) {
@ -122,11 +122,10 @@ export default class PageDesktopDragHandler extends BaseDragHandler {
protected getItemByIndex(index: number): any {
const column = index % this.mGridConfig.column;
const row = Math.floor(index / this.mGridConfig.column);
console.info('Launcher PageDesktop getItemByIndex column: ' + column + ', row: ' + row);
const pageIndex: number = this.mPageDesktopViewModel.getIndex();
const appGridInfo = this.getDragRelativeData();
console.info('Launcher PageDesktop getItemByIndex pageIndex: ' + pageIndex + ', appGridInfo length: ' + appGridInfo.length);
Log.showInfo(TAG, `getItemByIndex pageIndex: ${pageIndex}, appGridInfo length: ${appGridInfo.length},
column: ${column}, row: ${row}`);
const itemInfo = appGridInfo[pageIndex].find(item => {
if (item.type == CommonConstants.TYPE_APP) {
return item.column == column && item.row == row;
@ -154,7 +153,7 @@ export default class PageDesktopDragHandler extends BaseDragHandler {
private getTouchPosition(x, y): any {
const pageIndex =this.mPageDesktopViewModel.getIndex();
console.info('getTouchPosition pageIndex: ' + pageIndex);
Log.showInfo(TAG, `getTouchPosition pageIndex: ${pageIndex}`);
const position = {
page: pageIndex,
row: 0,
@ -182,7 +181,7 @@ export default class PageDesktopDragHandler extends BaseDragHandler {
}
protected onDragStart(event: any, itemIndex: number): void {
Log.showInfo(TAG, 'onDragStart itemIndex: ' + itemIndex);
Log.showInfo(TAG, `onDragStart itemIndex: ${itemIndex}`);
super.onDragStart(event, itemIndex);
const moveAppX = event.touches[0].screenX;
const moveAppY = event.touches[0].screenY;
@ -265,7 +264,7 @@ export default class PageDesktopDragHandler extends BaseDragHandler {
protected onDragMove(event: any, insertIndex: number, itemIndex: number): void {
super.onDragMove(event, insertIndex, itemIndex);
console.info('Launcher PageDesktop onDragMove insertIndex: ' + insertIndex);
Log.showInfo(TAG, `onDragMove insertIndex: ${insertIndex}`);
const moveAppX = event.touches[0].screenX;
const moveAppY = event.touches[0].screenY;
const dragItemInfo = this.getDragItemInfo();
@ -282,7 +281,7 @@ export default class PageDesktopDragHandler extends BaseDragHandler {
protected onDragDrop(event: any, insertIndex: number, itemIndex: number): boolean {
super.onDragDrop(event, insertIndex, itemIndex);
console.info('Launcher PageDesktop onDragDrop insertIndex: ' + insertIndex + ' ,mIsInEffectArea: ' + this.mIsInEffectArea);
Log.showInfo(TAG, `onDragDrop insertIndex: ${insertIndex}, mIsInEffectArea: ${this.mIsInEffectArea}`);
AppStorage.SetOrCreate('overlayMode', CommonConstants.OVERLAY_TYPE_HIDE);
let isDragSuccess = false;
const startPosition = this.copyPosition(this.mStartPosition);
@ -332,7 +331,7 @@ export default class PageDesktopDragHandler extends BaseDragHandler {
this.mPageDesktopViewModel.pagingFiltering();
isDragSuccess = true;
} else {
console.info('Launcher PageDesktop onDragEnd not selfDrag');
Log.showInfo(TAG, 'onDragEnd not selfDrag');
}
}
this.deleteBlankPageAfterDragging(startPosition, endPosition);
@ -341,9 +340,9 @@ export default class PageDesktopDragHandler extends BaseDragHandler {
protected onDragEnd(isSuccess: boolean): void {
super.onDragEnd(isSuccess);
console.info('Launcher PageDesktop onDragEnd isSuccess: ' + isSuccess);
Log.showInfo(TAG, `onDragEnd isSuccess: ${isSuccess}`);
if (this.isDropOutSide() && isSuccess) {
console.info('Launcher PageDesktop onDragEnd dropOutSide');
Log.showInfo(TAG, 'onDragEnd dropOutSide');
}
this.mStartPosition = null;
@ -476,7 +475,7 @@ export default class PageDesktopDragHandler extends BaseDragHandler {
const layoutInfo = info.layoutInfo;
this.moveLayout(startInfo, endInfo, layoutInfo, startInfo);
info.layoutInfo = layoutInfo;
console.info('Launcher PageDesktop layoutAdjustment setLayoutInfo');
Log.showInfo(TAG, 'layoutAdjustment setLayoutInfo');
this.mPageDesktopViewModel.setLayoutInfo(info);
this.mPageDesktopViewModel.pagingFiltering();
}
@ -485,7 +484,7 @@ export default class PageDesktopDragHandler extends BaseDragHandler {
const info = this.mPageDesktopViewModel.getLayoutInfo();
const layoutInfo = info.layoutInfo;
if (!this.isValidShortcut(layoutInfo, itemInfo)) {
console.info('Launcher PageDesktop layoutAdjustment isInvalidShortcut');
Log.showInfo(TAG, 'layoutAdjustment isInvalidShortcut');
Prompt.showToast({
message: $r('app.string.duplicate_add')
});
@ -507,7 +506,7 @@ export default class PageDesktopDragHandler extends BaseDragHandler {
}
}
info.layoutInfo = layoutInfo;
console.info('Launcher PageDesktop addItemToDeskTop setLayoutInfo');
Log.showInfo(TAG, 'addItemToDeskTop setLayoutInfo');
this.mPageDesktopViewModel.setLayoutInfo(info);
this.mPageDesktopViewModel.pagingFiltering();
}
@ -530,7 +529,7 @@ export default class PageDesktopDragHandler extends BaseDragHandler {
}
}
info.layoutInfo = layoutInfo;
console.info('Launcher PageDesktop removeItemFromDeskTop setLayoutInfo');
Log.showInfo(TAG, 'removeItemFromDeskTop setLayoutInfo');
this.mPageDesktopViewModel.setLayoutInfo(info);
this.mPageDesktopViewModel.pagingFiltering();
}

View File

@ -32,7 +32,7 @@ export default struct GridSwiper {
}
private aboutToDisappear(): void {
console.info("Launcher GridSwiper aboutToDisappear");
Log.showInfo(TAG, 'aboutToDisappear');
this.mPageDesktopViewModel.setPageIndex();
}

View File

@ -12,6 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import image from '@ohos.multimedia.image';
import CheckEmptyUtils from '../../../../../../../../common/src/main/ets/default/utils/CheckEmptyUtils';
import Log from '../../../../../../../../common/src/main/ets/default/utils/Log';
import CommonStyleConstants from '../../../../../../../../common/src/main/ets/default/constants/StyleConstants';
@ -20,6 +21,7 @@ import RecentMissionAppIcon from './RecentMissionAppIcon.ets';
import RecentMissionAppName from './RecentMissionAppName.ets';
import RecentMissionsViewModel from '../../viewmodel/RecentMissionsViewModel.ets';
import windowManager from '../../../../../../../../common/src/main/ets/default/manager/WindowManager';
import SnapShotInfo from '../../../../../../../../common/src/main/ets/default/bean/SnapShotInfo';
const TAG = 'Recent-RecentMissionCard';
@ -38,10 +40,10 @@ export default struct RecentMissionCard {
@Prop lockedState: boolean;
@State margin: number = StyleConstants.SINGLE_LIST_LAYOUT_MARGIN;
@State layoutWeight: number = StyleConstants.SINGLE_LIST_APP_INFO_LAYOUT_WEIGHT;
@State recentImage: any = '';
@State recentImage: string | image.PixelMap = '';
private mDefaultSnapShot: string = StyleConstants.DEFAULT_APP_IMAGE;
private mIsSingleLayout: boolean = true;
private mSnapshotList: any = [];
private snapShotTime: string = '';
private mRecentMissionsViewModel: RecentMissionsViewModel;
aboutToAppear(): void {
@ -52,6 +54,7 @@ export default struct RecentMissionCard {
StyleConstants.SINGLE_LIST_LAYOUT_MARGIN * StyleConstants.DPI_RATIO : StyleConstants.DOUBLE_LIST_LAYOUT_MARGIN;
this.layoutWeight = this.mRecentMissionsViewModel.getRecentMissionsRowType() === 'single' ?
StyleConstants.SINGLE_LIST_APP_INFO_LAYOUT_WEIGHT : StyleConstants.DOUBLE_LIST_APP_INFO_LAYOUT_WEIGHT;
this.mRecentMissionsViewModel.getMissionSnapShot(this.missionId, this.recentMissionsSnapshotCallback.bind(this));
if (CheckEmptyUtils.isEmpty(this.recentImage)) {
this.recentImage = this.mDefaultSnapShot;
}
@ -59,8 +62,11 @@ export default struct RecentMissionCard {
aboutToDisappear(): void {
Log.showInfo(TAG, `aboutToDisappear start ${this.missionId}`);
Log.showInfo(TAG, `typeof this.recentImage ${typeof this.recentImage}`);
if (this.recentImage != this.mDefaultSnapShot) {
void this.recentImage.release();
this.recentImage.release().catch((err) => {
Log.showError(TAG, `image.PixelMap release err: ${err}`);
})
}
}
@ -72,6 +78,23 @@ export default struct RecentMissionCard {
Log.showInfo(TAG, `onPageHide start`);
}
/**
* The callback of Recent missions snapshot.
*
* @param {number} missionId
* @param {any} snapShotInfo
*/
recentMissionsSnapshotCallback(missionId: number, snapShotInfo: SnapShotInfo): void {
Log.showInfo(TAG, `recentMissionsSnapshotCallback missionId: ${this.missionId}`);
if (missionId === this.missionId) {
this.recentImage = snapShotInfo.snapShotImage;
let width = snapShotInfo.snapShotImageWidth;
let height = snapShotInfo.snapShotImageHeight;
Log.showInfo(TAG, `recentMissionsSnapshotCallback recentImage: ${JSON.stringify(this.recentImage)},
width: ${JSON.stringify(width)}, height: ${JSON.stringify(height)}`);
}
}
build() {
Column() {
Row() {
@ -112,12 +135,12 @@ export default struct RecentMissionCard {
})
.onClick(() => {
this.isClickSubComponent = true;
Log.showInfo(TAG, 'onClick set recent mission Locked status');
this.mRecentMissionsViewModel.setRecentMissionLock(this.missionId, !this.lockedState);
this.lockedState = !this.lockedState;
Log.showInfo(TAG, `onClick set recent mission Locked status: ${this.lockedState}`);
this.mRecentMissionsViewModel.setRecentMissionLock(this.missionId, this.lockedState);
this.isClickSubComponent = false;
})
}
// .layoutWeight(1)
}
.margin({ bottom: this.mIsSingleLayout ? this.margin / 2 : StyleConstants.DOUBLE_LIST_APP_INFO_BOTTOM_MARGIN })
Image(this.recentImage)
@ -153,7 +176,8 @@ export default struct RecentMissionCard {
if (e.offsetY < -50 && e.offsetX <= offsetWidth && -offsetWidth <= e.offsetX) {
this.mRecentMissionsViewModel.deleteRecentMission(false, this.missionId);
} else if (e.offsetY > 50 && e.offsetX <= offsetWidth && -offsetWidth <= e.offsetX) {
this.lockedState = this.lockedState ? false : true;
this.lockedState = !this.lockedState;
Log.showInfo(TAG, `gesture set recent mission Locked status: ${this.lockedState}`);
this.mRecentMissionsViewModel.setRecentMissionLock(this.missionId, this.lockedState);
}
}))

View File

@ -61,7 +61,7 @@ export default struct RecentMissionsDoubleLayout {
abilityName: item.abilityName,
lockedState: item.lockedState,
isClickSubComponent: $isClickSubComponent,
recentImage: item.snapShotInfo.snapShotImage
snapShotTime: item.snapShotTime
})
}
.height(StyleConstants.DEFAULT_LAYOUT_PERCENTAGE)

View File

@ -54,7 +54,7 @@ export default struct RecentMissionsSingleLayout {
abilityName: item.abilityName,
lockedState: item.lockedState,
isClickSubComponent: $isClickSubComponent,
recentImage: item.snapShotInfo.snapShotImage
snapShotTime: item.snapShotTime
})
}, (item) => JSON.stringify(item))
}

View File

@ -100,8 +100,9 @@ export default class RecentMissionsViewModel {
Log.showInfo(TAG, 'getRecentMissionsList start');
this.mRecentMissionsList = await amsMissionManager.getRecentMissionsList();
Log.showInfo(TAG, `getRecentMissionsList length: ${this.mRecentMissionsList.length}`);
const snapShotTime = new Date().toString();
for (let item of this.mRecentMissionsList) {
item.snapShotInfo = await amsMissionManager.getMissionSnapShot(item.missionId);
item.snapShotTime = snapShotTime;
}
AppStorage.SetOrCreate('recentMissionsList', this.mRecentMissionsList);
}
@ -158,7 +159,6 @@ export default class RecentMissionsViewModel {
} else {
void this.unlockMission(missionId);
}
void this.getRecentMissionsList();
}
/**

View File

@ -1,7 +1,10 @@
import AbilityStage from '@ohos.application.AbilityStage';
import Log from '../../../../../../common/src/main/ets/default/utils/Log';
const TAG = 'Launcher Settings MyAbilityStage';
export default class MyAbilityStage extends AbilityStage {
onCreate(): void {
console.log('settings MyAbilityStage onCreate is called');
Log.showInfo(TAG, 'onCreate is called');
}
}

View File

@ -14,32 +14,35 @@
*/
import Ability from '@ohos.application.Ability';
import Log from '../../../../../../common/src/main/ets/default/utils/Log';
const TAG = 'Settings MainAbility';
export default class MainAbility extends Ability {
onCreate(want, launchParam) {
console.log('settings MainAbility onCreate is called');
Log.showInfo(TAG, 'onCreate is called');
}
onDestroy() {
console.log('settings MainAbility onDestroy is called');
Log.showInfo(TAG, 'onDestroy is called');
}
onWindowStageCreate(windowStage) {
console.log('settings MainAbility onWindowStageCreate is called');
Log.showInfo(TAG, 'onWindowStageCreate is called');
globalThis.settingsContext = this.context;
windowStage.setUIContent(this.context, 'pages/Settings', null);
}
onWindowStageDestroy() {
console.log('settings MainAbility onWindowStageDestroy is called');
Log.showInfo(TAG, 'onWindowStageDestroy is called');
}
onForeground() {
console.log('settings MainAbility onForeground is called');
Log.showInfo(TAG, 'onForeground is called');
}
onBackground() {
console.log('settings MainAbility onBackground is called');
Log.showInfo(TAG, 'onBackground is called');
globalThis.settingsContext.terminateSelf();
}
}

View File

@ -46,13 +46,13 @@ export default class SettingsPresenter {
private readonly mLayoutOptionsChecker: SettingItemOptionsChecker = ()=> {
const layout = this.mSettingsModel.getAppPageStartConfig();
Log.showInfo(TAG, 'mLayoutOptionsChecker layout is ' + layout);
Log.showInfo(TAG, `mLayoutOptionsChecker layout: ${layout}`);
return layout;
};
private readonly mGridLayOutOptionsChecker: SettingItemOptionsChecker = ()=> {
const gridLayout = this.mSettingsModel.getGridConfig().layout;
Log.showInfo(TAG, 'mGridLayOutOptionsChecker layout is ' + gridLayout);
Log.showInfo(TAG, `mGridLayOutOptionsChecker layout: ${gridLayout}`);
return gridLayout;
};

View File

@ -123,7 +123,7 @@ struct SettingPage {
private aboutToAppear(): void {
this.SettingList = mSettingsPresenter.getSettingList();
Log.showInfo(TAG, 'aboutToAppear SettingList ' + JSON.stringify(this.SettingList));
Log.showInfo(TAG, `aboutToAppear SettingList length: ${this.SettingList.length}`);
}
private onPageShow(): void {
@ -220,7 +220,7 @@ struct SettingItem {
.width(50)
.height(40)
.onChange((isOn: boolean) => {
Log.showInfo(TAG, 'SettingItemToggle onChange for GestureNavigation Enable:' + isOn);
Log.showInfo(TAG, `SettingItemToggle onChange for GestureNavigation Enable: ${isOn}`);
mSettingsPresenter.setValue(isOn ? '0' : '1');
})
}

View File

@ -50,7 +50,7 @@ export default class SmartDockDragHandler extends BaseDragHandler {
}
setDragEffectArea(effectArea): void {
Log.showInfo(TAG, 'setDragEffectArea:' + JSON.stringify(effectArea));
Log.showInfo(TAG, `setDragEffectArea: ${JSON.stringify(effectArea)}`);
super.setDragEffectArea(effectArea);
this.updateDockParam(effectArea);
}
@ -60,7 +60,7 @@ export default class SmartDockDragHandler extends BaseDragHandler {
const dockWidth = effectArea.right - effectArea.left;
const dockData: [] = this.getDragRelativeData();
const dataCount = dockData.length;
Log.showInfo(TAG, 'updateDockParam dockWidth: ' + dockWidth + ', dataCount: ' + dataCount);
Log.showInfo(TAG, `updateDockParam dockWidth: ${dockWidth}, dataCount: ${dataCount}`);
if (dataCount > 0) {
for (let index = 1; index <= dataCount; index++) {
this.mDockCoordinateData.push(dockWidth / dataCount * index + effectArea.left);
@ -68,7 +68,7 @@ export default class SmartDockDragHandler extends BaseDragHandler {
} else {
this.mDockCoordinateData.push(dockWidth);
}
Log.showInfo(TAG, 'updateDockParam DockCoordinateData: ' + JSON.stringify(this.mDockCoordinateData));
Log.showInfo(TAG, `updateDockParam DockCoordinateData: ${JSON.stringify(this.mDockCoordinateData)}`);
}
protected getDragRelativeData(): any {
@ -115,7 +115,7 @@ export default class SmartDockDragHandler extends BaseDragHandler {
protected onDragMove(event: any, insertIndex: number, itemIndex: number): void {
super.onDragMove(event, insertIndex, itemIndex);
Log.showInfo(TAG, 'onDragMove insertIndex: ' + insertIndex);
Log.showInfo(TAG, `onDragMove insertIndex: ${insertIndex}`);
const moveAppX = event.touches[0].screenX;
const moveAppY = event.touches[0].screenY;
AppStorage.SetOrCreate('overlayPositionX', moveAppX - (this.mSmartDockStyleConfig.mIconSize / 2));
@ -125,7 +125,7 @@ export default class SmartDockDragHandler extends BaseDragHandler {
protected onDragDrop(event: any, insertIndex: number, itemIndex: number): boolean {
this.mDevice = AppStorage.Get('device');
super.onDragDrop(event, insertIndex, itemIndex);
Log.showInfo(TAG, 'onDragDrop insertIndex: ' + insertIndex + ', this.mIsInEffectArea:' + this.mIsInEffectArea);
Log.showInfo(TAG, `onDragDrop insertIndex: ${insertIndex}, IsInEffectArea: ${this.mIsInEffectArea}`);
AppStorage.SetOrCreate('overlayMode', CommonConstants.OVERLAY_TYPE_HIDE);
let isDragSuccess = true;
if (this.mIsInEffectArea) {
@ -134,7 +134,7 @@ export default class SmartDockDragHandler extends BaseDragHandler {
isDragSuccess = true;
} else if (this.mDevice == CommonConstants.DEFAULT_DEVICE_TYPE) {
const dragItemInfo = this.getDragItemInfo();
Log.showInfo(TAG, 'onDragDrop addItem: ' + JSON.stringify(dragItemInfo));
Log.showInfo(TAG, `onDragDrop addItem: ${JSON.stringify(dragItemInfo)}`);
isDragSuccess = this.addItemToSmartDock(dragItemInfo, insertIndex);
}
} else if (this.mDevice == CommonConstants.DEFAULT_DEVICE_TYPE) {
@ -152,7 +152,6 @@ export default class SmartDockDragHandler extends BaseDragHandler {
this.mDevice = AppStorage.Get('device');
super.onDragEnd(isSuccess);
if (this.isDropOutSide() && isSuccess) {
console.info('Launcher PageDesktop onDragEnd dropOutSide');
Log.showInfo(TAG, 'onDragEnd dropOutSide');
}
}

View File

@ -58,7 +58,7 @@ export default class SmartDockModel {
this.registerDockListener();
this.getResidentList().then(() => {}, () => {});
this.mDevice = AppStorage.Get('device');
Log.showInfo(TAG, 'dockDevice:' + this.mDevice);
Log.showInfo(TAG, `dockDevice: ${this.mDevice}`);
if (this.mDevice === CommonConstants.PAD_DEVICE_TYPE) {
this.getRecentDataList().then(() => {}, () => {});
this.registerMissionListener();
@ -66,7 +66,7 @@ export default class SmartDockModel {
Log.showInfo(TAG, 'constructor!');
}
static getInstance(): SmartDockModel{
static getInstance(): SmartDockModel {
if (globalThis.SmartDockModel == null) {
globalThis.SmartDockModel = new SmartDockModel();
Log.showInfo(TAG, 'getInstance!');
@ -78,52 +78,65 @@ export default class SmartDockModel {
* get resident dock list
*/
async getResidentList(): Promise<void> {
const residentList = new Array<DockItemInfo>();
const dockDataList = this.mSmartDockLayoutConfig.getDockLayoutInfo();
Log.showInfo(TAG, 'getResidentList from config length:' + dockDataList.length);
for (let i = 0; i < dockDataList.length; i++) {
if (dockDataList[i].itemType == CommonConstants.TYPE_APP) {
Log.showInfo(TAG, 'getResidentList dockDataList[i].bundleName:' + dockDataList[i].bundleName);
const appData = await launcherAbilityManager.getAppInfoByBundleName(dockDataList[i].bundleName);
if (appData == undefined) {
continue;
let residentList = new Array<DockItemInfo>();
// query rdb data
let rdbResidentList: DockItemInfo[] = [];
rdbResidentList = await globalThis.RdbStoreManagerInstance.querySmartDock();
if (CheckEmptyUtils.isEmptyArr(rdbResidentList)) {
// init preset dock data
const dockDataList = this.mSmartDockLayoutConfig.getDockLayoutInfo();
Log.showInfo(TAG, `getResidentList from config length: ${dockDataList.length}`);
for (let i = 0; i < dockDataList.length; i++) {
if (dockDataList[i].itemType == CommonConstants.TYPE_APP) {
Log.showInfo(TAG, `getResidentList dockDataList[i].bundleName: ${dockDataList[i].bundleName}`);
const appData = await launcherAbilityManager.getAppInfoByBundleName(dockDataList[i].bundleName);
if (appData == undefined) {
continue;
}
const dockItemInfo = new DockItemInfo();
dockItemInfo.itemType = dockDataList[i].itemType;
dockItemInfo.editable = dockDataList[i].editable;
dockItemInfo.appName = typeof (appData) === 'undefined' ? dockDataList[i].appName : appData.appName;
dockItemInfo.bundleName = typeof (appData) === 'undefined' ? dockDataList[i].bundleName : appData.bundleName;
dockItemInfo.abilityName = typeof (appData) === 'undefined' ? dockItemInfo.abilityName : appData.abilityName;
dockItemInfo.appIconId = typeof (appData) === 'undefined' ? dockItemInfo.appIconId : appData.appIconId;
dockItemInfo.appLabelId = typeof (appData) === 'undefined' ? dockItemInfo.appLabelId : appData.appLabelId;
dockItemInfo.installTime = typeof (appData) === 'undefined' ? dockItemInfo.installTime : appData.installTime;
residentList.push(dockItemInfo);
} else if (dockDataList[i].itemType == CommonConstants.TYPE_CARD) {
} else {
const dockItemInfo = new DockItemInfo();
dockItemInfo.itemType = dockDataList[i].itemType;
dockItemInfo.editable = dockDataList[i].editable;
dockItemInfo.bundleName = dockDataList[i].bundleName;
dockItemInfo.abilityName = dockDataList[i].abilityName;
dockItemInfo.appIconId = typeof (dockDataList[i].appIconId) != 'undefined' ? dockDataList[i].appIconId : dockDataList[i].iconId.id;
dockItemInfo.appLabelId = typeof (dockDataList[i].appLabelId) != 'undefined' ? dockDataList[i].appLabelId : dockDataList[i].labelId.id;
const loadAppName = await this.mResourceManager
.getAppNameSync(dockItemInfo.appLabelId, dockItemInfo.bundleName, '');
dockItemInfo.appName = loadAppName;
residentList.push(dockItemInfo);
}
const dockItemInfo = new DockItemInfo();
dockItemInfo.itemType = dockDataList[i].itemType;
dockItemInfo.editable = dockDataList[i].editable;
dockItemInfo.appName = typeof (appData) === 'undefined' ? dockDataList[i].appName : appData.appName;
dockItemInfo.bundleName = typeof (appData) === 'undefined' ? dockDataList[i].bundleName : appData.bundleName;
dockItemInfo.abilityName = typeof (appData) === 'undefined' ? dockItemInfo.abilityName : appData.abilityName;
dockItemInfo.appIconId = typeof (appData) === 'undefined' ? dockItemInfo.appIconId : appData.appIconId;
dockItemInfo.appLabelId = typeof (appData) === 'undefined' ? dockItemInfo.appLabelId : appData.appLabelId;
dockItemInfo.installTime = typeof (appData) === 'undefined' ? dockItemInfo.installTime : appData.installTime;
residentList.push(dockItemInfo);
} else if (dockDataList[i].itemType == CommonConstants.TYPE_CARD) {
} else {
const dockItemInfo = new DockItemInfo();
dockItemInfo.itemType = dockDataList[i].itemType;
dockItemInfo.editable = dockDataList[i].editable;
dockItemInfo.bundleName = dockDataList[i].bundleName;
dockItemInfo.abilityName = dockDataList[i].abilityName;
dockItemInfo.appIconId = typeof (dockDataList[i].appIconId) != 'undefined' ? dockDataList[i].appIconId : dockDataList[i].iconId.id;
dockItemInfo.appLabelId = typeof (dockDataList[i].appLabelId) != 'undefined' ? dockDataList[i].appLabelId : dockDataList[i].labelId.id;
const loadAppName = await this.mResourceManager
.getAppNameSync(dockItemInfo.appLabelId, dockItemInfo.bundleName, '');
dockItemInfo.appName = loadAppName;
residentList.push(dockItemInfo);
}
// update persistent data
globalThis.RdbStoreManagerInstance.insertIntoSmartdock(residentList);
} else {
residentList = rdbResidentList;
Log.showInfo(TAG, 'getResidentList from rdb!');
}
// update persistent data
this.mSmartDockLayoutConfig.updateDockLayoutInfo(residentList);
// trigger component update
AppStorage.SetOrCreate('residentList', residentList);
Log.showInfo(TAG, 'getResidentList end residentList.length:' + residentList.length);
Log.showInfo(TAG, `getResidentList end residentList.length: ${residentList.length}`);
}
/**
* get recent dock list
*/
async getRecentDataList() {
async getRecentDataList(): Promise<void> {
Log.showInfo(TAG, 'getRecentDataList start!');
const recentList = await amsMissionManager.getRecentBundleMissionsList();
if (CheckEmptyUtils.isEmptyArr(recentList)) {
@ -151,7 +164,7 @@ export default class SmartDockModel {
}
AppStorage.SetOrCreate('recentList', recents);
AppStorage.SetOrCreate('missionInfoList', missionInfos);
Log.showInfo(TAG, 'getRecentDataList end, recentList.length:' + recents.length);
Log.showInfo(TAG, `getRecentDataList end, recentList.length: ${recents.length}`);
}
/**
@ -202,8 +215,8 @@ export default class SmartDockModel {
this.mResidentList.splice(index, 0, dockItemInfo);
}
AppStorage.SetOrCreate('residentList', this.mResidentList);
this.mSmartDockLayoutConfig.updateDockLayoutInfo(this.mResidentList);
Log.showInfo(TAG, 'addToSmartdock appInfo:' + appInfo.bundleName);
globalThis.RdbStoreManagerInstance.insertIntoSmartdock(this.mResidentList);
Log.showInfo(TAG, `addToSmartdock appInfo: ${appInfo.bundleName}`);
return true;
}
return false;
@ -215,7 +228,7 @@ export default class SmartDockModel {
* @return true: over max
* @return false: editable
*/
private checkDockNum(dockItemCount: number): boolean{
private checkDockNum(dockItemCount: number): boolean {
if (dockItemCount >= this.mSmartDockStyleConfig.mMaxDockNum) {
Prompt.showToast({
message: $r('app.string.no_space_for_add')
@ -232,7 +245,7 @@ export default class SmartDockModel {
* @return true: not exit, editable
* @return false: exited
*/
private idDuplicate(list: AppItemInfo[], appInfo: AppItemInfo): boolean{
private idDuplicate(list: AppItemInfo[], appInfo: AppItemInfo): boolean {
for (let i = 0; i < list.length; i++) {
if (list[i].bundleName === appInfo.bundleName) {
Prompt.showToast({
@ -248,7 +261,7 @@ export default class SmartDockModel {
* send requset to add appItem to pageDesktop
* @param appInfo
*/
addToPageDesk(appInfo: DockItemInfo) {
addToPageDesk(appInfo: DockItemInfo): void {
if (appInfo.itemType == CommonConstants.TYPE_APP) {
localEventManager.sendLocalEventSticky(EventConstants.EVENT_REQUEST_PAGEDESK_ITEM_ADD, appInfo).then(()=>{}, ()=>{});
} else {
@ -263,7 +276,7 @@ export default class SmartDockModel {
* @param insertIndex
* @param itemIndex
*/
inserItemToIndex(insertIndex: number, itemIndex: number) {
inserItemToIndex(insertIndex: number, itemIndex: number): void {
if ((insertIndex == 0 || insertIndex == 1 || itemIndex == 0 || itemIndex == 1) && this.mDevice === CommonConstants.PAD_DEVICE_TYPE) {
Prompt.showToast({
message: $r('app.string.disable_to_move')
@ -288,14 +301,14 @@ export default class SmartDockModel {
}
AppStorage.SetOrCreate('residentList', this.mResidentList);
this.mSmartDockLayoutConfig.updateDockLayoutInfo(this.mResidentList);
globalThis.RdbStoreManagerInstance.insertIntoSmartdock(this.mResidentList);
}
/**
* register residentList dock ADD ITEM Listener
* local listener for model to model send and receive msg
*/
registerDockListener() {
registerDockListener(): void {
localEventManager.registerEventListener(this.mAddToDockListener, [
EventConstants.EVENT_REQUEST_DOCK_ITEM_ADD,
EventConstants.EVENT_REQUEST_RESIDENT_DOCK_ITEM_DELETE,
@ -308,7 +321,7 @@ export default class SmartDockModel {
/**
* unregister residentList dock ADD ITEM Listener
*/
unregisterDockListener() {
unregisterDockListener(): void {
localEventManager.unregisterEventListener(this.mAddToDockListener);
Log.showInfo(TAG, 'local listener on destroy');
}
@ -318,7 +331,7 @@ export default class SmartDockModel {
*/
private readonly mAddToDockListener = {
onReceiveEvent: (event: string, params: any) => {
Log.showInfo(TAG, 'receive event: ' + event + ', params: ' + JSON.stringify(params));
Log.showInfo(TAG, `receive event: ${event}, params: ${JSON.stringify(params)}`);
if (event === EventConstants.EVENT_REQUEST_DOCK_ITEM_ADD) {
this.addToSmartdock(params);
} else if (event === EventConstants.EVENT_REQUEST_RESIDENT_DOCK_ITEM_DELETE) {
@ -331,7 +344,7 @@ export default class SmartDockModel {
}
};
private registerMissionListener() {
private registerMissionListener(): void {
Log.showInfo(TAG, 'registerMissionListener');
const listener = {
onMissionCreated: this.onMissionCreatedCallback.bind(this),
@ -343,22 +356,22 @@ export default class SmartDockModel {
}
onMissionCreatedCallback(missionId: number) {
onMissionCreatedCallback(missionId: number): void {
Log.showInfo(TAG, 'onMissionCreatedCallback, missionId=' + missionId);
this.getRecentDataList().then(() => {}, () => {});
}
onMissionDestroyedCallback(missionId: number) {
onMissionDestroyedCallback(missionId: number): void {
Log.showInfo(TAG, 'onMissionDestroyedCallback, missionId=' + missionId);
this.getRecentDataList().then(() => {}, ( )=> {});
}
onMissionSnapshotChangedCallback(missionId: number) {
onMissionSnapshotChangedCallback(missionId: number): void {
Log.showInfo(TAG, 'onMissionSnapshotChangedCallback, missionId=' + missionId);
this.getRecentDataList().then(() => {}, () => {});
}
onMissionMovedToFrontCallback(missionId: number) {
onMissionMovedToFrontCallback(missionId: number): void {
Log.showInfo(TAG, 'onMissionMovedToFrontCallback, missionId=' + missionId);
this.getRecentDataList().then(() => {}, () => { });
}
@ -367,7 +380,7 @@ export default class SmartDockModel {
* bundleName获取shortcutInfo
* @param bundleName
*/
getShortcutInfo(bundleName: string) {
getShortcutInfo(bundleName: string): any {
return this.mAppModel.getShortcutInfo(bundleName);
}
@ -376,11 +389,11 @@ export default class SmartDockModel {
*
* @return cache
*/
getAppName(cacheKey: string) {
getAppName(cacheKey: string): string {
return this.mResourceManager.getAppResourceCache(cacheKey, KEY_NAME);
}
async getSnapshot(missionIds: MissionInfo[], name: string) {
async getSnapshot(missionIds: MissionInfo[], name: string): Promise<any> {
const snapshotList: {
name: string,
image: any,
@ -417,7 +430,7 @@ export default class SmartDockModel {
return snapshotList;
}
private deleteResistDockItem(bundleName: string) {
private deleteResistDockItem(bundleName: string): boolean {
let res = false;
this.mResidentList = AppStorage.Get('residentList');
if (!CheckEmptyUtils.isEmptyArr(this.mResidentList)) {
@ -431,7 +444,7 @@ export default class SmartDockModel {
} else {
this.mResidentList.splice(i, 1);
AppStorage.SetOrCreate('residentList', this.mResidentList);
this.mSmartDockLayoutConfig.updateDockLayoutInfo(this.mResidentList);
globalThis.RdbStoreManagerInstance.insertIntoSmartdock(this.mResidentList);
Log.showInfo(TAG, `deleteRecentDockItem resist dockItem: ${bundleName}`);
res = true;
return res;
@ -442,7 +455,7 @@ export default class SmartDockModel {
return res;
}
private deleteRecentDockItem(bundleName: string) {
private deleteRecentDockItem(bundleName: string): boolean {
let res = false;
this.mRecentDataList = AppStorage.Get('recentList');
if (!CheckEmptyUtils.isEmptyArr(this.mResidentList)) {
@ -459,7 +472,7 @@ export default class SmartDockModel {
return res;
}
updateResistDockItem(appInfo: AppItemInfo){
updateResistDockItem(appInfo: AppItemInfo): void{
Log.showInfo(TAG, `updateResistDockItem appInfo: ${JSON.stringify(appInfo)}`);
let resistDockItem: DockItemInfo[] = AppStorage.Get('residentList');
if (!CheckEmptyUtils.isEmptyArr(resistDockItem)) {

View File

@ -100,7 +100,7 @@ export default class SmartDockViewModel extends BaseAppPresenter {
public recentOnClick(event, item, callback?) {
let missionInfoList = [];
missionInfoList = AppStorage.Get('missionInfoList');
Log.showInfo(TAG, 'recentOnClick missionInfoList.length:' + missionInfoList.length);
Log.showInfo(TAG, `recentOnClick missionInfoList.length: ${missionInfoList.length}`);
if (!CheckEmptyUtils.isEmptyArr(missionInfoList)) {
for (let i = 0; i < missionInfoList.length; i++) {
if (missionInfoList[i].bundleName === item.bundleName) {
@ -217,10 +217,10 @@ export default class SmartDockViewModel extends BaseAppPresenter {
removeMenu.menuImgSrc = this.mDevice === CommonConstants.PAD_DEVICE_TYPE ? '/common/pics/ic_public_remove.svg' : '/common/pics/ic_public_delete.svg';
removeMenu.menuText = this.mDevice === CommonConstants.PAD_DEVICE_TYPE ? $r('app.string.delete_app') : $r('app.string.uninstall');
removeMenu.onMenuClick = () => {
Log.showInfo(TAG, 'onMenuClick item remove:' + JSON.stringify(appInfo) + ',dockType:' + dockType);
Log.showInfo(TAG, `onMenuClick item remove: ${JSON.stringify(appInfo)},dockType: ${dockType}`);
const cacheKey = appInfo.appLabelId + appInfo.bundleName;
const appName = this.mSmartDockModel.getAppName(cacheKey);
Log.showInfo(TAG, 'onMenuClick item remove appName:' + appName);
Log.showInfo(TAG, `onMenuClick item remove appName: ${appName}`);
if (appName != null) {
appInfo.appName = appName;
}
@ -239,12 +239,12 @@ export default class SmartDockViewModel extends BaseAppPresenter {
}
getSelectedItem(): any {
Log.showInfo(TAG, 'getSelectedItem:' + JSON.stringify(this.mSelectedItem));
Log.showInfo(TAG, `getSelectedItem: ${JSON.stringify(this.mSelectedItem)}`);
return this.mSelectedItem;
}
getSelectedDockType(): any {
Log.showInfo(TAG, 'getSelectedDockType:' + JSON.stringify(this.mSelectedDockType));
Log.showInfo(TAG, `getSelectedDockType: ${JSON.stringify(this.mSelectedDockType)}`);
return this.mSelectedDockType;
}

View File

@ -14,9 +14,12 @@
*/
import AbilityStage from '@ohos.application.AbilityStage';
import Log from '../../../../../../common/src/main/ets/default/utils/Log';
const TAG = 'Launcher MyAbilityStage';
export default class MyAbilityStage extends AbilityStage {
onCreate(): void {
console.log('MyAbilityStage onCreate is called');
Log.showInfo(TAG, 'onCreate is called');
}
}

View File

@ -16,6 +16,7 @@
import ServiceExtension from '@ohos.application.ServiceExtensionAbility';
import display from '@ohos.display';
import Want from '@ohos.application.Want';
import RdbStoreManager from '../../../../../../common/src/main/ets/default/manager/RdbStoreManager';
import windowManager from '../../../../../../common/src/main/ets/default/manager/WindowManager';
import Log from '../../../../../../common/src/main/ets/default/utils/Log';
import GestureNavigationManage from '../../../../../../feature/gesturenavigation/src/main/ets/default/common/GestureNavigationManage';
@ -26,18 +27,35 @@ const TAG = 'LauncherMainAbility';
export default class MainAbility extends ServiceExtension {
onCreate(want: Want): void {
Log.showInfo(TAG,'onCreate start');
this.initLauncher();
}
async initLauncher(): Promise<void> {
// init Launcehr context
globalThis.desktopContext = this.context;
// init global const
this.initGlobalConst();
windowManager.createWindow(this.context, windowManager.DESKTOP_WINDOW_NAME,
// init Gesture navigation
this.startGestureNavigation();
// init rdb
let dbStore = RdbStoreManager.getInstance();
await dbStore.initRdbConfig();
await dbStore.createTable();
// create Launcher entry view
windowManager.createWindow(globalThis.desktopContext, windowManager.DESKTOP_WINDOW_NAME,
windowManager.DESKTOP_RANK, 'pages/EntryView');
}
private initGlobalConst(): void {
globalThis.desktopContext = this.context;
// init create window global function
globalThis.createWindowWithName = ((windowName: string, windowRank: number) => {
Log.showInfo(TAG, 'createWindowWithName Begin' + windowName);
windowManager.createWindowIfAbsent(this.context, windowName, windowRank, 'pages/' + windowName);
Log.showInfo(TAG, `createWindowWithName begin windowName: ${windowName}`);
windowManager.createWindowIfAbsent(globalThis.desktopContext, windowName, windowRank, 'pages/' + windowName);
});
this.startGestureNavigation();
}
private startGestureNavigation(): void {

View File

@ -40,10 +40,10 @@ class RecentEvent {
}
private createRecentCallBack(error: BusinessError, data: CommonEventData): void {
Log.showInfo(TAG, `createRecentCallBack error: ${JSON.stringify(error)} data: ${JSON.stringify(data)}`);
Log.showInfo(TAG, `createRecentCallBack error: ${JSON.stringify(error)}, data: ${JSON.stringify(data)}`);
commonEventSubscriber = data;
commonEvent.subscribe(data, (error, data) => {
Log.showInfo(TAG, `subscribe error: ${JSON.stringify(error)} data: ${JSON.stringify(data)}`);
Log.showInfo(TAG, `subscribe error: ${JSON.stringify(error)}, data: ${JSON.stringify(data)}`);
if (error.code == 0) {
this.mCallback.onStateChange();
} else {

View File

@ -58,10 +58,6 @@ struct EntryView {
this.getWindowSize();
this.updateScreenSize();
// init database
let dbStore = RdbStoreManager.getInstance();
dbStore.initRdbConfig();
// register recentEvent callback
let mCallback: Record<string, () => void> = {'onStateChange': () => this.createRecent()};
RecentEvent.registerCallback(mCallback);

View File

@ -14,9 +14,12 @@
*/
import AbilityStage from '@ohos.application.AbilityStage';
import Log from '../../../../../../common/src/main/ets/default/utils/Log';
const TAG = 'Launcher MyAbilityStage';
export default class MyAbilityStage extends AbilityStage {
onCreate(): void {
console.log('MyAbilityStage onCreate is called');
Log.showInfo(TAG, 'onCreate is called');
}
}

View File

@ -16,6 +16,7 @@
import ServiceExtension from '@ohos.application.ServiceExtensionAbility';
import display from '@ohos.display';
import Want from '@ohos.application.Want';
import RdbStoreManager from '../../../../../../common/src/main/ets/default/manager/RdbStoreManager';
import windowManager from '../../../../../../common/src/main/ets/default/manager/WindowManager';
import Log from '../../../../../../common/src/main/ets/default/utils/Log';
import GestureNavigationManage from '../../../../../../feature/gesturenavigation/src/main/ets/default/common/GestureNavigationManage';
@ -25,18 +26,35 @@ const TAG = 'LauncherMainAbility';
export default class MainAbility extends ServiceExtension {
onCreate(want: Want): void {
Log.showInfo(TAG,'onCreate start');
this.initLauncher();
}
async initLauncher(): Promise<void> {
// init Launcehr context
globalThis.desktopContext = this.context;
// init global const
this.initGlobalConst();
windowManager.createWindow(this.context, windowManager.DESKTOP_WINDOW_NAME,
// init Gesture navigation
this.startGestureNavigation();
// init rdb
let dbStore = RdbStoreManager.getInstance();
await dbStore.initRdbConfig();
await dbStore.createTable();
// create Launcher entry view
windowManager.createWindow(globalThis.desktopContext, windowManager.DESKTOP_WINDOW_NAME,
windowManager.DESKTOP_RANK, 'pages/EntryView');
}
private initGlobalConst(): void {
globalThis.desktopContext = this.context;
// init create window global function
globalThis.createWindowWithName = ((windowName: string, windowRank: number) => {
Log.showInfo(TAG, 'createWindowWithName Begin');
windowManager.createWindowIfAbsent(this.context, windowName, windowRank, 'pages/' + windowName);
Log.showInfo(TAG, `createWindowWithName begin windowName: ${windowName}`);
windowManager.createWindowIfAbsent(globalThis.desktopContext, windowName, windowRank, 'pages/' + windowName);
});
this.startGestureNavigation();
}
private startGestureNavigation(): void {

View File

@ -39,10 +39,10 @@ class RecentEvent {
}
private createRecentCallBack(error: BusinessError, data: CommonEventData): void {
Log.showInfo(TAG, `createRecentCallBack error: ${JSON.stringify(error)} data: ${JSON.stringify(data)}`);
Log.showInfo(TAG, `createRecentCallBack error: ${JSON.stringify(error)}, data: ${JSON.stringify(data)}`);
commonEventSubscriber = data;
commonEvent.subscribe(data, (error, data) => {
Log.showInfo(TAG, `subscribe error: ${JSON.stringify(error)} data: ${JSON.stringify(data)}`);
Log.showInfo(TAG, `subscribe error: ${JSON.stringify(error)}, data: ${JSON.stringify(data)}`);
if (error.code == 0) {
this.mCallback.onStateChange();
} else {

View File

@ -68,10 +68,6 @@ struct EntryView {
this.getWindowSize();
this.updateScreenSize();
// init database
let dbStore = RdbStoreManager.getInstance();
dbStore.initRdbConfig();
// register recentEvent callback
let mCallback: Record<string, () => void> = {'onStateChange': () => this.createRecent()};
RecentEvent.registerCallback(mCallback);