public class CameraFragmentStandard extends Fragment implements CameraFragmentInterface
CameraFragmentStandard
is the main entry point to the Gini Vision Library when using the Component API without 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 CameraFragmentStandard.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.
Include the CameraFragmentStandard
into your layout either directly with <fragment>
in your Activity's layout or using the android.app.FragmentManager
and one of the createInstance()
methods.
A CameraFragmentListener
instance must be available until the CameraFragmentStandard
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 CameraFragmentStandard.onAttach(Context)
.
See the CameraActivity
for details.
Constructor and Description |
---|
CameraFragmentStandard() |
Modifier and Type | Method and Description |
---|---|
static CameraFragmentStandard |
createInstance() |
static CameraFragmentStandard |
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 CameraFragmentStandard createInstance()
public static CameraFragmentStandard 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)
CameraFragmentInterface
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.
setListener
in interface CameraFragmentInterface
listener
- the CameraFragmentListener
instance@Deprecated public void showDocumentCornerGuides()
CameraFragmentInterface
Call 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()
CameraFragmentInterface
Call 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()
CameraFragmentInterface
Call 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()
CameraFragmentInterface
Call this method to hide the camera trigger button.
Note: the camera trigger button is shown by default.
hideCameraTriggerButton
in interface CameraFragmentInterface
public void showInterface()
CameraFragmentInterface
Call this method to show the interface elements. The camera preview is always visible.
Note: the interface elements are shown by default.
showInterface
in interface CameraFragmentInterface
public void hideInterface()
CameraFragmentInterface
Call this method to hide the interface elements. The camera preview remains visible.
Note: the interface elements are shown by default.
hideInterface
in interface CameraFragmentInterface
public void showActivityIndicatorAndDisableInteraction()
CameraFragmentInterface
Call this method to show an activity indicator and disable user interaction. The camera preview remains visible.
showActivityIndicatorAndDisableInteraction
in interface CameraFragmentInterface
public void hideActivityIndicatorAndEnableInteraction()
CameraFragmentInterface
Call this method to hide the activity indicator and enable user interaction.
hideActivityIndicatorAndEnableInteraction
in interface CameraFragmentInterface
public void showError(java.lang.String message, int duration)
CameraFragmentInterface
Call this method to show an error message to the user in the Camera Screen.
showError
in interface CameraFragmentInterface
message
- 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)