Example usage for android.content ClipData getItemAt

List of usage examples for android.content ClipData getItemAt

Introduction

In this page you can find the example usage for android.content ClipData getItemAt.

Prototype

public Item getItemAt(int index) 

Source Link

Document

Return a single item inside of the clip data.

Usage

From source file:com.android.ex.chips.RecipientEditTextView.java

/**
 * Handles pasting a {@link ClipData} to this {@link RecipientEditTextView}.
 *//*from   www .  j av  a2 s. c o  m*/
private void handlePasteClip(final ClipData clip) {
    removeTextChangedListener(mTextWatcher);
    if (clip != null && clip.getDescription().hasMimeType(ClipDescription.MIMETYPE_TEXT_PLAIN))
        for (int i = 0; i < clip.getItemCount(); i++) {
            final CharSequence paste = clip.getItemAt(i).getText();
            if (paste != null) {
                final int start = getSelectionStart();
                final int end = getSelectionEnd();
                final Editable editable = getText();
                if (start >= 0 && end >= 0 && start != end)
                    editable.append(paste, start, end);
                else
                    editable.insert(end, paste);
                handlePasteAndReplace();
            }
        }
    mHandler.post(mAddTextWatcher);
}

From source file:org.kontalk.ui.ComposeMessageFragment.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    // image from storage/picture from camera
    // since there are like up to 3 different ways of doing this...
    if (requestCode == SELECT_ATTACHMENT_OPENABLE || requestCode == SELECT_ATTACHMENT_PHOTO) {
        if (resultCode == Activity.RESULT_OK) {
            Uri[] uris = null;/* ww  w.ja va 2s.  c om*/
            String[] mimes = null;

            // returning from camera
            if (data == null) {
                if (mCurrentPhoto != null) {
                    Uri uri = Uri.fromFile(mCurrentPhoto);
                    // notify media scanner
                    Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
                    mediaScanIntent.setData(uri);
                    getActivity().sendBroadcast(mediaScanIntent);
                    mCurrentPhoto = null;

                    uris = new Uri[] { uri };
                }
            } else {
                if (mCurrentPhoto != null) {
                    mCurrentPhoto.delete();
                    mCurrentPhoto = null;
                }

                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN && data.getClipData() != null) {
                    ClipData cdata = data.getClipData();
                    uris = new Uri[cdata.getItemCount()];

                    for (int i = 0; i < uris.length; i++) {
                        ClipData.Item item = cdata.getItemAt(i);
                        uris[i] = item.getUri();
                    }
                } else {
                    uris = new Uri[] { data.getData() };
                    mimes = new String[] { data.getType() };
                }

                // SAF available, request persistable permissions
                if (MediaStorage.isStorageAccessFrameworkAvailable()) {
                    for (Uri uri : uris) {
                        if (uri != null && !"file".equals(uri.getScheme())) {
                            MediaStorage.requestPersistablePermissions(getActivity(), uri);
                        }
                    }
                }
            }

            for (int i = 0; uris != null && i < uris.length; i++) {
                Uri uri = uris[i];
                String mime = (mimes != null && mimes.length >= uris.length) ? mimes[i] : null;

                if (mime == null || mime.startsWith("*/") || mime.endsWith("/*")) {
                    mime = MediaStorage.getType(getActivity(), uri);
                    Log.v(TAG, "using detected mime type " + mime);
                }

                if (ImageComponent.supportsMimeType(mime))
                    sendBinaryMessage(uri, mime, true, ImageComponent.class);
                else if (VCardComponent.supportsMimeType(mime))
                    sendBinaryMessage(uri, VCardComponent.MIME_TYPE, false, VCardComponent.class);
                else
                    Toast.makeText(getActivity(), R.string.send_mime_not_supported, Toast.LENGTH_LONG).show();
            }
        }
        // operation aborted
        else {
            // delete photo :)
            if (mCurrentPhoto != null) {
                mCurrentPhoto.delete();
                mCurrentPhoto = null;
            }
        }
    }
    // contact card (vCard)
    else if (requestCode == SELECT_ATTACHMENT_CONTACT) {
        if (resultCode == Activity.RESULT_OK) {
            Uri uri = data.getData();
            if (uri != null) {
                // get lookup key
                final Cursor c = getActivity().getContentResolver().query(uri,
                        new String[] { Contacts.LOOKUP_KEY }, null, null, null);
                if (c != null) {
                    try {
                        c.moveToFirst();
                        String lookupKey = c.getString(0);
                        Uri vcardUri = Uri.withAppendedPath(Contacts.CONTENT_VCARD_URI, lookupKey);
                        sendBinaryMessage(vcardUri, VCardComponent.MIME_TYPE, false, VCardComponent.class);
                    } finally {
                        c.close();
                    }
                }
            }
        }
    }
}

