CameraFragmentCompat

Component API

{@code CameraFragmentCompat} is the main entry point to the Gini Vision Library when using the Component API with the Android Support Library.

It shows a camera preview with tap-to-focus functionality, a trigger button and an optional flash on/off button. The camera preview also shows document corner guides to which the user should align the document.

If instantiated with createInstance then a button for importing documents is shown next to the trigger button. A hint popup is displayed the first time the Gini Vision Library is used to inform the user about document importing.

For importing documents {@code READ_EXTERNAL_STORAGE} permission is required and if the permission is not granted the Gini Vision Library will prompt the user to grant the permission. See @ { code Customizing the Camera Screen } on how to override the message and button titles for the rationale and on permission denial alerts.

Note: Your Activity hosting this Fragment must extend the and use an AppCompat Theme.

Include the {@code CameraFragmentCompat} into your layout either directly with {@code } in your Activity's layout or using the androidx.fragment.app.FragmentManager and one of the {@code createInstance()} methods.

A CameraFragmentListener instance must be available until the {@code * CameraFragmentCompat} is attached to an activity. Failing to do so will throw an exception. The listener instance can be provided either implicitly by making the hosting Activity implement the CameraFragmentListener interface or explicitly by setting the listener using .

Your Activity is automatically set as the listener in onAttach .

Customizing the Camera Screen

See the CameraActivity for details.

public class CameraFragmentCompat extends Fragment implements CameraFragmentInterface, FragmentImplCallback

Functions

callStartTransitionListener
Link copied to clipboard
void callStartTransitionListener()
createInstance
Link copied to clipboard
static CameraFragmentCompat createInstance()

Factory method for creating a new instance of the Fragment with document import enabled for the specified file types.

dump
Link copied to clipboard
void dump(String prefix, FileDescriptor fd, PrintWriter writer, Array<Stringargs)
ensureAnimationInfo
Link copied to clipboard
Fragment.AnimationInfo ensureAnimationInfo()
equals
Link copied to clipboard
final boolean equals(Object o)
findFragmentByWho
Link copied to clipboard
Fragment findFragmentByWho(String who)
getActivity
Link copied to clipboard
final FragmentActivity getActivity()
abstract Activity getActivity()
getAllowEnterTransitionOverlap
Link copied to clipboard
boolean getAllowEnterTransitionOverlap()
getAllowReturnTransitionOverlap
Link copied to clipboard
boolean getAllowReturnTransitionOverlap()
getAnimatingAway
Link copied to clipboard
View getAnimatingAway()
getAnimator
Link copied to clipboard
Animator getAnimator()
getArguments
Link copied to clipboard
final Bundle getArguments()
getChildFragmentManager
Link copied to clipboard
final FragmentManager getChildFragmentManager()
getContext
Link copied to clipboard
Context getContext()
getDefaultViewModelProviderFactory
Link copied to clipboard
getEnterTransition
Link copied to clipboard
Object getEnterTransition()
getEnterTransitionCallback
Link copied to clipboard
SharedElementCallback getEnterTransitionCallback()
getExitTransition
Link copied to clipboard
Object getExitTransition()
getExitTransitionCallback
Link copied to clipboard
SharedElementCallback getExitTransitionCallback()
getFragmentManager
Link copied to clipboard
final FragmentManager getFragmentManager()
getHost
Link copied to clipboard
final Object getHost()
getId
Link copied to clipboard
final int getId()
getLayoutInflater
Link copied to clipboard
final LayoutInflater getLayoutInflater()
getLifecycle
Link copied to clipboard
Lifecycle getLifecycle()
getLoaderManager
Link copied to clipboard
LoaderManager getLoaderManager()
getNextAnim
Link copied to clipboard
int getNextAnim()
getNextTransition
Link copied to clipboard
int getNextTransition()
getParentFragment
Link copied to clipboard
final Fragment getParentFragment()
getParentFragmentManager
Link copied to clipboard
final FragmentManager getParentFragmentManager()
getReenterTransition
Link copied to clipboard
Object getReenterTransition()
getResources
Link copied to clipboard
final Resources getResources()
getRetainInstance
Link copied to clipboard
final boolean getRetainInstance()
getReturnTransition
Link copied to clipboard
Object getReturnTransition()
getSavedStateRegistry
Link copied to clipboard
final SavedStateRegistry getSavedStateRegistry()
getSharedElementEnterTransition
Link copied to clipboard
Object getSharedElementEnterTransition()
getSharedElementReturnTransition
Link copied to clipboard
Object getSharedElementReturnTransition()
getStateAfterAnimating
Link copied to clipboard
int getStateAfterAnimating()
getString
Link copied to clipboard
final String getString(int resId)
getTag
Link copied to clipboard
final String getTag()
getTargetFragment
Link copied to clipboard
final Fragment getTargetFragment()
getTargetRequestCode
Link copied to clipboard
final int getTargetRequestCode()
getText
Link copied to clipboard
final CharSequence getText(int resId)
getUserVisibleHint
Link copied to clipboard
boolean getUserVisibleHint()
getView
Link copied to clipboard
View getView()
abstract View getView()
getViewLifecycleOwner
Link copied to clipboard
LifecycleOwner getViewLifecycleOwner()
getViewLifecycleOwnerLiveData
Link copied to clipboard
LiveData<LifecycleOwnergetViewLifecycleOwnerLiveData()
getViewModelStore
Link copied to clipboard
ViewModelStore getViewModelStore()
hashCode
Link copied to clipboard
final int hashCode()
hasOptionsMenu
Link copied to clipboard
final boolean hasOptionsMenu()
hideActivityIndicatorAndEnableInteraction
Link copied to clipboard

