Search in sources :

Example 86 with ClipboardManager

use of android.content.ClipboardManager in project PocketHub by pockethub.

the class CommitDiffListFragment method copyHashToClipboard.

private void copyHashToClipboard() {
    ClipboardManager manager = (ClipboardManager) getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
    ClipData clip = ClipData.newPlainText("hash", commit.sha());
    manager.setPrimaryClip(clip);
    Toast.makeText(getActivity(), R.string.toast_msg_copied, Toast.LENGTH_SHORT).show();
}
Also used : ClipboardManager(android.content.ClipboardManager) ClipData(android.content.ClipData)

Example 87 with ClipboardManager

use of android.content.ClipboardManager in project Conversations by siacs.

the class CopyTextView method onTextContextMenuItem.

@Override
public boolean onTextContextMenuItem(int id) {
    CharSequence text = getText();
    int min = 0;
    int max = text.length();
    if (isFocused()) {
        final int selStart = getSelectionStart();
        final int selEnd = getSelectionEnd();
        min = Math.max(0, Math.min(selStart, selEnd));
        max = Math.max(0, Math.max(selStart, selEnd));
    }
    String textForCopy = null;
    if (id == android.R.id.copy && copyHandler != null) {
        textForCopy = copyHandler.transformTextForCopy(getText(), min, max);
    }
    try {
        return super.onTextContextMenuItem(id);
    } finally {
        if (textForCopy != null) {
            ClipboardManager clipboard = (ClipboardManager) getContext().getSystemService(Context.CLIPBOARD_SERVICE);
            clipboard.setPrimaryClip(ClipData.newPlainText(null, textForCopy));
        }
    }
}
Also used : ClipboardManager(android.content.ClipboardManager)

Example 88 with ClipboardManager

use of android.content.ClipboardManager in project Conversations by siacs.

the class XmppActivity method copyTextToClipboard.

public boolean copyTextToClipboard(String text, int labelResId) {
    ClipboardManager mClipBoardManager = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
    String label = getResources().getString(labelResId);
    if (mClipBoardManager != null) {
        ClipData mClipData = ClipData.newPlainText(label, text);
        mClipBoardManager.setPrimaryClip(mClipData);
        return true;
    }
    return false;
}
Also used : ClipboardManager(android.content.ClipboardManager) ClipData(android.content.ClipData)

Example 89 with ClipboardManager

use of android.content.ClipboardManager in project zxingfragmentlib by mitoyarzun.

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 90 with ClipboardManager

use of android.content.ClipboardManager in project Rashr by DsLNeXuS.

the class Common method copyToClipboard.

@SuppressLint("NewApi")
public static void copyToClipboard(Context context, String message) {
    ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        ClipData clip = ClipData.newPlainText("", message);
        clipboard.setPrimaryClip(clip);
    } else {
        clipboard.setText(message);
    }
}
Also used : ClipboardManager(android.content.ClipboardManager) ClipData(android.content.ClipData) SuppressLint(android.annotation.SuppressLint)

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