Package net.gini.android.vision.analysis

Contains the Activity and Fragments used for the Analysis Screen.

Screen API

Extending the AnalysisActivity 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.analysis.AnalysisActivity extends androidx.appcompat.app.AppCompatActivity, therefore you have to use *an AppCompat theme for your net.gini.android.vision.analysis.AnalysisActivity subclass.

Component API

To use the Component API you have to include the net.gini.android.vision.analysis.AnalysisFragmentStandard or the net.gini.android.vision.analysis.AnalysisFragmentCompat 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.analysis.AnalysisFragmentListener interface.

Types

AnalysisActivity
Link copied to clipboard

Screen API

When you use the Screen API, the {@code AnalysisActivity} displays the captured or imported document and an activity indicator while the document is being analyzed by the Gini API.

Note: The title from the ActionBar was removed. Use the activity indicator message instead by overriding the string resource named {@code gv_analysis_activity_indicator_message} . The message is displayed for images only.

For PDF documents the first page is shown (only on Android 5.0 Lollipop and newer) along with the PDF's filename and number of pages above the page. On Android KitKat and older only the PDF's filename is shown with the preview area left empty.

Extending the {@code AnalysisActivity} 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 and a GiniVisionNetworkApi implementation.

Note: When declaring your {@code AnalysisActivity} subclass in the {@code * AndroidManifest.xml} you should set the theme to the {@code GiniVisionTheme} . If you would like to use your own theme please consider that {@code AnalysisActivity} extends AppCompatActivity and requires an AppCompat Theme.

The {@code AnalysisActivity} is started by the CameraActivity after the user has reviewed the document and either made no changes to the document and it hasn't been analyzed before tapping the Next button, or the user has modified the document, e.g. by rotating it.

For imported documents that cannot be reviewed, like PDFs, the CameraActivity starts the {@code AnalysisActivity} directly.

If you didn't create GiniVision instance you have to implement the following methods in your {@code AnalysisActivity} subclass:

  • onAnalyzeDocument - start analyzing the document by sending it to the Gini API.Note: Call onDocumentAnalyzed when the analysis is done and the Activity hasn't been stopped.Note: If an analysis error message was set in the Review Screen with this method won't be called until the user clicks the retry button next to the error message.
  • onAddDataToResult - you should 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 before.When this is called, control is returned to your Activity which started the and you can extract the results of the analysis.

You can also override the following method:

  • - called when the back or the up button was clicked.
Customizing the Analysis Screen Customizing the look of the Analysis Screen is done via overriding of app resources.

The following items are customizable:

  • Activity indicator color: via the color resource named {@code * gv_analysis_activity_indicator}
  • Activity indicator message: via the string resource named {@code * gv_analysis_activity_indicator_message}
  • Activity indicator message text style: via overriding the style named {@code * GiniVisionTheme.Analysis.AnalysingMessage.TextStyle}
  • Activity indicator message font: via overriding the style named {@code * GiniVisionTheme.Analysis.AnalysingMessage.TextStyle} and setting an item named {@code gvCustomFont} with the path to the font file in your {@code assets} folder
  • PDF info panel background: via the color resource named {@code * gv_analysis_pdf_info_background}
  • PDF filename text style: via overriding the style named {@code * GiniVisionTheme.Analysis.PdfFilename.TextStyle} and setting an item named {@code android:textStyle} to {@code normal} , {@code bold} or {@code italic}
  • PDF filename text size: via overriding the style named {@code * GiniVisionTheme.Analysis.PdfFilename.TextStyle} and setting an item named {@code autoSizeMaxTextSize} and {@code autoSizeMinTextSize} to the desired maximum and minimum {@code sp} sizes
  • PDF filename text color: via the color resource named {@code * gv_analysis_pdf_info_text}
  • PDF filename font: via overriding the style named {@code * GiniVisionTheme.Analysis.PdfFilename.TextStyle} and setting an item named {@code gvCustomFont} with the path to the font file in your {@code assets} folder
  • PDF page count text style: via overriding the style named {@code * GiniVisionTheme.Analysis.PdfPageCount.TextStyle} and setting an item named {@code android:textStyle} to {@code normal} , {@code bold} or {@code italic}
  • PDF page count text size: via overriding the style named {@code * GiniVisionTheme.Analysis.PdfPageCount.TextStyle} and setting an item named {@code android:textSize} to the desired {@code sp} size
  • PDF page count text color: via the color resource named {@code * gv_analysis_pdf_info_text}
  • PDF page count font: via overriding the style named {@code * GiniVisionTheme.Analysis.PdfPageCount.TextStyle} and setting an item named {@code gvCustomFont} with the path to the font file in your {@code assets} folder
  • Background color: via the color resource named {@code gv_background} . Note: this color resource is global to all Activities ( CameraActivity , OnboardingActivity , ReviewActivity , )
  • Error message text color: via the color resource named {@code * gv_snackbar_error_text}
  • Error message font: via overriding the style named {@code * GiniVisionTheme.Snackbar.Error.TextStyle} and setting an item named {@code gvCustomFont} with the path to the font file in your {@code * assets} folder
  • Error message text style: via overriding the style named {@code * GiniVisionTheme.Snackbar.Error.TextStyle} and setting an item named {@code android:textStyle} to {@code normal} , {@code bold} or {@code * italic}
  • Error message text size: via overriding the style named {@code * GiniVisionTheme.Snackbar.Error.TextStyle} and setting an item named {@code android:textSize} to the desired {@code sp} size
  • Error message button text color: via the color resource named {@code * gv_snackbar_error_button_title} and {@code gv_snackbar_error_button_title_pressed}
  • Error message button font: via overriding the style named {@code * GiniVisionTheme.Snackbar.Error.Button.TextStyle} and setting an item named {@code gvCustomFont} with the path to the font file in your {@code assets} folder
  • Error message button text style: via overriding the style named {@code * GiniVisionTheme.Snackbar.Error.Button.TextStyle} and setting an item named {@code android:textStyle} to {@code normal} , {@code bold} or {@code italic}
  • Error message button text size: via overriding the style named {@code * GiniVisionTheme.Snackbar.Error.Button.TextStyle} and setting an item named {@code android:textSize} to the desired {@code sp} size
  • Error message background color: via the color resource named {@code * gv_snackbar_error_background}
  • Document analysis error message retry button text: via the string resource named {@code gv_document_analysis_error_retry}

