InProgressShapesView


public final class InProgressShapesView<ShapeSpecT extends Object, InProgressShapeT extends InProgressShape<@NonNull ShapeSpecT, @NonNull CompletedShapeT>, CompletedShapeT extends Object> extends FrameLayout


Displays in-progress shapes, as defined by a ShapeWorkflow, as MotionEvent user inputs are provided incrementally. This is a more generalized version of InProgressStrokesView for specialized developer needs for custom shapes. For normal usage, InProgressStrokesView is recommended. For a Jetpack Compose equivalent which also provides a default input handler, see androidx.ink.authoring.compose.InProgressShapes instead.

Summary

Public constructors

<ShapeSpecT extends Object, InProgressShapeT extends InProgressShape<@NonNull ShapeSpecT, @NonNull CompletedShapeT>, CompletedShapeT extends Object> InProgressShapesView(
    @NonNull Context context,
    AttributeSet attrs,
    @AttrRes int defStyleAttr
)

Public methods

final void

Add a listener to be notified when shapes are finished.

final boolean
addToShape(
    @NonNull MotionEvent event,
    int pointerId,
    MotionEvent prediction
)

Add event data for pointerId to the corresponding in-progress shape, if present.

final void
addToShape(
    @NonNull StrokeInputBatch inputs,
    @NonNull InProgressStrokeId shapeId,
    @NonNull StrokeInputBatch prediction
)

Add input data from a StrokeInputBatch to an existing shape.

final void
addToShape(
    @NonNull MotionEvent event,
    int pointerId,
    @NonNull InProgressStrokeId shapeId,
    MotionEvent prediction
)

Add input data, from a particular pointer within a MotionEvent, to an existing shape.

final boolean
cancelShape(@NonNull MotionEvent event, int pointerId)

Cancel the corresponding in-progress shape with event data for pointerId, if present.

final void

Cancel the building of a shape.

final void

Cancel all in-progress shapes.

final void

Removes all listeners that had previously been added with addCompletedShapesListener.

final void

Eagerly initialize rather than waiting for the first shape to be drawn.

final boolean
finishShape(@NonNull MotionEvent event, int pointerId)

Finish the corresponding in-progress shape with event data for pointerId, if present.

final void
finishShape(
    @NonNull StrokeInput input,
    @NonNull InProgressStrokeId shapeId
)

Finish providing inputs for the shape represented by the given shapeId, with the last input data coming from a StrokeInput.

final void
finishShape(
    @NonNull MotionEvent event,
    int pointerId,
    @NonNull InProgressStrokeId shapeId
)

Complete the building of a shape, with the last input data coming from a particular pointer of a MotionEvent.

final @NonNull Map<@NonNull InProgressStrokeId, @NonNull CompletedShapeT>

Returns all the finished shapes that are still being rendered by this view, with map iteration order in the z-order that the shapes are being rendered, from back to front.

final ShapeWorkflow<@NonNull ShapeSpecT, @NonNull InProgressShapeT, @NonNull CompletedShapeT>

A ShapeWorkflow to be used as an alternative to the standard Ink behavior provided by InProgressStrokesView.

final CountingIdlingResource

Allows a test to easily wait until all in-progress shapes are completed and handed off.

final Path

Denote an area of this InProgressShapesView where no ink should be visible.

final @NonNull Matrix

The transform matrix to convert MotionEvent coordinates, as passed to startShape, addToShape, and finishShape, into coordinates of this InProgressShapesView for rendering.

final boolean

Returns true if there are any in-progress shapes.

final void

Stop this view from rendering the shapes with the given IDs.

final void

Removes a listener that had previously been added with addCompletedShapesListener.

final void
setCustomShapeWorkflow(
    ShapeWorkflow<@NonNull ShapeSpecT, @NonNull InProgressShapeT, @NonNull CompletedShapeT> customShapeWorkflow
)

A ShapeWorkflow to be used as an alternative to the standard Ink behavior provided by InProgressStrokesView.

final void

Allows a test to easily wait until all in-progress shapes are completed and handed off.

final void
setMaskPath(Path maskPath)

Denote an area of this InProgressShapesView where no ink should be visible.

final void
setMotionEventToViewTransform(
    @NonNull Matrix motionEventToViewTransform
)

The transform matrix to convert MotionEvent coordinates, as passed to startShape, addToShape, and finishShape, into coordinates of this InProgressShapesView for rendering.

final @NonNull InProgressStrokeId
startShape(
    @NonNull StrokeInput input,
    @NonNull ShapeSpecT shapeSpec,
    @NonNull Matrix shapeToViewTransform
)

Start building a shape with the provided input.

final @NonNull InProgressStrokeId
startShape(
    @NonNull MotionEvent event,
    int pointerId,
    @NonNull ShapeSpecT shapeSpec,
    @NonNull Matrix motionEventToWorldTransform,
    @NonNull Matrix shapeToWorldTransform
)

Start building a shape using a particular pointer within a MotionEvent.

Protected methods

void
void

Inherited methods

From android.widget.FrameLayout
From android.view.View
void
void
void
void
@NonNull ViewPropertyAnimator
void

This method is deprecated. Deprecated in Java

void
void
boolean
boolean
boolean
awakenScrollBars(int p0, boolean p1)
void
void

This method is deprecated. Deprecated in Java

void
buildDrawingCache(boolean p0)

This method is deprecated. Deprecated in Java

void
boolean
boolean
boolean
boolean
boolean
boolean
final void
void
final void
boolean
void
void
void
int
int
int
void
@NonNull WindowInsets
int
int
int
@NonNull AccessibilityNodeInfo
void
void

This method is deprecated. Deprecated in Java

