public static final class AccessibilityService.MagnificationController extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
AccessibilityService.MagnificationController.OnMagnificationChangedListener
Listener for changes in the state of magnification.
|
Modifier and Type | Method and Description |
---|---|
void |
addListener(AccessibilityService.MagnificationController.OnMagnificationChangedListener listener)
Adds the specified change listener to the list of magnification
change listeners.
|
void |
addListener(AccessibilityService.MagnificationController.OnMagnificationChangedListener listener,
Handler handler)
Adds the specified change listener to the list of magnification
change listeners.
|
float |
getCenterX()
Returns the unscaled screen-relative X coordinate of the focal
center of the magnified region.
|
float |
getCenterY()
Returns the unscaled screen-relative Y coordinate of the focal
center of the magnified region.
|
Region |
getMagnificationRegion()
Returns the region of the screen currently active for magnification.
|
float |
getScale()
Returns the current magnification scale.
|
boolean |
removeListener(AccessibilityService.MagnificationController.OnMagnificationChangedListener listener)
Removes all instances of the specified change listener from the list
of magnification change listeners.
|
boolean |
reset(boolean animate)
Resets magnification scale and center to their default (e.g. no
magnification) values.
|
boolean |
setCenter(float centerX,
float centerY,
boolean animate)
Sets the center of the magnified viewport.
|
boolean |
setScale(float scale,
boolean animate)
Sets the magnification scale.
|
public void addListener(AccessibilityService.MagnificationController.OnMagnificationChangedListener listener)
listener
- the listener to add, must be non-null
public void addListener(AccessibilityService.MagnificationController.OnMagnificationChangedListener listener, Handler handler)
Handler
's thread, or on the service's main thread if the
handler is null
.listener
- the listener to add, must be non-nullhandler
- the handler on which the callback should execute, or
null
to execute on the service's main threadpublic boolean removeListener(AccessibilityService.MagnificationController.OnMagnificationChangedListener listener)
listener
- the listener to remove, must be non-nulltrue
if at least one instance of the listener was
removedpublic float getScale()
Note: If the service is not yet connected (e.g.
AccessibilityService.onServiceConnected()
has not yet been
called) or the service has been disconnected, this method will
return a default value of 1.0f
.
public float getCenterX()
Note: If the service is not yet connected (e.g.
AccessibilityService.onServiceConnected()
has not yet been
called) or the service has been disconnected, this method will
return a default value of 0.0f
.
public float getCenterY()
Note: If the service is not yet connected (e.g.
AccessibilityService.onServiceConnected()
has not yet been
called) or the service has been disconnected, this method will
return a default value of 0.0f
.
public Region getMagnificationRegion()
The returned region will be empty if magnification is not active. Magnification is active if magnification gestures are enabled or if a service is running that can control magnification.
Note: If the service is not yet connected (e.g.
AccessibilityService.onServiceConnected()
has not yet been
called) or the service has been disconnected, this method will
return an empty region.
public boolean reset(boolean animate)
Note: If the service is not yet connected (e.g.
AccessibilityService.onServiceConnected()
has not yet been
called) or the service has been disconnected, this method will have
no effect and return false
.
animate
- true
to animate from the current scale and
center or false
to reset the scale and center
immediatelytrue
on success, false
on failurepublic boolean setScale(float scale, boolean animate)
Note: If the service is not yet connected (e.g.
AccessibilityService.onServiceConnected()
has not yet been
called) or the service has been disconnected, this method will have
no effect and return false
.
scale
- the magnification scale to set, must be >= 1 and <= 5animate
- true
to animate from the current scale or
false
to set the scale immediatelytrue
on success, false
on failurepublic boolean setCenter(float centerX, float centerY, boolean animate)
Note: If the service is not yet connected (e.g.
AccessibilityService.onServiceConnected()
has not yet been
called) or the service has been disconnected, this method will have
no effect and return false
.
centerX
- the unscaled screen-relative X coordinate on which to
center the viewportcenterY
- the unscaled screen-relative Y coordinate on which to
center the viewportanimate
- true
to animate from the current viewport
center or false
to set the center immediatelytrue
on success, false
on failure