private void copyUrl(Message message) {
   final String url;
   final int resId;
   if (GeoHelper.isGeoUri(message.getBody())) {
     resId = R.string.location;
     url = message.getBody();
   } else if (message.hasFileOnRemoteHost()) {
     resId = R.string.file_url;
     url = message.getFileParams().url.toString();
   } else {
     url = message.getBody().trim();
     resId = R.string.file_url;
   }
   if (activity.copyTextToClipboard(url, resId)) {
     Toast.makeText(activity, R.string.url_copied_to_clipboard, Toast.LENGTH_SHORT).show();
   }
 }
Exemplo n.º 2
0
 public Message findSentMessageWithBody(String body) {
   synchronized (this.messages) {
     for (int i = this.messages.size() - 1; i >= 0; --i) {
       Message message = this.messages.get(i);
       if (message.getStatus() == Message.STATUS_UNSEND
           || message.getStatus() == Message.STATUS_SEND) {
         String otherBody;
         if (message.hasFileOnRemoteHost()) {
           otherBody = message.getFileParams().url.toString();
         } else {
           otherBody = message.body;
         }
         if (otherBody != null && otherBody.equals(body)) {
           return message;
         }
       }
     }
     return null;
   }
 }
Exemplo n.º 3
0
  @Nullable
  public XmppAxolotlMessage encrypt(Message message) {
    XmppAxolotlMessage axolotlMessage = buildHeader(message.getContact());

    if (axolotlMessage != null) {
      final String content;
      if (message.hasFileOnRemoteHost()) {
        content = message.getFileParams().url.toString();
      } else {
        content = message.getBody();
      }
      try {
        axolotlMessage.encrypt(content);
      } catch (CryptoFailedException e) {
        Log.w(
            Config.LOGTAG, getLogprefix(account) + "Failed to encrypt message: " + e.getMessage());
        return null;
      }
    }

    return axolotlMessage;
  }