From source file:org.mdc.chess.MDChess.java

private void clipBoardDialog() {
    final int COPY_GAME = 0;
    final int COPY_POSITION = 1;
    final int PASTE = 2;

    setAutoMode(AutoMode.OFF);//from  w  ww.  jav a  2 s .  com
    List<CharSequence> lst = new ArrayList<>();
    List<Integer> actions = new ArrayList<>();
    lst.add(getString(R.string.copy_game));
    actions.add(COPY_GAME);
    lst.add(getString(R.string.copy_position));
    actions.add(COPY_POSITION);
    lst.add(getString(R.string.paste));
    actions.add(PASTE);
    final List<Integer> finalActions = actions;
    new MaterialDialog.Builder(this).title(R.string.tools_menu).items(lst)
            .itemsCallback(new MaterialDialog.ListCallback() {
                @Override
                public void onSelection(MaterialDialog dialog, View view, int which, CharSequence text) {
                    switch (finalActions.get(which)) {
                    case COPY_GAME: {
                        String pgn = ctrl.getPGN();
                        ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
                        clipboard.setPrimaryClip(new ClipData("MD Chess game",
                                new String[] { "application/x-chess-pgn", ClipDescription.MIMETYPE_TEXT_PLAIN },
                                new ClipData.Item(pgn)));
                        break;
                    }
                    case COPY_POSITION: {
                        String fen = ctrl.getFEN() + "\n";
                        ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
                        clipboard.setPrimaryClip(new ClipData(fen,
                                new String[] { "application/x-chess-fen", ClipDescription.MIMETYPE_TEXT_PLAIN },
                                new ClipData.Item(fen)));
                        break;
                    }
                    case PASTE: {
                        ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
                        if (clipboard.hasPrimaryClip()) {
                            ClipData clip = clipboard.getPrimaryClip();
                            StringBuilder fenPgn = new StringBuilder();
                            for (int i = 0; i < clip.getItemCount(); i++) {
                                fenPgn.append(clip.getItemAt(i).coerceToText(getApplicationContext()));
                            }
                            try {
                                ctrl.setFENOrPGN(fenPgn.toString());
                                setBoardFlip(true);
                            } catch (ChessParseError e) {
                                Toast.makeText(getApplicationContext(), getParseErrString(e),
                                        Toast.LENGTH_SHORT).show();
                            }
                        }
                        break;
                    }
                    }
                }
            }).show();
}

From source file:com.android.mail.compose.ComposeActivity.java

/**
 * Add attachment and update the compose area appropriately.
 */// w  w w. jav a  2 s. c om
private void addAttachmentAndUpdateView(Intent data) {
    if (data == null) {
        return;
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        final ClipData clipData = data.getClipData();
        if (clipData != null) {
            for (int i = 0, size = clipData.getItemCount(); i < size; i++) {
                addAttachmentAndUpdateView(clipData.getItemAt(i).getUri());
            }
            return;
        }
    }

    addAttachmentAndUpdateView(data.getData());
}

From source file:com.android.mail.compose.ComposeActivity.java

