use of android.content.ClipData in project zxingfragmentlib by mitoyarzun.
the class ClipboardInterface method hasText.
public static boolean hasText(Context context) {
ClipboardManager clipboard = getManager(context);
ClipData clip = clipboard.getPrimaryClip();
return clip != null && clip.getItemCount() > 0;
}
use of android.content.ClipData in project LollipopShowcase by mikepenz.
the class DetailActivity method fillRow.
/**
* fill the rows with some information
*
* @param view
* @param title
* @param description
*/
public void fillRow(View view, final String title, final String description) {
TextView titleView = (TextView) view.findViewById(R.id.title);
titleView.setText(title);
TextView descriptionView = (TextView) view.findViewById(R.id.description);
descriptionView.setText(description);
view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
ClipData clip = ClipData.newPlainText("AppInfo", description);
clipboard.setPrimaryClip(clip);
Snackbar.make(mCoordinatorLayout, "Copied " + title, Snackbar.LENGTH_SHORT).show();
}
});
}
use of android.content.ClipData in project weiciyuan by qii.
the class MainTimeLineActivity method readClipboard.
//read clipboard to know whether there are any string link can be opened
private void readClipboard() {
ClipboardManager cm = (ClipboardManager) getApplicationContext().getSystemService(Context.CLIPBOARD_SERVICE);
ClipData cmContent = cm.getPrimaryClip();
if (cmContent == null) {
return;
}
ClipData.Item item = cmContent.getItemAt(0);
if (item != null) {
String url = item.coerceToText(this).toString();
boolean a = !TextUtils.isEmpty(url) && !url.equals(SettingUtility.getLastFoundWeiboAccountLink());
boolean b = Utility.isWeiboAccountIdLink(url) || Utility.isWeiboAccountDomainLink(url);
if (a && b) {
OpenWeiboAccountLinkDialog dialog = OpenWeiboAccountLinkDialog.newInstance(url);
dialog.show(getSupportFragmentManager(), "");
SettingUtility.setLastFoundWeiboAccountLink(url);
}
}
}
use of android.content.ClipData in project muzei by romannurik.
the class GallerySettingsActivity method onActivityResult.
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent result) {
super.onActivityResult(requestCode, resultCode, result);
if (requestCode != REQUEST_CHOOSE_PHOTOS && requestCode != REQUEST_CHOOSE_FOLDER) {
return;
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
if (!mAddToolbar.isAttachedToWindow()) {
// Can't animate detached Views
mAddToolbar.setVisibility(View.INVISIBLE);
mAddButton.setVisibility(View.VISIBLE);
} else {
hideAddToolbar(true);
}
}
if (resultCode != RESULT_OK) {
return;
}
if (result == null) {
return;
}
if (requestCode == REQUEST_CHOOSE_FOLDER) {
SharedPreferences preferences = getSharedPreferences(SHARED_PREF_NAME, Context.MODE_PRIVATE);
preferences.edit().putBoolean(SHOW_INTERNAL_STORAGE_MESSAGE, false).apply();
}
// Add chosen items
final Set<Uri> uris = new HashSet<>();
if (result.getData() != null) {
uris.add(result.getData());
}
// When selecting multiple images, "Photos" returns the first URI in getData and all URIs
// in getClipData.
ClipData clipData = result.getClipData();
if (clipData != null) {
int count = clipData.getItemCount();
for (int i = 0; i < count; i++) {
Uri uri = clipData.getItemAt(i).getUri();
if (uri != null) {
uris.add(uri);
}
}
}
if (uris.isEmpty()) {
// Nothing to do, so we can avoid posting the runnable at all
return;
}
// Update chosen URIs
runOnHandlerThread(new Runnable() {
@Override
public void run() {
ArrayList<ContentProviderOperation> operations = new ArrayList<>();
for (Uri uri : uris) {
ContentValues values = new ContentValues();
values.put(GalleryContract.ChosenPhotos.COLUMN_NAME_URI, uri.toString());
operations.add(ContentProviderOperation.newInsert(GalleryContract.ChosenPhotos.CONTENT_URI).withValues(values).build());
}
try {
getContentResolver().applyBatch(GalleryContract.AUTHORITY, operations);
} catch (RemoteException | OperationApplicationException e) {
Log.e(TAG, "Error writing uris to ContentProvider", e);
}
}
});
}
use of android.content.ClipData in project Conversations by siacs.
the class ConversationActivity method extractUriFromIntent.
@SuppressLint("NewApi")
private static List<Uri> extractUriFromIntent(final Intent intent) {
List<Uri> uris = new ArrayList<>();
if (intent == null) {
return uris;
}
Uri uri = intent.getData();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2 && uri == null) {
final ClipData clipData = intent.getClipData();
if (clipData != null) {
for (int i = 0; i < clipData.getItemCount(); ++i) {
uris.add(clipData.getItemAt(i).getUri());
}
}
} else {
uris.add(uri);
}
return uris;
}
Aggregations