Package 

Class AnalysisActivity

  • All Implemented Interfaces:
    android.content.ComponentCallbacks , android.content.ComponentCallbacks2 , android.view.KeyEvent.Callback , android.view.LayoutInflater.Factory , android.view.LayoutInflater.Factory2 , android.view.View.OnCreateContextMenuListener , android.view.Window.Callback , androidx.activity.OnBackPressedDispatcherOwner , androidx.activity.contextaware.ContextAware , androidx.activity.result.ActivityResultCaller , androidx.activity.result.ActivityResultRegistryOwner , androidx.appcompat.app.ActionBarDrawerToggle.DelegateProvider , androidx.appcompat.app.AppCompatCallback , androidx.core.app.ActivityCompat.OnRequestPermissionsResultCallback , androidx.core.app.ActivityCompat.RequestPermissionsRequestCodeValidator , androidx.core.app.OnMultiWindowModeChangedProvider , androidx.core.app.OnNewIntentProvider , androidx.core.app.OnPictureInPictureModeChangedProvider , androidx.core.app.TaskStackBuilder.SupportParentable , androidx.core.content.OnConfigurationChangedProvider , androidx.core.content.OnTrimMemoryProvider , androidx.core.view.KeyEventDispatcher.Component , androidx.core.view.MenuHost , androidx.lifecycle.HasDefaultViewModelProviderFactory , androidx.lifecycle.LifecycleOwner , androidx.lifecycle.ViewModelStoreOwner , androidx.savedstate.SavedStateRegistryOwner , net.gini.android.capture.analysis.AnalysisFragmentInterface , net.gini.android.capture.analysis.AnalysisFragmentListener

    
    public class AnalysisActivity
    extends AppCompatActivity implements AnalysisFragmentListener, AnalysisFragmentInterface
                        

    When you use the Screen API, the 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 gc_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.

    The preferred way of adding network calls to the Gini Capture SDK is by creating a GiniCapture instance with a and a GiniCaptureNetworkApi implementation.

    The 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 AnalysisActivity directly.

    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 gc_analysis_activity_indicator
    • Activity indicator message: via the string resource named gc_analysis_activity_indicator_message
    • Activity indicator message text style: via overriding the style named GiniCaptureTheme.Analysis.AnalysingMessage.TextStyle
    • Activity indicator message font: via overriding the style named GiniCaptureTheme.Analysis.AnalysingMessage.TextStyle and setting an item named gcCustomFont with the path to the font file in your assets folder
    • PDF info panel background: via the color resource named gc_analysis_pdf_info_background
    • PDF filename text style: via overriding the style named GiniCaptureTheme.Analysis.PdfFilename.TextStyle and setting an item named android:textStyle to normal, bold or italic
    • PDF filename text size: via overriding the style named GiniCaptureTheme.Analysis.PdfFilename.TextStyle and setting an item named autoSizeMaxTextSize and autoSizeMinTextSize to the desired maximum and minimum sp sizes
    • PDF filename text color: via the color resource named gc_analysis_pdf_info_text
    • PDF filename font: via overriding the style named GiniCaptureTheme.Analysis.PdfFilename.TextStyle and setting an item named gcCustomFont with the path to the font file in your assets folder
    • PDF page count text style: via overriding the style named GiniCaptureTheme.Analysis.PdfPageCount.TextStyle and setting an item named android:textStyle to normal, bold or italic
    • PDF page count text size: via overriding the style named GiniCaptureTheme.Analysis.PdfPageCount.TextStyle and setting an item named android:textSize to the desired sp size
    • PDF page count text color: via the color resource named gc_analysis_pdf_info_text
    • PDF page count font: via overriding the style named GiniCaptureTheme.Analysis.PdfPageCount.TextStyle and setting an item named gcCustomFont with the path to the font file in your assets folder
    • Background color: via the color resource named gc_background. Note: this color resource is global to all Activities (CameraActivity, OnboardingActivity, ReviewActivity, )
    • Error message text color: via the color resource named gc_snackbar_error_text
    • Error message font: via overriding the style named GiniCaptureTheme.Snackbar.Error.TextStyle and setting an item named gcCustomFont with the path to the font file in your assets folder
    • Error message text style: via overriding the style named GiniCaptureTheme.Snackbar.Error.TextStyle and setting an item named android:textStyle to normal, bold or italic
    • Error message text size: via overriding the style named GiniCaptureTheme.Snackbar.Error.TextStyle and setting an item named android:textSize to the desired sp size
    • Error message button text color: via the color resource named gc_snackbar_error_button_title and gc_snackbar_error_button_title_pressed
    • Error message button font: via overriding the style named GiniCaptureTheme.Snackbar.Error.Button.TextStyle and setting an item named gcCustomFont with the path to the font file in your assets folder
    • Error message button text style: via overriding the style named GiniCaptureTheme.Snackbar.Error.Button.TextStyle and setting an item named android:textStyle to normal, bold or italic
    • Error message button text size: via overriding the style named GiniCaptureTheme.Snackbar.Error.Button.TextStyle and setting an item named android:textSize to the desired sp size
    • Error message background color: via the color resource named gc_snackbar_error_background
    • Document analysis error message retry button text: via the string resource named gc_document_analysis_error_retry

    Important: All overriden styles must have their respective Root. prefixed style as their parent. Ex.: the parent of GiniCaptureTheme.Snackbar.Error.TextStyle must be Root.GiniCaptureTheme.Snackbar.Error.TextStyle.

    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.capture.review.multipage.MultiPageReviewActivity, AnalysisActivity).

    The following items are customizable:

    • Background color: via the color resource named gc_action_bar (highly recommended for Android 5+: customize the status bar color via gc_status_bar)
    • Back button (only for ReviewActivity and AnalysisActivity): via images for mdpi, hdpi, xhdpi, xxhdpi, xxxhdpi named gc_action_bar_back
    • Constructor Detail

    • Method Detail

      • showError

         void showError(@NonNull() String message, @NonNull() String buttonTitle, @NonNull() View.OnClickListener onClickListener)

        Call this method when you need to show an error message with an invokable action to the user in the Analysis Screen.

        Parameters:
        message - a short error message
        buttonTitle - if not null and not empty, shows a button with the given title
        onClickListener - listener for the button
      • showError

         void showError(@NonNull() String message, int duration)

        Call this method when you need to show an error message to the user in the Analysis Screen.

        Parameters:
        message - a short error message
        duration - how long should the error message be shown in ms
      • setListener

         void setListener(@NonNull() AnalysisFragmentListener listener)

        Set a listener for analysis events.

        By default the hosting Activity is expected to implement the AnalysisFragmentListener. 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.

        Parameters:
        listener - AnalysisFragmentListener instance
      • onDefaultPDFAppAlertDialogCancelled

         void onDefaultPDFAppAlertDialogCancelled()

        Called when the default PDF app alert dialog was cancelled. You should close the AnalysisFragment because the user decided not to continue with analysis.

        This alert dialog is shown for PDFs imported from another app when your app was set as default for opening PDFs.