mirror of
https://gitee.com/openharmony/applications_launcher
synced 2024-11-27 09:00:31 +00:00
commit
59cb31b89a
18
feature/appcenter/build.gradle
Normal file
18
feature/appcenter/build.gradle
Normal file
@ -0,0 +1,18 @@
|
||||
apply plugin: 'com.huawei.ohos.library'
|
||||
//For instructions on signature configuration, see https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ide_debug_device-0000001053822404#section1112183053510
|
||||
ohos {
|
||||
compileSdkVersion 8
|
||||
defaultConfig {
|
||||
compatibleSdkVersion 8
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
proguardOpt {
|
||||
proguardEnabled false
|
||||
rulesFiles 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
dependencies {
|
||||
}
|
22
feature/appcenter/src/main/config.json
Normal file
22
feature/appcenter/src/main/config.json
Normal file
@ -0,0 +1,22 @@
|
||||
{
|
||||
"app": {
|
||||
"bundleName": "com.ohos.launcher",
|
||||
"vendor": "ohos",
|
||||
"version": {
|
||||
"code": 1000000,
|
||||
"name": "1.0.0"
|
||||
}
|
||||
},
|
||||
"deviceConfig": {},
|
||||
"module": {
|
||||
"package": "com.ohos.launcher",
|
||||
"deviceType": [
|
||||
"phone"
|
||||
],
|
||||
"distro": {
|
||||
"deliveryWithInstall": true,
|
||||
"moduleName": "appcenter",
|
||||
"moduleType": "har"
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (c) 2021 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 CommonConstants from '../../../../../../../common/src/main/ets/default/constants/CommonConstants';
|
||||
import FeatureConstants from './constants/FeatureConstants';
|
||||
import AppGridStyleConfig from '../../../../../../../common/src/main/ets/default/layoutconfig/AppGridStyleConfig';
|
||||
import PresetStyleConstants from '../../../../../../../common/src/main/ets/default/constants/PresetStyleConstants';
|
||||
|
||||
/**
|
||||
* style config of AppCenter
|
||||
*/
|
||||
export default class AppCenterGridStyleConfig extends AppGridStyleConfig {
|
||||
|
||||
mPadding = PresetStyleConstants.DEFAULT_APP_CENTER_PADDING;
|
||||
|
||||
protected constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains the AppCenterGridStyleConfig instance.
|
||||
*
|
||||
* @return AppCenterGridStyleConfig
|
||||
*/
|
||||
static getInstance(): AppCenterGridStyleConfig {
|
||||
if (globalThis.AppCenterGridStyleConfigInstance == null) {
|
||||
globalThis.AppCenterGridStyleConfigInstance = new AppCenterGridStyleConfig();
|
||||
}
|
||||
return globalThis.AppCenterGridStyleConfigInstance;
|
||||
}
|
||||
|
||||
initConfig(): void {
|
||||
}
|
||||
|
||||
getConfigLevel(): string {
|
||||
return CommonConstants.LAYOUT_CONFIG_LEVEL_FEATURE;
|
||||
}
|
||||
|
||||
getFeatureName(): string {
|
||||
return FeatureConstants.FEATURE_NAME;
|
||||
}
|
||||
}
|
@ -0,0 +1,99 @@
|
||||
/*
|
||||
* Copyright (c) 2021 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 FeatureConstants from './constants/FeatureConstants';
|
||||
import StyleConstants from '../../../../../../../common/src/main/ets/default/constants/StyleConstants';
|
||||
import CommonConstants from '../../../../../../../common/src/main/ets/default/constants/CommonConstants';
|
||||
import AppListStyleConfig from '../../../../../../../common/src/main/ets/default/layoutconfig/AppListStyleConfig';
|
||||
|
||||
/**
|
||||
* 应用中心列表样式配置类
|
||||
*/
|
||||
export default class AppCenterListStyleConfig extends AppListStyleConfig {
|
||||
private static sFeatureInstance: AppCenterListStyleConfig = null;
|
||||
|
||||
/**
|
||||
* 列表条目宽度
|
||||
*/
|
||||
mListItemWidth: string | number = StyleConstants.PERCENTAGE_100;
|
||||
|
||||
/**
|
||||
* 列表条目高度
|
||||
*/
|
||||
mListItemHeight: string | number = StyleConstants.DEFAULT_80;
|
||||
|
||||
/**
|
||||
* 列表条目间距
|
||||
*/
|
||||
mListItemGap = 12;
|
||||
|
||||
/**
|
||||
* 列表名称是否展示在旁边
|
||||
*/
|
||||
mNameDisplaySide = true;
|
||||
|
||||
/**
|
||||
* 列表图标大小
|
||||
*/
|
||||
mIconSize: number = StyleConstants.DEFAULT_APP_ITEM_WIDTH;
|
||||
|
||||
/**
|
||||
* 列表名称大小
|
||||
*/
|
||||
mNameSize: number = StyleConstants.DEFAULT_APP_NAME_SIZE;
|
||||
|
||||
/**
|
||||
* 列表图标和名称的间距
|
||||
*/
|
||||
mNameIconGap: number = StyleConstants.DEFAULT_NUMBER;
|
||||
|
||||
/**
|
||||
* 条目的内部边距
|
||||
*/
|
||||
mItemPadding = 8;
|
||||
|
||||
/**
|
||||
* 条目的背景色
|
||||
*/
|
||||
mItemBackgroundColor: string = StyleConstants.LIGHT_BLACK;
|
||||
|
||||
/**
|
||||
* 条目的圆角值
|
||||
*/
|
||||
mItemBorderRadius: number = StyleConstants.DEFAULT_20;
|
||||
|
||||
protected constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取应用中心列表样式实例
|
||||
*/
|
||||
static getInstance(): AppCenterListStyleConfig {
|
||||
if (AppCenterListStyleConfig.sFeatureInstance == null) {
|
||||
AppCenterListStyleConfig.sFeatureInstance = new AppCenterListStyleConfig();
|
||||
AppCenterListStyleConfig.sFeatureInstance.initConfig();
|
||||
}
|
||||
return AppCenterListStyleConfig.sFeatureInstance;
|
||||
}
|
||||
|
||||
getConfigLevel(): string {
|
||||
return CommonConstants.LAYOUT_CONFIG_LEVEL_FEATURE;
|
||||
}
|
||||
|
||||
getFeatureName(): string {
|
||||
return FeatureConstants.FEATURE_NAME;
|
||||
}
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (c) 2021 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 BaseModulePreLoader from '../../../../../../../common/src/main/ets/default/base/BaseModulePreLoader';
|
||||
import LayoutConfigManager from '../../../../../../../common/src/main/ets/default/layoutconfig/LayoutConfigManager';
|
||||
import AppCenterListStyleConfig from './AppCenterListStyleConfig';
|
||||
import AppCenterGridStyleConfig from './AppCenterGridStyleConfig';
|
||||
|
||||
/**
|
||||
* 公共层初始化加载器
|
||||
*/
|
||||
class AppCenterPreLoader extends BaseModulePreLoader {
|
||||
protected loadConfig(): void {
|
||||
LayoutConfigManager.addConfigToManager(AppCenterListStyleConfig.getInstance());
|
||||
LayoutConfigManager.addConfigToManager(AppCenterGridStyleConfig.getInstance());
|
||||
}
|
||||
|
||||
protected loadData(): void {
|
||||
}
|
||||
|
||||
releaseConfigAndData(): void {
|
||||
LayoutConfigManager.removeConfigFromManager();
|
||||
}
|
||||
}
|
||||
|
||||
const appCenterPreLoader: BaseModulePreLoader = new AppCenterPreLoader();
|
||||
export default appCenterPreLoader;
|
@ -0,0 +1,18 @@
|
||||
/*
|
||||
* Copyright (c) 2021 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.
|
||||
*/
|
||||
|
||||
export default class FeatureConstants {
|
||||
static readonly FEATURE_NAME = 'featureAppCenter';
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 1.2 MiB |
@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (c) 2021 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 { ShortcutInfo } from 'bundle/shortcutInfo';
|
||||
import AppListPresenter from './AppListPresenter';
|
||||
|
||||
/**
|
||||
* AppGridPresenter
|
||||
*/
|
||||
export default class AppGridPresenter extends AppListPresenter {
|
||||
private static sAppGridPresenter: AppGridPresenter = null;
|
||||
|
||||
private constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取实例
|
||||
*/
|
||||
static getInstance(): AppGridPresenter {
|
||||
if (AppGridPresenter.sAppGridPresenter == null) {
|
||||
AppGridPresenter.sAppGridPresenter = new AppGridPresenter();
|
||||
}
|
||||
return AppGridPresenter.sAppGridPresenter;
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册监听事件
|
||||
*/
|
||||
registerAppListChange() {
|
||||
this.registerAppListChangeCallback();
|
||||
this.mAppModel.registerAppListEvent();
|
||||
}
|
||||
|
||||
/**
|
||||
* 反注册监听事件
|
||||
*/
|
||||
unregisterAppListChange() {
|
||||
this.unregisterAppListChangeCallback();
|
||||
this.mAppModel.unregisterAppListEvent();
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过bundleName获取shortcut信息
|
||||
*/
|
||||
getShortcutInfo(bundleName: string): ShortcutInfo[] | undefined {
|
||||
return this.mAppModel.getShortcutInfo(bundleName);
|
||||
}
|
||||
}
|
@ -0,0 +1,138 @@
|
||||
/*
|
||||
* Copyright (c) 2021 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 Prompt from '@ohos.prompt';
|
||||
import BaseAppPresenter from '../../../../../../../../common/src/main/ets/default/base/BaseAppPresenter';
|
||||
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';
|
||||
|
||||
const KEY_APP_LIST = "appListInfo";
|
||||
const KEY_NAME = "name";
|
||||
|
||||
export default class AppListPresenter extends BaseAppPresenter {
|
||||
private static sAppListPresenter: AppListPresenter = null;
|
||||
private mPinyinSort: PinyinSort;
|
||||
|
||||
protected constructor() {
|
||||
super();
|
||||
this.mPinyinSort = new PinyinSort();
|
||||
}
|
||||
|
||||
public static getInstance(): AppListPresenter {
|
||||
if (AppListPresenter.sAppListPresenter == null) {
|
||||
AppListPresenter.sAppListPresenter = new AppListPresenter();
|
||||
}
|
||||
return AppListPresenter.sAppListPresenter;
|
||||
}
|
||||
|
||||
public async getAppList() {
|
||||
let list: Array<AppItemInfo> | number = this.mAppListInfoCacheManager.getCache(KEY_APP_LIST);
|
||||
if (list != CommonConstants.INVALID_VALUE) {
|
||||
return list;
|
||||
}
|
||||
|
||||
list = await this.mAppModel.getAppList();
|
||||
for (let item of list) {
|
||||
let cacheKey = item.appLabelId + item.bundleName;
|
||||
let appName = this.mResourceManager.getAppResourceCache(cacheKey, KEY_NAME);
|
||||
if (appName != null) {
|
||||
item.appName = appName;
|
||||
} else {
|
||||
let loadAppName = await this.mResourceManager.getAppNameSync(item.appLabelId, item.bundleName, item.appName);
|
||||
console.info("Launcher AppListPresenter getAppList loadAppName:" + loadAppName);
|
||||
item.appName = loadAppName;
|
||||
}
|
||||
}
|
||||
|
||||
list.sort(this.mPinyinSort.sortByAppName.bind(this.mPinyinSort));
|
||||
this.mAppListInfoCacheManager.setCache(KEY_APP_LIST, list);
|
||||
animateTo({
|
||||
duration: 200,
|
||||
curve: Curve.EaseInOut,
|
||||
delay: 100,
|
||||
playMode: PlayMode.Normal,
|
||||
tempo: 0.5,
|
||||
iterations: 1,
|
||||
onFinish: () => {
|
||||
}
|
||||
}, () => {
|
||||
AppStorage.SetOrCreate('listInfo', list);
|
||||
})
|
||||
return list;
|
||||
}
|
||||
|
||||
public async regroupDataAppListChange(callbackList) {
|
||||
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);
|
||||
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);
|
||||
item.appName = loadAppName;
|
||||
}
|
||||
}
|
||||
callbackList.sort(this.mPinyinSort.sortByAppName.bind(this.mPinyinSort));
|
||||
this.mAppListInfoCacheManager.setCache(KEY_APP_LIST, callbackList);
|
||||
animateTo({
|
||||
duration: 200,
|
||||
curve: Curve.EaseInOut,
|
||||
delay: 100,
|
||||
playMode: PlayMode.Normal,
|
||||
tempo: 0.5,
|
||||
iterations: 1,
|
||||
onFinish: () => {
|
||||
}
|
||||
}, () => {
|
||||
AppStorage.SetOrCreate('listInfo', callbackList);
|
||||
})
|
||||
}
|
||||
|
||||
public informUninstallResult(resultCode) {
|
||||
console.info("Launcher AppListView getUninstallApp uninstallationResult:" + resultCode);
|
||||
if (resultCode === CommonConstants.UNINSTALL_FORBID) {
|
||||
Prompt.showToast({
|
||||
message: $r("app.string.disable_uninstall")
|
||||
});
|
||||
} else if (resultCode === CommonConstants.UNINSTALL_SUCCESS) {
|
||||
Prompt.showToast({
|
||||
message: $r("app.string.uninstall_success")
|
||||
});
|
||||
} else {
|
||||
Prompt.showToast({
|
||||
message: $r("app.string.uninstall_failed")
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public intoSetting() {
|
||||
console.info("Launcher AppListView intoSetting");
|
||||
this.jumpToSetting();
|
||||
}
|
||||
|
||||
/**
|
||||
* Open application function.
|
||||
*
|
||||
* @param {string} abilityName - ability name of the application to be jump to.
|
||||
* @param {string} bundleName - bundle name of the application to be jump to.
|
||||
*/
|
||||
public openApplication(abilityName, bundleName) {
|
||||
console.info("Launcher AppListView openApplication abilityName:" + abilityName);
|
||||
this.jumpTo(abilityName, bundleName);
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* 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 AppGridStyleConfig from '../../../../../../../../common/src/main/ets/default/layoutconfig/AppGridStyleConfig';
|
||||
import AppCenterGridStyleConfig from '../AppCenterGridStyleConfig';
|
||||
import LayoutConfigManager from '../../../../../../../../common/src/main/ets/default/layoutconfig/LayoutConfigManager';
|
||||
import FeatureConstants from '../constants/FeatureConstants';
|
||||
|
||||
export default class AppCenterViewModel {
|
||||
private mAppGridStyleConfig: AppCenterGridStyleConfig;
|
||||
|
||||
private constructor() {
|
||||
this.mAppGridStyleConfig = LayoutConfigManager.getStyleConfig(AppCenterGridStyleConfig.APP_GRID_STYLE_CONFIG, FeatureConstants.FEATURE_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains the AppCenterViewModel instance.
|
||||
*
|
||||
* @return AppCenterViewModel
|
||||
*/
|
||||
public static getInstance(): AppCenterViewModel {
|
||||
if (globalThis.AppCenterViewModelInstance == null) {
|
||||
globalThis.AppCenterViewModelInstance = new AppCenterViewModel();
|
||||
}
|
||||
return globalThis.AppCenterViewModelInstance;
|
||||
}
|
||||
|
||||
public getAppGridStyleConfig(): AppCenterGridStyleConfig {
|
||||
return this.mAppGridStyleConfig;
|
||||
}
|
||||
}
|
164
feature/appcenter/src/main/ets/default/layout/AppGridLayout.ets
Normal file
164
feature/appcenter/src/main/ets/default/layout/AppGridLayout.ets
Normal file
@ -0,0 +1,164 @@
|
||||
/*
|
||||
* Copyright (c) 2021 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 LayoutConfigManager from '../../../../../../../common/src/main/ets/default/layoutconfig/LayoutConfigManager';
|
||||
import StyleConstants from '../../../../../../../common/src/main/ets/default/constants/StyleConstants';
|
||||
import MenuInfo from '../../../../../../../common/src/main/ets/default/bean/MenuInfo';
|
||||
import CommonConstants from '../../../../../../../common/src/main/ets/default/constants/CommonConstants';
|
||||
import AppGrid from '../../../../../../../common/src/main/ets/default/uicomponents/AppGrid.ets';
|
||||
import UninstallDialog from '../../../../../../../common/src/main/ets/default/uicomponents/UninstallDialog.ets';
|
||||
import AppGridPresenter from '../common/presenter/AppGridPresenter';
|
||||
import AppCenterGridStyleConfig from '../common/AppCenterGridStyleConfig';
|
||||
import FeatureConstants from '../common/constants/FeatureConstants';
|
||||
import localEventManager from '../../../../../../../common/src/main/ets/default/manager/LocalEventManager';
|
||||
import EventConstants from '../../../../../../../common/src/main/ets/default/constants/EventConstants';
|
||||
import Trace from '../../../../../../../common/src/main/ets/default/utils/Trace';
|
||||
import AppCenterViewModel from '../common/viewmodel/AppCenterViewModel.ets';
|
||||
|
||||
@Component
|
||||
export default struct AppGridLayout {
|
||||
@State mColumns: number = StyleConstants.DEFAULT_APP_GRID_COLUMN;
|
||||
@State mRows: number = StyleConstants.DEFAULT_APP_GRID_ROW;
|
||||
@StorageLink('listInfo') appGridList: [] = [];
|
||||
mAppGridPresenter: AppGridPresenter = null;
|
||||
mAppCenterGridStyleConfig: AppCenterGridStyleConfig = null;
|
||||
mSelectItem = null;
|
||||
mDialogController: CustomDialogController = new CustomDialogController({
|
||||
builder: UninstallDialog({
|
||||
cancel: () => {
|
||||
},
|
||||
confirm: () => {
|
||||
this.onAccept()
|
||||
},
|
||||
dialogName: $r('app.string.app_center_menu_uninstall'),
|
||||
dialogContent: this.mSelectItem.appName + ' ?',
|
||||
}),
|
||||
cancel: () => {
|
||||
},
|
||||
autoCancel: true,
|
||||
customStyle: true
|
||||
});
|
||||
|
||||
onAccept() {
|
||||
if (this.mSelectItem == null) {
|
||||
return;
|
||||
}
|
||||
this.mAppGridPresenter.uninstallApp(this.mSelectItem.bundleName, this.mSelectItem.isUninstallAble);
|
||||
this.mDialogController.close();
|
||||
}
|
||||
|
||||
private aboutToDisappear(): void {
|
||||
this.mAppGridPresenter.unregisterAppListChange();
|
||||
}
|
||||
|
||||
private aboutToAppear(): void {
|
||||
this.mAppGridPresenter = AppGridPresenter.getInstance();
|
||||
this.mAppGridPresenter.getAppList();
|
||||
this.mAppGridPresenter.registerAppListChange()
|
||||
this.mAppCenterGridStyleConfig = AppCenterViewModel.getInstance().getAppGridStyleConfig();
|
||||
}
|
||||
|
||||
public buildMenuInfoList(appInfo) {
|
||||
let menuInfoList = new Array<MenuInfo>();
|
||||
let shortcutInfo = this.mAppGridPresenter.getShortcutInfo(appInfo.bundleName);
|
||||
if (shortcutInfo) {
|
||||
let Menu = null;
|
||||
shortcutInfo.forEach((value) => {
|
||||
Menu = new MenuInfo();
|
||||
Menu.menuType = CommonConstants.MENU_TYPE_DYNAMIC;
|
||||
Menu.menuImgSrc = value.icon;
|
||||
Menu.menuText = value.label;
|
||||
Menu.shortcutIconId = value.iconId;
|
||||
Menu.shortcutLabelId = value.labelId;
|
||||
Menu.bundleName = value.bundleName;
|
||||
Menu.onMenuClick = () => {
|
||||
this.mAppGridPresenter.jumpTo(value.wants[0].targetClass, value.wants[0].targetBundle);
|
||||
};
|
||||
menuInfoList.push(Menu);
|
||||
});
|
||||
}
|
||||
let addToDockMenu = new MenuInfo();
|
||||
addToDockMenu.menuType = CommonConstants.MENU_TYPE_FIXED;
|
||||
addToDockMenu.menuImgSrc = "/common/pics/ic_public_copy.svg";
|
||||
addToDockMenu.menuText = $r('app.string.app_center_menu_add_dock');
|
||||
addToDockMenu.onMenuClick = () => {
|
||||
console.info("Launcher click menu item add to smartDock entry");
|
||||
localEventManager.sendLocalEventSticky(EventConstants.EVENT_REQUEST_DOCK_ITEM_ADD, appInfo);
|
||||
};
|
||||
menuInfoList.push(addToDockMenu);
|
||||
|
||||
let addToDeskMenu = new MenuInfo();
|
||||
addToDeskMenu.menuType = CommonConstants.MENU_TYPE_FIXED;
|
||||
addToDeskMenu.menuImgSrc = "/common/pics/ic_public_copy.svg";
|
||||
addToDeskMenu.menuText = $r('app.string.app_center_menu_add_desktop');
|
||||
addToDeskMenu.onMenuClick = () => {
|
||||
console.info("Launcher click menu item add to pageDesk entry");
|
||||
localEventManager.sendLocalEventSticky(EventConstants.EVENT_REQUEST_PAGEDESK_ITEM_ADD, appInfo);
|
||||
};
|
||||
menuInfoList.push(addToDeskMenu);
|
||||
|
||||
let uninstallMenu = new MenuInfo();
|
||||
uninstallMenu.menuType = CommonConstants.MENU_TYPE_FIXED;
|
||||
uninstallMenu.menuImgSrc = "/common/pics/ic_public_delete.svg";
|
||||
uninstallMenu.menuText = $r('app.string.uninstall');
|
||||
uninstallMenu.onMenuClick = () => {
|
||||
console.info("Launcher click menu item uninstall" + JSON.stringify(appInfo));
|
||||
let cacheKey = appInfo.appLabelId + appInfo.bundleName;
|
||||
let appName = this.mAppGridPresenter.getAppName(cacheKey);
|
||||
console.info("Launcher AppGridLayout buildMenuInfoList appName" + appName);
|
||||
if (appName != null) {
|
||||
appInfo.appName = appName;
|
||||
}
|
||||
this.mSelectItem = appInfo;
|
||||
this.mDialogController.open();
|
||||
};
|
||||
uninstallMenu.menuEnabled = appInfo.isUninstallAble;
|
||||
menuInfoList.push(uninstallMenu);
|
||||
return menuInfoList;
|
||||
}
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
Row() {
|
||||
AppGrid({
|
||||
appGridList: $appGridList,
|
||||
isScroll: true,
|
||||
appGridStyleConfig: this.mAppCenterGridStyleConfig,
|
||||
onItemClick: (event, item) => {
|
||||
this.mAppGridPresenter.jumpTo(item.abilityName, item.bundleName)
|
||||
},
|
||||
buildMenu: (item) => this.buildMenuInfoList(item)
|
||||
})
|
||||
}.width(this.mAppCenterGridStyleConfig.mGridWidth)
|
||||
.height(this.mAppCenterGridStyleConfig.mGridHeight)
|
||||
|
||||
Row() {
|
||||
|
||||
}.width(216)
|
||||
if (this.traceBuildEnd()) {}
|
||||
}
|
||||
.padding({
|
||||
top: this.mAppCenterGridStyleConfig.mPadding
|
||||
})
|
||||
.backgroundImageSize(ImageSize.Cover)
|
||||
.width(StyleConstants.PERCENTAGE_100)
|
||||
.height(StyleConstants.PERCENTAGE_100)
|
||||
}
|
||||
|
||||
private traceBuildEnd() {
|
||||
Trace.end(Trace.CORE_METHOD_START_APP_CENTER);
|
||||
return true;
|
||||
}
|
||||
}
|
140
feature/appcenter/src/main/ets/default/layout/AppListLayout.ets
Normal file
140
feature/appcenter/src/main/ets/default/layout/AppListLayout.ets
Normal file
@ -0,0 +1,140 @@
|
||||
/*
|
||||
* Copyright (c) 2021 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 LayoutConfigManager from '../../../../../../../common/src/main/ets/default/layoutconfig/LayoutConfigManager';
|
||||
import AppCenterListStyleConfig from '../common/AppCenterListStyleConfig';
|
||||
import AppListPresenter from '../common/presenter/AppListPresenter';
|
||||
import FeatureConstants from '../common/constants/FeatureConstants';
|
||||
import AppList from '../../../../../../../common/src/main/ets/default/uicomponents/AppList.ets';
|
||||
import StyleConstants from '../../../../../../../common/src/main/ets/default/constants/StyleConstants';
|
||||
import UninstallDialog from '../../../../../../../common/src/main/ets/default/uicomponents/UninstallDialog.ets';
|
||||
|
||||
let mAppListPresenter: AppListPresenter;
|
||||
|
||||
@Component
|
||||
export default struct ListLayout {
|
||||
@StorageLink('listInfo') appListInfo: [] = [];
|
||||
@StorageLink('uninstallAppInfo') appInfo: any = {};
|
||||
|
||||
mAppCenterListStyleConfig: AppCenterListStyleConfig = null;
|
||||
|
||||
private aboutToAppear(): void {
|
||||
mAppListPresenter = AppListPresenter.getInstance();
|
||||
mAppListPresenter.getAppList();
|
||||
mAppListPresenter.registerAppListChangeCallback();
|
||||
this.mAppCenterListStyleConfig = LayoutConfigManager.getStyleConfig(AppCenterListStyleConfig.APP_LIST_STYLE_CONFIG, FeatureConstants.FEATURE_NAME);
|
||||
}
|
||||
|
||||
dialogController: CustomDialogController = new CustomDialogController({
|
||||
builder: ShowDialog({ action: this.openUninstallDialog }),
|
||||
cancel: this.cancelDialog,
|
||||
autoCancel: true,
|
||||
customStyle: true
|
||||
});
|
||||
uninstallDialogController: CustomDialogController = new CustomDialogController({
|
||||
builder: UninstallDialog({
|
||||
cancel: () => {},
|
||||
confirm: () => {
|
||||
mAppListPresenter.uninstallApp(this.appInfo.bundleName, this.appInfo.isUninstallAble);
|
||||
},
|
||||
dialogName: $r('app.string.uninstall'),
|
||||
dialogContent: this.appInfo.appName + ' ?',
|
||||
}),
|
||||
cancel: this.cancelDialog,
|
||||
autoCancel: true,
|
||||
customStyle: true
|
||||
});
|
||||
|
||||
openUninstallDialog() {
|
||||
this.dialogController.close();
|
||||
this.uninstallDialogController.open();
|
||||
}
|
||||
|
||||
cancelDialog() {
|
||||
console.info('Launcher Grid Cancel Dialog');
|
||||
}
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
AppList({
|
||||
appList: $appListInfo,
|
||||
appListStyleConfig: this.mAppCenterListStyleConfig,
|
||||
onItemClick: (event, item) => {
|
||||
mAppListPresenter.openApplication(item.abilityName, item.bundleName);
|
||||
},
|
||||
onItemLongPress: (event, item) => {
|
||||
AppStorage.SetOrCreate('uninstallAppInfo', item);
|
||||
this.dialogController.open();
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@CustomDialog
|
||||
struct ShowDialog {
|
||||
@StorageLink('uninstallAppInfo') appInfo: any = {};
|
||||
controller: CustomDialogController;
|
||||
cancel: () => void;
|
||||
action: () => void;
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
Text($r('app.string.launcher_edit'))
|
||||
.fontSize(StyleConstants.DEFAULT_BADGE_FONT_SIZE)
|
||||
.fontColor(StyleConstants.TEXT_COLOR_PRIMARY)
|
||||
.margin({top : StyleConstants.DEFAULT_DIALOG_RADIUS, bottom: StyleConstants.DEFAULT_DIALOG_BOTTOM_MARGIN})
|
||||
|
||||
Flex({justifyContent: FlexAlign.SpaceEvenly}) {
|
||||
Button() {
|
||||
Text($r('app.string.into_settings'))
|
||||
.fontSize(StyleConstants.DEFAULT_BADGE_FONT_SIZE)
|
||||
.fontColor(StyleConstants.BUTTON_FONT_COLOR)
|
||||
}
|
||||
.backgroundColor(StyleConstants.DEFAULT_BG_COLOR)
|
||||
.height(StyleConstants.DEFAULT_BUTTON_HEIGHT)
|
||||
.onClick(() => {
|
||||
mAppListPresenter.intoSetting();
|
||||
this.controller.close();
|
||||
})
|
||||
|
||||
Divider()
|
||||
.vertical(true)
|
||||
.color(StyleConstants.DEFAULT_DIVIDER_COLOR)
|
||||
.height(StyleConstants.DEFAULT_BUTTON_HEIGHT)
|
||||
|
||||
Button() {
|
||||
Text($r('app.string.uninstall'))
|
||||
.fontSize(StyleConstants.DEFAULT_BADGE_FONT_SIZE)
|
||||
.fontColor(StyleConstants.DEFAULT_COLOR_ERROR)
|
||||
}
|
||||
.backgroundColor(StyleConstants.DEFAULT_BG_COLOR)
|
||||
.height(StyleConstants.DEFAULT_BUTTON_HEIGHT)
|
||||
.onClick(() => {
|
||||
mAppListPresenter.uninstallApp(this.appInfo.bundleName, this.appInfo.isUninstallAble);
|
||||
this.controller.close();
|
||||
})
|
||||
}
|
||||
}
|
||||
.backgroundColor(Color.White)
|
||||
.padding({
|
||||
bottom: StyleConstants.DEFAULT_DIALOG_BOTTOM_MARGIN
|
||||
})
|
||||
.border({
|
||||
radius: StyleConstants.DEFAULT_DIALOG_RADIUS
|
||||
})
|
||||
.width(StyleConstants.DEFAULT_DIALOG_WIDTH)
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
{
|
||||
"string": [
|
||||
{
|
||||
"name": "uninstall_success",
|
||||
"value": "卸载成功"
|
||||
},
|
||||
{
|
||||
"name": "uninstall_failed",
|
||||
"value": "卸载失败"
|
||||
},
|
||||
{
|
||||
"name": "disable_uninstall",
|
||||
"value": "禁止卸载"
|
||||
},
|
||||
{
|
||||
"name": "app_center_menu_add_dock",
|
||||
"value": "添加到快捷栏"
|
||||
},
|
||||
{
|
||||
"name": "app_center_menu_uninstall",
|
||||
"value": "卸载"
|
||||
}
|
||||
]
|
||||
}
|
18
feature/bigfolder/build.gradle
Normal file
18
feature/bigfolder/build.gradle
Normal file
@ -0,0 +1,18 @@
|
||||
apply plugin: 'com.huawei.ohos.library'
|
||||
//For instructions on signature configuration, see https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ide_debug_device-0000001053822404#section1112183053510
|
||||
ohos {
|
||||
compileSdkVersion 8
|
||||
defaultConfig {
|
||||
compatibleSdkVersion 8
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
proguardOpt {
|
||||
proguardEnabled false
|
||||
rulesFiles 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
dependencies {
|
||||
}
|
22
feature/bigfolder/src/main/config.json
Normal file
22
feature/bigfolder/src/main/config.json
Normal file
@ -0,0 +1,22 @@
|
||||
{
|
||||
"app": {
|
||||
"bundleName": "com.ohos.launcher",
|
||||
"vendor": "ohos",
|
||||
"version": {
|
||||
"code": 1000000,
|
||||
"name": "1.0.0"
|
||||
}
|
||||
},
|
||||
"deviceConfig": {},
|
||||
"module": {
|
||||
"package": "com.ohos.launcher",
|
||||
"deviceType": [
|
||||
"phone"
|
||||
],
|
||||
"distro": {
|
||||
"deliveryWithInstall": true,
|
||||
"moduleName": "bigfolder",
|
||||
"moduleType": "har"
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,342 @@
|
||||
/*
|
||||
* Copyright (c) 2021 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 BaseDragHandler from '../../../../../../../common/src/main/ets/default/base/BaseDragHandler';
|
||||
import CommonConstants from '../../../../../../../common/src/main/ets/default/constants/CommonConstants';
|
||||
import BigFolderModel from './BigFolderModel';
|
||||
import FolderViewModel from '../viewmodel/FolderViewModel';
|
||||
import LayoutConfigManager from '../../../../../../../common/src/main/ets/default/layoutconfig/LayoutConfigManager';
|
||||
import PageDesktopGridStyleConfig from '../../../../../../pagedesktop/src/main/ets/default/common/PageDesktopGridStyleConfig';
|
||||
import PageDesktopFeatureConstants from '../../../../../../pagedesktop/src/main/ets/default/common/constants/FeatureConstants';
|
||||
import PageDesktopDragHandler from '../../../../../../pagedesktop/src/main/ets/default/common/PageDesktopDragHandler';
|
||||
import Log from '../../../../../../../common/src/main/ets/default/utils/Log';
|
||||
import PageDesktopViewModel from '../../../../../../pagedesktop/src/main/ets/default/common/viewmodel/PageDesktopViewModel';
|
||||
import FeatureConstants from './constants/FeatureConstants';
|
||||
|
||||
const TAG = 'BigFolderDragHandler';
|
||||
const DRAG_DROP_DELAY = 500;
|
||||
/**
|
||||
* bigfolder drag handler class
|
||||
*/
|
||||
export default class BigFolderDragHandler extends BaseDragHandler {
|
||||
private mFolderCoordinateData = {
|
||||
gridXAxis: [],
|
||||
gridYAxis: []
|
||||
};
|
||||
private mStartIndex = 0;
|
||||
private mEndIndex = 0;
|
||||
private mStartPosition: any = null;
|
||||
private mEndPosition: any = null;
|
||||
private readonly mBigFolderModel: BigFolderModel = null;
|
||||
private mFolderAppList: any[] = [];
|
||||
private readonly mFolderViewModel: FolderViewModel = null;
|
||||
private mOpenGridConfig;
|
||||
private mGridItemHeight: any = null;
|
||||
private mGridItemWidth: any = null;
|
||||
private readonly mDesktopStyleConfig: PageDesktopGridStyleConfig = null;
|
||||
private readonly mPageDesktopViewModel: PageDesktopViewModel;
|
||||
private hasDroped = false;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
this.mBigFolderModel = BigFolderModel.getInstance();
|
||||
this.mFolderViewModel = FolderViewModel.getInstance();
|
||||
this.mDesktopStyleConfig = LayoutConfigManager.getStyleConfig(PageDesktopGridStyleConfig.APP_GRID_STYLE_CONFIG,
|
||||
PageDesktopFeatureConstants.FEATURE_NAME);
|
||||
this.mPageDesktopViewModel = PageDesktopViewModel.getInstance();
|
||||
}
|
||||
|
||||
static getInstance() {
|
||||
if (globalThis.BigFolderDragHandlerInstance == null) {
|
||||
globalThis.BigFolderDragHandlerInstance = new BigFolderDragHandler();
|
||||
}
|
||||
return globalThis.BigFolderDragHandlerInstance;
|
||||
}
|
||||
|
||||
setDragEffectArea(effectArea): void {
|
||||
super.setDragEffectArea(effectArea);
|
||||
this.updateFolderParam(effectArea);
|
||||
}
|
||||
|
||||
getEffectArea(): any {
|
||||
return this.getDragEffectArea();
|
||||
}
|
||||
|
||||
private updateFolderParam(effectArea) {
|
||||
const gridWidth = effectArea.right - effectArea.left;
|
||||
const gridHeight = effectArea.bottom - effectArea.top;
|
||||
Log.showInfo(TAG, `Launcher OpenFolder updateGridParam gridWidth: ${gridWidth}, gridHeight: ${gridHeight}`);
|
||||
this.mOpenGridConfig = this.mBigFolderModel.getFolderOpenLayout();
|
||||
const column = this.mOpenGridConfig.column;
|
||||
const row = this.mOpenGridConfig.row;
|
||||
this.mGridItemHeight = gridHeight / row;
|
||||
Log.showInfo(TAG, 'this.mGridItemHeight ' + this.mGridItemHeight);
|
||||
this.mGridItemWidth = gridWidth / column;
|
||||
Log.showInfo(TAG, 'this.mGridItemWidth ' + this.mGridItemWidth);
|
||||
Log.showInfo(TAG, `Launcher BigFolder updateGridParam column: ${column}, row: ${row}`);
|
||||
this.mFolderCoordinateData.gridYAxis = [];
|
||||
for (let i = 1; i <= row; i++) {
|
||||
const touchPositioningY = this.mGridItemHeight * i + effectArea.top;
|
||||
this.mFolderCoordinateData.gridYAxis.push(touchPositioningY);
|
||||
}
|
||||
|
||||
this.mFolderCoordinateData.gridXAxis = [];
|
||||
for (let i = 1; i <= column; i++) {
|
||||
const touchPositioningX = this.mGridItemWidth * i + effectArea.left;
|
||||
this.mFolderCoordinateData.gridXAxis.push(touchPositioningX);
|
||||
}
|
||||
}
|
||||
|
||||
protected getDragRelativeData(): any {
|
||||
const openFolderData: {
|
||||
layoutInfo: [[]]
|
||||
} = AppStorage.Get('openFolderData');
|
||||
return openFolderData;
|
||||
}
|
||||
|
||||
protected getItemIndex(event: any): number {
|
||||
const x = event.touches[0].screenX;
|
||||
const y = event.touches[0].screenY;
|
||||
let rowVal = CommonConstants.INVALID_VALUE;
|
||||
for (let index = 0; index < this.mFolderCoordinateData.gridYAxis.length; index++) {
|
||||
if (this.mFolderCoordinateData.gridYAxis[index] > y) {
|
||||
rowVal = index;
|
||||
break;
|
||||
}
|
||||
}
|
||||
let columnVal = CommonConstants.INVALID_VALUE;
|
||||
for (let index = 0; index < this.mFolderCoordinateData.gridXAxis.length; index++) {
|
||||
if (this.mFolderCoordinateData.gridXAxis[index] > x) {
|
||||
columnVal = index;
|
||||
break;
|
||||
}
|
||||
}
|
||||
const column = this.mOpenGridConfig.column;
|
||||
Log.showInfo(TAG, `Launcher BigFolder getItemIndex column: ${column}, rowVal: ${rowVal}, columnVal: ${columnVal}`);
|
||||
if (rowVal != CommonConstants.INVALID_VALUE && columnVal != CommonConstants.INVALID_VALUE) {
|
||||
return rowVal * column + columnVal;
|
||||
}
|
||||
return CommonConstants.INVALID_VALUE;
|
||||
}
|
||||
|
||||
protected getItemByIndex(index: number): any {
|
||||
const pageIndex: number = this.mFolderViewModel.getIndex();
|
||||
Log.showInfo(TAG, `getItemByIndex: ${index}, pageIndex: ${pageIndex}`);
|
||||
const dataObj = this.getDragRelativeData().layoutInfo;
|
||||
if (index >= 0 && pageIndex < dataObj.length && index < dataObj[pageIndex].length) {
|
||||
return dataObj[pageIndex][index];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private getTouchPosition(x, y): any {
|
||||
const pageIndex: number = this.mFolderViewModel.getIndex();
|
||||
const position = {
|
||||
page: pageIndex,
|
||||
row: 0,
|
||||
column: 0,
|
||||
X: x,
|
||||
Y: y,
|
||||
};
|
||||
for (let i = 0; i < this.mFolderCoordinateData.gridXAxis.length; i++) {
|
||||
if (x < this.mFolderCoordinateData.gridXAxis[i]) {
|
||||
position.column = i;
|
||||
break;
|
||||
} else {
|
||||
position.column = this.mFolderCoordinateData.gridXAxis.length - 1;
|
||||
}
|
||||
}
|
||||
for (let i = 0; i < this.mFolderCoordinateData.gridYAxis.length; i++) {
|
||||
if (y < this.mFolderCoordinateData.gridYAxis[i]) {
|
||||
position.row = i;
|
||||
break;
|
||||
} else {
|
||||
position.row = this.mFolderCoordinateData.gridYAxis.length - 1;
|
||||
}
|
||||
}
|
||||
return position;
|
||||
}
|
||||
|
||||
protected onDragStart(event: any, itemIndex: number): void {
|
||||
super.onDragStart(event, itemIndex);
|
||||
this.mFolderAppList = [];
|
||||
const moveAppX = event.touches[0].screenX;
|
||||
const moveAppY = event.touches[0].screenY;
|
||||
this.mStartPosition = this.getTouchPosition(moveAppX, moveAppY);
|
||||
const pageIndex: number = this.mFolderViewModel.getIndex();
|
||||
const mItemIndex = this.getItemIndex(event);
|
||||
this.mStartIndex = mItemIndex + this.mOpenGridConfig.column * this.mOpenGridConfig.row * pageIndex;
|
||||
Log.showInfo(TAG, `onDragStart mStartIndex: ${this.mStartIndex}`);
|
||||
|
||||
AppStorage.SetOrCreate('overlayPositionX', moveAppX);
|
||||
AppStorage.SetOrCreate('overlayPositionY', moveAppY);
|
||||
AppStorage.SetOrCreate('overlayData', {
|
||||
iconSize: this.mDesktopStyleConfig.mIconSize * 1.15,
|
||||
nameSize: this.mDesktopStyleConfig.mNameSize * 1.15,
|
||||
nameHeight: this.mDesktopStyleConfig.mNameHeight * 1.15,
|
||||
appInfo: this.getDragItemInfo(),
|
||||
});
|
||||
AppStorage.SetOrCreate('withBlur', false);
|
||||
AppStorage.SetOrCreate('overlayMode', CommonConstants.OVERLAY_TYPE_APP_ICON);
|
||||
}
|
||||
|
||||
protected onDragMove(event: any, insertIndex: number, itemIndex: number): void {
|
||||
super.onDragMove(event, insertIndex, itemIndex);
|
||||
Log.showInfo(TAG, `Launcher OpenFolder onDragMove insertIndex: ${insertIndex}`);
|
||||
const moveAppX = event.touches[0].screenX;
|
||||
const moveAppY = event.touches[0].screenY;
|
||||
AppStorage.SetOrCreate('overlayPositionX', moveAppX);
|
||||
AppStorage.SetOrCreate('overlayPositionY', moveAppY);
|
||||
}
|
||||
|
||||
protected onDragLeave(event: any): void {
|
||||
super.onDragLeave(event);
|
||||
|
||||
const moveAppY = event.touches[0].screenY;
|
||||
const dragEffectArea = this.getEffectArea();
|
||||
|
||||
if (moveAppY >= dragEffectArea.bottom || moveAppY <= dragEffectArea.top) {
|
||||
this.mFolderViewModel.closeFolder();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected onDragDrop(event: any, insertIndex: number, itemIndex: number): boolean {
|
||||
if (this.hasDroped) {
|
||||
return false;
|
||||
}
|
||||
this.dropDelay();
|
||||
super.onDragDrop(event, insertIndex, itemIndex);
|
||||
Log.showInfo(TAG, `Launcher OpenFolder onDragDrop insertIndex:${insertIndex},mIsInEffectArea: ${this.mIsInEffectArea}`);
|
||||
AppStorage.SetOrCreate('overlayMode', CommonConstants.OVERLAY_TYPE_HIDE);
|
||||
let isDragSuccess = false;
|
||||
const openingStatus = AppStorage.Get('openFolderStatus');
|
||||
|
||||
const moveAppX = event.touches[0].screenX;
|
||||
const moveAppY = event.touches[0].screenY;
|
||||
const pageIndex: number = this.mFolderViewModel.getIndex();
|
||||
const openFolderData: {
|
||||
folderId: string,
|
||||
layoutInfo: any
|
||||
} = this.getDragRelativeData();
|
||||
for (let i = 0; i < openFolderData.layoutInfo.length; i++) {
|
||||
this.mFolderAppList = this.mFolderAppList.concat(openFolderData.layoutInfo[i]);
|
||||
}
|
||||
if (this.mIsInEffectArea && openingStatus !== FeatureConstants.OPEN_FOLDER_STATUS_CLOSE) {
|
||||
this.mEndPosition = this.getTouchPosition(moveAppX, moveAppY);
|
||||
let mItemIndex = this.getItemIndex(event);
|
||||
const itemCountByPage = this.mOpenGridConfig.column * this.mOpenGridConfig.row;
|
||||
mItemIndex = mItemIndex + itemCountByPage * pageIndex;
|
||||
Log.showInfo(TAG, `onDragDrop mItemIndex: ${mItemIndex}`);
|
||||
// remove add icon
|
||||
if (this.mFolderAppList.length > 0
|
||||
&& this.mFolderAppList[this.mFolderAppList.length - 1].type == CommonConstants.TYPE_ADD) {
|
||||
this.mFolderAppList.splice(this.mFolderAppList.length - 1, 1);
|
||||
}
|
||||
if (mItemIndex > this.mFolderAppList.length - 1) {
|
||||
this.mEndIndex = this.mFolderAppList.length - 1;
|
||||
} else {
|
||||
this.mEndIndex = mItemIndex;
|
||||
}
|
||||
Log.showInfo(TAG, `onDragDrop this.mEndIndex: ${this.mEndIndex}`);
|
||||
Log.showInfo(TAG, `onDragDrop this.mStartIndex: ${this.mStartIndex}`);
|
||||
this.layoutAdjustment(this.mStartIndex, this.mEndIndex);
|
||||
} else if (openingStatus === FeatureConstants.OPEN_FOLDER_STATUS_CLOSE) {
|
||||
// effectarea in desktop
|
||||
const desktopInstance = PageDesktopDragHandler.getInstance();
|
||||
const mDesktopPosition = desktopInstance.getCalPosition(moveAppX, moveAppY);
|
||||
|
||||
const info = this.mPageDesktopViewModel.getLayoutInfo();
|
||||
const layoutInfo = info.layoutInfo;
|
||||
const endLayoutInfo = layoutInfo.find(item => {
|
||||
if (item.type === CommonConstants.TYPE_FOLDER) {
|
||||
return item.page === mDesktopPosition.page
|
||||
&& (item.row <= mDesktopPosition.row && mDesktopPosition.row <= item.row + 1)
|
||||
&& (item.column <= mDesktopPosition.column && mDesktopPosition.column <= item.column + 1);
|
||||
}
|
||||
});
|
||||
|
||||
if (endLayoutInfo != undefined
|
||||
&& endLayoutInfo.type === CommonConstants.TYPE_FOLDER
|
||||
&& endLayoutInfo.folderId === openFolderData.folderId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
let result = false;
|
||||
const dragAppInfo = this.mFolderAppList[this.mStartIndex];
|
||||
result = this.mFolderViewModel.deleteAppByDraging(this.mFolderAppList, this.mStartIndex, pageIndex);
|
||||
|
||||
if (endLayoutInfo != undefined && endLayoutInfo.type == CommonConstants.TYPE_FOLDER) {
|
||||
this.mFolderViewModel.addOneAppToFolder(dragAppInfo, endLayoutInfo.folderId);
|
||||
}
|
||||
|
||||
AppStorage.SetOrCreate('openFolderData', {});
|
||||
this.mPageDesktopViewModel.getGridList();
|
||||
if (!result) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
isDragSuccess = true;
|
||||
return isDragSuccess;
|
||||
}
|
||||
|
||||
protected onDragEnd(isSuccess: boolean): void {
|
||||
super.onDragEnd(isSuccess);
|
||||
this.mStartPosition = null;
|
||||
this.mEndPosition = null;
|
||||
AppStorage.SetOrCreate('dragFocus', '');
|
||||
}
|
||||
|
||||
private dropDelay() {
|
||||
this.hasDroped = true;
|
||||
setTimeout(() => {
|
||||
this.hasDroped = false;
|
||||
}, DRAG_DROP_DELAY);
|
||||
}
|
||||
|
||||
private layoutAdjustment(startIndex: number, endIndex: number): void {
|
||||
|
||||
Log.showInfo(TAG, 'layoutAdjustment start');
|
||||
|
||||
const item = this.mFolderAppList[startIndex];
|
||||
this.mFolderAppList.splice(startIndex, 1);
|
||||
this.mFolderAppList.splice(endIndex, 0, item);
|
||||
|
||||
const folderLayoutInfo = this.mFolderViewModel.filterFolderPage(this.mFolderAppList);
|
||||
let openFolderData: {
|
||||
folderId: string,
|
||||
layoutInfo: any
|
||||
} = AppStorage.Get('openFolderData');
|
||||
openFolderData.layoutInfo = folderLayoutInfo;
|
||||
openFolderData = this.mFolderViewModel.addAddIcon(openFolderData);
|
||||
AppStorage.SetOrCreate('openFolderData', openFolderData);
|
||||
Log.showInfo(TAG, `layoutAdjustment this.openFolderData.folderId: ${openFolderData.folderId}`);
|
||||
const info = this.mPageDesktopViewModel.getLayoutInfo();
|
||||
const layoutInfo = info.layoutInfo;
|
||||
|
||||
for (let i = 0; i < layoutInfo.length; i++) {
|
||||
if (layoutInfo[i].type === CommonConstants.TYPE_FOLDER) {
|
||||
if (layoutInfo[i].folderId === openFolderData.folderId) {
|
||||
layoutInfo[i].layoutInfo = folderLayoutInfo;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
info.layoutInfo = layoutInfo;
|
||||
this.mPageDesktopViewModel.setLayoutInfo(info);
|
||||
this.mPageDesktopViewModel.getGridList();
|
||||
Log.showInfo(TAG, 'layoutAdjustment end');
|
||||
}
|
||||
}
|
@ -0,0 +1,98 @@
|
||||
/*
|
||||
* Copyright (c) 2021 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 LayoutConfigManager from '../../../../../../../common/src/main/ets/default/layoutconfig/LayoutConfigManager';
|
||||
import LocalEventManager from '../../../../../../../common/src/main/ets/default/manager/LocalEventManager';
|
||||
import FolderLayoutConfig from '../../../../../../../common/src/main/ets/default/layoutconfig/FolderLayoutConfig';
|
||||
import Log from '../../../../../../../common/src/main/ets/default/utils/Log';
|
||||
import CommonConstants from '../../../../../../../common/src/main/ets/default/constants/CommonConstants';
|
||||
import EventConstants from '../../../../../../../common/src/main/ets/default/constants/EventConstants';
|
||||
import SettingsModel from '../../../../../../../common/src/main/ets/default/model/SettingsModel';
|
||||
|
||||
const TAG = 'BigFolderModel';
|
||||
|
||||
/**
|
||||
* Folder information data model
|
||||
*/
|
||||
export default class BigFolderModel {
|
||||
private mFolderLayoutConfig: FolderLayoutConfig = null;
|
||||
mFolderInfoList = [];
|
||||
private readonly mSettingsModel: SettingsModel;
|
||||
|
||||
private constructor() {
|
||||
this.mSettingsModel = SettingsModel.getInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get folder model object
|
||||
*
|
||||
* @return Single instance of folder data model
|
||||
*/
|
||||
static getInstance() {
|
||||
if (globalThis.BigFolderModelInstance == null) {
|
||||
globalThis.BigFolderModelInstance = new BigFolderModel();
|
||||
globalThis.BigFolderModelInstance.initConfig();
|
||||
}
|
||||
return globalThis.BigFolderModelInstance;
|
||||
}
|
||||
|
||||
private initConfig() {
|
||||
this.mFolderLayoutConfig = LayoutConfigManager.getFunctionConfig(FolderLayoutConfig.FOLDER_GRID_LAYOUT_INFO);
|
||||
}
|
||||
|
||||
getFolderLayout(): any {
|
||||
return this.mFolderLayoutConfig.getFolderLayoutInfo().folderLayoutTable;
|
||||
}
|
||||
|
||||
getFolderOpenLayout(): any {
|
||||
return this.mFolderLayoutConfig.getFolderLayoutInfo().folderOpenLayoutTable;
|
||||
}
|
||||
|
||||
getFolderAddAppLayout(): any {
|
||||
return this.mFolderLayoutConfig.getFolderLayoutInfo().folderAddAppLayoutTable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get folder list
|
||||
*
|
||||
* @return folder list
|
||||
*/
|
||||
async getFolderList() {
|
||||
Log.showInfo(TAG, 'getFolderList');
|
||||
this.mFolderInfoList = [];
|
||||
let gridLayoutInfo = {
|
||||
layoutInfo: []
|
||||
};
|
||||
gridLayoutInfo = this.mSettingsModel.getLayoutInfo();
|
||||
const layoutInfo = gridLayoutInfo.layoutInfo;
|
||||
for (let i = 0; i < layoutInfo.length; i++) {
|
||||
if (layoutInfo[i].type == CommonConstants.TYPE_FOLDER) {
|
||||
this.mFolderInfoList.push(layoutInfo[i]);
|
||||
}
|
||||
}
|
||||
return this.mFolderInfoList;
|
||||
}
|
||||
|
||||
/**
|
||||
* register folder update event.
|
||||
*
|
||||
* @param listener
|
||||
*/
|
||||
registerFolderUpdateEvent(listener) {
|
||||
LocalEventManager.registerEventListener(listener, [
|
||||
EventConstants.EVENT_BADGE_UPDATE,
|
||||
EventConstants.EVENT_FOLDER_PACKAGE_REMOVED
|
||||
]);
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (c) 2021 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 BaseModulePreLoader from '../../../../../../../common/src/main/ets/default/base/BaseModulePreLoader';
|
||||
import LayoutConfigManager from '../../../../../../../common/src/main/ets/default/layoutconfig/LayoutConfigManager';
|
||||
import BigFolderStyleConfig from './BigFolderStyleConfig';
|
||||
import FolderLayoutConfig from '../../../../../../../common/src/main/ets/default/layoutconfig/FolderLayoutConfig';
|
||||
|
||||
/**
|
||||
* bigfolder layer initialization loader
|
||||
*/
|
||||
class BigFolderPreLoader extends BaseModulePreLoader {
|
||||
protected loadConfig(): void {
|
||||
LayoutConfigManager.addConfigToManager(FolderLayoutConfig.getInstance());
|
||||
LayoutConfigManager.addConfigToManager(BigFolderStyleConfig.getInstance());
|
||||
}
|
||||
|
||||
protected loadData(): void {
|
||||
}
|
||||
|
||||
releaseConfigAndData(): void {
|
||||
LayoutConfigManager.removeConfigFromManager();
|
||||
}
|
||||
}
|
||||
|
||||
const bigFolderPreLoader: BaseModulePreLoader = new BigFolderPreLoader();
|
||||
|
||||
export default bigFolderPreLoader;
|
@ -0,0 +1,204 @@
|
||||
/*
|
||||
* Copyright (c) 2021 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 AppListStyleConfig from '../../../../../../../common/src/main/ets/default/layoutconfig/AppListStyleConfig';
|
||||
import CommonConstants from '../../../../../../../common/src/main/ets/default/constants/CommonConstants';
|
||||
import PresetStyleConstants from '../../../../../../../common/src/main/ets/default/constants/PresetStyleConstants';
|
||||
import StyleConstants from '../../../../../../../common/src/main/ets/default/constants/StyleConstants';
|
||||
import FeatureConstants from './constants/FeatureConstants';
|
||||
import FolderStyleConstants from './constants/FolderStyleConstants';
|
||||
|
||||
/**
|
||||
* folder style config
|
||||
*/
|
||||
export default class BigFolderStyleConfig extends AppListStyleConfig {
|
||||
/**
|
||||
* folder grid size
|
||||
*/
|
||||
mGridSize = StyleConstants.DEFAULT_FOLDER_GRID_SIZE;
|
||||
|
||||
/**
|
||||
* folder app size
|
||||
*/
|
||||
mFolderAppSize = StyleConstants.DEFAULT_FOLDER_APP_SIZE;
|
||||
|
||||
/**
|
||||
* folder grid margin side
|
||||
*/
|
||||
mGridMargin = StyleConstants.DEFAULT_FOLDER_GRID_MARGIN;
|
||||
|
||||
/**
|
||||
* folder grid gap
|
||||
*/
|
||||
mFolderGridGap = StyleConstants.DEFAULT_FOLDER_GRID_GAP;
|
||||
|
||||
/**
|
||||
* margin of folder open
|
||||
*/
|
||||
mFolderOpenMargin = StyleConstants.DEFAULT_OPEN_FOLDER_TITLE_HEIGHT;
|
||||
|
||||
/**
|
||||
* open folder app size
|
||||
*/
|
||||
mOpenFolderAppSize = StyleConstants.DEFAULT_OPEN_FOLDER_APP_SIZE;
|
||||
|
||||
/**
|
||||
* icon size of open folder
|
||||
*/
|
||||
mOpenFolderIconSize = StyleConstants.DEFAULT_OPEN_FOLDER_APP_SIZE;
|
||||
|
||||
/**
|
||||
* open folder app size
|
||||
*/
|
||||
mOpenFolderAppNameSize = StyleConstants.DEFAULT_OPEN_FOLDER_APP_NAME_SIZE;
|
||||
|
||||
/**
|
||||
* open folder app name height
|
||||
*/
|
||||
mOpenFolderAppNameHeight = StyleConstants.DEFAULT_OPEN_FOLDER_APP_NAME_HEIGHT;
|
||||
|
||||
/**
|
||||
* open folder grid width
|
||||
*/
|
||||
mOpenFolderGridWidth = StyleConstants.DEFAULT_OPEN_FOLDER_GRID_WIDTH;
|
||||
|
||||
/**
|
||||
* open folder grid height
|
||||
*/
|
||||
mOpenFolderGridHeight = StyleConstants.DEFAULT_OPEN_FOLDER_GRID_HEIGHT;
|
||||
|
||||
/**
|
||||
* open folder grid gap
|
||||
*/
|
||||
mOpenFolderGridGap = StyleConstants.DEFAULT_OPEN_FOLDER_GRID_GAP;
|
||||
|
||||
/**
|
||||
* padding of open folder layout
|
||||
*/
|
||||
mOpenFolderGridPadding = PresetStyleConstants.DEFAULT_OPEN_FOLDER_PADDING;
|
||||
|
||||
/**
|
||||
* padding of open folder icon
|
||||
*/
|
||||
mOpenFolderGridIconTopPadding = PresetStyleConstants.DEFAULT_ICON_PADDING_TOP;
|
||||
/**
|
||||
* width of add app dialog
|
||||
*/
|
||||
mAddFolderDialogWidth: number = FolderStyleConstants.DEFAULT_APP_ADD_DIALOG_WIDTH;
|
||||
|
||||
/**
|
||||
* height of add app dialog
|
||||
*/
|
||||
mAddFolderDialogHeight: number = FolderStyleConstants.DEFAULT_APP_ADD_DIALOG_HEIGHT;
|
||||
|
||||
/**
|
||||
* width of add app container
|
||||
*/
|
||||
mAddFolderGridWidth: number = FolderStyleConstants.DEFAULT_FOLDER_APP_GRID_LIST;
|
||||
|
||||
/**
|
||||
* gap of add app container
|
||||
*/
|
||||
mAddFolderGridGap: number = PresetStyleConstants.DEFAULT_FOLDER_ADD_GAP;
|
||||
|
||||
/**
|
||||
* margin of add app container
|
||||
*/
|
||||
mAddFolderGridMargin: number = PresetStyleConstants.DEFAULT_FOLDER_ADD_MARGIN;
|
||||
|
||||
/**
|
||||
* maxHeight of add app container
|
||||
*/
|
||||
mAddFolderMaxHeight: number = PresetStyleConstants.DEFAULT_FOLDER_ADD_MAX_HEIGHT;
|
||||
|
||||
/**
|
||||
* size of add app toggle
|
||||
*/
|
||||
mFolderToggleSize: number = PresetStyleConstants.DEFAULT_APP_GRID_TOGGLE_SIZE;
|
||||
|
||||
/**
|
||||
* title size of add app
|
||||
*/
|
||||
mAddFolderTitleSize: number = PresetStyleConstants.DEFAULT_FOLDER_ADD_TITLE_TEXT_SIZE;
|
||||
|
||||
/**
|
||||
* text size of add app item
|
||||
*/
|
||||
mAddFolderTextSize: number = PresetStyleConstants.DEFAULT_FOLDER_ADD_GRID_TEXT_SIZE;
|
||||
|
||||
/**
|
||||
* name lines of add app item
|
||||
*/
|
||||
mAddFolderTextLines: number = PresetStyleConstants.DEFAULT_FOLDER_ADD_TEXT_LINES;
|
||||
|
||||
/**
|
||||
* line height of add app item
|
||||
*/
|
||||
mAddFolderLinesHeight: number = PresetStyleConstants.DEFAULT_TEXT_LINES;
|
||||
|
||||
/**
|
||||
* icon size of add app
|
||||
*/
|
||||
mAddFolderIconSize: number = PresetStyleConstants.DEFAULT_ICON_SIZE;
|
||||
|
||||
/**
|
||||
* size of add app item
|
||||
*/
|
||||
mAddFolderItemSize: number = PresetStyleConstants.DEFAULT_APP_LAYOUT_SIZE;
|
||||
|
||||
/**
|
||||
* padding top of add app icon
|
||||
*/
|
||||
mAddFolderIconPaddingTop: number = PresetStyleConstants.DEFAULT_ICON_PADDING_TOP;
|
||||
|
||||
/**
|
||||
* button size of add app
|
||||
*/
|
||||
mAddFolderButtonSize: number = PresetStyleConstants.DEFAULT_FOLDER_ADD_BUTTON_SIZE;
|
||||
|
||||
/**
|
||||
* margin left of icon with add app item
|
||||
*/
|
||||
mAddFolderIconMarginHorizontal = PresetStyleConstants.DEFAULT_ICON_PADDING_LEFT;
|
||||
/**
|
||||
* folder list blur
|
||||
*/
|
||||
mBackdropBlur = 20;
|
||||
|
||||
private constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* get folder style config instance
|
||||
*/
|
||||
static getInstance() {
|
||||
if (globalThis.BigFolderStyleConfigInstance == null) {
|
||||
globalThis.BigFolderStyleConfigInstance = new BigFolderStyleConfig();
|
||||
}
|
||||
return globalThis.BigFolderStyleConfigInstance;
|
||||
}
|
||||
|
||||
initConfig(): void {
|
||||
}
|
||||
|
||||
getConfigLevel(): string {
|
||||
return CommonConstants.LAYOUT_CONFIG_LEVEL_FEATURE;
|
||||
}
|
||||
|
||||
getFeatureName() {
|
||||
return FeatureConstants.FEATURE_NAME;
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (c) 2021 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.
|
||||
*/
|
||||
|
||||
export default class FeatureConstants {
|
||||
static readonly FEATURE_NAME = 'featureBigFolder';
|
||||
|
||||
/**
|
||||
* folder static status
|
||||
*/
|
||||
static readonly OPEN_FOLDER_STATUS_STATIC = -1;
|
||||
|
||||
/**
|
||||
* folder close status
|
||||
*/
|
||||
static readonly OPEN_FOLDER_STATUS_CLOSE = 0;
|
||||
|
||||
/**
|
||||
* folder open status
|
||||
*/
|
||||
static readonly OPEN_FOLDER_STATUS_OPEN = 1;
|
||||
|
||||
/**
|
||||
* folder refresh status
|
||||
*/
|
||||
static readonly OPEN_FOLDER_STATUS_REFRESH = 2;
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright (c) 2021 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.
|
||||
*/
|
||||
|
||||
export default class FolderStyleConstants {
|
||||
|
||||
// image resources
|
||||
static readonly DEFAULT_ICON: any = $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';
|
||||
|
||||
// font style resources
|
||||
static readonly DEFAULT_FONT_COLOR = '#ffffff';
|
||||
static readonly FOLDER_ADD_APP_FONT_COLOR = '#000000';
|
||||
|
||||
// layout percentage adaptation resources
|
||||
static readonly PERCENTAGE_100 = '100%';
|
||||
static readonly PERCENTAGE_80 = '80%';
|
||||
static readonly PERCENTAGE_50 = '50%';
|
||||
|
||||
// image size resources
|
||||
static readonly DEFAULT_APP_NAME_SIZE= 20;
|
||||
static readonly DEFAULT_FOLDER_ADD_APP_NAME_SIZE= 16;
|
||||
static readonly DEFAULT_APP_ITEM_WIDTH = 70;
|
||||
static readonly DEFAULT_APP_ITEM_HEIGHT = 95;
|
||||
static readonly DEFAULT_APP_ICON_SIZE_WIDTH = 70;
|
||||
static readonly DEFAULT_APP_NAME_HEIGHT = 25;
|
||||
static readonly DEFAULT_ADD_APP_ICON_SIZE = 50;
|
||||
static readonly DEFAULT_ADD_APP_SIZE = 65;
|
||||
static readonly DEFAULT_VP_30 = 30;
|
||||
static readonly DEFAULT_OPEN_FOLDER_NAME_SIZE = 30;
|
||||
static readonly DEFAULT_OPEN_FOLDER_TITLE_HEIGHT = 130;
|
||||
|
||||
// Folder add app grid list
|
||||
static readonly DEFAULT_FOLDER_APP_DIALOG_LIST = 536;
|
||||
static readonly DEFAULT_FOLDER_APP_GRID_LIST = 424;
|
||||
static readonly DEFAULT_FOLDER_APP_GRID_MARGIN = 10;
|
||||
static readonly DEFAULT_APP_GRID_TOGGLE_SIZE = 30;
|
||||
static readonly DEFAULT_APP_GRID_TOGGLE_MARGIN = -30;
|
||||
static readonly DEFAULT_APP_ADD_TEXT_MARGIN = 14;
|
||||
static readonly DEFAULT_APP_ADD_TEXT_BOTTOM_MARGIN = 20;
|
||||
static readonly DEFAULT_APP_ADD_WIDTH = '70%';
|
||||
static readonly DEFAULT_APP_GRID_LIST_WIDTH = 360;
|
||||
static readonly DEFAULT_APP_GRID_TEXT_FONT_SIZE = 20;
|
||||
static readonly DEFAULT_APP_GRID_BUTTON_SIZE = 60;
|
||||
static readonly DEFAULT_APP_GRID_RADIUS = 24;
|
||||
static readonly DEFAULT_APP_ADD_TITLE_SIZE = 56;
|
||||
static readonly DEFAULT_APP_ADD_DIALOG_WIDTH = 394;
|
||||
static readonly DEFAULT_APP_ADD_DIALOG_HEIGHT = 536;
|
||||
static readonly DEFAULT_BUTTON_HEIGHT = 40;
|
||||
static readonly DEFAULT_DIALOG_BOTTOM_MARGIN = 16;
|
||||
}
|
@ -0,0 +1,191 @@
|
||||
/*
|
||||
* Copyright (c) 2021 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 AppBubble from '../../../../../../../../common/src/main/ets/default/uicomponents/AppBubble.ets';
|
||||
import CommonConstants from '../../../../../../../../common/src/main/ets/default/constants/CommonConstants';
|
||||
import PresetStyleConstants from '../../../../../../../../common/src/main/ets/default/constants/PresetStyleConstants';
|
||||
import CommonStyleConstants from '../../../../../../../../common/src/main/ets/default/constants/StyleConstants';
|
||||
import ResourceManager from '../../../../../../../../common/src/main/ets/default/manager/ResourceManager';
|
||||
import FolderStyleConstants from '../constants/FolderStyleConstants';
|
||||
import FolderViewModel from '../../viewmodel/FolderViewModel';
|
||||
import Log from '../../../../../../../../common/src/main/ets/default/utils/Log';
|
||||
import TitleDescriptionComponent from './TitleDescriptionComponent.ets';
|
||||
import BigFolderStyleConfig from '../BigFolderStyleConfig';
|
||||
|
||||
const TAG = 'FolderAppListDialog';
|
||||
const FOLDER_ADD_APP_LIST_LENGTH = 16;
|
||||
|
||||
let folderViewModel: FolderViewModel;
|
||||
|
||||
@CustomDialog
|
||||
export default struct FolderAppListDialog {
|
||||
@StorageLink('allAppListForFolder') allAppInfoList: [] = [];
|
||||
@StorageLink('folderAppList') folderAppList: [] = [];
|
||||
@StorageLink('appListChecked') @Watch('onAppListChecked') appListChecked: any = [];
|
||||
@StorageLink('titleDescription') titleDescription: any = '';
|
||||
@State mAppItemWidth: number = FolderStyleConstants.DEFAULT_APP_ITEM_WIDTH;
|
||||
@State mAppNameHeight: number = FolderStyleConstants.DEFAULT_APP_NAME_HEIGHT;
|
||||
@State mAppNameSize: number = FolderStyleConstants.DEFAULT_FOLDER_ADD_APP_NAME_SIZE;
|
||||
@State mNameFontColor: string = FolderStyleConstants.FOLDER_ADD_APP_FONT_COLOR;
|
||||
private mFolderStyleConfig: BigFolderStyleConfig;
|
||||
private mColumnsTemplate: string;
|
||||
|
||||
controller: CustomDialogController;
|
||||
cancel: () => void;
|
||||
confirm: (isDestory) => void;
|
||||
folderItem: any;
|
||||
addToString: string = '';
|
||||
|
||||
private aboutToAppear(): void {
|
||||
Log.showInfo(TAG, `aboutToAppear`);
|
||||
folderViewModel = FolderViewModel.getInstance();
|
||||
this.mFolderStyleConfig = folderViewModel.getFolderStyleConfig();
|
||||
folderViewModel.getFolderAddAppList(this.folderItem.folderId);
|
||||
folderViewModel.getFolderAppList(this.folderItem.folderId);
|
||||
this.appListChecked = this.folderAppList;
|
||||
ResourceManager.getInstance().getStringById($r('app.string.add_to').id, this.updateTitleDes.bind(this));
|
||||
}
|
||||
|
||||
private updateTitleDes(value: string) {
|
||||
this.addToString = value;
|
||||
this.onAppListChecked();
|
||||
}
|
||||
|
||||
private onAppListChecked () {
|
||||
this.titleDescription = `${this.addToString}${this.folderItem.folderName}(${this.appListChecked.length}/${this.allAppInfoList.length})`;
|
||||
AppStorage.SetOrCreate('titleDescription', this.titleDescription);
|
||||
}
|
||||
|
||||
private getColumnsTemplate() {
|
||||
let columnsTemplate = '';
|
||||
for (let index = 0; index < folderViewModel.getAddListColumn(); index++) {
|
||||
columnsTemplate += '1fr ';
|
||||
}
|
||||
return columnsTemplate;
|
||||
}
|
||||
|
||||
build() {
|
||||
Flex({direction: FlexDirection.Column, justifyContent: FlexAlign.End}) {
|
||||
TitleDescriptionComponent({
|
||||
mTitleDescription: $titleDescription,
|
||||
mTextSize: this.mFolderStyleConfig.mAddFolderTitleSize})
|
||||
Column() {
|
||||
Grid() {
|
||||
ForEach(this.allAppInfoList, (item) => {
|
||||
GridItem() {
|
||||
Stack() {
|
||||
Column() {
|
||||
AppBubble({
|
||||
iconSize: this.mFolderStyleConfig.mAddFolderIconSize,
|
||||
nameSize: this.mFolderStyleConfig.mAddFolderTextSize,
|
||||
nameFontColor: this.mNameFontColor,
|
||||
nameHeight: this.mFolderStyleConfig.mAddFolderTextLines,
|
||||
appName: item.appName,
|
||||
bundleName: item.bundleName,
|
||||
appIconId: item.appIconId,
|
||||
appLabelId: item.appLabelId,
|
||||
isSelect:false,
|
||||
badgeNumber: CommonConstants.BADGE_DISPLAY_HIDE,
|
||||
nameLines: this.mFolderStyleConfig.mAddFolderTextLines,
|
||||
mPaddingTop: this.mFolderStyleConfig.mAddFolderIconPaddingTop,
|
||||
mIconNameMargin: this.mFolderStyleConfig.mIconNameMargin
|
||||
})
|
||||
}
|
||||
Toggle({ type: ToggleType.Checkbox, isOn: item.checked })
|
||||
.width(this.mFolderStyleConfig.mFolderToggleSize)
|
||||
.height(this.mFolderStyleConfig.mFolderToggleSize)
|
||||
.position({x:-this.mFolderStyleConfig.mFolderToggleSize + this.mFolderStyleConfig.mAddFolderIconMarginHorizontal
|
||||
, y:-this.mFolderStyleConfig.mFolderToggleSize/2})
|
||||
.onChange((isOn: boolean) => {
|
||||
Log.showInfo(TAG, `Toggle onChange this.isOn: ${isOn}`);
|
||||
if (isOn) {
|
||||
let appItem: any;
|
||||
appItem = item;
|
||||
appItem.area = [1,1];
|
||||
appItem.type = CommonConstants.TYPE_APP;
|
||||
this.appListChecked.push(appItem);
|
||||
} else {
|
||||
let index = this.appListChecked.indexOf(item);
|
||||
this.appListChecked.splice(index, 1);
|
||||
}
|
||||
AppStorage.SetOrCreate('appListChecked', this.appListChecked);
|
||||
})
|
||||
}
|
||||
}
|
||||
.width(this.mFolderStyleConfig.mAddFolderItemSize)
|
||||
.height(this.mFolderStyleConfig.mAddFolderItemSize)
|
||||
}, (item) => JSON.stringify(item))
|
||||
}
|
||||
.columnsTemplate(this.getColumnsTemplate())
|
||||
.columnsGap(this.mFolderStyleConfig.mAddFolderGridGap)
|
||||
.rowsGap(this.mFolderStyleConfig.mAddFolderGridGap)
|
||||
.margin( this.mFolderStyleConfig.mAddFolderGridMargin )
|
||||
}
|
||||
|
||||
Flex({ justifyContent: FlexAlign.SpaceAround }) {
|
||||
Button() {
|
||||
Text($r('app.string.cancel_dialog'))
|
||||
.fontSize(this.mFolderStyleConfig.mAddFolderButtonSize)
|
||||
.fontColor(CommonStyleConstants.BUTTON_FONT_COLOR)
|
||||
}
|
||||
.flexGrow(1)
|
||||
.backgroundColor(CommonStyleConstants.DEFAULT_BG_COLOR)
|
||||
.height(FolderStyleConstants.DEFAULT_BUTTON_HEIGHT)
|
||||
.onClick(() => {
|
||||
this.controller.close();
|
||||
this.cancel()
|
||||
})
|
||||
|
||||
Divider()
|
||||
.vertical(true)
|
||||
.color(CommonStyleConstants.DEFAULT_DIVIDER_COLOR)
|
||||
.height(FolderStyleConstants.DEFAULT_BUTTON_HEIGHT)
|
||||
|
||||
Button() {
|
||||
Text($r('app.string.confirm_dialog'))
|
||||
.fontSize(this.mFolderStyleConfig.mAddFolderButtonSize)
|
||||
.fontColor(CommonStyleConstants.BUTTON_FONT_COLOR)
|
||||
}
|
||||
.flexGrow(1)
|
||||
.backgroundColor(CommonStyleConstants.DEFAULT_BG_COLOR)
|
||||
.height(FolderStyleConstants.DEFAULT_BUTTON_HEIGHT)
|
||||
.onClick(() => {
|
||||
Log.showInfo(TAG, `Dialog confirm start`);
|
||||
folderViewModel.updateFolderAppList(this.appListChecked, this.folderItem);
|
||||
let isDestory = false;
|
||||
if (this.folderItem.layoutInfo[0].length < 2) {
|
||||
isDestory = true;
|
||||
} else {
|
||||
folderViewModel.refreshFolder(this.folderItem);
|
||||
}
|
||||
this.controller.close();
|
||||
this.confirm(isDestory);
|
||||
Log.showInfo(TAG, `Dialog confirm end`);
|
||||
})
|
||||
}
|
||||
}
|
||||
.backgroundColor(Color.White)
|
||||
.padding({
|
||||
bottom: FolderStyleConstants.DEFAULT_DIALOG_BOTTOM_MARGIN
|
||||
})
|
||||
.border({
|
||||
radius: CommonStyleConstants.DEFAULT_DIALOG_RADIUS
|
||||
})
|
||||
.margin({
|
||||
bottom: FolderStyleConstants.DEFAULT_DIALOG_BOTTOM_MARGIN
|
||||
})
|
||||
.width(this.mFolderStyleConfig.mAddFolderDialogWidth)
|
||||
.height(folderViewModel.getDialogHeight(this.allAppInfoList))
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (c) 2021 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 FolderStyleConstants from '../constants/FolderStyleConstants';
|
||||
|
||||
@Component
|
||||
export default struct TitleDescriptionComponent {
|
||||
@Link mTitleDescription: any;
|
||||
@State mTextSize: number = FolderStyleConstants.DEFAULT_APP_GRID_TEXT_FONT_SIZE;
|
||||
|
||||
build() {
|
||||
Text(this.mTitleDescription)
|
||||
.fontSize(this.mTextSize)
|
||||
.margin({
|
||||
top: FolderStyleConstants.DEFAULT_APP_ADD_TEXT_MARGIN,
|
||||
bottom: FolderStyleConstants.DEFAULT_APP_ADD_TEXT_MARGIN,
|
||||
left: FolderStyleConstants.DEFAULT_APP_ADD_TEXT_MARGIN
|
||||
})
|
||||
}
|
||||
}
|
@ -0,0 +1,565 @@
|
||||
/*
|
||||
* Copyright (c) 2021 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 windowManager from '../../../../../../../common/src/main/ets/default/manager/WindowManager';
|
||||
import AppBubble from '../../../../../../../common/src/main/ets/default/uicomponents/AppBubble.ets';
|
||||
import AppName from '../../../../../../../common/src/main/ets/default/uicomponents/AppName.ets';
|
||||
import CommonConstants from '../../../../../../../common/src/main/ets/default/constants/CommonConstants';
|
||||
import PageDesktopViewModel from '../../../../../../pagedesktop/src/main/ets/default/common/viewmodel/PageDesktopViewModel';
|
||||
import FolderAppListDialog from '../common/uicomponents/FolderAppListDialog.ets';
|
||||
import FormManagerDialog from '../../../../../../../feature/form/src/main/ets/default/common/uicomponents/FormManagerDialog.ets';
|
||||
import FolderViewModel from '../viewmodel/FolderViewModel';
|
||||
import BigFolderModel from '../common/BigFolderModel';
|
||||
import Log from '../../../../../../../common/src/main/ets/default/utils/Log';
|
||||
import FolderStyleConstants from '../common/constants/FolderStyleConstants';
|
||||
import FeatureConstants from '../common/constants/FeatureConstants';
|
||||
import UninstallDialog from '../../../../../../../common/src/main/ets/default/uicomponents/UninstallDialog.ets';
|
||||
import BigFolderDragHandler from '../common/BigFolderDragHandler';
|
||||
import BigFolderStyleConfig from '../common/BigFolderStyleConfig';
|
||||
import Trace from '../../../../../../../common/src/main/ets/default/utils/Trace';
|
||||
import PresetStyleConstants from '../../../../../../../common/src/main/ets/default/constants/PresetStyleConstants';
|
||||
|
||||
const TAG = 'FolderOpenComponent';
|
||||
|
||||
const APP_INFO_REFRESH_DELAY = 500;
|
||||
const FOLDER_CLOSE_DELAY = 500;
|
||||
let mFolderViewModel: FolderViewModel;
|
||||
let mPageDesktopViewModel: PageDesktopViewModel;
|
||||
let mBigFolderDragHandler: BigFolderDragHandler;
|
||||
let mBigFolderStyleConfig: BigFolderStyleConfig;
|
||||
let mFolderModel: BigFolderModel;
|
||||
let isOpenFolderDialog: boolean = false;
|
||||
let mAppNameHeight = FolderStyleConstants.DEFAULT_APP_NAME_HEIGHT;
|
||||
let mAppItemWidth = FolderStyleConstants.DEFAULT_APP_ITEM_WIDTH;
|
||||
let mAppNameSize = FolderStyleConstants.DEFAULT_APP_NAME_SIZE;
|
||||
let mAppIconSize = FolderStyleConstants.DEFAULT_APP_ITEM_WIDTH;
|
||||
let mNameLines = PresetStyleConstants.DEFAULT_APP_NAME_LINES;
|
||||
let mIconNameMargin = PresetStyleConstants.DEFAULT_ICON_NAME_GAP;
|
||||
let mGridWidth;
|
||||
let mGridHeight;
|
||||
let mGridPadding;
|
||||
let mGridMarginTop;
|
||||
let mGridIconTopPadding;
|
||||
let isPad = false;
|
||||
|
||||
@Component
|
||||
export default struct FolderOpenComponent {
|
||||
@State withBlur: boolean = true;
|
||||
@StorageLink('isDraging') isDraging: boolean = false;
|
||||
@State @Watch('showStateChange') showState: boolean = false;
|
||||
@StorageLink('openFolderPageIndex') PageIndex: number = 0;
|
||||
@StorageLink('openFolderStatus') @Watch('updateFolderData') openFolderStatus: number = FeatureConstants.OPEN_FOLDER_STATUS_CLOSE;
|
||||
@State overLayAlpha: number = 0.3;
|
||||
@State isRenaming: boolean = false;
|
||||
@StorageLink('openFolderData') mFolderInfo: {
|
||||
layoutInfo: [],
|
||||
enterEditing: boolean,
|
||||
folderName: string,
|
||||
folderId: string
|
||||
} = { layoutInfo: [], enterEditing: false, folderName: '', folderId: '' };
|
||||
private newFolderName: string;
|
||||
|
||||
private aboutToAppear(): void {
|
||||
console.info("==========getFolderInfo start");
|
||||
mFolderViewModel = FolderViewModel.getInstance();
|
||||
mPageDesktopViewModel = PageDesktopViewModel.getInstance();
|
||||
this.updateStyle();
|
||||
// Folder dialog data preloading
|
||||
mFolderViewModel.getFolderAddAppList(this.mFolderInfo.folderId);
|
||||
mFolderViewModel.getFolderAppList(this.mFolderInfo.folderId);
|
||||
console.info("==========getFolderInfo end");
|
||||
}
|
||||
|
||||
private updateStyle() {
|
||||
isPad = mFolderViewModel.getIsPad();
|
||||
mBigFolderStyleConfig = mFolderViewModel.getFolderStyleConfig();
|
||||
mAppItemWidth = mBigFolderStyleConfig.mOpenFolderAppSize;
|
||||
mAppIconSize = mBigFolderStyleConfig.mOpenFolderIconSize;
|
||||
mAppNameSize = mBigFolderStyleConfig.mOpenFolderAppNameSize;
|
||||
mAppNameHeight = mBigFolderStyleConfig.mOpenFolderAppNameHeight;
|
||||
mGridWidth = mBigFolderStyleConfig.mOpenFolderGridWidth;
|
||||
mGridHeight = mBigFolderStyleConfig.mOpenFolderGridHeight;
|
||||
mGridPadding = mBigFolderStyleConfig.mOpenFolderGridPadding;
|
||||
mNameLines = mBigFolderStyleConfig.mNameLines;
|
||||
mIconNameMargin = mBigFolderStyleConfig.mIconNameMargin;
|
||||
mGridMarginTop = mBigFolderStyleConfig.mFolderOpenMargin;
|
||||
mGridIconTopPadding = mBigFolderStyleConfig.mOpenFolderGridIconTopPadding;
|
||||
}
|
||||
|
||||
private showStateChange() {
|
||||
Log.showInfo(TAG, `showStateChange start`);
|
||||
if (this.showState) {
|
||||
this.showOpenFolder();
|
||||
} else {
|
||||
this.hideOpenFolder();
|
||||
}
|
||||
Log.showInfo(TAG, `showStateChange end`);
|
||||
}
|
||||
|
||||
private updateFolderData() {
|
||||
Log.showInfo(TAG, `updateFolderData start`);
|
||||
if (this.openFolderStatus == FeatureConstants.OPEN_FOLDER_STATUS_STATIC) {
|
||||
return;
|
||||
}
|
||||
if (this.openFolderStatus == FeatureConstants.OPEN_FOLDER_STATUS_CLOSE) {
|
||||
this.showState = false;
|
||||
mFolderViewModel.delAddIcon(this.mFolderInfo);
|
||||
mPageDesktopViewModel.pagingFiltering();
|
||||
this.newFolderName = '';
|
||||
return;
|
||||
} else {
|
||||
this.isRenaming = this.mFolderInfo.enterEditing;
|
||||
this.mFolderInfo = mFolderViewModel.addAddIcon(this.mFolderInfo);
|
||||
this.showState = true;
|
||||
}
|
||||
AppStorage.SetOrCreate('openFolderStatus', FeatureConstants.OPEN_FOLDER_STATUS_STATIC);
|
||||
AppStorage.SetOrCreate('isDraging', false);
|
||||
Log.showInfo(TAG, `updateFolderData end`);
|
||||
}
|
||||
|
||||
private hideOpenFolder() {
|
||||
Log.showInfo(TAG, `hideOpenFolder start`);
|
||||
this.isRenaming = false;
|
||||
this.withBlur = false;
|
||||
this.openFolderStatus = FeatureConstants.OPEN_FOLDER_STATUS_CLOSE;
|
||||
this.showAnimate(0.3, Curve.EaseOut);
|
||||
Log.showInfo(TAG, `hideOpenFolder end`);
|
||||
}
|
||||
|
||||
private showOpenFolder() {
|
||||
this.updateStyle();
|
||||
this.withBlur = true;
|
||||
this.showAnimate(1, Curve.EaseIn);
|
||||
}
|
||||
|
||||
private showAnimate(overLayAlpha: number, curveValue:Curve) {
|
||||
animateTo({
|
||||
duration: 250,
|
||||
tempo: 0.5,
|
||||
curve: curveValue,
|
||||
delay: 0,
|
||||
iterations: 1,
|
||||
playMode: PlayMode.Normal,
|
||||
}, () => {
|
||||
this.overLayAlpha = overLayAlpha;
|
||||
Trace.end(Trace.CORE_METHOD_OPEN_FOLDER);
|
||||
})
|
||||
}
|
||||
|
||||
build() {
|
||||
Stack() {
|
||||
if (this.withBlur) {
|
||||
Column()
|
||||
.blur(CommonConstants.OVERLAY_BLUR_RADIUS)
|
||||
.width(FolderStyleConstants.PERCENTAGE_100)
|
||||
.height(FolderStyleConstants.PERCENTAGE_100)
|
||||
}
|
||||
|
||||
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center }) {
|
||||
Stack({ alignContent: Alignment.Center }) {
|
||||
Text(this.mFolderInfo.folderName) {
|
||||
}
|
||||
.fontSize(FolderStyleConstants.DEFAULT_OPEN_FOLDER_NAME_SIZE)
|
||||
.fontColor(Color.White)
|
||||
.textAlign(TextAlign.Center)
|
||||
.width(FolderStyleConstants.PERCENTAGE_100)
|
||||
.visibility(this.isRenaming ? Visibility.Hidden : Visibility.Visible)
|
||||
.onClick(() => {
|
||||
console.log('title click');
|
||||
Log.showInfo(TAG, 'title click');
|
||||
this.isRenaming = true;
|
||||
})
|
||||
TextInput({ placeholder: this.mFolderInfo.folderName, text: this.newFolderName })
|
||||
.maxLength(CommonConstants.FOLDER_NAME_MAX_LENGTH)
|
||||
.fontColor(Color.White)
|
||||
.placeholderColor(Color.White)
|
||||
.caretColor(Color.White)
|
||||
.placeholderFont({
|
||||
size: FolderStyleConstants.DEFAULT_OPEN_FOLDER_NAME_SIZE,
|
||||
weight: FontWeight.Normal,
|
||||
family: "sans-serif"
|
||||
})
|
||||
.width(FolderStyleConstants.PERCENTAGE_100)
|
||||
.visibility(this.isRenaming ? Visibility.Visible : Visibility.Hidden)
|
||||
.enterKeyType(EnterKeyType.Done)
|
||||
.border({
|
||||
width: 1,
|
||||
color: Color.White,
|
||||
radius: 10,
|
||||
style: BorderStyle.Solid
|
||||
})
|
||||
.onSubmit((enterKey: EnterKeyType) => {
|
||||
Log.showInfo(TAG, `textinput done: ` + enterKey);
|
||||
this.isRenaming = false;
|
||||
})
|
||||
.onChange((text: string) => {
|
||||
Log.showInfo(TAG, `textinput: ` + text);
|
||||
this.newFolderName = text;
|
||||
})
|
||||
}
|
||||
.width(mGridWidth)
|
||||
.height(mGridMarginTop)
|
||||
|
||||
Stack() {
|
||||
Column() {
|
||||
Swiper() {
|
||||
ForEach(this.mFolderInfo.layoutInfo, (item) => {
|
||||
FolderSwiperPage({
|
||||
mAppInfo: item
|
||||
})
|
||||
}, (item) => JSON.stringify(item))
|
||||
}
|
||||
.onClick(() => {
|
||||
console.log('Swiper click')
|
||||
if (!isOpenFolderDialog) {
|
||||
mFolderViewModel.closeFolder();
|
||||
}
|
||||
})
|
||||
.height(mGridHeight)
|
||||
.width(mGridWidth)
|
||||
.index(this.PageIndex)
|
||||
.loop(false)
|
||||
.onChange((index) => {
|
||||
Log.showInfo(TAG, `mFolderViewModel.changeIndex(index):${index}`);
|
||||
mFolderViewModel.changeIndex(index);
|
||||
})
|
||||
}
|
||||
.height(mGridHeight)
|
||||
.width(mGridWidth)
|
||||
.borderRadius(32)
|
||||
.borderColor(this.isDraging ? 'rgba(255,255,255,0.25)' : 'rgba(0,0,0,0)')
|
||||
.borderWidth(2)
|
||||
}
|
||||
}
|
||||
.width(mGridWidth)
|
||||
}
|
||||
.width(FolderStyleConstants.PERCENTAGE_100)
|
||||
.height(FolderStyleConstants.PERCENTAGE_100)
|
||||
.visibility(this.showState ? Visibility.Visible : Visibility.None)
|
||||
.opacity(this.overLayAlpha)
|
||||
.backgroundColor('rgba(0,0,0,0.25)')
|
||||
.onClick(() => {
|
||||
Log.showInfo(TAG, 'blank click')
|
||||
if (this.isRenaming) {
|
||||
this.isRenaming = false;
|
||||
if (this.newFolderName && this.newFolderName != this.mFolderInfo.folderName) {
|
||||
this.mFolderInfo.folderName = this.newFolderName;
|
||||
mFolderViewModel.modifyFolderName(this.mFolderInfo)
|
||||
}
|
||||
} else {
|
||||
if (!isOpenFolderDialog) {
|
||||
mFolderViewModel.closeFolder();
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@Component
|
||||
struct FolderSwiperPage {
|
||||
private mAppInfo: any = {};
|
||||
private ColumnsTemplate: string = '';
|
||||
private RowsTemplate: string = '';
|
||||
private mGridGap;
|
||||
|
||||
private aboutToAppear(): void {
|
||||
mFolderModel = BigFolderModel.getInstance();
|
||||
mBigFolderDragHandler = BigFolderDragHandler.getInstance();
|
||||
this.updateConfig();
|
||||
this.updateOpenFolderParams();
|
||||
}
|
||||
|
||||
private updateConfig() {
|
||||
let styleConfig = mFolderViewModel.getFolderStyleConfig();
|
||||
this.mGridGap = styleConfig.mOpenFolderGridGap;
|
||||
let openFolderConfig = mFolderModel.getFolderOpenLayout();
|
||||
|
||||
let column = openFolderConfig.column;
|
||||
let row = openFolderConfig.row;
|
||||
this.ColumnsTemplate = '';
|
||||
this.RowsTemplate = '';
|
||||
for (let i = 0; i < column; i++) {
|
||||
this.ColumnsTemplate += '1fr '
|
||||
}
|
||||
for (let i = 0; i < row; i++) {
|
||||
this.RowsTemplate += '1fr '
|
||||
}
|
||||
}
|
||||
|
||||
private async updateOpenFolderParams() {
|
||||
let screenWidth = await windowManager.getWindowWidth();
|
||||
|
||||
if (mBigFolderDragHandler != null) {
|
||||
mBigFolderDragHandler.setDragEffectArea({
|
||||
left: (screenWidth - mGridWidth) / 2,
|
||||
top: mGridMarginTop,
|
||||
right: (screenWidth - mGridWidth) / 2 + mGridWidth,
|
||||
bottom: mGridMarginTop + mGridHeight
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
folderDialogController: CustomDialogController = new CustomDialogController({
|
||||
builder: FolderAppListDialog({
|
||||
cancel: () => {},
|
||||
confirm: (isDestory) => {
|
||||
if (isDestory) {
|
||||
mFolderViewModel.closeFolder();
|
||||
}
|
||||
},
|
||||
folderItem:AppStorage.Get('openFolderData')
|
||||
}),
|
||||
customStyle: true,
|
||||
alignment: isPad ? DialogAlignment.Center : DialogAlignment.Bottom,
|
||||
cancel: () => {},
|
||||
autoCancel: true
|
||||
})
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
Grid() {
|
||||
ForEach(this.mAppInfo, (item) => {
|
||||
GridItem() {
|
||||
if (item.type === CommonConstants.TYPE_ADD) {
|
||||
Column() {
|
||||
Stack({ alignContent: Alignment.Center }) {
|
||||
Column()
|
||||
.width(FolderStyleConstants.DEFAULT_ADD_APP_SIZE)
|
||||
.height(FolderStyleConstants.DEFAULT_ADD_APP_SIZE)
|
||||
.opacity(0.5)
|
||||
.borderRadius(10)
|
||||
.backgroundColor(Color.White)
|
||||
|
||||
Image(FolderStyleConstants.DEFAULT_ADD_FOLDER_APP_IMAGE)
|
||||
.width(FolderStyleConstants.DEFAULT_ADD_APP_ICON_SIZE)
|
||||
.height(FolderStyleConstants.DEFAULT_ADD_APP_ICON_SIZE)
|
||||
}.margin({top: mGridIconTopPadding})
|
||||
|
||||
AppName({
|
||||
nameHeight: mAppNameHeight,
|
||||
nameSize: mAppNameSize,
|
||||
nameFontColor: FolderStyleConstants.DEFAULT_FONT_COLOR,
|
||||
bundleName: '',
|
||||
appName: item.appName,
|
||||
labelId: '',
|
||||
useCache: false,
|
||||
nameLines: mNameLines,
|
||||
marginTop: mIconNameMargin
|
||||
})
|
||||
}
|
||||
.width(FolderStyleConstants.PERCENTAGE_100)
|
||||
.height(FolderStyleConstants.PERCENTAGE_100)
|
||||
.onClick(() => {
|
||||
Log.showInfo(TAG, `add app to this folder`);
|
||||
this.folderDialogController.open();
|
||||
})
|
||||
} else {
|
||||
FolderAppItem({
|
||||
item: item,
|
||||
})
|
||||
}
|
||||
}
|
||||
}, (item) => JSON.stringify(item))
|
||||
}
|
||||
.margin(mGridPadding)
|
||||
.width(mGridWidth - 2 * mGridPadding)
|
||||
.height(mGridHeight - 2 * mGridPadding)
|
||||
.columnsGap(this.mGridGap)
|
||||
.rowsGap(this.mGridGap)
|
||||
.onClick(() => {
|
||||
console.log('Grid click')
|
||||
mFolderViewModel.closeFolder();
|
||||
})
|
||||
.columnsTemplate(this.ColumnsTemplate)
|
||||
.rowsTemplate(this.RowsTemplate)
|
||||
}
|
||||
.width(mGridWidth)
|
||||
.height(mGridHeight)
|
||||
}
|
||||
}
|
||||
|
||||
@Component
|
||||
struct FolderAppItem {
|
||||
@StorageLink('uninstallAppInfo') appInfo: any = {};
|
||||
@StorageLink('dragLocation') @Watch('onTouchEventUpdate') dragLocation: string = '';
|
||||
@State @Watch('onIsDraging') isDraging: boolean = false;
|
||||
@State item: any = {};
|
||||
private ColumnsTemplate: string = '';
|
||||
private RowsTemplate: string = '';
|
||||
private isSwappingPage = false;
|
||||
private willCloseFolder: boolean = false;
|
||||
private mFolderInfo: any = {};
|
||||
|
||||
private aboutToAppear(): void {
|
||||
mFolderModel = BigFolderModel.getInstance();
|
||||
}
|
||||
|
||||
private onTouchEventUpdate() {
|
||||
if (AppStorage.Get('dragFocus') == FeatureConstants.FEATURE_NAME) {
|
||||
mBigFolderDragHandler.onTouchEventUpdate(AppStorage.Get('dragEvent'));
|
||||
}
|
||||
}
|
||||
|
||||
private onIsDraging() {
|
||||
AppStorage.SetOrCreate('isDraging', this.isDraging);
|
||||
}
|
||||
|
||||
uninstallDialogController: CustomDialogController = new CustomDialogController({
|
||||
builder: UninstallDialog({
|
||||
cancel: () => {},
|
||||
confirm: () => {
|
||||
if (isPad) {
|
||||
this.mFolderInfo = mFolderViewModel.deleteAppFromOpenFolder(this.appInfo);
|
||||
} else {
|
||||
mPageDesktopViewModel.uninstallApp(this.appInfo.bundleName, this.appInfo.isUninstallAble);
|
||||
if (this.appInfo.isUninstallAble) {
|
||||
this.mFolderInfo = mFolderViewModel.deleteAppFromOpenFolder(this.appInfo);
|
||||
}
|
||||
}
|
||||
mFolderViewModel.refreshFolder(this.mFolderInfo);
|
||||
mPageDesktopViewModel.getGridList();
|
||||
},
|
||||
dialogName: isPad ? $r('app.string.delete_app') : $r('app.string.uninstall'),
|
||||
dialogContent: this.appInfo.appName + ' ?',
|
||||
}),
|
||||
cancel: () => {},
|
||||
autoCancel: true,
|
||||
customStyle: true
|
||||
});
|
||||
|
||||
formManagerDialogController: CustomDialogController = new CustomDialogController({
|
||||
builder: FormManagerDialog({
|
||||
cancel: () => {
|
||||
// delete all form
|
||||
},
|
||||
confirm: (formCardItem) => {
|
||||
// add form to desktop
|
||||
Log.showInfo(TAG, "createCardToDeskTop formCardItem: " + JSON.stringify(formCardItem));
|
||||
mPageDesktopViewModel.createCardToDeskTop(formCardItem);
|
||||
},
|
||||
bundleName: this.item.bundleName,
|
||||
appName: mPageDesktopViewModel.getAppName(this.item.appLabelId + this.item.bundleName),
|
||||
appLabelId: this.item.appLabelId
|
||||
}),
|
||||
cancel: this.cancelFormDialog,
|
||||
autoCancel: true,
|
||||
customStyle: true
|
||||
});
|
||||
|
||||
cancelFormDialog() {
|
||||
console.info('Launcher form manager cancel dialog');
|
||||
}
|
||||
|
||||
private mDragStateListener = {
|
||||
onItemDragStart: (event: any, itemIndex: number) => {
|
||||
this.isDraging = true;
|
||||
},
|
||||
onItemDragMove: (event: any, insertIndex: number, itemIndex: number) => {
|
||||
Log.showInfo(TAG, "FolderOpenComponent onItemDragMove start");
|
||||
this.uninstallDialogController.close();
|
||||
|
||||
if (this.isSwappingPage) {
|
||||
return;
|
||||
}
|
||||
|
||||
let moveX = event.touches[0].screenX;
|
||||
let moveY = event.touches[0].screenY;
|
||||
let dragEffectArea = mBigFolderDragHandler.getEffectArea();
|
||||
|
||||
this.mFolderInfo = AppStorage.Get('openFolderData');
|
||||
let pageCount = this.mFolderInfo.layoutInfo.length;
|
||||
|
||||
let pageIndex: number = mFolderViewModel.getIndex();
|
||||
Log.showInfo(TAG, "FolderOpenComponent onItemDragMove pageIndex: " + pageIndex);
|
||||
|
||||
Log.showInfo(TAG, `FolderOpenComponent onItemDragMove dragEffectArea.left: ${dragEffectArea.left}`);
|
||||
Log.showInfo(TAG, `FolderOpenComponent onItemDragMove dragEffectArea.bottom: ${dragEffectArea.bottom}`);
|
||||
Log.showInfo(TAG, `FolderOpenComponent onItemDragMove dragEffectArea.right: ${dragEffectArea.right}`);
|
||||
|
||||
if ((moveX - mAppIconSize / 2) < dragEffectArea.left && moveY < dragEffectArea.bottom ) {
|
||||
if (pageIndex > 0) {
|
||||
mFolderViewModel.changeIndex(pageIndex - 1);
|
||||
this.movingIconSwapPageDelay();
|
||||
} else if (this.willCloseFolder) {
|
||||
mFolderViewModel.closeFolder();
|
||||
} else {
|
||||
this.closeFolderDelay();
|
||||
}
|
||||
} else if ((moveX + mAppIconSize / 2) > dragEffectArea.right && moveY < dragEffectArea.bottom ) {
|
||||
if (pageIndex < pageCount - 1) {
|
||||
mFolderViewModel.changeIndex(pageIndex + 1);
|
||||
this.movingIconSwapPageDelay();
|
||||
} else if (this.willCloseFolder) {
|
||||
mFolderViewModel.closeFolder();
|
||||
} else {
|
||||
this.closeFolderDelay();
|
||||
}
|
||||
}
|
||||
},
|
||||
onItemDragEnd: () => {
|
||||
this.isDraging = false;
|
||||
}
|
||||
};
|
||||
|
||||
closeFolderDelay() {
|
||||
this.willCloseFolder = false;
|
||||
setTimeout(() => {
|
||||
this.willCloseFolder = true;
|
||||
}, FOLDER_CLOSE_DELAY);
|
||||
}
|
||||
|
||||
movingIconSwapPageDelay() {
|
||||
this.isSwappingPage = true;
|
||||
setTimeout(() => {
|
||||
this.isSwappingPage = false;
|
||||
}, APP_INFO_REFRESH_DELAY);
|
||||
}
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
Column() {
|
||||
AppBubble({
|
||||
iconSize: mAppIconSize,
|
||||
nameSize: mAppNameSize,
|
||||
nameHeight: mAppNameHeight,
|
||||
nameFontColor: FolderStyleConstants.DEFAULT_FONT_COLOR,
|
||||
appName: this.item.appName,
|
||||
bundleName: this.item.bundleName,
|
||||
appIconId: this.item.appIconId,
|
||||
appLabelId: this.item.appLabelId,
|
||||
badgeNumber: this.item.badgeNumber,
|
||||
mPaddingTop: mGridIconTopPadding,
|
||||
menuInfo: mPageDesktopViewModel.buildMenuInfoList(this.item, this.uninstallDialogController, this.formManagerDialogController),
|
||||
nameLines: mNameLines,
|
||||
mIconNameMargin: mIconNameMargin
|
||||
})
|
||||
}
|
||||
.width(mAppItemWidth)
|
||||
.height(mAppItemWidth)
|
||||
.visibility(this.isDraging ? Visibility.Hidden : Visibility.Visible)
|
||||
.onClick(() => {
|
||||
Log.showInfo(TAG, 'App click');
|
||||
mPageDesktopViewModel.openApplication(this.item.abilityName, this.item.bundleName);
|
||||
})
|
||||
.onTouch((event: TouchEvent) => {
|
||||
Log.showInfo(TAG, `onTouch`);
|
||||
AppStorage.SetOrCreate('dragFocus', FeatureConstants.FEATURE_NAME);
|
||||
mBigFolderDragHandler.setDragStateListener(this.mDragStateListener);
|
||||
mBigFolderDragHandler.notifyTouchEventUpdate(event);
|
||||
})
|
||||
}
|
||||
.width(mAppItemWidth)
|
||||
.height(mAppItemWidth)
|
||||
}
|
||||
}
|
1103
feature/bigfolder/src/main/ets/default/viewModel/FolderViewModel.ts
Normal file
1103
feature/bigfolder/src/main/ets/default/viewModel/FolderViewModel.ts
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user