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();
}
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 "";
}
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);
}
}
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();
}
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;
}
}
Aggregations