InProgressShapesView


class InProgressShapesView<ShapeSpecT : Any, InProgressShapeT : InProgressShape<ShapeSpecT, CompletedShapeT>, CompletedShapeT : Any> : 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 : Any, InProgressShapeT : InProgressShape<ShapeSpecT, CompletedShapeT>, CompletedShapeT : Any> InProgressShapesView(
    context: Context,
    attrs: AttributeSet?,
    defStyleAttr: @AttrRes Int
)

Public functions

Unit

Add a listener to be notified when shapes are finished.

Boolean
addToShape(event: MotionEvent, pointerId: Int, prediction: MotionEvent?)

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

Unit
addToShape(
    inputs: StrokeInputBatch,
    shapeId: InProgressStrokeId,
    prediction: StrokeInputBatch
)

Add input data from a StrokeInputBatch to an existing shape.

Unit
addToShape(
    event: MotionEvent,
    pointerId: Int,
    shapeId: InProgressStrokeId,
    prediction: MotionEvent?
)

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

Boolean
cancelShape(event: MotionEvent, pointerId: Int)

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

Unit

Cancel the building of a shape.

Unit

Cancel all in-progress shapes.

Unit

Removes all listeners that had previously been added with addCompletedShapesListener.

Unit

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

Boolean
finishShape(event: MotionEvent, pointerId: Int)

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

Unit

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

Unit
finishShape(
    event: MotionEvent,
    pointerId: Int,
    shapeId: InProgressStrokeId
)

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

Map<InProgressStrokeId, 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.

Boolean

Returns true if there are any in-progress shapes.

Unit

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

Unit

Removes a listener that had previously been added with addCompletedShapesListener.

InProgressStrokeId
startShape(
    input: StrokeInput,
    shapeSpec: ShapeSpecT,
    shapeToViewTransform: Matrix
)

Start building a shape with the provided input.

InProgressStrokeId
startShape(
    event: MotionEvent,
    pointerId: Int,
    shapeSpec: ShapeSpecT,
    motionEventToWorldTransform: Matrix,
    shapeToWorldTransform: Matrix
)

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

Protected functions

open Unit
open Unit

Public properties

ShapeWorkflow<ShapeSpecT, InProgressShapeT, CompletedShapeT>?

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

CountingIdlingResource?

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

Path?

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

Matrix

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

Inherited functions

From android.view.accessibility.AccessibilityEventSource
From android.graphics.drawable.Drawable.Callback
open Unit
open Unit
scheduleDrawable(who: Drawable, what: Runnable, when: Long)
open Unit
From android.view.KeyEvent.Callback
open Boolean
onKeyDown(keyCode: Int, event: KeyEvent)
open Boolean
onKeyLongPress(keyCode: Int, event: KeyEvent)
open Boolean
onKeyMultiple(keyCode: Int, repeatCount: Int, event: KeyEvent)
open Boolean
onKeyUp(keyCode: Int, event: KeyEvent)
From android.view.View
open Unit
open Unit
addExtraDataToAccessibilityNodeInfo(
    info: AccessibilityNodeInfo,
    extraDataKey: String,
    arguments: Bundle?
)
open Unit
addFocusables(views: ArrayList<View>, direction: Int)
open Unit
addFocusables(views: ArrayList<View>, direction: Int, focusableMode: Int)
open Unit
addKeyboardNavigationClusters(
    views: MutableCollection<View>,
    direction: Int
)
open Unit
open Unit
open Unit
open Unit
open ViewPropertyAnimator
open Unit

This function is deprecated. Deprecated in Java

open Unit
open Unit
open Boolean
open Boolean
awakenScrollBars(startDelay: Int)
open Boolean
awakenScrollBars(startDelay: Int, invalidate: Boolean)
open Unit
open Unit

This function is deprecated. Deprecated in Java

open Unit

This function is deprecated. Deprecated in Java

open Unit
open Boolean
open Boolean
open Boolean
open Boolean
open Boolean
open Boolean
Unit
open Unit
Unit
open Boolean
open Unit
open Unit
open Unit
open Unit
open Int
open Int
open Int
open Unit
open WindowInsets
open Int
open Int
open Int
open AccessibilityNodeInfo
open Unit
open Unit

