-
- 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,net.gini.android.capture.camera.CameraFragmentInterface,net.gini.android.capture.internal.ui.FragmentImplCallback
public class CameraFragmentCompat extends Fragment implements CameraFragmentInterface, FragmentImplCallback
CameraFragmentCompatis the main entry point to the Gini Capture SDK 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 Capture SDK is used to inform the user about document importing.
For importing documents
READ_EXTERNAL_STORAGEpermission is required and if the permission is not granted the Gini Capture SDK 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
CameraFragmentCompatinto your layout either directly with<fragment>in your Activity's layout or using the androidx.fragment.app.FragmentManager and one of thecreateInstance()methods.A CameraFragmentListener instance must be available until the
CameraFragmentCompatis 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 setListener.Your Activity is automatically set as the listener in onAttach.
See the CameraActivity for details.
-
-
Field Summary
Fields Modifier and Type Field Description public StringmPreviousWho
-
Method Summary
Modifier and Type Method Description static CameraFragmentCompatcreateInstance()voidonCreate(Bundle savedInstanceState)Internal use only. ViewonCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)Internal use only. voidonStart()Internal use only. voidonResume()Internal use only. voidonStop()Internal use only. voidonSaveInstanceState(@NonNull() Bundle outState)Internal use only. voidonDestroy()Internal use only. voidonActivityResult(int requestCode, int resultCode, Intent data)voidsetListener(@NonNull() CameraFragmentListener listener)Set a listener for camera events. voidshowInterface()Call this method to show the interface elements. voidhideInterface()Call this method to hide the interface elements. voidshowActivityIndicatorAndDisableInteraction()Call this method to show an activity indicator and disable user interaction. voidhideActivityIndicatorAndEnableInteraction()Call this method to hide the activity indicator and enable user interaction. voidshowError(@NonNull() String message, int duration)Call this method to show an error message to the user in the Camera Screen. voidshowAlertDialog(@NonNull() String message, @NonNull() String positiveButtonTitle, @NonNull() DialogInterface.OnClickListener positiveButtonClickListener, @Nullable() String negativeButtonTitle, @Nullable() DialogInterface.OnClickListener negativeButtonClickListener, @Nullable() DialogInterface.OnCancelListener cancelListener)-
Methods inherited from class androidx.fragment.app.Fragment
dump, equals, getActivity, getAllowEnterTransitionOverlap, getAllowReturnTransitionOverlap, getArguments, getChildFragmentManager, getContext, getDefaultViewModelCreationExtras, getDefaultViewModelProviderFactory, getEnterTransition, getExitTransition, getFragmentManager, getHost, getId, getLayoutInflater, getLifecycle, getLoaderManager, getParentFragment, getParentFragmentManager, getReenterTransition, getResources, getRetainInstance, getReturnTransition, getSavedStateRegistry, getSharedElementEnterTransition, getSharedElementReturnTransition, getString, getTag, getTargetFragment, getTargetRequestCode, getText, getUserVisibleHint, getView, getViewLifecycleOwner, getViewLifecycleOwnerLiveData, getViewModelStore, hasOptionsMenu, hashCode, instantiate, isAdded, isDetached, isHidden, isInLayout, isMenuVisible, isRemoving, isResumed, isStateSaved, isVisible, onActivityCreated, onAttach, onAttachFragment, onConfigurationChanged, onContextItemSelected, onCreateAnimation, onCreateAnimator, onCreateContextMenu, onCreateOptionsMenu, onDestroyOptionsMenu, onDestroyView, onDetach, onGetLayoutInflater, onHiddenChanged, onInflate, onLowMemory, onMultiWindowModeChanged, onOptionsItemSelected, onOptionsMenuClosed, onPause, onPictureInPictureModeChanged, onPrepareOptionsMenu, onPrimaryNavigationFragmentChanged, onRequestPermissionsResult, onViewCreated, onViewStateRestored, postponeEnterTransition, 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, startActivityForResult, startIntentSenderForResult, startPostponedEnterTransition, toString, unregisterForContextMenu -
Methods inherited from class net.gini.android.capture.internal.ui.FragmentImplCallback
getActivity, getView, startActivity, startActivityForResult -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Method Detail
-
createInstance
static CameraFragmentCompat createInstance()
-
onCreateView
@Nullable() View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
Internal use only.
-
onStart
void onStart()
Internal use only.
-
onResume
void onResume()
Internal use only.
-
onStop
void onStop()
Internal use only.
-
onSaveInstanceState
void onSaveInstanceState(@NonNull() Bundle outState)
Internal use only.
-
onDestroy
void onDestroy()
Internal use only.
-
onActivityResult
void onActivityResult(int requestCode, int resultCode, Intent data)
-
setListener
void setListener(@NonNull() CameraFragmentListener listener)
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.
- Parameters:
listener- the CameraFragmentListener instance
-
showInterface
void showInterface()
Call this method to show the interface elements. The camera preview is always visible.
Note: the interface elements are shown by default.
-
hideInterface
void hideInterface()
Call this method to hide the interface elements. The camera preview remains visible.
Note: the interface elements are shown by default.
-
showActivityIndicatorAndDisableInteraction
void showActivityIndicatorAndDisableInteraction()
Call this method to show an activity indicator and disable user interaction. The camera preview remains visible.
-
hideActivityIndicatorAndEnableInteraction
void hideActivityIndicatorAndEnableInteraction()
Call this method to hide the activity indicator and enable user interaction.
-
showError
void showError(@NonNull() String message, int duration)
Call this method to show an error message to the user in the Camera Screen.
- Parameters:
message- a short error messageduration- how long should the error message be shown in ms
-
showAlertDialog
void showAlertDialog(@NonNull() String message, @NonNull() String positiveButtonTitle, @NonNull() DialogInterface.OnClickListener positiveButtonClickListener, @Nullable() String negativeButtonTitle, @Nullable() DialogInterface.OnClickListener negativeButtonClickListener, @Nullable() DialogInterface.OnCancelListener cancelListener)
-
-
-
-