use of com.android.mms.data.Contact in project android-aosp-mms by slvn.
the class ComposeMessageActivity method launchMultiplePhonePicker.
private void launchMultiplePhonePicker() {
Intent intent = new Intent(Intents.ACTION_GET_MULTIPLE_PHONES);
intent.addCategory("android.intent.category.DEFAULT");
intent.setType(Phone.CONTENT_TYPE);
// We have to wait for the constructing complete.
ContactList contacts = mRecipientsEditor.constructContactsFromInput(true);
int urisCount = 0;
Uri[] uris = new Uri[contacts.size()];
urisCount = 0;
for (Contact contact : contacts) {
if (Contact.CONTACT_METHOD_TYPE_PHONE == contact.getContactMethodType()) {
uris[urisCount++] = contact.getPhoneUri();
}
}
if (urisCount > 0) {
intent.putExtra(Intents.EXTRA_PHONE_URIS, uris);
}
startActivityForResult(intent, REQUEST_CODE_PICK);
}
use of com.android.mms.data.Contact in project android-aosp-mms by slvn.
the class ComposeMessageActivity method onActivityResult.
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (LogTag.VERBOSE) {
log("onActivityResult: requestCode=" + requestCode + ", resultCode=" + resultCode + ", data=" + data);
}
// We're back!
mWaitingForSubActivity = false;
mShouldLoadDraft = false;
if (mWorkingMessage.isFakeMmsForDraft()) {
// We no longer have to fake the fact we're an Mms. At this point we are or we aren't,
// based on attachments and other Mms attrs.
mWorkingMessage.removeFakeMmsForDraft();
}
if (requestCode == REQUEST_CODE_PICK) {
mWorkingMessage.asyncDeleteDraftSmsMessage(mConversation);
}
if (requestCode == REQUEST_CODE_ADD_CONTACT) {
// and it will update the title bar, etc.
if (mAddContactIntent != null) {
String address = mAddContactIntent.getStringExtra(ContactsContract.Intents.Insert.EMAIL);
if (address == null) {
address = mAddContactIntent.getStringExtra(ContactsContract.Intents.Insert.PHONE);
}
if (address != null) {
Contact contact = Contact.get(address, false);
if (contact != null) {
contact.reload();
}
}
}
}
if (resultCode != RESULT_OK) {
if (LogTag.VERBOSE)
log("bail due to resultCode=" + resultCode);
return;
}
switch(requestCode) {
case REQUEST_CODE_CREATE_SLIDESHOW:
if (data != null) {
WorkingMessage newMessage = WorkingMessage.load(this, data.getData());
if (newMessage != null) {
mWorkingMessage = newMessage;
mWorkingMessage.setConversation(mConversation);
updateThreadIdIfRunning();
drawTopPanel(false);
updateSendButtonState();
}
}
break;
case REQUEST_CODE_TAKE_PICTURE:
{
// create a file based uri and pass to addImage(). We want to read the JPEG
// data directly from file (using UriImage) instead of decoding it into a Bitmap,
// which takes up too much memory and could easily lead to OOM.
File file = new File(TempFileProvider.getScrapPath(this));
Uri uri = Uri.fromFile(file);
// Remove the old captured picture's thumbnail from the cache
MmsApp.getApplication().getThumbnailManager().removeThumbnail(uri);
addImageAsync(uri, false);
break;
}
case REQUEST_CODE_ATTACH_IMAGE:
{
if (data != null) {
addImageAsync(data.getData(), false);
}
break;
}
case REQUEST_CODE_TAKE_VIDEO:
Uri videoUri = TempFileProvider.renameScrapFile(".3gp", null, this);
// Remove the old captured video's thumbnail from the cache
MmsApp.getApplication().getThumbnailManager().removeThumbnail(videoUri);
// can handle null videoUri
addVideoAsync(videoUri, false);
break;
case REQUEST_CODE_ATTACH_VIDEO:
if (data != null) {
addVideoAsync(data.getData(), false);
}
break;
case REQUEST_CODE_ATTACH_SOUND:
{
Uri uri = (Uri) data.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI);
if (Settings.System.DEFAULT_RINGTONE_URI.equals(uri)) {
break;
}
addAudio(uri);
break;
}
case REQUEST_CODE_RECORD_SOUND:
if (data != null) {
addAudio(data.getData());
}
break;
case REQUEST_CODE_ECM_EXIT_DIALOG:
boolean outOfEmergencyMode = data.getBooleanExtra(EXIT_ECM_RESULT, false);
if (outOfEmergencyMode) {
sendMessage(false);
}
break;
case REQUEST_CODE_PICK:
if (data != null) {
processPickResult(data);
}
break;
default:
if (LogTag.VERBOSE)
log("bail due to unknown requestCode=" + requestCode);
break;
}
}
use of com.android.mms.data.Contact in project android-aosp-mms by slvn.
the class ConversationList method onContextItemSelected.
@Override
public boolean onContextItemSelected(MenuItem item) {
Cursor cursor = mListAdapter.getCursor();
if (cursor != null && cursor.getPosition() >= 0) {
Conversation conv = Conversation.from(ConversationList.this, cursor);
long threadId = conv.getThreadId();
switch(item.getItemId()) {
case MENU_DELETE:
{
confirmDeleteThread(threadId, mQueryHandler);
break;
}
case MENU_VIEW:
{
openThread(threadId);
break;
}
case MENU_VIEW_CONTACT:
{
Contact contact = conv.getRecipients().get(0);
Intent intent = new Intent(Intent.ACTION_VIEW, contact.getUri());
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
startActivity(intent);
break;
}
case MENU_ADD_TO_CONTACTS:
{
String address = conv.getRecipients().get(0).getNumber();
startActivity(createAddContactIntent(address));
break;
}
default:
break;
}
}
return super.onContextItemSelected(item);
}
use of com.android.mms.data.Contact in project android-aosp-mms by slvn.
the class ConversationListItem method updateAvatarView.
private void updateAvatarView() {
Drawable avatarDrawable;
if (mConversation.getRecipients().size() == 1) {
Contact contact = mConversation.getRecipients().get(0);
avatarDrawable = contact.getAvatar(mContext, sDefaultContactImage);
if (contact.existsInDatabase()) {
mAvatarView.assignContactUri(contact.getUri());
} else {
mAvatarView.assignContactFromPhone(contact.getNumber(), true);
}
} else {
// TODO get a multiple recipients asset (or do something else)
avatarDrawable = sDefaultContactImage;
mAvatarView.assignContactUri(null);
}
mAvatarView.setImageDrawable(avatarDrawable);
mAvatarView.setVisibility(View.VISIBLE);
}
use of com.android.mms.data.Contact in project android-aosp-mms by slvn.
the class MessageListItem method updateAvatarView.
private void updateAvatarView(String addr, boolean isSelf) {
Drawable avatarDrawable;
if (isSelf || !TextUtils.isEmpty(addr)) {
Contact contact = isSelf ? Contact.getMe(false) : Contact.get(addr, false);
avatarDrawable = contact.getAvatar(mContext, sDefaultContactImage);
if (isSelf) {
mAvatar.assignContactUri(Profile.CONTENT_URI);
} else {
if (contact.existsInDatabase()) {
mAvatar.assignContactUri(contact.getUri());
} else {
mAvatar.assignContactFromPhone(contact.getNumber(), true);
}
}
} else {
avatarDrawable = sDefaultContactImage;
}
mAvatar.setImageDrawable(avatarDrawable);
}
Aggregations