Search in sources :

Example 46 with ClipboardManager

use of android.content.ClipboardManager in project wire-android by wireapp.

the class FingerprintPreference method onClick.

@Override
protected void onClick() {
    ClipboardManager clipboard = (ClipboardManager) getContext().getSystemService(Context.CLIPBOARD_SERVICE);
    ClipData clip = ClipData.newPlainText(getContext().getString(R.string.pref_devices_device_fingerprint_copy_description), getTitle());
    clipboard.setPrimaryClip(clip);
    Toast.makeText(getContext(), R.string.pref_devices_device_fingerprint_copy_toast, Toast.LENGTH_SHORT).show();
}
Also used : ClipboardManager(android.content.ClipboardManager) ClipData(android.content.ClipData)

Example 47 with ClipboardManager

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

the class SignInFragment method getAuthCodeFromClipboard.

private String getAuthCodeFromClipboard() {
    ClipboardManager clipboard = (ClipboardManager) getActivity().getSystemService(CLIPBOARD_SERVICE);
    if (clipboard.getPrimaryClip() != null && clipboard.getPrimaryClip().getItemAt(0) != null && clipboard.getPrimaryClip().getItemAt(0).getText() != null) {
        String code = clipboard.getPrimaryClip().getItemAt(0).getText().toString();
        mTwoStepAuthCodeMatcher.reset(code);
        if (!code.isEmpty() && mTwoStepAuthCodeMatcher.matches()) {
            return code;
        }
    }
    return "";
}
Also used : ClipboardManager(android.content.ClipboardManager)

Example 48 with ClipboardManager

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

the class MediaItemFragment method copyUrlToClipboard.

private void copyUrlToClipboard() {
    try {
        ClipboardManager clipboard = (ClipboardManager) getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
        clipboard.setPrimaryClip(ClipData.newPlainText(mImageUri, mImageUri));
        ToastUtils.showToast(getActivity(), R.string.media_details_copy_url_toast);
    } catch (Exception e) {
        AppLog.e(AppLog.T.UTILS, e);
        ToastUtils.showToast(getActivity(), R.string.error_copy_to_clipboard);
    }
}
Also used : ClipboardManager(android.content.ClipboardManager)

Example 49 with ClipboardManager

use of android.content.ClipboardManager in project Remindy by abicelis.

the class ClipboardUtil method copyToClipboard.

public static void copyToClipboard(Activity activity, String textToCopy) {
    ClipboardManager clipboard = (ClipboardManager) activity.getSystemService(Context.CLIPBOARD_SERVICE);
    ClipData clip = ClipData.newPlainText("Remindy text", textToCopy);
    clipboard.setPrimaryClip(clip);
    String toastMsg = String.format(Locale.getDefault(), activity.getResources().getString(R.string.dialog_text_attachment_text_copied_clipboard), textToCopy);
    Toast.makeText(activity, toastMsg, Toast.LENGTH_SHORT).show();
}
Also used : ClipboardManager(android.content.ClipboardManager) ClipData(android.content.ClipData)

Example 50 with ClipboardManager

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

the class TextView method paste.

/**
     * Paste clipboard content between min and max positions.
     */
private void paste(int min, int max, boolean withFormatting) {
    ClipboardManager clipboard = (ClipboardManager) getContext().getSystemService(Context.CLIPBOARD_SERVICE);
    ClipData clip = clipboard.getPrimaryClip();
    if (clip != null) {
        boolean didFirst = false;
        for (int i = 0; i < clip.getItemCount(); i++) {
            final CharSequence paste;
            if (withFormatting) {
                paste = clip.getItemAt(i).coerceToStyledText(getContext());
            } else {
                // Get an item as text and remove all spans by toString().
                final CharSequence text = clip.getItemAt(i).coerceToText(getContext());
                paste = (text instanceof Spanned) ? text.toString() : text;
            }
            if (paste != null) {
                if (!didFirst) {
                    Selection.setSelection((Spannable) mText, max);
                    ((Editable) mText).replace(min, max, paste);
                    didFirst = true;
                } else {
                    ((Editable) mText).insert(getSelectionEnd(), "\n");
                    ((Editable) mText).insert(getSelectionEnd(), paste);
                }
            }
        }
        sLastCutCopyOrTextChangedTime = 0;
    }
}
Also used : ClipboardManager(android.content.ClipboardManager) Editable(android.text.Editable) ClipData(android.content.ClipData) Spanned(android.text.Spanned) TextPaint(android.text.TextPaint) Paint(android.graphics.Paint)

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