Search in sources :

Example 76 with Contact

use of com.applozic.mobicommons.people.contact.Contact in project Applozic-Android-SDK by AppLozic.

the class MobiComConversationFragment method sendMessage.

protected void sendMessage() {
    if (channel != null) {
        if (Channel.GroupType.GROUPOFTWO.getValue().equals(channel.getType())) {
            String userId = ChannelService.getInstance(getActivity()).getGroupOfTwoReceiverUserId(channel.getKey());
            if (!TextUtils.isEmpty(userId)) {
                Contact withUserContact = appContactService.getContactById(userId);
                if (withUserContact.isBlocked()) {
                    userBlockDialog(false, withUserContact, true);
                } else {
                    handleSendAndRecordButtonView(false);
                    processSendMessage();
                }
            }
        } else if (Channel.GroupType.OPEN.getValue().equals(channel.getType())) {
            if (Utils.isInternetAvailable(getActivity())) {
                handleSendAndRecordButtonView(false);
                processSendMessage();
            } else {
                Toast.makeText(ApplozicService.getContext(getContext()), ApplozicService.getContext(getContext()).getString(R.string.internet_connection_not_available), Toast.LENGTH_SHORT).show();
            }
        } else {
            handleSendAndRecordButtonView(false);
            processSendMessage();
        }
    } else if (contact != null) {
        if (contact.isBlocked()) {
            userBlockDialog(false, contact, false);
        } else {
            handleSendAndRecordButtonView(false);
            processSendMessage();
        }
    }
}
Also used : Contact(com.applozic.mobicommons.people.contact.Contact)

Example 77 with Contact

use of com.applozic.mobicommons.people.contact.Contact in project Applozic-Android-SDK by AppLozic.

the class AlTypingIndicator method createView.

/**
 * This method is always called whenever the typing status change is received from the subscribed userId or Group
 * Be careful to instantiate your views here.
 */
public void createView() {
    Contact contact = new AppContactService(getContext()).getContactById(typerUserId);
    removeAllViews();
    if (typingText == null) {
        typingText = new TextView(getContext());
        LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
        typingText.setLayoutParams(params);
        typingText.setTextSize(14);
        typingText.setTextColor(getContext().getResources().getColor(R.color.apploizc_black_color));
    }
    addView(typingText);
    if (isTyping) {
        typingText.setText((contact != null ? contact.getDisplayName() : "") + " is Typing...");
    } else {
        typingText.setText((contact != null ? contact.getDisplayName() : "") + " is not Typing...");
    }
}
Also used : AppContactService(com.applozic.mobicomkit.contact.AppContactService) TextView(android.widget.TextView) Contact(com.applozic.mobicommons.people.contact.Contact)

Example 78 with Contact

use of com.applozic.mobicommons.people.contact.Contact in project Applozic-Android-SDK by AppLozic.

the class UserService method processSyncUserBlock.

/**
 * Internal. Do not use.
 *
 * This method handle block user syncing. Calling this method is done internally by the SDK.
 */
