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.
|
java.lang.String |
getContentDescription()
Get the text for the accessibility content description.
|
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.
|
boolean |
getIgnoreStatusBar()
Get ignore status bar flag
|
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 |
onExtraPromptStateChanged(MaterialTapTargetPrompt prompt,
int state)
Handles emitting the additional prompt state changed events.
|
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 |
setContentDescription(int resId)
Set the accessibility content description text using the given resource id.
|
T |
setContentDescription(java.lang.String text)
Set the accessibility content description text to the given string
|
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 |
setIgnoreStatusBar(boolean enabled)
Indicates whether to ignore system status bar.
|
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.
|
void |
setSequenceListener(MaterialTapTargetPrompt.PromptStateChangeListener listener)
Set the internal listener to listen for when the prompt state changes.
|
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 a
MaterialTapTargetPrompt with the arguments supplied to this
builder and immediately displays the prompt. |
MaterialTapTargetPrompt |
showFor(long milliseconds)
Creates a
MaterialTapTargetPrompt with the arguments supplied to this
builder and immediately displays the prompt for the number of milliseconds supplied. |
public PromptOptions(@NonNull ResourceFinder resourceFinder)
resourceFinder
- The resource finder implementation to use to find resources.public void load(@StyleRes int themeResId)
themeResId
- The resource id for the theme.@NonNull public ResourceFinder getResourceFinder()
@NonNull public T setTarget(@Nullable android.view.View target)
target
- The view that the prompt will highlight.@NonNull public T setTarget(@IdRes int target)
target
- The view that the prompt will highlight.@Nullable public android.view.View getTargetView()
@NonNull public T setTarget(float left, float top)
left
- Centre point from screen lefttop
- Centre point from screen top@Nullable public android.graphics.PointF getTargetPosition()
@NonNull public T setTargetRenderView(@Nullable android.view.View view)
setTarget(View)
is rendered as the target.view
- The view to use to render the prompt target@Nullable public android.view.View getTargetRenderView()
public boolean isTargetSet()
@NonNull public T setPrimaryText(@StringRes int resId)
resId
- The string resource id for the primary text@NonNull public T setPrimaryText(@Nullable java.lang.String text)
text
- The primary text@NonNull public T setPrimaryText(@Nullable java.lang.CharSequence text)
text
- The primary text as CharSequence@Nullable public java.lang.CharSequence getPrimaryText()
@NonNull public T setPrimaryTextSize(@Dimension float size)
size
- The primary text font size@NonNull public T setPrimaryTextSize(@DimenRes int resId)
resId
- The resource id for the primary text size@Dimension public float getPrimaryTextSize()
@NonNull public T setPrimaryTextColour(int colour)
colour
- The primary text colour resource idpublic int getPrimaryTextColour()
@NonNull public T setPrimaryTextTypeface(@Nullable android.graphics.Typeface typeface)
typeface
- The primary text typeface@NonNull public T setPrimaryTextTypeface(@Nullable android.graphics.Typeface typeface, int style)
typeface
- The primary text typefacestyle
- The typeface style@Nullable public android.graphics.Typeface getPrimaryTextTypeface()
public int getPrimaryTextTypefaceStyle()
@NonNull public T setSecondaryText(@StringRes int resId)
resId
- The secondary text resource id@NonNull public T setSecondaryText(@Nullable java.lang.String text)
text
- The secondary text@NonNull public T setSecondaryText(@Nullable java.lang.CharSequence text)
text
- The secondary text as a CharSequence@Nullable public java.lang.CharSequence getSecondaryText()
@NonNull public T setSecondaryTextSize(@DimenRes int resId)
resId
- The secondary text string resource id@NonNull public T setSecondaryTextSize(@Dimension float size)
size
- The secondary text font size@Dimension public float getSecondaryTextSize()
@NonNull public T setSecondaryTextColour(int colour)
colour
- The secondary text colour resource idpublic int getSecondaryTextColour()
@NonNull public T setSecondaryTextTypeface(@Nullable android.graphics.Typeface typeface)
typeface
- The secondary text typeface@NonNull public T setSecondaryTextTypeface(@Nullable android.graphics.Typeface typeface, int style)
typeface
- The secondary text typefacestyle
- The typeface style@Nullable public android.graphics.Typeface getSecondaryTextTypeface()
public int getSecondaryTextTypefaceStyle()
@NonNull public T setContentDescription(@StringRes int resId)
resId
- The string resource id for the accessibility content description text@NonNull public T setContentDescription(@Nullable java.lang.String text)
text
- The accessibility content description text@Nullable public java.lang.String getContentDescription()
@NonNull public T setTextPadding(@DimenRes int resId)
resId
- The text padding dimension resource id@NonNull public T setTextPadding(@Dimension float padding)
padding
- The padding on the text left and right@Dimension public float getTextPadding()
@NonNull public T setTextSeparation(@DimenRes int resId)
resId
- The dimension resource id for the text separation@NonNull public T setTextSeparation(@Dimension float separation)
separation
- The distance separation between the primary and secondary text@Dimension public float getTextSeparation()
@NonNull public T setFocalPadding(@DimenRes int resId)
resId
- The dimension resource id for the focal to text distance@NonNull public T setFocalPadding(@Dimension float padding)
padding
- The distance between the text and focal@Dimension public float getFocalPadding()
@NonNull public T setAnimationInterpolator(@Nullable android.view.animation.Interpolator interpolator)
interpolator
- The animation interpolator to use@Nullable public android.view.animation.Interpolator getAnimationInterpolator()
@NonNull public T setIdleAnimationEnabled(boolean enabled)
enabled
- Idle animation enabledpublic boolean getIdleAnimationEnabled()
@NonNull public T setIcon(@DrawableRes int resId)
resId
- The drawable resource id for the icon@NonNull public T setIconDrawable(@Nullable android.graphics.drawable.Drawable drawable)
drawable
- The drawable for the icon@Nullable public android.graphics.drawable.Drawable getIconDrawable()
@NonNull public T setIconDrawableTintList(@Nullable android.content.res.ColorStateList tint)
tint
- the tint to apply to the icon drawable, null
will remove the tint.@NonNull public T setIconDrawableTintMode(@Nullable android.graphics.PorterDuff.Mode tintMode)
tintMode
- the tint mode to use on the icon drawable, null
will remove the
tint.@NonNull 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.@NonNull public T setPromptStateChangeListener(@Nullable MaterialTapTargetPrompt.PromptStateChangeListener listener)
listener
- The listener to usepublic void setSequenceListener(@Nullable MaterialTapTargetPrompt.PromptStateChangeListener listener)
listener
- The listener to usepublic void onPromptStateChanged(@NonNull MaterialTapTargetPrompt prompt, int state)
state
- The state that the prompt is now in.public void onExtraPromptStateChanged(@NonNull MaterialTapTargetPrompt prompt, int state)
state
- The state that the prompt is now in.@NonNull public T setCaptureTouchEventOnFocal(boolean captureTouchEvent)
captureTouchEvent
- True to capture touch events in the promptpublic boolean getCaptureTouchEventOnFocal()
@NonNull public T setMaxTextWidth(@DimenRes int resId)
resId
- The dimension resource id for the max width that the text can reach@NonNull public T setMaxTextWidth(@Dimension float width)
width
- The max width that the text can reach@Dimension public float getMaxTextWidth()
@NonNull public T setBackgroundColour(int colour)
colour
- The background colour colour resource idpublic int getBackgroundColour()
@NonNull public T setFocalColour(int colour)
colour
- The focal colour colour resource idpublic int getFocalColour()
@NonNull public T setFocalRadius(@DimenRes int resId)
resId
- The focal radius dimension resource id@NonNull public T setFocalRadius(@Dimension float radius)
radius
- The focal radius@Dimension public float getFocalRadius()
@NonNull 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()
@NonNull 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()
@NonNull public T setCaptureTouchEventOutsidePrompt(boolean captureTouchEventOutsidePrompt)
captureTouchEventOutsidePrompt
- True to capture touch events out side the promptpublic boolean getCaptureTouchEventOutsidePrompt()
@NonNull public T setTextGravity(int gravity)
Gravity.START
gravity
- The horizontal gravity@NonNull public T setPrimaryTextGravity(int gravity)
Gravity.START
gravity
- The horizontal gravitypublic int getPrimaryTextGravity()
@NonNull public T setSecondaryTextGravity(int gravity)
Gravity.START
gravity
- The horizontal gravitypublic int getSecondaryTextGravity()
@NonNull public T setClipToView(@Nullable 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 to@Nullable public android.view.View getClipToView()
@NonNull public T setBackButtonDismissEnabled(boolean enabled)
enabled
- True for back button dismiss enabledpublic boolean getBackButtonDismissEnabled()
@NonNull public T setIgnoreStatusBar(boolean enabled)
enabled
- true for drawing behind system status barpublic boolean getIgnoreStatusBar()
@NonNull public T setPromptBackground(@NonNull PromptBackground promptBackground)
promptBackground
- The background shape to use.@NonNull public PromptBackground getPromptBackground()
@NonNull public T setPromptFocal(@NonNull PromptFocal promptFocal)
promptFocal
- The focal shape to use.@NonNull public PromptFocal getPromptFocal()
@NonNull public T setPromptText(@NonNull PromptText promptText)
PromptText
implementation to use to render the prompt text.promptText
- The prompt text implementation.@NonNull public PromptText getPromptText()
PromptText
implementation used to render the prompt text.@Nullable 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()
.
@Nullable 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 and secondary
text are null.
To check that a valid target has been set call isTargetSet()
.
@Nullable public MaterialTapTargetPrompt showFor(long milliseconds)
MaterialTapTargetPrompt
with the arguments supplied to this
builder and immediately displays the prompt for the number of milliseconds supplied.
Calling this method is functionally identical to:
MaterialTapTargetPrompt prompt = builder.create(); prompt.showFor(milliseconds);
Will return null if a valid target has not been set or the primary text and secondary
text are null.
To check that a valid target has been set call isTargetSet()
.
milliseconds
- The number of milliseconds to show the prompt for.