private void finishCreate() {
    final Bundle savedState = mInnerSavedState;
    findViews();/*  ww w  . j a  va 2s . co  m*/
    final Intent intent = getIntent();
    final Message message;
    final ArrayList<AttachmentPreview> previews;
    mShowQuotedText = false;
    final CharSequence quotedText;
    int action;
    // Check for any of the possibly supplied accounts.;
    final Account account;
    if (hadSavedInstanceStateMessage(savedState)) {
        action = savedState.getInt(EXTRA_ACTION, COMPOSE);
        account = savedState.getParcelable(Utils.EXTRA_ACCOUNT);
        message = savedState.getParcelable(EXTRA_MESSAGE);

        previews = savedState.getParcelableArrayList(EXTRA_ATTACHMENT_PREVIEWS);
        mRefMessage = savedState.getParcelable(EXTRA_IN_REFERENCE_TO_MESSAGE);
        quotedText = savedState.getCharSequence(EXTRA_QUOTED_TEXT);

        mExtraValues = savedState.getParcelable(EXTRA_VALUES);

        // Get the draft id from the request id if there is one.
        if (savedState.containsKey(EXTRA_REQUEST_ID)) {
            final int requestId = savedState.getInt(EXTRA_REQUEST_ID);
            if (sRequestMessageIdMap.containsKey(requestId)) {
                synchronized (mDraftLock) {
                    mDraftId = sRequestMessageIdMap.get(requestId);
                }
            }
        }
    } else {
        account = obtainAccount(intent);
        action = intent.getIntExtra(EXTRA_ACTION, COMPOSE);
        // Initialize the message from the message in the intent
        message = intent.getParcelableExtra(ORIGINAL_DRAFT_MESSAGE);
        previews = intent.getParcelableArrayListExtra(EXTRA_ATTACHMENT_PREVIEWS);
        mRefMessage = intent.getParcelableExtra(EXTRA_IN_REFERENCE_TO_MESSAGE);
        mRefMessageUri = intent.getParcelableExtra(EXTRA_IN_REFERENCE_TO_MESSAGE_URI);
        quotedText = null;

        if (Analytics.isLoggable()) {
            if (intent.getBooleanExtra(Utils.EXTRA_FROM_NOTIFICATION, false)) {
                Analytics.getInstance().sendEvent("notification_action", "compose", getActionString(action), 0);
            }
        }
    }
    mAttachmentsView.setAttachmentPreviews(previews);

    setAccount(account);
    if (mAccount == null) {
        return;
    }

    initRecipients();

    // Clear the notification and mark the conversation as seen, if necessary
    final Folder notificationFolder = intent.getParcelableExtra(EXTRA_NOTIFICATION_FOLDER);

    if (notificationFolder != null) {
        final Uri conversationUri = intent.getParcelableExtra(EXTRA_NOTIFICATION_CONVERSATION);
        Intent actionIntent;
        if (conversationUri != null) {
            actionIntent = new Intent(MailIntentService.ACTION_RESEND_NOTIFICATIONS_WEAR);
            actionIntent.putExtra(Utils.EXTRA_CONVERSATION, conversationUri);
        } else {
            actionIntent = new Intent(MailIntentService.ACTION_CLEAR_NEW_MAIL_NOTIFICATIONS);
            actionIntent.setData(Utils.appendVersionQueryParameter(this, notificationFolder.folderUri.fullUri));
        }
        actionIntent.setPackage(getPackageName());
        actionIntent.putExtra(Utils.EXTRA_ACCOUNT, account);
        actionIntent.putExtra(Utils.EXTRA_FOLDER, notificationFolder);

        startService(actionIntent);
    }

    if (intent.getBooleanExtra(EXTRA_FROM_EMAIL_TASK, false)) {
        mLaunchedFromEmail = true;
    } else if (Intent.ACTION_SEND.equals(intent.getAction())) {
        final Uri dataUri = intent.getData();
        if (dataUri != null) {
            final String dataScheme = intent.getData().getScheme();
            final String accountScheme = mAccount.composeIntentUri.getScheme();
            mLaunchedFromEmail = TextUtils.equals(dataScheme, accountScheme);
        }
    }

    if (mRefMessageUri != null) {
        mShowQuotedText = true;
        mComposeMode = action;

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            Bundle remoteInput = RemoteInput.getResultsFromIntent(intent);
            String wearReply = null;
            if (remoteInput != null) {
                LogUtils.d(LOG_TAG, "Got remote input from new api");
                CharSequence input = remoteInput.getCharSequence(NotificationActionUtils.WEAR_REPLY_INPUT);
                if (input != null) {
                    wearReply = input.toString();
                }
            } else {
                // TODO: remove after legacy code has been removed.
                LogUtils.d(LOG_TAG, "No remote input from new api, falling back to compatibility mode");
                ClipData clipData = intent.getClipData();
                if (clipData != null && LEGACY_WEAR_EXTRA.equals(clipData.getDescription().getLabel())) {
                    Bundle extras = clipData.getItemAt(0).getIntent().getExtras();
                    if (extras != null) {
                        wearReply = extras.getString(NotificationActionUtils.WEAR_REPLY_INPUT);
                    }
                }
            }

            if (!TextUtils.isEmpty(wearReply)) {
                createWearReplyTask(this, mRefMessageUri, UIProvider.MESSAGE_PROJECTION, mComposeMode,
                        wearReply).execute();
                finish();
                return;
            } else {
                LogUtils.w(LOG_TAG, "remote input string is null");
            }
        }

        getLoaderManager().initLoader(INIT_DRAFT_USING_REFERENCE_MESSAGE, null, this);
        return;
    } else if (message != null && action != EDIT_DRAFT) {
        initFromDraftMessage(message);
        initQuotedTextFromRefMessage(mRefMessage, action);
        mShowQuotedText = message.appendRefMessageContent;
        // if we should be showing quoted text but mRefMessage is null
        // and we have some quotedText, display that
        if (mShowQuotedText && mRefMessage == null) {
            if (quotedText != null) {
                initQuotedText(quotedText, false /* shouldQuoteText */);
            } else if (mExtraValues != null) {
                initExtraValues(mExtraValues);
                return;
            }
        }
    } else if (action == EDIT_DRAFT) {
        if (message == null) {
            throw new IllegalStateException("Message must not be null to edit draft");
        }
        initFromDraftMessage(message);
        // Update the action to the draft type of the previous draft
        switch (message.draftType) {
        case UIProvider.DraftType.REPLY:
            action = REPLY;
            break;
        case UIProvider.DraftType.REPLY_ALL:
            action = REPLY_ALL;
            break;
        case UIProvider.DraftType.FORWARD:
            action = FORWARD;
            break;
        case UIProvider.DraftType.COMPOSE:
        default:
            action = COMPOSE;
            break;
        }
        LogUtils.d(LOG_TAG, "Previous draft had action type: %d", action);

        mShowQuotedText = message.appendRefMessageContent;
        if (message.refMessageUri != null) {
            // If we're editing an existing draft that was in reference to an existing message,
            // still need to load that original message since we might need to refer to the
            // original sender and recipients if user switches "reply <-> reply-all".
            mRefMessageUri = message.refMessageUri;
            mComposeMode = action;
            getLoaderManager().initLoader(REFERENCE_MESSAGE_LOADER, null, this);
            return;
        }
    } else if ((action == REPLY || action == REPLY_ALL || action == FORWARD)) {
        if (mRefMessage != null) {
            initFromRefMessage(action);
            mShowQuotedText = true;
        }
    } else {
        if (initFromExtras(intent)) {
            return;
        }
    }

    mComposeMode = action;
    finishSetup(action, intent, savedState);
}