boolean
boolean
dispatchNestedFling(float p0, float p1, boolean p2)
boolean
dispatchNestedPreFling(float p0, float p1)
boolean
boolean
dispatchNestedPreScroll(
    int p0,
    int p1,
    @Nullable int[] p2,
    @Nullable int[] p3
)
boolean
dispatchNestedScroll(int p0, int p1, int p2, int p3, @Nullable int[] p4)
boolean
void
void
drawableHotspotChanged(float p0, float p1)
final @Nullable OnBackInvokedDispatcher
final @NonNull T
<T extends View> findViewById(int p0)
final @NonNull T
<T extends View> findViewWithTag(@NonNull Object p0)
boolean

This method is deprecated. Deprecated in Java

@NonNull View
focusSearch(int p0)
void
void
void
generateDisplayHash(
    @NonNull String p0,
    @Nullable Rect p1,
    @NonNull Executor p2,
    @NonNull DisplayHashResultCallback p3
)
@NonNull View.AccessibilityDelegate
int
@NonNull AccessibilityNodeProvider
@Nullable CharSequence
int
int
@Nullable String
@Nullable String
float
@ViewDebug.ExportedProperty(category = "drawing")
getAlpha()
@NonNull Animation
@Nullable Matrix
@NonNull IBinder
@NonNull int[]
@NonNull Map<@NonNull Integer, @NonNull Integer>
@Nullable String[]
final @NonNull AutofillId
int
@Nullable AutofillValue
@NonNull Drawable
@Nullable BlendMode
@Nullable ColorStateList
@Nullable PorterDuff.Mode
int
@ViewDebug.ExportedProperty(category = "layout")
getBaseline()
final int
float
int
float
@NonNull Rect
boolean
final boolean
final @Nullable ContentCaptureSession
@NonNull CharSequence
@ViewDebug.ExportedProperty(category = "accessibility")
getContentDescription()
final int
final @NonNull Context
@NonNull ContextMenu.ContextMenuInfo
final boolean
@NonNull Display
final @NonNull int[]
@NonNull Bitmap

This method is deprecated. Deprecated in Java

@NonNull Bitmap
getDrawingCache(boolean p0)

This method is deprecated. Deprecated in Java

int

This method is deprecated. Deprecated in Java

int

This method is deprecated. Deprecated in Java

void
long
float
@ViewDebug.ExportedProperty(category = "drawing")
getElevation()
int
boolean
boolean
int
@ViewDebug.ExportedProperty(mapping = [@ViewDebug.IntToString(from = 0, to = "NOT_FOCUSABLE"), @ViewDebug.IntToString(from = 1, to = "FOCUSABLE"), @ViewDebug.IntToString(from = 16, to = "FOCUSABLE_AUTO")], category = "focus")
getFocusable()
@NonNull ArrayList<@NonNull View>
getFocusables(int p0)
void
@NonNull Drawable
int
@Nullable BlendMode
@Nullable ColorStateList
@Nullable PorterDuff.Mode
float
final boolean
boolean
@NonNull Handler
float
float
float
float
int
@Nullable Runnable
final boolean
final int
@ViewDebug.ExportedProperty(category = "layout")
getHeight()
void
int
int
@Nullable Drawable
@Nullable Drawable
int
int
@ViewDebug.ExportedProperty(category = "accessibility", mapping = [@ViewDebug.IntToString(from = 0, to = "auto"), @ViewDebug.IntToString(from = 1, to = "yes"), @ViewDebug.IntToString(from = 2, to = "no"), @ViewDebug.IntToString(from = 4, to = "noHideDescendants")])
getImportantForAccessibility()
int
@ViewDebug.ExportedProperty(mapping = [@ViewDebug.IntToString(from = 0, to = "auto"), @ViewDebug.IntToString(from = 1, to = "yes"), @ViewDebug.IntToString(from = 2, to = "no"), @ViewDebug.IntToString(from = 4, to = "yesExcludeDescendants"), @ViewDebug.IntToString(from = 8, to = "noExcludeDescendants")])
getImportantForAutofill()
int
@ViewDebug.ExportedProperty(mapping = [@ViewDebug.IntToString(from = 0, to = "auto"), @ViewDebug.IntToString(from = 1, to = "yes"), @ViewDebug.IntToString(from = 2, to = "no"), @ViewDebug.IntToString(from = 4, to = "yesExcludeDescendants"), @ViewDebug.IntToString(from = 8, to = "noExcludeDescendants")])
getImportantForContentCapture()
boolean
@NonNull KeyEvent.DispatcherState
int
@ViewDebug.ExportedProperty(category = "accessibility")
getLabelFor()
int
@ViewDebug.ExportedProperty(category = "drawing", mapping = [@ViewDebug.IntToString(from = 0, to = "NONE"), @ViewDebug.IntToString(from = 1, to = "SOFTWARE"), @ViewDebug.IntToString(from = 2, to = "HARDWARE")])
getLayerType()
int
@ViewDebug.ExportedProperty(category = "layout", mapping = [@ViewDebug.IntToString(from = 0, to = "RESOLVED_DIRECTION_LTR"), @ViewDebug.IntToString(from = 1, to = "RESOLVED_DIRECTION_RTL")])
getLayoutDirection()
@NonNull ViewGroup.LayoutParams
@ViewDebug.ExportedProperty(deepExport = true, prefix = "layout_")
getLayoutParams()
final int
float
int
final boolean
void
void
void
@NonNull Matrix
final int
final int
@ViewDebug.ExportedProperty(category = "measurement", flagMapping = [@ViewDebug.FlagToString(mask = -16777216, equals = 16777216, name = "MEASURED_STATE_TOO_SMALL")])
getMeasuredHeightAndState()
final int
final int
final int
@ViewDebug.ExportedProperty(category = "measurement", flagMapping = [@ViewDebug.FlagToString(mask = -16777216, equals = 16777216, name = "MEASURED_STATE_TOO_SMALL")])
getMeasuredWidthAndState()
int
int
int
int
int
int
int
int
@NonNull View.OnFocusChangeListener
int
@NonNull ViewOutlineProvider
int
int
int
int
int
int
int
int
final @NonNull ViewParent
@NonNull ViewParent
final @Nullable OutcomeReceiver<@NonNull GetCredentialResponse, @NonNull GetCredentialException>
final @Nullable GetCredentialRequest
float
@ViewDebug.ExportedProperty(category = "drawing")
getPivotX()
float
@ViewDebug.ExportedProperty(category = "drawing")
getPivotY()
@NonNull PointerIcon
final @NonNull List<@NonNull Rect>
@Nullable String[]
float
@NonNull Resources
final boolean
final int
float
int
@Nullable AttachedSurfaceControl
@NonNull View
@NonNull WindowInsets
float
@ViewDebug.ExportedProperty(category = "drawing")
getRotation()
float
@ViewDebug.ExportedProperty(category = "drawing")
getRotationX()
float
@ViewDebug.ExportedProperty(category = "drawing")
getRotationY()
float
@ViewDebug.ExportedProperty(category = "drawing")
getScaleX()
float
@ViewDebug.ExportedProperty(category = "drawing")
getScaleY()
int
int
int
int
@ViewDebug.ExportedProperty(mapping = [@ViewDebug.IntToString(from = 0, to = "INSIDE_OVERLAY"), @ViewDebug.IntToString(from = 16777216, to = "INSIDE_INSET"), @ViewDebug.IntToString(from = 33554432, to = "OUTSIDE_OVERLAY"), @ViewDebug.IntToString(from = 50331648, to = "OUTSIDE_INSET")])
getScrollBarStyle()
int
int
final int
final int
int
@ViewDebug.ExportedProperty(category = "drawing")
getSolidColor()
int
final @Nullable CharSequence
@ViewDebug.ExportedProperty(category = "accessibility")
getStateDescription()
@NonNull StateListAnimator
int
int
@Nullable CharSequence
@NonNull List<@NonNull Rect>
int

