private void viewGroupChatInfo() {

    NmsGroupChatContact groupContact = (NmsGroupChatContact) contact;

    if (groupContact.isAlive() && isActive) {
      finish();
      Intent i = new Intent(this, NmsGroupChatInfoActivity.class);
      i.putExtra("groupId", groupContact.getId());
      startActivity(i);
    }
  }
  public void selectGroupMembers(String[] contactId) {
    List<String> members = new ArrayList<String>();
    NmsGroupChatContact groupContact = (NmsGroupChatContact) contact;
    short groupId = groupContact.getId();
    if (contactId != null) {
      NmsLog.trace(Tag, "Add group members to group chat, the groupId:" + groupId);
      if (groupId > 0) {
        for (String id : contactId) {
          short engineContactId = Short.valueOf(id);
          NmsContact contact = NmsIpMessageApiNative.nmsGetContactInfoViaEngineId(engineContactId);
          if (contact != null) {
            members.add(contact.getNumber());
          } else {
            NmsLog.error(Tag, "can't get contact info. engineContactId:" + id);
          }
        }

        boolean ret = NmsIpMessageApiNative.nmsAddMembersToGroup(groupId, members);
        if (ret) {
          for (String id : contactId) {
            short engineContactId = Short.valueOf(id);
            NmsContact contact =
                NmsIpMessageApiNative.nmsGetContactInfoViaEngineId(engineContactId);
            if (contact != null) {
              memberList.add(contact);
            } else {
              NmsLog.error(Tag, "can't get contact info. engineContactId:" + id);
            }
          }
          Toast.makeText(mContext, R.string.STR_NMS_ADD_GROUP_MEMBER_SUCCESS, Toast.LENGTH_SHORT)
              .show();
        } else {
          Toast.makeText(mContext, R.string.STR_NMS_ADD_GROUP_MEMBER_FAILED, Toast.LENGTH_SHORT)
              .show();
        }
      } else {
        for (String id : contactId) {
          short engineContactId = Short.valueOf(id);
          NmsContact contact = NmsIpMessageApiNative.nmsGetContactInfoViaEngineId(engineContactId);
          if (contact != null) {
            memberList.add(contact);
          } else {
            NmsLog.error(Tag, "can't get contact info. engineContactId:" + id);
          }
        }
      }
    }

    // if (GroupChatMode.VIEW == groupChatMode) {
    // buildViewGroupMembers();
    // }
  }
Esempio n. 3
0
  public short getEngineContactIdViaNumber(String number) {
    String formatNumber = null;

    if (TextUtils.isEmpty(number)) {
      NmsLog.error(TAG, "number2engineId. number is empty!");
      return -1;
    }
    if (number.contains(",")) { // for broadcast
      formatNumber = number;
    } else {
      if (number.length() > NmsCustomUIConfig.PHONENUM_MAX_LENGTH
          && !NmsGroupChatContact.isGroupChatContactNumber(number)) {
        NmsLog.error(TAG, "number2engineId. number is too long!");
        return -1;
      }

      if (!NmsCommonUtils.isPhoneNumberValid(number)) {
        NmsLog.error(TAG, "number2engineId. number(" + number + ") is invalid!");
        return -1;
      }

      formatNumber = NmsCommonUtils.nmsGetStandardPhoneNum(number);
      if (TextUtils.isEmpty(formatNumber)) {
        NmsLog.error(TAG, "number2engineId. formatNumber is invalid!");
      }
    }

    return (short) engineadapter.get().nmsUIGetContactId(formatNumber);
  }
Esempio n. 4
0
  public Bitmap getGroupChatContactAvatar(NmsGroupChatContact groupChatContact) {
    if (groupChatContact == null) {
      NmsLog.error(TAG, "groupChatContact is invalid!");
      return null;
    }

    ArrayList<Bitmap> bitmapList = new ArrayList<Bitmap>();

    short[] memberIds = groupChatContact.getMemberIds();

    if (memberIds != null) {
      for (int index = 0; index < memberIds.length && bitmapList.size() < 3; ++index) {
        Bitmap avatar = getAvatarViaEngineContactId(memberIds[index]);
        if (avatar != null) {
          bitmapList.add(avatar);
        }
      }
    } else {
      NmsLog.warn(TAG, "memberIds is null.");
    }

    if (bitmapList.size() < 3 && groupChatContact.isAlive()) {
      // myself bitmap
      Bitmap avatar = getMyselfAvatarViaSimId(groupChatContact.getSimId());
      if (avatar == null) {
        avatar = mDefaultBitmap;
      }
      bitmapList.add(avatar);
    }

    bitmapList =
        fillBitmapList(groupChatContact.getMemberCount(), bitmapList, mDefaultBitmap, mBlankBitmap);

    Bitmap result = null;
    if (bitmapList != null && bitmapList.size() == 3) {
      result = NmsCommonUtils.stitchBitmap(bitmapList.get(0), bitmapList.get(1), bitmapList.get(2));
    }

    return result;
  }
  private void initQuickGroupCard() {
    setContentView(R.layout.quick_group_contact);

    NmsGroupChatContact groupContact = (NmsGroupChatContact) contact;
    short[] members = groupContact.getMemberIds();
    buildGroupMembers(members, groupContact.isAlive());

    TextView tvName = (TextView) this.findViewById(R.id.tv_name);
    tvName.setText(groupContact.getName());

    TextView tvCount = (TextView) this.findViewById(R.id.tv_count);
    tvCount.setText(String.valueOf(groupContact.getMemberCount()));

    Button btnInvite = (Button) this.findViewById(R.id.btn_invite);
    btnInvite.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stub
            addGroupChatMembers();
          }
        });
    Button btnChat = (Button) this.findViewById(R.id.btn_chat);
    btnChat.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stub
            chat();
          }
        });

    Button btnWelcome = (Button) this.findViewById(R.id.btn_welcome);
    btnWelcome.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stub
            chat();
          }
        });
    LinearLayout llWelcome = (LinearLayout) this.findViewById(R.id.ll_group);

    if (groupContact.isAlive() && isActive) {
      btnWelcome.setVisibility(View.GONE);
    } else {
      llWelcome.setVisibility(View.GONE);
      btnWelcome.setVisibility(View.VISIBLE);
    }

    GridView gv = (GridView) this.findViewById(R.id.gv_group_card);

    GroupListAdapter adapter = new GroupListAdapter(this);
    gv.setAdapter(adapter);

    gv.setOnItemClickListener(
        new OnItemClickListener() {

          @Override
          public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
            // TODO Auto-generated method stub
            viewGroupChatInfo();
          }
        });
  }