Ejemplo n.º 1
0
  @Override
  public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
    if (isEncryptedConversation && isSingleConversation()) {
      boolean isPushDestination = DirectoryHelper.isPushDestination(this, getRecipients());
      Recipient primaryRecipient =
          getRecipients() == null ? null : getRecipients().getPrimaryRecipient();
      boolean hasSession = Session.hasSession(this, masterSecret, primaryRecipient);

      getMenuInflater().inflate(R.menu.conversation_button_context, menu);

      if (attachmentManager.isAttachmentPresent()) {
        menu.removeItem(R.id.menu_context_send_encrypted_sms);
        menu.removeItem(R.id.menu_context_send_unencrypted_sms);
      } else {
        menu.removeItem(R.id.menu_context_send_encrypted_mms);
        menu.removeItem(R.id.menu_context_send_unencrypted_mms);
      }

      if (!isPushDestination) {
        menu.removeItem(R.id.menu_context_send_push);
      }

      if (!hasSession) {
        menu.removeItem(R.id.menu_context_send_encrypted_mms);
        menu.removeItem(R.id.menu_context_send_encrypted_sms);
      }
    }
  }
Ejemplo n.º 2
0
  private String getMessage() throws InvalidMessageException {
    String rawText = composeText.getText().toString();

    if (rawText.length() < 1 && !attachmentManager.isAttachmentPresent())
      throw new InvalidMessageException(
          getString(R.string.ConversationActivity_message_is_empty_exclamation));

    if (!isEncryptedConversation && Tag.isTaggable(rawText))
      rawText = Tag.getTaggedMessage(rawText);

    return rawText;
  }
Ejemplo n.º 3
0
  private void initializeSecurity() {
    TypedArray drawables = obtainStyledAttributes(SEND_ATTRIBUTES);
    Recipient primaryRecipient =
        getRecipients() == null ? null : getRecipients().getPrimaryRecipient();
    boolean isPushDestination = DirectoryHelper.isPushDestination(this, getRecipients());
    boolean isSecureDestination =
        isSingleConversation() && Session.hasSession(this, masterSecret, primaryRecipient);

    if (isPushDestination || isSecureDestination) {
      this.isEncryptedConversation = true;
      this.characterCalculator = new EncryptedCharacterCalculator();
    } else {
      this.isEncryptedConversation = false;
      this.characterCalculator = new CharacterCalculator();
    }

    if (isPushDestination) {
      sendButton.setImageDrawable(drawables.getDrawable(0));
      setComposeTextHint(getString(R.string.conversation_activity__type_message_push));
    } else if (isSecureDestination) {
      sendButton.setImageDrawable(drawables.getDrawable(1));
      setComposeTextHint(
          attachmentManager.isAttachmentPresent()
              ? getString(R.string.conversation_activity__type_message_mms_secure)
              : getString(R.string.conversation_activity__type_message_sms_secure));
    } else {
      sendButton.setImageDrawable(drawables.getDrawable(2));
      setComposeTextHint(
          (attachmentManager.isAttachmentPresent() || !recipients.isSingleRecipient())
              ? getString(R.string.conversation_activity__type_message_mms_insecure)
              : getString(R.string.conversation_activity__type_message_sms_insecure));
    }

    drawables.recycle();

    calculateCharactersRemaining();
  }
Ejemplo n.º 4
0
  private long sendMediaMessage(boolean forcePlaintext, boolean forceSms)
      throws InvalidMessageException, MmsException {
    SlideDeck slideDeck;

    if (attachmentManager.isAttachmentPresent()) slideDeck = attachmentManager.getSlideDeck();
    else slideDeck = new SlideDeck();

    OutgoingMediaMessage outgoingMessage =
        new OutgoingMediaMessage(this, recipients, slideDeck, getMessage(), distributionType);

    if (isEncryptedConversation && !forcePlaintext) {
      outgoingMessage = new OutgoingSecureMediaMessage(outgoingMessage);
    }

    return MessageSender.send(this, masterSecret, outgoingMessage, threadId, forceSms);
  }
Ejemplo n.º 5
0
  private void sendMessage(boolean forcePlaintext, boolean forceSms) {
    try {
      Recipients recipients = getRecipients();

      if (recipients == null) throw new RecipientFormattingException("Badly formatted");

      long allocatedThreadId;

      if ((!recipients.isSingleRecipient() || recipients.isEmailRecipient()) && !isMmsEnabled) {
        handleManualMmsRequired();
        return;
      } else if (attachmentManager.isAttachmentPresent()
          || !recipients.isSingleRecipient()
          || recipients.isGroupRecipient()
          || recipients.isEmailRecipient()) {
        allocatedThreadId = sendMediaMessage(forcePlaintext, forceSms);
      } else {
        allocatedThreadId = sendTextMessage(forcePlaintext, forceSms);
      }

      sendComplete(recipients, allocatedThreadId, allocatedThreadId != this.threadId);
    } catch (RecipientFormattingException ex) {
      Toast.makeText(
              ConversationActivity.this,
              R.string
                  .ConversationActivity_recipient_is_not_a_valid_sms_or_email_address_exclamation,
              Toast.LENGTH_LONG)
          .show();
      Log.w(TAG, ex);
    } catch (InvalidMessageException ex) {
      Toast.makeText(
              ConversationActivity.this,
              R.string.ConversationActivity_message_is_empty_exclamation,
              Toast.LENGTH_SHORT)
          .show();
      Log.w(TAG, ex);
    } catch (MmsException e) {
      Log.w(TAG, e);
    }
  }