This function is deprecated. Deprecated in Java

open WindowInsets
open Boolean
open Unit
open Unit
dispatchCreateViewTranslationRequest(
    viewIds: MutableMap<AutofillIdLongArray>,
    supportedFormats: IntArray,
    capability: TranslationCapability?,
    requests: MutableList<ViewTranslationRequest>
)
open Unit
open Boolean
open Unit
open Unit
open Unit
open Boolean
open Boolean
open Boolean
open Boolean
open Boolean
open Boolean
open Boolean
open Boolean
dispatchNestedFling(velocityX: Float, velocityY: Float, consumed: Boolean)
open Boolean
dispatchNestedPreFling(velocityX: Float, velocityY: Float)
open Boolean
dispatchNestedPrePerformAccessibilityAction(
    action: Int,
    arguments: Bundle?
)
open Boolean
dispatchNestedPreScroll(
    dx: Int,
    dy: Int,
    consumed: IntArray?,
    offsetInWindow: IntArray?
)
open Boolean
dispatchNestedScroll(
    dxConsumed: Int,
    dyConsumed: Int,
    dxUnconsumed: Int,
    dyUnconsumed: Int,
    offsetInWindow: IntArray?
)
open Unit
open Boolean
open Unit
open Unit
open Unit
open Unit
open Unit
dispatchScrollCaptureSearch(
    localVisibleRect: Rect,
    windowOffset: Point,
    targets: Consumer<ScrollCaptureTarget>
)
open Unit
open Unit
open Unit
open Unit
open Unit

This function is deprecated. Deprecated in Java

open Boolean
open Boolean
open Boolean
dispatchUnhandledMove(focused: View, direction: Int)
open Unit
dispatchVisibilityChanged(changedView: View, visibility: Int)
open Unit
open Unit
open Unit
open WindowInsets
open WindowInsetsAnimation.Bounds
open Unit

This function is deprecated. Deprecated in Java

open Unit
open Unit
draw(canvas: Canvas)
open Unit
open Unit
open View
OnBackInvokedDispatcher?
T
<T : View> findViewById(id: Int)
T
<T : View> findViewWithTag(tag: Any)
open Unit
findViewsWithText(
    outViews: ArrayList<View>,
    text: CharSequence,
    flags: Int
)
open Boolean

This function is deprecated. Deprecated in Java

open View
focusSearch(direction: Int)
open Unit
forceHasOverlappingRendering(hasOverlappingRendering: Boolean)
open Unit
open Boolean
open Unit
generateDisplayHash(
    hashAlgorithm: String,
    bounds: Rect?,
    executor: Executor,
    callback: DisplayHashResultCallback
)
open IntArray
open Unit
getDrawingRect(outRect: Rect)
open ArrayList<View>
getFocusables(direction: Int)
open Unit
Boolean
open Boolean
getGlobalVisibleRect(r: Rect, globalOffset: Point)
open Unit
getHitRect(outRect: Rect)
open Int
@ViewDebug.ExportedProperty(category = "layout", mapping = [@ViewDebug.IntToString(from = 0, to = "RESOLVED_DIRECTION_LTR"), @ViewDebug.IntToString(from = 1, to = "RESOLVED_DIRECTION_RTL")])
getLayoutDirection()
Boolean
open Unit
open Unit
open Unit
ViewParent
open ViewParent
open 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()
open 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()
open Unit
open Boolean
open Boolean
open Boolean
open Boolean
open Boolean
open Boolean
open Boolean
open Boolean
open Boolean
open Boolean
open Unit
open Unit
invalidate(dirty: Rect)

This function is deprecated. Deprecated in Java

open Unit
invalidate(l: Int, t: Int, r: Int, b: Int)

This function is deprecated. Deprecated in Java

