Fields | ||
---|---|---|
protected final Context | mContext | The context of the extension service |
protected final java.lang.String | mHostAppPackageName | Package name of the host application |
protected final BitmapFactory.Options | mBitmapOptions | Default bitmap factory options that will be frequently used throughout the extension to avoid any automatic scaling. |
Public Constructors | |
---|---|
ControlExtension(Context context, java.lang.String hostAppPackageName)
Create control extension. |
Public Methods | |
---|---|
final void |
start()
Sets the control state to started. |
final void |
resume()
Sets the control state to resumed. |
final void |
pause()
Sets the control state to paused. |
final void |
stop()
Sets the control state to stopped. |
final void |
destroy()
Sets the control state to destroyed. |
void |
onDoAction(int requestCode, Bundle bundle)
Called when the control receives an action request. |
void |
onDestroy()
Called to notify a control extension that it is no longer used and is being removed. |
void |
onStart()
Called when the control extension is started by the host application. |
void |
onStop()
Called when the control extension is stopped by the host application. |
void |
onPause()
Called when the control extension is paused by the host application. |
void |
onResume()
Called when the control extension is resumed by the host application. |
void |
onError(int code)
Called when extension receives an error. |
void |
onTap(int action, long timeStamp)
Called when a tap event has occurred. |
void |
onKey(int action, int keyCode, long timeStamp)
Called when a key event has occurred. |
void |
onTouch(ControlTouchEvent event)
Called when a touch event has occurred. |
void |
onObjectClick(ControlObjectClickEvent event)
Called when an object click event has occurred. |
void |
onSwipe(int direction)
Called when a swipe event has occurred. |
void |
onRequestListItem(int layoutReference, int listItemPosition)
Called when the host application requests content for a specific list item. |
void |
onListItemClick(ControlListItem listItem, int clickType, int itemLayoutReference)
Called when an item in a list has been clicked. |
void |
onListRefreshRequest(int layoutReference)
Called when list refresh was requested. |
void |
onListItemSelected(ControlListItem listItem)
Called when an item in a list has been selected. |
void |
onMenuItemSelected(int menuItem)
Called when a menu item has been selected. |
void |
onActiveLowPowerModeChange(boolean lowPowerModeOn)
Called when the accessory screen's state leaves or enters Active Low Power mode. |
Protected Methods | |
---|---|
void |
startRequest()
Send request to start control extension. |
void |
stopRequest()
Send request to stop control extension. |
void |
showImage(int resourceId)
Show an image on the accessory. |
void |
showLayout(int layoutId, Bundle[] layoutData)
Show a layout on the accessory. |
void |
sendImage(int layoutReference, int resourceId)
Update an image in a specific layout, on the accessory. |
void |
sendImage(int layoutReference, Bitmap bitmap)
Update an image in a specific layout, on the accessory. |
void |
sendText(int layoutReference, java.lang.String text)
Update text in a specific layout, on the accessory. |
void |
showBitmap(Bitmap bitmap)
Show bitmap on accessory. |
void |
showBitmap(Bitmap bitmap, int x, int y)
Show bitmap on accessory. |
void |
setScreenState(int state)
Set the accessory screens state. |
void |
startVibrator(int onDuration, int offDuration, int repeats)
Start repeating vibrator. |
void |
stopVibrator()
Stop vibrator. |
void |
startLedPattern(int id, int color, int onDuration, int offDuration, int repeats)
Start a LED pattern. |
void |
stopLedPattern(int id)
Turn led off. |
void |
clearDisplay()
Clear accessory display. |
void |
sendListCount(int layoutReference, int listCount)
Set the number of items in list. |
void |
sendListCountWithContent(int layoutReference, int listCount, Bundle[] bundles)
Set the number of items in list and populate it with content. |
void |
sendListItem(ControlListItem item)
Update a list item. |
void |
sendListPosition(int layoutReference, int position)
Sends a request to move a list to a specified position. |
void |
showMenu(Bundle[] menuItems)
Show a menu. |
void |
sendToHostApp(Intent intent)
Send intent to host application. |
long |
getHostAppId()
Get the host application id for this control. |
boolean |
hasVibrator()
Check if this host application has a vibrator. |
ControlViewGroup |
parseLayout(View v)
Process View and whole ViewGroup tree into ControlViewGroup used by accessory. |
The context of the extension service
Package name of the host application
Default bitmap factory options that will be frequently used throughout the extension to avoid any automatic scaling. Keep in mind that we are not showing the images on the phone, but on the accessory.
Create control extension.
context | The extension service context. |
---|---|
hostAppPackageName | Package name of host application. |
Sets the control state to started. To request a control extension to start you have to use startRequest() method.
Sets the control state to resumed.
Sets the control state to paused.
Sets the control state to stopped. To request a control extension to stop you have to use stopRequest() method.
Sets the control state to destroyed.
Called when the control receives an action request.
requestCode | Code used to distinguish between different actions. |
---|---|
bundle | Optional bundle with additional information. |
Called to notify a control extension that it is no longer used and is being removed. The control extension should clean up any resources it holds (threads, registered receivers, etc) at this point.
Called when the control extension is started by the host application.
Called when the control extension is stopped by the host application.
Called when the control extension is paused by the host application.
Called when the control extension is resumed by the host application. The extension is expected to send a new image each time it is resumed.
Called when extension receives an error.
code | The reported error code. EXTRA_ERROR_CODE |
---|
Called when a tap event has occurred.
action | Can be any tap actions defined in the Control.TapActions interface. |
---|---|
timeStamp | The time when the tap event occurred. |
Called when a key event has occurred.
action | The key action, one of
|
---|---|
keyCode | The key code. |
timeStamp | The time when the event occurred. |
Called when a touch event has occurred.
event | The touch event. |
---|
Called when an object click event has occurred.
event | The object click event. |
---|
Called when a swipe event has occurred.
direction | The swipe direction, one of
|
---|
Called when the host application requests content for a specific list item.
layoutReference | The referenced list view |
---|---|
listItemPosition | The requested list item position |
Called when an item in a list has been clicked.
listItem | The list item that was clicked |
---|---|
clickType | The type of click ( CLICK_TYPE_SHORT, CLICK_TYPE_LONG) |
itemLayoutReference | The object within the list item that was clicked |
Called when list refresh was requested.
layoutReference | The referenced list view |
---|
Called when an item in a list has been selected.
listItem | The list item that was selected |
---|
Called when a menu item has been selected.
menuItem | The menu item that was selected |
---|
Called when the accessory screen's state leaves or enters Active Low Power mode.
lowPowerModeOn | true when the low power mode is started, false when the accessory screen leaves Active Low power mode |
---|
Send request to start control extension.
Send request to stop control extension.
Show an image on the accessory.
resourceId | The image resource id. |
---|
Show a layout on the accessory.
layoutId | The layout resource id. |
---|---|
layoutData | The layout data. |
Update an image in a specific layout, on the accessory.
layoutReference | The referenced resource within the current layout. |
---|---|
resourceId | The image resource id. |
Update an image in a specific layout, on the accessory.
layoutReference | The referenced resource within the current layout. |
---|---|
bitmap | The bitmap to show. |
Update text in a specific layout, on the accessory.
layoutReference | The referenced resource within the current layout. |
---|---|
text | The text to show. |
Show bitmap on accessory.
bitmap | The bitmap to show. |
---|
Show bitmap on accessory. Used when only updating part of the screen.
bitmap | The bitmap to show. |
---|---|
x | The x position. |
y | The y position. |
Set the accessory screens state.
state | The screen state. |
---|
Start repeating vibrator.
onDuration | On duration in milliseconds. |
---|---|
offDuration | Off duration in milliseconds. |
repeats | The number of repeats of the on/off pattern. Use REPEAT_UNTIL_STOP_INTENT to repeat until explicitly stopped. |
Stop vibrator.
Start a LED pattern.
id | Id of the LED to be controlled. |
---|---|
color | Color you want the LED to blink with. |
onDuration | On duration in milliseconds. |
offDuration | Off duration in milliseconds. |
repeats | The number of repeats of the on/off pattern. Use REPEAT_UNTIL_STOP_INTENT to repeat until explicitly stopped. |
Turn led off.
id | Id of the LED to be controlled. |
---|
Clear accessory display.
Set the number of items in list. Used to specify the initial size of the list and to update the size of the list.
layoutReference | The referenced list view. |
---|---|
listCount | The requested number of items in list. |
Set the number of items in list and populate it with content.
layoutReference | The referenced list view. |
---|---|
listCount | The requested number of items in list. |
bundles | List content. See EXTRA_LIST_CONTENT. |
Update a list item.
item | List item. |
---|
Sends a request to move a list to a specified position.
layoutReference | The referenced list view. |
---|---|
position |
Show a menu.
menuItems | Menu items. See Control.Intents.EXTRA_MENU_ITEMS. |
---|
Send intent to host application. Adds host application package name and our package name.
intent | The intent to send. |
---|
Get the host application id for this control.
The host application id.
Check if this host application has a vibrator.
True if vibrator exists.
Process View and whole ViewGroup tree into ControlViewGroup used by accessory.
v | View to parse. |
---|
Group of processed views.
The control extension handles a control on an accessory.