Class ScanFragmentLegacy

  • 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 ScanFragmentLegacy
    extends ScanFragment
    Implementation of ScanFragment using the legacy Camera API
    • Method Summary

      All 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()  
      void onActivityCreated​(android.os.Bundle savedInstanceState)  
      void onAttach​(android.content.Context context)  
      android.view.View onCreateView​(android.view.LayoutInflater inflater, android.view.ViewGroup container, android.os.Bundle savedInstanceState)  
      void onDestroy()  
      void onPause()  
      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 color)  
      void setOverlayColorResource​(int colorResId)  
      void setPreviewAspectFill​(boolean isAspectFill)  
      void setPreviewEnabled​(boolean enabled)  
      void setRealTimeDetectionEnabled​(boolean enabled)  
      boolean takePicture​(java.io.File outputFile)  
      boolean takePicture​(java.io.File outputFile, boolean focusBeforeTrigger)
      Stop the real-time border detection and capture the image
      FlashMode toggleFlashMode()
      Toggle the flash mode to the next available flash mode.
      • 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, onActivityResult, onAttach, onAttachFragment, onConfigurationChanged, onContextItemSelected, onCreate, onCreateAnimation, onCreateAnimator, onCreateContextMenu, onCreateOptionsMenu, onDestroyOptionsMenu, onDestroyView, onDetach, onGetLayoutInflater, onHiddenChanged, onInflate, onInflate, onLowMemory, onMultiWindowModeChanged, onOptionsItemSelected, onOptionsMenuClosed, onPictureInPictureModeChanged, onPrepareOptionsMenu, onPrimaryNavigationFragmentChanged, onRequestPermissionsResult, onResume, onSaveInstanceState, onStart, onStop, onViewCreated, 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
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • ScanFragmentLegacy

        public ScanFragmentLegacy()
    • Method Detail

      • onAttach

        public void onAttach​(@NonNull
                             android.content.Context context)
        Overrides:
        onAttach in class androidx.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 class androidx.fragment.app.Fragment
      • onActivityCreated

        public void onActivityCreated​(android.os.Bundle savedInstanceState)
        Overrides:
        onActivityCreated in class androidx.fragment.app.Fragment
      • onPause

        public void onPause()
        Overrides:
        onPause in class androidx.fragment.app.Fragment
      • onDestroy

        public void onDestroy()
        Overrides:
        onDestroy in class androidx.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 class ScanFragment
      • takePicture

        public boolean takePicture​(java.io.File outputFile,
                                   boolean focusBeforeTrigger)
        Description copied from class: ScanFragment
        Stop the real-time border detection and capture the image
        Specified by:
        takePicture in class ScanFragment
        Parameters:
        outputFile - used to store the captured image
        focusBeforeTrigger - 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
      • getAvailableFlashModes

        public java.util.List<FlashMode> getAvailableFlashModes()
        Specified by:
        getAvailableFlashModes in class ScanFragment
        Returns:
        supported flash modes or null if the camera is not 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 class ScanFragment
        Parameters:
        jpegQuality - , between 0 and 100