Package 

Class CameraActivity

  • 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.camera.CameraFragmentInterface , net.gini.android.capture.camera.CameraFragmentListener

    
    public class CameraActivity
    extends AppCompatActivity implements CameraFragmentListener, CameraFragmentInterface
                        

    CameraActivity is the main entry point to the Gini Capture SDK when using the Screen API.

    It shows a camera preview with tap-to-focus functionality, a trigger button and an optional flash on/off button. The camera preview also shows document corner guides to which the user should align the document.

    On tablets in landscape orientation the camera trigger button is shown on the right side of the screen for easier access.

    If you enabled document import with setDocumentImportEnabledFileTypes then a button for importing documents is shown next to the trigger button. A hint popup is displayed the first time the Gini Capture SDK is used to inform the user about document importing.

    For importing documents READ_EXTERNAL_STORAGE permission is required and if the permission is not granted the Gini Capture SDK will prompt the user to grant the permission. See Customizing the Camera Screen on how to override the message and button titles for the rationale and on permission denial alerts.

    Start the CameraActivity with startActivityForResult to receive the extractions or a GiniCaptureError in case there was an error.

    The following result codes need to be handled:

    • RESULT_OK - image of a document was taken, reviewed and analyzed
    • RESULT_CANCELED - image of document was not taken, user canceled the Gini Capture SDK
    • RESULT_ERROR - an error occured

    Result extra returned by the CameraActivity:

    If the camera could not be opened due to missing permissions, the content of the Camera Screen is replaced with a no-camera icon, a short message and an optional button. The button is shown only on Android 6.0+ and tapping the button leads the user to the Application Details page in the Settings. If these are shown on Android 5.0 and earlier means that the camera permission was not declared in your manifest.

    Customizing the look of the Camera Screen is done via overriding of app resources.

    The following items are customizable:

    • Document corner guides: via the color resource named gc_camera_preview_corners
    • Camera trigger button: via images for mdpi, hdpi, xhdpi, xxhdpi, xxxhdpi named gc_camera_trigger_default.png and gc_camera_trigger_pressed.png
    • Document import button: via images for mdpi, hdpi, xhdpi, xxhdpi, xxxhdpi named gc_document_import_icon.png
    • Document import button subtitle text: via the string resource named gc_camera_document_import_subtitle
    • Document import button subtitle text style: via overriding the style named GiniCaptureTheme.Camera.DocumentImportSubtitle.TextStyle
    • Document import button subtitle font: via overriding the style named GiniCaptureTheme.Camera.DocumentImportSubtitle.TextStyle and setting an item named gcCustomFont with the path to the font file in your assets folder
    • Document import hint background: via the color resource named gc_document_import_hint_background
    • Document import hint close icon color: via the color resource name gc_hint_close
    • Document import hint text: via the string resource named gc_document_import_hint_text
    • Document import hint text size: via overriding the style named GiniCaptureTheme.Camera.DocumentImportHint.TextStyle and setting an item named android:textSize with the desired sp size
    • Document import hint text color: via the color resource name gc_document_import_hint_text
    • Document import hint font: via overriding the style named GiniCaptureTheme.Camera.DocumentImportHint.TextStyle and setting an item named gcCustomFont with the path to the font file in your assets folder
    • Images stack badge text style: via overriding the style named GiniCaptureTheme.Camera.ImageStackBadge.TextStyle
    • Images stack badge font: via overriding the style named GiniCaptureTheme.Camera.ImageStackBadge.TextStyle and setting an item named gcCustomFont with the path to the font file in your assets folder
    • Images stack badge background colors: via the color resources named gc_camera_image_stack_badge_background and gc_camera_image_stack_badge_background_border
    • Images stack badge background size: via the dimension resource named gc_camera_image_stack_badge_size
    • Images stack subtitle text: via the string resource named gc_camera_image_stack_subtitle
    • Images stack subtitle text style: via overriding the style named GiniCaptureTheme.Camera.ImageStackSubtitle.TextStyle
    • Images stack subtitle font: via overriding the style named GiniCaptureTheme.Camera.ImageStackSubtitle.TextStyle and setting an item named gcCustomFont with the path to the font file in your assets folder
    • Multi-page document page limit exceeded alert message: via the string resource named gc_document_error_too_many_pages
    • Multi-page document page limit exceeded alert positive button text: via the string resource named gc_document_error_multi_page_limit_review_pages_button
    • Multi-page document page limit exceeded alert cancel button text: via the string resource named gc_document_error_multi_page_limit_cancel_button
    • Read storage permission denied button color: via the color resource named gc_accent
    • QRCode detected popup background: via the color resource named gc_qrcode_detected_popup_background
    • QRCode detected popup texts: via the string resources named gc_qrcode_detected_popup_message_1 and gc_qrcode_detected_popup_message_2
    • QRCode detected popup text sizes: via overriding the styles named GiniCaptureTheme.Camera.QRCodeDetectedPopup.Message1.TextStyle and GiniCaptureTheme.Camera.QRCodeDetectedPopup.Message2.TextStyle and setting an item named android:textSize with the desired sp size
    • QRCode detected popup text colors: via the color resource name gc_qrcode_detected_popup_message_1 and gc_qrcode_detected_popup_message_2
    • QRCode detected popup fonts: via overriding the styles named GiniCaptureTheme.Camera.QRCodeDetectedPopup.Message1.TextStyle and GiniCaptureTheme.Camera.QRCodeDetectedPopup.Message2.TextStyle and setting an item named gcCustomFont with the path to the font file in your assets folder
    • Read storage permission rationale text: via the string resource named gc_storage_permission_rationale
    • Read storage permission rationale positive button text: via the string resource named gc_storage_permission_rationale_positive_button
    • Read storage permission rationale negative button text: via the string resource named gc_storage_permission_rationale_negative_button
    • Read storage permission rationale button color: via the color resource named gc_accent
    • Read storage permission denied text: via the string resource named gc_storage_permission_denied
    • Read storage permission denied positive button text: via the string resource named gc_storage_permission_denied_positive_button
    • Read storage permission denied negative button text: via the string resource named gc_storage_permission_denied_negative_button
    • Read storage permission denied button color: via the color resource named gc_accent
    • Tap-to-focus indicator: via images for mdpi, hdpi, xhdpi, xxhdpi, xxxhdpi named gc_camera_focus_indicator.png
    • Help menu item icon: via images for mdpi, hdpi, xhdpi, xxhdpi, xxxhdpi named gc_help_icon.png
    • Onboarding menu item title: via the string resource named gc_show_onboarding
    • Background color: via the color resource named gc_background. Note: this color resource is global to all Activities (CameraActivity, , ReviewActivity, AnalysisActivity)
    • No-camera icon: via images for mdpi, hdpi, xhdpi, xxhdpi, xxxhdpi named gc_no_camera.png
    • No camera permission text: via the string resource named gc_camera_error_no_permission
    • No camera permission text color: via the color resource named gc_camera_error_no_permission
    • No camera permission font: via overriding the style named GiniCaptureTheme.Camera.Error.NoPermission.TextStyle and setting an item named gcCustomFont with the path to the font file in your assets folder
    • No camera permission text style: via overriding the style named GiniCaptureTheme.Camera.Error.NoPermission.TextStyle and setting an item named android:textStyle to normal, bold or italic
    • No camera permission text size: via overriding the style named GiniCaptureTheme.Camera.Error.NoPermission.TextStyle and setting an item named android:textSize to the desired sp size
    • No camera permission button title: via the string resource named gc_camera_error_no_permission_button_title
    • No camera permission button title color: via the color resources named gc_camera_error_no_permission_button_title and gc_camera_error_no_permission_button_title_pressed
    • No camera permission button font: via overriding the style named GiniCaptureTheme.Camera.Error.NoPermission.Button.TextStyle and setting an item named gcCustomFont with the path to the font file in your assets folder
    • No camera permission button text style: via overriding the style named GiniCaptureTheme.Camera.Error.NoPermission.Button.TextStyle and setting an item named android:textStyle to normal, bold or italic
    • No camera permission button text size: via overriding the style named GiniCaptureTheme.Camera.Error.NoPermission.Button.TextStyle and setting an item named android:textSize to the desired sp size

    Important: All overriden styles must have their respective Root. prefixed style as their parent. Ex.: the parent of GiniCaptureTheme.Camera.Error.NoPermission.TextStyle must be Root.GiniCaptureTheme.Camera.Error.NoPermission.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, , ReviewActivity, MultiPageReviewActivity, ).

    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)
    • Title: via the string resource name gc_title_camera
    • Title color: via the color resource named gc_action_bar_title
    • Back button: via images for mdpi, hdpi, xhdpi, xxhdpi, xxxhdpi named gc_action_bar_back