use of android.content.ClipboardManager in project CoCoin by Nightonke.
the class CoCoinUtil method copyToClipboard.
public static void copyToClipboard(String content, Context context) {
ClipboardManager cmb = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
cmb.setText(content.trim());
}
use of android.content.ClipboardManager in project WordPress-Android by wordpress-mobile.
the class Utils method getUrlFromClipboard.
/**
* Checks the Clipboard for text that matches the {@link Patterns#WEB_URL} pattern.
*
* @return the URL text in the clipboard, if it exists; otherwise null
*/
public static String getUrlFromClipboard(Context context) {
if (context == null)
return null;
ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
ClipData data = clipboard != null ? clipboard.getPrimaryClip() : null;
if (data == null || data.getItemCount() <= 0)
return null;
String clipText = String.valueOf(data.getItemAt(0).getText());
return Patterns.WEB_URL.matcher(clipText).matches() ? clipText : null;
}
use of android.content.ClipboardManager in project CloudReader by youlookwhat.
the class BaseTools method copy.
/**
* 实现文本复制功能
*
* @param content 复制的文本
*/
public static void copy(String content) {
// 得到剪贴板管理器
ClipboardManager cmb = (ClipboardManager) CloudReaderApplication.getInstance().getSystemService(Context.CLIPBOARD_SERVICE);
cmb.setText(content.trim());
}
use of android.content.ClipboardManager in project Tusky by Vavassor.
the class ParserUtils method getPastedURLText.
// ComposeActivity : EditText inside the onTextChanged
public String getPastedURLText(Context context) {
ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
String pasteData;
if (clipboard.hasPrimaryClip()) {
// get what is in the clipboard
ClipData.Item item = clipboard.getPrimaryClip().getItemAt(0);
pasteData = item.getText().toString();
// If we share with an app, it's not only an url
List<String> strings = StringUtils.extractUrl(pasteData);
// we assume that the first url is the good one
String url = strings.get(0);
if (strings.size() > 0) {
if (URLUtil.isValidUrl(url)) {
new ThreadHeaderInfo().execute(url);
}
}
}
return null;
}
use of android.content.ClipboardManager in project Rocket.Chat.Android by RocketChat.
the class MarkDown method createLinkSpan.
/*package*/
static ClickableSpan createLinkSpan(final String url) {
return new ClickableSpan() {
@Override
public void onClick(View view) {
final Context context = view.getContext();
try {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
return;
} catch (Exception exception) {
}
try {
ClipboardManager clipboardManager = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
clipboardManager.setPrimaryClip(ClipData.newPlainText("linkURL", url));
Toast.makeText(context, "Copied to clipboard", Toast.LENGTH_SHORT).show();
} catch (Exception exception) {
}
}
};
}
Aggregations