Search in sources :

Example 6 with ClipDescription

use of android.content.ClipDescription in project android_frameworks_base by AOSPA.

the class RemoteInput method getResultsFromIntent.

/**
     * Get the remote input results bundle from an intent. The returned Bundle will
     * contain a key/value for every result key populated by remote input collector.
     * Use the {@link Bundle#getCharSequence(String)} method to retrieve a value.
     * @param intent The intent object that fired in response to an action or content intent
     *               which also had one or more remote input requested.
     */
public static Bundle getResultsFromIntent(Intent intent) {
    ClipData clipData = intent.getClipData();
    if (clipData == null) {
        return null;
    }
    ClipDescription clipDescription = clipData.getDescription();
    if (!clipDescription.hasMimeType(ClipDescription.MIMETYPE_TEXT_INTENT)) {
        return null;
    }
    if (clipDescription.getLabel().equals(RESULTS_CLIP_LABEL)) {
        return clipData.getItemAt(0).getIntent().getExtras().getParcelable(EXTRA_RESULTS_DATA);
    }
    return null;
}
Also used : ClipData(android.content.ClipData) ClipDescription(android.content.ClipDescription)

Example 7 with ClipDescription

use of android.content.ClipDescription in project android_frameworks_base by ResurrectionRemix.

the class RemoteInput method getResultsFromIntent.

/**
     * Get the remote input results bundle from an intent. The returned Bundle will
     * contain a key/value for every result key populated by remote input collector.
     * Use the {@link Bundle#getCharSequence(String)} method to retrieve a value.
     * @param intent The intent object that fired in response to an action or content intent
     *               which also had one or more remote input requested.
     */
public static Bundle getResultsFromIntent(Intent intent) {
    ClipData clipData = intent.getClipData();
    if (clipData == null) {
        return null;
    }
    ClipDescription clipDescription = clipData.getDescription();
    if (!clipDescription.hasMimeType(ClipDescription.MIMETYPE_TEXT_INTENT)) {
        return null;
    }
    if (clipDescription.getLabel().equals(RESULTS_CLIP_LABEL)) {
        return clipData.getItemAt(0).getIntent().getExtras().getParcelable(EXTRA_RESULTS_DATA);
    }
    return null;
}
Also used : ClipData(android.content.ClipData) ClipDescription(android.content.ClipDescription)

Example 8 with ClipDescription

use of android.content.ClipDescription in project android_frameworks_base by crdroidandroid.

the class RemoteInput method getResultsFromIntent.

/**
     * Get the remote input results bundle from an intent. The returned Bundle will
     * contain a key/value for every result key populated by remote input collector.
     * Use the {@link Bundle#getCharSequence(String)} method to retrieve a value.
     * @param intent The intent object that fired in response to an action or content intent
     *               which also had one or more remote input requested.
     */
public static Bundle getResultsFromIntent(Intent intent) {
    ClipData clipData = intent.getClipData();
    if (clipData == null) {
        return null;
    }
    ClipDescription clipDescription = clipData.getDescription();
    if (!clipDescription.hasMimeType(ClipDescription.MIMETYPE_TEXT_INTENT)) {
        return null;
    }
    if (clipDescription.getLabel().equals(RESULTS_CLIP_LABEL)) {
        return clipData.getItemAt(0).getIntent().getExtras().getParcelable(EXTRA_RESULTS_DATA);
    }
    return null;
}
Also used : ClipData(android.content.ClipData) ClipDescription(android.content.ClipDescription)

Example 9 with ClipDescription

use of android.content.ClipDescription in project krypton-android by kryptco.

the class MainActivity method checkClipboardForAppLinks.

private void checkClipboardForAppLinks() {
    ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
    if (clipboard == null) {
        return;
    }
    ClipData clipData = clipboard.getPrimaryClip();
    if (clipData == null) {
        return;
    }
    ClipData.Item item = clipData.getItemAt(0);
    if (item == null) {
        return;
    }
    CharSequence pasteData = item.getText();
    if (pasteData == null) {
        Uri pasteUri = item.getUri();
        if (pasteUri != null) {
            pasteData = pasteUri.toString();
        }
    }
    if (pasteData != null) {
        String pasteString = pasteData.toString();
        String[] toks = pasteString.split("\\s");
        for (String tok : toks) {
            if (tok.startsWith("krypton://")) {
                Uri uri = Uri.parse(tok);
                if (uri == null) {
                    continue;
                }
                // https://stackoverflow.com/questions/23418543/clear-all-clipboard-entries
                // Attempt to clear secret link from clipboard
                clipboard.setPrimaryClip(new ClipData(new ClipDescription("", new String[] {}), new ClipData.Item("")));
                AlertDialog alertDialog = new AlertDialog.Builder(this).create();
                alertDialog.setTitle("App Link Found on Clipboard");
                alertDialog.setMessage(uri.toString());
                alertDialog.setButton(AlertDialog.BUTTON_POSITIVE, "Process with Krypton", (dialog, which) -> {
                    dialog.dismiss();
                    Intent appLinkIntent = new Intent(this, TeamOnboardingActivity.class);
                    appLinkIntent.setAction("android.intent.action.VIEW");
                    appLinkIntent.setData(uri);
                    startActivity(appLinkIntent);
                });
                alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "Ignore", (dialog, which) -> dialog.dismiss());
                alertDialog.show();
                break;
            }
        }
    }
}
Also used : ClipboardManager(android.content.ClipboardManager) AlertDialog(android.support.v7.app.AlertDialog) Intent(android.content.Intent) ClipData(android.content.ClipData) Uri(android.net.Uri) ClipDescription(android.content.ClipDescription)

Example 10 with ClipDescription

use of android.content.ClipDescription in project AndroidUtilCode by Blankj.

the class ClipboardUtils method getLabel.

/**
 * Return the label for clipboard.
 *
 * @return the label for clipboard
 */
public static CharSequence getLabel() {
    ClipboardManager cm = (ClipboardManager) Utils.getApp().getSystemService(Context.CLIPBOARD_SERVICE);
    // noinspection ConstantConditions
    ClipDescription des = cm.getPrimaryClipDescription();
    if (des == null) {
        return "";
    }
    CharSequence label = des.getLabel();
    if (label == null) {
        return "";
    }
    return label;
}
Also used : ClipboardManager(android.content.ClipboardManager) ClipDescription(android.content.ClipDescription)

Aggregations

ClipDescription (android.content.ClipDescription)10 ClipData (android.content.ClipData)8 ClipboardManager (android.content.ClipboardManager)2 Uri (android.net.Uri)2 Intent (android.content.Intent)1 Paint (android.graphics.Paint)1 Point (android.graphics.Point)1 AlertDialog (android.support.v7.app.AlertDialog)1 Editable (android.text.Editable)1 SpannableString (android.text.SpannableString)1 TextPaint (android.text.TextPaint)1 Snackbar (com.google.android.material.snackbar.Snackbar)1 AddressFormatException (org.bitcoinj.core.AddressFormatException)1 BitcoinURI (org.bitcoinj.uri.BitcoinURI)1 BitcoinURIParseException (org.bitcoinj.uri.BitcoinURIParseException)1