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

Commit 61f6cf74 authored by Daniel Lehmann's avatar Daniel Lehmann Committed by Android (Google) Code Review
Browse files

Merge changes Ie617b76f,I83128ba7

* changes:
  Fix creation of Uri if the lookup key has characters that are not allowed in a Uri
  Create a single VCard file for several contacts Bug:2501468
parents a307b774 cbf7595c
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,
+1 −1
Original line number Diff line number Diff line
@@ -548,7 +548,7 @@ public class ViewContactActivity extends Activity
                if (mAllRestricted) return false;

                // TODO: Keep around actual LOOKUP_KEY, or formalize method of extracting
                final String lookupKey = mLookupUri.getPathSegments().get(2);
                final String lookupKey = Uri.encode(mLookupUri.getPathSegments().get(2));
                final Uri shareUri = Uri.withAppendedPath(Contacts.CONTENT_VCARD_URI, lookupKey);

                final Intent intent = new Intent(Intent.ACTION_SEND);