Search in sources :

Example 1 with ClipData

use of android.content.ClipData in project k-9 by k9mail.

the class ClipboardManager method setText.

/**
     * Copy a text string to the system clipboard
     *
     * @param label
     *         User-visible label for the content.
     * @param text
     *         The actual text to be copied to the clipboard.
     */
public void setText(String label, String text) {
    android.content.ClipboardManager clipboardManager = (android.content.ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
    ClipData clip = ClipData.newPlainText(label, text);
    clipboardManager.setPrimaryClip(clip);
}
Also used : ClipData(android.content.ClipData)

Example 2 with ClipData

use of android.content.ClipData in project android_frameworks_base by ParanoidAndroid.

the class ActivityManagerService method checkGrantUriPermissionFromIntentLocked.

/**
     * Like checkGrantUriPermissionLocked, but takes an Intent.
     */
NeededUriGrants checkGrantUriPermissionFromIntentLocked(int callingUid, String targetPkg, Intent intent, int mode, NeededUriGrants needed) {
    if (DEBUG_URI_PERMISSION)
        Slog.v(TAG, "Checking URI perm to data=" + (intent != null ? intent.getData() : null) + " clip=" + (intent != null ? intent.getClipData() : null) + " from " + intent + "; flags=0x" + Integer.toHexString(intent != null ? intent.getFlags() : 0));
    if (targetPkg == null) {
        throw new NullPointerException("targetPkg");
    }
    if (intent == null) {
        return null;
    }
    Uri data = intent.getData();
    ClipData clip = intent.getClipData();
    if (data == null && clip == null) {
        return null;
    }
    if (data != null) {
        int target = checkGrantUriPermissionLocked(callingUid, targetPkg, data, mode, needed != null ? needed.targetUid : -1);
        if (target > 0) {
            if (needed == null) {
                needed = new NeededUriGrants(targetPkg, target, mode);
            }
            needed.add(data);
        }
    }
    if (clip != null) {
        for (int i = 0; i < clip.getItemCount(); i++) {
            Uri uri = clip.getItemAt(i).getUri();
            if (uri != null) {
                int target = -1;
                target = checkGrantUriPermissionLocked(callingUid, targetPkg, uri, mode, needed != null ? needed.targetUid : -1);
                if (target > 0) {
                    if (needed == null) {
                        needed = new NeededUriGrants(targetPkg, target, mode);
                    }
                    needed.add(uri);
                }
            } else {
                Intent clipIntent = clip.getItemAt(i).getIntent();
                if (clipIntent != null) {
                    NeededUriGrants newNeeded = checkGrantUriPermissionFromIntentLocked(callingUid, targetPkg, clipIntent, mode, needed);
                    if (newNeeded != null) {
                        needed = newNeeded;
                    }
                }
            }
        }
    }
    return needed;
}
Also used : PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) Uri(android.net.Uri) ClipData(android.content.ClipData)

Example 3 with ClipData

use of android.content.ClipData in project WordPress-Android by wordpress-mobile.

the class Utils method getUrlFromClipboard.

/**
     * Checks the Clipboard for text that matches the {@link Patterns#WEB_URL} pattern.
     *
     * @return the URL text in the clipboard, if it exists; otherwise null
     */
public static String getUrlFromClipboard(Context context) {
    if (context == null)
        return null;
    ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
    ClipData data = clipboard != null ? clipboard.getPrimaryClip() : null;
    if (data == null || data.getItemCount() <= 0)
        return null;
    String clipText = String.valueOf(data.getItemAt(0).getText());
    return Patterns.WEB_URL.matcher(clipText).matches() ? clipText : null;
}
Also used : ClipboardManager(android.content.ClipboardManager) ClipData(android.content.ClipData)

Example 4 with ClipData

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

the class DocumentClipper method hasItemsToPaste.

public boolean hasItemsToPaste() {
    if (mClipboard.hasPrimaryClip()) {
        ClipData clipData = mClipboard.getPrimaryClip();
        int count = clipData.getItemCount();
        if (count > 0) {
            for (int i = 0; i < count; ++i) {
                ClipData.Item item = clipData.getItemAt(i);
                Uri uri = item.getUri();
                if (isDocumentUri(uri)) {
                    return true;
                }
            }
        }
    }
    return false;
}
Also used : ClipData(android.content.ClipData) Uri(android.net.Uri)

Example 5 with ClipData

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

the class DocumentClipper method clipDocuments.

public void clipDocuments(List<DocumentInfo> docs) {
    ClipData data = getClipDataForDocuments(docs);
    mClipboard.setPrimaryClip(data);
}
Also used : ClipData(android.content.ClipData)

Aggregations

ClipData (android.content.ClipData)343 ClipboardManager (android.content.ClipboardManager)190 Intent (android.content.Intent)83 Uri (android.net.Uri)65 View (android.view.View)38 MenuItem (android.view.MenuItem)34 TextView (android.widget.TextView)34 ArrayList (java.util.ArrayList)29 Paint (android.graphics.Paint)24 ImageView (android.widget.ImageView)20 Context (android.content.Context)19 DialogInterface (android.content.DialogInterface)19 PendingIntent (android.app.PendingIntent)16 Bundle (android.os.Bundle)16 RemoteException (android.os.RemoteException)14 SpannableStringBuilder (android.text.SpannableStringBuilder)14 SuppressLint (android.annotation.SuppressLint)12 TargetApi (android.annotation.TargetApi)12 Drawable (android.graphics.drawable.Drawable)11 RecyclerView (android.support.v7.widget.RecyclerView)11