/android/export-contacts

To get this branch, use:
bzr branch http://bzr.ed.am/android/export-contacts

« back to all changes in this revision

Viewing changes to src/am/ed/exportcontacts/VcardExporter.java

  • Committer: edam
  • Date: 2012-12-21 15:53:30 UTC
  • Revision ID: tim@ed.am-20121221155330-j2zt31mh1b55mdty
added thank you message to intro

Show diffs side-by-side

added added

removed removed

268
268
                                case ContactData.TYPE_WORK:
269
269
                                        types.add( "WORK" ); break;
270
270
                                }
271
 
                                // we use LABEL because is accepts formatted text (whereas ADR
272
 
                                // expects semicolon-delimited fields with specific purposes)
273
271
                                out.append( fold( "LABEL" +
274
272
                                        ( types.size() > 0? ";TYPE=" + join( types, "," ) : "" ) +
275
273
                                        ":" + escape( addresses.get( a ).getAddress() ) ) + "\n" );
285
283
                // append footer
286
284
                out.append( "END:VCARD\n" );
287
285
 
288
 
                // replace '\n' with "\r\n" (spec requires CRLF)
289
 
                int pos = 0;
290
 
                while( true ) {
291
 
                        pos = out.indexOf( "\n", pos );
292
 
                        if( pos == -1 ) break;
293
 
                        out.replace( pos, pos + 1, "\r\n" );
294
 
 
295
 
                        // skip our inserted string
296
 
                        pos += 2;
297
 
                }
298
 
 
299
286
                // write to file
300
287
                try {
301
288
                        _ostream.write( out.toString().getBytes() );