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