public abstract class BaseCameraView
extends android.view.ViewGroup
Modifier and Type | Class and Description |
---|---|
protected class |
BaseCameraView.BaseCameraListener |
protected class |
BaseCameraView.BaseCameraViewEventsListener |
protected class |
BaseCameraView.BaseOrientationChangeListener |
static class |
BaseCameraView.CameraViewState |
android.view.ViewGroup.LayoutParams, android.view.ViewGroup.MarginLayoutParams, android.view.ViewGroup.OnHierarchyChangeListener
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
Modifier and Type | Field and Description |
---|---|
protected CameraAspectMode |
mAspectMode
Defines the way camera preview will be layouted inside view
|
protected CameraEventsListener |
mCameraEventsListener
Listener that will receive various camera events
|
protected ICameraView |
mCameraSurfaceView
View element
|
protected BaseCameraView.CameraViewState |
mCameraViewState |
protected int |
mConfigurationOrientation
Current configuration orientation
|
protected DeviceManager |
mDeviceManager
Device manager that will load device list from resources
|
protected boolean |
mErrorState
Flag indicating there has been an unrecoverable error
|
protected int |
mHostScreenOrientation
Orientation of the host activity
|
protected Orientation |
mInitialOrientation
Initial orientation which will be used for frame orientation if mOrientation is unknown
|
protected boolean |
mIsRequestedOrientationSensor |
protected boolean |
mIsRequestedOrientationUser |
protected OnActivityFlipListener |
mOnActivityFlipListener
Listener that will be notified when activity flip occurs.
|
protected OrientationChangeListener |
mOrientationChangeListener |
protected boolean |
mRotateMeteringAreas |
protected java.util.concurrent.ConcurrentLinkedQueue |
mSlaveOrientationChangeListeners
Slave orientation change listeners that can be notified on orientation change events generated by mOrientationManager
|
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
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_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_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 and Description |
---|
BaseCameraView(android.content.Context context) |
BaseCameraView(android.content.Context context,
android.util.AttributeSet attrs) |
Modifier and Type | Method and Description |
---|---|
void |
addOrientationChangeListener(OrientationChangeListener orientationChangeListener)
Adds the orientation listener that will receive orientation change events that are already reported
to BaseCameraView.
|
protected boolean |
areCameraPixelsLandscapeLeft() |
protected int |
calculateHostScreenOrientation() |
protected void |
captureHighResFrame() |
void |
changeConfiguration(android.content.res.Configuration newConfiguration)
This method changes the view's configuration.
|
protected void |
changeConfigurationInternal(android.content.res.Configuration newConfiguration) |
void |
create()
Creates the view and its subviews and initializes camera settings.
|
protected abstract CameraListener |
createCameraListener()
ABSTRACT METHODS
|
protected ICameraView.CameraViewEventListener |
createCameraViewEventsListener() |
protected OrientationChangeListener |
createOrientationChangeListener() |
void |
destroy() |
boolean |
dispatchTouchEvent(android.view.MotionEvent ev) |
void |
focusCamera()
Request a new autofocus cycle from camera.
|
CameraAspectMode |
getAspectMode()
Returns the aspect mode of camera preview.
|
CameraEventsListener |
getCameraEventsListener()
Returns the current camera events listener.
|
protected CameraSettings |
getCameraFactorySettings() |
int |
getCameraPreviewHeight()
Returns the height in pixels of the actual camera preview (does not have to be same as getHeight).
|
int |
getCameraPreviewWidth()
Returns the width in pixels of the actual camera preview (does not have to be same as getWidth).
|
protected int |
getCameraSensorOrientation() |
BaseCameraView.CameraViewState |
getCameraViewState()
Returns the current lifecycle state of camera view.
|
protected int |
getConfigurationOrientation() |
Orientation |
getCurrentOrientation() |
int |
getHighResFrameLimit()
Returns the current high res frame limit
|
protected android.app.Activity |
getHostActivity() |
int |
getHostScreenOrientation()
Returns the host's screen orientation as detected internally.
|
Orientation |
getInitialOrientation()
Returns the initial orientation of rotatable view as set by setInitialOrientation.
|
CameraType |
getOpenedCameraType()
Returns the type of the currently opened camera or null if currently there is no opened camera.
|
android.graphics.RectF |
getVisiblePart()
Returns the rectangle that which part of camera frame is visible in view
|
float |
getZoomLevel()
Returns the current camera zoom level.
|
java.lang.Boolean |
isAutofocusSupported()
Returns true if opened camera supports autofocus.
|
boolean |
isCameraActive()
Returns true if camera is currently active.
|
boolean |
isCameraFocused()
Returns true if camera is currently in focus
|
boolean |
isCameraTorchSupported()
Returns true if camera has got torch.
|
boolean |
isDeviceShaking()
Returns true if the device is being shaken
|
boolean |
isHighResFrameCaptureEnabled()
Returns true if high res frame capture was enabled.
|
protected boolean |
isHostActivityOrientationOnSensor() |
protected boolean |
isOrientationAllowed(Orientation orientation) |
boolean |
isPinchToZoomAllowed()
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) |
boolean |
isTapToFocusAllowed()
Returns true if camera view will handle tap events to ask camera to perform autofocus
on tapped area.
|
protected abstract void |
onActivityFlip()
Called when activity is flipped - this event is not raised by OS so we have custom detection
of that state.
|
protected void |
onCameraPreviewStarted() |
protected void |
onCameraPreviewStopped() |
protected void |
onLayout(boolean changed,
int l,
int t,
int r,
int b) |
protected void |
onMeasure(int widthMeasureSpec,
int heightMeasureSpec) |
void |
pause()
This method must be called from activity's onPause.
|
protected void |
prepareCameraSettings(CameraSettings settings)
Called inside onCreate method before creating camera manager.
|
void |
removeOrientationChangeListener(OrientationChangeListener orientationChangeListener)
Removes a single listener instance from listeners collection,
if it is present.
|
protected abstract boolean |
requireAutofocusFeature()
If autofocus feature is required, please return true from this method.
|
void |
resume()
This method must be called from activity's onResume.
|
protected void |
runOnUIThread(java.lang.Runnable runnable)
Ensures given runnable is run on UI thread.
|
void |
setAspectMode(CameraAspectMode aspectMode)
Defines the aspect mode of camera preview.
|
void |
setCameraEventsListener(CameraEventsListener cameraEventsListener)
Sets the listener that will receive various camera events, such as when camera preview has
started or camera initialization error has occurred.
|
void |
setCameraFrameFactory(CameraFrameFactory cameraFrameFactory)
Set your custom implementation of camera frame factory.
|
void |
setCameraType(CameraType cameraType)
Sets the camera type that will be used.
|
void |
setForceUseLegacyCamera(boolean useLegacyCamera)
With this method you can request using legacy Camera API even on devices that natively support new Camera2 API.
|
void |
setHighResFrameCaptureEnabled(boolean enabled)
High res frame capture is disabled by default and needs to be enabled by using this method.
|
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.
|
void |
setMeteringAreas(android.graphics.RectF[] meteringAreas,
boolean rotateAreasWithDevice)
Sets the areas where camera will perform focus, exposure and white balance meterings.
|
protected void |
setMeteringAreasToCamera() |
void |
setOnActivityFlipListener(OnActivityFlipListener onActivityFlipListener)
Sets the listener that will be notified when activity flip event occurs.
|
void |
setOnSizeChangedListener(OnSizeChangedListener onSizeChangedListener)
Sets the listener that will be notified when size of child views changes.
|
void |
setOptimizeCameraForNearScan(boolean nearScan) |
void |
setOrientationAllowedListener(OrientationAllowedListener orientationAllowedListener)
Sets the listener that will be asked if device orientation is allowed prior rotating
rotatable view and native recognizer to that orientation.
|
void |
setPinchToZoomAllowed(boolean allowPinchToZoom)
Sets whether camear view will handle pinch events to manage camera zoom level.
|
void |
setRequestAutofocusOnShakingStopInContinousAutofocusMode(boolean requestAutofocusOnShakingStopInContinousAutofocusMode)
If device supports continous autofocus mode, enabling this feature will request normal autofocus every time device shaking
stops.
|
void |
setRequestedSurfaceViewForCameraDisplay(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 |
setShakeListener(ShakeCallback shakeCallback)
Sets the shake callback that will be notified about device shake events.
|
void |
setTapToFocusAllowed(boolean allowTapToFocus)
Sets whether camera view will handle tap events to ask camera to perform autofocus
on tapped area.
|
void |
setTorchState(boolean on,
SuccessCallback successCallback)
Turns the torch on the camera on or off.
|
void |
setVideoResolutionPreset(VideoResolutionPreset preset) |
void |
setZoomLevel(float zoomLevel)
Sets the camera zoom level.
|
protected boolean |
shouldStartCamera() |
void |
start() |
void |
stop() |
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, dispatchDisplayHint, dispatchDragEvent, dispatchDraw, dispatchDrawableHotspotChanged, dispatchFinishTemporaryDetach, dispatchFreezeSelfOnly, dispatchGenericFocusedEvent, dispatchGenericPointerEvent, dispatchHoverEvent, dispatchKeyEvent, dispatchKeyEventPreIme, dispatchKeyShortcutEvent, dispatchPointerCaptureChanged, dispatchProvideAutofillStructure, dispatchProvideStructure, dispatchRestoreInstanceState, dispatchSaveInstanceState, dispatchSetActivated, dispatchSetPressed, dispatchSetSelected, dispatchStartTemporaryDetach, dispatchSystemUiVisibilityChanged, dispatchThawSelfOnly, dispatchTrackballEvent, dispatchUnhandledMove, dispatchVisibilityChanged, dispatchWindowFocusChanged, dispatchWindowInsetsAnimationEnd, dispatchWindowInsetsAnimationPrepare, dispatchWindowInsetsAnimationProgress, dispatchWindowInsetsAnimationStart, dispatchWindowSystemUiVisiblityChanged, dispatchWindowVisibilityChanged, drawableStateChanged, drawChild, endViewTransition, findFocus, 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
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, combineMeasuredStates, computeHorizontalScrollExtent, computeHorizontalScrollOffset, computeHorizontalScrollRange, computeScroll, computeSystemWindowInsets, computeVerticalScrollExtent, computeVerticalScrollOffset, computeVerticalScrollRange, createAccessibilityNodeInfo, createContextMenu, destroyDrawingCache, dispatchGenericMotionEvent, dispatchNestedFling, dispatchNestedPreFling, dispatchNestedPrePerformAccessibilityAction, dispatchNestedPreScroll, dispatchNestedScroll, dispatchPopulateAccessibilityEvent, draw, drawableHotspotChanged, findViewById, findViewWithTag, fitSystemWindows, focusSearch, forceHasOverlappingRendering, forceLayout, generateViewId, getAccessibilityDelegate, getAccessibilityLiveRegion, getAccessibilityNodeProvider, getAccessibilityPaneTitle, getAccessibilityTraversalAfter, getAccessibilityTraversalBefore, 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, 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, getResources, getRevealOnFocusHint, getRight, getRightFadingEdgeStrength, getRightPaddingOffset, getRootView, getRootWindowInsets, getRotation, getRotationX, getRotationY, getScaleX, getScaleY, getScrollBarDefaultDelayBeforeFade, getScrollBarFadeDuration, getScrollBarSize, getScrollBarStyle, 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, 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, isAccessibilityFocused, isAccessibilityHeading, isActivated, isAttachedToWindow, isClickable, isContextClickable, isDirty, isDrawingCacheEnabled, isDuplicateParentStateEnabled, isEnabled, isFocusable, isFocusableInTouchMode, isFocused, isFocusedByDefault, isForceDarkAllowed, isHapticFeedbackEnabled, isHardwareAccelerated, isHorizontalFadingEdgeEnabled, isHorizontalScrollBarEnabled, isHovered, isImportantForAccessibility, isImportantForAutofill, isImportantForContentCapture, isInEditMode, isInLayout, isInTouchMode, isKeyboardNavigationCluster, isLaidOut, isLayoutDirectionResolved, isLayoutRequested, isLongClickable, isNestedScrollingEnabled, isOpaque, isPaddingOffsetRequired, isPaddingRelative, isPivotSet, 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, 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, onRestoreInstanceState, onRtlPropertiesChanged, onSaveInstanceState, onScreenStateChanged, onScrollChanged, onSetAlpha, onSizeChanged, onStartTemporaryDetach, onTouchEvent, onTrackballEvent, onVisibilityAggregated, onVisibilityChanged, onWindowFocusChanged, onWindowSystemUiVisibilityChanged, onWindowVisibilityChanged, overScrollBy, performAccessibilityAction, performClick, performContextClick, performContextClick, performHapticFeedback, performHapticFeedback, performLongClick, performLongClick, 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, setAccessibilityDelegate, setAccessibilityHeading, setAccessibilityLiveRegion, setAccessibilityPaneTitle, setAccessibilityTraversalAfter, setAccessibilityTraversalBefore, setActivated, setAlpha, setAnimation, setAnimationMatrix, setAutofillHints, setAutofillId, 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, setHapticFeedbackEnabled, setHasTransientState, setHorizontalFadingEdgeEnabled, setHorizontalScrollBarEnabled, setHorizontalScrollbarThumbDrawable, setHorizontalScrollbarTrackDrawable, setHovered, setId, setImportantForAccessibility, setImportantForAutofill, setImportantForContentCapture, 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, setOnScrollChangeListener, setOnSystemUiVisibilityChangeListener, setOnTouchListener, setOutlineAmbientShadowColor, setOutlineProvider, setOutlineSpotShadowColor, setOverScrollMode, setPadding, setPaddingRelative, setPivotX, setPivotY, setPointerIcon, setPressed, setRevealOnFocusHint, setRight, setRotation, setRotationX, setRotationY, setSaveEnabled, setSaveFromParentEnabled, setScaleX, setScaleY, setScreenReaderFocusable, setScrollBarDefaultDelayBeforeFade, setScrollBarFadeDuration, setScrollbarFadingEnabled, setScrollBarSize, setScrollBarStyle, 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, setVisibility, setWillNotCacheDrawing, setWillNotDraw, setX, setY, setZ, showContextMenu, showContextMenu, startActionMode, startActionMode, startAnimation, startDrag, startDragAndDrop, startNestedScroll, stopNestedScroll, toString, transformMatrixToGlobal, transformMatrixToLocal, unscheduleDrawable, unscheduleDrawable, updateDragShadow, verifyDrawable, willNotCacheDrawing, willNotDraw
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
canResolveLayoutDirection, canResolveTextAlignment, canResolveTextDirection, createContextMenu, getLayoutDirection, getParent, getParentForAccessibility, getTextAlignment, getTextDirection, isLayoutDirectionResolved, isLayoutRequested, isTextAlignmentResolved, isTextDirectionResolved, keyboardNavigationClusterSearch, requestFitSystemWindows, requestLayout
@Nullable protected CameraEventsListener mCameraEventsListener
protected boolean mErrorState
@Nullable protected DeviceManager mDeviceManager
@NonNull protected BaseCameraView.CameraViewState mCameraViewState
@Nullable protected ICameraView mCameraSurfaceView
protected int mConfigurationOrientation
@Nullable protected OnActivityFlipListener mOnActivityFlipListener
protected int mHostScreenOrientation
@NonNull protected CameraAspectMode mAspectMode
protected boolean mIsRequestedOrientationSensor
protected boolean mIsRequestedOrientationUser
@NonNull protected OrientationChangeListener mOrientationChangeListener
protected boolean mRotateMeteringAreas
@Nullable protected Orientation mInitialOrientation
@NonNull protected java.util.concurrent.ConcurrentLinkedQueue mSlaveOrientationChangeListeners
public BaseCameraView(@NonNull android.content.Context context)
public BaseCameraView(@NonNull android.content.Context context, @Nullable android.util.AttributeSet attrs)
protected static boolean isRequestedOrientationSensor(int requestedOrientation)
protected boolean isRequestedOrientationUser(int requestedOrientation)
protected int calculateHostScreenOrientation()
@AnyThread protected void runOnUIThread(@NonNull java.lang.Runnable runnable)
runnable
- public void changeConfiguration(@Nullable android.content.res.Configuration newConfiguration)
newConfiguration
- New view configuration@CallSuper protected void changeConfigurationInternal(@Nullable android.content.res.Configuration newConfiguration)
@Nullable protected android.app.Activity getHostActivity()
@CallSuper public void create()
@CallSuper public void destroy()
protected void prepareCameraSettings(@NonNull CameraSettings settings)
@NonNull protected CameraSettings getCameraFactorySettings()
protected boolean shouldStartCamera()
protected void onCameraPreviewStarted()
protected void onCameraPreviewStopped()
@MainThread @CallSuper public void start()
@MainThread @CallSuper public void resume()
@MainThread @CallSuper public void pause()
@MainThread @CallSuper public void stop()
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
onMeasure
in class android.view.View
public boolean dispatchTouchEvent(@Nullable android.view.MotionEvent ev)
dispatchTouchEvent
in class android.view.ViewGroup
protected void onLayout(boolean changed, int l, int t, int r, int b)
onLayout
in class android.view.ViewGroup
public final boolean isCameraFocused()
protected void captureHighResFrame()
@Nullable public final CameraType getOpenedCameraType()
public final void focusCamera()
public final boolean isCameraTorchSupported()
@Nullable public final java.lang.Boolean isAutofocusSupported()
public final void setTorchState(boolean on, @NonNull SuccessCallback successCallback)
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 stateprotected int getCameraSensorOrientation()
protected boolean areCameraPixelsLandscapeLeft()
public final float getZoomLevel()
public final void setZoomLevel(float zoomLevel)
zoomLevel
- Desired camera zoom level.public final int getHighResFrameLimit()
public final void setHighResFrameLimit(int highResFrameLimit)
highResFrameLimit
- desired high res frame limit, minimum 1public void setHighResFrameCaptureEnabled(boolean enabled)
VideoResolutionPreset.VIDEO_RESOLUTION_DEFAULT
,
higher resolutions might cause problems when combined with high res frame capture on some devices.enabled
- should high res frame capture be enabledpublic boolean isHighResFrameCaptureEnabled()
@NonNull public final BaseCameraView.CameraViewState getCameraViewState()
public final boolean isTapToFocusAllowed()
public final void setTapToFocusAllowed(boolean allowTapToFocus)
allowTapToFocus
- whether or not tap to focus is allowedpublic final boolean isPinchToZoomAllowed()
public final void setPinchToZoomAllowed(boolean allowPinchToZoom)
allowPinchToZoom
- whether or not pinch to zoom is allowed. Default is false.public final boolean isDeviceShaking()
public final int getCameraPreviewWidth()
public final int getCameraPreviewHeight()
public final void setMeteringAreas(@NonNull android.graphics.RectF[] meteringAreas, boolean rotateAreasWithDevice)
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 changesjava.lang.NullPointerException
- if at least one element of meteringAreas is nulljava.lang.IllegalArgumentException
- if at least on element of meteringAreas has either zero surface or is not inside viewjava.lang.IllegalStateException
- if camera is not activeprotected void setMeteringAreasToCamera()
@AnyThread public final boolean isCameraActive()
protected final int getConfigurationOrientation()
public void setCameraType(@NonNull CameraType cameraType)
cameraType
- public void setShakeListener(@NonNull ShakeCallback shakeCallback)
shakeCallback
- @NonNull public CameraAspectMode getAspectMode()
public void setAspectMode(@NonNull CameraAspectMode aspectMode)
aspectMode
- desired aspect modepublic final void setOnSizeChangedListener(@NonNull OnSizeChangedListener onSizeChangedListener)
onSizeChangedListener
- public final void setOnActivityFlipListener(@NonNull OnActivityFlipListener onActivityFlipListener)
onActivityFlipListener
- Activity flip listenerpublic final void setVideoResolutionPreset(@NonNull VideoResolutionPreset preset)
preset
- Sets the preset that will be used for choosing camera video resolution.public final void setForceUseLegacyCamera(boolean useLegacyCamera)
useLegacyCamera
- If set to true, legacy Camera API will be used even on devices that support new Camera2 API.public final void setCameraFrameFactory(CameraFrameFactory cameraFrameFactory)
public final void setRequestAutofocusOnShakingStopInContinousAutofocusMode(boolean requestAutofocusOnShakingStopInContinousAutofocusMode)
requestAutofocusOnShakingStopInContinousAutofocusMode
- will autofocus be requested each time device shaking stops.public final void setOptimizeCameraForNearScan(boolean nearScan)
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.public final void setRequestedSurfaceViewForCameraDisplay(@NonNull CameraSurface requestedSurface)
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.requestedSurface
- Which view should be used to display camera preview.@Nullable public CameraEventsListener getCameraEventsListener()
public void setCameraEventsListener(@Nullable CameraEventsListener cameraEventsListener)
cameraEventsListener
- public int getHostScreenOrientation()
@NonNull public android.graphics.RectF getVisiblePart()
@NonNull protected OrientationChangeListener createOrientationChangeListener()
@NonNull protected ICameraView.CameraViewEventListener createCameraViewEventsListener()
protected abstract boolean requireAutofocusFeature()
protected abstract void onActivityFlip()
@NonNull protected abstract CameraListener createCameraListener()
protected boolean isHostActivityOrientationOnSensor()
@NonNull public Orientation getCurrentOrientation()
protected final boolean isOrientationAllowed(@Nullable Orientation orientation)
@Nullable public final Orientation getInitialOrientation()
@CallSuper public void setInitialOrientation(@Nullable Orientation initialOrientation)
initialOrientation
- public void setOrientationAllowedListener(@NonNull OrientationAllowedListener orientationAllowedListener)
public void addOrientationChangeListener(@NonNull OrientationChangeListener orientationChangeListener)
orientationChangeListener
- listener that will receive orientation change eventsjava.lang.NullPointerException
- if the specified listener is null.java.lang.IllegalStateException
- if addOrientationChangeListener is called after calling start()public void removeOrientationChangeListener(@NonNull OrientationChangeListener orientationChangeListener)
orientationChangeListener
- listener to be removed from the collection.