Call this method to hide the activity indicator and enable user interaction.

void hideActivityIndicatorAndEnableInteraction()
hideCameraTriggerButton
Link copied to clipboard

Call this method to hide the camera trigger button.

Note: the camera trigger button is shown by default.

void hideCameraTriggerButton()
hideDocumentCornerGuides
Link copied to clipboard

Call this method to hide the document corner guides.

Note: the document corner guides are shown by default.

void hideDocumentCornerGuides()
hideInterface
Link copied to clipboard

Call this method to hide the interface elements. The camera preview remains visible.

Note: the interface elements are shown by default.

void hideInterface()
initLifecycle
Link copied to clipboard
void initLifecycle()
initState
Link copied to clipboard
void initState()
instantiate
Link copied to clipboard
static Fragment instantiate(Context context, String fname)
isAdded
Link copied to clipboard
final boolean isAdded()
isDetached
Link copied to clipboard
final boolean isDetached()
isHidden
Link copied to clipboard
final boolean isHidden()
isHideReplaced
Link copied to clipboard
boolean isHideReplaced()
isInBackStack
Link copied to clipboard
final boolean isInBackStack()
isInLayout
Link copied to clipboard
final boolean isInLayout()
isMenuVisible
Link copied to clipboard
final boolean isMenuVisible()
isPostponed
Link copied to clipboard
boolean isPostponed()
isRemoving
Link copied to clipboard
final boolean isRemoving()
isRemovingParent
Link copied to clipboard
final boolean isRemovingParent()
isResumed
Link copied to clipboard
final boolean isResumed()
isStateSaved
Link copied to clipboard
final boolean isStateSaved()
isVisible
Link copied to clipboard
final boolean isVisible()
noteStateNotSaved
Link copied to clipboard
void noteStateNotSaved()
onActivityCreated
Link copied to clipboard
void onActivityCreated(Bundle savedInstanceState)
onActivityResult
Link copied to clipboard
void onActivityResult(int requestCode, int resultCode, Intent data)
void onActivityResult(int requestCode, int resultCode, Intent data)
onAttach
Link copied to clipboard
void onAttach(Context context)
onAttachFragment
Link copied to clipboard
void onAttachFragment(Fragment childFragment)
onConfigurationChanged
Link copied to clipboard
void onConfigurationChanged(Configuration newConfig)
onContextItemSelected
Link copied to clipboard
boolean onContextItemSelected(MenuItem item)
onCreate
Link copied to clipboard
void onCreate(Bundle savedInstanceState)

Internal use only.

void onCreate(Bundle savedInstanceState)
onCreateAnimation
Link copied to clipboard
Animation onCreateAnimation(int transit, boolean enter, int nextAnim)
onCreateAnimator
Link copied to clipboard
Animator onCreateAnimator(int transit, boolean enter, int nextAnim)
onCreateContextMenu
Link copied to clipboard
onCreateOptionsMenu
Link copied to clipboard
void onCreateOptionsMenu(Menu menu, MenuInflater inflater)
onCreateView
Link copied to clipboard
onDestroy
Link copied to clipboard
void onDestroy()

Internal use only.

