コード例 #1
0
 private void addAttachmentsToBulletin(Bulletin bulletin) throws Exception {
   ArrayList<SecureFile> attachmentFiles = getJpegFiles();
   for (SecureFile attachmentFile : attachmentFiles) {
     SecureMobileAttachmentProxy attachementProxy =
         new SecureMobileAttachmentProxy(attachmentFile);
     if (attachmentFile.exists()) bulletin.addPublicAttachment(attachementProxy);
     else
       throw new Exception(
           getString(R.string.error_message_file_to_attach_does_not_exist, attachmentFile));
   }
 }
コード例 #2
0
  private void deleteFormAfterSent() {
    String instancePath =
        getIntent().getExtras().getString(MartusUploadManager.BULLETIN_ISTANCE_FILE_PATH_TAG);
    SecureFile secureFileToDelete = new SecureFile(instancePath);
    boolean wasDeleted = secureFileToDelete.delete();
    if (wasDeleted)
      Log.i(TAG, getString(R.string.error_message_form_was_deleted_after_upload_was_completed));
    else Log.i(TAG, getString(R.string.error_message_form_could_not_be_deleted));

    MainActivity.deleteOdkInstanceCacheDir(instancePath);
    removeFormFromOdkDatabase();
  }
コード例 #3
0
  private ArrayList<SecureFile> getJpegFiles() {
    String formInstancePath = findInstanceFormPath(this);
    if (formInstancePath == null) return new ArrayList();

    SecureFile attachmentsDir = ManageAttachmentsActivty.getAttachmentsDir(formInstancePath);
    SecureFile[] jpegFilesInInstanceDir = attachmentsDir.listFiles();
    ArrayList<SecureFile> jpegFiles = new ArrayList();
    for (int index = 0; index < jpegFilesInInstanceDir.length; ++index) {
      SecureFile jpegFile = jpegFilesInInstanceDir[index];
      jpegFiles.add(jpegFile);
    }

    return jpegFiles;
  }