public class GiniVision
extends java.lang.Object
This singleton class is preferred over the previous methods of configuration and interaction. It is only mandatory for new features. You can continue using features from previous releases without any modification.
To create and configure a singleton instance use the GiniVision.newInstance()
method and the
returned GiniVision.Builder
. If an instance is already available you need to call GiniVision.cleanup(Context)
before creating a new instance. Failing to do so will throw an exception.
After you are done using the Gini Vision Library use the GiniVision.cleanup(Context)
method.
This will free up resources used by the library.
Modifier and Type | Class and Description |
---|---|
static class |
GiniVision.Builder
Builder for
GiniVision . |
Modifier and Type | Method and Description |
---|---|
boolean |
areBackButtonsEnabled()
Screen API only
|
static void |
cleanup(Context context)
Destroys the
GiniVision instance and frees up used resources. |
static Document |
createDocumentForImportedFile(Intent intent,
Context context)
Component API
|
CancellationToken |
createDocumentForImportedFiles(Intent intent,
Context context,
AsyncCallback callback)
Component API
|
static Intent |
createIntentForImportedFile(Intent intent,
Context context,
java.lang.Class reviewActivityClass,
java.lang.Class analysisActivityClass)
Screen API
|
CancellationToken |
createIntentForImportedFiles(Intent intent,
Context context,
AsyncCallback callback)
Screen API
|
java.util.ArrayList |
getCustomOnboardingPages()
The custom Onboarding Screen pages, if configured.
|
DocumentImportEnabledFileTypes |
getDocumentImportEnabledFileTypes()
Retrieve the file types enabled for document import.
|
GiniVisionNetworkApi |
getGiniVisionNetworkApi()
Retrieve the
GiniVisionNetworkApi instance, if available. |
static GiniVision |
getInstance()
Retrieve the current instance.
|
static boolean |
hasInstance()
Check whether an instance exists.
|
boolean |
isFileImportEnabled()
Find out whether file import has been enabled.
|
boolean |
isFlashButtonEnabled()
Find out whether the flash button on the Camera Screen has been enabled.
|
boolean |
isFlashOnByDefault()
Find out whether the camera flash is on or off by default.
|
boolean |
isMultiPageEnabled()
Find out whether scanning multi-page documents has been enabled.
|
boolean |
isQRCodeScanningEnabled()
Find out whether QRCode scanning has been enabled.
|
boolean |
isSupportedFormatsHelpScreenEnabled()
Find out whether the Supported Formats help screen has been enabled.
|
static GiniVision.Builder |
newInstance()
Configure and create a new instance using the returned
GiniVision.Builder . |
void |
setShouldShowOnboarding(boolean shouldShowOnboarding)
Screen API only
|
boolean |
shouldShowOnboarding()
Screen API only
|
boolean |
shouldShowOnboardingAtFirstRun()
Screen API only
|
public static GiniVision getInstance()
GiniVision
instancejava.lang.IllegalStateException
- when there is no instancepublic static boolean hasInstance()
true
if there is an instancepublic static GiniVision.Builder newInstance()
GiniVision.Builder
.GiniVision.Builder
java.lang.IllegalStateException
- when an instance already exists. Call GiniVision.cleanup(Context)
before trying to create a new instancepublic static void cleanup(Context context)
GiniVision
instance and frees up used resources.context
- Android contextpublic GiniVisionNetworkApi getGiniVisionNetworkApi()
GiniVisionNetworkApi
instance, if available.GiniVisionNetworkApi
instance or null
public DocumentImportEnabledFileTypes getDocumentImportEnabledFileTypes()
Disabled by default.
public boolean isFileImportEnabled()
Disabled by default.
true
if file import was enabledpublic boolean isQRCodeScanningEnabled()
Disabled by default.
true
if QRCode scanning was enabledpublic boolean isMultiPageEnabled()
Disabled by default
true
if multi-page is enabledpublic java.util.ArrayList getCustomOnboardingPages()
OnboardingPage
spublic boolean shouldShowOnboardingAtFirstRun()
If set to false
, the Onboarding Screen won't be shown on the first run.
public boolean shouldShowOnboarding()
If set to true
, the Onboarding Screen will be shown every every time the
CameraActivity starts.
Default value is false
.
You can change it on the existing GiniVision instance with GiniVision.setShouldShowOnboarding(boolean)
.
public void setShouldShowOnboarding(boolean shouldShowOnboarding)
Set to true
to show the Onboarding Screen every time the CameraActivity starts.
Default value is false
.
shouldShowOnboarding
- whether to show the onboarding on every launchpublic boolean isSupportedFormatsHelpScreenEnabled()
Enabled by default.
true
if the Supported Formats help screen was enabledpublic boolean isFlashButtonEnabled()
Disabled by default.
true
if the flash button was enabledpublic boolean areBackButtonsEnabled()
Find out whether back buttons in all Activities have been enabled.
ReviewActivity
and AnalysisActivity
are not affected and always show back
buttons.
Enabled by default.
true
if the back buttons were enabledpublic boolean isFlashOnByDefault()
If not changed, then flash is on by default.
true
if the flash is on by defaultpublic CancellationToken createIntentForImportedFiles(Intent intent, Context context, AsyncCallback callback)
If you have enabled the multi-page feature and your application receives one or multiple files from another application you can use this method to create an Intent for launching the Gini Vision Library.
Importing the files is executed on a secondary thread as it can take several seconds for the process to complete. The callback methods are invoked on the main thread.
In your callback's onSuccess(Intent)
method start the Intent with android.app.Activity#startActivityForResult(Intent, int)
to receive the extractions or a
GiniVisionError
in case there was an error.
intent
- the Intent your app receivedcontext
- Android contextcallback
- A AsyncCallback
implementationCancellationToken
for cancelling the import processpublic CancellationToken createDocumentForImportedFiles(Intent intent, Context context, AsyncCallback callback)
If you have enabled the multi-page feature and your application receives one or multiple
files from another application you can use this method to create a Document for launching the
Gini Vision Library's MultiPageReviewFragment
or one of the Analysis Fragments.
Importing the files is executed on a secondary thread as it can take several seconds for the process to complete. The callback methods are invoked on the main thread.
If the Document can be reviewed (Document.isReviewable()
) launch the MultiPageReviewFragment
.
If the Document cannot be reviewed you must launch one of the Analysis Fragments (AnalysisFragmentCompat
or AnalysisFragmentStandard
).
intent
- the Intent your app receivedcontext
- Android contextcallback
- A AsyncCallback
implementationCancellationToken
for cancelling the import processpublic static Intent createIntentForImportedFile(Intent intent, Context context, java.lang.Class reviewActivityClass, java.lang.Class analysisActivityClass) throws ImportedFileValidationException
When your application receives a file from another application you can use this method to create an Intent for launching the Gini Vision Library.
Start the Intent with android.app.Activity#startActivityForResult(Intent, int)
to
receive the extractions or a GiniVisionError
in case there was an error.
intent
- the Intent your app receivedcontext
- Android contextreviewActivityClass
- (optional) the class of your application's ReviewActivity
subclassanalysisActivityClass
- (optional) the class of your application's AnalysisActivity
subclassImportedFileValidationException
- if the file didn't pass validationjava.lang.IllegalArgumentException
- if the Intent's data is not valid or the mime type is
not supportedpublic static Document createDocumentForImportedFile(Intent intent, Context context) throws ImportedFileValidationException
When your application receives a file from another application you can use this method to create a Document for launching one of the Gini Vision Library's Review Fragments or Analysis Fragments.
If the Document can be reviewed (Document.isReviewable()
) launch one of the
Review Fragments (ReviewFragmentCompat
or ReviewFragmentStandard
).
If the Document cannot be reviewed you must launch one of the Analysis Fragments (AnalysisFragmentCompat
or AnalysisFragmentStandard
).
intent
- the Intent your app receivedcontext
- Android contextImportedFileValidationException
- if the file didn't pass validation