public class DesignTool


Utility class to manipulate MotionLayout from the layout editor

Summary

Public constructors

DesignTool(MotionLayout motionLayout)

Public methods

int
designAccess(
    int cmd,
    String type,
    Object viewObject,
    float[] in,
    int inLength,
    float[] out,
    int outLength
)

This is a general access to systems in the MotionLayout System This provides a series of commands used by the designer to access needed logic It is written this way to minimize the interface between the library and designer.

void
disableAutoTransition(boolean disable)

this allow disabling autoTransitions to prevent design surface from being in undefined states

void
int
getAnimationKeyFrames(Object view, float[] key)

Get the location of the start end and key frames

int
getAnimationPath(Object view, float[] path, int len)

Get the center point of the animation path of a view

void
getAnimationRectangles(Object view, float[] path)

Get the center point of the animation path of a view

String
int
getKeyFrameInfo(Object view, int type, int[] info)

Get the keyFrames for the view controlled by this MotionController.

float
getKeyFramePosition(Object view, int type, float x, float y)
int
getKeyFramePositions(Object view, int[] type, float[] pos)

Get the keyFrames for the view controlled by this MotionController.

Object
getKeyframe(int type, int target, int position)
Object
getKeyframe(Object view, int type, int position)
Object
getKeyframeAtLocation(Object viewObject, float x, float y)
Boolean
getPositionKeyframe(
    Object keyFrame,
    Object view,
    float x,
    float y,
    String[] attribute,
    float[] value
)
float

Return the current progress of the current transition

String
String

Return the current state (ConstraintSet id) as a string

long

Gets the time of the currently set animation.

boolean

Utility method, returns true if we are currently in a transition

void
setAttributes(
    int dpi,
    String constraintSetId,
    Object opaqueView,
    Object opaqueAttributes
)

Live setting of attributes on a view

void
setKeyFrame(Object view, int position, String name, Object value)
boolean
setKeyFramePosition(Object view, int position, int type, float x, float y)

Move the widget directly

void
setKeyframe(Object keyFrame, String tag, Object value)
void

This sets the constraint set based on a string.

void
setToolPosition(float position)
void
setTransition(String start, String end)

This sets the constraint set based on a string.

void
setViewDebug(Object view, int debugMode)

Public constructors

DesignTool

Added in 2.2.0
public DesignTool(MotionLayout motionLayout)

Public methods

designAccess

Added in 2.2.0
public int designAccess(
    int cmd,
    String type,
    Object viewObject,
    float[] in,
    int inLength,
    float[] out,
    int outLength
)

This is a general access to systems in the MotionLayout System This provides a series of commands used by the designer to access needed logic It is written this way to minimize the interface between the library and designer. It allows the logic to be kept only in the library not replicated in the gui builder. It also allows us to understand understand the version of MotionLayout in use commands 0 return the version number 1 Get the center point of the animation path of a view 2 Get the location of the start end and key frames

Parameters
int cmd

this provide the command needed

String type

support argument for command

Object viewObject

if this command references a view this provides access

float[] in

this allows for an array of float to be the input to the system

int inLength

this provides the length of the input

float[] out

this provide the output array

int outLength

the length of the output array

Returns
int

command dependent -1 is typically an error (do not understand)

disableAutoTransition

Added in 2.2.0
public void disableAutoTransition(boolean disable)

this allow disabling autoTransitions to prevent design surface from being in undefined states

Parameters
boolean disable

dumpConstraintSet

Added in 2.2.0
public void dumpConstraintSet(String set)
Parameters
String set

getAnimationKeyFrames

Added in 2.2.0
public int getAnimationKeyFrames(Object view, float[] key)

Get the location of the start end and key frames

Parameters
Object view

the view to track

float[] key

array to be filled

Returns
int

number of key frames + 2

getAnimationPath

Added in 2.2.0
public int getAnimationPath(Object view, float[] path, int len)

Get the center point of the animation path of a view

Parameters
Object view

view to getMap the animation of

float[] path

array to be filled (x1,y1,x2,y2...)

Returns
int

-1 if not under and animation 0 if not animated or number of point along animation

getAnimationRectangles

Added in 2.2.0
public void getAnimationRectangles(Object view, float[] path)

