Package com.geniusscansdk.camera
Class ScanFragmentX
- java.lang.Object
-
- androidx.fragment.app.Fragment
-
- com.geniusscansdk.camera.ScanFragment
-
- com.geniusscansdk.camera.ScanFragmentX
-
- All Implemented Interfaces:
android.content.ComponentCallbacks
,android.view.View.OnCreateContextMenuListener
,androidx.activity.result.ActivityResultCaller
,androidx.lifecycle.HasDefaultViewModelProviderFactory
,androidx.lifecycle.LifecycleOwner
,androidx.lifecycle.ViewModelStoreOwner
,androidx.savedstate.SavedStateRegistryOwner
public class ScanFragmentX extends ScanFragment
Implementation ofScanFragment
using CameraX API
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.geniusscansdk.camera.ScanFragment
ScanFragment.Callback, ScanFragment.CameraCallbackProvider
-
-
Constructor Summary
Constructors Constructor Description ScanFragmentX()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.List<FlashMode>
getAvailableFlashModes()
void
initializeCamera()
Setup the camera and start the preview.boolean
isRealTimeBorderDetectionEnabled()
static byte[]
jpegImageToJpegByteArray(androidx.camera.core.ImageProxy image)
void
onAttach(android.content.Context context)
android.view.View
onCreateView(android.view.LayoutInflater inflater, android.view.ViewGroup container, android.os.Bundle savedInstanceState)
void
onPause()
void
onViewCreated(android.view.View view, android.os.Bundle savedInstanceState)
void
resetBorderDetection()
void
setAutoTriggerAnimationEnabled(boolean enabled)
void
setBorderDetectorListener(BorderDetector.BorderDetectorListener listener)
void
setFlashMode(FlashMode flashMode)
Set the camera flash mode.void
setFocusIndicator(FocusIndicator focusIndicator)
void
setJpegQuality(int jpegQuality)
Set the JPEG quality of camera output pictures.void
setOverlayColor(int colorResId)
void
setOverlayColorResource(int colorResId)
void
setPreviewAspectFill(boolean isAspectFill)
void
setPreviewEnabled(boolean enabled)
void
setRealTimeDetectionEnabled(boolean enabled)
boolean
takePicture(ImageCaptureCallback callback)
boolean
takePicture(ImageCaptureCallback callback, boolean focusBeforeTrigger)
Stop the real-time border detection and capture the imageFlashMode
toggleFlashMode()
Toggle the flash mode to the next available flash mode.-
Methods inherited from class com.geniusscansdk.camera.ScanFragment
createBestForDevice
-
Methods inherited from class androidx.fragment.app.Fragment
dump, equals, getActivity, getAllowEnterTransitionOverlap, getAllowReturnTransitionOverlap, getArguments, getChildFragmentManager, getContext, getDefaultViewModelProviderFactory, getEnterTransition, getExitTransition, getFragmentManager, getHost, getId, getLayoutInflater, getLayoutInflater, getLifecycle, getLoaderManager, getParentFragment, getParentFragmentManager, getReenterTransition, getResources, getRetainInstance, getReturnTransition, getSavedStateRegistry, getSharedElementEnterTransition, getSharedElementReturnTransition, getString, getString, getTag, getTargetFragment, getTargetRequestCode, getText, getUserVisibleHint, getView, getViewLifecycleOwner, getViewLifecycleOwnerLiveData, getViewModelStore, hashCode, hasOptionsMenu, instantiate, instantiate, isAdded, isDetached, isHidden, isInLayout, isMenuVisible, isRemoving, isResumed, isStateSaved, isVisible, onActivityCreated, onActivityResult, onAttach, onAttachFragment, onConfigurationChanged, onContextItemSelected, onCreate, onCreateAnimation, onCreateAnimator, onCreateContextMenu, onCreateOptionsMenu, onDestroy, onDestroyOptionsMenu, onDestroyView, onDetach, onGetLayoutInflater, onHiddenChanged, onInflate, onInflate, onLowMemory, onMultiWindowModeChanged, onOptionsItemSelected, onOptionsMenuClosed, onPictureInPictureModeChanged, onPrepareOptionsMenu, onPrimaryNavigationFragmentChanged, onRequestPermissionsResult, onResume, onSaveInstanceState, onStart, onStop, onViewStateRestored, postponeEnterTransition, postponeEnterTransition, registerForActivityResult, registerForActivityResult, registerForContextMenu, requestPermissions, requireActivity, requireArguments, requireContext, requireFragmentManager, requireHost, requireParentFragment, requireView, setAllowEnterTransitionOverlap, setAllowReturnTransitionOverlap, setArguments, setEnterSharedElementCallback, setEnterTransition, setExitSharedElementCallback, setExitTransition, setHasOptionsMenu, setInitialSavedState, setMenuVisibility, setReenterTransition, setRetainInstance, setReturnTransition, setSharedElementEnterTransition, setSharedElementReturnTransition, setTargetFragment, setUserVisibleHint, shouldShowRequestPermissionRationale, startActivity, startActivity, startActivityForResult, startActivityForResult, startIntentSenderForResult, startPostponedEnterTransition, toString, unregisterForContextMenu
-
-
-
-
Method Detail
-
onAttach
public void onAttach(@NonNull android.content.Context context)
- Overrides:
onAttach
in classandroidx.fragment.app.Fragment
-
onCreateView
public android.view.View onCreateView(@NonNull android.view.LayoutInflater inflater, android.view.ViewGroup container, android.os.Bundle savedInstanceState)
- Overrides:
onCreateView
in classandroidx.fragment.app.Fragment
-
onViewCreated
public void onViewCreated(@NonNull android.view.View view, @Nullable android.os.Bundle savedInstanceState)
- Overrides:
onViewCreated
in classandroidx.fragment.app.Fragment
-
onPause
public void onPause()
- Overrides:
onPause
in classandroidx.fragment.app.Fragment
-
initializeCamera
public void initializeCamera()
Description copied from class:ScanFragment
Setup the camera and start the preview. This needs to be called by the parent activity in Activity#onResume().- Specified by:
initializeCamera
in classScanFragment
-
setPreviewEnabled
public void setPreviewEnabled(boolean enabled)
- Specified by:
setPreviewEnabled
in classScanFragment
-
setPreviewAspectFill
public void setPreviewAspectFill(boolean isAspectFill)
- Specified by:
setPreviewAspectFill
in classScanFragment
- See Also:
PreviewSurfaceView.setAspectFill(boolean)
-
takePicture
public boolean takePicture(ImageCaptureCallback callback)
- Specified by:
takePicture
in classScanFragment
- Parameters:
callback
- used to notify capture success or failure- See Also:
ScanFragment.takePicture(ImageCaptureCallback, boolean)
-
takePicture
public boolean takePicture(ImageCaptureCallback callback, boolean focusBeforeTrigger)
Description copied from class:ScanFragment
Stop the real-time border detection and capture the image- Specified by:
takePicture
in classScanFragment
- Parameters:
callback
- used to notify capture success or failurefocusBeforeTrigger
- if true, an auto-focus will run before the picture is captured. This can be especially useful on devices where the continuous auto-focus is not great to improve the chances of the picture being sharp, but it slows down the capture.- Returns:
- false if a picture is already being taken, true otherwise
-
jpegImageToJpegByteArray
@NonNull public static byte[] jpegImageToJpegByteArray(@NonNull androidx.camera.core.ImageProxy image)
-
setRealTimeDetectionEnabled
public void setRealTimeDetectionEnabled(boolean enabled)
- Specified by:
setRealTimeDetectionEnabled
in classScanFragment
-
setOverlayColor
public void setOverlayColor(int colorResId)
- Specified by:
setOverlayColor
in classScanFragment
-
setOverlayColorResource
public void setOverlayColorResource(@ColorRes int colorResId)
- Specified by:
setOverlayColorResource
in classScanFragment
-
setFlashMode
public void setFlashMode(@NonNull FlashMode flashMode)
Description copied from class:ScanFragment
Set the camera flash mode. It's best to callScanFragment.getAvailableFlashModes()
to make sure that the camera supports this flash mode.- Specified by:
setFlashMode
in classScanFragment
- Parameters:
flashMode
- the flash mode to use
-
toggleFlashMode
@Nullable public FlashMode toggleFlashMode()
Description copied from class:ScanFragment
Toggle the flash mode to the next available flash mode. It's best to callScanFragment.getAvailableFlashModes()
to make sure that the camera supports this flash mode.- Specified by:
toggleFlashMode
in classScanFragment
- Returns:
- the next available flash mode or null if the camera doesn't support flash.
-
getAvailableFlashModes
@NonNull public java.util.List<FlashMode> getAvailableFlashModes()
- Specified by:
getAvailableFlashModes
in classScanFragment
- Returns:
- supported flash modes or an empty list if the camera is not yet available
-
setJpegQuality
public void setJpegQuality(int jpegQuality)
Description copied from class:ScanFragment
Set the JPEG quality of camera output pictures. This method can only be called when the camera is ready.- Specified by:
setJpegQuality
in classScanFragment
- Parameters:
jpegQuality
- , between 0 and 100
-
setFocusIndicator
public void setFocusIndicator(@Nullable FocusIndicator focusIndicator)
- Specified by:
setFocusIndicator
in classScanFragment
-
setBorderDetectorListener
public void setBorderDetectorListener(BorderDetector.BorderDetectorListener listener)
- Specified by:
setBorderDetectorListener
in classScanFragment
-
setAutoTriggerAnimationEnabled
public void setAutoTriggerAnimationEnabled(boolean enabled)
- Specified by:
setAutoTriggerAnimationEnabled
in classScanFragment
-
isRealTimeBorderDetectionEnabled
public boolean isRealTimeBorderDetectionEnabled()
- Specified by:
isRealTimeBorderDetectionEnabled
in classScanFragment
-
resetBorderDetection
public void resetBorderDetection()
- Specified by:
resetBorderDetection
in classScanFragment
-
-