提交 e0b71bf2 编写于 作者: C chengxingzhen

fix codex

Signed-off-by: Nchengxingzhen <chengxingzhen@huawei.com>
上级 560a6bbb
/*
* 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 formManager from '@ohos.ability.formmanager';
import bundleManager from '@ohos.bundle';
import abilityManager from '@ohos.app.abilityManager';
export default class FormViewModel {
private static sFormViewModel: FormViewModel = null;
public static getInstance(): FormViewModel {
if (FormViewModel.sFormViewModel == null) {
FormViewModel.sFormViewModel = new FormViewModel();
}
return FormViewModel.sFormViewModel;
}
public async castTempFormToNormal(formId: string) {
formManager.castTempForm(formId)
.then((data) => {
console.info('[FormComponent] castTempForm result:' + data);
});
}
public async requestForm(formId: string) {
formManager.requestForm(formId)
.then((data) => {
console.info('[FormComponent] requestForm result:' + data);
});
}
public async deleteCard(formId: string) {
formManager.deleteForm(formId)
.then((data) => {
console.info('[FormComponent] deleteForm result:' + data);
});
}
public async releaseCard(formId: string) {
formManager.releaseForm(formId)
.then((data) => {
console.info('[FormComponent] releaseForm result:' + data);
});
}
public async enableCard(formId: string) {
formManager.enableFormsUpdate([formId])
.then((data) => {
console.info('[FormComponent] enableFormsUpdate result:' + data);
});
}
public async disableCard(formId: string) {
formManager.disableFormsUpdate([formId])
.then((data) => {
console.info('[FormComponent] disableCard result:' + data);
});
}
public async changeCardVisible(formId: string, isVisible: boolean) {
if (isVisible) {
formManager.notifyVisibleForms([formId])
.then((data) => {
console.info('[FormComponent] changeCardVisible result:' + data + ', isVisible:' + isVisible);
});
} else {
formManager.notifyInvisibleForms([formId])
.then((data) => {
console.info('[FormComponent] changeCardVisible result:' + data + ', isVisible:' + isVisible);
});
}
}
public async isFmsReady() {
formManager.isSystemReady()
.then((data) => {
console.info('[FormComponent] isFmsReady result:' + data);
});
}
public async getAllFormsInfo() {
formManager.getAllFormsInfo()
.then((data) => {
console.info('[FormComponent] getAllFormsInfo result:' + JSON.stringify(data));
});
}
public async getFormsInfoByApp(bundle: string) {
formManager.getFormsInfo(bundle)
.then((data) => {
console.info('[FormComponent] getFormsInfoByApp result:' + JSON.stringify(data));
});
}
public async getFormsInfoByModule(bundle: string, moduleName: string) {
formManager.getFormsInfo(bundle, moduleName)
.then((data) => {
console.info('[FormComponent] getFormsInfoByModule result:' + JSON.stringify(data));
});
}
public async clearFormUserCache() {
abilityManager.clearUpApplicationData('com.ohos.myapplicationform')
.then((data) => {
console.info('[FormComponent] cleanBundleCacheFiles result:' + JSON.stringify(data));
});
}
public async clearFormProviderCache(bundle: string) {
abilityManager.clearUpApplicationData(bundle)
.then((data) => {
console.info('[FormComponent] cleanBundleCacheFiles result:' + JSON.stringify(data));
});
}
}
\ No newline at end of file
......@@ -13,11 +13,10 @@
* limitations under the License.
*/
import FormViewModel from './FormViewModel.ets';
import router from '@system.router';
import featureAbility from "@ohos.ability.featureAbility";
import formManager from '@ohos.application.formHost'
import commonEvent from '@ohos.commonEvent';
import featureAbility from "@ohos.ability.featureAbility";
import formManager from '@ohos.application.formHost';
@Entry
@Component
struct Index {
......@@ -26,10 +25,7 @@ struct Index {
@State ability: string = "com.form.formsystemtestservicea.hmservice.MainAbility";
@State moduleName: string = "entry";
@State name: string = "Form_Js001";
@State width: number = 300;
@State height: number = 200;
@State allowUpate: boolean = true;
@State onAcquireResult: string = "";
@State isShowing: boolean = true;
@State canCreateForm: boolean = false;
private dimension: FormDimension = FormDimension.Dimension_1_2;
......@@ -38,12 +34,7 @@ struct Index {
private deleteId = "-1";
private temporaryId = "-1";
private temporary = false;
private mFormViewModel: FormViewModel;
private isVisible = false;
private mMargin = 15;
private BTN_BG_COLOR: string = '#0D9FFB';
private castForm = false;
private tempFormId: number = 0;
private formOnAcquiredEvent = "FMS_FormOnAcquired_commonEvent";
private formCastEvent = "FMS_FormCast_commonEvent";
......@@ -84,16 +75,7 @@ struct Index {
console.info("!!!====>formsystemhost deleteCallBack end ====>");
}
private unSubscribeDeleteCallback() {
console.debug("====>formsystemhost unSubscribeDeleteCallback_1100 CallBack====>");
}
private aboutToAppear() {
const TAG = "[FormComponent.host]"
this.mFormViewModel = FormViewModel.getInstance();
commonEvent.createSubscriber(this.subscriberFormDeleteEvent).then(async (data) => {
console.info("====>formsystemhost Subscriber FormDelete data:====>", JSON.stringify(data));
this.subscriberDel = data;
......@@ -297,9 +279,6 @@ struct Index {
.onError((error) => {
console.log("[FormComponent.host] error code:" + error.errcode);
console.log("[FormComponent.host] error msg:" + error.msg);
this.onAcquireResult += error.errcode;
this.onAcquireResult += " ";
this.onAcquireResult += error.msg;
if (this.deleteForm && this.deleteId) {
let commonEventPublishData = {
data: error.msg,
......
/*
* 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 formManager from '@ohos.ability.formmanager';
import bundleManager from '@ohos.bundle';
import abilityManager from '@ohos.app.abilityManager';
export default class FormViewModel {
private static sFormViewModel: FormViewModel = null;
public static getInstance(): FormViewModel {
if (FormViewModel.sFormViewModel == null) {
FormViewModel.sFormViewModel = new FormViewModel();
}
return FormViewModel.sFormViewModel;
}
public async castTempFormToNormal(formId: string) {
formManager.castTempForm(formId)
.then((data) => {
console.info('[FormComponent] castTempForm result:' + data);
});
}
public async requestForm(formId: string) {
formManager.requestForm(formId)
.then((data) => {
console.info('[FormComponent] requestForm result:' + data);
});
}
public async deleteCard(formId: string) {
formManager.deleteForm(formId)
.then((data) => {
console.info('[FormComponent] deleteForm result:' + data);
});
}
public async releaseCard(formId: string) {
formManager.releaseForm(formId)
.then((data) => {
console.info('[FormComponent] releaseForm result:' + data);
});
}
public async enableCard(formId: string) {
formManager.enableFormsUpdate([formId])
.then((data) => {
console.info('[FormComponent] enableFormsUpdate result:' + data);
});
}
public async disableCard(formId: string) {
formManager.disableFormsUpdate([formId])
.then((data) => {
console.info('[FormComponent] disableCard result:' + data);
});
}
public async changeCardVisible(formId: string, isVisible: boolean) {
if (isVisible) {
formManager.notifyVisibleForms([formId])
.then((data) => {
console.info('[FormComponent] changeCardVisible result:' + data + ', isVisible:' + isVisible);
});
} else {
formManager.notifyInvisibleForms([formId])
.then((data) => {
console.info('[FormComponent] changeCardVisible result:' + data + ', isVisible:' + isVisible);
});
}
}
public async isFmsReady() {
formManager.isSystemReady()
.then((data) => {
console.info('[FormComponent] isFmsReady result:' + data);
});
}
public async getAllFormsInfo() {
formManager.getAllFormsInfo()
.then((data) => {
console.info('[FormComponent] getAllFormsInfo result:' + JSON.stringify(data));
});
}
public async getFormsInfoByApp(bundle: string) {
formManager.getFormsInfo(bundle)
.then((data) => {
console.info('[FormComponent] getFormsInfoByApp result:' + JSON.stringify(data));
});
}
public async getFormsInfoByModule(bundle: string, moduleName: string) {
formManager.getFormsInfo(bundle, moduleName)
.then((data) => {
console.info('[FormComponent] getFormsInfoByModule result:' + JSON.stringify(data));
});
}
public async clearFormUserCache() {
abilityManager.clearUpApplicationData('com.ohos.myapplicationform')
.then((data) => {
console.info('[FormComponent] cleanBundleCacheFiles result:' + JSON.stringify(data));
});
}
public async clearFormProviderCache(bundle: string) {
abilityManager.clearUpApplicationData(bundle)
.then((data) => {
console.info('[FormComponent] cleanBundleCacheFiles result:' + JSON.stringify(data));
});
}
}
\ No newline at end of file
......@@ -13,11 +13,9 @@
* limitations under the License.
*/
import FormViewModel from './FormViewModel.ets';
import router from '@system.router';
import featureAbility from "@ohos.ability.featureAbility";
import formManager from '@ohos.application.formHost'
import commonEvent from '@ohos.commonEvent';
import featureAbility from "@ohos.ability.featureAbility";
import formManager from '@ohos.application.formHost';
@Entry
@Component
......@@ -26,11 +24,8 @@ struct Index {
@State bundle: string = "com.form.formsystemtestservicea.hmservice";
@State ability: string = "com.form.formsystemtestservicea.hmservice.MainAbility";
@State moduleName: string = "entry";
@State name: string = "Form_Js001";
@State width: number = 300;
@State height: number = 200;
@State name: string = "Form_Js001";
@State allowUpate: boolean = true;
@State onAcquireResult: string = "";
@State isShowing: boolean = true;
@State canCreateForm: boolean = false;
......@@ -40,12 +35,7 @@ struct Index {
private deleteId = "-1";
private temporaryId="-1";
private temporary = false;
private mFormViewModel: FormViewModel;
private isVisible = false;
private mMargin = 15;
private BTN_BG_COLOR: string = '#0D9FFB';
private castForm = false;
private tempFormId: number = 0;
private formOnAcquiredEvent = "FMS_FormOnAcquired_commonEvent";
private formCastEvent = "FMS_FormCast_commonEvent";
......@@ -80,16 +70,7 @@ struct Index {
console.info("!!!====>formsystemhost deleteCallBack end ====>");
}
private unSubscribeDeleteCallback() {
console.debug("====>formsystemhost unSubscribeDeleteCallback_1100 CallBack====>");
}
private aboutToAppear() {
const TAG = "[FormComponent.host]"
this.mFormViewModel = FormViewModel.getInstance();
commonEvent.createSubscriber(this.subscriberFormDeleteEvent).then(async (data) => {
console.info("====>formsystemhost Subscriber FormDelete data:====>", JSON.stringify(data));
this.subscriberDle = data;
......@@ -255,9 +236,6 @@ struct Index {
.onError((error) => {
console.log("[FormComponent.host] error code:" + error.errcode);
console.log("[FormComponent.host] error msg:" + error.msg);
this.onAcquireResult += error.errcode;
this.onAcquireResult += " ";
this.onAcquireResult += error.msg;
if(this.deleteForm && this.deleteId) {
let commonEventPublishData = {
data: error.msg,
......
/*
* 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 formManager from '@ohos.ability.formmanager';
import bundleManager from '@ohos.bundle';
import abilityManager from '@ohos.app.abilityManager';
export default class FormViewModel {
private static sFormViewModel: FormViewModel = null;
public static getInstance(): FormViewModel {
if (FormViewModel.sFormViewModel == null) {
FormViewModel.sFormViewModel = new FormViewModel();
}
return FormViewModel.sFormViewModel;
}
public async castTempFormToNormal(formId: string) {
formManager.castTempForm(formId)
.then((data) => {
console.info('[FormComponent] castTempForm result:' + data);
});
}
public async requestForm(formId: string) {
formManager.requestForm(formId)
.then((data) => {
console.info('[FormComponent] requestForm result:' + data);
});
}
public async deleteCard(formId: string) {
formManager.deleteForm(formId)
.then((data) => {
console.info('[FormComponent] deleteForm result:' + data);
});
}
public async releaseCard(formId: string) {
formManager.releaseForm(formId)
.then((data) => {
console.info('[FormComponent] releaseForm result:' + data);
});
}
public async enableCard(formId: string) {
formManager.enableFormsUpdate([formId])
.then((data) => {
console.info('[FormComponent] enableFormsUpdate result:' + data);
});
}
public async disableCard(formId: string) {
formManager.disableFormsUpdate([formId])
.then((data) => {
console.info('[FormComponent] disableCard result:' + data);
});
}
public async changeCardVisible(formId: string, isVisible: boolean) {
if (isVisible) {
formManager.notifyVisibleForms([formId])
.then((data) => {
console.info('[FormComponent] changeCardVisible result:' + data + ', isVisible:' + isVisible);
});
} else {
formManager.notifyInvisibleForms([formId])
.then((data) => {
console.info('[FormComponent] changeCardVisible result:' + data + ', isVisible:' + isVisible);
});
}
}
public async isFmsReady() {
formManager.isSystemReady()
.then((data) => {
console.info('[FormComponent] isFmsReady result:' + data);
});
}
public async getAllFormsInfo() {
formManager.getAllFormsInfo()
.then((data) => {
console.info('[FormComponent] getAllFormsInfo result:' + JSON.stringify(data));
});
}
public async getFormsInfoByApp(bundle: string) {
formManager.getFormsInfo(bundle)
.then((data) => {
console.info('[FormComponent] getFormsInfoByApp result:' + JSON.stringify(data));
});
}
public async getFormsInfoByModule(bundle: string, moduleName: string) {
formManager.getFormsInfo(bundle, moduleName)
.then((data) => {
console.info('[FormComponent] getFormsInfoByModule result:' + JSON.stringify(data));
});
}
public async clearFormUserCache() {
abilityManager.clearUpApplicationData('com.ohos.myapplicationform')
.then((data) => {
console.info('[FormComponent] cleanBundleCacheFiles result:' + JSON.stringify(data));
});
}
public async clearFormProviderCache(bundle: string) {
abilityManager.clearUpApplicationData(bundle)
.then((data) => {
console.info('[FormComponent] cleanBundleCacheFiles result:' + JSON.stringify(data));
});
}
}
\ No newline at end of file
/*
* 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 formManager from '@ohos.ability.formmanager';
import bundleManager from '@ohos.bundle';
import abilityManager from '@ohos.app.abilityManager';
export default class FormViewModel {
private static sFormViewModel: FormViewModel = null;
public static getInstance(): FormViewModel {
if (FormViewModel.sFormViewModel == null) {
FormViewModel.sFormViewModel = new FormViewModel();
}
return FormViewModel.sFormViewModel;
}
public async castTempFormToNormal(formId: string) {
formManager.castTempForm(formId)
.then((data) => {
console.info('[FormComponent] castTempForm result:' + data);
});
}
public async requestForm(formId: string) {
formManager.requestForm(formId)
.then((data) => {
console.info('[FormComponent] requestForm result:' + data);
});
}
public async deleteCard(formId: string) {
formManager.deleteForm(formId)
.then((data) => {
console.info('[FormComponent] deleteForm result:' + data);
});
}
public async releaseCard(formId: string) {
formManager.releaseForm(formId)
.then((data) => {
console.info('[FormComponent] releaseForm result:' + data);
});
}
public async enableCard(formId: string) {
formManager.enableFormsUpdate([formId])
.then((data) => {
console.info('[FormComponent] enableFormsUpdate result:' + data);
});
}
public async disableCard(formId: string) {
formManager.disableFormsUpdate([formId])
.then((data) => {
console.info('[FormComponent] disableCard result:' + data);
});
}
public async changeCardVisible(formId: string, isVisible: boolean) {
if (isVisible) {
formManager.notifyVisibleForms([formId])
.then((data) => {
console.info('[FormComponent] changeCardVisible result:' + data + ', isVisible:' + isVisible);
});
} else {
formManager.notifyInvisibleForms([formId])
.then((data) => {
console.info('[FormComponent] changeCardVisible result:' + data + ', isVisible:' + isVisible);
});
}
}
public async isFmsReady() {
formManager.isSystemReady()
.then((data) => {
console.info('[FormComponent] isFmsReady result:' + data);
});
}
public async getAllFormsInfo() {
formManager.getAllFormsInfo()
.then((data) => {
console.info('[FormComponent] getAllFormsInfo result:' + JSON.stringify(data));
});
}
public async getFormsInfoByApp(bundle: string) {
formManager.getFormsInfo(bundle)
.then((data) => {
console.info('[FormComponent] getFormsInfoByApp result:' + JSON.stringify(data));
});
}
public async getFormsInfoByModule(bundle: string, moduleName: string) {
formManager.getFormsInfo(bundle, moduleName)
.then((data) => {
console.info('[FormComponent] getFormsInfoByModule result:' + JSON.stringify(data));
});
}
public async clearFormUserCache() {
abilityManager.clearUpApplicationData('com.ohos.myapplicationform')
.then((data) => {
console.info('[FormComponent] cleanBundleCacheFiles result:' + JSON.stringify(data));
});
}
public async clearFormProviderCache(bundle: string) {
abilityManager.clearUpApplicationData(bundle)
.then((data) => {
console.info('[FormComponent] cleanBundleCacheFiles result:' + JSON.stringify(data));
});
}
}
\ No newline at end of file
......@@ -13,11 +13,9 @@
* limitations under the License.
*/
import FormViewModel from './FormViewModel.ets';
import router from '@system.router';
import featureAbility from "@ohos.ability.featureAbility";
import formManager from '@ohos.application.formHost'
import commonEvent from '@ohos.commonEvent';
import featureAbility from "@ohos.ability.featureAbility";
import formManager from '@ohos.application.formHost';
@Entry
@Component
......@@ -26,11 +24,8 @@ struct Index {
@State bundle: string = "com.form.formsystemtestservicea.hmservice";
@State ability: string = "com.form.formsystemtestservicea.hmservice.MainAbility";
@State moduleName: string = "entry";
@State name: string = "Form_Js001";
@State width: number = 300;
@State height: number = 200;
@State name: string = "Form_Js001";
@State allowUpate: boolean = true;
@State onAcquireResult: string = "";
@State isShowing: boolean = true;
@State canCreateForm: boolean = false;
......@@ -42,12 +37,7 @@ struct Index {
private deleteId = "-1";
private temporaryId="-1";
private temporary = false;
private mFormViewModel: FormViewModel;
private isVisible = false;
private mMargin = 15;
private BTN_BG_COLOR: string = '#0D9FFB';
private castForm = false;
private tempFormId: number = 0;
private formOnAcquiredEvent = "FMS_FormOnAcquired_commonEvent";
private formCastEvent = "FMS_FormCast_commonEvent";
......@@ -93,16 +83,7 @@ struct Index {
console.info("!!!====>formsystemhost deleteCallBack end ====>");
}
private unSubscribeDeleteCallback() {
console.debug("====>formsystemhost unSubscribeDeleteCallback_1100 CallBack====>");
}
private aboutToAppear() {
const TAG = "[FormComponent.host]"
this.mFormViewModel = FormViewModel.getInstance();
commonEvent.createSubscriber(this.subscriberFormDeleteEvent).then(async (data) => {
console.info("====>formsystemhost Subscriber FormDelete data:====>", JSON.stringify(data));
this.subscriberDel = data;
......@@ -327,9 +308,6 @@ struct Index {
.onError((error) => {
console.log("[FormComponent.host] error code:" + error.errcode);
console.log("[FormComponent.host] error msg:" + error.msg);
this.onAcquireResult += error.errcode;
this.onAcquireResult += " ";
this.onAcquireResult += error.msg;
if(this.deleteForm && this.deleteId) {
let commonEventPublishData = {
data: error.msg,
......
/*
* 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 formManager from '@ohos.ability.formmanager';
import bundleManager from '@ohos.bundle';
import abilityManager from '@ohos.app.abilityManager';
export default class FormViewModel {
private static sFormViewModel: FormViewModel = null;
public static getInstance(): FormViewModel {
if (FormViewModel.sFormViewModel == null) {
FormViewModel.sFormViewModel = new FormViewModel();
}
return FormViewModel.sFormViewModel;
}
public async castTempFormToNormal(formId: string) {
formManager.castTempForm(formId)
.then((data) => {
console.info('[FormComponent] castTempForm result:' + data);
});
}
public async requestForm(formId: string) {
formManager.requestForm(formId)
.then((data) => {
console.info('[FormComponent] requestForm result:' + data);
});
}
public async deleteCard(formId: string) {
formManager.deleteForm(formId)
.then((data) => {
console.info('[FormComponent] deleteForm result:' + data);
});
}
public async releaseCard(formId: string) {
formManager.releaseForm(formId)
.then((data) => {
console.info('[FormComponent] releaseForm result:' + data);
});
}
public async enableCard(formId: string) {
formManager.enableFormsUpdate([formId])
.then((data) => {
console.info('[FormComponent] enableFormsUpdate result:' + data);
});
}
public async disableCard(formId: string) {
formManager.disableFormsUpdate([formId])
.then((data) => {
console.info('[FormComponent] disableCard result:' + data);
});
}
public async changeCardVisible(formId: string, isVisible: boolean) {
if (isVisible) {
formManager.notifyVisibleForms([formId])
.then((data) => {
console.info('[FormComponent] changeCardVisible result:' + data + ', isVisible:' + isVisible);
});
} else {
formManager.notifyInvisibleForms([formId])
.then((data) => {
console.info('[FormComponent] changeCardVisible result:' + data + ', isVisible:' + isVisible);
});
}
}
public async isFmsReady() {
formManager.isSystemReady()
.then((data) => {
console.info('[FormComponent] isFmsReady result:' + data);
});
}
public async getAllFormsInfo() {
formManager.getAllFormsInfo()
.then((data) => {
console.info('[FormComponent] getAllFormsInfo result:' + JSON.stringify(data));
});
}
public async getFormsInfoByApp(bundle: string) {
formManager.getFormsInfo(bundle)
.then((data) => {
console.info('[FormComponent] getFormsInfoByApp result:' + JSON.stringify(data));
});
}
public async getFormsInfoByModule(bundle: string, moduleName: string) {
formManager.getFormsInfo(bundle, moduleName)
.then((data) => {
console.info('[FormComponent] getFormsInfoByModule result:' + JSON.stringify(data));
});
}
public async clearFormUserCache() {
abilityManager.clearUpApplicationData('com.ohos.myapplicationform')
.then((data) => {
console.info('[FormComponent] cleanBundleCacheFiles result:' + JSON.stringify(data));
});
}
public async clearFormProviderCache(bundle: string) {
abilityManager.clearUpApplicationData(bundle)
.then((data) => {
console.info('[FormComponent] cleanBundleCacheFiles result:' + JSON.stringify(data));
});
}
}
\ No newline at end of file
......@@ -13,12 +13,10 @@
* limitations under the License.
*/
import FormViewModel from './FormViewModel.ets';
import router from '@system.router';
import featureAbility from '@ohos.ability.featureAbility';
import formManager from '@ohos.application.formHost'
import formProvider from '@ohos.application.formProvider'
import commonEvent from '@ohos.commonEvent';
import featureAbility from '@ohos.ability.featureAbility';
import formManager from '@ohos.application.formHost';
import formProvider from '@ohos.application.formProvider';
@Entry
@Component
......@@ -28,10 +26,7 @@ struct Index {
@State ability: string = "com.form.formsystemtestservicea.hmservice.MainAbility";
@State moduleName: string = "entry";
@State name: string = "Form_Js001";
@State width: number = 300;
@State height: number = 200;
@State allowUpate: boolean = true;
@State onAcquireResult: string = "";
@State isShowing: boolean = true;
@State canCreateForm: boolean = false;
......@@ -48,11 +43,6 @@ struct Index {
private deleteId = "-1";
private temporaryId = "-1";
private temporary = false;
private mFormViewModel: FormViewModel;
private isVisible = false;
private mMargin = 15;
private BTN_BG_COLOR: string = '#0D9FFB';
private tempFormId: number = 0;
private formOnAcquiredEvent = "FMS_FormOnAcquired_commonEvent";
private formOnErrorEvent = "FMS_FormOnError_commonEvent";
......@@ -77,10 +67,6 @@ struct Index {
this.canCreateForm = false;
console.debug("====>formsystemhostc formOnDynamicRefreshEventk ====>");
}
private formOnNotifyVisibleFormsCallBack() {
this.canCreateForm = false;
console.debug("====>formsystemhostc formOnDynamicRefreshEventk ====>");
}
private formOnRequestCallBack() {
this.canCreateForm = false;
console.debug("====>formsystemhostc formOnRequestCallBack ====>");
......@@ -103,16 +89,7 @@ struct Index {
console.info("!!!====>formsystemhost deleteCallBack end ====>");
}
private unSubscribeDeleteCallback() {
console.debug("====>formsystemhost unSubscribeDeleteCallback_1100 CallBack====>");
}
private aboutToAppear() {
const TAG = "[FormComponent.host]"
this.mFormViewModel = FormViewModel.getInstance();
commonEvent.createSubscriber(this.subscriberFormDeleteEvent).then(async (data) => {
console.info("====>formsystemhost Subscriber FormDelete data:====>", JSON.stringify(data));
this.subscriberDel = data;
......@@ -414,9 +391,6 @@ struct Index {
.onError((error) => {
console.log("[FormComponent.host] error code:" + error.errcode);
console.log("[FormComponent.host] error msg:" + error.msg);
this.onAcquireResult += error.errcode;
this.onAcquireResult += " ";
this.onAcquireResult += error.msg;
if (this.deleteForm && this.deleteId) {
let commonEventPublishData = {
data: error.msg,
......
/*
* 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 formManager from '@ohos.ability.formmanager';
import bundleManager from '@ohos.bundle';
import abilityManager from '@ohos.app.abilityManager';
export default class FormViewModel {
private static sFormViewModel: FormViewModel = null;
public static getInstance(): FormViewModel {
if (FormViewModel.sFormViewModel == null) {
FormViewModel.sFormViewModel = new FormViewModel();
}
return FormViewModel.sFormViewModel;
}
public async castTempFormToNormal(formId: string) {
formManager.castTempForm(formId)
.then((data) => {
console.info('[FormComponent] castTempForm result:' + data);
});
}
public async requestForm(formId: string) {
formManager.requestForm(formId)
.then((data) => {
console.info('[FormComponent] requestForm result:' + data);
});
}
public async deleteCard(formId: string) {
formManager.deleteForm(formId)
.then((data) => {
console.info('[FormComponent] deleteForm result:' + data);
});
}
public async releaseCard(formId: string) {
formManager.releaseForm(formId)
.then((data) => {
console.info('[FormComponent] releaseForm result:' + data);
});
}
public async enableCard(formId: string) {
formManager.enableFormsUpdate([formId])
.then((data) => {
console.info('[FormComponent] enableFormsUpdate result:' + data);
});
}
public async disableCard(formId: string) {
formManager.disableFormsUpdate([formId])
.then((data) => {
console.info('[FormComponent] disableCard result:' + data);
});
}
public async changeCardVisible(formId: string, isVisible: boolean) {
if (isVisible) {
formManager.notifyVisibleForms([formId])
.then((data) => {
console.info('[FormComponent] changeCardVisible result:' + data + ', isVisible:' + isVisible);
});
} else {
formManager.notifyInvisibleForms([formId])
.then((data) => {
console.info('[FormComponent] changeCardVisible result:' + data + ', isVisible:' + isVisible);
});
}
}
public async isFmsReady() {
formManager.isSystemReady()
.then((data) => {
console.info('[FormComponent] isFmsReady result:' + data);
});
}
public async getAllFormsInfo() {
formManager.getAllFormsInfo()
.then((data) => {
console.info('[FormComponent] getAllFormsInfo result:' + JSON.stringify(data));
});
}
public async getFormsInfoByApp(bundle: string) {
formManager.getFormsInfo(bundle)
.then((data) => {
console.info('[FormComponent] getFormsInfoByApp result:' + JSON.stringify(data));
});
}
public async getFormsInfoByModule(bundle: string, moduleName: string) {
formManager.getFormsInfo(bundle, moduleName)
.then((data) => {
console.info('[FormComponent] getFormsInfoByModule result:' + JSON.stringify(data));
});
}
public async clearFormUserCache() {
abilityManager.clearUpApplicationData('com.ohos.myapplicationform')
.then((data) => {
console.info('[FormComponent] cleanBundleCacheFiles result:' + JSON.stringify(data));
});
}
public async clearFormProviderCache(bundle: string) {
abilityManager.clearUpApplicationData(bundle)
.then((data) => {
console.info('[FormComponent] cleanBundleCacheFiles result:' + JSON.stringify(data));
});
}
}
\ No newline at end of file
/*
* 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 formManager from '@ohos.ability.formmanager';
import bundleManager from '@ohos.bundle';
import abilityManager from '@ohos.app.abilityManager';
export default class FormViewModel {
private static sFormViewModel: FormViewModel = null;
public static getInstance(): FormViewModel {
if (FormViewModel.sFormViewModel == null) {
FormViewModel.sFormViewModel = new FormViewModel();
}
return FormViewModel.sFormViewModel;
}
public async castTempFormToNormal(formId: string) {
formManager.castTempForm(formId)
.then((data) => {
console.info('[FormComponent] castTempForm result:' + data);
});
}
public async requestForm(formId: string) {
formManager.requestForm(formId)
.then((data) => {
console.info('[FormComponent] requestForm result:' + data);
});
}
public async deleteCard(formId: string) {
formManager.deleteForm(formId)
.then((data) => {
console.info('[FormComponent] deleteForm result:' + data);
});
}
public async releaseCard(formId: string) {
formManager.releaseForm(formId)
.then((data) => {
console.info('[FormComponent] releaseForm result:' + data);
});
}
public async enableCard(formId: string) {
formManager.enableFormsUpdate([formId])
.then((data) => {
console.info('[FormComponent] enableFormsUpdate result:' + data);
});
}
public async disableCard(formId: string) {
formManager.disableFormsUpdate([formId])
.then((data) => {
console.info('[FormComponent] disableCard result:' + data);
});
}
public async changeCardVisible(formId: string, isVisible: boolean) {
if (isVisible) {
formManager.notifyVisibleForms([formId])
.then((data) => {
console.info('[FormComponent] changeCardVisible result:' + data + ', isVisible:' + isVisible);
});
} else {
formManager.notifyInvisibleForms([formId])
.then((data) => {
console.info('[FormComponent] changeCardVisible result:' + data + ', isVisible:' + isVisible);
});
}
}
public async isFmsReady() {
formManager.isSystemReady()
.then((data) => {
console.info('[FormComponent] isFmsReady result:' + data);
});
}
public async getAllFormsInfo() {
formManager.getAllFormsInfo()
.then((data) => {
console.info('[FormComponent] getAllFormsInfo result:' + JSON.stringify(data));
});
}
public async getFormsInfoByApp(bundle: string) {
formManager.getFormsInfo(bundle)
.then((data) => {
console.info('[FormComponent] getFormsInfoByApp result:' + JSON.stringify(data));
});
}
public async getFormsInfoByModule(bundle: string, moduleName: string) {
formManager.getFormsInfo(bundle, moduleName)
.then((data) => {
console.info('[FormComponent] getFormsInfoByModule result:' + JSON.stringify(data));
});
}
public async clearFormUserCache() {
abilityManager.clearUpApplicationData('com.ohos.myapplicationform')
.then((data) => {
console.info('[FormComponent] cleanBundleCacheFiles result:' + JSON.stringify(data));
});
}
public async clearFormProviderCache(bundle: string) {
abilityManager.clearUpApplicationData(bundle)
.then((data) => {
console.info('[FormComponent] cleanBundleCacheFiles result:' + JSON.stringify(data));
});
}
}
\ No newline at end of file
/*
* 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 formManager from '@ohos.application.formHost';
import bundleManager from '@ohos.bundle';
import abilityManager from '@ohos.app.abilityManager';
export default class FormViewModel {
private static sFormViewModel: FormViewModel = null;
public static getInstance(): FormViewModel {
if (FormViewModel.sFormViewModel == null) {
FormViewModel.sFormViewModel = new FormViewModel();
}
return FormViewModel.sFormViewModel;
}
public async castTempFormToNormal(formId: string) {
formManager.castTempForm(formId)
.then((data) => {
console.info('[FormComponent] castTempForm result:' + data);
});
}
public async requestForm(formId: string) {
formManager.requestForm(formId)
.then((data) => {
console.info('[FormComponent] requestForm result:' + data);
});
}
public async deleteCard(formId: string) {
formManager.deleteForm(formId)
.then((data) => {
console.info('[FormComponent] deleteForm result:' + data);
});
}
public async releaseCard(formId: string) {
formManager.releaseForm(formId)
.then((data) => {
console.info('[FormComponent] releaseForm result:' + data);
});
}
public async enableCard(formId: string) {
formManager.enableFormsUpdate([formId])
.then((data) => {
console.info('[FormComponent] enableFormsUpdate result:' + data);
});
}
public async disableCard(formId: string) {
formManager.disableFormsUpdate([formId])
.then((data) => {
console.info('[FormComponent] disableCard result:' + data);
});
}
public async changeCardVisible(formId: string, isVisible: boolean) {
if (isVisible) {
formManager.notifyVisibleForms([formId])
.then((data) => {
console.info('[FormComponent] changeCardVisible result:' + data + ', isVisible:' + isVisible);
});
} else {
formManager.notifyInvisibleForms([formId])
.then((data) => {
console.info('[FormComponent] changeCardVisible result:' + data + ', isVisible:' + isVisible);
});
}
}
public async isFmsReady() {
formManager.isSystemReady()
.then((data) => {
console.info('[FormComponent] isFmsReady result:' + data);
});
}
public async getAllFormsInfo() {
formManager.getAllFormsInfo()
.then((data) => {
console.info('[FormComponent] getAllFormsInfo result:' + JSON.stringify(data));
});
}
public async getFormsInfoByApp(bundle: string) {
formManager.getFormsInfo(bundle)
.then((data) => {
console.info('[FormComponent] getFormsInfoByApp result:' + JSON.stringify(data));
});
}
public async getFormsInfoByModule(bundle: string, moduleName: string) {
formManager.getFormsInfo(bundle, moduleName)
.then((data) => {
console.info('[FormComponent] getFormsInfoByModule result:' + JSON.stringify(data));
});
}
public async clearFormUserCache() {
abilityManager.clearUpApplicationData('com.ohos.myapplicationform')
.then((data) => {
console.info('[FormComponent] cleanBundleCacheFiles result:' + JSON.stringify(data));
});
}
public async clearFormProviderCache(bundle: string) {
abilityManager.clearUpApplicationData(bundle)
.then((data) => {
console.info('[FormComponent] cleanBundleCacheFiles result:' + JSON.stringify(data));
});
}
}
\ No newline at end of file
......@@ -13,10 +13,10 @@
* limitations under the License.
*/
import commonEvent from '@ohos.commonEvent';
import featureAbility from "@ohos.ability.featureAbility";
import formManager from '@ohos.application.formHost';
import commonEvent from '@ohos.commonEvent';
import FormViewModel from './FormViewModel.ets';
@Entry
@Component
struct Index {
......@@ -25,10 +25,7 @@ struct Index {
@State ability: string = "com.form.formsystemtestservicea.hmservice.MainAbility";
@State moduleName: string = "entry";
@State name: string = "Form_Js001";
@State width: number = 300;
@State height: number = 200;
@State allowUpate: boolean = true;
@State onAcquireResult: string = "";
@State isShowing: boolean = true;
@State canCreateForm: boolean = false;
......@@ -37,12 +34,7 @@ struct Index {
private deleteId = "-1";
private temporaryId = "-1";
private temporary = false;
private mFormViewModel: FormViewModel;
private isVisible = false;
private mMargin = 15;
private BTN_BG_COLOR: string = '#0D9FFB';
private castForm = false;
private tempFormId: number = 0;
private formOnAcquiredEvent = "FMS_FormOnAcquired_commonEvent";
private formCastEvent = "FMS_FormCast_commonEvent";
......@@ -78,16 +70,7 @@ struct Index {
console.info("!!!====>formsystemhost deleteCallBack end ====>");
}
private unSubscribeDeleteCallback() {
console.info("====>formsystemhost unSubscribeDeleteCallback_1100 CallBack====>");
}
private aboutToAppear() {
const TAG = "[FormComponent.host]"
this.mFormViewModel = FormViewModel.getInstance();
commonEvent.createSubscriber(this.subscriberFormDeleteEvent).then(async (data) => {
console.info("====>formsystemhost Subscriber FormDelete data:====>", JSON.stringify(data));
this.subscriberDel = data;
......@@ -282,9 +265,6 @@ struct Index {
.onError((error) => {
console.info("[FormComponent.host] error code:" + error.errcode);
console.info("[FormComponent.host] error msg:" + error.msg);
this.onAcquireResult += error.errcode;
this.onAcquireResult += " ";
this.onAcquireResult += error.msg;
if (this.deleteForm && this.deleteId) {
let commonEventPublishData = {
data: error.msg,
......
/*
* 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 formManager from '@ohos.ability.formmanager';
import bundleManager from '@ohos.bundle';
import abilityManager from '@ohos.app.abilityManager';
export default class FormViewModel {
private static sFormViewModel: FormViewModel = null;
public static getInstance(): FormViewModel {
if (FormViewModel.sFormViewModel == null) {
FormViewModel.sFormViewModel = new FormViewModel();
}
return FormViewModel.sFormViewModel;
}
public async castTempFormToNormal(formId: string) {
formManager.castTempForm(formId)
.then((data) => {
console.info('[FormComponent] castTempForm result:' + data);
});
}
public async requestForm(formId: string) {
formManager.requestForm(formId)
.then((data) => {
console.info('[FormComponent] requestForm result:' + data);
});
}
public async deleteCard(formId: string) {
formManager.deleteForm(formId)
.then((data) => {
console.info('[FormComponent] deleteForm result:' + data);
});
}
public async releaseCard(formId: string) {
formManager.releaseForm(formId)
.then((data) => {
console.info('[FormComponent] releaseForm result:' + data);
});
}
public async enableCard(formId: string) {
formManager.enableFormsUpdate([formId])
.then((data) => {
console.info('[FormComponent] enableFormsUpdate result:' + data);
});
}
public async disableCard(formId: string) {
formManager.disableFormsUpdate([formId])
.then((data) => {
console.info('[FormComponent] disableCard result:' + data);
});
}
public async changeCardVisible(formId: string, isVisible: boolean) {
if (isVisible) {
formManager.notifyVisibleForms([formId])
.then((data) => {
console.info('[FormComponent] changeCardVisible result:' + data + ', isVisible:' + isVisible);
});
} else {
formManager.notifyInvisibleForms([formId])
.then((data) => {
console.info('[FormComponent] changeCardVisible result:' + data + ', isVisible:' + isVisible);
});
}
}
public async isFmsReady() {
formManager.isSystemReady()
.then((data) => {
console.info('[FormComponent] isFmsReady result:' + data);
});
}
public async getAllFormsInfo() {
formManager.getAllFormsInfo()
.then((data) => {
console.info('[FormComponent] getAllFormsInfo result:' + JSON.stringify(data));
});
}
public async getFormsInfoByApp(bundle: string) {
formManager.getFormsInfo(bundle)
.then((data) => {
console.info('[FormComponent] getFormsInfoByApp result:' + JSON.stringify(data));
});
}
public async getFormsInfoByModule(bundle: string, moduleName: string) {
formManager.getFormsInfo(bundle, moduleName)
.then((data) => {
console.info('[FormComponent] getFormsInfoByModule result:' + JSON.stringify(data));
});
}
public async clearFormUserCache() {
abilityManager.clearUpApplicationData('com.ohos.myapplicationform')
.then((data) => {
console.info('[FormComponent] cleanBundleCacheFiles result:' + JSON.stringify(data));
});
}
public async clearFormProviderCache(bundle: string) {
abilityManager.clearUpApplicationData(bundle)
.then((data) => {
console.info('[FormComponent] cleanBundleCacheFiles result:' + JSON.stringify(data));
});
}
}
\ No newline at end of file
......@@ -13,11 +13,10 @@
* limitations under the License.
*/
import FormViewModel from './FormViewModel.ets';
import router from '@system.router';
import featureAbility from "@ohos.ability.featureAbility";
import formManager from '@ohos.application.formHost'
import commonEvent from '@ohos.commonEvent';
import featureAbility from "@ohos.ability.featureAbility";
import formManager from '@ohos.application.formHost';
@Entry
@Component
struct Index {
......@@ -25,11 +24,8 @@ struct Index {
@State bundle: string = "com.form.formsystemtestservicea.hmservice";
@State ability: string = "com.form.formsystemtestservicea.hmservice.MainAbility";
@State moduleName: string = "entry";
@State name: string = "Form_Js001";
@State width: number = 300;
@State height: number = 200;
@State name: string = "Form_Js001";
@State allowUpate: boolean = true;
@State onAcquireResult: string = "";
@State isShowing: boolean = true;
@State canCreateForm: boolean = false;
private dimension: FormDimension = FormDimension.Dimension_1_2;
......@@ -38,12 +34,7 @@ struct Index {
private deleteId = "-1";
private temporaryId="-1";
private temporary = false;
private mFormViewModel: FormViewModel;
private isVisible = false;
private mMargin = 15;
private BTN_BG_COLOR: string = '#0D9FFB';
private castForm = false;
private tempFormId: number = 0;
private formOnAcquiredEvent = "FMS_FormOnAcquired_commonEvent";
private formCastEvent = "FMS_FormCast_commonEvent";
......@@ -79,16 +70,7 @@ struct Index {
console.info("!!!====>formsystemhostj deleteCallBack end ====>");
}
private unSubscribeDeleteCallback() {
console.debug("====>formsystemhostj unSubscribeDeleteCallback_1100 CallBack====>");
}
private aboutToAppear() {
const TAG = "[FormComponent.host]"
this.mFormViewModel = FormViewModel.getInstance();
commonEvent.createSubscriber(this.subscriberFormDeleteEvent).then(async (data) => {
console.info("====>formsystemhostj Subscriber FormDelete data:====>", JSON.stringify(data));
this.subscriberDel = data;
......@@ -283,9 +265,6 @@ struct Index {
.onError((error) => {
console.log("[FormComponent.host] error code:" + error.errcode);
console.log("[FormComponent.host] error msg:" + error.msg);
this.onAcquireResult += error.errcode;
this.onAcquireResult += " ";
this.onAcquireResult += error.msg;
if(this.deleteForm && this.deleteId) {
let commonEventPublishData = {
data: error.msg,
......
/*
* 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 formManager from '@ohos.ability.formmanager';
import bundleManager from '@ohos.bundle';
import abilityManager from '@ohos.app.abilityManager';
export default class FormViewModel {
private static sFormViewModel: FormViewModel = null;
public static getInstance(): FormViewModel {
if (FormViewModel.sFormViewModel == null) {
FormViewModel.sFormViewModel = new FormViewModel();
}
return FormViewModel.sFormViewModel;
}
public async castTempFormToNormal(formId: string) {
formManager.castTempForm(formId)
.then((data) => {
console.info('[FormComponent] castTempForm result:' + data);
});
}
public async requestForm(formId: string) {
formManager.requestForm(formId)
.then((data) => {
console.info('[FormComponent] requestForm result:' + data);
});
}
public async deleteCard(formId: string) {
formManager.deleteForm(formId)
.then((data) => {
console.info('[FormComponent] deleteForm result:' + data);
});
}
public async releaseCard(formId: string) {
formManager.releaseForm(formId)
.then((data) => {
console.info('[FormComponent] releaseForm result:' + data);
});
}
public async enableCard(formId: string) {
formManager.enableFormsUpdate([formId])
.then((data) => {
console.info('[FormComponent] enableFormsUpdate result:' + data);
});
}
public async disableCard(formId: string) {
formManager.disableFormsUpdate([formId])
.then((data) => {
console.info('[FormComponent] disableCard result:' + data);
});
}
public async changeCardVisible(formId: string, isVisible: boolean) {
if (isVisible) {
formManager.notifyVisibleForms([formId])
.then((data) => {
console.info('[FormComponent] changeCardVisible result:' + data + ', isVisible:' + isVisible);
});
} else {
formManager.notifyInvisibleForms([formId])
.then((data) => {
console.info('[FormComponent] changeCardVisible result:' + data + ', isVisible:' + isVisible);
});
}
}
public async isFmsReady() {
formManager.isSystemReady()
.then((data) => {
console.info('[FormComponent] isFmsReady result:' + data);
});
}
public async getAllFormsInfo() {
formManager.getAllFormsInfo()
.then((data) => {
console.info('[FormComponent] getAllFormsInfo result:' + JSON.stringify(data));
});
}
public async getFormsInfoByApp(bundle: string) {
formManager.getFormsInfo(bundle)
.then((data) => {
console.info('[FormComponent] getFormsInfoByApp result:' + JSON.stringify(data));
});
}
public async getFormsInfoByModule(bundle: string, moduleName: string) {
formManager.getFormsInfo(bundle, moduleName)
.then((data) => {
console.info('[FormComponent] getFormsInfoByModule result:' + JSON.stringify(data));
});
}
public async clearFormUserCache() {
abilityManager.clearUpApplicationData('com.ohos.myapplicationform')
.then((data) => {
console.info('[FormComponent] cleanBundleCacheFiles result:' + JSON.stringify(data));
});
}
public async clearFormProviderCache(bundle: string) {
abilityManager.clearUpApplicationData(bundle)
.then((data) => {
console.info('[FormComponent] cleanBundleCacheFiles result:' + JSON.stringify(data));
});
}
}
\ No newline at end of file
/*
* 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 formManager from '@ohos.ability.formmanager';
import bundleManager from '@ohos.bundle';
import abilityManager from '@ohos.app.abilityManager';
export default class FormViewModel {
private static sFormViewModel: FormViewModel = null;
public static getInstance(): FormViewModel {
if (FormViewModel.sFormViewModel == null) {
FormViewModel.sFormViewModel = new FormViewModel();
}
return FormViewModel.sFormViewModel;
}
public async castTempFormToNormal(formId: string) {
formManager.castTempForm(formId)
.then((data) => {
console.info('[FormComponent] castTempForm result:' + data);
});
}
public async requestForm(formId: string) {
formManager.requestForm(formId)
.then((data) => {
console.info('[FormComponent] requestForm result:' + data);
});
}
public async deleteCard(formId: string) {
formManager.deleteForm(formId)
.then((data) => {
console.info('[FormComponent] deleteForm result:' + data);
});
}
public async releaseCard(formId: string) {
formManager.releaseForm(formId)
.then((data) => {
console.info('[FormComponent] releaseForm result:' + data);
});
}
public async enableCard(formId: string) {
formManager.enableFormsUpdate([formId])
.then((data) => {
console.info('[FormComponent] enableFormsUpdate result:' + data);
});
}
public async disableCard(formId: string) {
formManager.disableFormsUpdate([formId])
.then((data) => {
console.info('[FormComponent] disableCard result:' + data);
});
}
public async changeCardVisible(formId: string, isVisible: boolean) {
if (isVisible) {
formManager.notifyVisibleForms([formId])
.then((data) => {
console.info('[FormComponent] changeCardVisible result:' + data + ', isVisible:' + isVisible);
});
} else {
formManager.notifyInvisibleForms([formId])
.then((data) => {
console.info('[FormComponent] changeCardVisible result:' + data + ', isVisible:' + isVisible);
});
}
}
public async isFmsReady() {
formManager.isSystemReady()
.then((data) => {
console.info('[FormComponent] isFmsReady result:' + data);
});
}
public async getAllFormsInfo() {
formManager.getAllFormsInfo()
.then((data) => {
console.info('[FormComponent] getAllFormsInfo result:' + JSON.stringify(data));
});
}
public async getFormsInfoByApp(bundle: string) {
formManager.getFormsInfo(bundle)
.then((data) => {
console.info('[FormComponent] getFormsInfoByApp result:' + JSON.stringify(data));
});
}
public async getFormsInfoByModule(bundle: string, moduleName: string) {
formManager.getFormsInfo(bundle, moduleName)
.then((data) => {
console.info('[FormComponent] getFormsInfoByModule result:' + JSON.stringify(data));
});
}
public async clearFormUserCache() {
abilityManager.clearUpApplicationData('com.ohos.myapplicationform')
.then((data) => {
console.info('[FormComponent] cleanBundleCacheFiles result:' + JSON.stringify(data));
});
}
public async clearFormProviderCache(bundle: string) {
abilityManager.clearUpApplicationData(bundle)
.then((data) => {
console.info('[FormComponent] cleanBundleCacheFiles result:' + JSON.stringify(data));
});
}
}
\ No newline at end of file
......@@ -13,7 +13,6 @@
* limitations under the License.
*/
import FormViewModel from './FormViewModel.ets';
import commonEvent from '@ohos.commonEvent';
import featureAbility from '@ohos.ability.featureAbility';
import formManager from '@ohos.application.formHost';
......@@ -32,7 +31,6 @@ struct Index {
@State isShowing: boolean = true;
@State dimension: FormDimension = FormDimension.Dimension_1_2;
@State temporary: boolean = false;
private mFormViewModel: FormViewModel;
private requestForm = false;
private requestId = `-1`;
private subscriberDel;
......@@ -57,8 +55,6 @@ struct Index {
}
async private aboutToAppear() {
this.mFormViewModel = FormViewModel.getInstance();
const onDeleteEventSubscriber = await commonEvent.createSubscriber(this.subscriberFormDeleteEvent);
commonEvent.subscribe(onDeleteEventSubscriber, async (err, data) => {
console.info(`${this.TAG} deleteCallBack start:====> ${JSON.stringify(data)}`);
......
/*
* 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 formManager from '@ohos.ability.formmanager';
import bundleManager from '@ohos.bundle';
import abilityManager from '@ohos.app.abilityManager';
export default class FormViewModel {
private static sFormViewModel: FormViewModel = null;
public static getInstance(): FormViewModel {
if (FormViewModel.sFormViewModel == null) {
FormViewModel.sFormViewModel = new FormViewModel();
}
return FormViewModel.sFormViewModel;
}
public async castTempFormToNormal(formId: string) {
formManager.castTempForm(formId)
.then((data) => {
console.info('[FormComponent] castTempForm result:' + data);
});
}
public async requestForm(formId: string) {
formManager.requestForm(formId)
.then((data) => {
console.info('[FormComponent] requestForm result:' + data);
});
}
public async deleteCard(formId: string) {
formManager.deleteForm(formId)
.then((data) => {
console.info('[FormComponent] deleteForm result:' + data);
});
}
public async releaseCard(formId: string) {
formManager.releaseForm(formId)
.then((data) => {
console.info('[FormComponent] releaseForm result:' + data);
});
}
public async enableCard(formId: string) {
formManager.enableFormsUpdate([formId])
.then((data) => {
console.info('[FormComponent] enableFormsUpdate result:' + data);
});
}
public async disableCard(formId: string) {
formManager.disableFormsUpdate([formId])
.then((data) => {
console.info('[FormComponent] disableCard result:' + data);
});
}
public async changeCardVisible(formId: string, isVisible: boolean) {
if (isVisible) {
formManager.notifyVisibleForms([formId])
.then((data) => {
console.info('[FormComponent] changeCardVisible result:' + data + ', isVisible:' + isVisible);
});
} else {
formManager.notifyInvisibleForms([formId])
.then((data) => {
console.info('[FormComponent] changeCardVisible result:' + data + ', isVisible:' + isVisible);
});
}
}
public async isFmsReady() {
formManager.isSystemReady()
.then((data) => {
console.info('[FormComponent] isFmsReady result:' + data);
});
}
public async getAllFormsInfo() {
formManager.getAllFormsInfo()
.then((data) => {
console.info('[FormComponent] getAllFormsInfo result:' + JSON.stringify(data));
});
}
public async getFormsInfoByApp(bundle: string) {
formManager.getFormsInfo(bundle)
.then((data) => {
console.info('[FormComponent] getFormsInfoByApp result:' + JSON.stringify(data));
});
}
public async getFormsInfoByModule(bundle: string, moduleName: string) {
formManager.getFormsInfo(bundle, moduleName)
.then((data) => {
console.info('[FormComponent] getFormsInfoByModule result:' + JSON.stringify(data));
});
}
public async clearFormUserCache() {
abilityManager.clearUpApplicationData('com.ohos.myapplicationform')
.then((data) => {
console.info('[FormComponent] cleanBundleCacheFiles result:' + JSON.stringify(data));
});
}
public async clearFormProviderCache(bundle: string) {
abilityManager.clearUpApplicationData(bundle)
.then((data) => {
console.info('[FormComponent] cleanBundleCacheFiles result:' + JSON.stringify(data));
});
}
}
\ No newline at end of file
......@@ -2,7 +2,7 @@
"string": [
{
"name": "entry_MainAbility",
"value": "formhostB"
"value": "formhostNoPerm"
},
{
"name": "description_mainability",
......
/*
* 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 formManager from '@ohos.ability.formmanager';
import bundleManager from '@ohos.bundle';
export default class FormViewModel {
private static sFormViewModel: FormViewModel = null;
public static getInstance(): FormViewModel {
if (FormViewModel.sFormViewModel == null) {
FormViewModel.sFormViewModel = new FormViewModel();
}
return FormViewModel.sFormViewModel;
}
public async requestForm(formId: string) {
formManager.requestForm(formId)
.then((data) => {
console.info( '[FormComponent] requestForm result:' + data);
});
}
public async deleteCard(formId: string) {
formManager.deleteForm(formId)
.then((data) => {
console.info('[FormComponent] deleteForm result:' + data);
});
}
public async releaseCard(formId: string) {
formManager.releaseForm(formId)
.then((data) => {
console.info('[FormComponent] releaseForm result:' + data);
});
}
public async castTempToNormal(formId: string) {
formManager.castTempForm(formId)
.then((data) => {
console.info('[FormComponent] castTempToNormal result:' + data);
});
}
public async enableCard(formId: string) {
formManager.enableFormsUpdate([formId])
.then((data) => {
console.info('[FormComponent] enableFormsUpdate result:' + data);
});
}
public async disableCard(formId: string) {
formManager.disableFormsUpdate([formId])
.then((data) => {
console.info('[FormComponent] disableCard result:' + data);
});
}
public async changeCardVisible(formId: string, isVisible: boolean) {
if (isVisible) {
formManager.notifyVisibleForms([formId])
.then((data) => {
console.info('[FormComponent] changeCardVisible result:' + data + ', isVisible:' + isVisible);
});
} else {
formManager.notifyInvisibleForms([formId])
.then((data) => {
console.info('[FormComponent] changeCardVisible result:' + data + ', isVisible:' + isVisible);
});
}
}
public async isFmsReady() {
formManager.isSystemReady()
.then((data) => {
console.info('[FormComponent] isFmsReady result:' + data);
});
}
public async getAllFormsInfo() {
console.info("[FormComponent] getAllFormsInfo start");
formManager.getAllFormsInfo()
.then((data) => {
console.info('[FormComponent] getAllFormsInfo result:' + JSON.stringify(data));
})
.catch((err) => {
console.info('[FormComponent] getAllFormsInfo error:' + JSON.stringify(err));
});
console.info("[FormComponent] getAllFormsInfo end");
}
public async getFormsInfoByApp(bundle: string) {
formManager.getFormsInfo(bundle)
.then((data) => {
console.info('[FormComponent] getFormsInfoByApp result:' + JSON.stringify(data));
});
}
public async getFormsInfoByModule(bundle: string, moduleName: string) {
formManager.getFormsInfo(bundle, moduleName)
.then((data) => {
console.info('[FormComponent] getFormsInfoByModule result:' + JSON.stringify(data));
});
}
public async clearFormUserCache() {
bundleManager.cleanBundleCacheFiles('com.ohos.myapplicationform')
.then((data) => {
console.info('[FormComponent] cleanBundleCacheFiles result:' + JSON.stringify(data));
});
}
public async clearFormProviderCache(bundle: string) {
bundleManager.cleanBundleCacheFiles(bundle)
.then((data) => {
console.info('[FormComponent] cleanBundleCacheFiles result:' + JSON.stringify(data));
});
}
}
\ No newline at end of file
/*
* 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 formManager from '@ohos.ability.formmanager';
import bundleManager from '@ohos.bundle';
export default class FormViewModel {
private static sFormViewModel: FormViewModel = null;
public static getInstance(): FormViewModel {
if (FormViewModel.sFormViewModel == null) {
FormViewModel.sFormViewModel = new FormViewModel();
}
return FormViewModel.sFormViewModel;
}
public async requestForm(formId: string) {
formManager.requestForm(formId)
.then((data) => {
console.info( '[FormComponent] requestForm result:' + data);
});
}
public async deleteCard(formId: string) {
formManager.deleteForm(formId)
.then((data) => {
console.info('[FormComponent] deleteForm result:' + data);
});
}
public async releaseCard(formId: string) {
formManager.releaseForm(formId)
.then((data) => {
console.info('[FormComponent] releaseForm result:' + data);
});
}
public async castTempToNormal(formId: string) {
formManager.castTempForm(formId)
.then((data) => {
console.info('[FormComponent] castTempToNormal result:' + data);
});
}
public async enableCard(formId: string) {
formManager.enableFormsUpdate([formId])
.then((data) => {
console.info('[FormComponent] enableFormsUpdate result:' + data);
});
}
public async disableCard(formId: string) {
formManager.disableFormsUpdate([formId])
.then((data) => {
console.info('[FormComponent] disableCard result:' + data);
});
}
public async changeCardVisible(formId: string, isVisible: boolean) {
if (isVisible) {
formManager.notifyVisibleForms([formId])
.then((data) => {
console.info('[FormComponent] changeCardVisible result:' + data + ', isVisible:' + isVisible);
});
} else {
formManager.notifyInvisibleForms([formId])
.then((data) => {
console.info('[FormComponent] changeCardVisible result:' + data + ', isVisible:' + isVisible);
});
}
}
public async isFmsReady() {
formManager.isSystemReady()
.then((data) => {
console.info('[FormComponent] isFmsReady result:' + data);
});
}
public async getAllFormsInfo() {
console.info("[FormComponent] getAllFormsInfo start");
formManager.getAllFormsInfo()
.then((data) => {
console.info('[FormComponent] getAllFormsInfo result:' + JSON.stringify(data));
})
.catch((err) => {
console.info('[FormComponent] getAllFormsInfo error:' + JSON.stringify(err));
});
console.info("[FormComponent] getAllFormsInfo end");
}
public async getFormsInfoByApp(bundle: string) {
formManager.getFormsInfo(bundle)
.then((data) => {
console.info('[FormComponent] getFormsInfoByApp result:' + JSON.stringify(data));
});
}
public async getFormsInfoByModule(bundle: string, moduleName: string) {
formManager.getFormsInfo(bundle, moduleName)
.then((data) => {
console.info('[FormComponent] getFormsInfoByModule result:' + JSON.stringify(data));
});
}
public async clearFormUserCache() {
bundleManager.cleanBundleCacheFiles('com.ohos.myapplicationform')
.then((data) => {
console.info('[FormComponent] cleanBundleCacheFiles result:' + JSON.stringify(data));
});
}
public async clearFormProviderCache(bundle: string) {
bundleManager.cleanBundleCacheFiles(bundle)
.then((data) => {
console.info('[FormComponent] cleanBundleCacheFiles result:' + JSON.stringify(data));
});
}
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册