Search in sources :

Example 6 with ClipData

use of android.content.ClipData in project platform_frameworks_base by android.

the class Editor method startDragAndDrop.

private void startDragAndDrop() {
    // TODO: Fix drag and drop in full screen extracted mode.
    if (mTextView.isInExtractedMode()) {
        return;
    }
    final int start = mTextView.getSelectionStart();
    final int end = mTextView.getSelectionEnd();
    CharSequence selectedText = mTextView.getTransformedText(start, end);
    ClipData data = ClipData.newPlainText(null, selectedText);
    DragLocalState localState = new DragLocalState(mTextView, start, end);
    mTextView.startDragAndDrop(data, getTextThumbnailBuilder(start, end), localState, View.DRAG_FLAG_GLOBAL);
    stopTextActionMode();
    if (hasSelectionController()) {
        getSelectionController().resetTouchOffsets();
    }
}
Also used : ClipData(android.content.ClipData) Paint(android.graphics.Paint)

Example 7 with ClipData

use of android.content.ClipData in project platform_frameworks_base by android.

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 8 with ClipData

use of android.content.ClipData in project platform_frameworks_base by android.

the class DocumentClipper method getClipDataForDocuments.

/**
     * Returns ClipData representing the list of docs, or null if docs is empty,
     * or docs cannot be converted.
     */
@Nullable
public ClipData getClipDataForDocuments(List<DocumentInfo> docs) {
    final ContentResolver resolver = mContext.getContentResolver();
    final String[] mimeTypes = getMimeTypes(resolver, docs);
    ClipData clipData = null;
    for (DocumentInfo doc : docs) {
        if (clipData == null) {
            // TODO: figure out what this string should be.
            // Currently it is not displayed anywhere in the UI, but this might change.
            final String label = "";
            clipData = new ClipData(label, mimeTypes, new ClipData.Item(doc.derivedUri));
        } else {
            // TODO: update list of mime types in ClipData.
            clipData.addItem(new ClipData.Item(doc.derivedUri));
        }
    }
    return clipData;
}
Also used : ClipData(android.content.ClipData) ContentResolver(android.content.ContentResolver) DocumentInfo(com.android.documentsui.model.DocumentInfo) Nullable(android.support.annotation.Nullable)

Example 9 with ClipData

use of android.content.ClipData in project platform_frameworks_base by android.

the class VoiceInteractionSessionConnection method deliverSessionDataLocked.

private void deliverSessionDataLocked(AssistDataForActivity assistDataForActivity) {
    Bundle assistData = assistDataForActivity.data.getBundle(VoiceInteractionSession.KEY_DATA);
    AssistStructure structure = assistDataForActivity.data.getParcelable(VoiceInteractionSession.KEY_STRUCTURE);
    AssistContent content = assistDataForActivity.data.getParcelable(VoiceInteractionSession.KEY_CONTENT);
    int uid = assistDataForActivity.data.getInt(Intent.EXTRA_ASSIST_UID, -1);
    if (uid >= 0 && content != null) {
        Intent intent = content.getIntent();
        if (intent != null) {
            ClipData data = intent.getClipData();
            if (data != null && Intent.isAccessUriMode(intent.getFlags())) {
                grantClipDataPermissions(data, intent.getFlags(), uid, mCallingUid, mSessionComponentName.getPackageName());
            }
        }
        ClipData data = content.getClipData();
        if (data != null) {
            grantClipDataPermissions(data, Intent.FLAG_GRANT_READ_URI_PERMISSION, uid, mCallingUid, mSessionComponentName.getPackageName());
        }
    }
    try {
        mSession.handleAssist(assistData, structure, content, assistDataForActivity.activityIndex, assistDataForActivity.activityCount);
    } catch (RemoteException e) {
    }
}
Also used : AssistContent(android.app.assist.AssistContent) Bundle(android.os.Bundle) AssistStructure(android.app.assist.AssistStructure) Intent(android.content.Intent) RemoteException(android.os.RemoteException) ClipData(android.content.ClipData)

Example 10 with ClipData

use of android.content.ClipData in project android-common by litesuits.

the class ClipboardUtil method getItemCount.

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public static int getItemCount(Context context) {
    ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
    ClipData data = clipboard.getPrimaryClip();
    return data.getItemCount();
}
Also used : ClipboardManager(android.content.ClipboardManager) ClipData(android.content.ClipData) TargetApi(android.annotation.TargetApi)

Aggregations

ClipData (android.content.ClipData)193 ClipboardManager (android.content.ClipboardManager)81 Intent (android.content.Intent)48 Uri (android.net.Uri)41 Paint (android.graphics.Paint)24 MenuItem (android.view.MenuItem)20 View (android.view.View)16 ArrayList (java.util.ArrayList)15 TextView (android.widget.TextView)12 PendingIntent (android.app.PendingIntent)11 Bundle (android.os.Bundle)11 RemoteException (android.os.RemoteException)11 ContentResolver (android.content.ContentResolver)10 Nullable (android.support.annotation.Nullable)10 TextPaint (android.text.TextPaint)10 ImageView (android.widget.ImageView)10 DocumentInfo (com.android.documentsui.model.DocumentInfo)10 Item (android.content.ClipData.Item)9 Editable (android.text.Editable)9 DialogInterface (android.content.DialogInterface)8