diff --git a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/entryability/EntryAbility.ts b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/entryability/EntryAbility.ts index ba5dcdafca81f67a20996b50c5c9382e7c40a040..3525105f633fa8fa47303f9567a189a94997ebd2 100644 --- a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/entryability/EntryAbility.ts +++ b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/entryability/EntryAbility.ts @@ -13,6 +13,7 @@ * limitations under the License. */ +// [Start entry_ability] import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; import { window } from '@kit.ArkUI'; import { hilog } from '@kit.PerformanceAnalysisKit'; @@ -74,4 +75,5 @@ export default class EntryAbility extends UIAbility { hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); }); } -} \ No newline at end of file +} +// [End entry_ability] \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/entryformability/EntryFormAbility.ts b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/entryformability/EntryFormAbility.ts index 3166a0106d4f95a87672520c750bc686dbe13e0d..450aa79cb6ee45848700857445d7417962c4bed7 100644 --- a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/entryformability/EntryFormAbility.ts +++ b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/entryformability/EntryFormAbility.ts @@ -13,15 +13,23 @@ * limitations under the License. */ +// [Start import_entry_form_ability] +// [Start update_form_interface] import { formBindingData, FormExtensionAbility, formInfo, formProvider } from '@kit.FormKit'; +// [StartExclude update_form_interface] import { Configuration, Want } from '@kit.AbilityKit'; +// [EndExclude update_form_interface] import { BusinessError } from '@kit.BasicServicesKit'; import { hilog } from '@kit.PerformanceAnalysisKit'; +// [End import_entry_form_ability] +// [Start form_extension_ability_interface] const TAG: string = 'EntryFormAbility'; const DOMAIN_NUMBER: number = 0xFF00; +// [Start form_extension_lifecycle_interface] export default class EntryFormAbility extends FormExtensionAbility { + // [StartExclude update_form_interface] onAddForm(want: Want): formBindingData.FormBindingData { hilog.info(DOMAIN_NUMBER, TAG, '[EntryFormAbility] onAddForm'); hilog.info(DOMAIN_NUMBER, TAG, want.parameters?.[formInfo.FormParam.NAME_KEY] as string); @@ -53,10 +61,11 @@ export default class EntryFormAbility extends FormExtensionAbility { hilog.info(DOMAIN_NUMBER, TAG, '[EntryFormAbility] onChangeFormVisibility'); } + // [EndExclude update_form_interface] onFormEvent(formId: string, message: string): void { // Called when a specified message event defined by the form provider is triggered. hilog.info(DOMAIN_NUMBER, TAG, `FormAbility onFormEvent, formId = ${formId}, message: ${JSON.stringify(message)}`); - + // [StartExclude form_extension_lifecycle_interface] class FormDataClass { title: string = 'Title Update.'; // 和卡片布局中对应 detail: string = 'Description update success.'; // 和卡片布局中对应 @@ -69,8 +78,10 @@ export default class EntryFormAbility extends FormExtensionAbility { }).catch((error) => { hilog.error(DOMAIN_NUMBER, TAG, `Operation updateForm failed. Cause: ${JSON.stringify(error)}`); }); + // [EndExclude form_extension_lifecycle_interface] } + // [StartExclude update_form_interface] onRemoveForm(formId: string): void { // 删除卡片实例数据 hilog.info(DOMAIN_NUMBER, TAG, '[EntryFormAbility] onRemoveForm'); @@ -78,14 +89,20 @@ export default class EntryFormAbility extends FormExtensionAbility { // 此接口请根据实际情况实现,具体请参考:FormExtAbility Stage模型卡片实例 } + // [StartExclude form_extension_lifecycle_interface] onConfigurationUpdate(config: Configuration) { // 当前formExtensionAbility存活时更新系统配置信息时触发的回调。 // 需注意:formExtensionAbility创建后10秒内无操作将会被清理。 hilog.info(DOMAIN_NUMBER, TAG, '[EntryFormAbility] onConfigurationUpdate:' + JSON.stringify(config)); } + // [EndExclude form_extension_lifecycle_interface] onAcquireFormState(want: Want): formInfo.FormState { // Called to return a {@link FormState} object. return formInfo.FormState.READY; } -} \ No newline at end of file + // [EndExclude update_form_interface] +} +// [End form_extension_ability_interface] +// [End update_form_interface] +// [End form_extension_lifecycle_interface] \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/funpages/FunA.ets b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/funpages/FunA.ets index a46e5733d95cc77e41175fe486aef507cc2ef1ad..d6b18aab7491b9f35ed7cb744c6fd3dca68b113c 100644 --- a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/funpages/FunA.ets +++ b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/funpages/FunA.ets @@ -13,6 +13,7 @@ * limitations under the License. */ +// [Start fun_a] @Entry @Component struct FunA { @@ -43,4 +44,5 @@ struct FunA { .width('100%') .height('100%') } -} \ No newline at end of file +} +// [End fun_a] \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/jscardentryability/JsCardEntryAbility.ts b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/jscardentryability/JsCardEntryAbility.ts index 2afbd3d94e27b198f8fdb2d3413901727b91a0dd..50606008c4110d1b3bc51d6da82a7605ee42d72c 100644 --- a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/jscardentryability/JsCardEntryAbility.ts +++ b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/jscardentryability/JsCardEntryAbility.ts @@ -13,6 +13,8 @@ * limitations under the License. */ +// [Start js_card_entry_ability] +// [Start receive_router_event] import type AbilityConstant from '@ohos.app.ability.AbilityConstant'; import hilog from '@ohos.hilog'; import UIAbility from '@ohos.app.ability.UIAbility'; @@ -21,12 +23,13 @@ import type window from '@ohos.window'; const TAG: string = 'JsCardEntryAbility'; const DOMAIN_NUMBER: number = 0xFF00; +// [End js_card_entry_ability] export default class JsCardEntryAbility extends UIAbility { onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { if (want.parameters) { let params: Record = JSON.parse(JSON.stringify(want.parameters.params)); - if (params.info === 'router info') { + if (params.info === 'router info') { hilog.info(DOMAIN_NUMBER, TAG, `router info: ${params.info}`); } if (params.message === 'router message') { @@ -35,6 +38,7 @@ export default class JsCardEntryAbility extends UIAbility { } } + // [StartExclude receive_router_event] onWindowStageCreate(windowStage: window.WindowStage): void { // Main window is created, set main page for this ability hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onWindowStageCreate'); @@ -47,4 +51,6 @@ export default class JsCardEntryAbility extends UIAbility { hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); }); } -} \ No newline at end of file + // [EndExclude receive_router_event] +} +// [End receive_router_event] \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/jscardformability/JsCardFormAbility.ts b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/jscardformability/JsCardFormAbility.ts index efe0212011b39e752f8d7a4264f8f2dfbd0c7b41..8a4c31c431a64a64f12582cd77a70b350ab229d7 100644 --- a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/jscardformability/JsCardFormAbility.ts +++ b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/jscardformability/JsCardFormAbility.ts @@ -13,17 +13,30 @@ * limitations under the License. */ +// [Start js_card_form_ability] +// [Start remove_form_interface] +// [Start update_form_interface] import { common, Want } from '@kit.AbilityKit'; +// [Start receive_message_interface] import { hilog } from '@kit.PerformanceAnalysisKit'; import { formBindingData, FormExtensionAbility, formInfo, formProvider } from '@kit.FormKit'; +// [StartExclude receive_message_interface] import { BusinessError } from '@kit.BasicServicesKit'; import { preferences } from '@kit.ArkData'; import { Configuration } from '@kit.ArkUI'; +// [EndExclude receive_message_interface] const TAG: string = 'JsCardFormAbility'; +// [StartExclude update_form_interface] +// [StartExclude receive_message_interface] const DATA_STORAGE_PATH: string = '/data/storage/el2/base/haps/form_store'; +// [EndExclude update_form_interface] +// [EndExclude receive_message_interface] const DOMAIN_NUMBER: number = 0xFF00; +// [StartExclude remove_form_interface] +// [StartExclude update_form_interface] +// [StartExclude receive_message_interface] let storeFormInfo = async (formId: string, formName: string, tempFlag: boolean, context: common.FormExtensionContext): Promise => { // 此处仅对卡片ID:formId,卡片名:formName和是否为临时卡片:tempFlag进行了持久化 @@ -45,6 +58,8 @@ let storeFormInfo = ; }; +// [StartExclude js_card_form_ability] +// [EndExclude remove_form_interface] let deleteFormInfo = async (formId: string, context: common.FormExtensionContext): Promise => { try { const storage: preferences.Preferences = await preferences.getPreferences(context, DATA_STORAGE_PATH); @@ -58,8 +73,13 @@ let deleteFormInfo = async (formId: string, context: common.FormExtensionContext } ; }; - +// [EndExclude js_card_form_ability] +// [EndExclude update_form_interface] +// [EndExclude receive_message_interface] export default class JsCardFormAbility extends FormExtensionAbility { + // [StartExclude remove_form_interface] + // [StartExclude update_form_interface] + // [StartExclude receive_message_interface] onAddForm(want: Want): formBindingData.FormBindingData { hilog.info(DOMAIN_NUMBER, TAG, '[JsCardFormAbility] onAddForm'); @@ -81,11 +101,13 @@ export default class JsCardFormAbility extends FormExtensionAbility { return formData; } + // [StartExclude js_card_form_ability] onCastToNormalForm(formId: string): void { // 使用方将临时卡片转换为常态卡片触发,提供方需要做相应的处理 hilog.info(DOMAIN_NUMBER, TAG, '[EntryFormAbility] onCastToNormalForm'); } + // [EndExclude update_form_interface] onUpdateForm(formId: string): void { // 若卡片支持定时更新/定点更新/卡片使用方主动请求更新功能,则提供方需要重写该方法以支持数据更新 hilog.info(DOMAIN_NUMBER, TAG, '[EntryFormAbility] onUpdateForm'); @@ -98,11 +120,13 @@ export default class JsCardFormAbility extends FormExtensionAbility { hilog.info(DOMAIN_NUMBER, TAG, '[EntryFormAbility] updateForm, error:' + JSON.stringify(error)); }); } + // [StartExclude update_form_interface] onChangeFormVisibility(newStatus: Record): void { // 使用方发起可见或者不可见通知触发,提供方需要做相应的处理,仅系统应用生效 hilog.info(DOMAIN_NUMBER, TAG, '[EntryFormAbility] onChangeFormVisibility'); } + // [EndExclude receive_message_interface] onFormEvent(formId: string, message: string): void { // 若卡片支持触发事件,则需要重写该方法并实现对事件的触发 @@ -114,7 +138,8 @@ export default class JsCardFormAbility extends FormExtensionAbility { hilog.info(DOMAIN_NUMBER, TAG, 'message info:' + msg.detail); } } - + // [StartExclude receive_message_interface] + // [EndExclude remove_form_interface] onRemoveForm(formId: string): void { // 删除卡片实例数据 hilog.info(DOMAIN_NUMBER, TAG, '[EntryFormAbility] onRemoveForm'); @@ -122,6 +147,7 @@ export default class JsCardFormAbility extends FormExtensionAbility { // 此接口请根据实际情况实现,具体请参考:FormExtAbility Stage模型卡片实例 deleteFormInfo(formId, this.context); } + // [StartExclude js_card_form_ability] onConfigurationUpdate(config: Configuration) { // 当前formExtensionAbility存活时更新系统配置信息时触发的回调。 @@ -133,4 +159,12 @@ export default class JsCardFormAbility extends FormExtensionAbility { // 卡片提供方接收查询卡片状态通知接口,默认返回卡片初始状态。 return formInfo.FormState.READY; } -} \ No newline at end of file + // [EndExclude js_card_form_ability] + // [EndExclude remove_form_interface] + // [EndExclude update_form_interface] + // [EndExclude receive_message_interface] +} +// [End js_card_form_ability] +// [End remove_form_interface] +// [End update_form_interface] +// [End receive_message_interface] \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/persistentdataformability/PersistentDataFormAbility.ts b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/persistentdataformability/PersistentDataFormAbility.ts index 5da2361e5bc955d855ff5a4d5f597a4a82977897..2745b1322f1faf624de6c630ae3f1f77a2ad0cd5 100644 --- a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/persistentdataformability/PersistentDataFormAbility.ts +++ b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/persistentdataformability/PersistentDataFormAbility.ts @@ -13,6 +13,7 @@ * limitations under the License. */ +// [Start persistent_data_form_ability] import { formBindingData, FormExtensionAbility, formInfo } from '@kit.FormKit'; import { Want } from '@kit.AbilityKit'; import { dataShare } from '@kit.ArkData'; @@ -47,9 +48,11 @@ export default class PersistentDataFormAbility extends FormExtensionAbility { }; return formBinding; } - + // [StartExclude persistent_data_form_ability] onAcquireFormState(want: Want): formInfo.FormState { // Called to return a {@link FormState} object. return formInfo.FormState.READY; } -} \ No newline at end of file + // [EndExclude persistent_data_form_ability] +} +// [End persistent_data_form_ability] \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/processdataentryability/ProcessDataFormAbility.ts b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/processdataentryability/ProcessDataFormAbility.ts index 6647cfb27506a59ed48da0198849b192c3b0a35b..7d74ac123059cb31c5db9f8e3e48215a0a24a816 100644 --- a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/processdataentryability/ProcessDataFormAbility.ts +++ b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/processdataentryability/ProcessDataFormAbility.ts @@ -13,6 +13,7 @@ * limitations under the License. */ +// [Start process_data_form_ability] import { formBindingData, FormExtensionAbility, formInfo } from '@kit.FormKit'; import { Want } from '@kit.AbilityKit'; import { hilog } from '@kit.PerformanceAnalysisKit'; @@ -35,8 +36,11 @@ export default class ProcessDataFormAbility extends FormExtensionAbility { return formBinding; } + // [StartExclude process_data_form_ability] onAcquireFormState(want: Want): formInfo.FormState { // Called to return a {@link FormState} object. return formInfo.FormState.READY; } -} \ No newline at end of file + // [EndExclude process_data_form_ability] +} +// [End process_data_form_ability] \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/updatebymessage/pages/UpdateByMessageCard.ets b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/updatebymessage/pages/UpdateByMessageCard.ets index d95fbfc2993e8b6ff8b8b1f8f9f3c9e219b4f3b1..22ddf550c36d0d67409af01f5eb35d4aeb323f76 100644 --- a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/updatebymessage/pages/UpdateByMessageCard.ets +++ b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/updatebymessage/pages/UpdateByMessageCard.ets @@ -13,6 +13,7 @@ * limitations under the License. */ +// [Start update_by_message_card] let storageUpdateByMsg = new LocalStorage(); @Entry(storageUpdateByMsg) @@ -63,4 +64,5 @@ struct UpdateByMessageCard { .backgroundImage($r('app.media.CardEvent')) .backgroundImageSize(ImageSize.Cover) } -} \ No newline at end of file +} +// [End update_by_message_card] \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/updatebystatusformability/UpdateByStatusFormAbility.ts b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/updatebystatusformability/UpdateByStatusFormAbility.ts index ae907bee1f00bcc33c6ca3a5adda3b41b964728c..51f1356cd4ec6539ff1ded74825a1d663d0e9cd6 100644 --- a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/updatebystatusformability/UpdateByStatusFormAbility.ts +++ b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/updatebystatusformability/UpdateByStatusFormAbility.ts @@ -13,6 +13,8 @@ * limitations under the License. */ +// [Start update_by_status_form_ability] +// [Start receive_message_event] import { Want } from '@kit.AbilityKit'; import { preferences } from '@kit.ArkData'; import { BusinessError } from '@kit.BasicServicesKit'; @@ -120,4 +122,6 @@ export default class UpdateByStatusFormAbility extends FormExtensionAbility { hilog.error(DOMAIN_NUMBER, TAG, `Failed to get preferences. ${JSON.stringify(err)}`); }); } -} \ No newline at end of file +} +// [End update_by_status_form_ability] +// [End receive_message_event] \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/updatebytimeformability/UpdateByTimeFormAbility.ts b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/updatebytimeformability/UpdateByTimeFormAbility.ts index 5e6e2ff4cb0d76a475bb98b9b25b075ff0c0cb57..1b5e1170626a6d30d4188de9e7ea010846749b21 100644 --- a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/updatebytimeformability/UpdateByTimeFormAbility.ts +++ b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/updatebytimeformability/UpdateByTimeFormAbility.ts @@ -13,6 +13,7 @@ * limitations under the License. */ +// [Start update_by_time_form_ability] import { formBindingData, FormExtensionAbility, formInfo, formProvider } from '@kit.FormKit'; import { hilog } from '@kit.PerformanceAnalysisKit'; import { BusinessError } from '@kit.BasicServicesKit'; @@ -23,6 +24,7 @@ const FIVE_MINUTE: number = 5; const DOMAIN_NUMBER: number = 0xFF00; export default class UpdateByTimeFormAbility extends FormExtensionAbility { + // [StartExclude update_by_time_form_ability] onAddForm(want: Want): formBindingData.FormBindingData { // Called to return a FormBindingData object. let formData = {}; @@ -45,6 +47,7 @@ export default class UpdateByTimeFormAbility extends FormExtensionAbility { }); } + // [EndExclude update_by_time_form_ability] onFormEvent(formId: string, message: string): void { // Called when a specified message event defined by the form provider is triggered. hilog.info(DOMAIN_NUMBER, TAG, `FormAbility onFormEvent, formId = ${formId}, message: ${JSON.stringify(message)}`); @@ -66,9 +69,11 @@ export default class UpdateByTimeFormAbility extends FormExtensionAbility { } ; } - + // [StartExclude update_by_time_form_ability] onAcquireFormState(want: Want): formInfo.FormState { // Called to return a {@link FormState} object. return formInfo.FormState.READY; } -} \ No newline at end of file + // [EndExclude update_by_time_form_ability] +} +// [End update_by_time_form_ability] \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/wgtimgupdateentryformability/WgtImgUpdateEntryFormAbility.ts b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/wgtimgupdateentryformability/WgtImgUpdateEntryFormAbility.ts index 598bd01d8770da9233175161fe9568fb8279cf6e..c34d8809d394ea353f529dc8e0df7500aeba0b29 100644 --- a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/wgtimgupdateentryformability/WgtImgUpdateEntryFormAbility.ts +++ b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/wgtimgupdateentryformability/WgtImgUpdateEntryFormAbility.ts @@ -13,6 +13,8 @@ * limitations under the License. */ +// [Start local_file_refresh] +// [Start network_file_refresh] import { Want } from '@kit.AbilityKit'; import { BusinessError } from '@kit.BasicServicesKit'; import { fileIo } from '@kit.CoreFileKit'; @@ -26,6 +28,7 @@ const TEXT1: string = '刷新中...' const TEXT2: string = '刷新失败' export default class WgtImgUpdateEntryFormAbility extends FormExtensionAbility { + // [StartExclude network_file_refresh] // 在添加卡片时,打开一个本地图片并将图片内容传递给卡片页面显示 onAddForm(want: Want): formBindingData.FormBindingData { // 假设在当前卡片应用的tmp目录下有一个本地图片:head.PNG @@ -55,7 +58,8 @@ export default class WgtImgUpdateEntryFormAbility extends FormExtensionAbility { // 将fd封装在formData中并返回至卡片页面 return formBindingData.createFormBindingData(formData); } - + // [StartExclude local_file_refresh] + // [EndExclude network_file_refresh] async onFormEvent(formId: string, message: string): Promise { let param: Record = { 'text': TEXT1 @@ -121,10 +125,14 @@ export default class WgtImgUpdateEntryFormAbility extends FormExtensionAbility { } httpRequest.destroy(); } + // [StartExclude network_file_refresh] onAcquireFormState(want: Want): formInfo.FormState { // Called to return a {@link FormState} object. return formInfo.FormState.READY; } + // [EndExclude local_file_refresh] + // [EndExclude network_file_refresh] } +// [End local_file_refresh] diff --git a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/widgetcalleeentryability/WidgetCalleeEntryAbility.ts b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/widgetcalleeentryability/WidgetCalleeEntryAbility.ts index 19752caebb755ff006e801ea04a22d1d794a8df9..2dc0631465a06c10fb4847f8f50f88ce8817d605 100644 --- a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/widgetcalleeentryability/WidgetCalleeEntryAbility.ts +++ b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/widgetcalleeentryability/WidgetCalleeEntryAbility.ts @@ -13,6 +13,7 @@ * limitations under the License. */ +// [Start widget_callee_entry_ability] import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; import { window } from '@kit.ArkUI'; import { BusinessError } from '@kit.BasicServicesKit'; @@ -91,4 +92,5 @@ export default class WidgetCalleeEntryAbility extends UIAbility { hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); }); } -} \ No newline at end of file +} +// [End widget_callee_entry_ability] \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/widgeteventcall/pages/WidgetEventCallCard.ets b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/widgeteventcall/pages/WidgetEventCallCard.ets index eda6d22d0cf92fb22a2aacdbb257a09d10ca131f..99bac245a8e73f0f96e7f41ffd595e6615cb7e54 100644 --- a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/widgeteventcall/pages/WidgetEventCallCard.ets +++ b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/widgeteventcall/pages/WidgetEventCallCard.ets @@ -15,6 +15,7 @@ let storageEventCall = new LocalStorage(); +// [Start widget_event_call_card] @Entry(storageEventCall) @Component struct WidgetEventCallCard { @@ -22,23 +23,29 @@ struct WidgetEventCallCard { build() { Column() { + // [StartExclude widget_event_call_card] Text($r('app.string.WidgetEventCallEntryAbility_desc')) .fontColor('#FFFFFF') .opacity(0.9) .fontSize(14) .margin({ top: '8%', left: '10%' }) + // [EndExclude widget_event_call_card] Row() { Column() { Button() { + // [StartExclude widget_event_call_card] Text($r('app.string.ButtonA_label')) .fontColor('#45A6F4') .fontSize(12) + // [EndExclude widget_event_call_card] } + // [StartExclude widget_event_call_card] .width(120) .height(32) .margin({ top: '20%' }) .backgroundColor('#FFFFFF') .borderRadius(16) + // [EndExclude widget_event_call_card] .onClick(() => { postCardAction(this, { action: 'call', @@ -51,15 +58,19 @@ struct WidgetEventCallCard { }) Button() { + // [StartExclude widget_event_call_card] Text($r('app.string.ButtonB_label')) .fontColor('#45A6F4') .fontSize(12) + // [EndExclude widget_event_call_card] } + // [StartExclude widget_event_call_card] .width(120) .height(32) .margin({ top: '8%', bottom: '15vp' }) .backgroundColor('#FFFFFF') .borderRadius(16) + // [EndExclude widget_event_call_card] .onClick(() => { postCardAction(this, { action: 'call', @@ -78,7 +89,10 @@ struct WidgetEventCallCard { .width('100%') .height('100%') .alignItems(HorizontalAlign.Start) + // [StartExclude widget_event_call_card] .backgroundImage($r('app.media.CardEvent')) .backgroundImageSize(ImageSize.Cover) + // [EndExclude widget_event_call_card] } -} \ No newline at end of file +} +// [End widget_event_call_card] \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/widgeteventcallentryability/WidgetEventCallEntryAbility.ts b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/widgeteventcallentryability/WidgetEventCallEntryAbility.ts index b49da20a6022785789b59bfba78e53f412063ea4..ee3a63315117586a9e68bdf824ef30c041b452f1 100644 --- a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/widgeteventcallentryability/WidgetEventCallEntryAbility.ts +++ b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/widgeteventcallentryability/WidgetEventCallEntryAbility.ts @@ -13,6 +13,7 @@ * limitations under the License. */ +// [Start widget_event_call_card_entry_ability] import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; import { promptAction } from '@kit.ArkUI'; import { BusinessError } from '@kit.BasicServicesKit'; @@ -81,4 +82,5 @@ export default class WidgetEventCallEntryAbility extends UIAbility { hilog.error(DOMAIN_NUMBER, TAG, `Failed to register callee off. Cause: ${JSON.stringify(err as BusinessError)}`); }; } -} \ No newline at end of file +} +// [Start widget_event_call_card_entry_ability] \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/widgetevententryability/WidgetEventRouterEntryAbility.ts b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/widgetevententryability/WidgetEventRouterEntryAbility.ts index dff614ade6143414754aaf7dba67c82a3cd5cb0b..b5b6d2b257313904bbe4d962c22f06193e504046 100644 --- a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/widgetevententryability/WidgetEventRouterEntryAbility.ts +++ b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/widgetevententryability/WidgetEventRouterEntryAbility.ts @@ -13,6 +13,7 @@ * limitations under the License. */ +// [Start widget_event_router_entry_ability] import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; import { window } from '@kit.ArkUI'; import { BusinessError } from '@kit.BasicServicesKit'; @@ -76,4 +77,5 @@ export default class WidgetEventRouterEntryAbility extends UIAbility { hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); }); } -} \ No newline at end of file +} +// [End widget_event_router_entry_ability] \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/widgeteventrouter/pages/WidgetEventRouterCard.ets b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/widgeteventrouter/pages/WidgetEventRouterCard.ets index 443c3334bca65d9f51f5806fe3690ed9ecd107b9..dc7da7ef54f10e4f77e485bb10680944837286d4 100644 --- a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/widgeteventrouter/pages/WidgetEventRouterCard.ets +++ b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/widgeteventrouter/pages/WidgetEventRouterCard.ets @@ -13,6 +13,7 @@ * limitations under the License. */ +// [Start widget_event_router_card] @Entry @Component struct WidgetEventRouterCard { @@ -70,4 +71,5 @@ struct WidgetEventRouterCard { .backgroundImage($r('app.media.CardEvent')) .backgroundImageSize(ImageSize.Cover) } -} \ No newline at end of file +} +// [End widget_event_router_card] \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/widgetimageupdate/pages/WidgetImageUpdateCard.ets b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/widgetimageupdate/pages/WidgetImageUpdateCard.ets index 988e5d19d4cbc6b932c6acbbbb4ab65418e645a3..0d79cde7a98a539cfb5a6959f130447d9a3ec752 100644 --- a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/widgetimageupdate/pages/WidgetImageUpdateCard.ets +++ b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/widgetimageupdate/pages/WidgetImageUpdateCard.ets @@ -13,6 +13,7 @@ * limitations under the License. */ +// [Start widget_image_update_card] let storageWidgetImageUpdate = new LocalStorage(); @Entry(storageWidgetImageUpdate) @@ -61,7 +62,9 @@ struct WidgetImageUpdateCard { .width('100%').height('100%') .backgroundImage('memory://' + this.imgName) .backgroundImageSize(ImageSize.Cover) - } else { + } + // [StartExclude widget_image_update_card] + else { Column() { Column() { Text(this.text) @@ -99,5 +102,7 @@ struct WidgetImageUpdateCard { .backgroundImage($r('app.media.ImageDisp')) .backgroundImageSize(ImageSize.Cover) } - } -} \ No newline at end of file + // [EndExclude widget_image_update_card] + } +} +// [End widget_image_update_card] \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/widgetpersistentdata/pages/WidgetPersistentDataCard.ets b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/widgetpersistentdata/pages/WidgetPersistentDataCard.ets index 492be67c22b9aedf9e156005dde8bb9cb2917298..7aeae32d8f7279e14675fb601a5f64178b351592 100644 --- a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/widgetpersistentdata/pages/WidgetPersistentDataCard.ets +++ b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/widgetpersistentdata/pages/WidgetPersistentDataCard.ets @@ -13,6 +13,7 @@ * limitations under the License. */ +// [Start widget_persistent_data_card] let storagePersis = new LocalStorage(); @Entry(storagePersis) @@ -36,4 +37,5 @@ struct WidgetPersistentDataCard { .backgroundImage($r('app.media.CardEvent')) .backgroundImageSize(ImageSize.Cover) } -} \ No newline at end of file +} +// [End widget_persistent_data_card] \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/widgetprocessdata/pages/WidgetProcessDataCard.ets b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/widgetprocessdata/pages/WidgetProcessDataCard.ets index e73752b19033ba0306575261ca92d82de6e7936e..1d0284243468e78702e77e313b2b683f5ded5ca0 100644 --- a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/widgetprocessdata/pages/WidgetProcessDataCard.ets +++ b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/widgetprocessdata/pages/WidgetProcessDataCard.ets @@ -13,6 +13,7 @@ * limitations under the License. */ +// [Start widget_process_data_card] let storageProcess = new LocalStorage(); @Entry(storageProcess) @@ -35,4 +36,5 @@ struct WidgetProcessDataCard { .backgroundImage($r('app.media.CardEvent')) .backgroundImageSize(ImageSize.Cover) } -} \ No newline at end of file +} +// [End widget_process_data_card] \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/widgetupdatebystatus/pages/WidgetUpdateByStatusCard.ets b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/widgetupdatebystatus/pages/WidgetUpdateByStatusCard.ets index a8d757b219c5cc2d28b32674522a09f24609a164..c4663f6713d3485b87fdd9a2630e25f517c9356a 100644 --- a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/widgetupdatebystatus/pages/WidgetUpdateByStatusCard.ets +++ b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/widgetupdatebystatus/pages/WidgetUpdateByStatusCard.ets @@ -13,6 +13,7 @@ * limitations under the License. */ +// [Start widget_update_by_status_card] let storageUpdateByStatus = new LocalStorage(); @Entry(storageUpdateByStatus) @@ -109,4 +110,5 @@ struct WidgetUpdateByStatusCard { .backgroundImage($r('app.media.CardUpdateByStatus')) .backgroundImageSize(ImageSize.Cover) } -} \ No newline at end of file +} +// [End widget_update_by_status_card] \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/widgetupdatecall/pages/WidgetUpdateCallCard.ets b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/widgetupdatecall/pages/WidgetUpdateCallCard.ets index 95f756b494cd668780c18efd84a1894f8b11398e..783b8a6161f23b6b13b7b74c3c350d55d70a56f7 100644 --- a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/widgetupdatecall/pages/WidgetUpdateCallCard.ets +++ b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/widgetupdatecall/pages/WidgetUpdateCallCard.ets @@ -13,6 +13,7 @@ * limitations under the License. */ +// [Start widget_update_call_card] let storageUpdtCall = new LocalStorage(); @Entry(storageUpdtCall) @@ -63,4 +64,5 @@ struct WidgetUpdateCallCard { .backgroundImage($r('app.media.CardEvent')) .backgroundImageSize(ImageSize.Cover) } -} \ No newline at end of file +} +// [End widget_update_call_card] \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/widgetupdaterouter/pages/WidgetUpdateRouterCard.ets b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/widgetupdaterouter/pages/WidgetUpdateRouterCard.ets index f4eeba95cf93dd0e4915e4ab374079714df97e20..fd242beab49b3ae5d917b77ed4d450177df86b69 100644 --- a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/widgetupdaterouter/pages/WidgetUpdateRouterCard.ets +++ b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/ets/widgetupdaterouter/pages/WidgetUpdateRouterCard.ets @@ -13,6 +13,7 @@ * limitations under the License. */ +// [Start widget_updt_router_card] let storageUpdtRouter = new LocalStorage(); @Entry(storageUpdtRouter) @@ -62,4 +63,5 @@ struct WidgetUpdtRouterCard { .backgroundImage($r('app.media.CardEvent')) .backgroundImageSize(ImageSize.Cover) } -} \ No newline at end of file +} +// [End widget_updt_router_card] \ No newline at end of file diff --git a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/module.json5 b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/module.json5 index 11fea8127cc2b7929f08769ba29107595acd2357..5402420b4dad2395515e7967bf45dca19c319584 100644 --- a/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/module.json5 +++ b/code/DocsSample/ApplicationModels/StageServiceWidgetCards/entry/src/main/module.json5 @@ -13,8 +13,10 @@ * limitations under the License. */ +// [Start jscard_extension_ability] { "module": { + // [StartExclude jscard_extension_ability] "name": "entry", "type": "entry", "description": "$string:module_desc", @@ -26,7 +28,9 @@ "deliveryWithInstall": true, "installationFree": false, "pages": "$profile:main_pages", + // [Start module_json5_abilities] "abilities": [ + // [StartExclude module_json5_abilities] { "name": "EntryAbility", "srcEntry": "./ets/entryability/EntryAbility.ts", @@ -74,6 +78,7 @@ "startWindowIcon": "$media:icon", "startWindowBackground": "$color:start_window_background" }, + // [EndExclude module_json5_abilities] { "name": "WidgetEventCallEntryAbility", "srcEntry": "./ets/widgeteventcallentryability/WidgetEventCallEntryAbility.ts", @@ -84,7 +89,10 @@ "startWindowBackground": "$color:start_window_background" } ], + // [End module_json5_abilities] + // [EndExclude jscard_extension_ability] "extensionAbilities": [ + // [StartExclude jscard_extension_ability] { "name": "EntryFormAbility", "srcEntry": "./ets/entryformability/EntryFormAbility.ts", @@ -137,6 +145,7 @@ } ] }, + // [EndExclude jscard_extension_ability] { "name": "JsCardFormAbility", "srcEntry": "./ets/jscardformability/JsCardFormAbility.ts", @@ -150,6 +159,7 @@ } ] }, + // [StartExclude jscard_extension_ability] { "name": "ProcessDataFormAbility", "srcEntry": "./ets/processdataentryability/ProcessDataFormAbility.ts", @@ -190,10 +200,12 @@ ] } ], + // [Start module_json5_request_permissions] "requestPermissions": [ { "name": "ohos.permission.KEEP_BACKGROUND_RUNNING", }, + // [StartExclude module_json5_request_permissions] { "name": "ohos.permission.START_ABILITIES_FROM_BACKGROUND", }, @@ -209,6 +221,10 @@ "when": "inuse", } } + // [EndExclude module_json5_request_permissions] + // [EndExclude jscard_extension_ability] ] + // [End module_json5_request_permissions] } -} \ No newline at end of file +} +// [End jscard_extension_ability] \ No newline at end of file diff --git a/code/DocsSample/Form/ArkTSCardDocsSample/entry/src/main/ets/widget/pages/AnimationCard.ets b/code/DocsSample/Form/ArkTSCardDocsSample/entry/src/main/ets/widget/pages/AnimationCard.ets index 4f8312bc900d000ec7bc38c074f41bff024a9bbd..a41673f8cc6d5f191802f9aad5104da3ab44db12 100644 --- a/code/DocsSample/Form/ArkTSCardDocsSample/entry/src/main/ets/widget/pages/AnimationCard.ets +++ b/code/DocsSample/Form/ArkTSCardDocsSample/entry/src/main/ets/widget/pages/AnimationCard.ets @@ -13,6 +13,7 @@ * limitations under the License. */ +// [Start animation_card] @Entry @Component struct AnimationCard { @@ -35,4 +36,5 @@ struct AnimationCard { }.height('100%') .alignItems(VerticalAlign.Center) } -} \ No newline at end of file +} +// [End animation_card] \ No newline at end of file diff --git a/code/DocsSample/Form/ArkTSCardDocsSample/entry/src/main/ets/widget/pages/CanvasCard.ets b/code/DocsSample/Form/ArkTSCardDocsSample/entry/src/main/ets/widget/pages/CanvasCard.ets index 60a2ea671bf2538597aa5b929ef45f0b8c91d5bb..ab4e6339642c02b119d05ea2d693f1eaf5433050 100644 --- a/code/DocsSample/Form/ArkTSCardDocsSample/entry/src/main/ets/widget/pages/CanvasCard.ets +++ b/code/DocsSample/Form/ArkTSCardDocsSample/entry/src/main/ets/widget/pages/CanvasCard.ets @@ -13,6 +13,7 @@ * limitations under the License. */ +// [Start canvas_card] @Entry @Component struct CanvasCard { @@ -91,4 +92,5 @@ struct CanvasCard { } }.height('100%').width('100%') } -} \ No newline at end of file +} +// [End canvas_card] \ No newline at end of file diff --git a/code/DocsSample/Form/ArkTSCardDocsSample/entry/src/main/module.json5 b/code/DocsSample/Form/ArkTSCardDocsSample/entry/src/main/module.json5 index 87ff9920aeab99a71c9d69f0dddce8504b1db77c..62247c90f13745e0e86779365c3866bc6b560c9d 100644 --- a/code/DocsSample/Form/ArkTSCardDocsSample/entry/src/main/module.json5 +++ b/code/DocsSample/Form/ArkTSCardDocsSample/entry/src/main/module.json5 @@ -13,8 +13,10 @@ * limitations under the License. */ +// [Start module_config_extensionAbilities] { "module": { + //[StartExclude module_config_extensionAbilities] "name": "entry", "type": "entry", "description": "$string:module_desc", @@ -47,6 +49,7 @@ ] } ], + // [EndExclude module_config_extensionAbilities] "extensionAbilities": [ { "name": "EntryFormAbility", @@ -63,4 +66,5 @@ } ] } -} \ No newline at end of file +} +//[End module_config_extensionAbilities] \ No newline at end of file diff --git a/code/DocsSample/Form/FormHost/entry/src/main/ets/pages/Index.ets b/code/DocsSample/Form/FormHost/entry/src/main/ets/pages/Index.ets index 9bde392b2a6d76d8eb0a10c2a97fcbfd7cfeca94..d9126ca6073b09e74e9fcfc79daaf62e58046c6c 100644 --- a/code/DocsSample/Form/FormHost/entry/src/main/ets/pages/Index.ets +++ b/code/DocsSample/Form/FormHost/entry/src/main/ets/pages/Index.ets @@ -13,6 +13,7 @@ * limitations under the License. */ +// [Start form_host_index] import { HashMap, HashSet } from '@kit.ArkTS'; import { formHost, formInfo, formObserver } from '@kit.FormKit'; import { bundleMonitor } from '@kit.AbilityKit'; @@ -368,11 +369,13 @@ struct formHostSample { break; case 1: try { + // [Start request_form] formHost.requestForm(this.selectFormId, (error: BusinessError) => { if (error) { console.error(`requestForm error, code: ${error.code}, message: ${error.message}`); } }); + // [End request_form] } catch (error) { console.error(`requestForm catch error, code: ${(error as BusinessError).code}, message: ${(error as BusinessError).message}`); @@ -443,4 +446,4 @@ struct formHostSample { } } } - +// [End form_host_index]