This method is deprecated. Deprecated in Java

@NonNull Object
@NonNull Object
getTag(int p0)
int
@ViewDebug.ExportedProperty(category = "text", mapping = [@ViewDebug.IntToString(from = 0, to = "INHERIT"), @ViewDebug.IntToString(from = 1, to = "GRAVITY"), @ViewDebug.IntToString(from = 2, to = "TEXT_START"), @ViewDebug.IntToString(from = 3, to = "TEXT_END"), @ViewDebug.IntToString(from = 4, to = "CENTER"), @ViewDebug.IntToString(from = 5, to = "VIEW_START"), @ViewDebug.IntToString(from = 6, to = "VIEW_END")])
getTextAlignment()
int
@ViewDebug.ExportedProperty(category = "text", mapping = [@ViewDebug.IntToString(from = 0, to = "INHERIT"), @ViewDebug.IntToString(from = 1, to = "FIRST_STRONG"), @ViewDebug.IntToString(from = 2, to = "ANY_RTL"), @ViewDebug.IntToString(from = 3, to = "LTR"), @ViewDebug.IntToString(from = 4, to = "RTL"), @ViewDebug.IntToString(from = 5, to = "LOCALE"), @ViewDebug.IntToString(from = 6, to = "FIRST_STRONG_LTR"), @ViewDebug.IntToString(from = 7, to = "FIRST_STRONG_RTL")])
getTextDirection()
@Nullable CharSequence
final int
float
int
@NonNull TouchDelegate
@NonNull ArrayList<@NonNull View>
float
@NonNull String
float
float
float
long
int
int
@Nullable Drawable
@Nullable Drawable
int
@Nullable ViewTranslationResponse
@NonNull ViewTreeObserver
int
@ViewDebug.ExportedProperty(mapping = [@ViewDebug.IntToString(from = 0, to = "VISIBLE"), @ViewDebug.IntToString(from = 4, to = "INVISIBLE"), @ViewDebug.IntToString(from = 8, to = "GONE")])
getVisibility()
final int
@ViewDebug.ExportedProperty(category = "layout")
getWidth()
int
@NonNull WindowId
@Nullable WindowInsetsController
int

This method is deprecated. Deprecated in Java

@NonNull IBinder
int
void
float
@ViewDebug.ExportedProperty(category = "drawing")
getX()
float
@ViewDebug.ExportedProperty(category = "drawing")
getY()
float
@ViewDebug.ExportedProperty(category = "drawing")
getZ()
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
void
void

This method is deprecated. Deprecated in Java

void
invalidate(int p0, int p1, int p2, int p3)

This method is deprecated. Deprecated in Java

void
void
boolean
boolean
boolean
boolean
boolean
boolean
boolean
final boolean
boolean
boolean
boolean
boolean

This method is deprecated. Deprecated in Java

boolean
boolean
final boolean
@ViewDebug.ExportedProperty(category = "focus")
isFocusable()
final boolean
boolean
@ViewDebug.ExportedProperty(category = "focus")
isFocused()
final boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
final boolean
final boolean
boolean
boolean
boolean
final boolean
boolean
boolean
boolean
boolean
boolean
boolean
@ViewDebug.ExportedProperty(category = "drawing")
isOpaque()
boolean
boolean
boolean
final boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
final boolean
boolean
boolean
final boolean
boolean
boolean
boolean
boolean
boolean
@NonNull View
final void
measure(int p0, int p1)
void
void
void
void
@NonNull WindowInsets
void
boolean
boolean
void
void
@NonNull InputConnection
void
void
void
onDisplayHint(int p0)
boolean
void
void
final void
boolean
void
void
void
onFocusChanged(boolean p0, int p1, @Nullable Rect p2)
boolean
void
onHoverChanged(boolean p0)
boolean
void
void
boolean
onKeyDown(int p0, @NonNull KeyEvent p1)
boolean
boolean
onKeyMultiple(int p0, int p1, @NonNull KeyEvent p2)
boolean
onKeyPreIme(int p0, @NonNull KeyEvent p1)
boolean
boolean
onKeyUp(int p0, @NonNull KeyEvent p1)
void
onOverScrolled(int p0, int p1, boolean p2, boolean p3)
void
void
void
void
void
void
void
@Nullable ContentInfo
void
void
@Nullable Parcelable
void
void
void
onScrollChanged(int p0, int p1, int p2, int p3)
boolean
onSetAlpha(int p0)
void
onSizeChanged(int p0, int p1, int p2, int p3)
void
boolean
boolean
void
void
void
void
void
void