void onDestroy()
onDestroyOptionsMenu
Link copied to clipboard
void onDestroyOptionsMenu()
onDestroyView
Link copied to clipboard
void onDestroyView()
onDetach
Link copied to clipboard
void onDetach()
onGetLayoutInflater
Link copied to clipboard
onHiddenChanged
Link copied to clipboard
void onHiddenChanged(boolean hidden)
onInflate
Link copied to clipboard
void onInflate(Context context, AttributeSet attrs, Bundle savedInstanceState)
onLowMemory
Link copied to clipboard
void onLowMemory()
onMultiWindowModeChanged
Link copied to clipboard
void onMultiWindowModeChanged(boolean isInMultiWindowMode)
onOptionsItemSelected
Link copied to clipboard
boolean onOptionsItemSelected(MenuItem item)
onOptionsMenuClosed
Link copied to clipboard
void onOptionsMenuClosed(Menu menu)
onPause
Link copied to clipboard
void onPause()
onPictureInPictureModeChanged
Link copied to clipboard
void onPictureInPictureModeChanged(boolean isInPictureInPictureMode)
onPrepareOptionsMenu
Link copied to clipboard
void onPrepareOptionsMenu(Menu menu)
onPrimaryNavigationFragmentChanged
Link copied to clipboard
void onPrimaryNavigationFragmentChanged(boolean isPrimaryNavigationFragment)
onRequestPermissionsResult
Link copied to clipboard
void onRequestPermissionsResult(int requestCode, Array<Stringpermissions, Array<int> grantResults)
onResume
Link copied to clipboard
void onResume()

Internal use only.

void onResume()
onSaveInstanceState
Link copied to clipboard
void onSaveInstanceState(Bundle outState)

Internal use only.

void onSaveInstanceState(Bundle outState)
onStart
Link copied to clipboard
void onStart()

Internal use only.

void onStart()
onStop
Link copied to clipboard
void onStop()

Internal use only.

void onStop()
onViewCreated
Link copied to clipboard
void onViewCreated(View view, Bundle savedInstanceState)
onViewStateRestored
Link copied to clipboard
void onViewStateRestored(Bundle savedInstanceState)
performActivityCreated
Link copied to clipboard
void performActivityCreated(Bundle savedInstanceState)
performAttach
Link copied to clipboard
void performAttach()
performConfigurationChanged
Link copied to clipboard
void performConfigurationChanged(Configuration newConfig)
performContextItemSelected
Link copied to clipboard
boolean performContextItemSelected(MenuItem item)
performCreate
Link copied to clipboard
void performCreate(Bundle savedInstanceState)
performCreateOptionsMenu
Link copied to clipboard
boolean performCreateOptionsMenu(Menu menu, MenuInflater inflater)
performCreateView
Link copied to clipboard
performDestroy
Link copied to clipboard
void performDestroy()
performDestroyView
Link copied to clipboard
void performDestroyView()
performDetach
Link copied to clipboard
void performDetach()
performGetLayoutInflater
Link copied to clipboard
performLowMemory
Link copied to clipboard
void performLowMemory()
performMultiWindowModeChanged
Link copied to clipboard
void performMultiWindowModeChanged(boolean isInMultiWindowMode)
performOptionsItemSelected
Link copied to clipboard
boolean performOptionsItemSelected(MenuItem item)
performOptionsMenuClosed
Link copied to clipboard
void performOptionsMenuClosed(Menu menu)
performPause
Link copied to clipboard
void performPause()
performPictureInPictureModeChanged
Link copied to clipboard
void performPictureInPictureModeChanged(boolean isInPictureInPictureMode)
performPrepareOptionsMenu
Link copied to clipboard
boolean performPrepareOptionsMenu(Menu menu)
performPrimaryNavigationFragmentChanged
Link copied to clipboard
void performPrimaryNavigationFragmentChanged()
performResume
Link copied to clipboard
void performResume()
performSaveInstanceState
Link copied to clipboard
void performSaveInstanceState(Bundle outState)
performStart
Link copied to clipboard
void performStart()
performStop
Link copied to clipboard
void performStop()
postponeEnterTransition
Link copied to clipboard
void postponeEnterTransition()
registerForContextMenu
Link copied to clipboard
void registerForContextMenu(View view)
requestPermissions
Link copied to clipboard
final void requestPermissions(Array<Stringpermissions, int requestCode)
requireActivity
Link copied to clipboard
final FragmentActivity requireActivity()
requireArguments
Link copied to clipboard
final Bundle requireArguments()
requireContext
Link copied to clipboard
final Context requireContext()
requireFragmentManager
Link copied to clipboard
final FragmentManager requireFragmentManager()
requireHost
Link copied to clipboard
final Object requireHost()
requireParentFragment
Link copied to clipboard
final Fragment requireParentFragment()
requireView
Link copied to clipboard
final View requireView()
restoreChildFragmentState
Link copied to clipboard
void restoreChildFragmentState(Bundle savedInstanceState)
restoreViewState
Link copied to clipboard
final void restoreViewState(Bundle savedInstanceState)
setAllowEnterTransitionOverlap
Link copied to clipboard
void setAllowEnterTransitionOverlap(boolean allow)
setAllowReturnTransitionOverlap
Link copied to clipboard
void setAllowReturnTransitionOverlap(boolean allow)
setAnimatingAway
Link copied to clipboard
void setAnimatingAway(View view)
setAnimator
Link copied to clipboard
void setAnimator(Animator animator)
setArguments
Link copied to clipboard
void setArguments(Bundle args)
setEnterSharedElementCallback
Link copied to clipboard
setEnterTransition
Link copied to clipboard
void setEnterTransition(Object transition)
setExitSharedElementCallback
Link copied to clipboard
void setExitSharedElementCallback(SharedElementCallback callback)
setExitTransition
Link copied to clipboard
void setExitTransition(Object transition)
setHasOptionsMenu
Link copied to clipboard
void setHasOptionsMenu(boolean hasMenu)
setHideReplaced
Link copied to clipboard
void setHideReplaced(boolean replaced)
setInitialSavedState
Link copied to clipboard
void setInitialSavedState(Fragment.SavedState state)
setListener
Link copied to clipboard

