Class AttachmentHelper



  • public class AttachmentHelper
    extends java.lang.Object
    Class with static helper methods for uploading attachments
    • Constructor Detail

      • AttachmentHelper

        public AttachmentHelper()
    • Method Detail

      • isAttachmentSupportEnabled

        public static boolean isAttachmentSupportEnabled(SafeMobileSettings storedSettings)
        Check if uploading attachments is allowed.
        Returns:
        True if attachment support is enabled, false if not allowed or we don't have valid settings
      • isFileEligibleForUpload

        public static boolean isFileEligibleForUpload(java.io.File file,
                                                      SafeMobileSettings storedSettings)
        Check if the provided file is eligible for upload.
        Parameters:
        file - A file
        Returns:
        True if exists and is allowed for upload, false if it doesn't exist, is too big or we don't have valid settings.
      • showAttachmentTryAgainDialog

        public static void showAttachmentTryAgainDialog(Context context,
                                                        BelvedereResult file,
                                                        ErrorResponse errorResponse,
                                                        ImageUploadHelper imageUploadHelper,
                                                        AttachmentContainerHost attachmentContainerHost)
        Show an android.app.AlertDialog after uploading a file failed.

        Show this modal dialog if uploading a file failed. The dialog offers the user to cancel the upload or try the upload again.

        Parameters:
        context - An application context
        file - Reference to the file
        errorResponse - ErrorResponse containing information why uploading failed
        imageUploadHelper - ImageUploadHelper for restarting the upload
        attachmentContainerHost - AttachmentContainerHost For manipulating UI according to the users choice
      • processAndUploadSelectedFiles

        public static void processAndUploadSelectedFiles(java.util.List<BelvedereResult> selectedFiles,
                                                         ImageUploadHelper imageUploadHelper,
                                                         Context context,
                                                         AttachmentContainerHost attachmentContainerHost,
                                                         SafeMobileSettings storedSettings)

        Helper method for uploading a List of File
        The files are provided by com.zendesk.belvedere.Belvedere#getFilesFromActivityOnResult(int, int, Intent, BelvedereCallback) If a provided file is not allowed to be uploaded a Toast will be shown.

        This method takes a list of files and prepares them for upload.

        1. Deduplicate selected files
        2. Check if files exist
        3. Check if files complies with AttachmentSettings.getMaxAttachmentSize()
        Parameters:
        selectedFiles - A list of files that should be uploaded
        imageUploadHelper - An instance of ImageUploadHelper
        context - An application context
        attachmentContainerHost - An instance of AttachmentContainerHost