Methods Summary |
---|
private void | confirmDeleteDialog(android.content.DialogInterface.OnClickListener listener, boolean deleteAll)
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.confirm_dialog_title);
builder.setIcon(android.R.drawable.ic_dialog_alert);
builder.setCancelable(true);
builder.setPositiveButton(R.string.yes, listener);
builder.setNegativeButton(R.string.no, null);
builder.setMessage(deleteAll
? R.string.confirm_delete_all_conversations
: R.string.confirm_delete_conversation);
builder.show();
|
public static android.content.Intent | createAddContactIntent(java.lang.String address)
// address must be a single recipient
Intent intent = new Intent(Intent.ACTION_INSERT_OR_EDIT);
intent.setType(Contacts.People.CONTENT_ITEM_TYPE);
if (Recipient.isPhoneNumber(address)) {
intent.putExtra(Insert.PHONE, address);
} else {
intent.putExtra(Insert.EMAIL, address);
}
return intent;
|
private void | createNewMessage()
Intent intent = new Intent(this, ComposeMessageActivity.class);
startActivity(intent);
|
private java.lang.String | getAddress(android.database.Cursor cursor)
long threadId = cursor.getLong(ConversationListAdapter.COLUMN_ID);
String address = null;
if (mListAdapter.isSimpleMode()) {
address = MessageUtils.getRecipientsByIds(
this,
cursor.getString(ConversationListAdapter.COLUMN_RECIPIENTS_IDS),
true /* allow query */);
} else {
String msgType = cursor.getString(ConversationListAdapter.COLUMN_MESSAGE_TYPE);
if (msgType.equals("sms")) {
address = cursor.getString(ConversationListAdapter.COLUMN_SMS_ADDRESS);
} else {
address = MessageUtils.getAddressByThreadId(this, threadId);
}
}
return address;
|
protected void | handleCreationIntent(android.content.Intent intent)
// Handle intents that occur upon creation of the activity.
initNormalQueryArgs();
|
private void | initListAdapter()
mListAdapter = new ConversationListAdapter(this, null, true, mCachingNameStore);
setListAdapter(mListAdapter);
|
private void | initNormalQueryArgs()
Uri.Builder builder = Threads.CONTENT_URI.buildUpon();
builder.appendQueryParameter("simple", "true");
mBaseUri = builder.build();
mSelection = null;
mProjection = ConversationListAdapter.PROJECTION;
mQueryToken = THREAD_LIST_QUERY_TOKEN;
mTitle = getString(R.string.app_label);
|
public static boolean | isFailedToDeliver(android.content.Intent intent)
return (intent != null) && intent.getBooleanExtra("undelivered_flag", false);
|
public void | onConfigurationChanged(android.content.res.Configuration newConfig)
// We override this method to avoid restarting the entire
// activity when the keyboard is opened (declared in
// AndroidManifest.xml). Because the only translatable text
// in this activity is "New Message", which has the full width
// of phone to work with, localization shouldn't be a problem:
// no abbreviated alternate words should be needed even in
// 'wide' languages like German or Russian.
super.onConfigurationChanged(newConfig);
if (DEBUG) Log.v(TAG, "onConfigurationChanged: " + newConfig);
|
public boolean | onContextItemSelected(android.view.MenuItem item)
Cursor cursor = mListAdapter.getCursor();
long threadId = cursor.getLong(ConversationListAdapter.COLUMN_ID);
switch (item.getItemId()) {
case MENU_DELETE: {
DeleteThreadListener l = new DeleteThreadListener(threadId);
confirmDeleteDialog(l, false);
break;
}
case MENU_VIEW: {
String address = getAddress(cursor);
openThread(threadId, address);
break;
}
case MENU_VIEW_CONTACT: {
String address = getAddress(cursor);
viewContact(address);
break;
}
case MENU_ADD_TO_CONTACTS: {
String address = getAddress(cursor);
startActivity(createAddContactIntent(address));
break;
}
default:
break;
}
return super.onContextItemSelected(item);
|
protected void | onCreate(android.os.Bundle savedInstanceState)
// Returns comma-separated list of contact's display names
// given a semicolon-delimited string of canonical phone
// numbers.
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
setContentView(R.layout.conversation_list_screen);
mQueryHandler = new ThreadListQueryHandler(getContentResolver());
ListView listView = getListView();
LayoutInflater inflater = LayoutInflater.from(this);
ConversationHeaderView headerView = (ConversationHeaderView)
inflater.inflate(R.layout.conversation_header, listView, false);
headerView.bind(getString(R.string.new_message),
getString(R.string.create_new_message));
listView.addHeaderView(headerView, null, true);
listView.setOnCreateContextMenuListener(mConvListOnCreateContextMenuListener);
listView.setOnKeyListener(mThreadListKeyListener);
mCachingNameStore = new CachingNameStoreImpl(this);
initListAdapter();
if (savedInstanceState != null) {
mBaseUri = (Uri) savedInstanceState.getParcelable("base_uri");
mSearchFlag = savedInstanceState.getBoolean("search_flag");
mFilter = savedInstanceState.getString("filter");
mQueryToken = savedInstanceState.getInt("query_token");
}
handleCreationIntent(getIntent());
|
public void | onDraftChanged(long threadId, boolean hasDraft)
// Run notifyDataSetChanged() on the main thread.
mQueryHandler.post(new Runnable() {
public void run() {
mListAdapter.notifyDataSetChanged();
}
});
|
protected void | onListItemClick(android.widget.ListView l, android.view.View v, int position, long id)
if (LOCAL_LOGV) {
Log.v(TAG, "onListItemClick: position=" + position + ", id=" + id);
}
if (position == 0) {
createNewMessage();
} else if (v instanceof ConversationHeaderView) {
ConversationHeaderView headerView = (ConversationHeaderView) v;
ConversationHeader ch = headerView.getConversationHeader();
// TODO: The 'from' view of the ConversationHeader was
// repurposed to be the cached display value, rather than
// the old raw value, which openThread() wanted. But it
// turns out openThread() doesn't need it:
// ComposeMessageActivity will load it. That's not ideal,
// though, as it's an SQLite query. So fix this later to
// save some latency on starting ComposeMessageActivity.
String somethingDelimitedAddresses = null;
openThread(ch.getThreadId(), somethingDelimitedAddresses);
}
|
protected void | onNewIntent(android.content.Intent intent)
// Handle intents that occur after the activity has already been created.
handleCreationIntent(intent);
|
public boolean | onOptionsItemSelected(android.view.MenuItem item)
switch(item.getItemId()) {
case MENU_COMPOSE_NEW:
createNewMessage();
break;
case MENU_SEARCH:
onSearchRequested();
break;
case MENU_DELETE_ALL:
confirmDeleteDialog(new DeleteThreadListener(-1L), true);
break;
case MENU_PREFERENCES: {
Intent intent = new Intent(this, MessagingPreferenceActivity.class);
startActivityIfNeeded(intent, -1);
break;
}
default:
return true;
}
return false;
|
protected void | onPause()
super.onPause();
DraftCache.getInstance().removeOnDraftChangedListener(this);
|
public boolean | onPrepareOptionsMenu(android.view.Menu menu)
menu.clear();
menu.add(0, MENU_COMPOSE_NEW, 0, R.string.menu_compose_new).setIcon(
com.android.internal.R.drawable.ic_menu_compose);
// Removed search as part of b/1205708
//menu.add(0, MENU_SEARCH, 0, R.string.menu_search).setIcon(
// R.drawable.ic_menu_search).setAlphabeticShortcut(SearchManager.MENU_KEY);
if (mListAdapter.getCount() > 0 && !mSearchFlag) {
menu.add(0, MENU_DELETE_ALL, 0, R.string.menu_delete_all).setIcon(
android.R.drawable.ic_menu_delete);
}
menu.add(0, MENU_PREFERENCES, 0, R.string.menu_preferences).setIcon(
android.R.drawable.ic_menu_preferences);
return true;
|
protected void | onResume()
super.onResume();
DraftCache.getInstance().addOnDraftChangedListener(this);
getContentResolver().delete(Threads.OBSOLETE_THREADS_URI, null, null);
// Make sure the draft cache is up to date.
DraftCache.getInstance().refresh();
startAsyncQuery();
// force invalidate the contact info cache, so we will query for fresh info again.
// This is so we can get fresh presence info again on the screen, since the presence
// info changes pretty quickly, and we can't get change notifications when presence is
// updated in the ContactsProvider.
ContactInfoCache.getInstance().invalidateCache();
|
protected void | onSaveInstanceState(android.os.Bundle outState)
super.onSaveInstanceState(outState);
outState.putParcelable("base_uri", mBaseUri);
outState.putInt("query_token", mQueryToken);
outState.putBoolean("search_flag", mSearchFlag);
if (mSearchFlag) {
outState.putString("filter", mFilter);
}
|
protected void | onStop()
super.onStop();
mListAdapter.changeCursor(null);
|
private void | openThread(long threadId, java.lang.String address)
Intent intent = new Intent(this, ComposeMessageActivity.class);
intent.putExtra("thread_id", threadId);
if (!TextUtils.isEmpty(address)) {
intent.putExtra("address", address);
}
startActivity(intent);
|
private void | startAsyncQuery()
try {
setTitle(getString(R.string.refreshing));
setProgressBarIndeterminateVisibility(true);
mQueryHandler.cancelOperation(THREAD_LIST_QUERY_TOKEN);
mQueryHandler.startQuery(THREAD_LIST_QUERY_TOKEN, null, mBaseUri,
mProjection, mSelection, null, Conversations.DEFAULT_SORT_ORDER);
} catch (SQLiteException e) {
SqliteWrapper.checkSQLiteException(this, e);
}
|
private void | viewContact(java.lang.String address)
// address must be a single recipient
ContactInfoCache cache = ContactInfoCache.getInstance();
ContactInfoCache.CacheEntry info;
if (Mms.isEmailAddress(address)) {
info = cache.getContactInfoForEmailAddress(getApplicationContext(), address,
true /* allow query */);
} else {
info = cache.getContactInfo(this, address);
}
if (info != null && info.person_id > 0) {
Uri uri = ContentUris.withAppendedId(People.CONTENT_URI, info.person_id);
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
}
|