Search in sources :

Example 26 with Contact

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

the class ContactDatabase method getUpdatedMetadata.

private Map<String, String> getUpdatedMetadata(Contact contact, boolean isContactUpdate) {
    Map<String, String> metadata = contact.getMetadata();
    if (isContactUpdate) {
        if (metadata != null && !metadata.isEmpty() && metadata.containsKey(Contact.AL_DISPLAY_NAME_UPDATED)) {
            return metadata;
        }
        Contact existingContact = getContactById(contact.getUserId());
        Map<String, String> existingMetadata = existingContact.getMetadata();
        if (metadata != null && existingMetadata != null && !existingMetadata.isEmpty() && existingMetadata.containsKey(Contact.AL_DISPLAY_NAME_UPDATED)) {
            String flag = existingMetadata.get(Contact.AL_DISPLAY_NAME_UPDATED);
            if (!TextUtils.isEmpty(flag)) {
                metadata.put(Contact.AL_DISPLAY_NAME_UPDATED, flag);
            }
        }
    }
    return metadata;
}
Also used : Contact(com.applozic.mobicommons.people.contact.Contact)

Example 27 with Contact

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

the class ContactDatabase method updateMetadataKeyValueForUserId.

// Cleanup: default
public void updateMetadataKeyValueForUserId(String userId, String key, String value) {
    Contact contact = getContactById(userId);
    if (contact != null) {
        Map<String, String> metadata = contact.getMetadata();
        if (metadata != null && !metadata.isEmpty()) {
            metadata.put(key, value);
            ContentValues contentValues = new ContentValues();
            contentValues.put(MobiComDatabaseHelper.USER_METADATA, GsonUtils.getJsonFromObject(metadata, Map.class));
            dbHelper.getWritableDatabase().update(CONTACT, contentValues, MobiComDatabaseHelper.USERID + "=?", new String[] { contact.getUserId() });
        }
    }
}
Also used : ContentValues(android.content.ContentValues) Map(java.util.Map) Contact(com.applozic.mobicommons.people.contact.Contact)

Example 28 with Contact

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

the class UserWorker method enqueueWork.

public static void enqueueWork(Context context, String userId, Contact contact, Channel channel, String pairedMessageKeyString, int unreadCount, boolean updateLastSeenStatus) {
    Data.Builder dataBuilder = new Data.Builder();
    if (!TextUtils.isEmpty(userId)) {
        dataBuilder.putString(USER_ID, userId);
    }
    if (contact != null) {
        dataBuilder.putString(CONTACT, GsonUtils.getJsonFromObject(contact, Contact.class));
    }
    if (channel != null) {
        dataBuilder.putString(CHANNEL, GsonUtils.getJsonFromObject(channel, Channel.class));
    }
    if (!TextUtils.isEmpty(pairedMessageKeyString)) {
        dataBuilder.putString(PAIRED_MESSAGE_KEY_STRING, pairedMessageKeyString);
    }
    dataBuilder.putInt(UNREAD_COUNT, unreadCount);
    dataBuilder.putBoolean(USER_LAST_SEEN_AT_STATUS, updateLastSeenStatus);
    Data data = dataBuilder.build();
    OneTimeWorkRequest messageWorkerRequest = new OneTimeWorkRequest.Builder(UserWorker.class).setInputData(data).build();
    WorkManager.getInstance(context).enqueue(messageWorkerRequest);
}
Also used : Channel(com.applozic.mobicommons.people.channel.Channel) Data(androidx.work.Data) Contact(com.applozic.mobicommons.people.contact.Contact) OneTimeWorkRequest(androidx.work.OneTimeWorkRequest)

Example 29 with Contact

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

the class VideoCallNotificationHelper method handleVideoCallNotificationMessages.

public void handleVideoCallNotificationMessages(final Message message) {
    Map<String, String> valueMap = message.getMetadata();
    String type = valueMap.get(MSG_TYPE);
    videoCallId = valueMap.get(CALL_ID);
    if (TextUtils.isEmpty(type)) {
        return;
    }
    if (type.equals(CALL_DIALED)) {
        handleIncomingVideoNotification(message);
    } else if (type.equals(CALL_ANSWERED)) {
        Intent intent = new Intent(MobiComKitConstants.APPLOZIC_VIDEO_CALL_ANSWER);
        intent.putExtra(CALL_ID, videoCallId);
        LocalBroadcastManager.getInstance(context).sendBroadcast(intent);
    } else if (type.equals(CALL_REJECTED)) {
        Intent intent = new Intent(MobiComKitConstants.APPLOZIC_VIDEO_CALL_REJECTED);
        intent.putExtra(CALL_ID, videoCallId);
        LocalBroadcastManager.getInstance(context).sendBroadcast(intent);
        if (!message.isTypeOutbox() && BroadcastService.videoCallAcitivityOpend) {
            Contact contact = baseContactService.getContactById(message.getContactIds());
            Message statusMessage = getVideoCallStatusMessage(contact);
            statusMessage.setMessage("Call Busy");
            statusMessage.setMetadata(getRejectedCallMap());
            conversationService.sendMessage(statusMessage);
        }
    } else if (type.equals(CALL_MISSED)) {
        Intent intent = new Intent(CALL_MISSED);
        intent.putExtra(CALL_ID, videoCallId);
        LocalBroadcastManager.getInstance(context).sendBroadcast(intent);
    } else if (type.equals(CALL_CANCELED)) {
        Intent intent = new Intent(CALL_CANCELED);
        intent.putExtra(CALL_ID, videoCallId);
        LocalBroadcastManager.getInstance(context).sendBroadcast(intent);
    } else if (type.equals(CALL_END)) {
        Intent intent = new Intent(CALL_END);
        intent.putExtra(CALL_ID, videoCallId);
        LocalBroadcastManager.getInstance(context).sendBroadcast(intent);
    }
}
Also used : Message(com.applozic.mobicomkit.api.conversation.Message) Intent(android.content.Intent) Contact(com.applozic.mobicommons.people.contact.Contact)

Example 30 with Contact

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

the class VideoCallNotificationHelper method buildVideoCallNotification.

public static void buildVideoCallNotification(Context context, Message message, int index) {
    Map<String, String> metaDataMap = message.getMetadata();
    Contact contact = new AppContactService(context).getContactById(message.getContactIds());
    String audioORVideoCallPrefix = Boolean.valueOf(metaDataMap.get(CALL_AUDIO_ONLY)) ? "audio call " : "video call ";
    if (metaDataMap.get(VideoCallNotificationHelper.MSG_TYPE).equals(VideoCallNotificationHelper.CALL_MISSED)) {
        Message message1 = new Message(message);
        message1.setMessage("You missed " + audioORVideoCallPrefix + " from " + contact.getDisplayName());
        BroadcastService.sendNotificationBroadcast(context, message1, index);
    }
}
Also used : AppContactService(com.applozic.mobicomkit.contact.AppContactService) Message(com.applozic.mobicomkit.api.conversation.Message) 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