Package com.zendesk.sdk.attachment
Class AttachmentHelper
- java.lang.Object
-
- com.zendesk.sdk.attachment.AttachmentHelper
-
public class AttachmentHelper extends java.lang.Object
Class with static helper methods for uploading attachments
-
-
Constructor Summary
Constructors Constructor and Description AttachmentHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method and Description static boolean
isAttachmentSupportEnabled(SafeMobileSettings storedSettings)
Check if uploading attachments is allowed.static boolean
isFileEligibleForUpload(java.io.File file, SafeMobileSettings storedSettings)
Check if the provided file is eligible for upload.static void
processAndUploadSelectedFiles(java.util.List<BelvedereResult> selectedFiles, ImageUploadHelper imageUploadHelper, Context context, AttachmentContainerHost attachmentContainerHost, SafeMobileSettings storedSettings)
Helper method for uploading aList
ofFile
The files are provided bycom.zendesk.belvedere.Belvedere#getFilesFromActivityOnResult(int, int, Intent, BelvedereCallback)
If a provided file is not allowed to be uploaded aToast
will be shown.static void
showAttachmentTryAgainDialog(Context context, BelvedereResult file, ErrorResponse errorResponse, ImageUploadHelper imageUploadHelper, AttachmentContainerHost attachmentContainerHost)
Show anandroid.app.AlertDialog
after uploading a file failed.
-
-
-
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 anandroid.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 contextfile
- Reference to the fileerrorResponse
- ErrorResponse containing information why uploading failedimageUploadHelper
- ImageUploadHelper for restarting the uploadattachmentContainerHost
- 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
ofFile
The files are provided bycom.zendesk.belvedere.Belvedere#getFilesFromActivityOnResult(int, int, Intent, BelvedereCallback)
If a provided file is not allowed to be uploaded aToast
will be shown.This method takes a list of files and prepares them for upload.
- Deduplicate selected files
- Check if files exist
- Check if files complies with
AttachmentSettings.getMaxAttachmentSize()
- Parameters:
selectedFiles
- A list of files that should be uploadedimageUploadHelper
- An instance ofImageUploadHelper
context
- An application contextattachmentContainerHost
- An instance ofAttachmentContainerHost
-
-