Important: All overriden styles must have their respective {@code Root.} prefixed style as their parent. Ex.: the parent of {@code GiniVisionTheme.Snackbar.Error.TextStyle} must be {@code * Root.GiniVisionTheme.Snackbar.Error.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 , OnboardingActivity , ReviewActivity , net.gini.android.vision.review.multipage.MultiPageReviewActivity , 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} )
  • Back button (only for ReviewActivity and AnalysisActivity ): via images for mdpi, hdpi, xhdpi, xxhdpi, xxxhdpi named {@code gv_action_bar_back}

public class AnalysisActivity extends AppCompatActivity implements AnalysisFragmentListener, AnalysisFragmentInterface
AnalysisFragmentCompat
Link copied to clipboard

Component API

When you use the Component API with the Android Support Library, the {@code * AnalyzeDocumentFragmentCompat} displays the captured or imported document and an activity indicator while the document is being analyzed by the Gini API.

Note: You can use the activity indicator message to display a message under the activity indicator by overriding the string resource named {@code gv_analysis_activity_indicator_message} . The message is displayed for images only.

For PDF documents the first page is shown (only on Android 5.0 Lollipop and newer) along with the PDF's filename and number of pages above the page. On Android KitKat and older only the PDF's filename is shown with the preview area left empty.

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

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

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

Your Activity is automatically set as the listener in onCreate .

Customizing the Analysis Screen

See the AnalysisActivity for details.

public class AnalysisFragmentCompat extends Fragment implements FragmentImplCallback, AnalysisFragmentInterface
AnalysisFragmentHelper
Link copied to clipboard
final class AnalysisFragmentHelper
AnalysisFragmentImpl
Link copied to clipboard
class AnalysisFragmentImpl extends AnalysisScreenContract.View
AnalysisFragmentInterface
Link copied to clipboard

Methods which both Analysis Fragments must implement.

public interface AnalysisFragmentInterface
AnalysisFragmentListener
Link copied to clipboard

Interface used by AnalysisFragmentStandard and AnalysisFragmentCompat to dispatch events to the hosting Activity.

public interface AnalysisFragmentListener
AnalysisFragmentStandard
Link copied to clipboard

Component API

When you use the Component API without the Android Support Library, the {@code AnalyzeDocumentFragmentStandard} displays the captured or imported document and an activity indicator while the document is being analyzed by the Gini API.

Note: You can use the activity indicator message to display a message under the activity indicator by overriding the string resource named {@code gv_analysis_activity_indicator_message} . The message is displayed for images only.

For PDF documents the first page is shown (only on Android 5.0 Lollipop and newer) along with the PDF's filename and number of pages above the page. On Android KitKat and older only the PDF's filename is shown with the preview area left empty.

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

An AnalysisFragmentListener instance must be available until the {@code AnalysisFragmentStandard} 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 AnalysisFragmentListener interface or explicitly by setting the listener using setListener .

Your Activity is automatically set as the listener in onCreate .

Customizing the Analysis Screen

See the AnalysisActivity for details.

public class AnalysisFragmentStandard extends Fragment implements FragmentImplCallback, AnalysisFragmentInterface
AnalysisHint
Link copied to clipboard
enum AnalysisHint
AnalysisHintsAnimator
Link copied to clipboard

Created by Alpar Szotyori on 09.05.2019. Copyright (c) 2019 Gini GmbH.

class AnalysisHintsAnimator
AnalysisInteractor
Link copied to clipboard

Internal use only.

public class AnalysisInteractor
AnalysisScreenContract
Link copied to clipboard

Created by Alpar Szotyori on 08.05.2019. Copyright (c) 2019 Gini GmbH.

interface AnalysisScreenContract
AnalysisScreenPresenter
Link copied to clipboard

Created by Alpar Szotyori on 08.05.2019. Copyright (c) 2019 Gini GmbH.

class AnalysisScreenPresenter extends AnalysisScreenContract.Presenter