open Unit
open Boolean
open Boolean
open Boolean
open Boolean
open Boolean
open Unit
open View
keyboardNavigationClusterSearch(currentCluster: View, direction: Int)
Unit
layout(l: Int, t: Int, r: Int, b: Int)
Unit
measure(widthMeasureSpec: Int, heightMeasureSpec: Int)
open Unit
open Unit
open Unit
open Unit
open WindowInsets
open Unit
open Boolean
open Boolean
open Unit
open Unit
open IntArray
open InputConnection
open Unit
onCreateViewTranslationRequest(
    supportedFormats: IntArray,
    requestsCollector: Consumer<ViewTranslationRequest>
)
open Unit
onCreateVirtualViewTranslationRequests(
    virtualIds: LongArray,
    supportedFormats: IntArray,
    requestsCollector: Consumer<ViewTranslationRequest>
)
open Unit
open Boolean
open Unit
onDraw(canvas: Canvas)
open Unit
Unit
open Boolean
open Unit
open Unit
open Unit
onFocusChanged(
    gainFocus: Boolean,
    direction: Int,
    previouslyFocusedRect: Rect?
)
open Boolean
open Unit
open Boolean
open Unit
open Unit
open Boolean
onKeyPreIme(keyCode: Int, event: KeyEvent)
open Boolean
onKeyShortcut(keyCode: Int, event: KeyEvent)
open Unit
onLayout(changed: Boolean, left: Int, top: Int, right: Int, bottom: Int)
open Unit
onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int)
open Unit
onOverScrolled(
    scrollX: Int,
    scrollY: Int,
    clampedX: Boolean,
    clampedY: Boolean
)
open Unit
open Unit
open Unit
open Unit
open Unit
open Unit
open Unit
open ContentInfo?
open PointerIcon
onResolvePointerIcon(event: MotionEvent, pointerIndex: Int)
open Unit
open Unit
onRtlPropertiesChanged(layoutDirection: Int)
open Parcelable?
open Unit
onScreenStateChanged(screenState: Int)
open Unit
onScrollCaptureSearch(
    localVisibleRect: Rect,
    windowOffset: Point,
    targets: Consumer<ScrollCaptureTarget>
)
open Unit
onScrollChanged(l: Int, t: Int, oldl: Int, oldt: Int)
open Boolean
onSetAlpha(alpha: Int)
open Unit
onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int)
open Unit
open Boolean
open Boolean
open Unit
open Unit
open Unit
open Unit
onVisibilityChanged(changedView: View, visibility: Int)
open Unit
onWindowFocusChanged(hasWindowFocus: Boolean)
open Unit

This function is deprecated. Deprecated in Java

open Unit
open Boolean
overScrollBy(
    deltaX: Int,
    deltaY: Int,
    scrollX: Int,
    scrollY: Int,
    scrollRangeX: Int,
    scrollRangeY: Int,
    maxOverScrollX: Int,
    maxOverScrollY: Int,
    isTouchEvent: Boolean
)
open Boolean
performAccessibilityAction(action: Int, arguments: Bundle?)
open Boolean
open Boolean
open Boolean
open Boolean
performHapticFeedback(feedbackConstant: Int)
open Boolean
performHapticFeedback(feedbackConstant: Int, flags: Int)
open Boolean
open Boolean
open ContentInfo?
open Unit
playSoundEffect(soundConstant: Int)
open Boolean
post(action: Runnable)
open Boolean
postDelayed(action: Runnable, delayMillis: Long)
open Unit
open Unit
postInvalidate(left: Int, top: Int, right: Int, bottom: Int)
open Unit
postInvalidateDelayed(delayMilliseconds: Long)
open Unit
postInvalidateDelayed(
    delayMilliseconds: Long,
    left: Int,
    top: Int,
    right: Int,
    bottom: Int
)
open Unit
open Unit
postInvalidateOnAnimation(left: Int, top: Int, right: Int, bottom: Int)
open Unit
open Unit
postOnAnimationDelayed(action: Runnable, delayMillis: Long)
open Unit
open Unit
open Boolean
open Unit
open Unit
open Unit
open Unit
open Unit
open Unit

This function is deprecated. Deprecated in Java