From source file:com.tct.mail.compose.ComposeActivity.java

private void finishCreate() {
    final Bundle savedState = mInnerSavedState;
    findViews();/*from  www .  ja v  a  2 s  .c  o m*/
    // TS: junwei-xu 2015-09-01 EMAIL BUGFIX-526192 ADD_S
    updateFromRowByAccounts();
    // TS: junwei-xu 2015-09-01 EMAIL BUGFIX-526192 ADD_E
    final Intent intent = getIntent();
    final Message message;
    final ArrayList<AttachmentPreview> previews;
    mShowQuotedText = false;
    final CharSequence quotedText;
    int action;
    // Check for any of the possibly supplied accounts.;
    final Account account;
    if (hadSavedInstanceStateMessage(savedState)) {
        action = savedState.getInt(EXTRA_ACTION, COMPOSE);
        account = savedState.getParcelable(Utils.EXTRA_ACCOUNT);
        message = savedState.getParcelable(EXTRA_MESSAGE);

        previews = savedState.getParcelableArrayList(EXTRA_ATTACHMENT_PREVIEWS);
        mRefMessage = savedState.getParcelable(EXTRA_IN_REFERENCE_TO_MESSAGE);
        quotedText = savedState.getCharSequence(EXTRA_QUOTED_TEXT);

        mExtraValues = savedState.getParcelable(EXTRA_VALUES);
    } else {
        account = obtainAccount(intent);
        action = intent.getIntExtra(EXTRA_ACTION, COMPOSE);
        // Initialize the message from the message in the intent
        message = intent.getParcelableExtra(ORIGINAL_DRAFT_MESSAGE);
        previews = intent.getParcelableArrayListExtra(EXTRA_ATTACHMENT_PREVIEWS);
        mRefMessage = intent.getParcelableExtra(EXTRA_IN_REFERENCE_TO_MESSAGE);
        //TS: wenggangjin 2015-01-06 EMAIL BUGFIX_882161 MOD_S
        if (mRefMessage != null && "".equals(mRefMessage.bodyHtml)) {
            String htmlbody = Body.restoreBodyHtmlWithMessageId(this, mRefMessage.getId());
            mRefMessage.bodyHtml = htmlbody;
            //TS: xujian 2015-06-23 EMAIL BUGFIX_1015657 MOD_S
        } else if (message != null) {
            if ("".equals(message.bodyHtml)) {
                String htmlbody = Body.restoreBodyHtmlWithMessageId(this, message.getId());
                message.bodyHtml = htmlbody;
            }
            if ("".equals(message.bodyText)) {
                String body = Body.restoreBodyTextWithMessageId(this, message.getId());
                message.bodyText = body;
            }
            //TS: xujian 2015-06-23 EMAIL BUGFIX_1015657 MOD_S
        }
        //TS: wenggangjin 2015-01-06 EMAIL BUGFIX_882161 MOD_E
        mRefMessageUri = intent.getParcelableExtra(EXTRA_IN_REFERENCE_TO_MESSAGE_URI);
        quotedText = null;

        if (Analytics.isLoggable()) {
            if (intent.getBooleanExtra(Utils.EXTRA_FROM_NOTIFICATION, false)) {
                Analytics.getInstance().sendEvent("notification_action", "compose", getActionString(action), 0);
            }
        }
    }
    //TS: Gantao 2015-08-27 EMAIL FEATURE_ID DEL_S
    //        mAttachmentsView.setAttachmentPreviews(previews);
    //TS: Gantao 2015-08-27 EMAIL FEATURE_ID DEL_E
    // TS: yanhua.chen 2015-9-19 EMAIL BUGFIX_569665 ADD_S
    if (action == EDIT_DRAFT) {
        //mIsClickIcon = true;//[BUGFIX]-MOD by SCDTABLET.shujing.jin@tcl.com,05/06/2016,2013535
        mEditDraft = true;
    }
    // TS: yanhua.chen 2015-9-19 EMAIL BUGFIX_569665 ADD_E

    setAccount(account);
    if (mAccount == null) {
        return;
    }
    // TS: chenyanhua 2015-01-12 EMAIL BUGFIX-890424 MOD_S
    //        initRecipients();
    // TS: chenyanhua 2015-01-12 EMAIL BUGFIX-890424 MOD_S
    // Clear the notification and mark the conversation as seen, if necessary
    final Folder notificationFolder = intent.getParcelableExtra(EXTRA_NOTIFICATION_FOLDER);

    if (notificationFolder != null) {
        final Uri conversationUri = intent.getParcelableExtra(EXTRA_NOTIFICATION_CONVERSATION);
        Intent actionIntent;
        if (conversationUri != null) {
            actionIntent = new Intent(MailIntentService.ACTION_RESEND_NOTIFICATIONS_WEAR);
            actionIntent.putExtra(Utils.EXTRA_CONVERSATION, conversationUri);
        } else {
            actionIntent = new Intent(MailIntentService.ACTION_CLEAR_NEW_MAIL_NOTIFICATIONS);
            actionIntent.setData(Utils.appendVersionQueryParameter(this, notificationFolder.folderUri.fullUri));
        }
        actionIntent.setPackage(getPackageName());
        actionIntent.putExtra(Utils.EXTRA_ACCOUNT, account);
        actionIntent.putExtra(Utils.EXTRA_FOLDER, notificationFolder);

        startService(actionIntent);
    }

    if (intent.getBooleanExtra(EXTRA_FROM_EMAIL_TASK, false)) {
        mLaunchedFromEmail = true;
    } else if (Intent.ACTION_SEND.equals(intent.getAction())) {
        final Uri dataUri = intent.getData();
        if (dataUri != null) {
            final String dataScheme = intent.getData().getScheme();
            final String accountScheme = mAccount.composeIntentUri.getScheme();
            mLaunchedFromEmail = TextUtils.equals(dataScheme, accountScheme);
        }
    }

    if (mRefMessageUri != null) {
        mShowQuotedText = true;
        mComposeMode = action;

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            Bundle remoteInput = RemoteInput.getResultsFromIntent(intent);
            String wearReply = null;
            if (remoteInput != null) {
                LogUtils.d(LOG_TAG, "Got remote input from new api");
                CharSequence input = remoteInput.getCharSequence(NotificationActionUtils.WEAR_REPLY_INPUT);
                if (input != null) {
                    wearReply = input.toString();
                }
            } else {
                // TODO: remove after legacy code has been removed.
                LogUtils.d(LOG_TAG, "No remote input from new api, falling back to compatibility mode");
                ClipData clipData = intent.getClipData();
                if (clipData != null && LEGACY_WEAR_EXTRA.equals(clipData.getDescription().getLabel())) {
                    Bundle extras = clipData.getItemAt(0).getIntent().getExtras();
                    if (extras != null) {
                        wearReply = extras.getString(NotificationActionUtils.WEAR_REPLY_INPUT);
                    }
                }
            }

            if (!TextUtils.isEmpty(wearReply)) {
                createWearReplyTask(this, mRefMessageUri, UIProvider.MESSAGE_PROJECTION, mComposeMode,
                        wearReply).execute();
                finish();
                return;
            } else {
                LogUtils.w(LOG_TAG, "remote input string is null");
            }
        }

        getLoaderManager().initLoader(INIT_DRAFT_USING_REFERENCE_MESSAGE, null, this);
        return;
    } else if (message != null && action != EDIT_DRAFT) {
        initFromDraftMessage(message);
        initQuotedTextFromRefMessage(mRefMessage, action);
        mShowQuotedText = message.appendRefMessageContent;
        // if we should be showing quoted text but mRefMessage is null
        // and we have some quotedText, display that
        if (mShowQuotedText && mRefMessage == null) {
            if (quotedText != null) {
                initQuotedText(quotedText, false /* shouldQuoteText */);
            } else if (mExtraValues != null) {
                initExtraValues(mExtraValues);
                return;
            }
        }
    } else if (action == EDIT_DRAFT) {
        if (message == null) {
            throw new IllegalStateException("Message must not be null to edit draft");
        }
        initFromDraftMessage(message);
        // Update the action to the draft type of the previous draft
        switch (message.draftType) {
        case UIProvider.DraftType.REPLY:
            action = REPLY;
            break;
        case UIProvider.DraftType.REPLY_ALL:
            action = REPLY_ALL;
            break;
        case UIProvider.DraftType.FORWARD:
            action = FORWARD;
            break;
        case UIProvider.DraftType.COMPOSE:
        default:
            action = COMPOSE;
            break;
        }
        LogUtils.d(LOG_TAG, "Previous draft had action type: %d", action);

        mShowQuotedText = message.appendRefMessageContent;
        //TS: Gantao 2015-07-28 EMAIL BUGFIX_1053829 MOD_S
        //Terrible original design,refMessageUri did not save to db,the value is always 0 here.
        //but the body's sourceKey is saved ,it points to the refMessage's id,so we can get
        //the refMessage from the body's sourceKey.
        long sourceKey = Body.restoreBodySourceKey(this, message.id);
        if (sourceKey != 0) {
            // If we're editing an existing draft that was in reference to an existing message,
            // still need to load that original message since we might need to refer to the
            // original sender and recipients if user switches "reply <-> reply-all".
            mRefMessageUri = Uri.parse("content://" + EmailContent.AUTHORITY + "/uimessage/" + sourceKey);
            //TS: Gantao 2015-07-28 EMAIL BUGFIX_1053829 MOD_E
            mComposeMode = action;
            getLoaderManager().initLoader(REFERENCE_MESSAGE_LOADER, null, this);
            return;
        }
    } else if ((action == REPLY || action == REPLY_ALL || action == FORWARD)) {
        if (mRefMessage != null) {
            initFromRefMessage(action);
            mShowQuotedText = true;
        }
    } else {
        if (initFromExtras(intent)) {
            return;
        }
    }

    mComposeMode = action;
    finishSetup(action, intent, savedState);
}