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 new Address(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;
    }
  }
 boolean processDragStarted(DragEvent event) {
   // Determine whether to continue processing drag and drop based on the
   // plain text mime type.
   ClipDescription clipDesc = event.getClipDescription();
   if (clipDesc != null) {
     return clipDesc.hasMimeType(ClipDescription.MIMETYPE_TEXT_PLAIN);
   }
   return false;
 }
 /**
  * Get the remote input results bundle from an intent. The returned Bundle will contain a
  * key/value for every result key populated by remote input collector. Use the {@link
  * Bundle#getCharSequence(String)} method to retrieve a value.
  *
  * @param intent The intent object that fired in response to an action or content intent which
  *     also had one or more remote input requested.
  */
 public static Bundle getResultsFromIntent(Intent intent) {
   ClipData clipData = intent.getClipData();
   if (clipData == null) {
     return null;
   }
   ClipDescription clipDescription = clipData.getDescription();
   if (!clipDescription.hasMimeType(ClipDescription.MIMETYPE_TEXT_INTENT)) {
     return null;
   }
   if (clipDescription.getLabel().equals(RESULTS_CLIP_LABEL)) {
     return clipData.getItemAt(0).getIntent().getExtras().getParcelable(EXTRA_RESULTS_DATA);
   }
   return null;
 }
Exemple #4
0
 public final Bundle getResultsFromIntent(Intent paramIntent) {
   paramIntent = paramIntent.getClipData();
   if (paramIntent != null) {
     ClipDescription localClipDescription = paramIntent.getDescription();
     if ((localClipDescription.hasMimeType("text/vnd.android.intent"))
         && (localClipDescription.getLabel().equals("android.remoteinput.results"))) {
       return (Bundle)
           paramIntent
               .getItemAt(0)
               .getIntent()
               .getExtras()
               .getParcelable("android.remoteinput.resultsData");
     }
   }
   return null;
 }
 @Override
 public String[] getStreamTypes(Uri uri, String mimeTypeFilter) {
   switch (sUriMatcher.match(uri)) {
     case NOTES:
     case LIVE_FOLDER_NOTES:
       return null;
     case NOTE_ID:
       return NOTE_STREAM_TYPES.filterMimeTypes(mimeTypeFilter);
     default:
       throw new IllegalArgumentException("Unknown URI " + uri);
   }
 }
 /**
  * Creates a {@link Parcel} object from this DragEvent object.
  *
  * @param dest A {@link Parcel} object in which to put the DragEvent object.
  * @param flags Flags to store in the Parcel.
  */
 public void writeToParcel(Parcel dest, int flags) {
   dest.writeInt(mAction);
   dest.writeFloat(mX);
   dest.writeFloat(mY);
   dest.writeInt(mDragResult ? 1 : 0);
   if (mClipData == null) {
     dest.writeInt(0);
   } else {
     dest.writeInt(1);
     mClipData.writeToParcel(dest, flags);
   }
   if (mClipDescription == null) {
     dest.writeInt(0);
   } else {
     dest.writeInt(1);
     mClipDescription.writeToParcel(dest, flags);
   }
 }