Boolean
Boolean
requestFocus(direction: Int)
open Boolean
requestFocus(direction: Int, previouslyFocusedRect: Rect)
Boolean
open Unit
open Unit
open Boolean
open Boolean
requestRectangleOnScreen(rectangle: Rect, immediate: Boolean)
Unit
Unit
T
<T : View> requireViewById(id: Int)
open Unit
open Boolean
open Unit
Unit
saveAttributeDataForStyleable(
    context: Context,
    styleable: IntArray,
    attrs: AttributeSet?,
    t: TypedArray,
    defStyleAttr: Int,
    defStyleRes: Int
)
open Unit
open Unit
scrollBy(x: Int, y: Int)
open Unit
scrollTo(x: Int, y: Int)
open Unit
setAccessibilityDataSensitive(accessibilityDataSensitive: Int)
open Unit
setAllowClickWhenDisabled(clickableWhenDisabled: Boolean)
open Unit
open Unit
open Unit
setAutofillHints(vararg autofillHints: String?)
open Unit
open Unit

This function is deprecated. Deprecated in Java

open Unit
open Unit
open Unit
setHandwritingBoundsOffsets(
    offsetLeft: Float,
    offsetTop: Float,
    offsetRight: Float,
    offsetBottom: Float
)
open Unit
setHasTransientState(hasTransientState: Boolean)
open Unit
setIsCredential(isCredential: Boolean)
open Unit
setIsHandwritingDelegate(isHandwritingDelegate: Boolean)
open Unit
open Unit
setLayerType(layerType: Int, paint: Paint?)
Unit
setLeftTopRightBottom(left: Int, top: Int, right: Int, bottom: Int)
Unit
setMeasuredDimension(measuredWidth: Int, measuredHeight: Int)
open Unit
open Unit
open Unit
open Unit
open Unit
open Unit
open Unit
open Unit
open Unit
open Unit
open Unit
setOnReceiveContentListener(
    mimeTypes: Array<String>?,
    listener: OnReceiveContentListener?
)
open Unit
open Unit

This function is deprecated. Deprecated in Java

open Unit
open Unit
setPadding(left: Int, top: Int, right: Int, bottom: Int)
open Unit
setPaddingRelative(start: Int, top: Int, end: Int, bottom: Int)
open Unit
open Unit
setRenderEffect(renderEffect: RenderEffect?)
Unit
open Unit
open Unit
open Unit
setWillNotCacheDrawing(willNotCacheDrawing: Boolean)

This function is deprecated. Deprecated in Java

open Unit
setWillNotDraw(willNotDraw: Boolean)
open Unit
open Boolean
open Boolean
open ActionMode
open ActionMode
open Unit
Boolean
startDrag(
    data: ClipData,
    shadowBuilder: View.DragShadowBuilder,
    myLocalState: Any,
    flags: Int
)

This function is deprecated. Deprecated in Java

Boolean
startDragAndDrop(
    data: ClipData,
    shadowBuilder: View.DragShadowBuilder,
    myLocalState: Any,
    flags: Int
)
open Boolean
open Unit
open Unit
open Unit
open Unit
Unit
open Boolean
open Boolean

This function is deprecated. Deprecated in Java

open Boolean
@ViewDebug.ExportedProperty(category = "drawing")
willNotDraw()
From android.view.ViewGroup
open Boolean
open Unit
addView(child: View)
open Unit
addView(child: View, index: Int)
open Unit
addView(child: View, index: Int, params: ViewGroup.LayoutParams)
open Unit
addView(child: View, width: Int, height: Int)
open Boolean
addViewInLayout(child: View, index: Int, params: ViewGroup.LayoutParams)
open Boolean
addViewInLayout(
    child: View,
    index: Int,
    params: ViewGroup.LayoutParams,
    preventRequestLayout: Boolean
)
open Unit
attachLayoutAnimationParameters(
    child: View,
    params: ViewGroup.LayoutParams,
    index: Int,
    count: Int
)
open Unit
attachViewToParent(child: View, index: Int, params: ViewGroup.LayoutParams)
open Boolean
open Boolean
open Unit
open Unit
open Unit
debug(depth: Int)
open Unit
open Unit
open Unit
open Unit
detachViewsFromParent(start: Int, count: Int)
open Unit
open Unit
open Boolean
drawChild(canvas: Canvas, child: View, drawingTime: Long)
open Unit
open FrameLayout.LayoutParams
open FrameLayout.LayoutParams
open ViewGroup.LayoutParams
open View
getChildAt(index: Int)
Int
getChildDrawingOrder(drawingPosition: Int)
open Int
getChildDrawingOrder(childCount: Int, drawingPosition: Int)
open Boolean
open Int
open Unit
measureChild(
    child: View,
    parentWidthMeasureSpec: Int,
    parentHeightMeasureSpec: Int
)
open Unit
measureChildWithMargins(
    child: View,
    parentWidthMeasureSpec: Int,
    widthUsed: Int,
    parentHeightMeasureSpec: Int,
    heightUsed: Int
)
open Unit
measureChildren(widthMeasureSpec: Int, heightMeasureSpec: Int)
Unit
Unit
open Boolean
open Boolean
open Boolean
onRequestFocusInDescendants(direction: Int, previouslyFocusedRect: Rect)
open Boolean
open Unit
onViewAdded(child: View)
open Unit
open Unit
propagateRequestedFrameRate(frameRate: Float, forceOverride: Boolean)
open Unit
open Unit
open Unit
removeDetachedView(child: View, animate: Boolean)
open Unit
removeViewAt(index: Int)
open Unit
open Unit
removeViews(start: Int, count: Int)
open Unit
removeViewsInLayout(start: Int, count: Int)
open Unit
open Unit
open Unit

