Package net.gini.android.vision.review

Contains the Activity and Fragments used for the Review Screen.

Screen API

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 net.gini.android.vision.GiniVision instance with a net.gini.android.vision.network.GiniVisionNetworkService and a net.gini.android.vision.network.GiniVisionNetworkApi implementation.

Note:net.gini.android.vision.review.ReviewActivity extends androidx.appcompat.app.AppCompatActivity, therefore you have to use an AppCompat theme for your net.gini.android.vision.review.ReviewActivity subclass.

Component API

To use the Component API you have to include the net.gini.android.vision.review.ReviewFragmentStandard or the net.gini.android.vision.review.ReviewFragmentCompat in an Activity in your app (a dedicated Activity is recommended). To receive events from the Fragments your Activity must implement the net.gini.android.vision.review.ReviewFragmentListener interface.

Types

ReviewActivity
Link copied to clipboard

Screen API When you use the Screen API, the {@code 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 {@code 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 {@code ReviewActivity} subclass in the {@code * AndroidManifest.xml} you should set the theme to the {@code GiniVisionTheme} and the title to the string resource named {@code gv_title_review} . If you would like to use your own theme please consider that {@code ReviewActivity} extends AppCompatActivity and requires an AppCompat Theme.

The {@code 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 {@code ReviewActivity} subclass:

  • onShouldAnalyzeDocument - 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.Note: Call when the analysis is done and the Activity wasn't stopped.
  • onAddDataToResult - you can add the results of the analysis to the Intent as extras and retrieve them once the CameraActivity returns.This is called only if you called onDocumentAnalyzed and the image wasn't changed before the user tapped on the Next button.When this is called, your subclass is not launched, instead control is returned to your Activity which started the CameraActivity and you can extract the results of the analysis.
You can also override the following methods, if you didn't create a GiniVision instance:
  • onDocumentWasRotated - you should cancel the analysis started in onShouldAnalyzeDocument 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.
  • onProceedToAnalysisScreen - 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.
  • - called when the back or the up button was clicked. You should cancel the analysis started in onShouldAnalyzeDocument .
Customizing the Review Screen Customizing the look of the Review Screen is done via overriding of app resources.

The following items are customizable:

  • Rotate button icon: via images for mdpi, hdpi, xhdpi, xxhdpi, xxxhdpi named {@code * gv_review_button_rotate.png}
  • Rotate button color: via the color resources named {@code gv_review_fab_mini} and {@code gv_review_fab_mini_pressed}
  • Next button icon: via images for mdpi, hdpi, xhdpi, xxhdpi, xxxhdpi named {@code * gv_review_fab_next.png}
  • Next button color: via the color resources named {@code gv_review_fab} and {@code * gv_review_fab_pressed}
  • Bottom advice text: via the string resource named {@code gv_review_bottom_panel_text}
  • Bottom text color: via the color resource named {@code gv_review_bottom_panel_text}
  • Bottom text font: via overriding the style named {@code * GiniVisionTheme.Review.BottomPanel.TextStyle} and setting an item named {@code gvCustomFont} with the path to the font file in your {@code assets} folder
  • Bottom text style: via overriding the style named {@code * GiniVisionTheme.Review.BottomPanel.TextStyle} and setting an item named {@code android:textStyle} to {@code normal} , {@code bold} or {@code italic}
  • Bottom text size: via overriding the style named {@code * GiniVisionTheme.Review.BottomPanel.TextStyle} and setting an item named {@code android:textSize} to the desired {@code sp} size
  • Bottom panel background color: via the color resource named {@code * gv_review_bottom_panel_background}
  • Background color: via the color resource named {@code gv_background} . Note: this color resource is global to all Activities ( CameraActivity , , ReviewActivity , AnalysisActivity )

Important: All overridden styles must have their respective {@code Root.} prefixed style as their parent. Ex.: the parent of {@code GiniVisionTheme.Review.BottomPanel.TextStyle} must be {@code Root.GiniVisionTheme.Review.BottomPanel.TextStyle} .

Customizing the Action Bar Customizing the Action Bar is also done via overriding of app resources and each one - except the title string resource - is global to all Activities ( CameraActivity , , ReviewActivity , AnalysisActivity ).

The following items are customizable:

  • Background color: via the color resource named {@code gv_action_bar} (highly recommended for Android 5+: customize the status bar color via {@code gv_status_bar} )
  • Title: via the string resource you set in your {@code AndroidManifest.xml} when declaring your Activity that extends ReviewActivity . The default title string resource is named {@code gv_title_review}
  • Title color: via the color resource named {@code gv_action_bar_title}
  • Back button: via images for mdpi, hdpi, xhdpi, xxhdpi, xxxhdpi named {@code gv_action_bar_back}

public class ReviewActivity extends AppCompatActivity implements ReviewFragmentListener, ReviewFragmentInterface
ReviewFragmentCompat
Link copied to clipboard

Component API

When you use the Compontent API with the Android Support Library, the {@code * ReviewFragmentCompat} 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.

Note: Your Activity hosting this Fragment must extend the and use an AppCompat Theme.

Include the {@code ReviewFragmentCompat} into your layout by using the factory method to create an instance and display it using the androidx.fragment.app.FragmentManager .

A ReviewFragmentListener instance must be available until the {@code * ReviewFragmentCompat} 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 ReviewFragmentListener interface or explicitly by setting the listener using .

Your Activity is automatically set as the listener in onCreate .

Customizing the Review Screen See the ReviewActivity for details.

public class ReviewFragmentCompat extends Fragment implements FragmentImplCallback, ReviewFragmentInterface
ReviewFragmentHelper
Link copied to clipboard

Internal use only.

final class ReviewFragmentHelper
ReviewFragmentImpl
Link copied to clipboard

Internal use only.

class ReviewFragmentImpl implements ReviewFragmentInterface
ReviewFragmentInterface
Link copied to clipboard

Methods which both Review Fragments must implement.

public interface ReviewFragmentInterface
ReviewFragmentListener
Link copied to clipboard

Interface used by ReviewFragmentStandard and ReviewFragmentCompat to dispatch events to the hosting Activity.

public interface ReviewFragmentListener
ReviewFragmentStandard
Link copied to clipboard

Component API

When you use the Compontent API without the Android Support Library, the {@code * ReviewFragmentStandard} 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.

Include the {@code ReviewFragmentStandard} into your layout by using the factory method to create an instance and display it using the android.app.FragmentManager .

A ReviewFragmentListener instance must be available until the {@code * ReviewFragmentStandard} 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 ReviewFragmentListener interface or explicitly by setting the listener using .

Your Activity is automatically set as the listener in onCreate .

Customizing the Review Screen See the ReviewActivity for details.

public class ReviewFragmentStandard extends Fragment implements FragmentImplCallback, ReviewFragmentInterface
RotatableImageViewContainer
Link copied to clipboard

Internal use only.

public class RotatableImageViewContainer extends FrameLayout
RotatableTouchImageViewContainer
Link copied to clipboard

Internal use only.

public class RotatableTouchImageViewContainer extends RotatableImageViewContainer