This method is deprecated. Deprecated in Java

void
boolean
overScrollBy(
    int p0,
    int p1,
    int p2,
    int p3,
    int p4,
    int p5,
    int p6,
    int p7,
    boolean p8
)
boolean
boolean
boolean
boolean
performContextClick(float p0, float p1)
boolean
boolean
performHapticFeedback(int p0, int p1)
boolean
boolean
performLongClick(float p0, float p1)
@Nullable ContentInfo
void
boolean
boolean
postDelayed(@NonNull Runnable p0, long p1)
void
void
postInvalidate(int p0, int p1, int p2, int p3)
void
void
postInvalidateDelayed(long p0, int p1, int p2, int p3, int p4)
void
void
postInvalidateOnAnimation(int p0, int p1, int p2, int p3)
void
void
void
void
boolean
void
void
void
void
void
void

This method is deprecated. Deprecated in Java

final boolean
final boolean
requestFocus(int p0)
final boolean
void
void
boolean
boolean
final void
final void
final @NonNull T
<T extends View> requireViewById(int p0)
void
void
final void
saveAttributeDataForStyleable(
    @NonNull Context p0,
    @NonNull int[] p1,
    @Nullable AttributeSet p2,
    @NonNull TypedArray p3,
    int p4,
    int p5
)
void
void
void
scrollBy(int p0, int p1)
void
scrollTo(int p0, int p1)
void
void
void
void
void
void
void
void
void
void
setActivated(boolean p0)
void
void
void
void
setAlpha(float p0)
void
void
void
void
void
void
void
void

This method is deprecated. Deprecated in Java

void
void
void
void
final void
setBottom(int p0)
void
void
setClickable(boolean p0)
void
void
setClipToOutline(boolean p0)
void
void
final void
void
setContextClickable(boolean p0)
void
void

This method is deprecated. Deprecated in Java

void

This method is deprecated. Deprecated in Java

void

This method is deprecated. Deprecated in Java

void
void
setElevation(float p0)
void
setEnabled(boolean p0)
void
void
void
void
setFocusable(boolean p0)
void
setFocusable(int p0)
void
void
setFocusedByDefault(boolean p0)
void
setForceDarkAllowed(boolean p0)
void
void
void
void
void
void
setHandwritingBoundsOffsets(float p0, float p1, float p2, float p3)
void
void
void
void
void
void
void
void
void
setHovered(boolean p0)
void
setId(int p0)
void
void
void
void
setIsCredential(boolean p0)
void
void
setKeepScreenOn(boolean p0)
void
void
setLabelFor(int p0)
void
void
setLayerType(int p0, @Nullable Paint p1)
void
void
final void
setLeft(int p0)
final void
setLeftTopRightBottom(int p0, int p1, int p2, int p3)
void
setLongClickable(boolean p0)
final void
setMeasuredDimension(int p0, int p1)
void
void
void
void
void
void
void
void
void
void
void
void
void
void
void
void
void
void
void
void
void
void
void

This method is deprecated. Deprecated in Java

void
void
void
void
void
void
setPadding(int p0, int p1, int p2, int p3)
void
setPaddingRelative(int p0, int p1, int p2, int p3)
void
void
setPivotX(float p0)
void
setPivotY(float p0)
void
final void
setPreferKeepClear(boolean p0)
final void
void
setPressed(boolean p0)
void
final void
final void
setRight(int p0)
void
setRotation(float p0)
void
setRotationX(float p0)
void
setRotationY(float p0)
void
setSaveEnabled(boolean p0)
void
void
setScaleX(float p0)
void
setScaleY(float p0)
void
void
void
void
void
final void
void
void
setScrollContainer(boolean p0)
void
void
setScrollIndicators(int p0, int p1)
void
setScrollX(int p0)
void
setScrollY(int p0)
void
void
setSelected(boolean p0)
void
void
void
void
void
void

This method is deprecated. Deprecated in Java

void
void
setTag(int p0, @NonNull Object p1)
void
void
void
final void
setTop(int p0)
void
void
final void
void
void
setTranslationX(float p0)
void
setTranslationY(float p0)
void
setTranslationZ(float p0)
void
void
void
void
void
void
void
setVisibility(int p0)
void

This method is deprecated. Deprecated in Java

void
setWillNotDraw(boolean p0)
void
setX(float p0)
void
setY(float p0)
void
setZ(float p0)
boolean
boolean
showContextMenu(float p0, float p1)
@NonNull ActionMode
@NonNull ActionMode
void
final boolean
startDrag(
    @NonNull ClipData p0,
    @NonNull View.DragShadowBuilder p1,
    @NonNull Object p2,
    int p3
)

This method is deprecated. Deprecated in Java

final boolean
startDragAndDrop(
    @NonNull ClipData p0,
    @NonNull View.DragShadowBuilder p1,
    @NonNull Object p2,
    int p3
)
boolean
void
@NonNull String
void
void
void
void
final void
boolean
boolean

This method is deprecated. Deprecated in Java

