Search in sources :

Example 31 with MobiComUserPreference

use of com.applozic.mobicomkit.api.account.user.MobiComUserPreference in project Applozic-Android-SDK by AppLozic.

the class VideoCallNotificationHelper method getVideoCallStatusMessage.

@NonNull
private Message getVideoCallStatusMessage(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_STATUS_MSG.getValue());
    notificationMessage.setDeviceKeyString(userPreferences.getDeviceKeyString());
    return notificationMessage;
}
Also used : Message(com.applozic.mobicomkit.api.conversation.Message) MobiComUserPreference(com.applozic.mobicomkit.api.account.user.MobiComUserPreference) NonNull(android.support.annotation.NonNull)

Example 32 with MobiComUserPreference

use of com.applozic.mobicomkit.api.account.user.MobiComUserPreference in project Applozic-Android-SDK by AppLozic.

the class MobiComConversationFragment method sendBroadcastMessage.

public void sendBroadcastMessage(String message, String path) {
    MobiComUserPreference userPreferences = MobiComUserPreference.getInstance(getActivity());
    if (channelUserMapperList != null && channelUserMapperList.size() > 0) {
        for (ChannelUserMapper channelUserMapper : channelUserMapperList) {
            if (!userPreferences.getUserId().equals(channelUserMapper.getUserKey())) {
                Message messageToSend = new Message();
                messageToSend.setTo(channelUserMapper.getUserKey());
                messageToSend.setContactIds(channelUserMapper.getUserKey());
                messageToSend.setRead(Boolean.TRUE);
                messageToSend.setStoreOnDevice(Boolean.TRUE);
                if (messageToSend.getCreatedAtTime() == null) {
                    messageToSend.setCreatedAtTime(System.currentTimeMillis() + userPreferences.getDeviceTimeOffset());
                }
                if (currentConversationId != null && currentConversationId != 0) {
                    messageToSend.setConversationId(currentConversationId);
                }
                messageToSend.setSendToDevice(Boolean.FALSE);
                messageToSend.setType(sendType.getSelectedItemId() == 1 ? Message.MessageType.MT_OUTBOX.getValue() : Message.MessageType.OUTBOX.getValue());
                messageToSend.setTimeToLive(getTimeToLive());
                messageToSend.setMessage(message);
                messageToSend.setDeviceKeyString(userPreferences.getDeviceKeyString());
                messageToSend.setScheduledAt(scheduledTimeHolder.getTimestamp());
                messageToSend.setSource(Message.Source.MT_MOBILE_APP.getValue());
                if (!TextUtils.isEmpty(path)) {
                    List<String> filePaths = new ArrayList<String>();
                    filePaths.add(path);
                    messageToSend.setFilePaths(filePaths);
                }
                conversationService.sendMessage(messageToSend, MessageIntentService.class);
                if (selfDestructMessageSpinner != null) {
                    selfDestructMessageSpinner.setSelection(0);
                }
                attachmentLayout.setVisibility(View.GONE);
            }
        }
    }
}
Also used : Message(com.applozic.mobicomkit.api.conversation.Message) MobiComUserPreference(com.applozic.mobicomkit.api.account.user.MobiComUserPreference) ArrayList(java.util.ArrayList) ChannelUserMapper(com.applozic.mobicommons.people.channel.ChannelUserMapper)

Example 33 with MobiComUserPreference

use of com.applozic.mobicomkit.api.account.user.MobiComUserPreference in project Applozic-Android-SDK by AppLozic.

the class MobiComConversationFragment method sendProductMessage.

public void sendProductMessage(final String messageToSend, final FileMeta fileMeta, final Contact contact, final short messageContentType) {
    final Message message = new Message();
    new Thread(new Runnable() {

        @Override
        public void run() {
            String topicId;
            MobiComConversationService conversationService = new MobiComConversationService(getActivity());
            MobiComUserPreference userPreferences = MobiComUserPreference.getInstance(getActivity());
            topicId = new MessageClientService(getActivity()).getTopicId(currentConversationId);
            if (getChannel() != null) {
                message.setGroupId(channelKey);
            } else {
                message.setContactIds(contact.getUserId());
                message.setTo(contact.getUserId());
            }
            message.setMessage(messageToSend);
            message.setRead(Boolean.TRUE);
            message.setStoreOnDevice(Boolean.TRUE);
            message.setSendToDevice(Boolean.FALSE);
            message.setContentType(messageContentType);
            message.setType(Message.MessageType.MT_OUTBOX.getValue());
            message.setDeviceKeyString(userPreferences.getDeviceKeyString());
            message.setSource(Message.Source.MT_MOBILE_APP.getValue());
            message.setTopicId(messageToSend);
            message.setCreatedAtTime(System.currentTimeMillis() + userPreferences.getDeviceTimeOffset());
            message.setTopicId(topicId);
            message.setConversationId(currentConversationId);
            message.setFileMetas(fileMeta);
            conversationService.sendMessage(message, MessageIntentService.class);
        }
    }).start();
}
Also used : Message(com.applozic.mobicomkit.api.conversation.Message) MobiComUserPreference(com.applozic.mobicomkit.api.account.user.MobiComUserPreference) MessageClientService(com.applozic.mobicomkit.api.conversation.MessageClientService) MobiComConversationService(com.applozic.mobicomkit.api.conversation.MobiComConversationService)

Aggregations

MobiComUserPreference (com.applozic.mobicomkit.api.account.user.MobiComUserPreference)33 Message (com.applozic.mobicomkit.api.conversation.Message)8 ArrayList (java.util.ArrayList)6 Intent (android.content.Intent)5 Gson (com.google.gson.Gson)5 Contact (com.applozic.mobicommons.people.contact.Contact)4 PersonalizedMessage (com.applozic.mobicommons.personalization.PersonalizedMessage)4 User (com.applozic.mobicomkit.api.account.user.User)3 Channel (com.applozic.mobicommons.people.channel.Channel)3 Cursor (android.database.Cursor)2 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)2 NonNull (android.support.annotation.NonNull)2 FileClientService (com.applozic.mobicomkit.api.attachment.FileClientService)2 MobiComConversationService (com.applozic.mobicomkit.api.conversation.MobiComConversationService)2 InvalidApplicationException (com.applozic.mobicomkit.exception.InvalidApplicationException)2 UnAuthoriseException (com.applozic.mobicomkit.exception.UnAuthoriseException)2 MessageResponse (com.applozic.mobicomkit.feed.MessageResponse)2 SyncMessageFeed (com.applozic.mobicomkit.sync.SyncMessageFeed)2 JsonParser (com.google.gson.JsonParser)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2