This function is deprecated. Deprecated in Java

open Unit
open Unit
open Boolean
open Unit
open Unit
open Unit
From android.view.ViewManager
open Unit
addView(child: View, params: ViewGroup.LayoutParams)
open Unit
open Unit
From android.view.ViewParent
open Unit
open Unit
open Unit
childHasTransientStateChanged(
    child: View,
    childHasTransientState: Boolean
)
open Unit
open OnBackInvokedDispatcher?
open View
focusSearch(focused: View, direction: Int)
open Unit
open Boolean
getChildVisibleRect(child: View, r: Rect, offset: Point)
Unit
invalidateChild(child: View, dirty: Rect)

This function is deprecated. Deprecated in Java

open ViewParent
invalidateChildInParent(location: IntArray, dirty: Rect)

This function is deprecated. Deprecated in Java

open Unit
notifySubtreeAccessibilityStateChanged(
    child: View,
    source: View,
    changeType: Int
)
open Unit
onDescendantInvalidated(child: View, target: View)
open Boolean
onNestedFling(
    target: View,
    velocityX: Float,
    velocityY: Float,
    consumed: Boolean
)
open Boolean
onNestedPreFling(target: View, velocityX: Float, velocityY: Float)
open Boolean
onNestedPrePerformAccessibilityAction(
    target: View,
    action: Int,
    args: Bundle?
)
open Unit
onNestedPreScroll(target: View, dx: Int, dy: Int, consumed: IntArray)
open Unit
onNestedScroll(
    target: View,
    dxConsumed: Int,
    dyConsumed: Int,
    dxUnconsumed: Int,
    dyUnconsumed: Int
)
open Unit
onNestedScrollAccepted(child: View, target: View, axes: Int)
open Boolean
onStartNestedScroll(child: View, target: View, nestedScrollAxes: Int)
open Unit
open Unit
open Unit
requestChildFocus(child: View, focused: View)
open Boolean
requestChildRectangleOnScreen(
    child: View,
    rectangle: Rect,
    immediate: Boolean
)
open Unit
open Boolean
open Unit
open Boolean
open Boolean
showContextMenuForChild(originalView: View, x: Float, y: Float)
open ActionMode
startActionModeForChild(
    originalView: View,
    callback: ActionMode.Callback
)
open ActionMode
startActionModeForChild(
    originalView: View,
    callback: ActionMode.Callback,
    type: Int
)

Inherited properties

