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;
}
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() });
}
}
}
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);
}
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);
}
}
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);
}
}
Aggregations