Created
October 10, 2011 06:35
-
-
Save anonymous/1274748 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class BuildEnvelope extends Activity { | |
@Override | |
public void onCreate(Bundle savedInstanceState) | |
{ | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.buildenvelope); | |
try | |
{ | |
Document doc = new Document(); | |
doc.setID(1); | |
Uri uri = getIntent().getParcelableExtra(Intent.EXTRA_STREAM); | |
ContentResolver cr = getContentResolver(); | |
Cursor cur = cr.query(uri, null, null, null, null); | |
if (cur.moveToFirst()) | |
{ | |
doc.setName(cur.getString(cur.getColumnIndex(MediaStore.MediaColumns.TITLE))); | |
String filename = cur.getString(cur.getColumnIndex(MediaStore.MediaColumns.DATA)); | |
int lastdot = filename.lastIndexOf('.'); | |
int lastdir = filename.lastIndexOf('/'); | |
if (lastdot <= lastdir) | |
doc.setFileExtension(""); | |
else | |
doc.setFileExtension(filename.substring(lastdot + 1)); | |
InputStream is = cr.openInputStream(uri); | |
byte[] buf = new byte[cur.getInt(cur.getColumnIndex(MediaStore.MediaColumns.SIZE))]; | |
is.read(buf); | |
is.close(); | |
doc.setData(buf); | |
} | |
Recipient recip = new Recipient(); | |
recip.setID(1); | |
recip.setUserName(((DSApplication)getApplication()).getCurrentUser().getUserName()); | |
recip.setSignerName(((DSApplication)getApplication()).getCurrentUser().getUserName()); | |
recip.setEmail(((DSApplication)getApplication()).getCurrentUser().getEmail()); | |
recip.setType(Recipient.Type.Signer); | |
recip.setRoutingOrder(1); | |
recip.setAutoNavigation(true); | |
CustomField cf_appname = new CustomField(); | |
cf_appname.setName("AppName"); | |
cf_appname.setValue("DocuSign Ink Beta"); | |
CustomField cf_platform = new CustomField(); | |
cf_appname.setName("Platform"); | |
cf_appname.setValue("Android"); | |
Envelope env = new Envelope(); | |
env.setDocuments(Collections.singletonList(doc)); | |
env.setRecipients(Collections.singleton(recip)); | |
ArrayList<CustomField> fields = new ArrayList<CustomField>(); | |
fields.add(cf_appname); | |
fields.add(cf_platform); | |
env.setCustomFields(fields); | |
env.setSubject(doc.getName()); | |
env.setEmailBlurb(""); | |
// if i uncomment the putExtra call, this line has no effect | |
startActivity(new Intent(this, UploadActivity.class)/*.putExtra("Envelope", env)*/); | |
// this works fine | |
finish(); | |
} | |
catch (Exception e) | |
{ | |
Toast.makeText(this, e.toString(), Toast.LENGTH_LONG); | |
finish(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment