コード例 #1
0
  /** On Message */
  @Override
  protected void onMessage(
      String target, String sender, String login, String hostname, String text) {
    Message message = new Message(text, sender);
    Conversation conversation = server.getConversation(target);

    if (isMentioned(text)) {
      // highlight
      message.setColor(Message.COLOR_RED);
      if (conversation.getStatus() != Conversation.STATUS_SELECTED || !server.getIsForeground()) {
        service.addNewMention(
            server.getId(),
            conversation,
            target + ": <" + sender + "> " + text,
            service.getSettings().isVibrateHighlightEnabled(),
            service.getSettings().isSoundHighlightEnabled());
      }

      conversation.setStatus(Conversation.STATUS_HIGHLIGHT);
    }

    conversation.addMessage(message);

    Intent intent =
        Broadcast.createConversationIntent(Broadcast.CONVERSATION_MESSAGE, server.getId(), target);
    service.sendBroadcast(intent);
  }
コード例 #2
0
  /** On channel action */
  @Override
  protected void onAction(
      String sender, String login, String hostname, String target, String action) {
    Conversation conversation;

    Message message = new Message(sender + " " + action);
    message.setIcon(R.drawable.action);

    String queryNick = target;
    if (queryNick.equals(this.getNick())) {
      // We are the target - this is an action in a query
      queryNick = sender;
    }
    conversation = server.getConversation(queryNick);

    if (conversation == null) {
      // Open a query if there's none yet
      conversation = new Query(queryNick);
      conversation.setHistorySize(service.getSettings().getHistorySize());
      server.addConversation(conversation);
      conversation.addMessage(message);

      Intent intent =
          Broadcast.createConversationIntent(Broadcast.CONVERSATION_NEW, server.getId(), queryNick);
      service.sendBroadcast(intent);
    } else {
      conversation.addMessage(message);

      Intent intent =
          Broadcast.createConversationIntent(
              Broadcast.CONVERSATION_MESSAGE, server.getId(), queryNick);
      service.sendBroadcast(intent);
    }

    if (sender.equals(this.getNick())) {
      // Don't notify for something sent in our name
      return;
    }

    boolean mentioned = isMentioned(action);
    if (mentioned || target.equals(this.getNick())) {
      if (conversation.getStatus() != Conversation.STATUS_SELECTED || !server.getIsForeground()) {
        service.addNewMention(
            server.getId(),
            conversation,
            conversation.getName() + ": " + sender + " " + action,
            service.getSettings().isVibrateHighlightEnabled(),
            service.getSettings().isSoundHighlightEnabled());
      }
    }

    if (mentioned) {
      // highlight
      message.setColor(Message.COLOR_RED);
      conversation.setStatus(Conversation.STATUS_HIGHLIGHT);
    }
  }
コード例 #3
0
  /** On Private Message */
  @Override
  protected void onPrivateMessage(
      String sender, String login, String hostname, String target, String text) {
    Message message = new Message("<" + sender + "> " + text);
    String queryNick = sender;

    if (queryNick.equals(this.getNick())) {
      queryNick = target;
    }
    Conversation conversation = server.getConversation(queryNick);

    if (conversation == null) {
      // Open a query if there's none yet
      conversation = new Query(queryNick);
      conversation.setHistorySize(service.getSettings().getHistorySize());
      conversation.addMessage(message);
      server.addConversation(conversation);

      Intent intent =
          Broadcast.createConversationIntent(Broadcast.CONVERSATION_NEW, server.getId(), queryNick);
      service.sendBroadcast(intent);
    } else {
      conversation.addMessage(message);

      Intent intent =
          Broadcast.createConversationIntent(
              Broadcast.CONVERSATION_MESSAGE, server.getId(), queryNick);
      service.sendBroadcast(intent);
    }

    if (sender.equals(this.getNick())) {
      // Don't notify for something sent in our name
      return;
    }

    if (conversation.getStatus() != Conversation.STATUS_SELECTED || !server.getIsForeground()) {
      service.addNewMention(
          server.getId(),
          conversation,
          "<" + sender + "> " + text,
          service.getSettings().isVibrateHighlightEnabled(),
          service.getSettings().isSoundHighlightEnabled());
    }

    if (isMentioned(text)) {
      message.setColor(Message.COLOR_RED);
      conversation.setStatus(Conversation.STATUS_HIGHLIGHT);
    }
  }