Search in sources :

Example 1 with Conversation

use of com.android.mms.data.Conversation in project android-aosp-mms by slvn.

the class ComposeMessageActivity method onNewIntent.

@Override
protected void onNewIntent(Intent intent) {
    super.onNewIntent(intent);
    setIntent(intent);
    Conversation conversation = null;
    mSentMessage = false;
    // If we have been passed a thread_id, use that to find our
    // conversation.
    // Note that originalThreadId might be zero but if this is a draft and we save the
    // draft, ensureThreadId gets called async from WorkingMessage.asyncUpdateDraftSmsMessage
    // the thread will get a threadId behind the UI thread's back.
    long originalThreadId = mConversation.getThreadId();
    long threadId = intent.getLongExtra(THREAD_ID, 0);
    Uri intentUri = intent.getData();
    boolean sameThread = false;
    if (threadId > 0) {
        conversation = Conversation.get(this, threadId, false);
    } else {
        if (mConversation.getThreadId() == 0) {
            // We've got a draft. Make sure the working recipients are synched
            // to the conversation so when we compare conversations later in this function,
            // the compare will work.
            mWorkingMessage.syncWorkingRecipients();
        }
        // Get the "real" conversation based on the intentUri. The intentUri might specify
        // the conversation by a phone number or by a thread id. We'll typically get a threadId
        // based uri when the user pulls down a notification while in ComposeMessageActivity and
        // we end up here in onNewIntent. mConversation can have a threadId of zero when we're
        // working on a draft. When a new message comes in for that same recipient, a
        // conversation will get created behind CMA's back when the message is inserted into
        // the database and the corresponding entry made in the threads table. The code should
        // use the real conversation as soon as it can rather than finding out the threadId
        // when sending with "ensureThreadId".
        conversation = Conversation.get(this, intentUri, false);
    }
    if (LogTag.VERBOSE || Log.isLoggable(LogTag.APP, Log.VERBOSE)) {
        log("onNewIntent: data=" + intentUri + ", thread_id extra is " + threadId + ", new conversation=" + conversation + ", mConversation=" + mConversation);
    }
    // this is probably paranoid to compare both thread_ids and recipient lists,
    // but we want to make double sure because this is a last minute fix for Froyo
    // and the previous code checked thread ids only.
    // (we cannot just compare thread ids because there is a case where mConversation
    // has a stale/obsolete thread id (=1) that could collide against the new thread_id(=1),
    // even though the recipient lists are different)
    sameThread = ((conversation.getThreadId() == mConversation.getThreadId() || mConversation.getThreadId() == 0) && conversation.equals(mConversation));
    if (sameThread) {
        log("onNewIntent: same conversation");
        if (mConversation.getThreadId() == 0) {
            mConversation = conversation;
            mWorkingMessage.setConversation(mConversation);
            updateThreadIdIfRunning();
            invalidateOptionsMenu();
        }
    } else {
        if (LogTag.VERBOSE || Log.isLoggable(LogTag.APP, Log.VERBOSE)) {
            log("onNewIntent: different conversation");
        }
        // if we've got a draft, save it first
        saveDraft(false);
        initialize(null, originalThreadId);
    }
    loadMessagesAndDraft(0);
}
Also used : Conversation(com.android.mms.data.Conversation) Uri(android.net.Uri)

Example 2 with Conversation

use of com.android.mms.data.Conversation in project android-aosp-mms by slvn.

the class ConversationList method onListItemClick.

@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
    // Note: don't read the thread id data from the ConversationListItem view passed in.
    // It's unreliable to read the cached data stored in the view because the ListItem
    // can be recycled, and the same view could be assigned to a different position
    // if you click the list item fast enough. Instead, get the cursor at the position
    // clicked and load the data from the cursor.
    // (ConversationListAdapter extends CursorAdapter, so getItemAtPosition() should
    // return the cursor object, which is moved to the position passed in)
    Cursor cursor = (Cursor) getListView().getItemAtPosition(position);
    Conversation conv = Conversation.from(this, cursor);
    long tid = conv.getThreadId();
    if (LogTag.VERBOSE) {
        Log.d(TAG, "onListItemClick: pos=" + position + ", view=" + v + ", tid=" + tid);
    }
    openThread(tid);
}
Also used : Conversation(com.android.mms.data.Conversation) Cursor(android.database.Cursor)

Example 3 with Conversation

use of com.android.mms.data.Conversation 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);
}
Also used : Conversation(com.android.mms.data.Conversation) Intent(android.content.Intent) Cursor(android.database.Cursor) Contact(com.android.mms.data.Contact)

Example 4 with Conversation

use of com.android.mms.data.Conversation in project android-aosp-mms by slvn.

the class ConversationListAdapter method uncheckAll.

public void uncheckAll() {
    int count = getCount();
    for (int i = 0; i < count; i++) {
        Cursor cursor = (Cursor) getItem(i);
        Conversation conv = Conversation.from(mContext, cursor);
        conv.setIsChecked(false);
    }
}
Also used : Conversation(com.android.mms.data.Conversation) Cursor(android.database.Cursor)

Example 5 with Conversation

use of com.android.mms.data.Conversation in project android-aosp-mms by slvn.

the class ConversationListAdapter method bindView.

@Override
public void bindView(View view, Context context, Cursor cursor) {
    if (!(view instanceof ConversationListItem)) {
        Log.e(TAG, "Unexpected bound view: " + view);
        return;
    }
    ConversationListItem headerView = (ConversationListItem) view;
    Conversation conv = Conversation.from(context, cursor);
    headerView.bind(context, conv);
}
Also used : Conversation(com.android.mms.data.Conversation)

Aggregations

Conversation (com.android.mms.data.Conversation)7 Cursor (android.database.Cursor)3 ContactList (com.android.mms.data.ContactList)2 ActionBar (android.app.ActionBar)1 Intent (android.content.Intent)1 Uri (android.net.Uri)1 LargeTest (android.test.suitebuilder.annotation.LargeTest)1 Contact (com.android.mms.data.Contact)1 WorkingMessage (com.android.mms.data.WorkingMessage)1