diff options
author | kaiyiz <kaiyiz@codeaurora.org> | 2014-09-25 14:18:39 +0800 |
---|---|---|
committer | Matt Garnes <matt@cyngn.com> | 2014-11-13 17:48:11 -0800 |
commit | 313f3751054cfb2263c04a008f3a7b51eb2c810b (patch) | |
tree | e3a4cf7d8e29d9faa014675c11b9d7f307c0e385 /src | |
parent | 243a665ed7aa53eb1e0705b99ece1bc5f2056deb (diff) | |
download | android_packages_apps_Dialer-313f3751054cfb2263c04a008f3a7b51eb2c810b.tar.gz android_packages_apps_Dialer-313f3751054cfb2263c04a008f3a7b51eb2c810b.tar.bz2 android_packages_apps_Dialer-313f3751054cfb2263c04a008f3a7b51eb2c810b.zip |
Dialer: Enable share visible contacts function
Deal with the result which contains contacts that
user selects.
CRs-Fixed: 707535
Change-Id: I212832312dfa79b3857c0bf93f4dc59adc4ea898
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/dialer/DialtactsActivity.java | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/com/android/dialer/DialtactsActivity.java b/src/com/android/dialer/DialtactsActivity.java index 3ac7d86e4..7d24926b6 100644 --- a/src/com/android/dialer/DialtactsActivity.java +++ b/src/com/android/dialer/DialtactsActivity.java @@ -60,6 +60,7 @@ import android.widget.PopupMenu; import android.widget.Toast; import com.android.contacts.common.CallUtil; +import com.android.contacts.common.SimContactsConstants; import com.android.contacts.common.dialog.ClearFrequentsDialog; import com.android.contacts.common.interactions.ImportExportDialogFragment; import com.android.contacts.common.interactions.TouchPointManager; @@ -93,6 +94,7 @@ import com.android.internal.telephony.TelephonyProperties; import com.android.phone.common.animation.AnimationListenerAdapter; import java.util.ArrayList; +import java.util.Iterator; import java.util.List; /** @@ -638,10 +640,56 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O } else { Log.e(TAG, "Voice search failed"); } + } else if (requestCode == ImportExportDialogFragment.SUBACTIVITY_SHARE_VISILBLE_CONTACTS) { + if (resultCode == RESULT_OK) { + Bundle result = data.getExtras().getBundle( + SimContactsConstants.RESULT_KEY); + StringBuilder uriList = buildUriList(result); + if (uriList == null) { + return; + } + Uri uri = Uri.withAppendedPath( + Contacts.CONTENT_MULTI_VCARD_URI, + Uri.encode(uriList.toString())); + final Intent intent = new Intent(Intent.ACTION_SEND); + intent.setType(Contacts.CONTENT_VCARD_TYPE); + intent.putExtra(Intent.EXTRA_STREAM, uri); + startActivity(intent); + } } super.onActivityResult(requestCode, resultCode, data); } + private StringBuilder buildUriList(Bundle result) { + if (result == null) { + return null; + } + 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 null; + } + StringBuilder uriListBuilder = new StringBuilder(); + int index = 0; + 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++; + } + return uriListBuilder; + } + /** * Initiates a fragment transaction to show the dialpad fragment. Animations and other visual * updates are handled by a callback which is invoked after the dialpad fragment is shown. |