public List<Message> getMessages(String userId, Long startTime, Long endTime) { return getMessages(startTime, endTime, new Contact(userId), null, null, false); }
public static Contact getContact(Context context, String number) { if (TextUtils.isEmpty(number)) { return new Contact(); } String contactId = ""; Uri uri = Uri.withAppendedPath(ContactsContract.PhoneLookup.CONTENT_FILTER_URI, Uri.encode(number)); Cursor phoneCursor = context.getContentResolver().query(uri, new String[]{ContactsContract.PhoneLookup._ID, ContactsContract.PhoneLookup.NUMBER}, null, null, null); try { if (phoneCursor != null && phoneCursor.moveToNext()) { contactId = phoneCursor.getString(0); number = phoneCursor.getString(1); } } finally { if (phoneCursor != null) { phoneCursor.close(); } } return getContact(context, contactId, number); }
public static Contact getContactByEmailId(Context context, String emailId) { Contact contact = new Contact(); String contactNumber = emailId; String contactId = null; String displayName = ""; Cursor cursor = context.getContentResolver().query(ContactsContract.Data.CONTENT_URI, new String[]{ContactsContract.CommonDataKinds.Email.CONTACT_ID, ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME, ContactsContract.CommonDataKinds.Phone.NUMBER}, ContactsContract.CommonDataKinds.Email.DATA + "=?", new String[]{emailId}, null); try { while (cursor.moveToNext()) { contactId = cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Email.CONTACT_ID)); contactNumber = cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)); displayName = cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME)); } } finally { if (cursor != null) { cursor.close(); } } if (contactId != null) { contactNumber = getContactNumberByContactId(context, contactId); contact.setContactId(Long.parseLong(contactId)); } contact.processFullName(displayName); contact.setContactNumber(contactNumber); return contact; }
public synchronized String[] getOnlineUsers(int numberOfUser) { try { Map<String, String> userMapList = userClientService.getOnlineUserList(numberOfUser); if (userMapList != null && userMapList.size() > 0) { String[] userIdArray = new String[userMapList.size()]; Set<String> userIds = new HashSet<String>(); int i = 0; for (Map.Entry<String, String> keyValue : userMapList.entrySet()) { Contact contact = new Contact(); contact.setUserId(keyValue.getKey()); contact.setConnected(keyValue.getValue().contains("true")); userIdArray[i] = keyValue.getKey(); userIds.add(keyValue.getKey()); baseContactService.upsert(contact); i++; } processUserDetails(userIds); return userIdArray; } } catch (Exception e) { e.printStackTrace(); } return null; }
Contact contact = new Contact();
Contact newContact = new Contact(); newContact.setContactNumber(formattedPhoneNumber); newContact.setUserId(lookupKey);
Contact contact = new Contact(); contact.setUserId(keyValue.getKey()); contact.setFullName(keyValue.getValue());
@Test public void testDeleteSync_withContact_returnSuccess() { try { Contact contact = new Contact(); contact.setUserId("testUserId"); when(messageClientService.syncDeleteConversationThreadFromServer(contact, null)).thenReturn("success"); assertEquals("success", mobiComConversationService.deleteSync(contact, null, null)); // Check if method is called... Mockito.verify(messageDatabaseService, Mockito.times(1)).deleteConversation(anyString()); } catch (Exception e) { e.printStackTrace(); } }
@Test public void testDeleteMessage() { try { Message message = (Message) GsonUtils.getObjectFromJson(MockConstants.Message, Message.class); Mockito.when(messageDatabaseService.deleteMessage(any(Message.class), anyString())).thenReturn("checkMe"); Mockito.when(messageClientService.deleteMessage(any(Message.class), nullable(Contact.class))).thenReturn("success"); mobiComConversationService.deleteMessage(message, new Contact()); Mockito.verify(messageDatabaseService, Mockito.times(1)).deleteMessage(any(Message.class), nullable(String.class)); } catch (Exception e) { e.printStackTrace(); } }
channel = new Channel(message.getGroupId()); } else { contact = new Contact(message.getContactIds());
@Override public Contact getContactById(String contactId) { Contact contact = contactDatabase.getContactById(contactId); if (contact != null) { contact.processContactNumbers(context); } else { contact = new Contact(context, contactId); if (Applozic.getInstance(context).isDeviceContactSync()) { upsert(contact); } else { add(contact); } } return contact; }
channel = new Channel(message.getGroupId()); } else { contact = new Contact(message.getContactIds());
public Contact getSupportContact() { Contact contact = new Contact(); contact.setFirstName("Support"); contact.setLastName(""); contact.setFullName("Support"); contact.setContactNumber(getSupportNumber()); contact.setFormattedContactNumber(getSupportNumber()); return contact; } }
@Test public void processUserDetails() { try { List<UserDetail> userDetails = new ArrayList<UserDetail>(); userDetails.add(new UserDetail()); SyncUserDetailsResponse response = new SyncUserDetailsResponse(); response.setGeneratedAt("GEneratedAtString"); response.setStatus("success"); response.setResponse(userDetails); when(messageClientService.getUserDetailsList(anyString())).thenReturn(response); when(appContactService.getContactById("")).thenReturn(new Contact()); Mockito.doNothing().when(appContactService).upsert(any(Contact.class)); mobiComConversationService.processLastSeenAtStatus(); assertEquals(response.getGeneratedAt(), MobiComUserPreference.getInstance(context).getLastSeenAtSyncTime()); } catch (Exception e) { e.printStackTrace(); } }
public synchronized void processMuteUserResponse(MuteUserResponse response) { Contact contact = new Contact(); contact.setUserId(response.getUserId()); BroadcastService.sendMuteUserBroadcast(context, BroadcastService.INTENT_ACTIONS.MUTE_USER_CHAT.toString(), true, response.getUserId()); if (!TextUtils.isEmpty(response.getImageLink())) { contact.setImageURL(response.getImageLink()); } contact.setUnreadCount(response.getUnreadCount()); if (response.getNotificationAfterTime() != null && response.getNotificationAfterTime() != 0) { contact.setNotificationAfterTime(response.getNotificationAfterTime()); } contact.setConnected(response.isConnected()); baseContactService.upsert(contact); }
private void buildSupportContactData() { Context context = getApplicationContext(); AppContactService appContactService = new AppContactService(context); // avoid each time update .... if (!appContactService.isContactExists(getString(R.string.support_contact_userId))) { Contact contact = new Contact(); contact.setUserId(getString(R.string.support_contact_userId)); contact.setFullName(getString(R.string.support_contact_display_name)); contact.setContactNumber(getString(R.string.support_contact_number)); contact.setImageURL(getString(R.string.support_contact_image_url)); contact.setEmailId(getString(R.string.support_contact_emailId)); appContactService.add(contact); } }
public synchronized void processUser(UserDetail userDetail, Contact.ContactType contactType) { Contact contact = new Contact(); contact.setUserId(userDetail.getUserId()); contact.setContactNumber(userDetail.getPhoneNumber()); contact.setConnected(userDetail.isConnected()); contact.setStatus(userDetail.getStatusMessage()); if (!TextUtils.isEmpty(userDetail.getDisplayName())) { contact.setFullName(userDetail.getDisplayName()); } contact.setLastSeenAt(userDetail.getLastSeenAtTime()); contact.setUserTypeId(userDetail.getUserTypeId()); contact.setUnreadCount(0); contact.setLastMessageAtTime(userDetail.getLastMessageAtTime()); contact.setMetadata(userDetail.getMetadata()); contact.setRoleType(userDetail.getRoleType()); contact.setDeletedAtTime(userDetail.getDeletedAtTime()); if (!TextUtils.isEmpty(userDetail.getImageLink())) { contact.setImageURL(userDetail.getImageLink()); } if (Applozic.getInstance(context).isDeviceContactSync()) { contact.setDeviceContactType(contactType.getValue()); } else { contact.setContactType(contactType.getValue()); } baseContactService.upsert(contact); }
public void processUserDetails(UserDetail[] userDetails) { if (userDetails != null && userDetails.length > 0) { for (UserDetail userDetail : userDetails) { Contact contact = new Contact(); contact.setUserId(userDetail.getUserId()); contact.setContactNumber(userDetail.getPhoneNumber()); contact.setConnected(userDetail.isConnected()); if (!TextUtils.isEmpty(userDetail.getDisplayName())) { contact.setFullName(userDetail.getDisplayName()); } contact.setLastSeenAt(userDetail.getLastSeenAtTime()); contact.setStatus(userDetail.getStatusMessage()); contact.setUnreadCount(userDetail.getUnreadCount()); contact.setUserTypeId(userDetail.getUserTypeId()); contact.setImageURL(userDetail.getImageLink()); contact.setDeletedAtTime(userDetail.getDeletedAtTime()); contact.setLastMessageAtTime(userDetail.getLastMessageAtTime()); contact.setMetadata(userDetail.getMetadata()); contact.setRoleType(userDetail.getRoleType()); baseContactService.upsert(contact); } } }
public synchronized Contact getContactFromUserDetail(UserDetail userDetail, Contact.ContactType contactType) { Contact contact = new Contact(); contact.setUserId(userDetail.getUserId()); contact.setContactNumber(userDetail.getPhoneNumber()); contact.setConnected(userDetail.isConnected()); contact.setStatus(userDetail.getStatusMessage()); if (!TextUtils.isEmpty(userDetail.getDisplayName())) { contact.setFullName(userDetail.getDisplayName()); } contact.setLastSeenAt(userDetail.getLastSeenAtTime()); contact.setUserTypeId(userDetail.getUserTypeId()); contact.setUnreadCount(0); contact.setLastMessageAtTime(userDetail.getLastMessageAtTime()); contact.setMetadata(userDetail.getMetadata()); contact.setRoleType(userDetail.getRoleType()); contact.setDeletedAtTime(userDetail.getDeletedAtTime()); if (!TextUtils.isEmpty(userDetail.getImageLink())) { contact.setImageURL(userDetail.getImageLink()); } if (Applozic.getInstance(context).isDeviceContactSync()) { contact.setDeviceContactType(contactType.getValue()); } else { contact.setContactType(contactType.getValue()); } baseContactService.upsert(contact); return contact; }
private void processUserDetails(SyncUserDetailsResponse userDetailsResponse) { for (UserDetail userDetail : userDetailsResponse.getResponse()) { Contact newContact = baseContactService.getContactById(userDetail.getUserId()); Contact contact = new Contact(); contact.setUserId(userDetail.getUserId()); contact.setContactNumber(userDetail.getPhoneNumber());