From android.widget.FrameLayout
From android.view.View
open View.AccessibilityDelegate
open Int
open AccessibilityNodeProvider
open CharSequence?
open Int
open Int
open String?
open String?
open Float
open Animation
open Matrix?
open IBinder
open MutableMap<IntInt>
open Array<String>?
AutofillId
open Int
open AutofillValue?
open Drawable
open BlendMode?
open ColorStateList?
open PorterDuff.Mode?
open Int
Int
open Float
open Int
open Float
open Rect
Boolean
ContentCaptureSession?
open CharSequence
Int
Context
open ContextMenu.ContextMenuInfo
Boolean
open Display
IntArray
open Bitmap
open Int
open Int
open Long
open Float
open Int
open Boolean
open Boolean
open Int
open Drawable
open Int
open BlendMode?
open ColorStateList?
open PorterDuff.Mode?
open Float
open Handler
open Float
open Float
open Float
open Float
open Int
open Runnable?
Boolean
Int
open Int
open Int
open Drawable?
open Drawable?
open Int
open Int
open Int
open Int
open Boolean
open Boolean
open Boolean
open Boolean
open Boolean
open Boolean
open Boolean
Boolean
open Boolean
open Boolean
open Boolean
open Boolean
open Boolean
open Boolean
Boolean
Boolean
open Boolean
Boolean
open Boolean
open Boolean
open Boolean
open Boolean
open Boolean
open Boolean
open Boolean
open Boolean
Boolean
Boolean
open Boolean
open Boolean
open Boolean
Boolean
open Boolean
open Boolean
open Boolean
open Boolean
open Boolean
open Boolean
open Boolean
open Boolean
open Boolean
Boolean
open Boolean
open Boolean
open Boolean
open Boolean
open Boolean
open Boolean
open Boolean
Boolean
open Boolean
open Boolean
Boolean
open Boolean
open Boolean
open Boolean
open Boolean
open Boolean
open KeyEvent.DispatcherState
open Int
open Int
open Int
open ViewGroup.LayoutParams
Int
open Float
open Int
open Matrix
Int
Int
Int
Int
Int
open Int
open Int
open Int
open Int
open Int
open Int
open Int
open Int
open View.OnFocusChangeListener
open Int
open ViewOutlineProvider
open Int
open Int
open Int
open Int
open Int
open Int
open Int
open Int
final ViewParent
open ViewParent
OutcomeReceiver<GetCredentialResponseGetCredentialException>?
GetCredentialRequest?
open Float
open Float
open PointerIcon
MutableList<Rect>
open Array<String>?
open Float
open Resources
Boolean
Int
open Float
open Int
open AttachedSurfaceControl?
open View
open WindowInsets
open Float
open Float
open Float
open Float
open Float
open Int
open Int
open Int
open Int
open Int
open Int
Int
Int
open Int
open Int
CharSequence?
open StateListAnimator
open Int
open Int
open CharSequence?
open MutableList<Rect>
open Int
open Any
open Int
open Int
open CharSequence?
Int
open Float
open Int
open TouchDelegate
open ArrayList<View>
open Float
open String
open Float
open Float
open Float
open Long
open Int
open Int
open Drawable?
open Drawable?
open Int
open ViewTranslationResponse?
open ViewTreeObserver
open Int
Int
open Int
open WindowId
open WindowInsetsController?
open Int
open IBinder
open Int
open Float
open Float
open Float
From android.view.ViewGroup

Public constructors

InProgressShapesView

<ShapeSpecT : Any, InProgressShapeT : InProgressShape<ShapeSpecT, CompletedShapeT>, CompletedShapeT : Any> InProgressShapesView(
    context: Context,
    attrs: AttributeSet? = null,
    defStyleAttr: @AttrRes Int = 0
)

Public functions

addCompletedShapesListener

Added in 1.0.0
fun addCompletedShapesListener(
    listener: InProgressShapesCompletedListener<CompletedShapeT>
): Unit

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
fun addToShape(event: MotionEvent, pointerId: Int, prediction: MotionEvent? = null): Boolean

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
event: MotionEvent

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

pointerId: Int

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.

prediction: MotionEvent? = null

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
fun addToShape(
    inputs: StrokeInputBatch,
    shapeId: InProgressStrokeId,
    prediction: StrokeInputBatch = ImmutableStrokeInputBatch.EMPTY
): Unit

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
inputs: StrokeInputBatch

The next StrokeInputBatch to be added to the shape.

shapeId: InProgressStrokeId

The InProgressStrokeId of the shape to be built upon.

