Sequenceablepublic final class AbilityForm extends Object implements Sequenceable
Ability.
The following two roles are involved in the presentation of an AbilityForm depending on who provides or
displays the content:
AbilityForm content to be displayed. The supplier controls the
display content and logic.
AbilityForm content. The client controls the AbilityForm
layout.
AbilityForm on AbilitySlice objects. Multiple clients can
display AbilityForm contents on the same AbilitySlice.AbilitySlice to lay out
AbilityForm instances displayed on the ability slice.AbilityForm for the first time is as
follows:
AbilitySlice#acquireAbilityFormAsync(Intent, OnAcquiredCallback) method to
send an asynchronous request to the supplier through the AbilityForm framework to request the
AbilityForm to be displayed.Ability#onCreateForm() method on the supplier to
notify the developer of the supplier to create an AbilityForm instance. You need to provide a
layout file when creating an AbilityForm. You can also set attributes of components and register
a listener for click events.OnAcquiredCallback#onAcquired(AbilityForm) method on
the client to notify the developer of the client in an asynchronous way that the AbilityForm
display request has been processed.AbilityForm#getComponent() method to obtain the root
component of the AbilityForm, and uses the layout method provided in AbilitySlice to
inflate the AbilityForm content to the layout of the client.The supplier provides the following functions:
AbilitySlice#acquireAbilityFormAsync(Intent, OnAcquiredCallback) to send an asynchronous
request to the supplier through the AbilityForm framework to request the AbilityForm to be displayed,
the AbilityForm framework calls back the Ability#onCreateForm() method on the supplier to
notify the developer of the supplier to create an AbilityForm instance. You need to provide
a layout file when creating an AbilityForm. You can also set attributes of components and
register a listener for click events.AbilityForm#setText(int, String).AbilityForm#registerViewListener(int, ViewListener) to listen for click events of specific
components.The client provides the following functions:
AbilitySlice#acquireAbilityFormAsync(Intent, OnAcquiredCallback) to send an asynchronous
request to the supplier through the AbilityForm framework to request the AbilityForm to be displayed.
AbilitySlice#releaseAbilityForm(AbilityForm) to release an AbilityForm.getComponent() method to obtain the root component of the AbilityForm, and uses
the layout method provided in AbilitySlice to inflate the AbilityForm content to
the layout of the client.startFullPage() to display the complete content of an AbilityForm.SystemCapability.Aafwk#ABILITY| 限定符和类型 | 类 | 说明 |
|---|---|---|
static interface |
AbilityForm.OnAcquiredCallback |
Provides callback methods that are invoked when an
AbilityForm instance created by the supplier is
obtained or destroyed on the client. |
Sequenceable.Producer<T>| 限定符和类型 | 字段 | 说明 |
|---|---|---|
static String |
PERMISSION_REQUIRE_FORM |
Indicates the permission to obtain an
AbilityForm. |
static Sequenceable.Producer<AbilityForm> |
PRODUCER |
Creates a
AbilityForm instance from a Parcel. |
| 构造器 | 说明 |
|---|---|
AbilityForm(int resId,
Context context) |
A constructor used to create an
AbilityForm instance on the AbilityForm supplier. |
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
Component |
getComponent() |
Obtains the root component of an
AbilityForm from the supplier. |
Intent |
getFullPageIntent() |
Obtains the
Intent for starting full page display. |
boolean |
marshalling(Parcel out) |
Marshals an
AbilityForm object into a Parcel. |
boolean |
registerViewListener(int componentId,
ViewListener listener) |
Registers a listener by the AbilityForm supplier to listen for click events of a component on the AbilityForm
client.
|
void |
sendActions(ComponentProvider remoteComponentActions) |
Sends the supplier's actions configured in the
ComponentProvider object to the client. |
void |
setFullPageIntent(Intent intent) |
Sets the
Intent used for starting full page display. |
void |
setText(int componentId,
String text) |
Sets the text to be displayed for a specific component on the
AbilityForm supplier. |
void |
setTextSize(int componentId,
int size) |
Sets the font size of a specific component on the
AbilityForm supplier. |
void |
startFullPage() |
Switches to full page display of the
AbilityForm by the AbilityForm client. |
boolean |
unmarshalling(Parcel in) |
Unmarshals an
AbilityForm object from a Parcel. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waithasFileDescriptorpublic static final String PERMISSION_REQUIRE_FORM
AbilityForm.
Applications functioning as the AbilityForm client, for example, the home screen, must have this
permission. This permission is not available to third-party applications.
public static final Sequenceable.Producer<AbilityForm> PRODUCER
AbilityForm instance from a Parcel.public AbilityForm(int resId,
Context context)
AbilityForm instance on the AbilityForm supplier.
The supplier uses this constructor to create an instance in response to the Ability#onCreateForm()
method.
resId - Indicates the id of the layout resource file of the AbilityForm.context - Indicates the Ability context, which is used for asynchronous message processing of the
AbilityForm supplier.IllegalStateException - invalid parameterpublic boolean marshalling(Parcel out)
AbilityForm object into a Parcel.marshalling 在接口中 Sequenceableout - Indicates the Parcel object for marshalling.true if the marshalling is successful; returns false otherwise.public boolean unmarshalling(Parcel in)
AbilityForm object from a Parcel.unmarshalling 在接口中 Sequenceablein - Indicates the Parcel object for unmarshalling.true if the unmarshalling is successful; returns false otherwise.public Intent getFullPageIntent()
Intent for starting full page display.
You can use helper methods such as Ability.LayoutParamsHelper#setX(int) to set the display area for
full page in the obtained Intent, and then use the AbilityForm#setFullPageIntent(Intent)
method to pass the modified Intent back to the AbilityForm.
Intent for starting full page display.startFullPage(),
setFullPageIntent(Intent)public void setText(int componentId,
String text)
AbilityForm supplier.componentId - Identifies the component to be set. The value cannot be a negative number.text - Indicates the text to be displayed.public void setTextSize(int componentId,
int size)
AbilityForm supplier.componentId - Identifies the component to be set. The value cannot be a negative number.size - Indicates the font size to be set. The value must be greater than 0.IllegalArgumentException - invalid argumentpublic void sendActions(ComponentProvider remoteComponentActions)
ComponentProvider object to the client.
The AbilityForm framework then applies these actions on the client for the actions to take effect.
remoteComponentActions - Indicates the actions to be sent to the client.IllegalStateException - if client stub is in a wrong statepublic Component getComponent()
AbilityForm from the supplier.public boolean registerViewListener(int componentId,
ViewListener listener)
componentId - Identifies the component to be listened on. The value cannot be a negative number.listener - Indicates the callback method to be called when a component is clicked.true if the registration is successful; returns false otherwise.public void startFullPage()
AbilityForm by the AbilityForm client.
Typically, the AbilityForm client starts the full page display by performing the following steps:
AbilityForm#getFullPageIntent() in
AbilityForm.OnAcquiredCallback#onAcquired(AbilityForm) to obtain the Intent for starting
full page display.
Ability.LayoutParamsHelper#setX(int) to set layout parameters in
the obtained Intent.
AbilityForm#setFullPageIntent(Intent) to pass the configured Intent back
to the AbilityForm.
setFullPageIntent(Intent),
getFullPageIntent()public void setFullPageIntent(Intent intent)
Intent used for starting full page display.
After calling AbilityForm#getFullPageIntent() to obtain the Intent for starting full page
display, the client can set Intent parameters and then call the current method to pass the Intent
back to the AbilityForm.
intent - Indicates the Intent for starting full page display.startFullPage(),
getFullPageIntent()