@Override
 public void onItemClick(Conversation conversation, View view) {
   if (mAdapter.isInMultiSelectMode()) {
     mAdapter.toggleSelection(conversation.getThreadId());
   } else {
     ((MainActivity) mContext).setConversation(conversation.getThreadId(), -1, null, true);
   }
 }
Esempio n. 2
0
 @Override
 public void onClick(DialogInterface dialog, final int whichButton) {
   MessageUtils.handleReadReport(
       mContext,
       mThreadIds,
       PduHeaders.READ_STATUS__DELETED_WITHOUT_BEING_READ,
       () -> {
         int token = DELETE_CONVERSATION_TOKEN;
         if (mThreadIds == null) {
           Conversation.startDeleteAll(mHandler, token, mDeleteLockedMessages);
           DraftCache.getInstance().refresh();
         } else {
           Conversation.startDelete(mHandler, token, mDeleteLockedMessages, mThreadIds);
         }
       });
   dialog.dismiss();
 }
Esempio n. 3
0
  /**
   * Sets the conversation for this compose view. This will setup the ComposeView with drafts.
   *
   * @param conversationLegacy
   */
  public void onOpenConversation(Conversation conversation, ConversationLegacy conversationLegacy) {
    long threadId = mConversation != null ? mConversation.getThreadId() : -1;
    if (threadId > 0) sendPendingDelayedMessage();
    long newThreadId = conversation != null ? conversation.getThreadId() : -1;
    if (mConversation != null && mConversationLegacy != null && threadId != newThreadId) {
      // Save the old draft first before updating the conversation objects.
      saveDraft();
    }

    mConversation = conversation;
    mConversationLegacy = conversationLegacy;

    // If the conversation was different, set up the draft here.
    if (threadId != newThreadId) {
      setupDraft();
    }
  }
  @Override
  public void onItemLongClick(final Conversation conversation, View view) {
    if (mAdapter.isInMultiSelectMode()) {
      mAdapter.toggleSelection(conversation.getThreadId());
      return;
    }

    final long threadId = conversation.getThreadId();
    final String name = conversation.getRecipients().formatNames(", ");

    final ConversationPrefsHelper conversationPrefs =
        new ConversationPrefsHelper(mContext, threadId);
    final boolean muted = !conversationPrefs.getNotificationsEnabled();

    final QKDialog dialog = new QKDialog().setContext(mContext).setTitle(name);

    if (!mAdapter.isInMultiSelectMode()) {
      dialog.addMenuItem(R.string.menu_multi_select, MENU_MULTI_SELECT);
    }

    if (muted) {
      dialog.addMenuItem(R.string.menu_unmute_conversation, MENU_UNMUTE_CONVERSATION);
    } else {
      dialog.addMenuItem(R.string.menu_mute_conversation, MENU_MUTE_CONVERSATION);
    }

    if (conversation.hasUnreadMessages()) {
      dialog.addMenuItem(R.string.menu_mark_read, MENU_MARK_READ);
    } else {
      dialog.addMenuItem(R.string.menu_mark_unread, MENU_MARK_UNREAD);
    }

    dialog.addMenuItem(R.string.menu_notification_settings, MENU_NOTIFICATION_SETTINGS);
    dialog.addMenuItem(R.string.menu_view_details, MENU_VIEW_DETAILS);

    if (conversation.hasError()) {
      dialog.addMenuItem(R.string.delete_all_failed, MENU_DELETE_FAILED);
    }

    dialog.addMenuItem(R.string.menu_delete_conversation, MENU_DELETE_CONVERSATION);

    dialog
        .buildMenu(
            new AdapterView.OnItemClickListener() {
              @Override
              public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                switch ((int) id) {
                  case MENU_MUTE_CONVERSATION:
                    conversationPrefs.putBoolean(SettingsFragment.NOTIFICATIONS, false);
                    mAdapter.notifyDataSetChanged();
                    break;

                  case MENU_UNMUTE_CONVERSATION:
                    conversationPrefs.putBoolean(SettingsFragment.NOTIFICATIONS, true);
                    mAdapter.notifyDataSetChanged();
                    break;

                  case MENU_NOTIFICATION_SETTINGS:
                    ConversationNotificationSettingsDialog.newInstance(threadId, name)
                        .setContext(mContext)
                        .show(((MainActivity) mContext).getFragmentManager(), "notification prefs");
                    break;

                  case MENU_VIEW_DETAILS:
                    mConversationDetailsDialog.showDetails(conversation);
                    break;

                  case MENU_MARK_READ:
                    new ConversationLegacy(mContext, threadId).markRead();
                    break;

                  case MENU_MARK_UNREAD:
                    new ConversationLegacy(mContext, threadId).markUnread();
                    break;

                  case MENU_MULTI_SELECT:
                    mAdapter.setSelected(threadId);
                    break;

                  case MENU_DELETE_CONVERSATION:
                    DialogHelper.showDeleteConversationDialog((MainActivity) mContext, threadId);
                    break;
                  case MENU_DELETE_FAILED:
                    // Deletes all failed messages from all conversations
                    DialogHelper.showDeleteFailedMessagesDialog((MainActivity) mContext, threadId);
                    break;
                }
              }
            })
        .show(mContext.getFragmentManager(), "conversation options");
  }
Esempio n. 5
0
  public void sendSms() {
    String body = mReplyText.getText().toString();

    final Drawable attachment;
    if (mAttachment.hasAttachment()) {
      attachment = mAttachment.getDrawable();
    } else {
      attachment = null;
    }
    clearAttachment();

    String[] recipients = null;
    if (mConversation != null) {
      recipients = mConversation.getRecipients().getNumbers();
      for (int i = 0; i < recipients.length; i++) {
        recipients[i] = PhoneNumberUtils.stripSeparators(recipients[i]);
      }
    } else if (mRecipientProvider != null) {
      recipients = mRecipientProvider.getRecipientAddresses();
    }

    // If we have some recipients, send the message!
    if (recipients != null && recipients.length > 0) {
      mReplyText.setText("");

      AnalyticsManager.getInstance()
          .sendEvent(
              AnalyticsManager.CATEGORY_MESSAGES, AnalyticsManager.ACTION_SEND_MESSAGE, mLabel);

      Transaction sendTransaction = new Transaction(mContext, SmsHelper.getSendSettings(mContext));

      com.moez.QKSMS.mmssms.Message message = new com.moez.QKSMS.mmssms.Message(body, recipients);
      message.setType(com.moez.QKSMS.mmssms.Message.TYPE_SMSMMS);
      if (attachment != null) {
        message.setImage(ImageUtils.drawableToBitmap(attachment));
      }

      // Notify the listener about the new text message
      if (mOnSendListener != null) {
        mOnSendListener.onSend(recipients, message.getSubject());
      }

      long threadId = mConversation != null ? mConversation.getThreadId() : 0;
      if (!message.toString().equals("")) {
        sendTransaction.sendNewMessage(message, threadId);
      }
      NotificationManager.update(mContext);

      if (mConversationLegacy != null) {
        mConversationLegacy.markRead();
      }

      // Reset the image button state
      updateButtonState();

      // Otherwise, show a toast to the user to prompt them to add recipients.
    } else {
      Toast.makeText(mContext, mRes.getString(R.string.error_no_recipients), Toast.LENGTH_SHORT)
          .show();
    }
  }