mirror of
https://gitee.com/openharmony/applications_settings
synced 2024-11-23 14:30:06 +00:00
settings跳转应用详情
Signed-off-by: liminjie10 <liminjie10@huawei.com>
This commit is contained in:
parent
7850a130a6
commit
eee581a99b
46
product/phone/src/main/ets/MainAbility/AppInfoAbility.ts
Normal file
46
product/phone/src/main/ets/MainAbility/AppInfoAbility.ts
Normal file
@ -0,0 +1,46 @@
|
||||
/**
|
||||
* 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 ConfigData from '../../../../../../common/utils/src/main/ets/default/baseUtil/ConfigData';
|
||||
import LogUtil from '../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil';
|
||||
import Ability from '@ohos.application.Ability'
|
||||
|
||||
export default class MainAbility extends Ability {
|
||||
tag: string = "ApplicationInfoSettings";
|
||||
windowStage;
|
||||
onCreate(want, launchParam) {
|
||||
LogUtil.info(this.tag + ' Application onCreate');
|
||||
globalThis.abilityWant = want;
|
||||
globalThis.settingsAbilityContext = this.context;
|
||||
}
|
||||
|
||||
onDestroy() {
|
||||
LogUtil.info(this.tag + 'Application onDestroy')
|
||||
}
|
||||
|
||||
onWindowStageCreate(windowStage) {
|
||||
// Main window is created, set main page for this ability
|
||||
LogUtil.info(this.tag + " onWindowStageCreate is called");
|
||||
this.windowStage = windowStage;
|
||||
windowStage.setUIContent(this.context, "pages/applicationInfo", null);
|
||||
}
|
||||
|
||||
onNewWant(want): void {
|
||||
globalThis.abilityWant = want;
|
||||
LogUtil.info(this.tag + " onNewWant is called");
|
||||
this.windowStage?.setUIContent(this.context, "pages/applicationInfo", null);
|
||||
}
|
||||
|
||||
};
|
@ -22,6 +22,8 @@ import ConfigData from '../../../../../../common/utils/src/main/ets/default/base
|
||||
import HeadComponent from '../../../../../../common/component/src/main/ets/default/headComponent';
|
||||
import EntryComponent from '../../../../../../common/component/src/main/ets/default/entryComponent';
|
||||
import { DialogButtonLayout } from '../../../../../../common/component/src/main/ets/default/dialogComponent';
|
||||
import Bundle from '@ohos.bundle';
|
||||
import AppManagementModel from '../model/appManagementImpl/AppManagementModel';
|
||||
|
||||
const MODULE_TAG = ConfigData.TAG + 'application-> ';
|
||||
const deviceTypeInfo = deviceInfo.deviceType;
|
||||
@ -33,15 +35,17 @@ let appInfo;
|
||||
@Entry
|
||||
@Component
|
||||
struct ApplicationInfo {
|
||||
tag: string = "ApplicationInfoSettings";
|
||||
private controller: ApplicationInfoController = new ApplicationInfoController();
|
||||
@State isPhoneOrRK: boolean = false;
|
||||
@State isRemovableBundle: boolean = true;
|
||||
@State isTouchedLeft: boolean = false;
|
||||
@State isTouchedRight: boolean = false;
|
||||
private bundleName: string = " ";
|
||||
showDialog: CustomDialogController = new CustomDialogController({
|
||||
builder: ShowDialog({
|
||||
action: () => {
|
||||
this.controller.uninstall(appInfo.settingBundleName);
|
||||
this.controller.uninstall(this.bundleName);
|
||||
}
|
||||
}),
|
||||
alignment: this.isPhoneOrRK ? DialogAlignment.Bottom : DialogAlignment.Center,
|
||||
@ -105,7 +109,7 @@ struct ApplicationInfo {
|
||||
.borderRadius($r('app.float.radius_20'))
|
||||
.backgroundColor($r('sys.color.ohos_id_color_button_normal'))
|
||||
.onClick(() => {
|
||||
this.showPromptDialog(this.controller.killProcessesByBundleName.bind(this, appInfo.settingBundleName));
|
||||
this.showPromptDialog(this.controller.killProcessesByBundleName.bind(this, this.bundleName));
|
||||
})
|
||||
}
|
||||
.alignItems(VerticalAlign.Center)
|
||||
@ -153,15 +157,45 @@ struct ApplicationInfo {
|
||||
|
||||
@Log
|
||||
aboutToAppear(): void{
|
||||
LogUtil.info(this.tag + " aboutToAppear start ");
|
||||
if (deviceTypeInfo === 'phone' || deviceTypeInfo === 'default') {
|
||||
this.isPhoneOrRK = true;
|
||||
} else {
|
||||
this.isPhoneOrRK = false;
|
||||
}
|
||||
|
||||
this.getBundleName();
|
||||
this.updateRemovableStatus(this.bundleName);
|
||||
LogUtil.info(this.tag + " aboutToAppear end ");
|
||||
}
|
||||
|
||||
getBundleName(): void {
|
||||
appInfo = Router.getParams();
|
||||
LogUtil.info('settings ApplicationInfo aboutToAppear this.item:' + JSON.stringify(appInfo));
|
||||
this.updateRemovableStatus(appInfo.settingBundleName);
|
||||
LogUtil.info(this.tag + " aboutToAppear appInfo: " + JSON.stringify(appInfo));
|
||||
if (appInfo) {
|
||||
this.bundleName = appInfo.settingBundleName;
|
||||
LogUtil.info(this.tag + " aboutToAppear appInfo bundleName: " + JSON.stringify(this.bundleName));
|
||||
}
|
||||
|
||||
if (this.bundleName == " ") {
|
||||
LogUtil.info(this.tag + " Router params bundleName invalid " + JSON.stringify(appInfo));
|
||||
if (globalThis.abilityWant?.action == "action.settings.app.info") {
|
||||
this.bundleName = globalThis.abilityWant?.parameters?.settingsParamBundleName;
|
||||
LogUtil.info(this.tag + " want bundleName: " + JSON.stringify(this.bundleName));
|
||||
|
||||
let bundleList: any[] = [];
|
||||
let mBundleInfoList: any[] = [];
|
||||
Bundle.getBundleInfo(this.bundleName, Bundle.BundleFlag.GET_BUNDLE_WITH_ABILITIES)
|
||||
.then((data) => {
|
||||
LogUtil.info(this.tag + " getBundleInfo start");
|
||||
bundleList[0] = data;
|
||||
AppManagementModel.getResourceItem(0, 1, bundleList);
|
||||
mBundleInfoList = AppStorage.Get('appManagementList');
|
||||
appInfo = mBundleInfoList[0];
|
||||
LogUtil.info(this.tag + ' appInfo ' + JSON.stringify(appInfo));
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Log
|
||||
|
@ -40,6 +40,24 @@
|
||||
],
|
||||
"startWindowIcon": "$media:app_icon",
|
||||
"startWindowBackground": "$color:white",
|
||||
},
|
||||
{
|
||||
"name": "com.ohos.settings.AppInfoAbility",
|
||||
"srcEntrance": "./ets/MainAbility/AppInfoAbility.ts",
|
||||
"description": "$string:applicationInfo",
|
||||
"icon": "$media:app_icon",
|
||||
"label": "$string:applicationInfo",
|
||||
"visible": true,
|
||||
"launchType": "singleton",
|
||||
"skills": [
|
||||
{
|
||||
"actions": [
|
||||
"action.settings.app.info"
|
||||
]
|
||||
}
|
||||
],
|
||||
"startWindowIcon": "$media:app_icon",
|
||||
"startWindowBackground": "$color:white",
|
||||
}
|
||||
],
|
||||
"requestPermissions": [
|
||||
|
Loading…
Reference in New Issue
Block a user