Example usage for android.net Uri getSchemeSpecificPart

List of usage examples for android.net Uri getSchemeSpecificPart

Introduction

In this page you can find the example usage for android.net Uri getSchemeSpecificPart.

Prototype

public abstract String getSchemeSpecificPart();

Source Link

Document

Gets the scheme-specific part of this URI, i.e. everything between the scheme separator ':' and the fragment separator '#'.

Usage

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

/**
 * Fill all the widgets with the content found in the Intent Extra, if any.
 * Also apply the same style to all widgets. Note: if initFromExtras is
 * called as a result of switching between reply, reply all, and forward per
 * the latest revision of Gmail, and the user has already made changes to
 * attachments on a previous incarnation of the message (as a reply, reply
 * all, or forward), the original attachments from the message will not be
 * re-instantiated. The user's changes will be respected. This follows the
 * web gmail interaction./* ww w.ja  v  a2s  .  c  o  m*/
 * @return {@code true} if the activity should not call {@link #finishSetup}.
 */
public boolean initFromExtras(Intent intent) {
    // If we were invoked with a SENDTO intent, the value
    // should take precedence
    final Uri dataUri = intent.getData();
    if (dataUri != null) {
        if (MAIL_TO.equals(dataUri.getScheme())) {
            initFromMailTo(dataUri.toString());
        } else {
            if (!mAccount.composeIntentUri.equals(dataUri)) {
                String toText = dataUri.getSchemeSpecificPart();
                if (toText != null) {
                    mTo.setText("");
                    addToAddresses(Arrays.asList(TextUtils.split(toText, ",")));
                }
            }
        }
    }

    String[] extraStrings = intent.getStringArrayExtra(Intent.EXTRA_EMAIL);
    if (extraStrings != null) {
        addToAddresses(Arrays.asList(extraStrings));
    }
    extraStrings = intent.getStringArrayExtra(Intent.EXTRA_CC);
    if (extraStrings != null) {
        addCcAddresses(Arrays.asList(extraStrings), null);
    }
    extraStrings = intent.getStringArrayExtra(Intent.EXTRA_BCC);
    if (extraStrings != null) {
        addBccAddresses(Arrays.asList(extraStrings));
    }

    String extraString = intent.getStringExtra(Intent.EXTRA_SUBJECT);
    if (extraString != null) {
        mSubject.setText(extraString);
    }

    for (String extra : ALL_EXTRAS) {
        if (intent.hasExtra(extra)) {
            String value = intent.getStringExtra(extra);
            if (EXTRA_TO.equals(extra)) {
                addToAddresses(Arrays.asList(TextUtils.split(value, ",")));
            } else if (EXTRA_CC.equals(extra)) {
                addCcAddresses(Arrays.asList(TextUtils.split(value, ",")), null);
            } else if (EXTRA_BCC.equals(extra)) {
                addBccAddresses(Arrays.asList(TextUtils.split(value, ",")));
            } else if (EXTRA_SUBJECT.equals(extra)) {
                mSubject.setText(value);
            } else if (EXTRA_BODY.equals(extra)) {
                setBody(value, true /* with signature */);
            } else if (EXTRA_QUOTED_TEXT.equals(extra)) {
                initQuotedText(value, true /* shouldQuoteText */);
            }
        }
    }

    Bundle extras = intent.getExtras();
    if (extras != null) {
        CharSequence text = extras.getCharSequence(Intent.EXTRA_TEXT);
        setBody((text != null) ? text : "", true /* with signature */);

        // TODO - support EXTRA_HTML_TEXT
    }

    mExtraValues = intent.getParcelableExtra(EXTRA_VALUES);
    if (mExtraValues != null) {
        LogUtils.d(LOG_TAG, "Launched with extra values: %s", mExtraValues.toString());
        initExtraValues(mExtraValues);
        return true;
    }

    return false;
}

From source file:com.android.mms.ui.ComposeMessageActivity.java

private String getBody(Uri uri) {
    if (uri == null) {
        return null;
    }/* ww  w.j  av  a  2  s. c  o m*/
    String urlStr = uri.getSchemeSpecificPart();
    if (!urlStr.contains("?")) {
        return null;
    }
    urlStr = urlStr.substring(urlStr.indexOf('?') + 1);
    String[] params = urlStr.split("&");
    for (String p : params) {
        if (p.startsWith("body=")) {
            try {
                return URLDecoder.decode(p.substring(5), "UTF-8");
            } catch (UnsupportedEncodingException e) {
            }
        }
    }
    return null;
}

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

/**
 * Fill all the widgets with the content found in the Intent Extra, if any.
 * Also apply the same style to all widgets. Note: if initFromExtras is
 * called as a result of switching between reply, reply all, and forward per
 * the latest revision of Gmail, and the user has already made changes to
 * attachments on a previous incarnation of the message (as a reply, reply
 * all, or forward), the original attachments from the message will not be
 * re-instantiated. The user's changes will be respected. This follows the
 * web gmail interaction./*  w  w  w .  j  a va  2s .c o  m*/
 * @return {@code true} if the activity should not call {@link #finishSetup}.
 */
public boolean initFromExtras(Intent intent) {
    // If we were invoked with a SENDTO intent, the value
    // should take precedence
    final Uri dataUri = intent.getData();
    if (dataUri != null) {
        if (MAIL_TO.equals(dataUri.getScheme())) {
            initFromMailTo(dataUri.toString());
        } else {
            if (!mAccount.composeIntentUri.equals(dataUri)) {
                String toText = dataUri.getSchemeSpecificPart();
                // TS: junwei-xu 2015-03-23 EMAIL BUGFIX_980239 MOD_S
                //if (toText != null) {
                if (Address.isAllValid(toText)) {
                    // TS: junwei-xu 2015-04-23 EMAIL BUGFIX_980239 MOD_E
                    mTo.setText("");
                    addToAddresses(Arrays.asList(TextUtils.split(toText, ",")));
                }
            }
        }
    }

    String[] extraStrings = intent.getStringArrayExtra(Intent.EXTRA_EMAIL);
    if (extraStrings != null) {
        addToAddresses(Arrays.asList(extraStrings));
    }
    extraStrings = intent.getStringArrayExtra(Intent.EXTRA_CC);
    if (extraStrings != null) {
        addCcAddresses(Arrays.asList(extraStrings), null);
    }
    extraStrings = intent.getStringArrayExtra(Intent.EXTRA_BCC);
    if (extraStrings != null) {
        addBccAddresses(Arrays.asList(extraStrings));
    }

    String extraString = intent.getStringExtra(Intent.EXTRA_SUBJECT);
    if (extraString != null) {
        mSubject.setText(extraString);
    }

    for (String extra : ALL_EXTRAS) {
        if (intent.hasExtra(extra)) {
            String value = intent.getStringExtra(extra);
            if (EXTRA_TO.equals(extra)) {
                addToAddresses(Arrays.asList(TextUtils.split(value, ",")));
            } else if (EXTRA_CC.equals(extra)) {
                addCcAddresses(Arrays.asList(TextUtils.split(value, ",")), null);
            } else if (EXTRA_BCC.equals(extra)) {
                addBccAddresses(Arrays.asList(TextUtils.split(value, ",")));
            } else if (EXTRA_SUBJECT.equals(extra)) {
                mSubject.setText(value);
            } else if (EXTRA_BODY.equals(extra)) {
                //[BUGFIX]-Add-BEGINbySCDTABLET.yafang.wei,07/21/2016,2565329
                // Modifytofixsignatureshowsbeforebodyissuewhensharewebsitebyemail
                if (mBodyView.getText().toString().trim()
                        .equals(convertToPrintableSignature(mSignature).trim())) {
                    mBodyView.setText("");
                    setBody(value, true /* with signature */);
                    appendSignature();
                } else {
                    setBody(value, true /* with signature */);
                }
                //[BUGFIX]-Add-ENDbySCDTABLET.yafang.wei
            } else if (EXTRA_QUOTED_TEXT.equals(extra)) {
                initQuotedText(value, true /* shouldQuoteText */);
            }
        }
    }

    Bundle extras = intent.getExtras();
    //[BUGFIX]-MOD-BEGIN by TSNJ,wenlu.wu,10/20/2014,FR-739335
    if (extras != null && !mBodyAlreadySet) {
        //[BUGFIX]-MOD-END by TSNJ,wenlu.wu,10/20/2014,FR-739335
        CharSequence text = extras.getCharSequence(Intent.EXTRA_TEXT);
        //[BUGFIX]-Add-BEGINbySCDTABLET.yafang.wei,07/21/2016,2565329
        // Modifytofixsignatureshowsbeforebodyissuewhensharewebsitebyemail
        if (mBodyView.getText().toString().trim().equals(convertToPrintableSignature(mSignature).trim())) {
            mBodyView.setText("");
            setBody((text != null) ? text : "", true /* with signature */);
            appendSignature();
        } else {
            setBody((text != null) ? text : "", true /* with signature */);
        }
        //[BUGFIX]-Add-ENDbySCDTABLET.yafang.wei

        // TODO - support EXTRA_HTML_TEXT
    }

    mExtraValues = intent.getParcelableExtra(EXTRA_VALUES);
    if (mExtraValues != null) {
        LogUtils.d(LOG_TAG, "Launched with extra values: %s", mExtraValues.toString());
        initExtraValues(mExtraValues);
        return true;
    }

    return false;
}