AccessibilityService.MagnificationController
public
static
final
class
AccessibilityService.MagnificationController
extends Object
java.lang.Object | |
↳ | android.accessibilityservice.AccessibilityService.MagnificationController |
Used to control and query the state of display magnification.
Summary
Nested classes | |
---|---|
interface |
AccessibilityService.MagnificationController.OnMagnificationChangedListener
Listener for changes in the state of magnification. |
Public methods | |
---|---|
void
|
addListener(AccessibilityService.MagnificationController.OnMagnificationChangedListener listener, Handler handler)
Adds the specified change listener to the list of magnification change listeners. |
void
|
addListener(AccessibilityService.MagnificationController.OnMagnificationChangedListener listener)
Adds the specified change listener to the list of magnification change listeners. |
float
|
getCenterX()
This method was deprecated
in API level 33.
Use |
float
|
getCenterY()
This method was deprecated
in API level 33.
Use |
Region
|
getCurrentMagnificationRegion()
Returns the region of the screen currently active for magnification if the
controlling magnification is |
MagnificationConfig
|
getMagnificationConfig()
Gets the |
Region
|
getMagnificationRegion()
This method was deprecated
in API level 33.
Use |
float
|
getScale()
This method was deprecated
in API level 33.
Use |
boolean
|
removeListener(AccessibilityService.MagnificationController.OnMagnificationChangedListener listener)
Removes 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
|
resetCurrentMagnification(boolean animate)
Resets magnification scale and center of the controlling magnification to their default (e.g. no magnification) values. |
boolean
|
setCenter(float centerX, float centerY, boolean animate)
This method was deprecated
in API level 33.
Use |
boolean
|
setMagnificationConfig(MagnificationConfig config, boolean animate)
Sets the |
boolean
|
setScale(float scale, boolean animate)
This method was deprecated
in API level 33.
Use |
Inherited methods | |
---|---|
Public methods
addListener
public void addListener (AccessibilityService.MagnificationController.OnMagnificationChangedListener listener, Handler handler)
Adds the specified change listener to the list of magnification
change listeners. The callback will occur on the specified
Handler
's thread, or on the service's main thread if the
handler is null
.
Parameters | |
---|---|
listener |
AccessibilityService.MagnificationController.OnMagnificationChangedListener : the listener to add, must be non-null |
handler |
Handler : the handler on which the callback should execute, or
null to execute on the service's main thread |
addListener
public void addListener (AccessibilityService.MagnificationController.OnMagnificationChangedListener listener)
Adds the specified change listener to the list of magnification change listeners. The callback will occur on the service's main thread.
Parameters | |
---|---|
listener |
AccessibilityService.MagnificationController.OnMagnificationChangedListener : the listener to add, must be non-null |
getCenterX
public float getCenterX ()
This method was deprecated
in API level 33.
Use getMagnificationConfig()
instead
Returns the unscaled screen-relative X coordinate of the focal center of the magnified region. This is the point around which zooming occurs and is guaranteed to lie within the magnified region.
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
.
Note: This legacy API gets the center position of full-screen
magnification. To get the magnification center of the current controlling magnifier,
use getMagnificationConfig()
instead.
Returns | |
---|---|
float |
the unscaled screen-relative X coordinate of the center of the magnified region |
getCenterY
public float getCenterY ()
This method was deprecated
in API level 33.
Use getMagnificationConfig()
instead
Returns the unscaled screen-relative Y coordinate of the focal center of the magnified region. This is the point around which zooming occurs and is guaranteed to lie within the magnified region.
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
.
Note: This legacy API gets the center position of full-screen
magnification. To get the magnification center of the current controlling magnifier,
use getMagnificationConfig()
instead.
Returns | |
---|---|
float |
the unscaled screen-relative Y coordinate of the center of the magnified region |
getCurrentMagnificationRegion
public Region getCurrentMagnificationRegion ()
Returns the region of the screen currently active for magnification if the
controlling magnification is MagnificationConfig.MAGNIFICATION_MODE_FULLSCREEN
.
Returns the region of screen projected on the magnification window if the
controlling magnification is MagnificationConfig.MAGNIFICATION_MODE_WINDOW
.
If the controlling mode is MagnificationConfig.MAGNIFICATION_MODE_FULLSCREEN
,
the returned region will be empty if the magnification is
not active. And the magnification is active if magnification gestures are enabled
or if a service is running that can control magnification.
If the controlling mode is MagnificationConfig.MAGNIFICATION_MODE_WINDOW
,
the returned region will be empty if the magnification is not activated.
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.
Returns | |
---|---|
Region |
the magnification region of the currently controlling magnification
This value cannot be null . |
getMagnificationConfig
public MagnificationConfig getMagnificationConfig ()
Gets the MagnificationConfig
of the controlling magnifier on the display.
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 null.
Returns | |
---|---|
MagnificationConfig |
the magnification config that the service controls |
getMagnificationRegion
public Region getMagnificationRegion ()
This method was deprecated
in API level 33.
Use getCurrentMagnificationRegion()
instead
Returns the region of the screen currently active for magnification. Changes to magnification scale and center only affect this portion of the screen. The rest of the screen, for example input methods, cannot be magnified. This region is relative to the unscaled screen and is independent of the scale and center point.
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.
Note: This legacy API gets the magnification region of full-screen
magnification. To get the magnification region of the current controlling magnifier,
use getCurrentMagnificationRegion()
instead.
Returns | |
---|---|
Region |
the region of the screen currently active for magnification, or an empty region
if magnification is not active.
This value cannot be null . |
getScale
public float getScale ()
This method was deprecated
in API level 33.
Use getMagnificationConfig()
instead
Returns the current magnification scale.
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
.
Note: This legacy API gets the scale of full-screen
magnification. To get the scale of the current controlling magnifier,
use getMagnificationConfig()
instead.
Returns | |
---|---|
float |
the current magnification scale |
removeListener
public boolean removeListener (AccessibilityService.MagnificationController.OnMagnificationChangedListener listener)
Removes the specified change listener from the list of magnification change listeners.
Parameters | |
---|---|
listener |
AccessibilityService.MagnificationController.OnMagnificationChangedListener : the listener to remove, must be non-null |
Returns | |
---|---|
boolean |
true if the listener was removed, false otherwise |
reset
public boolean reset (boolean animate)
Resets magnification scale and center to their default (e.g. no magnification) values.
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
.
Note: This legacy API reset full-screen magnification.
To reset the current controlling magnifier, use
resetCurrentMagnification(boolean)
()} instead.
Parameters | |
---|---|
animate |
boolean : true to animate from the current scale and
center or false to reset the scale and center
immediately |
Returns | |
---|---|
boolean |
true on success, false on failure |
resetCurrentMagnification
public boolean resetCurrentMagnification (boolean animate)
Resets magnification scale and center of the controlling magnification to their default (e.g. no magnification) values.
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
.
Parameters | |
---|---|
animate |
boolean : true to animate from the current scale and
center or false to reset the scale and center
immediately |
Returns | |
---|---|
boolean |
true on success, false on failure |
setCenter
public boolean setCenter (float centerX, float centerY, boolean animate)
This method was deprecated
in API level 33.
Use setMagnificationConfig(android.accessibilityservice.MagnificationConfig, boolean)
instead
Sets the center of the magnified viewport.
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
.
Note: This legacy API sets the center of full-screen
magnification. To set the center of the specified magnifier,
use setMagnificationConfig(MagnificationConfig, boolean)
instead.
Parameters | |
---|---|
centerX |
float : the unscaled screen-relative X coordinate on which to
center the viewport |
centerY |
float : the unscaled screen-relative Y coordinate on which to
center the viewport |
animate |
boolean : true to animate from the current viewport
center or false to set the center immediately |
Returns | |
---|---|
boolean |
true on success, false on failure |
setMagnificationConfig
public boolean setMagnificationConfig (MagnificationConfig config, boolean animate)
Sets the MagnificationConfig
. The service controls the magnification by
setting the config.
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
.
Parameters | |
---|---|
config |
MagnificationConfig : the magnification config
This value cannot be null . |
animate |
boolean : true to animate from the current spec or
false to set the spec immediately |
Returns | |
---|---|
boolean |
true on success, false on failure |
setScale
public boolean setScale (float scale, boolean animate)
This method was deprecated
in API level 33.
Use setMagnificationConfig(android.accessibilityservice.MagnificationConfig, boolean)
instead
Sets the magnification scale.
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
.
Note: This legacy API sets the scale of full-screen
magnification. To set the scale of the specified magnifier,
use setMagnificationConfig(MagnificationConfig, boolean)
instead.
Parameters | |
---|---|
scale |
float : the magnification scale to set, must be >= 1 and <= 8 |
animate |
boolean : true to animate from the current scale or
false to set the scale immediately |
Returns | |
---|---|
boolean |
true on success, false on failure |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2024-12-18 UTC.