boolean
@ViewDebug.ExportedProperty(category = "drawing")
willNotDraw()
From android.view.ViewGroup
void
void
void
addFocusables(@NonNull ArrayList<@NonNull View> p0, int p1, int p2)
void
boolean
void
void
void
addView(@NonNull View p0, int p1)
void
void
addView(@NonNull View p0, int p1, int p2)
void
boolean
addViewInLayout(
    @NonNull View p0,
    int p1,
    @NonNull ViewGroup.LayoutParams p2
)
boolean
addViewInLayout(
    @NonNull View p0,
    int p1,
    @NonNull ViewGroup.LayoutParams p2,
    boolean p3
)
void
attachLayoutAnimationParameters(
    @NonNull View p0,
    @NonNull ViewGroup.LayoutParams p1,
    int p2,
    int p3
)
void
attachViewToParent(
    @NonNull View p0,
    int p1,
    @NonNull ViewGroup.LayoutParams p2
)
void
boolean
void
void
void
void
void
void
void
debug(int p0)
void
void
void
void
detachViewsFromParent(int p0, int p1)
@NonNull WindowInsets
boolean
void
void
void
boolean
void
void
dispatchDrawableHotspotChanged(float p0, float p1)
void
void
boolean
boolean
boolean
boolean
boolean
boolean
void
void
void
void
void
void
void
void
dispatchSetPressed(boolean p0)
void
dispatchSetSelected(boolean p0)
void
void

This method is deprecated. Deprecated in Java

void
boolean
boolean
boolean
void
void
void
void
@NonNull WindowInsets
@NonNull WindowInsetsAnimation.Bounds
void

This method is deprecated. Deprecated in Java

void
boolean
drawChild(@NonNull Canvas p0, @NonNull View p1, long p2)
void
void
@NonNull View
@Nullable OnBackInvokedDispatcher
void
findViewsWithText(
    @NonNull ArrayList<@NonNull View> p0,
    @NonNull CharSequence p1,
    int p2
)
@NonNull View
focusSearch(@NonNull View p0, int p1)
void
boolean
@NonNull View
getChildAt(int p0)
int
final int
int
getChildDrawingOrder(int p0, int p1)
boolean
boolean
boolean
boolean
int
@ViewDebug.ExportedProperty(category = "focus", mapping = [@ViewDebug.IntToString(from = 131072, to = "FOCUS_BEFORE_DESCENDANTS"), @ViewDebug.IntToString(from = 262144, to = "FOCUS_AFTER_DESCENDANTS"), @ViewDebug.IntToString(from = 393216, to = "FOCUS_BLOCK_DESCENDANTS")])
getDescendantFocusability()
@NonNull View
@NonNull LayoutAnimationController
@NonNull Animation.AnimationListener
int
@NonNull LayoutTransition
int
@NonNull ViewGroupOverlay
int
@ViewDebug.ExportedProperty(category = "drawing", mapping = [@ViewDebug.IntToString(from = 0, to = "NONE"), @ViewDebug.IntToString(from = 1, to = "ANIMATION"), @ViewDebug.IntToString(from = 2, to = "SCROLLING"), @ViewDebug.IntToString(from = 3, to = "ALL")])
getPersistentDrawingCache()

This method is deprecated. Deprecated in Java

boolean
boolean
boolean
int
final void

This method is deprecated. Deprecated in Java

@NonNull ViewParent

This method is deprecated. Deprecated in Java

boolean

This method is deprecated. Deprecated in Java

boolean

This method is deprecated. Deprecated in Java

boolean
boolean

This method is deprecated. Deprecated in Java

boolean
boolean
boolean
void
final void
layout(int p0, int p1, int p2, int p3)
void
measureChild(@NonNull View p0, int p1, int p2)
void
measureChildWithMargins(@NonNull View p0, int p1, int p2, int p3, int p4)
void
measureChildren(int p0, int p1)
void
notifySubtreeAccessibilityStateChanged(
    @NonNull View p0,
    @NonNull View p1,
    int p2
)
final void
final void
@NonNull int[]
void
boolean
boolean
boolean
onNestedFling(@NonNull View p0, float p1, float p2, boolean p3)
boolean
onNestedPreFling(@NonNull View p0, float p1, float p2)
boolean
void
onNestedPreScroll(@NonNull View p0, int p1, int p2, @NonNull int[] p3)
void
onNestedScroll(@NonNull View p0, int p1, int p2, int p3, int p4)
void
boolean
boolean
@NonNull PointerIcon
boolean
void
void
void
void
propagateRequestedFrameRate(float p0, boolean p1)
void
void
void
void
removeDetachedView(@NonNull View p0, boolean p1)
void
void
removeViewAt(int p0)
void
void
removeViews(int p0, int p1)
void
removeViewsInLayout(int p0, int p1)
void
boolean
requestChildRectangleOnScreen(
    @NonNull View p0,
    @NonNull Rect p1,
    boolean p2
)
void
boolean
requestFocus(int p0, @NonNull Rect p1)
boolean
void
boolean
void
void
void

This method is deprecated. Deprecated in Java

void

This method is deprecated. Deprecated in Java

void

This method is deprecated. Deprecated in Java

void
void

This method is deprecated. Deprecated in Java

void
setClipChildren(boolean p0)
void
setClipToPadding(boolean p0)
void
void
void
void
setLayoutMode(int p0)
void
void
void
void

This method is deprecated. Deprecated in Java

void
void
void
void
setTransitionGroup(boolean p0)
void
boolean
boolean
showContextMenuForChild(@NonNull View p0, float p1, float p2)
@NonNull ActionMode
@NonNull ActionMode
startActionModeForChild(
    @NonNull View p0,
    @NonNull ActionMode.Callback p1,
    int p2
)
void
void
void
suppressLayout(boolean p0)
void

Public constructors

InProgressShapesView

public <ShapeSpecT extends Object, InProgressShapeT extends InProgressShape<@NonNull ShapeSpecT, @NonNull CompletedShapeT>, CompletedShapeT extends Object> InProgressShapesView(
    @NonNull Context context,
    AttributeSet attrs,
    @AttrRes int defStyleAttr
)

Public methods

addCompletedShapesListener

Added in 1.0.0-beta02
public final void addCompletedShapesListener(
    @NonNull InProgressShapesCompletedListener<@NonNull CompletedShapeT> listener
)

Add a listener to be notified when shapes are finished. These shapes will continue to be rendered within this view until removeCompletedShapes is called. All of the shapes that have been delivered to listeners but have not yet been removed with removeCompletedShapes are available through getCompletedShapes.

addToShape

