Class BaseCameraView

java.lang.Object
android.view.View
android.view.ViewGroup
com.microblink.blinkid.view.BaseCameraView
All Implemented Interfaces:
android.graphics.drawable.Drawable.Callback, android.view.accessibility.AccessibilityEventSource, android.view.KeyEvent.Callback, android.view.ViewManager, android.view.ViewParent
Direct Known Subclasses:
CameraViewGroup

public abstract class BaseCameraView extends android.view.ViewGroup
Created by dodo on 25/08/16.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    protected class 
     
    protected class 
     
    protected class 
     
    static enum 
     
    protected static interface 
     

    Nested classes/interfaces inherited from class android.view.ViewGroup

    android.view.ViewGroup.LayoutParams, android.view.ViewGroup.MarginLayoutParams, android.view.ViewGroup.OnHierarchyChangeListener

    Nested classes/interfaces inherited from class android.view.View

    android.view.View.AccessibilityDelegate, android.view.View.BaseSavedState, android.view.View.DragShadowBuilder, android.view.View.MeasureSpec, android.view.View.OnApplyWindowInsetsListener, android.view.View.OnAttachStateChangeListener, android.view.View.OnCapturedPointerListener, android.view.View.OnClickListener, android.view.View.OnContextClickListener, android.view.View.OnCreateContextMenuListener, android.view.View.OnDragListener, android.view.View.OnFocusChangeListener, android.view.View.OnGenericMotionListener, android.view.View.OnHoverListener, android.view.View.OnKeyListener, android.view.View.OnLayoutChangeListener, android.view.View.OnLongClickListener, android.view.View.OnScrollChangeListener, android.view.View.OnSystemUiVisibilityChangeListener, android.view.View.OnTouchListener, android.view.View.OnUnhandledKeyEventListener
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    Defines the way camera preview will be layouted inside view
    Listener that will receive various camera events
    protected com.microblink.blinkid.view.surface.ICameraView
    View element
     
    protected int
    Current configuration orientation
    protected com.microblink.blinkid.hardware.DeviceManager
    Device manager that will load device list from resources
    protected boolean
    Flag indicating there has been an unrecoverable error
    protected int
    Orientation of the host activity
    protected Orientation
    Initial orientation which will be used for frame orientation if mOrientation is unknown
    protected boolean
     
    protected boolean
     
    Listener that will be notified when activity flip occurs.
    protected com.microblink.blinkid.hardware.orientation.OrientationChangeListener
     
    protected float
     
    protected boolean
     
    protected ConcurrentLinkedQueue<com.microblink.blinkid.hardware.orientation.OrientationChangeListener>
    Slave orientation change listeners that can be notified on orientation change events generated by mOrientationManager

    Fields inherited from class android.view.ViewGroup

    CLIP_TO_PADDING_MASK, FOCUS_AFTER_DESCENDANTS, FOCUS_BEFORE_DESCENDANTS, FOCUS_BLOCK_DESCENDANTS, LAYOUT_MODE_CLIP_BOUNDS, LAYOUT_MODE_OPTICAL_BOUNDS, PERSISTENT_ALL_CACHES, PERSISTENT_ANIMATION_CACHE, PERSISTENT_NO_CACHE, PERSISTENT_SCROLLING_CACHE

    Fields inherited from class android.view.View

    ACCESSIBILITY_DATA_SENSITIVE_AUTO, ACCESSIBILITY_DATA_SENSITIVE_NO, ACCESSIBILITY_DATA_SENSITIVE_YES, ACCESSIBILITY_LIVE_REGION_ASSERTIVE, ACCESSIBILITY_LIVE_REGION_NONE, ACCESSIBILITY_LIVE_REGION_POLITE, ALPHA, AUTOFILL_FLAG_INCLUDE_NOT_IMPORTANT_VIEWS, AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DATE, AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DAY, AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_MONTH, AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_YEAR, AUTOFILL_HINT_CREDIT_CARD_NUMBER, AUTOFILL_HINT_CREDIT_CARD_SECURITY_CODE, AUTOFILL_HINT_EMAIL_ADDRESS, AUTOFILL_HINT_NAME, AUTOFILL_HINT_PASSWORD, AUTOFILL_HINT_PHONE, AUTOFILL_HINT_POSTAL_ADDRESS, AUTOFILL_HINT_POSTAL_CODE, AUTOFILL_HINT_USERNAME, AUTOFILL_TYPE_DATE, AUTOFILL_TYPE_LIST, AUTOFILL_TYPE_NONE, AUTOFILL_TYPE_TEXT, AUTOFILL_TYPE_TOGGLE, DRAG_FLAG_ACCESSIBILITY_ACTION, DRAG_FLAG_GLOBAL, DRAG_FLAG_GLOBAL_PERSISTABLE_URI_PERMISSION, DRAG_FLAG_GLOBAL_PREFIX_URI_PERMISSION, DRAG_FLAG_GLOBAL_URI_READ, DRAG_FLAG_GLOBAL_URI_WRITE, DRAG_FLAG_OPAQUE, DRAWING_CACHE_QUALITY_AUTO, DRAWING_CACHE_QUALITY_HIGH, DRAWING_CACHE_QUALITY_LOW, EMPTY_STATE_SET, ENABLED_FOCUSED_SELECTED_STATE_SET, ENABLED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, ENABLED_FOCUSED_STATE_SET, ENABLED_FOCUSED_WINDOW_FOCUSED_STATE_SET, ENABLED_SELECTED_STATE_SET, ENABLED_SELECTED_WINDOW_FOCUSED_STATE_SET, ENABLED_STATE_SET, ENABLED_WINDOW_FOCUSED_STATE_SET, FIND_VIEWS_WITH_CONTENT_DESCRIPTION, FIND_VIEWS_WITH_TEXT, FOCUS_BACKWARD, FOCUS_DOWN, FOCUS_FORWARD, FOCUS_LEFT, FOCUS_RIGHT, FOCUS_UP, FOCUSABLE, FOCUSABLE_AUTO, FOCUSABLES_ALL, FOCUSABLES_TOUCH_MODE, FOCUSED_SELECTED_STATE_SET, FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, FOCUSED_STATE_SET, FOCUSED_WINDOW_FOCUSED_STATE_SET, GONE, HAPTIC_FEEDBACK_ENABLED, IMPORTANT_FOR_ACCESSIBILITY_AUTO, IMPORTANT_FOR_ACCESSIBILITY_NO, IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS, IMPORTANT_FOR_ACCESSIBILITY_YES, IMPORTANT_FOR_AUTOFILL_AUTO, IMPORTANT_FOR_AUTOFILL_NO, IMPORTANT_FOR_AUTOFILL_NO_EXCLUDE_DESCENDANTS, IMPORTANT_FOR_AUTOFILL_YES, IMPORTANT_FOR_AUTOFILL_YES_EXCLUDE_DESCENDANTS, IMPORTANT_FOR_CONTENT_CAPTURE_AUTO, IMPORTANT_FOR_CONTENT_CAPTURE_NO, IMPORTANT_FOR_CONTENT_CAPTURE_NO_EXCLUDE_DESCENDANTS, IMPORTANT_FOR_CONTENT_CAPTURE_YES, IMPORTANT_FOR_CONTENT_CAPTURE_YES_EXCLUDE_DESCENDANTS, INVISIBLE, KEEP_SCREEN_ON, LAYER_TYPE_HARDWARE, LAYER_TYPE_NONE, LAYER_TYPE_SOFTWARE, LAYOUT_DIRECTION_INHERIT, LAYOUT_DIRECTION_LOCALE, LAYOUT_DIRECTION_LTR, LAYOUT_DIRECTION_RTL, MEASURED_HEIGHT_STATE_SHIFT, MEASURED_SIZE_MASK, MEASURED_STATE_MASK, MEASURED_STATE_TOO_SMALL, NO_ID, NOT_FOCUSABLE, OVER_SCROLL_ALWAYS, OVER_SCROLL_IF_CONTENT_SCROLLS, OVER_SCROLL_NEVER, PRESSED_ENABLED_FOCUSED_SELECTED_STATE_SET, PRESSED_ENABLED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_ENABLED_FOCUSED_STATE_SET, PRESSED_ENABLED_FOCUSED_WINDOW_FOCUSED_STATE_SET, PRESSED_ENABLED_SELECTED_STATE_SET, PRESSED_ENABLED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_ENABLED_STATE_SET, PRESSED_ENABLED_WINDOW_FOCUSED_STATE_SET, PRESSED_FOCUSED_SELECTED_STATE_SET, PRESSED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_FOCUSED_STATE_SET, PRESSED_FOCUSED_WINDOW_FOCUSED_STATE_SET, PRESSED_SELECTED_STATE_SET, PRESSED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_STATE_SET, PRESSED_WINDOW_FOCUSED_STATE_SET, ROTATION, ROTATION_X, ROTATION_Y, SCALE_X, SCALE_Y, SCREEN_STATE_OFF, SCREEN_STATE_ON, SCROLL_AXIS_HORIZONTAL, SCROLL_AXIS_NONE, SCROLL_AXIS_VERTICAL, SCROLL_CAPTURE_HINT_AUTO, SCROLL_CAPTURE_HINT_EXCLUDE, SCROLL_CAPTURE_HINT_EXCLUDE_DESCENDANTS, SCROLL_CAPTURE_HINT_INCLUDE, SCROLL_INDICATOR_BOTTOM, SCROLL_INDICATOR_END, SCROLL_INDICATOR_LEFT, SCROLL_INDICATOR_RIGHT, SCROLL_INDICATOR_START, SCROLL_INDICATOR_TOP, SCROLLBAR_POSITION_DEFAULT, SCROLLBAR_POSITION_LEFT, SCROLLBAR_POSITION_RIGHT, SCROLLBARS_INSIDE_INSET, SCROLLBARS_INSIDE_OVERLAY, SCROLLBARS_OUTSIDE_INSET, SCROLLBARS_OUTSIDE_OVERLAY, SELECTED_STATE_SET, SELECTED_WINDOW_FOCUSED_STATE_SET, SOUND_EFFECTS_ENABLED, STATUS_BAR_HIDDEN, STATUS_BAR_VISIBLE, SYSTEM_UI_FLAG_FULLSCREEN, SYSTEM_UI_FLAG_HIDE_NAVIGATION, SYSTEM_UI_FLAG_IMMERSIVE, SYSTEM_UI_FLAG_IMMERSIVE_STICKY, SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN, SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION, SYSTEM_UI_FLAG_LAYOUT_STABLE, SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR, SYSTEM_UI_FLAG_LIGHT_STATUS_BAR, SYSTEM_UI_FLAG_LOW_PROFILE, SYSTEM_UI_FLAG_VISIBLE, SYSTEM_UI_LAYOUT_FLAGS, TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_GRAVITY, TEXT_ALIGNMENT_INHERIT, TEXT_ALIGNMENT_TEXT_END, TEXT_ALIGNMENT_TEXT_START, TEXT_ALIGNMENT_VIEW_END, TEXT_ALIGNMENT_VIEW_START, TEXT_DIRECTION_ANY_RTL, TEXT_DIRECTION_FIRST_STRONG, TEXT_DIRECTION_FIRST_STRONG_LTR, TEXT_DIRECTION_FIRST_STRONG_RTL, TEXT_DIRECTION_INHERIT, TEXT_DIRECTION_LOCALE, TEXT_DIRECTION_LTR, TEXT_DIRECTION_RTL, TRANSLATION_X, TRANSLATION_Y, TRANSLATION_Z, VIEW_LOG_TAG, VISIBLE, WINDOW_FOCUSED_STATE_SET, X, Y, Z
  • Constructor Summary

    Constructors
    Constructor
    Description
    BaseCameraView(android.content.Context context)
     
    BaseCameraView(android.content.Context context, android.util.AttributeSet attrs)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addOrientationChangeListener(com.microblink.blinkid.hardware.orientation.OrientationChangeListener orientationChangeListener)
    Adds the orientation listener that will receive orientation change events that are already reported to BaseCameraView.
    protected boolean
     
    protected int
     
    protected void
     
    void
    changeConfiguration(android.content.res.Configuration newConfiguration)
    This method changes the view's configuration.
    protected void
    changeConfigurationInternal(android.content.res.Configuration newConfiguration)
     
    void
    Creates the view and its subviews and initializes camera settings.
    protected abstract com.microblink.blinkid.hardware.camera.CameraListener
    ABSTRACT METHODS
    protected com.microblink.blinkid.view.surface.ICameraView.CameraViewEventListener
     
    protected com.microblink.blinkid.hardware.orientation.OrientationChangeListener
     
    void
     
    boolean
    dispatchTouchEvent(android.view.MotionEvent ev)
     
    final void
    Request a new autofocus cycle from camera.
    Returns the aspect mode of camera preview.
    Returns the current camera events listener.
    protected com.microblink.blinkid.hardware.camera.CameraSettings
     
    final int
    Returns the height in pixels of the actual camera preview (does not have to be same as getHeight).
    final int
    Returns the width in pixels of the actual camera preview (does not have to be same as getWidth).
    protected int
     
    Returns the current lifecycle state of camera view.
    protected final int
     
     
    final int
    Returns the current high res frame limit
    protected android.app.Activity
     
    int
    Returns the host's screen orientation as detected internally.
    Returns the initial orientation of rotatable view as set by setInitialOrientation.
    Returns the type of the currently opened camera or null if currently there is no opened camera.
    float
    Returns the preview zoom scale that is used to draw the camera preview.
    android.graphics.RectF
    Returns the rectangle that which part of camera frame is visible in view
    final float
    Returns the current camera zoom level.
    final Boolean
    Returns true if opened camera supports autofocus.
    final boolean
    Returns true if camera is currently active.
    final boolean
    Returns true if camera is currently in focus
    final boolean
    Returns true if camera has got torch.
    final boolean
    Returns true if the device is being shaken
    boolean
    Returns true if high res frame capture was enabled.
    protected boolean
     
    protected final boolean
     
    final boolean
    Returns true if camera view will handle pinch events to manage camera zoom level.
    protected static boolean
    isRequestedOrientationSensor(int requestedOrientation)
     
    protected boolean
    isRequestedOrientationUser(int requestedOrientation)
     
    final boolean
    Returns true if camera view will handle tap events to ask camera to perform autofocus on tapped area.
    protected abstract void
    Called when activity is flipped - this event is not raised by OS so we have custom detection of that state.
    protected void
     
    protected void
     
    protected void
    onLayout(boolean changed, int l, int t, int r, int b)
     
    protected void
    onMeasure(int widthMeasureSpec, int heightMeasureSpec)
     
    void
    This method must be called from activity's onPause.
    protected void
    prepareCameraSettings(com.microblink.blinkid.hardware.camera.CameraSettings settings)
    Called inside onCreate method before creating camera manager.
    void
    removeOrientationChangeListener(com.microblink.blinkid.hardware.orientation.OrientationChangeListener orientationChangeListener)
    Removes a single listener instance from listeners collection, if it is present.
    protected abstract boolean
    If autofocus feature is required, please return true from this method.
    void
    This method must be called from activity's onResume.
    protected void
    Ensures given runnable is run on UI thread.
    void
    Defines the aspect mode of camera preview.
    void
    Sets the listener that will receive various camera events, such as when camera preview has started or camera initialization error has occurred.
    final void
    setCameraFrameFactory(com.microblink.blinkid.hardware.camera.frame.CameraFrameFactory cameraFrameFactory)
    Set your custom implementation of camera frame factory.
    void
    Sets the camera type that will be used.
    final void
    setForceUseLegacyCamera(boolean useLegacyCamera)
    With this method you can request using legacy Camera API even on devices that natively support new Camera2 API.
    void
    High res frame capture is disabled by default and needs to be enabled by using this method.
    final void
    setHighResFrameLimit(int highResFrameLimit)
    Sets the maximum number of high res frames that can be active at a given moment.
    void
    setInitialOrientation(Orientation initialOrientation)
    Sets the initial orientation of rotatable view and recognizer.
    final void
    setMeteringAreas(android.graphics.RectF[] meteringAreas, boolean rotateAreasWithDevice)
    Sets the areas where camera will perform focus, exposure and white balance meterings.
    protected void
     
    final void
    Sets the listener that will be notified when activity flip event occurs.
    final void
    Sets the listener that will be notified when size of child views changes.
    final void
    setOptimizeCameraForNearScan(boolean nearScan)
     
    void
    Sets the listener that will be asked if device orientation is allowed prior rotating rotatable view and native recognizer to that orientation.
    final void
    setPinchToZoomAllowed(boolean allowPinchToZoom)
    Sets whether camear view will handle pinch events to manage camera zoom level.
    void
    setPreviewZoomScale(float previewZoomScale)
    Sets the preview zoom scale that will be used to draw the camera preview.
    final void
    setRequestAutofocusOnShakingStopInContinousAutofocusMode(boolean requestAutofocusOnShakingStopInContinousAutofocusMode)
    If device supports continous autofocus mode, enabling this feature will request normal autofocus every time device shaking stops.
    final void
    setRequestedSurfaceViewForCameraDisplay(com.microblink.blinkid.view.surface.CameraSurface requestedSurface)
    In order to display camera preview, camera view must use one of two android's view's that are capable of displaying camera preview video stream: SurfaceView and TextureView.
    void
    Sets the shake callback that will be notified about device shake events.
    final void
    setTapToFocusAllowed(boolean allowTapToFocus)
    Sets whether camera view will handle tap events to ask camera to perform autofocus on tapped area.
    final void
    setTorchState(boolean on, SuccessCallback successCallback)
    Turns the torch on the camera on or off.
    final void
     
    protected void
     
    final void
    setZoomLevel(float zoomLevel)
    Sets the camera zoom level.
    protected boolean
     
    void
     
    void
     

    Methods inherited from class android.view.ViewGroup

    addChildrenForAccessibility, addExtraDataToAccessibilityNodeInfo, addFocusables, addKeyboardNavigationClusters, addStatesFromChildren, addTouchables, addView, addView, addView, addView, addView, addViewInLayout, addViewInLayout, attachLayoutAnimationParameters, attachViewToParent, bringChildToFront, canAnimate, checkLayoutParams, childDrawableStateChanged, childHasTransientStateChanged, cleanupLayoutState, clearChildFocus, clearDisappearingChildren, clearFocus, debug, detachAllViewsFromParent, detachViewFromParent, detachViewFromParent, detachViewsFromParent, dispatchApplyWindowInsets, dispatchCapturedPointerEvent, dispatchConfigurationChanged, dispatchCreateViewTranslationRequest, dispatchDisplayHint, dispatchDragEvent, dispatchDraw, dispatchDrawableHotspotChanged, dispatchFinishTemporaryDetach, dispatchFreezeSelfOnly, dispatchGenericFocusedEvent, dispatchGenericPointerEvent, dispatchHoverEvent, dispatchKeyEvent, dispatchKeyEventPreIme, dispatchKeyShortcutEvent, dispatchPointerCaptureChanged, dispatchProvideAutofillStructure, dispatchProvideStructure, dispatchRestoreInstanceState, dispatchSaveInstanceState, dispatchScrollCaptureSearch, dispatchSetActivated, dispatchSetPressed, dispatchSetSelected, dispatchStartTemporaryDetach, dispatchSystemUiVisibilityChanged, dispatchThawSelfOnly, dispatchTrackballEvent, dispatchUnhandledMove, dispatchVisibilityChanged, dispatchWindowFocusChanged, dispatchWindowInsetsAnimationEnd, dispatchWindowInsetsAnimationPrepare, dispatchWindowInsetsAnimationProgress, dispatchWindowInsetsAnimationStart, dispatchWindowSystemUiVisiblityChanged, dispatchWindowVisibilityChanged, drawableStateChanged, drawChild, endViewTransition, findFocus, findOnBackInvokedDispatcherForChild, findViewsWithText, focusableViewAvailable, focusSearch, gatherTransparentRegion, generateDefaultLayoutParams, generateLayoutParams, generateLayoutParams, getAccessibilityClassName, getChildAt, getChildCount, getChildDrawingOrder, getChildDrawingOrder, getChildMeasureSpec, getChildStaticTransformation, getChildVisibleRect, getClipChildren, getClipToPadding, getDescendantFocusability, getFocusedChild, getLayoutAnimation, getLayoutAnimationListener, getLayoutMode, getLayoutTransition, getNestedScrollAxes, getOverlay, getPersistentDrawingCache, getTouchscreenBlocksFocus, hasFocus, hasTransientState, indexOfChild, invalidateChild, invalidateChildInParent, isAlwaysDrawnWithCacheEnabled, isAnimationCacheEnabled, isChildrenDrawingOrderEnabled, isChildrenDrawnWithCacheEnabled, isLayoutSuppressed, isMotionEventSplittingEnabled, isTransitionGroup, jumpDrawablesToCurrentState, layout, measureChild, measureChildren, measureChildWithMargins, notifySubtreeAccessibilityStateChanged, offsetDescendantRectToMyCoords, offsetRectIntoDescendantCoords, onAttachedToWindow, onCreateDrawableState, onDescendantInvalidated, onDetachedFromWindow, onInterceptHoverEvent, onInterceptTouchEvent, onNestedFling, onNestedPreFling, onNestedPrePerformAccessibilityAction, onNestedPreScroll, onNestedScroll, onNestedScrollAccepted, onRequestFocusInDescendants, onRequestSendAccessibilityEvent, onResolvePointerIcon, onStartNestedScroll, onStopNestedScroll, onViewAdded, onViewRemoved, recomputeViewAttributes, removeAllViews, removeAllViewsInLayout, removeDetachedView, removeView, removeViewAt, removeViewInLayout, removeViews, removeViewsInLayout, requestChildFocus, requestChildRectangleOnScreen, requestDisallowInterceptTouchEvent, requestFocus, requestSendAccessibilityEvent, requestTransparentRegion, restoreDefaultFocus, scheduleLayoutAnimation, setAddStatesFromChildren, setAlwaysDrawnWithCacheEnabled, setAnimationCacheEnabled, setChildrenDrawingCacheEnabled, setChildrenDrawingOrderEnabled, setChildrenDrawnWithCacheEnabled, setClipChildren, setClipToPadding, setDescendantFocusability, setLayoutAnimation, setLayoutAnimationListener, setLayoutMode, setLayoutTransition, setMotionEventSplittingEnabled, setOnHierarchyChangeListener, setPersistentDrawingCache, setStaticTransformationsEnabled, setTouchscreenBlocksFocus, setTransitionGroup, setWindowInsetsAnimationCallback, shouldDelayChildPressedState, showContextMenuForChild, showContextMenuForChild, startActionModeForChild, startActionModeForChild, startLayoutAnimation, startViewTransition, suppressLayout, updateViewLayout

    Methods inherited from class android.view.View

    addFocusables, addOnAttachStateChangeListener, addOnLayoutChangeListener, addOnUnhandledKeyEventListener, animate, announceForAccessibility, autofill, autofill, awakenScrollBars, awakenScrollBars, awakenScrollBars, bringToFront, buildDrawingCache, buildDrawingCache, buildLayer, callOnClick, cancelDragAndDrop, cancelLongPress, cancelPendingInputEvents, canResolveLayoutDirection, canResolveTextAlignment, canResolveTextDirection, canScrollHorizontally, canScrollVertically, checkInputConnectionProxy, clearAnimation, clearViewTranslationCallback, combineMeasuredStates, computeHorizontalScrollExtent, computeHorizontalScrollOffset, computeHorizontalScrollRange, computeScroll, computeSystemWindowInsets, computeVerticalScrollExtent, computeVerticalScrollOffset, computeVerticalScrollRange, createAccessibilityNodeInfo, createContextMenu, destroyDrawingCache, dispatchGenericMotionEvent, dispatchNestedFling, dispatchNestedPreFling, dispatchNestedPrePerformAccessibilityAction, dispatchNestedPreScroll, dispatchNestedScroll, dispatchPopulateAccessibilityEvent, draw, drawableHotspotChanged, findOnBackInvokedDispatcher, findViewById, findViewWithTag, fitSystemWindows, focusSearch, forceHasOverlappingRendering, forceLayout, generateDisplayHash, generateViewId, getAccessibilityDelegate, getAccessibilityLiveRegion, getAccessibilityNodeProvider, getAccessibilityPaneTitle, getAccessibilityTraversalAfter, getAccessibilityTraversalBefore, getAllowedHandwritingDelegatePackageName, getAllowedHandwritingDelegatorPackageName, getAlpha, getAnimation, getAnimationMatrix, getApplicationWindowToken, getAttributeResolutionStack, getAttributeSourceResourceMap, getAutofillHints, getAutofillId, getAutofillType, getAutofillValue, getBackground, getBackgroundTintBlendMode, getBackgroundTintList, getBackgroundTintMode, getBaseline, getBottom, getBottomFadingEdgeStrength, getBottomPaddingOffset, getCameraDistance, getClipBounds, getClipBounds, getClipToOutline, getContentCaptureSession, getContentDescription, getContext, getContextMenuInfo, getDefaultFocusHighlightEnabled, getDefaultSize, getDisplay, getDrawableState, getDrawingCache, getDrawingCache, getDrawingCacheBackgroundColor, getDrawingCacheQuality, getDrawingRect, getDrawingTime, getElevation, getExplicitStyle, getFilterTouchesWhenObscured, getFitsSystemWindows, getFocusable, getFocusables, getFocusedRect, getForeground, getForegroundGravity, getForegroundTintBlendMode, getForegroundTintList, getForegroundTintMode, getGlobalVisibleRect, getGlobalVisibleRect, getHandler, getHandwritingBoundsOffsetBottom, getHandwritingBoundsOffsetLeft, getHandwritingBoundsOffsetRight, getHandwritingBoundsOffsetTop, getHandwritingDelegatorCallback, getHasOverlappingRendering, getHeight, getHitRect, getHorizontalFadingEdgeLength, getHorizontalScrollbarHeight, getHorizontalScrollbarThumbDrawable, getHorizontalScrollbarTrackDrawable, getId, getImportantForAccessibility, getImportantForAutofill, getImportantForContentCapture, getKeepScreenOn, getKeyDispatcherState, getLabelFor, getLayerType, getLayoutDirection, getLayoutParams, getLeft, getLeftFadingEdgeStrength, getLeftPaddingOffset, getLocalVisibleRect, getLocationInSurface, getLocationInWindow, getLocationOnScreen, getMatrix, getMeasuredHeight, getMeasuredHeightAndState, getMeasuredState, getMeasuredWidth, getMeasuredWidthAndState, getMinimumHeight, getMinimumWidth, getNextClusterForwardId, getNextFocusDownId, getNextFocusForwardId, getNextFocusLeftId, getNextFocusRightId, getNextFocusUpId, getOnFocusChangeListener, getOutlineAmbientShadowColor, getOutlineProvider, getOutlineSpotShadowColor, getOverScrollMode, getPaddingBottom, getPaddingEnd, getPaddingLeft, getPaddingRight, getPaddingStart, getPaddingTop, getParent, getParentForAccessibility, getPivotX, getPivotY, getPointerIcon, getPreferKeepClearRects, getReceiveContentMimeTypes, getResources, getRevealOnFocusHint, getRight, getRightFadingEdgeStrength, getRightPaddingOffset, getRootSurfaceControl, getRootView, getRootWindowInsets, getRotation, getRotationX, getRotationY, getScaleX, getScaleY, getScrollBarDefaultDelayBeforeFade, getScrollBarFadeDuration, getScrollBarSize, getScrollBarStyle, getScrollCaptureHint, getScrollIndicators, getScrollX, getScrollY, getSolidColor, getSourceLayoutResId, getStateDescription, getStateListAnimator, getSuggestedMinimumHeight, getSuggestedMinimumWidth, getSystemGestureExclusionRects, getSystemUiVisibility, getTag, getTag, getTextAlignment, getTextDirection, getTooltipText, getTop, getTopFadingEdgeStrength, getTopPaddingOffset, getTouchables, getTouchDelegate, getTransitionAlpha, getTransitionName, getTranslationX, getTranslationY, getTranslationZ, getUniqueDrawingId, getVerticalFadingEdgeLength, getVerticalScrollbarPosition, getVerticalScrollbarThumbDrawable, getVerticalScrollbarTrackDrawable, getVerticalScrollbarWidth, getViewTranslationResponse, getViewTreeObserver, getVisibility, getWidth, getWindowAttachCount, getWindowId, getWindowInsetsController, getWindowSystemUiVisibility, getWindowToken, getWindowVisibility, getWindowVisibleDisplayFrame, getX, getY, getZ, hasExplicitFocusable, hasFocusable, hasNestedScrollingParent, hasOnClickListeners, hasOnLongClickListeners, hasOverlappingRendering, hasPointerCapture, hasWindowFocus, inflate, invalidate, invalidate, invalidate, invalidateDrawable, invalidateOutline, isAccessibilityDataSensitive, isAccessibilityFocused, isAccessibilityHeading, isActivated, isAttachedToWindow, isAutoHandwritingEnabled, isClickable, isContextClickable, isCredential, isDirty, isDrawingCacheEnabled, isDuplicateParentStateEnabled, isEnabled, isFocusable, isFocusableInTouchMode, isFocused, isFocusedByDefault, isForceDarkAllowed, isHandwritingDelegate, isHapticFeedbackEnabled, isHardwareAccelerated, isHorizontalFadingEdgeEnabled, isHorizontalScrollBarEnabled, isHovered, isImportantForAccessibility, isImportantForAutofill, isImportantForContentCapture, isInEditMode, isInLayout, isInTouchMode, isKeyboardNavigationCluster, isLaidOut, isLayoutDirectionResolved, isLayoutRequested, isLongClickable, isNestedScrollingEnabled, isOpaque, isPaddingOffsetRequired, isPaddingRelative, isPivotSet, isPreferKeepClear, isPressed, isSaveEnabled, isSaveFromParentEnabled, isScreenReaderFocusable, isScrollbarFadingEnabled, isScrollContainer, isSelected, isShowingLayoutBounds, isShown, isSoundEffectsEnabled, isTemporarilyDetached, isTextAlignmentResolved, isTextDirectionResolved, isVerticalFadingEdgeEnabled, isVerticalScrollBarEnabled, isVisibleToUserForAutofill, keyboardNavigationClusterSearch, measure, mergeDrawableStates, offsetLeftAndRight, offsetTopAndBottom, onAnimationEnd, onAnimationStart, onApplyWindowInsets, onCancelPendingInputEvents, onCapturedPointerEvent, onCheckIsTextEditor, onConfigurationChanged, onCreateContextMenu, onCreateInputConnection, onCreateViewTranslationRequest, onCreateVirtualViewTranslationRequests, onDisplayHint, onDragEvent, onDraw, onDrawForeground, onDrawScrollBars, onFilterTouchEventForSecurity, onFinishInflate, onFinishTemporaryDetach, onFocusChanged, onGenericMotionEvent, onHoverChanged, onHoverEvent, onInitializeAccessibilityEvent, onInitializeAccessibilityNodeInfo, onKeyDown, onKeyLongPress, onKeyMultiple, onKeyPreIme, onKeyShortcut, onKeyUp, onOverScrolled, onPointerCaptureChange, onPopulateAccessibilityEvent, onProvideAutofillStructure, onProvideAutofillVirtualStructure, onProvideContentCaptureStructure, onProvideStructure, onProvideVirtualStructure, onReceiveContent, onRestoreInstanceState, onRtlPropertiesChanged, onSaveInstanceState, onScreenStateChanged, onScrollCaptureSearch, onScrollChanged, onSetAlpha, onSizeChanged, onStartTemporaryDetach, onTouchEvent, onTrackballEvent, onViewTranslationResponse, onVirtualViewTranslationResponses, onVisibilityAggregated, onVisibilityChanged, onWindowFocusChanged, onWindowSystemUiVisibilityChanged, onWindowVisibilityChanged, overScrollBy, performAccessibilityAction, performClick, performContextClick, performContextClick, performHapticFeedback, performHapticFeedback, performLongClick, performLongClick, performReceiveContent, playSoundEffect, post, postDelayed, postInvalidate, postInvalidate, postInvalidateDelayed, postInvalidateDelayed, postInvalidateOnAnimation, postInvalidateOnAnimation, postOnAnimation, postOnAnimationDelayed, refreshDrawableState, releasePointerCapture, removeCallbacks, removeOnAttachStateChangeListener, removeOnLayoutChangeListener, removeOnUnhandledKeyEventListener, requestApplyInsets, requestFitSystemWindows, requestFocus, requestFocus, requestFocusFromTouch, requestLayout, requestPointerCapture, requestRectangleOnScreen, requestRectangleOnScreen, requestUnbufferedDispatch, requestUnbufferedDispatch, requireViewById, resetPivot, resolveSize, resolveSizeAndState, restoreHierarchyState, saveAttributeDataForStyleable, saveHierarchyState, scheduleDrawable, scrollBy, scrollTo, sendAccessibilityEvent, sendAccessibilityEventUnchecked, setAccessibilityDataSensitive, setAccessibilityDelegate, setAccessibilityHeading, setAccessibilityLiveRegion, setAccessibilityPaneTitle, setAccessibilityTraversalAfter, setAccessibilityTraversalBefore, setActivated, setAllowClickWhenDisabled, setAllowedHandwritingDelegatePackage, setAllowedHandwritingDelegatorPackage, setAlpha, setAnimation, setAnimationMatrix, setAutofillHints, setAutofillId, setAutoHandwritingEnabled, setBackground, setBackgroundColor, setBackgroundDrawable, setBackgroundResource, setBackgroundTintBlendMode, setBackgroundTintList, setBackgroundTintMode, setBottom, setCameraDistance, setClickable, setClipBounds, setClipToOutline, setContentCaptureSession, setContentDescription, setContextClickable, setDefaultFocusHighlightEnabled, setDrawingCacheBackgroundColor, setDrawingCacheEnabled, setDrawingCacheQuality, setDuplicateParentStateEnabled, setElevation, setEnabled, setFadingEdgeLength, setFilterTouchesWhenObscured, setFitsSystemWindows, setFocusable, setFocusable, setFocusableInTouchMode, setFocusedByDefault, setForceDarkAllowed, setForeground, setForegroundGravity, setForegroundTintBlendMode, setForegroundTintList, setForegroundTintMode, setHandwritingBoundsOffsets, setHandwritingDelegatorCallback, setHapticFeedbackEnabled, setHasTransientState, setHorizontalFadingEdgeEnabled, setHorizontalScrollBarEnabled, setHorizontalScrollbarThumbDrawable, setHorizontalScrollbarTrackDrawable, setHovered, setId, setImportantForAccessibility, setImportantForAutofill, setImportantForContentCapture, setIsCredential, setIsHandwritingDelegate, setKeepScreenOn, setKeyboardNavigationCluster, setLabelFor, setLayerPaint, setLayerType, setLayoutDirection, setLayoutParams, setLeft, setLeftTopRightBottom, setLongClickable, setMeasuredDimension, setMinimumHeight, setMinimumWidth, setNestedScrollingEnabled, setNextClusterForwardId, setNextFocusDownId, setNextFocusForwardId, setNextFocusLeftId, setNextFocusRightId, setNextFocusUpId, setOnApplyWindowInsetsListener, setOnCapturedPointerListener, setOnClickListener, setOnContextClickListener, setOnCreateContextMenuListener, setOnDragListener, setOnFocusChangeListener, setOnGenericMotionListener, setOnHoverListener, setOnKeyListener, setOnLongClickListener, setOnReceiveContentListener, setOnScrollChangeListener, setOnSystemUiVisibilityChangeListener, setOnTouchListener, setOutlineAmbientShadowColor, setOutlineProvider, setOutlineSpotShadowColor, setOverScrollMode, setPadding, setPaddingRelative, setPivotX, setPivotY, setPointerIcon, setPreferKeepClear, setPreferKeepClearRects, setPressed, setRenderEffect, setRevealOnFocusHint, setRight, setRotation, setRotationX, setRotationY, setSaveEnabled, setSaveFromParentEnabled, setScaleX, setScaleY, setScreenReaderFocusable, setScrollBarDefaultDelayBeforeFade, setScrollBarFadeDuration, setScrollbarFadingEnabled, setScrollBarSize, setScrollBarStyle, setScrollCaptureCallback, setScrollCaptureHint, setScrollContainer, setScrollIndicators, setScrollIndicators, setScrollX, setScrollY, setSelected, setSoundEffectsEnabled, setStateDescription, setStateListAnimator, setSystemGestureExclusionRects, setSystemUiVisibility, setTag, setTag, setTextAlignment, setTextDirection, setTooltipText, setTop, setTouchDelegate, setTransitionAlpha, setTransitionName, setTransitionVisibility, setTranslationX, setTranslationY, setTranslationZ, setVerticalFadingEdgeEnabled, setVerticalScrollBarEnabled, setVerticalScrollbarPosition, setVerticalScrollbarThumbDrawable, setVerticalScrollbarTrackDrawable, setViewTranslationCallback, setVisibility, setWillNotCacheDrawing, setWillNotDraw, setX, setY, setZ, showContextMenu, showContextMenu, startActionMode, startActionMode, startAnimation, startDrag, startDragAndDrop, startNestedScroll, stopNestedScroll, toString, transformMatrixToGlobal, transformMatrixToLocal, unscheduleDrawable, unscheduleDrawable, updateDragShadow, verifyDrawable, willNotCacheDrawing, willNotDraw

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface android.view.ViewParent

    canResolveLayoutDirection, canResolveTextAlignment, canResolveTextDirection, createContextMenu, getLayoutDirection, getParent, getParentForAccessibility, getTextAlignment, getTextDirection, isLayoutDirectionResolved, isLayoutRequested, isTextAlignmentResolved, isTextDirectionResolved, keyboardNavigationClusterSearch, requestFitSystemWindows, requestLayout
  • Field Details

    • mCameraEventsListener

      @Nullable protected CameraEventsListener mCameraEventsListener
      Listener that will receive various camera events
    • mErrorState

      protected boolean mErrorState
      Flag indicating there has been an unrecoverable error
    • mDeviceManager

      @Nullable protected com.microblink.blinkid.hardware.DeviceManager mDeviceManager
      Device manager that will load device list from resources
    • mCameraViewState

      @NonNull protected BaseCameraView.CameraViewState mCameraViewState
    • mCameraSurfaceView

      @Nullable protected com.microblink.blinkid.view.surface.ICameraView mCameraSurfaceView
      View element
    • mConfigurationOrientation

      protected int mConfigurationOrientation
      Current configuration orientation
    • mOnActivityFlipListener

      @Nullable protected OnActivityFlipListener mOnActivityFlipListener
      Listener that will be notified when activity flip occurs.
    • mHostScreenOrientation

      protected int mHostScreenOrientation
      Orientation of the host activity
    • mAspectMode

      @NonNull protected CameraAspectMode mAspectMode
      Defines the way camera preview will be layouted inside view
    • mPreviewZoomScale

      protected float mPreviewZoomScale
    • mIsRequestedOrientationSensor

      protected boolean mIsRequestedOrientationSensor
    • mIsRequestedOrientationUser

      protected boolean mIsRequestedOrientationUser
    • mOrientationChangeListener

      @NonNull protected com.microblink.blinkid.hardware.orientation.OrientationChangeListener mOrientationChangeListener
    • mRotateMeteringAreas

      protected boolean mRotateMeteringAreas
    • mInitialOrientation

      @Nullable protected Orientation mInitialOrientation
      Initial orientation which will be used for frame orientation if mOrientation is unknown
    • mSlaveOrientationChangeListeners

      @NonNull protected ConcurrentLinkedQueue<com.microblink.blinkid.hardware.orientation.OrientationChangeListener> mSlaveOrientationChangeListeners
      Slave orientation change listeners that can be notified on orientation change events generated by mOrientationManager
  • Constructor Details

    • BaseCameraView

      public BaseCameraView(@NonNull android.content.Context context)
    • BaseCameraView

      public BaseCameraView(@NonNull android.content.Context context, @Nullable android.util.AttributeSet attrs)
  • Method Details

    • isRequestedOrientationSensor

      protected static boolean isRequestedOrientationSensor(int requestedOrientation)
    • isRequestedOrientationUser

      protected boolean isRequestedOrientationUser(int requestedOrientation)
    • calculateHostScreenOrientation

      protected int calculateHostScreenOrientation()
    • runOnUIThread

      @AnyThread protected void runOnUIThread(@NonNull Runnable runnable)
      Ensures given runnable is run on UI thread. If called from UI thread, runnable's code will be run immediately (before returning from method). If not, runnable's code will be posted to UI thread's processing queue.
      Parameters:
      runnable -
    • changeConfiguration

      public void changeConfiguration(@Nullable android.content.res.Configuration newConfiguration)
      This method changes the view's configuration. It is meant to be called from onConfigurationChange event.
      Parameters:
      newConfiguration - New view configuration
    • changeConfigurationInternal

      @CallSuper protected void changeConfigurationInternal(@Nullable android.content.res.Configuration newConfiguration)
    • getHostActivity

      @Nullable protected android.app.Activity getHostActivity()
    • create

      @CallSuper public void create()
      Creates the view and its subviews and initializes camera settings. This method must be called in onCreate method of host activity. If not called, camera will not work. Make sure you set all your settings before calling this method.
    • destroy

      @CallSuper public void destroy()
    • prepareCameraSettings

      protected void prepareCameraSettings(@NonNull com.microblink.blinkid.hardware.camera.CameraSettings settings)
      Called inside onCreate method before creating camera manager. Use this method to create camera settings that are used on each startPreview event.
    • getCameraFactorySettings

      @NonNull protected com.microblink.blinkid.hardware.camera.CameraSettings getCameraFactorySettings()
    • shouldStartCamera

      protected boolean shouldStartCamera()
    • onCameraPreviewStarted

      protected void onCameraPreviewStarted()
    • onCameraPreviewStopped

      protected void onCameraPreviewStopped()
    • start

      @MainThread @CallSuper public void start()
    • resume

      @MainThread @CallSuper public void resume()
      This method must be called from activity's onResume. If not called, camera will not work.
    • pause

      @MainThread @CallSuper public void pause()
      This method must be called from activity's onPause. If not called, camera will not work properly.
    • stop

      @MainThread @CallSuper public void stop()
    • onMeasure

      protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
      Overrides:
      onMeasure in class android.view.View
    • dispatchTouchEvent

      public boolean dispatchTouchEvent(@Nullable android.view.MotionEvent ev)
      Overrides:
      dispatchTouchEvent in class android.view.ViewGroup
    • onLayout

      protected void onLayout(boolean changed, int l, int t, int r, int b)
      Specified by:
      onLayout in class android.view.ViewGroup
    • setVisiblePartUpdateListener

      protected void setVisiblePartUpdateListener(BaseCameraView.VisiblePartUpdateListener visiblePartUpdateListener)
    • isCameraFocused

      public final boolean isCameraFocused()
      Returns true if camera is currently in focus
      Returns:
    • captureHighResFrame

      protected void captureHighResFrame()
    • getOpenedCameraType

      @Nullable public final CameraType getOpenedCameraType()
      Returns the type of the currently opened camera or null if currently there is no opened camera.
      Returns:
      the type of the currently opened camera or null if currently there is no opened camera.
    • focusCamera

      public final void focusCamera()
      Request a new autofocus cycle from camera.
    • isCameraTorchSupported

      public final boolean isCameraTorchSupported()
      Returns true if camera has got torch.
      Returns:
      true if camera has got torch.
    • isAutofocusSupported

      @Nullable public final Boolean isAutofocusSupported()
      Returns true if opened camera supports autofocus. Returns false if opened camera does not support autofocus. Returns null if camera is not opened.
      Returns:
      whether opened camera supports autofocus or null if no camera is opened
    • setTorchState

      public final void setTorchState(boolean on, @NonNull SuccessCallback successCallback)
      Turns the torch on the camera on or off. Returns true on success, false on failure.
      Parameters:
      on - If true, torch will be turned on, if false, torch will be turned off.
      successCallback - callback that will receive information if torch was successfully put in desired state
    • getCameraSensorOrientation

      protected int getCameraSensorOrientation()
    • areCameraPixelsLandscapeLeft

      protected boolean areCameraPixelsLandscapeLeft()
    • getZoomLevel

      public final float getZoomLevel()
      Returns the current camera zoom level.
      Returns:
      the current camera zoom level.
    • setZoomLevel

      public final void setZoomLevel(@FloatRange(from=0.0,to=1.0) float zoomLevel)
      Sets the camera zoom level. Zoom level 0.f defines no applied zoom, while zoom level 1.f defines maximum supported camera zoom. Values beyond interval [0.f, 1.f] are cropped to interval [0.f, 1.f]. If camera is active, new zoom level is applied immediately. If camera is not active, desired zoom level will be applied on next camera startup.
      Parameters:
      zoomLevel - Desired camera zoom level.
    • getHighResFrameLimit

      public final int getHighResFrameLimit()
      Returns the current high res frame limit
      Returns:
      current high res frame limit
    • setHighResFrameLimit

      public final void setHighResFrameLimit(@IntRange(from=0L) int highResFrameLimit)
      Sets the maximum number of high res frames that can be active at a given moment. You should try to keep it as low as possible to avoid memory issues. Trying to capture high res frames over this limit not only won't work but might also interfere with recognition process.
      Parameters:
      highResFrameLimit - desired high res frame limit, minimum 1
    • setHighResFrameCaptureEnabled

      public void setHighResFrameCaptureEnabled(boolean enabled)
      High res frame capture is disabled by default and needs to be enabled by using this method. If enabling high res frames, please use VideoResolutionPreset.VIDEO_RESOLUTION_DEFAULT, higher resolutions might cause problems when combined with high res frame capture on some devices.
      Parameters:
      enabled - should high res frame capture be enabled
    • isHighResFrameCaptureEnabled

      public boolean isHighResFrameCaptureEnabled()
      Returns true if high res frame capture was enabled.
      Returns:
      is high res frame capture enabled
    • getCameraViewState

      @NonNull public final BaseCameraView.CameraViewState getCameraViewState()
      Returns the current lifecycle state of camera view.
      Returns:
    • isTapToFocusAllowed

      public final boolean isTapToFocusAllowed()
      Returns true if camera view will handle tap events to ask camera to perform autofocus on tapped area.
      Returns:
      true if tap to focus is allowed
    • setTapToFocusAllowed

      public final void setTapToFocusAllowed(boolean allowTapToFocus)
      Sets whether camera view will handle tap events to ask camera to perform autofocus on tapped area. Default is true.
      Parameters:
      allowTapToFocus - whether or not tap to focus is allowed
    • isPinchToZoomAllowed

      public final boolean isPinchToZoomAllowed()
      Returns true if camera view will handle pinch events to manage camera zoom level.
      Returns:
      true if pinch to zoom is allowed
    • setPinchToZoomAllowed

      public final void setPinchToZoomAllowed(boolean allowPinchToZoom)
      Sets whether camear view will handle pinch events to manage camera zoom level.
      Parameters:
      allowPinchToZoom - whether or not pinch to zoom is allowed. Default is false.
    • isDeviceShaking

      public final boolean isDeviceShaking()
      Returns true if the device is being shaken
      Returns:
      true if the device is being shaken
    • getCameraPreviewWidth

      public final int getCameraPreviewWidth()
      Returns the width in pixels of the actual camera preview (does not have to be same as getWidth).
      Returns:
      the width in pixels of the actual camera preview (does not have to be same as getWidth).
    • getCameraPreviewHeight

      public final int getCameraPreviewHeight()
      Returns the height in pixels of the actual camera preview (does not have to be same as getHeight).
      Returns:
      the height in pixels of the actual camera preview (does not have to be same as getHeight).
    • setMeteringAreas

      public final void setMeteringAreas(@NonNull android.graphics.RectF[] meteringAreas, boolean rotateAreasWithDevice)
      Sets the areas where camera will perform focus, exposure and white balance meterings.
      Parameters:
      meteringAreas - array of rectangles that define areas where camera will perform focus, exposure and white balance meterings.
      rotateAreasWithDevice - if set to true, metering areas will be readjusted each time device orientation changes
      Throws:
      NullPointerException - if at least one element of meteringAreas is null
      IllegalArgumentException - if at least on element of meteringAreas has either zero surface or is not inside view
      IllegalStateException - if camera is not active
    • setMeteringAreasToCamera

      protected void setMeteringAreasToCamera()
    • isCameraActive

      @AnyThread public final boolean isCameraActive()
      Returns true if camera is currently active.
      Returns:
      true if camera is currently active.
    • getConfigurationOrientation

      protected final int getConfigurationOrientation()
    • setCameraType

      public void setCameraType(@NonNull CameraType cameraType)
      Sets the camera type that will be used. You must set this before calling create method.
      Parameters:
      cameraType -
    • setShakeListener

      public void setShakeListener(@NonNull ShakeCallback shakeCallback)
      Sets the shake callback that will be notified about device shake events.
      Parameters:
      shakeCallback -
    • getAspectMode

      @NonNull public CameraAspectMode getAspectMode()
      Returns the aspect mode of camera preview.
      Returns:
      the aspect mode of camera preview.
    • setAspectMode

      public void setAspectMode(@NonNull CameraAspectMode aspectMode)
      Defines the aspect mode of camera preview.
      Parameters:
      aspectMode - desired aspect mode
    • getPreviewZoomScale

      public float getPreviewZoomScale()
      Returns the preview zoom scale that is used to draw the camera preview.
      Returns:
      preview zoom scale.
    • setPreviewZoomScale

      public void setPreviewZoomScale(@FloatRange(from=1.0,to=2.0) float previewZoomScale)
      Sets the preview zoom scale that will be used to draw the camera preview. If the preview is upscaled, the visible part will be centered, and marginal parts of the camera preview will be invisible.
      Parameters:
      previewZoomScale - zoom scale in range [1, 2]
    • setOnSizeChangedListener

      public final void setOnSizeChangedListener(@NonNull OnSizeChangedListener onSizeChangedListener)
      Sets the listener that will be notified when size of child views changes.
      Parameters:
      onSizeChangedListener -
    • setOnActivityFlipListener

      public final void setOnActivityFlipListener(@NonNull OnActivityFlipListener onActivityFlipListener)
      Sets the listener that will be notified when activity flip event occurs.
      Parameters:
      onActivityFlipListener - Activity flip listener
    • setVideoResolutionPreset

      public final void setVideoResolutionPreset(@NonNull VideoResolutionPreset preset)
      Parameters:
      preset - Sets the preset that will be used for choosing camera video resolution.
    • setForceUseLegacyCamera

      public final void setForceUseLegacyCamera(boolean useLegacyCamera)
      With this method you can request using legacy Camera API even on devices that natively support new Camera2 API. Set this to true only if you have problems with camera management on Lollipop and newer devices. Using legacy camera API is less efficient than new Camera2 API.
      Parameters:
      useLegacyCamera - If set to true, legacy Camera API will be used even on devices that support new Camera2 API.
    • setCameraFrameFactory

      public final void setCameraFrameFactory(com.microblink.blinkid.hardware.camera.frame.CameraFrameFactory cameraFrameFactory)
      Set your custom implementation of camera frame factory.
    • setRequestAutofocusOnShakingStopInContinousAutofocusMode

      public final void setRequestAutofocusOnShakingStopInContinousAutofocusMode(boolean requestAutofocusOnShakingStopInContinousAutofocusMode)
      If device supports continous autofocus mode, enabling this feature will request normal autofocus every time device shaking stops. By default, this is off, as is expected from device which supports continous autofocus to do this automatically. However, some devices do not meet that expectation so this tweak can be used to force autofocus after device has stopped moving.
      Parameters:
      requestAutofocusOnShakingStopInContinousAutofocusMode - will autofocus be requested each time device shaking stops.
    • setOptimizeCameraForNearScan

      public final void setOptimizeCameraForNearScan(boolean nearScan)
      Parameters:
      nearScan - Flag which indicates camera parameters should be optimized for near object scanning. When camera parameters are optimized for near object scanning, macro focus mode will be preferred over autofocus mode. Thus, camera will have easier time focusing on to near objects, but might have harder time focusing on far objects. If you expect that most of your scans will be performed by holding the device very near the object, turn on that parameter. By default, this parameter is set to false.
    • setRequestedSurfaceViewForCameraDisplay

      public final void setRequestedSurfaceViewForCameraDisplay(@NonNull com.microblink.blinkid.view.surface.CameraSurface requestedSurface)
      In order to display camera preview, camera view must use one of two android's view's that are capable of displaying camera preview video stream: SurfaceView and TextureView. By default, SurfaceView will be preferred because it is faster and more power efficient. Sometimes, when you create complex UI on top of camera screen, animations or UI may render incorrectly on some devices when using SurfaceView for displaying camera preview. In that case, you can use this method to force setting the surface you want.
      Parameters:
      requestedSurface - Which view should be used to display camera preview.
    • getCameraEventsListener

      @Nullable public CameraEventsListener getCameraEventsListener()
      Returns the current camera events listener.
      Returns:
      the current camera events listener.
    • setCameraEventsListener

      public void setCameraEventsListener(@Nullable CameraEventsListener cameraEventsListener)
      Sets the listener that will receive various camera events, such as when camera preview has started or camera initialization error has occurred.
      Parameters:
      cameraEventsListener -
    • getHostScreenOrientation

      public int getHostScreenOrientation()
      Returns the host's screen orientation as detected internally. Possible return codes are ActivityInfo.SCREEN_ORIENTATION_PORTRAIT, ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT, ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE and ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE
      Returns:
      the host's screen orientation
    • getVisiblePart

      @NonNull public android.graphics.RectF getVisiblePart()
      Returns the rectangle that which part of camera frame is visible in view
      Returns:
      the rectangle that which part of camera frame is visible in view
    • createOrientationChangeListener

      @NonNull protected com.microblink.blinkid.hardware.orientation.OrientationChangeListener createOrientationChangeListener()
    • createCameraViewEventsListener

      @NonNull protected com.microblink.blinkid.view.surface.ICameraView.CameraViewEventListener createCameraViewEventsListener()
    • requireAutofocusFeature

      protected abstract boolean requireAutofocusFeature()
      If autofocus feature is required, please return true from this method. If autofocus feature is not required, return false. If autofocus is required and device does not support autofocus, error will be raised and application will not start. If autofocus is not required, application will work even on devices without autofocus.
      Returns:
      True if autofocus is required, otherwise false.
    • onActivityFlip

      protected abstract void onActivityFlip()
      Called when activity is flipped - this event is not raised by OS so we have custom detection of that state.
    • createCameraListener

      @NonNull protected abstract com.microblink.blinkid.hardware.camera.CameraListener createCameraListener()
      ABSTRACT METHODS
    • isHostActivityOrientationOnSensor

      protected boolean isHostActivityOrientationOnSensor()
    • getCurrentOrientation

      @NonNull public Orientation getCurrentOrientation()
    • isOrientationAllowed

      protected final boolean isOrientationAllowed(@Nullable Orientation orientation)
    • getInitialOrientation

      @Nullable public final Orientation getInitialOrientation()
      Returns the initial orientation of rotatable view as set by setInitialOrientation.
      Returns:
      the initial orientation of rotatable view as set by setInitialOrientation.
    • setInitialOrientation

      @CallSuper public void setInitialOrientation(@Nullable Orientation initialOrientation)
      Sets the initial orientation of rotatable view and recognizer.
      Parameters:
      initialOrientation -
    • setOrientationAllowedListener

      public void setOrientationAllowedListener(@NonNull OrientationAllowedListener orientationAllowedListener)
      Sets the listener that will be asked if device orientation is allowed prior rotating rotatable view and native recognizer to that orientation. If you do not set this listener, recognition will be performed only in orientation defined by current activity's orientation.
    • addOrientationChangeListener

      public void addOrientationChangeListener(@NonNull com.microblink.blinkid.hardware.orientation.OrientationChangeListener orientationChangeListener)
      Adds the orientation listener that will receive orientation change events that are already reported to BaseCameraView. Orientation change events are independent of host activity's orientation settings.
      Parameters:
      orientationChangeListener - listener that will receive orientation change events
      Throws:
      NullPointerException - if the specified listener is null.
      IllegalStateException - if addOrientationChangeListener is called after calling start()
    • removeOrientationChangeListener

      public void removeOrientationChangeListener(@NonNull com.microblink.blinkid.hardware.orientation.OrientationChangeListener orientationChangeListener)
      Removes a single listener instance from listeners collection, if it is present.
      Parameters:
      orientationChangeListener - listener to be removed from the collection.