Search in sources :

Example 36 with ClipboardManager

use of android.content.ClipboardManager in project BarcodeEye by BarcodeEye.

the class ClipboardInterface method getText.

public static CharSequence getText(Context context) {
    ClipboardManager clipboard = getManager(context);
    ClipData clip = clipboard.getPrimaryClip();
    return hasText(context) ? clip.getItemAt(0).coerceToText(context) : null;
}
Also used : ClipboardManager(android.content.ClipboardManager) ClipData(android.content.ClipData)

Example 37 with ClipboardManager

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

the class SelectActionModeCallback method onCreateActionMode.

// ActionMode.Callback implementation
@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
    mode.getMenuInflater().inflate(com.android.internal.R.menu.webview_copy, menu);
    final Context context = mWebView.getContext();
    mode.setTitle(context.getString(com.android.internal.R.string.textSelectionCABTitle));
    mode.setTitleOptionalHint(true);
    // If the action mode UI we're running in isn't capable of taking window focus
    // the user won't be able to type into the find on page UI. Disable this functionality.
    // (Note that this should only happen in floating dialog windows.)
    // This can be removed once we can handle multiple focusable windows at a time
    // in a better way.
    ClipboardManager cm = (ClipboardManager) (context.getSystemService(Context.CLIPBOARD_SERVICE));
    boolean isFocusable = mode.isUiFocusable();
    boolean isEditable = mWebView.focusCandidateIsEditableText();
    boolean canPaste = isEditable && cm.hasPrimaryClip() && isFocusable;
    boolean canFind = !isEditable && isFocusable;
    boolean canCut = isEditable && mIsTextSelected && isFocusable;
    boolean canCopy = mIsTextSelected;
    boolean canWebSearch = mIsTextSelected;
    setMenuVisibility(menu, canFind, com.android.internal.R.id.find);
    setMenuVisibility(menu, canPaste, com.android.internal.R.id.paste);
    setMenuVisibility(menu, canCut, com.android.internal.R.id.cut);
    setMenuVisibility(menu, canCopy, com.android.internal.R.id.copy);
    setMenuVisibility(menu, canWebSearch, com.android.internal.R.id.websearch);
    mActionMode = mode;
    return true;
}
Also used : Context(android.content.Context) ClipboardManager(android.content.ClipboardManager)

Example 38 with ClipboardManager

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

the class WebViewClassic method copySelection.

/**
     * Copy the selection to the clipboard
     *
     * This is an implementation detail.
     */
public boolean copySelection() {
    boolean copiedSomething = false;
    String selection = getSelection();
    if (selection != null && selection != "") {
        if (DebugFlags.WEB_VIEW) {
            Log.v(LOGTAG, "copySelection \"" + selection + "\"");
        }
        Toast.makeText(mContext, com.android.internal.R.string.text_copied, Toast.LENGTH_SHORT).show();
        copiedSomething = true;
        ClipboardManager cm = (ClipboardManager) mContext.getSystemService(Context.CLIPBOARD_SERVICE);
        cm.setText(selection);
        int[] handles = new int[4];
        getSelectionHandles(handles);
        mWebViewCore.sendMessage(EventHub.COPY_TEXT, handles);
    }
    // remove selection region and pointer
    invalidate();
    return copiedSomething;
}
Also used : ClipboardManager(android.content.ClipboardManager)

Example 39 with ClipboardManager

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

the class WebViewClassic method pasteFromClipboard.

/**
     * Paste text from the clipboard to the cursor position.
     *
     * This is an implementation detail
     */
public void pasteFromClipboard() {
    ClipboardManager cm = (ClipboardManager) mContext.getSystemService(Context.CLIPBOARD_SERVICE);
    ClipData clipData = cm.getPrimaryClip();
    if (clipData != null) {
        ClipData.Item clipItem = clipData.getItemAt(0);
        CharSequence pasteText = clipItem.coerceToText(mContext);
        if (mInputConnection != null) {
            mInputConnection.replaceSelection(pasteText);
        }
    }
}
Also used : ClipboardManager(android.content.ClipboardManager) ClipData(android.content.ClipData)

Example 40 with ClipboardManager

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

the class WebViewClassic method copyToClipboard.

/**
     * Copy text into the clipboard. This is called indirectly from
     * WebViewCore.
     * @param text The text to put into the clipboard.
     */
private void copyToClipboard(String text) {
    ClipboardManager cm = (ClipboardManager) mContext.getSystemService(Context.CLIPBOARD_SERVICE);
    ClipData clip = ClipData.newPlainText(getTitle(), text);
    cm.setPrimaryClip(clip);
}
Also used : ClipboardManager(android.content.ClipboardManager) ClipData(android.content.ClipData)

Aggregations

ClipboardManager (android.content.ClipboardManager)125 ClipData (android.content.ClipData)82 Intent (android.content.Intent)17 View (android.view.View)15 TextView (android.widget.TextView)13 Context (android.content.Context)10 Paint (android.graphics.Paint)9 DialogInterface (android.content.DialogInterface)7 Bundle (android.os.Bundle)7 AlertDialog (android.support.v7.app.AlertDialog)7 Editable (android.text.Editable)7 TextPaint (android.text.TextPaint)7 ImageView (android.widget.ImageView)6 TargetApi (android.annotation.TargetApi)5 Spanned (android.text.Spanned)5 AlertDialog (android.app.AlertDialog)4 Uri (android.net.Uri)4 ColorDrawable (android.graphics.drawable.ColorDrawable)3 Drawable (android.graphics.drawable.Drawable)3 MenuItem (android.view.MenuItem)3