Added in 1.0.0-beta02
public final boolean addToShape(
    @NonNull MotionEvent event,
    int pointerId,
    MotionEvent prediction
)

Add event data for pointerId to the corresponding in-progress shape, if present. The shape must have been started with an overload of startShape that accepts a MotionEvent.

Parameters
@NonNull MotionEvent event

The next MotionEvent as part of a shape's input data, typically a MotionEvent.ACTION_MOVE.

int pointerId

The index of the relevant pointer in the event. If pointerId does not correspond to an in-progress shape, this call is ignored and false is returned.

MotionEvent prediction

An optional predicted MotionEvent containing predicted inputs between event and the time of the next frame, as generated by androidx.input.motionprediction.MotionEventPredictor.predict.

Returns
boolean

Whether the pointer corresponds to an in-progress shape.

addToShape

Added in 1.0.0-beta02
public final void addToShape(
    @NonNull StrokeInputBatch inputs,
    @NonNull InProgressStrokeId shapeId,
    @NonNull StrokeInputBatch prediction
)

Add input data from a StrokeInputBatch to an existing shape. The shape must have been started with an overload of startShape that accepts a StrokeInput.

Parameters
@NonNull StrokeInputBatch inputs

The next StrokeInputBatch to be added to the shape.

@NonNull InProgressStrokeId shapeId

The InProgressStrokeId of the shape to be built upon.

@NonNull StrokeInputBatch prediction

Predicted StrokeInputBatch containing predicted inputs between inputs and the time of the next frame. This can technically be empty, but it is strongly recommended for it to be non-empty to achieve the best performance.

addToShape

Added in 1.0.0-beta02
public final void addToShape(
    @NonNull MotionEvent event,
    int pointerId,
    @NonNull InProgressStrokeId shapeId,
    MotionEvent prediction
)

Add input data, from a particular pointer within a MotionEvent, to an existing shape. The shape must have been started with an overload of startShape that accepts a MotionEvent.

Parameters
@NonNull MotionEvent event

The next MotionEvent as part of a shape's input data, typically one with MotionEvent.getActionMasked of MotionEvent.ACTION_MOVE.

int pointerId

The identifier of the pointer within event to be used for inking, as determined by MotionEvent.getPointerId and used as an input to MotionEvent.findPointerIndex. Note that this is the ID of the pointer, not its index.

@NonNull InProgressStrokeId shapeId

The InProgressStrokeId of the shape to be built upon.

MotionEvent prediction

Predicted MotionEvent containing predicted inputs between event and the time of the next frame. This value typically comes from androidx.input.motionprediction.MotionEventPredictor.predict. It is technically optional, but it is strongly recommended to achieve the best performance.

cancelShape

Added in 1.0.0-beta02
public final boolean cancelShape(@NonNull MotionEvent event, int pointerId)

Cancel the corresponding in-progress shape with event data for pointerId, if present. The shape must have been started with an overload of startShape that accepts a MotionEvent.

Parameters
@NonNull MotionEvent event

The MotionEvent that led to this cancellation, typically an ACTION_CANCEL.

int pointerId

the id of the relevant pointer in the event.

Returns
boolean

Whether the pointer corresponded to an in-progress shape.

cancelShape

Added in 1.0.0-beta02
public final void cancelShape(@NonNull InProgressStrokeId shapeId, MotionEvent event)

Cancel the building of a shape. It will no longer be visible within this InProgressShapesView, and no CompletedShapeT object will come through InProgressShapesCompletedListener for the given shapeId.

This is typically done for one of three reasons:

  1. A MotionEvent with MotionEvent.getActionMasked of MotionEvent.ACTION_CANCEL. This tends to be when an entire gesture has been canceled, for example when a parent View uses android.view.ViewGroup.onInterceptTouchEvent to intercept and handle the gesture itself.

  2. A MotionEvent with MotionEvent.getFlags containing MotionEvent.FLAG_CANCELED. This tends to be when the system has detected an unintentional touch, such as from the user resting their palm on the screen while writing or drawing, after some events from that unintentional pointer have already been delivered.

  3. An app's business logic reinterprets a gesture previously used for inking as something else, and the earlier inking may be seen as unintentional. For example, an app that uses single-pointer gestures for inking and dual-pointer gestures for pan/zoom/rotate will start inking when the first pointer goes down, but when the second pointer goes down it may want to cancel the shape from the first pointer rather than leave the small ink marks on the screen.

Does nothing if a shape with the given shapeId is not in progress.

Parameters
@NonNull InProgressStrokeId shapeId

The InProgressStrokeId of the shape to be canceled.

MotionEvent event

The MotionEvent that led to this cancellation, if applicable.

cancelUnfinishedShapes

Added in 1.0.0-beta02
public final void cancelUnfinishedShapes()

Cancel all in-progress shapes.

clearCompletedShapesListeners

Added in 1.0.0-beta02
public final void clearCompletedShapesListeners()

Removes all listeners that had previously been added with addCompletedShapesListener.

eagerInit

Added in 1.0.0-beta02
public final void eagerInit()

Eagerly initialize rather than waiting for the first shape to be drawn. Since initialization can be somewhat heavyweight, doing this as soon as it's likely for the user to start drawing can prevent initialization from introducing latency to the first shape.

finishShape

Added in 1.0.0-beta02
public final boolean finishShape(@NonNull MotionEvent event, int pointerId)

Finish the corresponding in-progress shape with event data for pointerId, if present. The shape must have been started with an overload of startShape that accepts a MotionEvent. The resulting CompletedShapeT will be passed to InProgressShapesCompletedListener (registered with addCompletedShapesListener) shortly after all currently in-progress shapes are finished.

Parameters
@NonNull MotionEvent event

the last MotionEvent as part of a shape, typically a MotionEvent.ACTION_UP.

int pointerId

the id of the relevant pointer in the event. If pointerId does not correspond to an in-progress shape, this call is ignored and false is returned.

Returns
boolean

Whether the pointer corresponded to an in-progress shape.

finishShape

