ViewConfigurationCompat

Added in 1.1.0

class ViewConfigurationCompat


Helper for accessing features in ViewConfiguration.

Summary

Public functions

java-static Float
getScaledHorizontalScrollFactor(
    config: ViewConfiguration,
    context: Context
)
java-static Int
java-static Int
getScaledMaximumFlingVelocity(
    context: Context,
    config: ViewConfiguration,
    inputDeviceId: Int,
    axis: Int,
    source: Int
)

Maximum absolute value of velocity to initiate a fling for a motion generated by an InputDevice with an id of inputDeviceId, from an input source and on a given motion event axis.

java-static Int
getScaledMinimumFlingVelocity(
    context: Context,
    config: ViewConfiguration,
    inputDeviceId: Int,
    axis: Int,
    source: Int
)

Minimum absolute value of velocity to initiate a fling for a motion generated by an InputDevice with an id of inputDeviceId, from an input source and on a given motion event axis.

java-static Int
@ReplaceWith(expression = "config.getScaledPagingTouchSlop()")
getScaledPagingTouchSlop(config: ViewConfiguration!)

This function is deprecated.

Call getScaledPagingTouchSlop directly.

java-static Float
getScaledVerticalScrollFactor(
    config: ViewConfiguration,
    context: Context
)
java-static Boolean
@ReplaceWith(expression = "config.hasPermanentMenuKey()")
hasPermanentMenuKey(config: ViewConfiguration!)

This function is deprecated.

Use hasPermanentMenuKey directly.

java-static Boolean

Check if shortcuts should be displayed in menus.

Public functions

getScaledHorizontalScrollFactor

Added in 1.1.0
java-static fun getScaledHorizontalScrollFactor(
    config: ViewConfiguration,
    context: Context
): Float
Parameters
config: ViewConfiguration

Used to get the scaling factor directly from the ViewConfiguration.

context: Context

Used to locate a resource value.

Returns
Float

Amount to scroll in response to a horizontal ACTION_SCROLL event. Multiply this by the event's axis value to obtain the number of pixels to be scrolled.

getScaledHoverSlop

Added in 1.1.0
java-static fun getScaledHoverSlop(config: ViewConfiguration): Int
Parameters
config: ViewConfiguration

Used to get the hover slop directly from the ViewConfiguration.

Returns
Int

The hover slop value.

getScaledMaximumFlingVelocity

Added in 1.12.0
java-static fun getScaledMaximumFlingVelocity(
    context: Context,
    config: ViewConfiguration,
    inputDeviceId: Int,
    axis: Int,
    source: Int
): Int

Maximum absolute value of velocity to initiate a fling for a motion generated by an InputDevice with an id of inputDeviceId, from an input source and on a given motion event axis.

Similar to getScaledMinimumFlingVelocity, but for maximum fling velocity, instead of minimum. Also, unlike that method which returns Integer.MAX_VALUE for bad input device ID, source and/or motion event axis inputs, this method returns Integer.MIN_VALUE for such bad inputs.

getScaledMinimumFlingVelocity

Added in 1.12.0
java-static fun getScaledMinimumFlingVelocity(
    context: Context,
    config: ViewConfiguration,
    inputDeviceId: Int,
    axis: Int,
    source: Int
): Int

Minimum absolute value of velocity to initiate a fling for a motion generated by an InputDevice with an id of inputDeviceId, from an input source and on a given motion event axis.

Before utilizing this method to get a minimum fling velocity for a motion generated by the input device, scale the velocity of the motion events generated by the input device to pixels per second.

For instance, if you tracked AXIS_SCROLL vertical velocities generated from a SOURCE_ROTARY_ENCODER, the velocity returned from VelocityTracker will be in the units with which the axis values were reported in the motion event. Before comparing that velocity against the minimum fling velocity specified here, make sure that the AXIS_SCROLL velocity from the tracker is calculated in "units per second" (see computeCurrentVelocity, computeCurrentVelocity to adjust your velocity computations to "per second"), and use getScaledVerticalScrollFactor to change this velocity value to "pixels/second".

If the provided inputDeviceId is not valid, or if the input device whose ID is provided does not support the given motion event source and/or axis, this method will return Integer.MAX_VALUE.

Obtaining the correct arguments for this method call

inputDeviceId: if calling this method in response to a MotionEvent, use the device ID that is reported by the event, which can be obtained using getDeviceId. Otherwise, use a valid ID that is obtained from getId, or from an InputManager instance (getInputDeviceIds gives all the valid input device IDs).

axis: a MotionEvent may report data for multiple axes, and each axis may have multiple data points for different pointers. Use the axis for which you obtained the velocity for (VelocityTracker lets you calculate velocities for a specific axis. Use the axis for which you calculated velocity). You can use getMotionRanges to get all the InputDevice.MotionRanges for the InputDevice, from which you can derive all the valid axes for the device.

source: use getSource if calling this method in response to a MotionEvent. Otherwise, use a valid source for the InputDevice. You can use getMotionRanges to get all the InputDevice.MotionRanges for the InputDevice, from which you can derive all the valid sources for the device.

This method optimizes calls over multiple input device IDs, so caching the return value of the method is not necessary if you are handling multiple input devices.

Parameters
context: Context

the Context associated with the view.

config: ViewConfiguration

the ViewConfiguration to derive the minimum fling velocity from.

inputDeviceId: Int

the ID of the InputDevice that generated the motion triggering fling.

axis: Int

the axis on which the motion triggering the fling happened. This axis should be a valid axis that can be reported by the provided input device from the provided input device source.

source: Int

the input source of the motion causing fling. This source should be a valid source for the InputDevice whose ID is inputDeviceId.

Returns
Int

the minimum velocity, in pixels/second, to trigger fling.

getScaledPagingTouchSlop

Added in 1.1.0
Deprecated in 1.1.0
@ReplaceWith(expression = "config.getScaledPagingTouchSlop()")
java-static fun getScaledPagingTouchSlop(config: ViewConfiguration!): Int

Call getScaledPagingTouchSlop.

getScaledVerticalScrollFactor

Added in 1.1.0
java-static fun getScaledVerticalScrollFactor(
    config: ViewConfiguration,
    context: Context
): Float
Parameters
config: ViewConfiguration

Used to get the scaling factor directly from the ViewConfiguration.

context: Context

Used to locate a resource value.

Returns
Float

Amount to scroll in response to a vertical ACTION_SCROLL event. Multiply this by the event's axis value to obtain the number of pixels to be scrolled.

hasPermanentMenuKey

Added in 1.1.0
Deprecated in 1.1.0
@ReplaceWith(expression = "config.hasPermanentMenuKey()")
java-static fun hasPermanentMenuKey(config: ViewConfiguration!): Boolean

Report if the device has a permanent menu key available to the user, in a backwards compatible way.

shouldShowMenuShortcutsWhenKeyboardPresent

Added in 1.1.0
java-static fun shouldShowMenuShortcutsWhenKeyboardPresent(
    config: ViewConfiguration,
    context: Context
): Boolean

Check if shortcuts should be displayed in menus.

Returns
Boolean

True if shortcuts should be displayed in menus.