T
- The subclass that extends this.public class PromptOptions<T extends PromptOptions>
extends java.lang.Object
Constructor and Description |
---|
PromptOptions(ResourceFinder resourceFinder)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
MaterialTapTargetPrompt |
create()
Creates an
MaterialTapTargetPrompt with the arguments supplied to this
builder. |
android.view.animation.Interpolator |
getAnimationInterpolator()
Get the animation interpolator that is used.
|
boolean |
getAutoDismiss()
Get whether the prompt should dismiss itself when a touch event occurs outside the focal.
|
boolean |
getAutoFinish()
Get if the prompt should finish itself when a touch event occurs inside the focal.
|
boolean |
getBackButtonDismissEnabled()
Will the pressing the system back button dismiss the prompt.
|
int |
getBackgroundColour()
Get the background colour.
|
boolean |
getCaptureTouchEventOnFocal()
Get if the prompt should stop touch events on the focal point from passing to underlying
views.
|
boolean |
getCaptureTouchEventOutsidePrompt()
Get if the prompt should stop touch events outside the prompt from passing to underlying views.
|
android.view.View |
getClipToView()
Get the view that the prompt canvas is clipped to.
|
int |
getFocalColour()
Get the focal point colour.
|
float |
getFocalPadding()
Get the padding between the text and the focal.
|
float |
getFocalRadius()
Get the focal point radius for the circle prompt focal.
|
android.graphics.drawable.Drawable |
getIconDrawable()
Get the icon drawn as the target.
|
boolean |
getIdleAnimationEnabled()
Is the focal animation enabled.
|
float |
getMaxTextWidth()
Get the maximum width that the primary and secondary text can be.
|
java.lang.CharSequence |
getPrimaryText()
Get the text to draw for the primary text.
|
int |
getPrimaryTextColour()
Gets the primary text font colour.
|
int |
getPrimaryTextGravity()
Gets the gravity for the primary text.
|
float |
getPrimaryTextSize()
Get the primary text font size.
|
android.graphics.Typeface |
getPrimaryTextTypeface()
Get the typeface for the primary text.
|
int |
getPrimaryTextTypefaceStyle()
Get the primary text typeface style.
|
PromptBackground |
getPromptBackground()
Get the prompt focal renderer.
|
PromptFocal |
getPromptFocal()
Get the prompt focal renderer.
|
PromptText |
getPromptText()
Get the
PromptText implementation used to render the prompt text. |
ResourceFinder |
getResourceFinder()
Get the resource finder being used.
|
java.lang.CharSequence |
getSecondaryText()
Get the secondary text.
|
int |
getSecondaryTextColour()
Get the secondary text colour.
|
int |
getSecondaryTextGravity()
Gets the gravity for the secondary text.
|
float |
getSecondaryTextSize()
Get the secondary text size.
|
android.graphics.Typeface |
getSecondaryTextTypeface()
Get the secondary text typeface.
|
int |
getSecondaryTextTypefaceStyle()
Get the secondary text typeface style.
|
android.graphics.PointF |
getTargetPosition()
Get the position on the screen that is being targeted.
|
android.view.View |
getTargetRenderView()
Get the view that is rendered as the target.
|
android.view.View |
getTargetView()
Gets the view that the prompt is targeting.
|
float |
getTextPadding()
Get the text left and right padding.
|
float |
getTextSeparation()
Get the distance between the primary and secondary text.
|
boolean |
isTargetSet()
Has the target been set successfully?
|
void |
load(int themeResId)
Loads the supplied theme into the prompt overwriting any previously set values if they are set in the theme.
|
void |
onPromptStateChanged(MaterialTapTargetPrompt prompt,
int state)
Handles emitting the prompt state changed events.
|
T |
setAnimationInterpolator(android.view.animation.Interpolator interpolator)
Set the interpolator to use in animations.
|
T |
setAutoDismiss(boolean autoDismiss)
Set whether the prompt should dismiss itself when a touch event occurs outside the focal.
|
T |
setAutoFinish(boolean autoFinish)
Set whether the prompt should finish itself when a touch event occurs inside the focal.
|
T |
setBackButtonDismissEnabled(boolean enabled)
Back button can be used to dismiss the prompt.
|
T |
setBackgroundColour(int colour)
Set the background colour.
|
T |
setCaptureTouchEventOnFocal(boolean captureTouchEvent)
Set if the prompt should stop touch events on the focal point from passing to underlying
views.
|
T |
setCaptureTouchEventOutsidePrompt(boolean captureTouchEventOutsidePrompt)
Set if the prompt should stop touch events outside the prompt from passing to underlying
views.
|
T |
setClipToView(android.view.View view)
Set the view to clip the prompt to.
|
T |
setFocalColour(int colour)
Set the focal point colour.
|
T |
setFocalPadding(float padding)
Set the padding between the text and the focal point.
|
T |
setFocalPadding(int resId)
Set the padding between the text and the focal point using the given resource id.
|
T |
setFocalRadius(float radius)
Set the focal point radius.
|
T |
setFocalRadius(int resId)
Set the focal point radius using the given resource id.
|
T |
setIcon(int resId)
Set the icon to draw in the focal point using the given resource id.
|
T |
setIconDrawable(android.graphics.drawable.Drawable drawable)
Set the icon to draw in the focal point.
|
T |
setIconDrawableColourFilter(int colour)
Sets the colour to use to tint the icon drawable.
|
T |
setIconDrawableTintList(android.content.res.ColorStateList tint)
Applies a tint to the icon drawable
|
T |
setIconDrawableTintMode(android.graphics.PorterDuff.Mode tintMode)
Sets the PorterDuff mode to use to apply the tint.
|
T |
setIdleAnimationEnabled(boolean enabled)
Enable/disable focal animation.
|
T |
setMaxTextWidth(float width)
Set the max width that the primary and secondary text can be.
|
T |
setMaxTextWidth(int resId)
Set the max width that the primary and secondary text can be using the given resource
id.
|
T |
setPrimaryText(java.lang.CharSequence text)
Set the primary text to the given CharSequence.
|
T |
setPrimaryText(int resId)
Set the primary text using the given resource id.
|
T |
setPrimaryText(java.lang.String text)
Set the primary text to the given string
|
T |
setPrimaryTextColour(int colour)
Set the primary text colour.
|
T |
setPrimaryTextGravity(int gravity)
Set the primary text horizontal layout gravity.
|
T |
setPrimaryTextSize(float size)
Set the primary text font size.
|
T |
setPrimaryTextSize(int resId)
Set the primary text font size using the given resource id.
|
T |
setPrimaryTextTypeface(android.graphics.Typeface typeface)
Sets the typeface and style used to display the primary text.
|
T |
setPrimaryTextTypeface(android.graphics.Typeface typeface,
int style)
Sets the typeface used to display the primary text.
|
T |
setPromptBackground(PromptBackground promptBackground)
Sets the renderer for the prompt background.
|
T |
setPromptFocal(PromptFocal promptFocal)
Sets the renderer for the prompt focal.
|
T |
setPromptStateChangeListener(MaterialTapTargetPrompt.PromptStateChangeListener listener)
Set the listener to listen for when the prompt state changes.
|
T |
setPromptText(PromptText promptText)
Set the
PromptText implementation to use to render the prompt text. |
T |
setSecondaryText(java.lang.CharSequence text)
Set the secondary text.
|
T |
setSecondaryText(int resId)
Set the secondary text using the given resource id.
|
T |
setSecondaryText(java.lang.String text)
Set the secondary text.
|
T |
setSecondaryTextColour(int colour)
Set the secondary text colour.
|
T |
setSecondaryTextGravity(int gravity)
Set the secondary text horizontal layout gravity.
|
T |
setSecondaryTextSize(float size)
Set the secondary text font size.
|
T |
setSecondaryTextSize(int resId)
Set the secondary text font size using the give resource id.
|
T |
setSecondaryTextTypeface(android.graphics.Typeface typeface)
Sets the typeface used to display the secondary text.
|
T |
setSecondaryTextTypeface(android.graphics.Typeface typeface,
int style)
Sets the typeface and style used to display the secondary text.
|
T |
setTarget(float left,
float top)
Set the centre point as a screen position
|
T |
setTarget(int target)
Set the view for the prompt to focus on using the given resource id.
|
T |
setTarget(android.view.View target)
Set the view for the prompt to focus on.
|
T |
setTargetRenderView(android.view.View view)
Change the view that is rendered as the target.
|
T |
setTextGravity(int gravity)
Set the primary and secondary text horizontal layout gravity.
|
T |
setTextPadding(float padding)
Set the text left and right padding.
|
T |
setTextPadding(int resId)
Set the text left and right padding using the given resource id.
|
T |
setTextSeparation(float separation)
Set the distance between the primary and secondary text.
|
T |
setTextSeparation(int resId)
Set the distance between the primary and secondary text using the given resource id.
|
MaterialTapTargetPrompt |
show()
Creates an
MaterialTapTargetPrompt with the arguments supplied to this
builder and immediately displays the prompt. |
public PromptOptions(ResourceFinder resourceFinder)
resourceFinder
- The resource finder implementation to use to find resources.public void load(int themeResId)
themeResId
- The resource id for the theme.public ResourceFinder getResourceFinder()
public T setTarget(android.view.View target)
target
- The view that the prompt will highlight.public T setTarget(@IdRes int target)
target
- The view that the prompt will highlight.@Nullable public android.view.View getTargetView()
public T setTarget(float left, float top)
left
- Centre point from screen lefttop
- Centre point from screen top@Nullable public android.graphics.PointF getTargetPosition()
public T setTargetRenderView(android.view.View view)
setTarget(View)
is rendered as the target.view
- The view to use to render the prompt targetpublic android.view.View getTargetRenderView()
public boolean isTargetSet()
public T setPrimaryText(@StringRes int resId)
resId
- The string resource id for the primary textpublic T setPrimaryText(java.lang.String text)
text
- The primary textpublic T setPrimaryText(java.lang.CharSequence text)
text
- The primary text as CharSequence@Nullable public java.lang.CharSequence getPrimaryText()
public T setPrimaryTextSize(float size)
size
- The primary text font sizepublic T setPrimaryTextSize(@DimenRes int resId)
resId
- The resource id for the primary text sizepublic float getPrimaryTextSize()
public T setPrimaryTextColour(int colour)
colour
- The primary text colour resource idpublic int getPrimaryTextColour()
public T setPrimaryTextTypeface(android.graphics.Typeface typeface)
typeface
- The primary text typefacepublic T setPrimaryTextTypeface(android.graphics.Typeface typeface, int style)
typeface
- The primary text typefacestyle
- The typeface stylepublic android.graphics.Typeface getPrimaryTextTypeface()
public int getPrimaryTextTypefaceStyle()
public T setSecondaryText(@StringRes int resId)
resId
- The secondary text resource idpublic T setSecondaryText(java.lang.String text)
text
- The secondary textpublic T setSecondaryText(java.lang.CharSequence text)
text
- The secondary text as a CharSequencepublic java.lang.CharSequence getSecondaryText()
public T setSecondaryTextSize(@DimenRes int resId)
resId
- The secondary text string resource idpublic T setSecondaryTextSize(float size)
size
- The secondary text font sizepublic float getSecondaryTextSize()
public T setSecondaryTextColour(int colour)
colour
- The secondary text colour resource idpublic int getSecondaryTextColour()
public T setSecondaryTextTypeface(android.graphics.Typeface typeface)
typeface
- The secondary text typefacepublic T setSecondaryTextTypeface(android.graphics.Typeface typeface, int style)
typeface
- The secondary text typefacestyle
- The typeface stylepublic android.graphics.Typeface getSecondaryTextTypeface()
public int getSecondaryTextTypefaceStyle()
public T setTextPadding(float padding)
padding
- The padding on the text left and rightpublic T setTextPadding(@DimenRes int resId)
resId
- The text padding dimension resource idpublic float getTextPadding()
public T setTextSeparation(float separation)
separation
- The distance separation between the primary and secondary textpublic T setTextSeparation(@DimenRes int resId)
resId
- The dimension resource id for the text separationpublic float getTextSeparation()
public T setFocalPadding(float padding)
padding
- The distance between the text and focalpublic T setFocalPadding(@DimenRes int resId)
resId
- The dimension resource id for the focal to text distancepublic float getFocalPadding()
public T setAnimationInterpolator(android.view.animation.Interpolator interpolator)
interpolator
- The animation interpolator to usepublic android.view.animation.Interpolator getAnimationInterpolator()
public T setIdleAnimationEnabled(boolean enabled)
enabled
- Idle animation enabledpublic boolean getIdleAnimationEnabled()
public T setIcon(@DrawableRes int resId)
resId
- The drawable resource id for the iconpublic T setIconDrawable(android.graphics.drawable.Drawable drawable)
drawable
- The drawable for the iconpublic android.graphics.drawable.Drawable getIconDrawable()
public T setIconDrawableTintList(@Nullable android.content.res.ColorStateList tint)
tint
- the tint to apply to the icon drawable, null
will remove the tint.public T setIconDrawableTintMode(@Nullable android.graphics.PorterDuff.Mode tintMode)
tintMode
- the tint mode to use on the icon drawable, null
will remove the
tint.public T setIconDrawableColourFilter(int colour)
colour
- The colour to use to tint the icon drawable, call setIconDrawableTintList(ColorStateList)
or setIconDrawableTintMode(PorterDuff.Mode)
with null
to remove the
tint.public T setPromptStateChangeListener(MaterialTapTargetPrompt.PromptStateChangeListener listener)
listener
- The listener to usepublic void onPromptStateChanged(MaterialTapTargetPrompt prompt, int state)
state
- The state that the prompt is now in.public T setCaptureTouchEventOnFocal(boolean captureTouchEvent)
captureTouchEvent
- True to capture touch events in the promptpublic boolean getCaptureTouchEventOnFocal()
public T setMaxTextWidth(float width)
width
- The max width that the text can reachpublic T setMaxTextWidth(@DimenRes int resId)
resId
- The dimension resource id for the max width that the text can reachpublic float getMaxTextWidth()
public T setBackgroundColour(int colour)
colour
- The background colour colour resource idpublic int getBackgroundColour()
public T setFocalColour(int colour)
colour
- The focal colour colour resource idpublic int getFocalColour()
public T setFocalRadius(float radius)
radius
- The focal radiuspublic T setFocalRadius(@DimenRes int resId)
resId
- The focal radius dimension resource idpublic float getFocalRadius()
public T setAutoDismiss(boolean autoDismiss)
MaterialTapTargetPrompt.STATE_NON_FOCAL_PRESSED
event in the
setPromptStateChangeListener(MaterialTapTargetPrompt.PromptStateChangeListener)
to handle the prompt
being pressed outside the focal area.autoDismiss
- True - prompt will dismiss when touched outside the focal, false - no
action taken.public boolean getAutoDismiss()
public T setAutoFinish(boolean autoFinish)
MaterialTapTargetPrompt.STATE_FOCAL_PRESSED
event in the
setPromptStateChangeListener(MaterialTapTargetPrompt.PromptStateChangeListener)
to handle the prompt
target being pressed.autoFinish
- True - prompt will finish when touched inside the focal, false - no
action taken.public boolean getAutoFinish()
public T setCaptureTouchEventOutsidePrompt(boolean captureTouchEventOutsidePrompt)
captureTouchEventOutsidePrompt
- True to capture touch events out side the promptpublic boolean getCaptureTouchEventOutsidePrompt()
public T setTextGravity(int gravity)
Gravity.START
gravity
- The horizontal gravitypublic T setPrimaryTextGravity(int gravity)
Gravity.START
gravity
- The horizontal gravitypublic int getPrimaryTextGravity()
public T setSecondaryTextGravity(int gravity)
Gravity.START
gravity
- The horizontal gravitypublic int getSecondaryTextGravity()
public T setClipToView(android.view.View view)
R.id.content
Null can be used to stop the prompt being clipped to a view.
view
- The view to clip topublic android.view.View getClipToView()
public T setBackButtonDismissEnabled(boolean enabled)
true
enabled
- True for back button dismiss enabledpublic boolean getBackButtonDismissEnabled()
public T setPromptBackground(@NonNull PromptBackground promptBackground)
promptBackground
- The background shape to use.public PromptBackground getPromptBackground()
public T setPromptFocal(@NonNull PromptFocal promptFocal)
promptFocal
- The focal shape to use.public PromptFocal getPromptFocal()
public T setPromptText(@NonNull PromptText promptText)
PromptText
implementation to use to render the prompt text.promptText
- The prompt text implementation.public PromptText getPromptText()
PromptText
implementation used to render the prompt text.public MaterialTapTargetPrompt create()
MaterialTapTargetPrompt
with the arguments supplied to this
builder.
Calling this method does not display the prompt. If no additional
processing is needed, show()
may be called instead to both
create and display the prompt.
Will return null
if a valid target has not been set or the primary text is null
.
To check that a valid target has been set call isTargetSet()
.
public MaterialTapTargetPrompt show()
MaterialTapTargetPrompt
with the arguments supplied to this
builder and immediately displays the prompt.
Calling this method is functionally identical to:
MaterialTapTargetPrompt prompt = builder.create(); prompt.show();
Will return null
if a valid target has not been set or the primary text is null
.
To check that a valid target has been set call isTargetSet()
.