Added in 1.0.0-beta02
public final void finishShape(
    @NonNull StrokeInput input,
    @NonNull InProgressStrokeId shapeId
)

Finish providing inputs for the shape represented by the given shapeId, with the last input data coming from a StrokeInput. The shape must have been started with an overload of startShape that accepts a StrokeInput. The resulting CompletedShapeT will be passed to InProgressShapesCompletedListener (registered with addCompletedShapesListener) shortly after all currently in-progress shapes are finished.

Parameters
@NonNull StrokeInput input

The last StrokeInput in the shape.

@NonNull InProgressStrokeId shapeId

The InProgressStrokeId of the shape to be finished.

finishShape

Added in 1.0.0-beta02
public final void finishShape(
    @NonNull MotionEvent event,
    int pointerId,
    @NonNull InProgressStrokeId shapeId
)

Complete the building of a shape, with the last input data coming from a particular pointer of a MotionEvent. The shape must have been started with an overload of startShape that accepts a MotionEvent.

The resulting CompletedShapeT will be passed to InProgressShapesCompletedListener (registered with addCompletedShapesListener) shortly after all currently in-progress shapes are finished.

Does nothing if a shape with the given shapeId is not in progress.

Parameters
@NonNull MotionEvent event

The last MotionEvent as part of a shape's input data, typically one with MotionEvent.getActionMasked of MotionEvent.ACTION_UP or MotionEvent.ACTION_POINTER_UP, but can also be other actions.

int pointerId

The identifier of the pointer within event to be used for inking, as determined by MotionEvent.getPointerId and used as an input to MotionEvent.findPointerIndex. Note that this is the ID of the pointer, not its index.

@NonNull InProgressStrokeId shapeId

The InProgressStrokeId of the shape to be finished.

getCompletedShapes

Added in 1.0.0-beta02
public final @NonNull Map<@NonNull InProgressStrokeId, @NonNull CompletedShapeT> getCompletedShapes()

Returns all the finished shapes that are still being rendered by this view, with map iteration order in the z-order that the shapes are being rendered, from back to front. This is the same order that shapes were started with startShape. The IDs of these shapes should be passed to removeCompletedShapes when they are handed off to another view.

getCustomShapeWorkflow

Added in 1.0.0-beta02
public final ShapeWorkflow<@NonNull ShapeSpecT, @NonNull InProgressShapeT, @NonNull CompletedShapeT> getCustomShapeWorkflow()

A ShapeWorkflow to be used as an alternative to the standard Ink behavior provided by InProgressStrokesView. It must be set before the first call to startShape or eagerInit.

getInProgressShapeCounter

Added in 1.0.0-beta02
public final CountingIdlingResource getInProgressShapeCounter()

Allows a test to easily wait until all in-progress shapes are completed and handed off. There is no reason to set this in non-test code.

getMaskPath

Added in 1.0.0-beta02
public final Path getMaskPath()

Denote an area of this InProgressShapesView where no ink should be visible. A value of null indicates that shapes will be visible anywhere they are drawn. This is useful for UI elements that float on top of (in Z order) the drawing surface - without this, a user would be able to draw in-progress ("wet") shapes on top of those UI elements, but then when the shape is finished, it will appear as a dry shape underneath of the UI element. If this mask is set to the shape and position of the floating UI element, then the ink will never be rendered in that area, making it appear as if it's being drawn underneath the UI element.

This technique is most convincing when the UI element is opaque. Often there are parts of the UI element that are translucent, such as drop shadows, or anti-aliasing along the edges. The result will look a little different between wet and dry shapes for those cases, but it can be a worthwhile tradeoff compared to the alternative of drawing wet shapes on top of that UI element.

Note that this parameter does not affect the contents of the shapes at all, nor how they appear when drawn in a separate composable after InProgressShapesCompletedListener.onShapesCompleted is called - just how the shapes appear when they are still in progress in this view.

getMotionEventToViewTransform

Added in 1.0.0-beta02
public final @NonNull Matrix getMotionEventToViewTransform()

The transform matrix to convert MotionEvent coordinates, as passed to startShape, addToShape, and finishShape, into coordinates of this InProgressShapesView for rendering. Defaults to the identity matrix, for the recommended case where InProgressShapesView exactly overlays the android.view.View that has the touch listener from which MotionEvent instances are being forwarded.

hasUnfinishedShapes

Added in 1.0.0-beta02
public final boolean hasUnfinishedShapes()

Returns true if there are any in-progress shapes.

removeCompletedShapes

Added in 1.0.0-beta02
@UiThread
public final void removeCompletedShapes(@NonNull Set<@NonNull InProgressStrokeId> strokeIds)

Stop this view from rendering the shapes with the given IDs.

This should be called in the same UI thread run loop (HWUI frame) as when the shapes start being rendered elsewhere in the view hierarchy. This means they are saved in a location where they will be picked up in a view's next call to onDraw, and that view's invalidate method has been called. If these two operations are not done within the same UI thread run loop (usually side by side - see example below), then there will be brief rendering errors - either a visual gap where the shape is not drawn during a frame, or a double draw where the shape is drawn twice and translucent shapes appear more opaque than they should.

removeCompletedShapesListener

Added in 1.0.0-beta02
public final void removeCompletedShapesListener(
    @NonNull InProgressShapesCompletedListener<@NonNull CompletedShapeT> listener
)

Removes a listener that had previously been added with addCompletedShapesListener.

setCustomShapeWorkflow

public final void setCustomShapeWorkflow(
    ShapeWorkflow<@NonNull ShapeSpecT, @NonNull InProgressShapeT, @NonNull CompletedShapeT> customShapeWorkflow
)

A ShapeWorkflow to be used as an alternative to the standard Ink behavior provided by InProgressStrokesView. It must be set before the first call to startShape or eagerInit.

setInProgressShapeCounter

Added in 1.0.0-beta02
public final void setInProgressShapeCounter(
    @VisibleForTesting CountingIdlingResource inProgressShapeCounter
)

