List of usage examples for android.content ClipDescription MIMETYPE_TEXT_INTENT
String MIMETYPE_TEXT_INTENT
To view the source code for android.content ClipDescription MIMETYPE_TEXT_INTENT.
Click Source Link
From source file:Main.java
/** * Get intent from Clipboard/*from w w w . j av a 2 s . com*/ * * @param context * @return */ public static Intent getIntent(Context context) { ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE); if (clipboard.hasPrimaryClip() && clipboard.getPrimaryClipDescription().hasMimeType(ClipDescription.MIMETYPE_TEXT_INTENT)) { ClipData clip = clipboard.getPrimaryClip(); if (clip != null && clip.getItemCount() > 0) { return clip.getItemAt(0).getIntent(); } } return null; }
From source file:im.vector.util.VectorRoomMediasSender.java
/** * Send a list of images from their URIs *//*from ww w .j av a 2 s . c o m*/ private void sendMedias() { // sanity checks if ((null == mVectorRoomActivity) || (null == mVectorMessageListFragment) || (null == mMediasCache)) { Log.d(LOG_TAG, "sendMedias : null parameters"); return; } // detect end of messages sending if ((null == mSharedDataItems) || (0 == mSharedDataItems.size())) { Log.d(LOG_TAG, "sendMedias : done"); mImageCompressionDescription = null; mSharedDataItems = null; mVectorRoomActivity.runOnUiThread(new Runnable() { @Override public void run() { mVectorMessageListFragment.scrollToBottom(); mVectorRoomActivity.cancelSelectionMode(); mVectorRoomActivity.setProgressVisibility(View.GONE); } }); return; } // display a spinner mVectorRoomActivity.cancelSelectionMode(); mVectorRoomActivity.setProgressVisibility(View.VISIBLE); Log.d(LOG_TAG, "sendMedias : " + mSharedDataItems.size() + " items to send"); mMediasSendingHandler.post(new Runnable() { @Override public void run() { SharedDataItem sharedDataItem = mSharedDataItems.get(0); String mimeType = sharedDataItem.getMimeType(mVectorRoomActivity); // avoid null case if (null == mimeType) { mimeType = ""; } if (TextUtils.equals(ClipDescription.MIMETYPE_TEXT_INTENT, mimeType)) { Log.d(LOG_TAG, "sendMedias : unsupported mime type"); // don't know how to manage it -> skip it // GA issue if (mSharedDataItems.size() > 0) { mSharedDataItems.remove(0); } sendMedias(); } else if (TextUtils.equals(ClipDescription.MIMETYPE_TEXT_PLAIN, mimeType) || TextUtils.equals(ClipDescription.MIMETYPE_TEXT_HTML, mimeType)) { sendTextMessage(sharedDataItem); } else { // check if it is an uri // else we don't know what to do if (null == sharedDataItem.getUri()) { Log.e(LOG_TAG, "sendMedias : null uri"); // manage others if (mSharedDataItems.size() > 0) { mSharedDataItems.remove(0); } sendMedias(); return; } final String fFilename = sharedDataItem.getFileName(mVectorRoomActivity); ResourceUtils.Resource resource = ResourceUtils.openResource(mVectorRoomActivity, sharedDataItem.getUri(), sharedDataItem.getMimeType(mVectorRoomActivity)); if (null == resource) { Log.e(LOG_TAG, "sendMedias : " + fFilename + " is not found"); mVectorRoomActivity.runOnUiThread(new Runnable() { @Override public void run() { Toast.makeText(mVectorRoomActivity, mVectorRoomActivity.getString(R.string.room_message_file_not_found), Toast.LENGTH_LONG).show(); } }); // manage others if (mSharedDataItems.size() > 0) { mSharedDataItems.remove(0); } sendMedias(); return; } if (mimeType.startsWith("image/")) { sendImageMessage(sharedDataItem, resource); } else if (mimeType.startsWith("video/")) { sendVideoMessage(sharedDataItem, resource); } else { sendFileMessage(sharedDataItem, resource); } } } }); }
From source file:im.neon.util.VectorRoomMediasSender.java
/** * Send a list of images from their URIs *///from www .jav a2 s . c o m private void sendMedias() { // sanity checks if ((null == mVectorRoomActivity) || (null == mVectorMessageListFragment) || (null == mMediasCache)) { Log.d(LOG_TAG, "sendMedias : null parameters"); return; } // detect end of messages sending if ((null == mSharedDataItems) || (0 == mSharedDataItems.size())) { Log.d(LOG_TAG, "sendMedias : done"); mImageCompressionDescription = null; mSharedDataItems = null; mVectorRoomActivity.runOnUiThread(new Runnable() { @Override public void run() { mVectorMessageListFragment.scrollToBottom(); mVectorRoomActivity.cancelSelectionMode(); mVectorRoomActivity.setProgressVisibility(View.GONE); } }); return; } // display a spinner mVectorRoomActivity.cancelSelectionMode(); mVectorRoomActivity.setProgressVisibility(View.VISIBLE); Log.d(LOG_TAG, "sendMedias : " + mSharedDataItems.size() + " items to send"); mMediasSendingHandler.post(new Runnable() { @Override public void run() { SharedDataItem sharedDataItem = mSharedDataItems.get(0); String mimeType = sharedDataItem.getMimeType(mVectorRoomActivity); // avoid null case if (null == mimeType) { mimeType = ""; } if (TextUtils.equals(ClipDescription.MIMETYPE_TEXT_INTENT, mimeType)) { Log.d(LOG_TAG, "sendMedias : unsupported mime type"); // don't know how to manage it -> skip it // GA issue if (mSharedDataItems.size() > 0) { mSharedDataItems.remove(0); } sendMedias(); } else if ((null == sharedDataItem.getUri()) && (TextUtils.equals(ClipDescription.MIMETYPE_TEXT_PLAIN, mimeType) || TextUtils.equals(ClipDescription.MIMETYPE_TEXT_HTML, mimeType))) { sendTextMessage(sharedDataItem); } else { // check if it is an uri // else we don't know what to do if (null == sharedDataItem.getUri()) { Log.e(LOG_TAG, "sendMedias : null uri"); // manage others if (mSharedDataItems.size() > 0) { mSharedDataItems.remove(0); } sendMedias(); return; } final String fFilename = sharedDataItem.getFileName(mVectorRoomActivity); ResourceUtils.Resource resource = ResourceUtils.openResource(mVectorRoomActivity, sharedDataItem.getUri(), sharedDataItem.getMimeType(mVectorRoomActivity)); if (null == resource) { Log.e(LOG_TAG, "sendMedias : " + fFilename + " is not found"); mVectorRoomActivity.runOnUiThread(new Runnable() { @Override public void run() { Toast.makeText(mVectorRoomActivity, mVectorRoomActivity.getString(R.string.room_message_file_not_found), Toast.LENGTH_LONG).show(); } }); // manage others if (mSharedDataItems.size() > 0) { mSharedDataItems.remove(0); } sendMedias(); return; } if (mimeType.startsWith("image/")) { sendImageMessage(sharedDataItem, resource); } else if (mimeType.startsWith("video/")) { sendVideoMessage(sharedDataItem, resource); } else { sendFileMessage(sharedDataItem, resource); } } } }); }