use of android.content.ClipData in project twicalico by moko256.
the class PostActivity method onActivityResult.
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == REQUEST_GET_IMAGE) {
if (data != null) {
Uri resultUri = data.getData();
ClipData resultUris = data.getClipData();
if (resultUri != null) {
addedImagesAdapter.getImagesList().add(resultUri);
model.getUriList().add(resultUri);
addedImagesAdapter.notifyItemChanged(addedImagesAdapter.getImagesList().size() - 1);
possiblySensitiveSwitch.setEnabled(true);
} else if (resultUris != null) {
int itemCount = resultUris.getItemCount();
for (int i = 0; i < itemCount; i++) {
Uri uri = resultUris.getItemAt(i).getUri();
addedImagesAdapter.getImagesList().add(uri);
model.getUriList().add(uri);
}
addedImagesAdapter.notifyItemRangeChanged(addedImagesAdapter.getImagesList().size() - itemCount, itemCount);
possiblySensitiveSwitch.setEnabled(true);
}
}
}
}
use of android.content.ClipData in project bitcoin-wallet by bitcoin-wallet.
the class SendingAddressesFragment method getAddressFromPrimaryClip.
private Address getAddressFromPrimaryClip() {
if (!clipboardManager.hasPrimaryClip())
return null;
final ClipData clip = clipboardManager.getPrimaryClip();
final ClipDescription clipDescription = clip.getDescription();
if (clipDescription.hasMimeType(ClipDescription.MIMETYPE_TEXT_PLAIN)) {
final CharSequence clipText = clip.getItemAt(0).getText();
if (clipText == null)
return null;
try {
return Address.fromBase58(Constants.NETWORK_PARAMETERS, clipText.toString().trim());
} catch (final AddressFormatException x) {
return null;
}
} else if (clipDescription.hasMimeType(ClipDescription.MIMETYPE_TEXT_URILIST)) {
final Uri clipUri = clip.getItemAt(0).getUri();
if (clipUri == null)
return null;
try {
return new BitcoinURI(clipUri.toString()).getAddress();
} catch (final BitcoinURIParseException x) {
return null;
}
} else {
return null;
}
}
use of android.content.ClipData in project cloudrail-si-android-sdk by CloudRail.
the class Files method createShareLink.
private void createShareLink() {
this.startSpinner();
TextView tv = (TextView) this.selectedItem.findViewById(R.id.list_item);
final String name = (String) tv.getText();
new Thread(new Runnable() {
@Override
public void run() {
String next = currentPath;
if (!currentPath.equals("/")) {
next += "/";
}
next += name;
final String shareLink = getService().createShareLink(next);
getOwnActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
ClipData clip = ClipData.newPlainText("Sharable Link", shareLink);
clipboard.setPrimaryClip(clip);
Toast.makeText(context, "Copied link to clipboard\n" + shareLink, Toast.LENGTH_LONG).show();
}
});
stopSpinner();
}
}).start();
}
use of android.content.ClipData in project instructure-android by instructure.
the class CanvasWebView method onCreateContextMenu.
/**
* Create a context menu to copy the link that was pressed and then copy that link to the clipboard
*/
@Override
protected void onCreateContextMenu(ContextMenu menu) {
super.onCreateContextMenu(menu);
final HitTestResult result = this.getHitTestResult();
MenuItem.OnMenuItemClickListener handler = new MenuItem.OnMenuItemClickListener() {
public boolean onMenuItemClick(MenuItem item) {
// do the menu action
if (item.getItemId() == COPY_LINK_ID) {
ClipboardManager clipboard = (ClipboardManager) mContext.getSystemService(Context.CLIPBOARD_SERVICE);
if (clipboard != null) {
ClipData clip = ClipData.newPlainText(mContext.getString(R.string.link), result.getExtra());
clipboard.setPrimaryClip(clip);
// Let the user know
Toast.makeText(mContext, mContext.getString(R.string.linkCopied), Toast.LENGTH_SHORT).show();
}
} else if (item.getItemId() == SHARE_LINK_ID) {
// Share the link with other apps
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(result.getExtra()));
if (intent.resolveActivity(getContext().getPackageManager()) != null) {
mContext.startActivity(intent);
} else {
// No apps can do anything with this link, let the user know
Toast.makeText(mContext, mContext.getString(R.string.noApps), Toast.LENGTH_SHORT).show();
}
}
return true;
}
};
if (result.getType() == HitTestResult.ANCHOR_TYPE || result.getType() == HitTestResult.SRC_ANCHOR_TYPE) {
// Title of the link, use a custom view so we can show the entire link in the style we want
TextView title = new TextView(mContext);
title.setText(result.getExtra());
title.setTextColor(mContext.getResources().getColor(R.color.canvasTextDark));
int padding = (int) Utils.dpToPx(mContext, 8);
title.setPadding(padding * 2, padding, padding * 2, 0);
menu.setHeaderView(title);
// Menu options for a hyperlink.
// Copy
menu.add(0, COPY_LINK_ID, 0, mContext.getString(R.string.copyLinkAddress)).setOnMenuItemClickListener(handler);
// Share with a different app
menu.add(0, SHARE_LINK_ID, 1, mContext.getString(R.string.shareLink)).setOnMenuItemClickListener(handler);
}
}
use of android.content.ClipData in project instructure-android by instructure.
the class RecipientEditTextView method startDrag.
/**
* Starts drag-and-drop for the selected chip.
*/
private void startDrag(DrawableRecipientChip currentChip) {
String address = currentChip.getEntry().getDestination();
ClipData data = ClipData.newPlainText(address, address + COMMIT_CHAR_COMMA);
// Start drag mode.
startDrag(data, new RecipientChipShadow(currentChip), null, 0);
// Remove the current chip, so drag-and-drop will result in a move.
// TODO (phamm): consider readd this chip if it's dropped outside a target.
removeChip(currentChip);
}
Aggregations