use of com.android.mms.data.ContactList in project android-aosp-mms by slvn.
the class ComposeMessageActivity method buildAddAddressToContactMenuItem.
private void buildAddAddressToContactMenuItem(Menu menu) {
// bug #7087793: for group of recipients, remove "Add to People" action. Rely on
// individually creating contacts for unknown phone numbers by touching the individual
// sender's avatars, one at a time
ContactList contacts = getRecipients();
if (contacts.size() != 1) {
return;
}
// if we don't have a contact for the recipient, create a menu item to add the number
// to contacts.
Contact c = contacts.get(0);
if (!c.existsInDatabase() && canAddToContacts(c)) {
Intent intent = ConversationList.createAddContactIntent(c.getNumber());
menu.add(0, MENU_ADD_ADDRESS_TO_CONTACTS, 0, R.string.menu_add_to_contacts).setIcon(android.R.drawable.ic_menu_add).setIntent(intent);
}
}
use of com.android.mms.data.ContactList in project android-aosp-mms by slvn.
the class ComposeMessageActivity method initRecipientsEditor.
// Get the recipients editor ready to be displayed onscreen.
private void initRecipientsEditor() {
if (isRecipientsEditorVisible()) {
return;
}
// Must grab the recipients before the view is made visible because getRecipients()
// returns empty recipients when the editor is visible.
ContactList recipients = getRecipients();
ViewStub stub = (ViewStub) findViewById(R.id.recipients_editor_stub);
if (stub != null) {
View stubView = stub.inflate();
mRecipientsEditor = (RecipientsEditor) stubView.findViewById(R.id.recipients_editor);
mRecipientsPicker = (ImageButton) stubView.findViewById(R.id.recipients_picker);
} else {
mRecipientsEditor = (RecipientsEditor) findViewById(R.id.recipients_editor);
mRecipientsEditor.setVisibility(View.VISIBLE);
mRecipientsPicker = (ImageButton) findViewById(R.id.recipients_picker);
}
mRecipientsPicker.setOnClickListener(this);
mRecipientsEditor.setAdapter(new ChipsRecipientAdapter(this));
mRecipientsEditor.populate(recipients);
mRecipientsEditor.setOnCreateContextMenuListener(mRecipientsMenuCreateListener);
mRecipientsEditor.addTextChangedListener(mRecipientsWatcher);
// TODO : Remove the max length limitation due to the multiple phone picker is added and the
// user is able to select a large number of recipients from the Contacts. The coming
// potential issue is that it is hard for user to edit a recipient from hundred of
// recipients in the editor box. We may redesign the editor box UI for this use case.
// mRecipientsEditor.setFilters(new InputFilter[] {
// new InputFilter.LengthFilter(RECIPIENTS_MAX_LENGTH) });
mRecipientsEditor.setOnSelectChipRunnable(new Runnable() {
@Override
public void run() {
// keeps having focus stolen away.
if (mRecipientsEditor.getRecipientCount() == 1) {
// if we're in extract mode then don't request focus
final InputMethodManager inputManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
if (inputManager == null || !inputManager.isFullscreenMode()) {
mTextEditor.requestFocus();
}
}
}
});
mRecipientsEditor.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
if (!hasFocus) {
RecipientsEditor editor = (RecipientsEditor) v;
ContactList contacts = editor.constructContactsFromInput(false);
updateTitle(contacts);
}
}
});
PhoneNumberFormatter.setPhoneNumberFormattingTextWatcher(this, mRecipientsEditor);
mTopPanel.setVisibility(View.VISIBLE);
}
use of com.android.mms.data.ContactList in project android-aosp-mms by slvn.
the class ComposeMessageActivity method processPickResult.
private void processPickResult(final Intent data) {
// The EXTRA_PHONE_URIS stores the phone's urls that were selected by user in the
// multiple phone picker.
final Parcelable[] uris = data.getParcelableArrayExtra(Intents.EXTRA_PHONE_URIS);
final int recipientCount = uris != null ? uris.length : 0;
final int recipientLimit = MmsConfig.getRecipientLimit();
if (recipientLimit != Integer.MAX_VALUE && recipientCount > recipientLimit) {
new AlertDialog.Builder(this).setMessage(getString(R.string.too_many_recipients, recipientCount, recipientLimit)).setPositiveButton(android.R.string.ok, null).create().show();
return;
}
final Handler handler = new Handler();
final ProgressDialog progressDialog = new ProgressDialog(this);
progressDialog.setTitle(getText(R.string.pick_too_many_recipients));
progressDialog.setMessage(getText(R.string.adding_recipients));
progressDialog.setIndeterminate(true);
progressDialog.setCancelable(false);
final Runnable showProgress = new Runnable() {
@Override
public void run() {
progressDialog.show();
}
};
// Only show the progress dialog if we can not finish off parsing the return data in 1s,
// otherwise the dialog could flicker.
handler.postDelayed(showProgress, 1000);
new Thread(new Runnable() {
@Override
public void run() {
final ContactList list;
try {
list = ContactList.blockingGetByUris(uris);
} finally {
handler.removeCallbacks(showProgress);
progressDialog.dismiss();
}
// TODO: there is already code to update the contact header widget and recipients
// editor if the contacts change. we can re-use that code.
final Runnable populateWorker = new Runnable() {
@Override
public void run() {
mRecipientsEditor.populate(list);
updateTitle(list);
}
};
handler.post(populateWorker);
}
}, "ComoseMessageActivity.processPickResult").start();
}
use of com.android.mms.data.ContactList in project android-aosp-mms by slvn.
the class ComposeMessageActivity method onOptionsItemSelected.
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch(item.getItemId()) {
case MENU_ADD_SUBJECT:
showSubjectEditor(true);
mWorkingMessage.setSubject("", true);
updateSendButtonState();
mSubjectTextEditor.requestFocus();
break;
case MENU_ADD_ATTACHMENT:
// Launch the add-attachment list dialog
showAddAttachmentDialog(false);
break;
case MENU_DISCARD:
mWorkingMessage.discard();
finish();
break;
case MENU_SEND:
if (isPreparedForSending()) {
confirmSendMessageIfNeeded();
}
break;
case MENU_SEARCH:
onSearchRequested();
break;
case MENU_DELETE_THREAD:
confirmDeleteThread(mConversation.getThreadId());
break;
case android.R.id.home:
case MENU_CONVERSATION_LIST:
exitComposeMessageActivity(new Runnable() {
@Override
public void run() {
goToConversationList();
}
});
break;
case MENU_CALL_RECIPIENT:
dialRecipient();
break;
case MENU_GROUP_PARTICIPANTS:
{
Intent intent = new Intent(this, RecipientListActivity.class);
intent.putExtra(THREAD_ID, mConversation.getThreadId());
startActivity(intent);
break;
}
case MENU_VIEW_CONTACT:
{
// View the contact for the first (and only) recipient.
ContactList list = getRecipients();
if (list.size() == 1 && list.get(0).existsInDatabase()) {
Uri contactUri = list.get(0).getUri();
Intent intent = new Intent(Intent.ACTION_VIEW, contactUri);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
startActivity(intent);
}
break;
}
case MENU_ADD_ADDRESS_TO_CONTACTS:
mAddContactIntent = item.getIntent();
startActivityForResult(mAddContactIntent, REQUEST_CODE_ADD_CONTACT);
break;
case MENU_PREFERENCES:
{
Intent intent = new Intent(this, MessagingPreferenceActivity.class);
startActivityIfNeeded(intent, -1);
break;
}
case MENU_DEBUG_DUMP:
mWorkingMessage.dump();
Conversation.dump();
LogTag.dumpInternalTables(this);
break;
}
return true;
}
use of com.android.mms.data.ContactList in project android-aosp-mms by slvn.
the class RecipientListActivity method onCreate.
@Override
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
if (icicle != null) {
// Retrieve previously saved state of this activity.
mThreadId = icicle.getLong(ComposeMessageActivity.THREAD_ID);
} else {
mThreadId = getIntent().getLongExtra(ComposeMessageActivity.THREAD_ID, 0);
}
if (mThreadId == 0) {
Log.w(TAG, "No thread_id specified in extras or icicle. Finishing...");
finish();
return;
}
Conversation conv = Conversation.get(this, mThreadId, true);
if (conv == null) {
Log.w(TAG, "No conversation found for threadId: " + mThreadId + ". Finishing...");
finish();
return;
}
final ContactList contacts = conv.getRecipients();
getListView().setAdapter(new RecipientListAdapter(this, R.layout.recipient_list_item, contacts));
ActionBar actionBar = getActionBar();
actionBar.setDisplayHomeAsUpEnabled(true);
int cnt = contacts.size();
actionBar.setSubtitle(getResources().getQuantityString(R.plurals.recipient_count, cnt, cnt));
}
Aggregations