public class ReviewActivity extends AppCompatActivity implements ReviewFragmentListener, ReviewFragmentInterface
ReviewActivity
displays the photographed or imported
image and allows the user to review it by checking the sharpness, quality and orientation of
the image. The user can correct the orientation by rotating the image.
Extending the ReviewActivity
in your application has been deprecated. The preferred
way of adding network calls to the Gini Vision Library is by creating a GiniVision
instance with a GiniVisionNetworkService
and a GiniVisionNetworkApi
implementation.
Note: When declaring your ReviewActivity
subclass in the AndroidManifest.xml
you should set the theme to the GiniVisionTheme
and the title to the
string resource named gv_title_review
. If you would like to use your own theme please
consider that ReviewActivity
extends AppCompatActivity
and requires an AppCompat
Theme.
The ReviewActivity
is started by the CameraActivity
after the user has taken
a photo or imported an image of a document.
If you didn't create GiniVision
instance you have to implement the following methods
in your ReviewActivity
subclass:
ReviewActivity.onShouldAnalyzeDocument(Document)
- you should start analyzing the
original document by sending it to the Gini API. We assume that in most cases the photo is good
enough and this way we are able to provide analysis results quicker.ReviewActivity.onDocumentAnalyzed()
when the analysis is done and the Activity wasn't stopped.
ReviewActivity.onAddDataToResult(Intent)
- you can add the results of the analysis to
the Intent as extras and retrieve them once the CameraActivity
returns.ReviewActivity.onDocumentAnalyzed()
and the image wasn't
changed before the user tapped on the Next button.AnalysisActivity
subclass is not launched, instead control is returned to your Activity which
started the CameraActivity
and you can extract the results of the analysis.
GiniVision
instance:
ReviewActivity.onDocumentWasRotated(Document, int, int)
- you should cancel the
analysis started in ReviewActivity.onShouldAnalyzeDocument(Document)
because the document
was rotated and analysing the original is not necessary anymore. The Gini Vision Library will
proceed to the Analysis Screen where the reviewed document can be analyzed.
ReviewActivity.onProceedToAnalysisScreen(Document)
- called when the Gini Vision
Library will continue to the Analysis Screen. For example you can unsubscribe your analysis
listener, if you want to continue the analysis in your AnalysisActivity
subclass in case
the document wasn't modified.
ReviewActivity.onBackPressed()
- called when the back or the up button was clicked.
You should cancel the analysis started in ReviewActivity.onShouldAnalyzeDocument(Document)
.
The following items are customizable:
gv_review_button_rotate.png
gv_review_fab_mini
and
gv_review_fab_mini_pressed
gv_review_fab_next.png
gv_review_fab
and gv_review_fab_pressed
gv_review_bottom_panel_text
gv_review_bottom_panel_text
GiniVisionTheme.Review.BottomPanel.TextStyle
and setting an item named gvCustomFont
with
the path to the font file in your assets
folder
GiniVisionTheme.Review.BottomPanel.TextStyle
and setting an item named android:textStyle
to normal
, bold
or italic
GiniVisionTheme.Review.BottomPanel.TextStyle
and setting an item named android:textSize
to the desired sp
size
gv_review_bottom_panel_background
gv_background
. Note:
this color resource is global to all Activities (CameraActivity
, OnboardingActivity
, ReviewActivity
, AnalysisActivity
)
Important: All overridden styles must have their respective Root.
prefixed
style as their parent. Ex.: the parent of GiniVisionTheme.Review.BottomPanel.TextStyle
must be Root.GiniVisionTheme.Review.BottomPanel.TextStyle
.
CameraActivity
, OnboardingActivity
, ReviewActivity
, AnalysisActivity
).
The following items are customizable:
gv_action_bar
(highly
recommended for Android 5+: customize the status bar color via gv_status_bar
)
AndroidManifest.xml
when
declaring your Activity that extends ReviewActivity
. The default title string resource is
named gv_title_review
gv_action_bar_title
gv_action_bar_back
Constructor and Description |
---|
ReviewActivity() |
Modifier and Type | Method and Description |
---|---|
void |
onAddDataToResult(Intent result)
Deprecated.
When a
GiniVision instance is available the document is analyzed
internally by using the configured GiniVisionNetworkService implementation. The
extractions will be returned in the extra called CameraActivity.EXTRA_OUT_EXTRACTIONS
of the CameraActivity 's result Intent. |
void |
onBackPressed() |
void |
onDocumentAnalyzed()
Deprecated.
When a
GiniVision instance is available the document is analyzed
internally by using the configured GiniVisionNetworkService implementation. The
extractions will be returned in the extra called CameraActivity.EXTRA_OUT_EXTRACTIONS
of the CameraActivity 's result Intent. |
void |
onDocumentReviewedAndAnalyzed(Document document)
Called if you called
ReviewFragmentStandard.onDocumentAnalyzed() or ReviewFragmentCompat.onDocumentAnalyzed() and the image wasn't changed and the user tapped
on the Next button. |
void |
onDocumentWasRotated(Document document,
int oldRotation,
int newRotation)
Deprecated.
When a
GiniVision and a GiniVisionNetworkService instance is
available rotation is handled internally. The document is analyzed by using the configured
GiniVisionNetworkService implementation. The extractions will be returned in the
Analysis Screen in AnalysisFragmentListener#onExtractionsAvailable(Map, Map) . |
void |
onError(GiniVisionError error)
Called when an error occurred.
|
void |
onExtractionsAvailable(java.util.Map extractions)
Called when the document has been analyzed and extractions are available.
|
void |
onNoExtractionsFound()
Deprecated.
When a
GiniVision instance is available the document is analyzed
internally by using the configured GiniVisionNetworkService implementation. |
boolean |
onOptionsItemSelected(MenuItem item) |
void |
onProceedToAnalysisScreen(Document document)
Called if you didn't call
ReviewFragmentStandard.onDocumentAnalyzed() or ReviewFragmentCompat.onDocumentAnalyzed() (or the image was changed) and the user tapped on
the Next button. |
void |
onProceedToAnalysisScreen(Document document,
java.lang.String errorMessage)
Called when the user tapped on the Next button and one of the following conditions apply:
Analysis is in progress Analysis completed with an error The image was
rotated
|
void |
onProceedToNoExtractionsScreen(Document document)
Called when the document has been analyzed and no extractions were received.
|
void |
onShouldAnalyzeDocument(Document document)
Deprecated.
When a
GiniVision instance is available the document is analyzed
internally by using the configured GiniVisionNetworkService implementation. The
extractions will be returned in the extra called CameraActivity.EXTRA_OUT_EXTRACTIONS
of the CameraActivity 's result Intent. |
void |
setListener(ReviewFragmentListener listener)
Set a listener for review events.
|
public boolean onOptionsItemSelected(MenuItem item)
public void onBackPressed()
@Deprecated public void onShouldAnalyzeDocument(Document document)
GiniVision
instance is available the document is analyzed
internally by using the configured GiniVisionNetworkService
implementation. The
extractions will be returned in the extra called CameraActivity.EXTRA_OUT_EXTRACTIONS
of the CameraActivity
's result Intent.ReviewFragmentListener
We assume that in most cases the photo is good enough and this way we are able to provide analysis results quicker.
Note: Call ReviewFragmentStandard.onDocumentAnalyzed()
or ReviewFragmentCompat.onDocumentAnalyzed()
when the analysis is done and your Activity wasn't
stopped.
onShouldAnalyzeDocument
in interface ReviewFragmentListener
document
- contains the original image taken by the camerapublic void onProceedToAnalysisScreen(Document document)
ReviewFragmentListener
ReviewFragmentStandard.onDocumentAnalyzed()
or ReviewFragmentCompat.onDocumentAnalyzed()
(or the image was changed) and the user tapped on
the Next button.
You should start your Activity extending AnalysisActivity
and set the document as
the AnalysisActivity.EXTRA_IN_DOCUMENT
extra.
onProceedToAnalysisScreen
in interface ReviewFragmentListener
document
- contains the reviewed image (can be the original one or a modified image)public void onProceedToAnalysisScreen(Document document, java.lang.String errorMessage)
ReviewFragmentListener
You should start your Activity extending AnalysisActivity
and set the document as
the AnalysisActivity.EXTRA_IN_DOCUMENT
extra.
onProceedToAnalysisScreen
in interface ReviewFragmentListener
document
- contains the reviewed image (can be the original one or a modified
image)errorMessage
- an optional error message to be passed to the Analysis Screenpublic void onDocumentReviewedAndAnalyzed(Document document)
ReviewFragmentListener
ReviewFragmentStandard.onDocumentAnalyzed()
or ReviewFragmentCompat.onDocumentAnalyzed()
and the image wasn't changed and the user tapped
on the Next button.
You should finish your Activity and proceed to handling the results of the analysis.
onDocumentReviewedAndAnalyzed
in interface ReviewFragmentListener
document
- contains the reviewed image (can be the original one or a modified image)@Deprecated public void onAddDataToResult(Intent result)
GiniVision
instance is available the document is analyzed
internally by using the configured GiniVisionNetworkService
implementation. The
extractions will be returned in the extra called CameraActivity.EXTRA_OUT_EXTRACTIONS
of the CameraActivity
's result Intent.Callback for adding your own data to the Activity's result.
Called when the document has been analyzed and wasn't modified at the time the user tapped on the Next button.
You should add the results of the analysis as extras and retrieve them when
the CameraActivity
returns.
Note: you should call ReviewActivity.onDocumentAnalyzed()
after you've received the analysis results from the Gini
API, otherwise this method won't be invoked.
result
- the Intent
which will be returned as the result data.public void onDocumentWasRotated(Document document, int oldRotation, int newRotation)
GiniVision
and a GiniVisionNetworkService
instance is
available rotation is handled internally. The document is analyzed by using the configured
GiniVisionNetworkService
implementation. The extractions will be returned in the
Analysis Screen in AnalysisFragmentListener#onExtractionsAvailable(Map, Map)
.Called when the user rotated the image.
In case you started the document
analysis in ReviewFragmentListener.onShouldAnalyzeDocument(Document)
you should
cancel it here as the original image is not valid anymore.
onDocumentWasRotated
in interface ReviewFragmentListener
document
- contains the modified imageoldRotation
- the previous rotation in degreesnewRotation
- the new rotation in degrees@Deprecated public void onDocumentAnalyzed()
GiniVision
instance is available the document is analyzed
internally by using the configured GiniVisionNetworkService
implementation. The
extractions will be returned in the extra called CameraActivity.EXTRA_OUT_EXTRACTIONS
of the CameraActivity
's result Intent.ReviewFragmentInterface
This is important for managing the behavior of the Review Document Fragment when the Next button was clicked.
If the document has already been analyzed and the image wasn't changed when the user
tapped the Next button, ReviewFragmentListener.onDocumentReviewedAndAnalyzed(Document)
is called and there is no need to show an AnalysisActivity
or AnalysisFragmentStandard
or AnalysisFragmentCompat
.
If the document wasn't analyzed or the image was changed when the user tapped the Next
button, ReviewFragmentListener.onProceedToAnalysisScreen(Document)
is called.
onDocumentAnalyzed
in interface ReviewFragmentInterface
@Deprecated public void onNoExtractionsFound()
GiniVision
instance is available the document is analyzed
internally by using the configured GiniVisionNetworkService
implementation.ReviewFragmentInterface
onNoExtractionsFound
in interface ReviewFragmentInterface
public void onError(GiniVisionError error)
ReviewFragmentListener
onError
in interface ReviewFragmentListener
error
- details about what went wrongpublic void setListener(ReviewFragmentListener listener)
ReviewFragmentInterface
By default the hosting Activity is expected to implement the ReviewFragmentListener
. 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 ReviewFragmentInterface
listener
- ReviewFragmentListener
instancepublic void onExtractionsAvailable(java.util.Map extractions)
ReviewFragmentListener
onExtractionsAvailable
in interface ReviewFragmentListener
extractions
- a map of the extractions with the extraction labels as keyspublic void onProceedToNoExtractionsScreen(Document document)
ReviewFragmentListener
You should show the NoResultsFragmentStandard
or NoResultsFragmentCompat
.
onProceedToNoExtractionsScreen
in interface ReviewFragmentListener
document
- contains the reviewed document