Get the center point of the animation path of a view

Parameters
Object view

view to getMap the animation of

float[] path

array to be filled (in groups of 8) (x1,y1,x2,y2...)

getEndState

Added in 2.2.0
public String getEndState()
Returns
String

getKeyFrameInfo

Added in 2.2.0
public int getKeyFrameInfo(Object view, int type, int[] info)

Get the keyFrames for the view controlled by this MotionController. The call is designed to be efficient because it will be called 30x Number of views a second

Parameters
Object view

the view to return keyframe positions

int[] info
Returns
int

Number of keyFrames found

getKeyFramePosition

Added in 2.2.0
public float getKeyFramePosition(Object view, int type, float x, float y)
Parameters
Object view
int type
float x
float y
Returns
float

getKeyFramePositions

Added in 2.2.0
public int getKeyFramePositions(Object view, int[] type, float[] pos)

Get the keyFrames for the view controlled by this MotionController. The call is designed to be efficient because it will be called 30x Number of views a second

Parameters
Object view

the view to return keyframe positions

int[] type

is pos(0-100) + 1000*mType(1=Attrib, 2=Position, 3=TimeCycle 4=Cycle 5=Trigger

float[] pos

the x&y position of the keyFrame along the path

Returns
int

Number of keyFrames found

getKeyframe

Added in 2.2.0
public Object getKeyframe(int type, int target, int position)
Parameters
int type
int target
int position
Returns
Object

getKeyframe

Added in 2.2.0
public Object getKeyframe(Object view, int type, int position)
Parameters
Object view
int type
int position
Returns
Object

getKeyframeAtLocation

Added in 2.2.0
public Object getKeyframeAtLocation(Object viewObject, float x, float y)
Parameters
Object viewObject
float x
float y
Returns
Object

getPositionKeyframe

Added in 2.2.0
public Boolean getPositionKeyframe(
    Object keyFrame,
    Object view,
    float x,
    float y,
    String[] attribute,
    float[] value
)
Parameters
Object keyFrame
Object view
float x
float y
String[] attribute
float[] value
Returns
Boolean

getProgress

Added in 2.2.0
public float getProgress()

Return the current progress of the current transition

Returns
float

current transition's progress

getStartState

Added in 2.2.0
public String getStartState()
Returns
String

getState

Added in 2.2.0
public String getState()

Return the current state (ConstraintSet id) as a string

Returns
String

the last state set via the design tool bridge

getTransitionTimeMs

Added in 2.2.0
public long getTransitionTimeMs()

Gets the time of the currently set animation.

Returns
long

time in Milliseconds

isInTransition

Added in 2.2.0
public boolean isInTransition()

Utility method, returns true if we are currently in a transition

Returns
boolean

true if in a transition, false otherwise

setAttributes

Added in 2.2.0
public void setAttributes(
    int dpi,
    String constraintSetId,
    Object opaqueView,
    Object opaqueAttributes
)

Live setting of attributes on a view

Parameters
int dpi

dpi used by the application

String constraintSetId

ConstraintSet id

Object opaqueView

the Android View we operate on, passed as an Object

Object opaqueAttributes

the list of attributes (hash) we pass to the view

setKeyFrame

Added in 2.2.0
public void setKeyFrame(Object view, int position, String name, Object value)
Parameters
Object view
int position
String name
Object value

setKeyFramePosition

Added in 2.2.0
public boolean setKeyFramePosition(Object view, int position, int type, float x, float y)

Move the widget directly

Parameters
Object view
int position
int type
float x
float y
Returns
boolean

setKeyframe

Added in 2.2.0
public void setKeyframe(Object keyFrame, String tag, Object value)
Parameters
Object keyFrame
String tag
Object value

setState

Added in 2.2.0
public void setState(String id)

This sets the constraint set based on a string. (without the "@+id/")

Parameters
String id

setToolPosition

Added in 2.2.0
public void setToolPosition(float position)
Parameters
float position

setTransition

Added in 2.2.0
public void setTransition(String start, String end)

This sets the constraint set based on a string. (without the "@+id/")

Parameters
String start
String end

setViewDebug

Added in 2.2.0
public void setViewDebug(Object view, int debugMode)
Parameters
Object view
int debugMode