summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/com/android/dialer/DialtactsActivity.java37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/com/android/dialer/DialtactsActivity.java b/src/com/android/dialer/DialtactsActivity.java
index 07aac4b5a..f7e314a95 100644
--- a/src/com/android/dialer/DialtactsActivity.java
+++ b/src/com/android/dialer/DialtactsActivity.java
@@ -38,6 +38,7 @@ import android.os.Looper;
import android.os.Trace;
import android.provider.CallLog.Calls;
import android.preference.PreferenceManager;
+import android.provider.ContactsContract;
import android.provider.ContactsContract.CommonDataKinds.Phone;
import android.provider.ContactsContract.CommonDataKinds.SipAddress;
import android.speech.RecognizerIntent;
@@ -931,6 +932,42 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O
this.startActivity(exportIntent);
}
break;
+ case ImportExportDialogFragment.SUBACTIVITY_SHARE_VISILBLE_CONTACTS:
+ if (resultCode == RESULT_OK) {
+ Bundle result = data.getExtras().getBundle(
+ SimContactsConstants.RESULT_KEY);
+ StringBuilder uriListBuilder = new StringBuilder();
+ int index = 0;
+ int size = result.keySet().size();
+ // The premise of allowing to share contacts is that the
+ // amount of those contacts which have been selected to
+ // append and will be put into intent as extra data to
+ // deliver is not more that 2000, because too long arguments
+ // will cause TransactionTooLargeException in binder.
+ if (size > ImportExportDialogFragment.MAX_COUNT_ALLOW_SHARE_CONTACT) {
+ Toast.makeText(this, R.string.share_failed,
+ Toast.LENGTH_SHORT).show();
+ return;
+ }
+ Iterator<String> it = result.keySet().iterator();
+ String[] values = null;
+ while (it.hasNext()) {
+ if (index != 0) {
+ uriListBuilder.append(':');
+ }
+ values = result.getStringArray(it.next());
+ uriListBuilder.append(values[0]);
+ index++;
+ }
+ Uri uri = Uri.withAppendedPath(
+ ContactsContract.Contacts.CONTENT_MULTI_VCARD_URI,
+ Uri.encode(uriListBuilder.toString()));
+ final Intent intent = new Intent(Intent.ACTION_SEND);
+ intent.setType(ContactsContract.Contacts.CONTENT_VCARD_TYPE);
+ intent.putExtra(Intent.EXTRA_STREAM, uri);
+ startActivity(intent);
+ }
+ break;
}
super.onActivityResult(requestCode, resultCode, data);