public synchronized void processSyncUserBlock() {
    try {
        SyncBlockUserApiResponse apiResponse = userClientService.getSyncUserBlockList(userPreference.getUserBlockSyncTime());
        if (apiResponse != null && SyncBlockUserApiResponse.SUCCESS.equals(apiResponse.getStatus())) {
            SyncUserBlockListFeed syncUserBlockListFeed = apiResponse.getResponse();
            if (syncUserBlockListFeed != null) {
                List<SyncUserBlockFeed> blockedToUserList = syncUserBlockListFeed.getBlockedToUserList();
                List<SyncUserBlockFeed> blockedByUserList = syncUserBlockListFeed.getBlockedByUserList();
                if (blockedToUserList != null && blockedToUserList.size() > 0) {
                    for (SyncUserBlockFeed syncUserBlockedFeed : blockedToUserList) {
                        Contact contact = new Contact();
                        if (syncUserBlockedFeed.getUserBlocked() != null && !TextUtils.isEmpty(syncUserBlockedFeed.getBlockedTo())) {
                            if (baseContactService.isContactExists(syncUserBlockedFeed.getBlockedTo())) {
                                baseContactService.updateUserBlocked(syncUserBlockedFeed.getBlockedTo(), syncUserBlockedFeed.getUserBlocked());
                            } else {
                                contact.setBlocked(syncUserBlockedFeed.getUserBlocked());
                                contact.setUserId(syncUserBlockedFeed.getBlockedTo());
                                baseContactService.upsert(contact);
                                baseContactService.updateUserBlocked(syncUserBlockedFeed.getBlockedTo(), syncUserBlockedFeed.getUserBlocked());
                            }
                        }
                    }
                }
                if (blockedByUserList != null && blockedByUserList.size() > 0) {
                    for (SyncUserBlockFeed syncUserBlockByFeed : blockedByUserList) {
                        Contact contact = new Contact();
                        if (syncUserBlockByFeed.getUserBlocked() != null && !TextUtils.isEmpty(syncUserBlockByFeed.getBlockedBy())) {
                            if (baseContactService.isContactExists(syncUserBlockByFeed.getBlockedBy())) {
                                baseContactService.updateUserBlockedBy(syncUserBlockByFeed.getBlockedBy(), syncUserBlockByFeed.getUserBlocked());
                            } else {
                                contact.setBlockedBy(syncUserBlockByFeed.getUserBlocked());
                                contact.setUserId(syncUserBlockByFeed.getBlockedBy());
                                baseContactService.upsert(contact);
                                baseContactService.updateUserBlockedBy(syncUserBlockByFeed.getBlockedBy(), syncUserBlockByFeed.getUserBlocked());
                            }
                        }
                    }
                }
            }
            userPreference.setUserBlockSyncTime(apiResponse.getGeneratedAt());
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : SyncUserBlockListFeed(com.applozic.mobicomkit.sync.SyncUserBlockListFeed) SyncBlockUserApiResponse(com.applozic.mobicomkit.feed.SyncBlockUserApiResponse) SyncUserBlockFeed(com.applozic.mobicomkit.sync.SyncUserBlockFeed) ApplozicException(com.applozic.mobicomkit.exception.ApplozicException) Contact(com.applozic.mobicommons.people.contact.Contact)

Example 79 with Contact

use of com.applozic.mobicommons.people.contact.Contact in project Applozic-Android-SDK by AppLozic.

the class UserService method getOnlineUsers.

/**
 * Retrieves a list of the current online users from the server. They are also saved locally.
 *
 * <p>This methods updates the local database for these retrieved users by calling {@link UserService#processUserDetail(Set)}.</p>
 *
 * <p>Note: This method has database and network operation. Run it asynchronously.</p>
 *
 * @param numberOfUser the number of users to return
 * @return array of userIds of the online users
 */
@Nullable
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;
}
Also used : HashMap(java.util.HashMap) Map(java.util.Map) SuppressLint(android.annotation.SuppressLint) ApplozicException(com.applozic.mobicomkit.exception.ApplozicException) HashSet(java.util.HashSet) Contact(com.applozic.mobicommons.people.contact.Contact) Nullable(androidx.annotation.Nullable)

Example 80 with Contact

use of com.applozic.mobicommons.people.contact.Contact in project Applozic-Android-SDK by AppLozic.

the class UserService method processUser.

// Cleanup: private or rename
/**
 * Internal. Do not use.
 *
 * This method inserts/updates the user(user detail) in the local database.
 *
 * <p>Note: This method has database and network operation. Run it asynchronously.</p>
 *
 * @param userDetail the user detail to save
 * @param contactType the contact type of the user
 */
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());
    contact.setEmailId(userDetail.getEmailId());
    if (!TextUtils.isEmpty(userDetail.getImageLink())) {
        contact.setImageURL(userDetail.getImageLink());
    }
    contact.setContactType(contactType.getValue());
    baseContactService.upsert(contact);
}
Also used : Contact(com.applozic.mobicommons.people.contact.Contact)

Aggregations

Contact (com.applozic.mobicommons.people.contact.Contact)107 Channel (com.applozic.mobicommons.people.channel.Channel)26 Message (com.applozic.mobicomkit.api.conversation.Message)18 Intent (android.content.Intent)17 AppContactService (com.applozic.mobicomkit.contact.AppContactService)17 ArrayList (java.util.ArrayList)15 ApplozicException (com.applozic.mobicomkit.exception.ApplozicException)14 UserDetail (com.applozic.mobicomkit.api.account.user.UserDetail)12 Test (org.junit.Test)12 Bitmap (android.graphics.Bitmap)11 MobiComUserPreference (com.applozic.mobicomkit.api.account.user.MobiComUserPreference)10 Context (android.content.Context)9 SpannableString (android.text.SpannableString)8 NonNull (androidx.annotation.NonNull)8 FileMeta (com.applozic.mobicomkit.api.attachment.FileMeta)8 ApiResponse (com.applozic.mobicomkit.feed.ApiResponse)8 SyncBlockUserApiResponse (com.applozic.mobicomkit.feed.SyncBlockUserApiResponse)8 FileClientService (com.applozic.mobicomkit.api.attachment.FileClientService)7 ContactDatabase (com.applozic.mobicomkit.contact.database.ContactDatabase)7 RegisteredUsersApiResponse (com.applozic.mobicomkit.feed.RegisteredUsersApiResponse)7