prediction: StrokeInputBatch = ImmutableStrokeInputBatch.EMPTY

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
fun addToShape(
    event: MotionEvent,
    pointerId: Int,
    shapeId: InProgressStrokeId,
    prediction: MotionEvent? = null
): Unit

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
event: MotionEvent

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

pointerId: Int

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.

shapeId: InProgressStrokeId

The InProgressStrokeId of the shape to be built upon.

prediction: MotionEvent? = null

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
fun cancelShape(event: MotionEvent, pointerId: Int): Boolean

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
event: MotionEvent

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

pointerId: Int

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
fun cancelShape(shapeId: InProgressStrokeId, event: MotionEvent? = null): Unit

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
shapeId: InProgressStrokeId

The InProgressStrokeId of the shape to be canceled.

event: MotionEvent? = null

The MotionEvent that led to this cancellation, if applicable.

cancelUnfinishedShapes

Added in 1.0.0
fun cancelUnfinishedShapes(): Unit

Cancel all in-progress shapes.

clearCompletedShapesListeners

Added in 1.0.0
fun clearCompletedShapesListeners(): Unit

Removes all listeners that had previously been added with addCompletedShapesListener.

eagerInit

Added in 1.0.0
fun eagerInit(): Unit

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
fun finishShape(event: MotionEvent, pointerId: Int): Boolean

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
event: MotionEvent

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

pointerId: Int

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
fun finishShape(input: StrokeInput, shapeId: InProgressStrokeId): Unit

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
input: StrokeInput

The last StrokeInput in the shape.

shapeId: InProgressStrokeId

The InProgressStrokeId of the shape to be finished.

finishShape

Added in 1.0.0
fun finishShape(
    event: MotionEvent,
    pointerId: Int,
    shapeId: InProgressStrokeId
): Unit

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
event: MotionEvent

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.

pointerId: Int

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.

shapeId: InProgressStrokeId

The InProgressStrokeId of the shape to be finished.

getCompletedShapes

Added in 1.0.0
fun getCompletedShapes(): Map<InProgressStrokeId, 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. 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.

hasUnfinishedShapes

Added in 1.0.0
fun hasUnfinishedShapes(): Boolean

Returns true if there are any in-progress shapes.

removeCompletedShapes

Added in 1.0.0
@UiThread
fun removeCompletedShapes(strokeIds: Set<InProgressStrokeId>): Unit

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
fun removeCompletedShapesListener(
    listener: InProgressShapesCompletedListener<CompletedShapeT>
): Unit

Removes a listener that had previously been added with addCompletedShapesListener.

startShape

Added in 1.0.0
fun startShape(
    input: StrokeInput,
    shapeSpec: ShapeSpecT,
    shapeToViewTransform: Matrix = IDENTITY_MATRIX
): InProgressStrokeId

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
input: StrokeInput

The StrokeInput that started a shape.

shapeSpec: ShapeSpecT

Specification for the shape being started.

shapeToViewTransform: Matrix = IDENTITY_MATRIX

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

Returns
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
fun startShape(
    event: MotionEvent,
    pointerId: Int,
    shapeSpec: ShapeSpecT,
    motionEventToWorldTransform: Matrix = IDENTITY_MATRIX,
    shapeToWorldTransform: Matrix = IDENTITY_MATRIX
): InProgressStrokeId

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
event: MotionEvent

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.

pointerId: Int

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.

shapeSpec: ShapeSpecT

Specification for the shape being started.

motionEventToWorldTransform: Matrix = IDENTITY_MATRIX

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.

shapeToWorldTransform: Matrix = IDENTITY_MATRIX

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
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 functions

onAttachedToWindow

protected open fun onAttachedToWindow(): Unit

onDetachedFromWindow

protected open fun onDetachedFromWindow(): Unit

Public properties

customShapeWorkflow

Added in 1.0.0
var customShapeWorkflowShapeWorkflow<ShapeSpecT, InProgressShapeT, CompletedShapeT>?

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.

inProgressShapeCounter

Added in 1.0.0
@VisibleForTesting
var inProgressShapeCounterCountingIdlingResource?

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.

maskPath

Added in 1.0.0
var maskPathPath?

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.

motionEventToViewTransform

Added in 1.0.0
var motionEventToViewTransformMatrix

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.