use of android.content.ClipData in project k-9 by k9mail.
the class ClipboardManager method setText.
/**
* Copy a text string to the system clipboard
*
* @param label
* User-visible label for the content.
* @param text
* The actual text to be copied to the clipboard.
*/
public void setText(String label, String text) {
android.content.ClipboardManager clipboardManager = (android.content.ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
ClipData clip = ClipData.newPlainText(label, text);
clipboardManager.setPrimaryClip(clip);
}
use of android.content.ClipData in project android_frameworks_base by ParanoidAndroid.
the class ActivityManagerService method checkGrantUriPermissionFromIntentLocked.
/**
* Like checkGrantUriPermissionLocked, but takes an Intent.
*/
NeededUriGrants checkGrantUriPermissionFromIntentLocked(int callingUid, String targetPkg, Intent intent, int mode, NeededUriGrants needed) {
if (DEBUG_URI_PERMISSION)
Slog.v(TAG, "Checking URI perm to data=" + (intent != null ? intent.getData() : null) + " clip=" + (intent != null ? intent.getClipData() : null) + " from " + intent + "; flags=0x" + Integer.toHexString(intent != null ? intent.getFlags() : 0));
if (targetPkg == null) {
throw new NullPointerException("targetPkg");
}
if (intent == null) {
return null;
}
Uri data = intent.getData();
ClipData clip = intent.getClipData();
if (data == null && clip == null) {
return null;
}
if (data != null) {
int target = checkGrantUriPermissionLocked(callingUid, targetPkg, data, mode, needed != null ? needed.targetUid : -1);
if (target > 0) {
if (needed == null) {
needed = new NeededUriGrants(targetPkg, target, mode);
}
needed.add(data);
}
}
if (clip != null) {
for (int i = 0; i < clip.getItemCount(); i++) {
Uri uri = clip.getItemAt(i).getUri();
if (uri != null) {
int target = -1;
target = checkGrantUriPermissionLocked(callingUid, targetPkg, uri, mode, needed != null ? needed.targetUid : -1);
if (target > 0) {
if (needed == null) {
needed = new NeededUriGrants(targetPkg, target, mode);
}
needed.add(uri);
}
} else {
Intent clipIntent = clip.getItemAt(i).getIntent();
if (clipIntent != null) {
NeededUriGrants newNeeded = checkGrantUriPermissionFromIntentLocked(callingUid, targetPkg, clipIntent, mode, needed);
if (newNeeded != null) {
needed = newNeeded;
}
}
}
}
}
return needed;
}
use of android.content.ClipData 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.ClipData in project android_frameworks_base by ResurrectionRemix.
the class DocumentClipper method hasItemsToPaste.
public boolean hasItemsToPaste() {
if (mClipboard.hasPrimaryClip()) {
ClipData clipData = mClipboard.getPrimaryClip();
int count = clipData.getItemCount();
if (count > 0) {
for (int i = 0; i < count; ++i) {
ClipData.Item item = clipData.getItemAt(i);
Uri uri = item.getUri();
if (isDocumentUri(uri)) {
return true;
}
}
}
}
return false;
}
use of android.content.ClipData in project android_frameworks_base by ResurrectionRemix.
the class DocumentClipper method clipDocuments.
public void clipDocuments(List<DocumentInfo> docs) {
ClipData data = getClipDataForDocuments(docs);
mClipboard.setPrimaryClip(data);
}
Aggregations