Set a listener for camera events.

By default the hosting Activity is expected to implement the CameraFragmentListener . In case that is not feasible you may set the listener using this method.

Note: the listener is expected to be available until the fragment is attached to an activity. Make sure to set the listener before that.

void setListener(CameraFragmentListener listener)
setMenuVisibility
Link copied to clipboard
void setMenuVisibility(boolean menuVisible)
setNextAnim
Link copied to clipboard
void setNextAnim(int animResourceId)
setNextTransition
Link copied to clipboard
void setNextTransition(int nextTransition)
setOnStartEnterTransitionListener
Link copied to clipboard
setReenterTransition
Link copied to clipboard
void setReenterTransition(Object transition)
setRetainInstance
Link copied to clipboard
void setRetainInstance(boolean retain)
setReturnTransition
Link copied to clipboard
void setReturnTransition(Object transition)
setSharedElementEnterTransition
Link copied to clipboard
void setSharedElementEnterTransition(Object transition)
setSharedElementReturnTransition
Link copied to clipboard
void setSharedElementReturnTransition(Object transition)
setStateAfterAnimating
Link copied to clipboard
void setStateAfterAnimating(int state)
setTargetFragment
Link copied to clipboard
void setTargetFragment(Fragment fragment, int requestCode)
setUserVisibleHint
Link copied to clipboard
void setUserVisibleHint(boolean isVisibleToUser)
shouldShowRequestPermissionRationale
Link copied to clipboard
boolean shouldShowRequestPermissionRationale(String permission)
showActivityIndicatorAndDisableInteraction
Link copied to clipboard

Call this method to show an activity indicator and disable user interaction. The camera preview remains visible.

void showActivityIndicatorAndDisableInteraction()
showCameraTriggerButton
Link copied to clipboard

Call this method to show the camera trigger button.

Note: the camera trigger button is shown by default.

void showCameraTriggerButton()
showDocumentCornerGuides
Link copied to clipboard

Call this method to show the document corner guides.

Note: the document corner guides are shown by default.

void showDocumentCornerGuides()
showError
Link copied to clipboard

Call this method to show an error message to the user in the Camera Screen.

void showError(String message, int duration)
abstract void showError(String message, int duration)
showInterface
Link copied to clipboard

Call this method to show the interface elements. The camera preview is always visible.

Note: the interface elements are shown by default.

void showInterface()
startActivity
Link copied to clipboard
void startActivity(Intent intent)
abstract void startActivity(Intent intent)
startActivityForResult
Link copied to clipboard
void startActivityForResult(Intent intent, int requestCode)
abstract void startActivityForResult(Intent intent, int requestCode)
startIntentSenderForResult
Link copied to clipboard
startPostponedEnterTransition
Link copied to clipboard
void startPostponedEnterTransition()
toString
Link copied to clipboard
String toString()
unregisterForContextMenu
Link copied to clipboard
void unregisterForContextMenu(View view)