summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorStephen Bird <sbird@cyngn.com>2016-06-06 10:54:11 -0700
committerStephen Bird <sbird@cyngn.com>2016-06-06 10:54:11 -0700
commit054c1bb090611b361e518167d3bfea2482cd4b81 (patch)
tree352d0484259d6ab7e1d14f16e4778de2f4a43cc7 /src
parent4893c00493d9b15c8fcf8df03c12d466b7005179 (diff)
downloadandroid_packages_apps_Dialer-054c1bb090611b361e518167d3bfea2482cd4b81.tar.gz
android_packages_apps_Dialer-054c1bb090611b361e518167d3bfea2482cd4b81.tar.bz2
android_packages_apps_Dialer-054c1bb090611b361e518167d3bfea2482cd4b81.zip
Wire up share visible contacts
This code was missing from aosp. The actions are the same as what contacts uses to respond to the result. Change-Id: I0f0b94eb31df64b4120c9d22dca568da03fd01f5 Ticket: CYNGNOS-2758
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);