public class CameraFragmentCompat extends Fragment implements CameraFragmentInterface
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 CameraFragmentCompat.createInstance(GiniVisionFeatureConfiguration)
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 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 android.support.v7.app.AppCompatActivity and use an AppCompat Theme.
Include the CameraFragmentCompat into your layout either directly with <fragment>
in your Activity's layout or using the android.support.v4.app.FragmentManager and one of
the createInstance() methods.
A CameraFragmentListener instance must be available until the 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 CameraFragmentCompat.setListener(CameraFragmentListener).
Your Activity is automatically set as the listener in CameraFragmentCompat#onAttach(Context).
See the CameraActivity for details.
| Constructor and Description |
|---|
CameraFragmentCompat() |
| Modifier and Type | Method and Description |
|---|---|
static CameraFragmentCompat |
createInstance() |
static CameraFragmentCompat |
createInstance(GiniVisionFeatureConfiguration giniVisionFeatureConfiguration)
Factory method for creating a new instance of the Fragment with document import enabled for
the specified file types.
|
void |
hideActivityIndicatorAndEnableInteraction()
Call this method to hide the activity indicator and enable user interaction.
|
void |
hideCameraTriggerButton()
Deprecated.
|
void |
hideDocumentCornerGuides()
Deprecated.
|
void |
hideInterface()
Call this method to hide the interface elements.
|
void |
onActivityResult(int requestCode,
int resultCode,
Intent data) |
void |
setListener(CameraFragmentListener listener)
Set a listener for camera events.
|
void |
showActivityIndicatorAndDisableInteraction()
Call this method to show an activity indicator and disable user interaction.
|
void |
showAlertDialog(java.lang.String message,
java.lang.String positiveButtonTitle,
DialogInterface.OnClickListener positiveButtonClickListener,
java.lang.String negativeButtonTitle,
DialogInterface.OnClickListener negativeButtonClickListener,
DialogInterface.OnCancelListener cancelListener) |
void |
showCameraTriggerButton()
Deprecated.
|
void |
showDocumentCornerGuides()
Deprecated.
|
void |
showError(java.lang.String message,
int duration)
Call this method to show an error message to the user in the Camera Screen.
|
void |
showInterface()
Call this method to show the interface elements.
|
public static CameraFragmentCompat createInstance()
public static CameraFragmentCompat createInstance(GiniVisionFeatureConfiguration giniVisionFeatureConfiguration)
Factory method for creating a new instance of the Fragment with document import enabled for the specified file types.
giniVisionFeatureConfiguration - feature configurationpublic void onActivityResult(int requestCode,
int resultCode,
Intent data)
public void setListener(CameraFragmentListener listener)
CameraFragmentInterfaceSet 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.
setListener in interface CameraFragmentInterfacelistener - the CameraFragmentListener instance@Deprecated public void showDocumentCornerGuides()
CameraFragmentInterfaceCall this method to show the document corner guides.
Note: the document corner guides are shown by default.
showDocumentCornerGuides in interface CameraFragmentInterface@Deprecated public void hideDocumentCornerGuides()
CameraFragmentInterfaceCall this method to hide the document corner guides.
Note: the document corner guides are shown by default.
hideDocumentCornerGuides in interface CameraFragmentInterface@Deprecated public void showCameraTriggerButton()
CameraFragmentInterfaceCall this method to show the camera trigger button.
Note: the camera trigger button is shown by default.
showCameraTriggerButton in interface CameraFragmentInterface@Deprecated public void hideCameraTriggerButton()
CameraFragmentInterfaceCall this method to hide the camera trigger button.
Note: the camera trigger button is shown by default.
hideCameraTriggerButton in interface CameraFragmentInterfacepublic void showInterface()
CameraFragmentInterfaceCall this method to show the interface elements. The camera preview is always visible.
Note: the interface elements are shown by default.
showInterface in interface CameraFragmentInterfacepublic void hideInterface()
CameraFragmentInterfaceCall this method to hide the interface elements. The camera preview remains visible.
Note: the interface elements are shown by default.
hideInterface in interface CameraFragmentInterfacepublic void showActivityIndicatorAndDisableInteraction()
CameraFragmentInterfaceCall this method to show an activity indicator and disable user interaction. The camera preview remains visible.
showActivityIndicatorAndDisableInteraction in interface CameraFragmentInterfacepublic void hideActivityIndicatorAndEnableInteraction()
CameraFragmentInterfaceCall this method to hide the activity indicator and enable user interaction.
hideActivityIndicatorAndEnableInteraction in interface CameraFragmentInterfacepublic void showError(java.lang.String message,
int duration)
CameraFragmentInterfaceCall this method to show an error message to the user in the Camera Screen.
showError in interface CameraFragmentInterfacemessage - a short error messageduration - how long should the error message be shown in mspublic void showAlertDialog(java.lang.String message,
java.lang.String positiveButtonTitle,
DialogInterface.OnClickListener positiveButtonClickListener,
java.lang.String negativeButtonTitle,
DialogInterface.OnClickListener negativeButtonClickListener,
DialogInterface.OnCancelListener cancelListener)