public String getIpMessageSrvNumberName(String number) { NmsLog.trace(TAG, "getIpMessageSrvNumberName. number is " + number); if (TextUtils.isEmpty(number)) { NmsLog.error(TAG, "getIpMessageSrvNumberName. number is empty!"); return null; } if (number.contains("@")) { NmsLog.error(TAG, "getIpMessageSrvNumberName. number is include contain @"); return null; } short[] ids = engineadapter.get().nmsUIGetServiceContactList(); if (ids != null) { for (int i = 0; i < ids.length; ++i) { NmsLog.trace(TAG, "hesine customer service id is " + ids[i]); NmsUIContact contact = getContactInfoViaEngineContactId(ids[i]); if (contact != null && contact.getNumberOrEmail().equals(number)) { NmsLog.trace(TAG, "hesine customer service id name " + contact.getName()); return contact.getName(); } } } else { NmsLog.trace(TAG, "hesine customer service num is null"); } return null; }
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); }
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(); // } }
public short getEngineContactIdViaSystemMsgId(long msgId) { if (msgId <= 0) { NmsLog.error(TAG, "msgId2engineId. msgId is invalid!"); return -1; } long threadId = NmsSMSMMSManager.getInstance(mContext).getThreadViaSysMsgId(msgId); if (threadId <= 0) { NmsLog.error(TAG, "msgId2engineId. threadId is invalid!"); return -1; } return getEngineContactIdViaSystemThreadId(threadId); }
public short getMyselfEngineContactIdViaSimId(int simId) { if (simId < 0) { NmsLog.error(TAG, "simId < 0."); return -1; } SNmsSimInfo simInfo = NmsIpMessageApiNative.nmsGetSimInfoViaSimId(simId); if (simInfo == null) { NmsLog.error(TAG, "simInfo is null."); return -1; } return getEngineContactIdViaNumber(simInfo.number); }
public long getSystemContactIdViaContactUri(Uri uri) { if (uri == null) { NmsLog.error(TAG, "getSystemContactIdViaContactUri is invalid!"); return -1; } long result = -1; Cursor cursor = null; try { cursor = NmsContentResolver.query( mContext.getContentResolver(), uri, new String[] {Contacts._ID}, null, null, null); if (cursor != null && cursor.moveToFirst()) { result = cursor.getLong(cursor.getColumnIndex(Contacts._ID)); } } catch (Exception e) { NmsLog.nmsPrintStackTrace(e); } finally { if (cursor != null) { cursor.close(); cursor = null; } } return result; }
public String getSystemNameViaSystemContactId(long systemContactId) { if (systemContactId <= 0) { NmsLog.error(TAG, "getSystemNameViaSystemContactId: sysContactId is invalid!"); return null; } String result = ""; Cursor cursor = null; try { cursor = NmsContentResolver.query( mContext.getContentResolver(), Contacts.CONTENT_URI, new String[] {Contacts.DISPLAY_NAME}, Contacts._ID + "=?", new String[] {String.valueOf(systemContactId)}, null); if (cursor != null && cursor.moveToFirst()) { result = cursor.getString(cursor.getColumnIndex(Contacts.DISPLAY_NAME)); } } catch (Exception e) { NmsLog.nmsPrintStackTrace(e); } finally { if (cursor != null) { cursor.close(); cursor = null; } } return result == null ? "" : result; }
public void buildGroupMembers(short[] contactId, boolean isAlive) { memberList.clear(); if (isAlive) { NmsContact selfPerson = new NmsContact(); selfPerson.setName( this.getResources().getText(R.string.STR_NMS_GROUP_MEMEBER_YOU).toString()); selfPerson.setId( NmsContactApi.getInstance(mContext) .getMyselfEngineContactIdViaSimId( (int) NmsPlatformAdapter.getInstance(mContext).getCurrentSimId())); memberList.add(selfPerson); } if (contactId != null) { for (short id : contactId) { NmsContact contact = NmsIpMessageApiNative.nmsGetContactInfoViaEngineId(id); if (contact != null) { memberList.add(contact); } else { NmsLog.error(Tag, "can't get contact info. engineContactId:" + id); } } } }
public boolean nmsDeleteMsgFromImportantList(long[] msgIds) { if (msgIds == null || msgIds.length <= 0) { NmsLog.error(HissageTag.api, "nmsDeleteMsgFromImportantList param error."); return false; } Bundle param = new Bundle(); param.putLongArray(FUNC_ID_nmsDeleteMsgFromImportantList + 1, msgIds); Bundle back = mApiProviders.call(API_CONTENT_URI, FUNC_ID_nmsDeleteMsgFromImportantList, null, param); if (back != null) { return back.getBoolean(FUNC_ID_nmsDeleteMsgFromImportantList); } else { NmsLog.error(HissageTag.api, "failed to delete msg from important list, return false"); return false; } }
private SystemContactSummary getSystemContactSummaryViaNumber(String number) { if (TextUtils.isEmpty(number)) { NmsLog.error(TAG, "getSystemContactSummaryViaNumber. number is empty!"); return null; } String encodeNumber = Uri.encode(number); if (TextUtils.isEmpty(encodeNumber)) { NmsLog.error(TAG, "getSystemContactSummaryViaNumber. encodeNumber is empty!"); return null; } SystemContactSummary result = null; Cursor cursor = null; try { Uri lookupUri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, encodeNumber); cursor = NmsContentResolver.query( mContext.getContentResolver(), lookupUri, new String[] {PhoneLookup._ID, PhoneLookup.DISPLAY_NAME, PhoneLookup.NUMBER}, null, null, null); if (cursor != null && cursor.moveToFirst()) { result = new SystemContactSummary(); result.contactId = cursor.getLong(cursor.getColumnIndex(PhoneLookup._ID)); result.name = cursor.getString(cursor.getColumnIndex(PhoneLookup.DISPLAY_NAME)); result.number = NmsCommonUtils.nmsGetStandardPhoneNum( cursor.getString(cursor.getColumnIndex(PhoneLookup.NUMBER))); } } catch (Exception e) { NmsLog.error(TAG, "number: " + number + ". encodeNumber: " + encodeNumber); NmsLog.nmsPrintStackTrace(e); } finally { if (cursor != null) { cursor.close(); cursor = null; } } return result; }
public boolean isExistSystemContactViaEmail(String email) { if (TextUtils.isEmpty(email)) { NmsLog.error(TAG, "isExistSystemContactViaEmail. email is empty!"); return false; } if (!email.contains("@")) { NmsLog.error(TAG, "isExistSystemContactViaEmail. email is invalid"); return false; } String encodeEmail = Uri.encode(email); if (TextUtils.isEmpty(encodeEmail)) { NmsLog.error(TAG, "isExistSystemContactViaEmail. encodeEmail is empty!"); return false; } Cursor cursor = null; boolean result = false; try { Uri lookupUri = Uri.withAppendedPath(Email.CONTENT_LOOKUP_URI, encodeEmail); cursor = NmsContentResolver.query( mContext.getContentResolver(), lookupUri, new String[] {Email.CONTACT_ID}, null, null, null); if (cursor != null && cursor.moveToFirst()) { result = true; } } catch (Exception e) { NmsLog.error(TAG, "email: " + email + ". encodeEmail: " + encodeEmail); NmsLog.nmsPrintStackTrace(e); } finally { if (cursor != null) { cursor.close(); cursor = null; } } return result; }
public boolean isExistSystemContactViaNumber(String number) { if (TextUtils.isEmpty(number)) { NmsLog.error(TAG, "isExistSystemContact. number is empty!"); return false; } if (getSystemContactSummaryViaNumber(number) != null) { return true; } else { return false; } }
public void nmsDeleteIpMsg(final long[] ids, boolean delImportant, boolean isDelMsgInSmsDb) { if (ids == null || ids.length <= 0) { NmsLog.error(HissageTag.api, "nmsDeleteIpMsg param error."); return; } Bundle param = new Bundle(); param.putLongArray(FUNC_ID_nmsDeleteIpMsg + 1, ids); param.putBoolean(FUNC_ID_nmsDeleteIpMsg + 2, delImportant); param.putBoolean(FUNC_ID_nmsDeleteIpMsg + 3, isDelMsgInSmsDb); mApiProviders.call(API_CONTENT_URI, FUNC_ID_nmsDeleteIpMsg, null, param); };
public boolean nmsDeleteContactFromSpamList(int[] engineContactIds) { Bundle param = new Bundle(); if (engineContactIds == null || engineContactIds.length <= 0) { NmsLog.error(HissageTag.api, "The engineContactIds is null or the length is 0"); return false; } short[] s = new short[engineContactIds.length]; for (int i = 0; i < engineContactIds.length; i++) { s[i] = (short) engineContactIds[i]; } param.putShortArray(FUNC_ID_nmsDeleteContactFromSpamList + 1, s); Bundle back = mApiProviders.call(API_CONTENT_URI, FUNC_ID_nmsDeleteContactFromSpamList, null, param); if (back != null) { return back.getBoolean(FUNC_ID_nmsDeleteContactFromSpamList); } else { NmsLog.error(HissageTag.api, "failed to delete contact from spam list, return false"); return false; } }
public static boolean isGroupChatContactNumber(String number) { if (TextUtils.isEmpty(number)) { NmsLog.error(TAG, "number is empty, return false"); return false; } if (number.length() == NMS_CLIENT_GUID_LEN && number.indexOf(NmsGroupChatContact.NMS_GUID_PREFIX) == 0) { return true; } else { return false; } }
private Bitmap getMyselfAvatarViaSimId(int simId) { if (simId < 0) { NmsLog.error(TAG, "simId < 0.."); return null; } SNmsSimInfo simInfo = NmsIpMessageApiNative.nmsGetSimInfoViaSimId(simId); if (simInfo == null) { NmsLog.error(TAG, "simInfo is null"); return null; } Bitmap result = getSystemAvatarViaNumber(simInfo.number); if (result == null) { NmsProfileSettings userProfile = engineadapter.get().nmsUIGetUserInfoViaImsi(simInfo.imsi); if (userProfile != null) { result = userProfile.getProfileSettingsAvatar(); } } return result; }
public long getSystemContactIdViaNumber(String number) { if (TextUtils.isEmpty(number)) { NmsLog.error(TAG, "getSystemContactIdViaNumber. number is empty!"); return -1; } long result = -1; SystemContactSummary cs = getSystemContactSummaryViaNumber(number); if (cs != null) { result = cs.contactId; } return result; }
public String getSystemNumberViaNumber(String number) { if (TextUtils.isEmpty(number)) { NmsLog.error(TAG, "getSystemNumberViaNumber. number is empty!"); return null; } String result = ""; SystemContactSummary cs = getSystemContactSummaryViaNumber(number); if (cs != null) { result = cs.number; } return result == null ? "" : result; }
public Bitmap getSystemAvatarViaNumber(String number) { if (TextUtils.isEmpty(number)) { NmsLog.error(TAG, "getSystemAvatarViaNumber. number is empty!"); return null; } long systemContactId = getSystemContactIdViaNumber(number); if (systemContactId <= 0) { NmsLog.trace(TAG, "this number is not in System Contact. number:" + number); return null; } return getSystemAvatarViaSystemContactId(systemContactId); }
public String getSystemNameViaNumber(String number) { if (TextUtils.isEmpty(number)) { NmsLog.error(TAG, "getSystemNameViaNumber. number is empty!"); return null; } String result = ""; SystemContactSummary cs = getSystemContactSummaryViaNumber(number); if (cs != null) { result = cs.name; // NmsLog.error("TAG", "test!!! number=" + number + ", name=" + // result); } return result == null ? "" : result; }
public boolean isHissageNumber(String number) { if (TextUtils.isEmpty(number)) { NmsLog.error(TAG, "isHissageNumber. number is empty!"); return false; } if (number.contains("@")) { return false; } String cutNumber = NmsCommonUtils.nmsGetStandardPhoneNum(number); if (TextUtils.isEmpty(cutNumber)) { NmsLog.warn(TAG, "isHisssageNumber. cutNumber is empty!"); } return engineadapter.get().nmsUIGetIsHesineAccount(cutNumber) == 0 ? true : false; }
@Override protected void onCreate(Bundle icicle) { super.onCreate(icicle); requestWindowFeature(Window.FEATURE_NO_TITLE); mContext = this; // this.getApplicationContext(); threadId = getIntent().getLongExtra("threadId", (long) -1); contactId = getIntent().getShortExtra("contactId", (short) -1); phoneNum = getIntent().getStringExtra("PHONE_NUM"); int simId = (int) NmsPlatformAdapter.getInstance(this).getCurrentSimId(); SNmsSimInfo info = NmsIpMessageApiNative.nmsGetSimInfoViaSimId(simId); if (info != null && info.status != NmsSimActivateStatus.NMS_SIM_STATUS_ACTIVATED) { isActive = false; } if (threadId > 0) { contact = NmsIpMessageApiNative.nmsGetContactInfoViaThreadId(threadId); } else { if (contactId > 0) { contact = NmsIpMessageApiNative.nmsGetContactInfoViaEngineId(contactId); } else { contact = NmsIpMessageApiNative.nmsGetContactInfoViaNumber(phoneNum); } } try { if (contact instanceof NmsGroupChatContact) { if (simId != ((NmsGroupChatContact) contact).getSimId()) { isActive = false; } initQuickGroupCard(); } else { initQuickContactCard(); } } catch (Exception e) { NmsLog.error(Tag, "onCreate got the execption: " + NmsLog.nmsGetStactTrace(e)); } }
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; }
public boolean isMyselfEngineContactId(short engContactId) { if (engContactId <= 0) { NmsLog.error(TAG, "engContactId <= 0"); return false; } short[] ids = engineadapter.get().nmsUIGetSelfContactIds(); if (ids == null) { NmsLog.warn(TAG, "engContactIds is null"); return false; } boolean result = false; for (short id : ids) { if (id == engContactId) { result = true; break; } } return result; }
public Bitmap getSystemAvatarViaSystemContactId(long systemContactId) { if (systemContactId <= 0) { NmsLog.error(TAG, "getSystemAvatarViaSystemContactId. sysContactId is invalid!"); return null; } Bitmap result = null; Cursor cursor = null; try { cursor = NmsContentResolver.query( mContext.getContentResolver(), Contacts.CONTENT_URI, new String[] {Contacts.PHOTO_ID}, Contacts._ID + "=?", new String[] {String.valueOf(systemContactId)}, null); if (cursor != null && cursor.moveToFirst()) { long photoId = cursor.getLong(cursor.getColumnIndex(Contacts.PHOTO_ID)); if (photoId > 0) { Uri uri = ContentUris.withAppendedId(Contacts.CONTENT_URI, systemContactId); InputStream input = Contacts.openContactPhotoInputStream(mContext.getContentResolver(), uri); result = BitmapFactory.decodeStream(input); } } } catch (Exception e) { NmsLog.nmsPrintStackTrace(e); } finally { if (cursor != null) { cursor.close(); cursor = null; } } return result; }
public Bitmap getAvatarViaEngineContactId(short engineContactId) { if (engineContactId <= 0) { NmsLog.error(TAG, "getAvatarViaEngineContactId. engineContactId <= 0"); return null; } Bitmap result = null; NmsContact contact = engineadapter.get().nmsUIGetContact(engineContactId); if (contact != null) { if (contact instanceof NmsGroupChatContact) { result = getGroupChatContactAvatar((NmsGroupChatContact) contact); } else if (contact instanceof NmsBroadCastContact) { result = mBroadCastBitmap; } else { result = getSystemAvatarViaNumber(contact.getNumber()); if (result == null) { result = getEngineAvatarViaEngineContactId(contact.getId()); } } } return result; }
public Bitmap getEngineAvatarViaEngineContactId(short engineContactId) { if (engineContactId <= 0) { NmsLog.error(TAG, "getEngineAvatarViaEngineContactId. engineContactId is invalid!"); return null; } Bitmap result = null; if (isMyselfEngineContactId(engineContactId)) { NmsContact contact = engineadapter.get().nmsUIGetContact(engineContactId); NmsProfileSettings userProfile = engineadapter .get() .nmsUIGetUserInfoViaImsi( engineadapter.get().nmsUIGetImsiViaNumber(contact.getNumber())); if (userProfile != null) { result = userProfile.getProfileSettingsAvatar(); } } else { SNmsImg photoPath = engineadapter.get().nmsUIGetContactImg(engineContactId); if (photoPath != null) { if (photoPath.imgPath != null) { try { result = BitmapFactory.decodeFile(photoPath.imgPath); } catch (Exception e) { NmsLog.warn( TAG, "BitmapFactory.decodeFile failed, engineContactId: " + engineContactId); } } else if (photoPath.byteImg != null) { result = BitmapFactory.decodeByteArray(photoPath.byteImg, 0, photoPath.byteImg.length); } } } return result; }
private ArrayList<Bitmap> fillBitmapList( int count, ArrayList<Bitmap> bitmapList, Bitmap defaultBitmap, Bitmap blankBitmap) { if (count < 0 || bitmapList == null || defaultBitmap == null || blankBitmap == null) { NmsLog.error(TAG, "fillBitmapList. parm is error"); return null; } int size = bitmapList.size(); if (count == 0) { if (size == 0) { bitmapList.add(blankBitmap); bitmapList.add(blankBitmap); bitmapList.add(blankBitmap); } else { NmsLog.error(TAG, "count==0, size>0"); return null; } } else if (count == 1) { if (size == 0) { bitmapList.add(defaultBitmap); bitmapList.add(blankBitmap); bitmapList.add(blankBitmap); } else if (size == 1) { bitmapList.add(blankBitmap); bitmapList.add(blankBitmap); } else { NmsLog.error(TAG, "count==1, size>1"); return null; } } else if (count == 2) { if (size == 0) { bitmapList.add(defaultBitmap); bitmapList.add(defaultBitmap); bitmapList.add(blankBitmap); } else if (size == 1) { bitmapList.add(defaultBitmap); bitmapList.add(blankBitmap); } else if (size == 2) { bitmapList.add(blankBitmap); } else { NmsLog.error(TAG, "count==2, size>2"); return null; } } else if (count >= 3) { if (size == 0) { bitmapList.add(defaultBitmap); bitmapList.add(defaultBitmap); bitmapList.add(defaultBitmap); } else if (size == 1) { bitmapList.add(defaultBitmap); bitmapList.add(defaultBitmap); } else if (size == 2) { bitmapList.add(defaultBitmap); } else if (size == 3) { } else { NmsLog.error(TAG, "count>=3, size>3"); return null; } } else { NmsLog.error(TAG, "count<0"); return null; } return bitmapList; }