Search in sources :

Example 26 with Message

use of com.applozic.mobicomkit.api.conversation.Message in project Applozic-Android-SDK by AppLozic.

the class VideoCallNotificationHelper method sendVideoCallAnswer.

public void sendVideoCallAnswer(Contact contact, String videoCallId) {
    Log.i(TAG, "sendVideoCallAnswer()");
    this.videoCallId = videoCallId;
    Message notificationMessage = getNotificationMessage(contact);
    notificationMessage.setMessage(videoCallId);
    notificationMessage.setMetadata(getAnswerCallMetaData());
    conversationService.sendMessage(notificationMessage, MessageIntentService.class);
    Log.i(TAG, "sendVideoCallAnswer()  END");
}
Also used : Message(com.applozic.mobicomkit.api.conversation.Message)

Example 27 with Message

use of com.applozic.mobicomkit.api.conversation.Message in project Applozic-Android-SDK by AppLozic.

the class VideoCallNotificationHelper method buildVideoCallNotification.

public static void buildVideoCallNotification(Context context, Message message) {
    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);
    }
}
Also used : AppContactService(com.applozic.mobicomkit.contact.AppContactService) Message(com.applozic.mobicomkit.api.conversation.Message) Contact(com.applozic.mobicommons.people.contact.Contact)

Example 28 with Message

use of com.applozic.mobicomkit.api.conversation.Message in project Applozic-Android-SDK by AppLozic.

the class VideoCallNotificationHelper method sendVideoCallReject.

// public void sendVideoCallCanceled(Contact contact, String videoCallId) {
// 
// Message statusMessage = getVideoCallStatusMessage(contact);
// statusMessage.setMetadata(getVideoCanceledMap());
// statusMessage.setMessage(videoCallId);
// conversationService.sendMessage(statusMessage, MessageIntentService.class);
// 
// }
// public void sendVideoCallCanceledNotification(Contact contact, String videoCallId) {
// 
// Message statusMessage = getNotificationMessage(contact);
// statusMessage.setMetadata(getVideoCanceledMap());
// statusMessage.setMessage(videoCallId);
// conversationService.sendMessage(statusMessage, MessageIntentService.class);
// 
// }
public void sendVideoCallReject(Contact contact, String videoCallId) {
    this.videoCallId = videoCallId;
    Message notificationMessage = getNotificationMessage(contact);
    notificationMessage.setMetadata(getRejectedCallMap());
    notificationMessage.setMessage(videoCallId);
    conversationService.sendMessage(notificationMessage, MessageIntentService.class);
}
Also used : Message(com.applozic.mobicomkit.api.conversation.Message)

Example 29 with Message

use of com.applozic.mobicomkit.api.conversation.Message 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, MessageIntentService.class);
        }
    } 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 Message

use of com.applozic.mobicomkit.api.conversation.Message in project Applozic-Android-SDK by AppLozic.

the class VideoCallNotificationHelper method getNotificationMessage.

@NonNull
private Message getNotificationMessage(Contact contact) {
    Message notificationMessage = new Message();
    MobiComUserPreference userPreferences = MobiComUserPreference.getInstance(context);
    notificationMessage.setContactIds(contact.getContactIds());
    notificationMessage.setTo(contact.getContactIds());
    notificationMessage.setCreatedAtTime(System.currentTimeMillis());
    notificationMessage.setStoreOnDevice(Boolean.TRUE);
    notificationMessage.setSendToDevice(Boolean.TRUE);
    notificationMessage.setContentType(Message.ContentType.VIDEO_CALL_NOTIFICATION_MSG.getValue());
    notificationMessage.setDeviceKeyString(userPreferences.getDeviceKeyString());
    notificationMessage.setMessage(videoCallId);
    return notificationMessage;
}
Also used : Message(com.applozic.mobicomkit.api.conversation.Message) MobiComUserPreference(com.applozic.mobicomkit.api.account.user.MobiComUserPreference) NonNull(android.support.annotation.NonNull)

Aggregations

Message (com.applozic.mobicomkit.api.conversation.Message)55 ArrayList (java.util.ArrayList)14 Intent (android.content.Intent)13 Contact (com.applozic.mobicommons.people.contact.Contact)11 Cursor (android.database.Cursor)8 MobiComUserPreference (com.applozic.mobicomkit.api.account.user.MobiComUserPreference)8 Uri (android.net.Uri)7 FileMeta (com.applozic.mobicomkit.api.attachment.FileMeta)7 File (java.io.File)7 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)6 Context (android.content.Context)5 View (android.view.View)5 MessageDatabaseService (com.applozic.mobicomkit.api.conversation.database.MessageDatabaseService)5 Channel (com.applozic.mobicommons.people.channel.Channel)5 Configuration (android.content.res.Configuration)4 ImageView (android.widget.ImageView)4 TextView (android.widget.TextView)4 Collections.disjoint (java.util.Collections.disjoint)4 Bitmap (android.graphics.Bitmap)3 RecyclerView (android.support.v7.widget.RecyclerView)3