Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bc5c776d authored by Daniel Lehmann's avatar Daniel Lehmann
Browse files

Create a single VCard file for several contacts

Bug:2501468

Change-Id: I83128ba7f2cf120ec5816a2914b1e9501de526d9
parent 381f1749
Loading
Loading
Loading
Loading
+11 −6
Original line number Diff line number Diff line
@@ -1397,16 +1397,21 @@ public class ContactsListActivity extends ListActivity implements View.OnCreateC
                return;
            }

            ArrayList<Uri> uriList = new ArrayList<Uri>();
            StringBuilder uriListBuilder = new StringBuilder();
            int index = 0;
            for (;!cursor.isAfterLast(); cursor.moveToNext()) {
                uriList.add(Uri.withAppendedPath(
                        Contacts.CONTENT_VCARD_URI,
                        cursor.getString(0)));
                if (index != 0)
                    uriListBuilder.append(':');
                uriListBuilder.append(Uri.encode(cursor.getString(0)));
                index++;
            }
            Uri uri = Uri.withAppendedPath(
                    Contacts.CONTENT_MULTI_VCARD_URI,
                    Uri.encode(uriListBuilder.toString()));

            final Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE);
            final Intent intent = new Intent(Intent.ACTION_SEND);
            intent.setType(Contacts.CONTENT_VCARD_TYPE);
            intent.putExtra(Intent.EXTRA_STREAM, uriList);
            intent.putExtra(Intent.EXTRA_STREAM, uri);
            startActivity(intent);
        } finally {
            cursor.close();
+12 −9
Original line number Diff line number Diff line
@@ -263,7 +263,7 @@ public class ImportVCardActivity extends Activity {
                            // Assume that VCardSourceDetector was able to detect the source.
                        }
                        String charset = detector.getEstimatedCharset();
                        createdUri = doActuallyReadOneVCard(uri, mAccount,
                        doActuallyReadOneVCard(uri, mAccount,
                                charset, false, detector, mErrorFileNameList);
                        mProgressDialogForReadVCard.incrementProgressBy(1);
                    }
@@ -279,6 +279,7 @@ public class ImportVCardActivity extends Activity {
                            mNeedReview = false;
                            Log.v("importVCardActivity", "Prepare to review the imported contact");

                            if (createdUri != null) {
                                // get contact_id of this raw_contact
                                final long rawContactId = ContentUris.parseId(createdUri);
                                Uri contactUri = RawContacts.getContactLookupUri(getContentResolver(),
@@ -288,6 +289,7 @@ public class ImportVCardActivity extends Activity {
                                Intent viewIntent = new Intent(Intent.ACTION_VIEW, contactUri);
                                startActivity(viewIntent);
                            }
                        }
                    } else {
                        StringBuilder builder = new StringBuilder();
                        boolean first = true;
@@ -338,7 +340,8 @@ public class ImportVCardActivity extends Activity {
            } catch (VCardNestedException e) {
                Log.e(LOG_TAG, "Never reach here.");
            }
            return committer.getLastCreatedUri();
            final ArrayList<Uri> createdUris = committer.getCreatedUris();
            return (createdUris == null || createdUris.size() != 1) ? null : createdUris.get(0);
        }

        private boolean readOneVCardFile(Uri uri, String charset,