Allows a test to easily wait until all in-progress shapes are completed and handed off. There is no reason to set this in non-test code.

setMaskPath

Added in 1.0.0-beta02
public final void setMaskPath(Path maskPath)

Denote an area of this InProgressShapesView where no ink should be visible. A value of null indicates that shapes will be visible anywhere they are drawn. This is useful for UI elements that float on top of (in Z order) the drawing surface - without this, a user would be able to draw in-progress ("wet") shapes on top of those UI elements, but then when the shape is finished, it will appear as a dry shape underneath of the UI element. If this mask is set to the shape and position of the floating UI element, then the ink will never be rendered in that area, making it appear as if it's being drawn underneath the UI element.

This technique is most convincing when the UI element is opaque. Often there are parts of the UI element that are translucent, such as drop shadows, or anti-aliasing along the edges. The result will look a little different between wet and dry shapes for those cases, but it can be a worthwhile tradeoff compared to the alternative of drawing wet shapes on top of that UI element.

Note that this parameter does not affect the contents of the shapes at all, nor how they appear when drawn in a separate composable after InProgressShapesCompletedListener.onShapesCompleted is called - just how the shapes appear when they are still in progress in this view.

setMotionEventToViewTransform

Added in 1.0.0-beta02
public final void setMotionEventToViewTransform(
    @NonNull Matrix motionEventToViewTransform
)

The transform matrix to convert MotionEvent coordinates, as passed to startShape, addToShape, and finishShape, into coordinates of this InProgressShapesView for rendering. Defaults to the identity matrix, for the recommended case where InProgressShapesView exactly overlays the android.view.View that has the touch listener from which MotionEvent instances are being forwarded.

startShape

Added in 1.0.0-beta02
public final @NonNull InProgressStrokeId startShape(
    @NonNull StrokeInput input,
    @NonNull ShapeSpecT shapeSpec,
    @NonNull Matrix shapeToViewTransform
)

Start building a shape with the provided input. This would typically be followed by many calls to addToShape, and the sequence would end with a call to either finishShape or cancelShape.

In most circumstances, the startShape overload that accepts a MotionEvent is more convenient. However, this overload using a StrokeInput is available for cases where the input data may not come directly from a MotionEvent, such as receiving events over a network connection. Using this function to start a shape can only be followed by the StrokeInput variants of addToShape and finishShape for the same shape.

If there is a way to request unbuffered dispatch from the source of the input data used here, equivalent to View.requestUnbufferedDispatch for unbuffered MotionEvent data, then be sure to request it for optimal performance.

Parameters
@NonNull StrokeInput input

The StrokeInput that started a shape.

@NonNull ShapeSpecT shapeSpec

Specification for the shape being started.

@NonNull Matrix shapeToViewTransform

The Matrix that converts shape coordinates as provided in input into the coordinate space of this InProgressShapesView for rendering.

Returns
@NonNull InProgressStrokeId

The InProgressStrokeId of the shape being built, later used to identify which shape is being updated with addToShape or ended with finishShape or cancelShape.

startShape

Added in 1.0.0-beta02
public final @NonNull InProgressStrokeId startShape(
    @NonNull MotionEvent event,
    int pointerId,
    @NonNull ShapeSpecT shapeSpec,
    @NonNull Matrix motionEventToWorldTransform,
    @NonNull Matrix shapeToWorldTransform
)

Start building a shape using a particular pointer within a MotionEvent. This would typically be followed by many calls to addToShape, and the sequence would end with a call to either finishShape or cancelShape.

In most circumstances, prefer to use this function over startShape that accepts a StrokeInput. Using this function to start a shape must only be followed by the MotionEvent variants of addToShape and finishShape for the same shape.

For optimum performance, it is strongly recommended to call View.requestUnbufferedDispatch using event and the View that generated event alongside calling this function. When requested this way, unbuffered dispatch mode will automatically end when the gesture is complete.

Parameters
@NonNull MotionEvent event

The first MotionEvent as part of a shape's input data, typically one with a MotionEvent.getActionMasked value of MotionEvent.ACTION_DOWN or MotionEvent.ACTION_POINTER_DOWN, but not restricted to those action types.

int pointerId

The identifier of the pointer within event to be used for inking, as determined by MotionEvent.getPointerId and used as an input to MotionEvent.findPointerIndex. Note that this is the ID of the pointer, not its index.

@NonNull ShapeSpecT shapeSpec

Specification for the shape being started.

@NonNull Matrix motionEventToWorldTransform

The matrix that transforms event coordinates into the client app's "world" coordinates, which typically is defined by how a client app's document is panned/zoomed/rotated. This defaults to the identity matrix, in which case the world coordinate space is the same as the MotionEvent coordinates, but the caller should pass in their own value reflecting a coordinate system that is independent of the device's pixel density (e.g. scaled by 1 / android.util.DisplayMetrics.density) and any pan/zoom/rotate gestures that have been applied to the "camera" which portrays the "world" on the device screen. This matrix must be invertible.

@NonNull Matrix shapeToWorldTransform

Allows an object-specific (shape-specific) coordinate space to be defined in relation to the caller's "world" coordinate space. This defaults to the identity matrix, which is typical for many use cases at the time of shape construction. In typical use cases, shape coordinates and world coordinates may start to differ from one another after shape creation as a particular shape is manipulated within the world, e.g. it may be moved, scaled, or rotated relative to other content within an app's document. This matrix must be invertible.

Returns
@NonNull InProgressStrokeId

The InProgressStrokeId of the shape being built, later used to identify which shape is being updated with addToShape or ended with finishShape or cancelShape. Callers that assume shapes map one-to-one with pointers in a gesture (as is typical) can skip storing this return value and use the overrides of addToShape, finishShape, and cancelShape that just take a MotionEvent and a pointerId.

Protected methods

onAttachedToWindow

protected void onAttachedToWindow()

onDetachedFromWindow

protected void onDetachedFromWindow()