Search in sources :

Example 16 with ChannelUserMapper

use of com.applozic.mobicommons.people.channel.ChannelUserMapper 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 (!loggedInUserId.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.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);
                if (selfDestructMessageSpinner != null) {
                    selfDestructMessageSpinner.setSelection(0);
                }
                attachmentLayout.setVisibility(View.GONE);
            }
        }
    }
}
Also used : AlRichMessage(com.applozic.mobicomkit.uiwidgets.conversation.richmessaging.AlRichMessage) 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 17 with ChannelUserMapper

use of com.applozic.mobicommons.people.channel.ChannelUserMapper in project Applozic-Android-SDK by AppLozic.

the class ChannelInfoActivity method onCreateOptionsMenu.

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.channel_menu_option, menu);
    if (channel == null) {
        return true;
    }
    ChannelUserMapper loggedInUserMapper = ChannelService.getInstance(this).getChannelUserMapperByUserId(channel.getKey(), MobiComUserPreference.getInstance(ChannelInfoActivity.this).getUserId());
    if (alCustomizationSettings.isHideGroupAddMembersButton() || loggedInUserMapper != null && ChannelUserMapper.UserRole.MEMBER.getValue().equals(loggedInUserMapper.getRole()) || (!ChannelUtils.isAdminUserId(userPreference.getUserId(), channel) && loggedInUserMapper != null && Integer.valueOf(0).equals(loggedInUserMapper.getRole()))) {
        menu.removeItem(R.id.add_member_to_channel);
    }
    if (ApplozicSetting.getInstance(this).isHideGroupNameEditButton() || alCustomizationSettings.isHideGroupNameUpdateButton() || channel.isBroadcastMessage()) {
        menu.removeItem(R.id.edit_channel_name);
    }
    return true;
}
Also used : ChannelUserMapper(com.applozic.mobicommons.people.channel.ChannelUserMapper)

Example 18 with ChannelUserMapper

use of com.applozic.mobicommons.people.channel.ChannelUserMapper in project Applozic-Android-SDK by AppLozic.

the class ChannelInfoActivity method onCreateContextMenu.

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
    int positionInList = info.position;
    if (positionInList < 0 || channelUserMapperList.isEmpty()) {
        return;
    }
    ChannelUserMapper channelUserMapper = channelUserMapperList.get(positionInList);
    if (MobiComUserPreference.getInstance(ChannelInfoActivity.this).getUserId().equals(channelUserMapper.getUserKey())) {
        return;
    }
    boolean isHideRemove = alCustomizationSettings.isHideGroupRemoveMemberOption();
    ChannelUserMapper loggedInUserMapper = ChannelService.getInstance(this).getChannelUserMapperByUserId(channelUserMapper.getKey(), MobiComUserPreference.getInstance(ChannelInfoActivity.this).getUserId());
    String[] menuItems = getResources().getStringArray(R.array.channel_users_menu_option);
    Contact contact = baseContactService.getContactById(channelUserMapper.getUserKey());
    for (int i = 0; i < menuItems.length; i++) {
        if (menuItems[i].equals(getString(R.string.make_admin_text_info)) && loggedInUserMapper != null && ChannelUserMapper.UserRole.MEMBER.getValue().equals(loggedInUserMapper.getRole())) {
            continue;
        }
        if (menuItems[i].equals(getString(R.string.remove_member)) && (isHideRemove || !isUserPresent || !ChannelUtils.isAdminUserId(userPreference.getUserId(), channel) && loggedInUserMapper != null && Integer.valueOf(0).equals(loggedInUserMapper.getRole()) || loggedInUserMapper != null && ChannelUserMapper.UserRole.MEMBER.getValue().equals(loggedInUserMapper.getRole()))) {
            continue;
        }
        if (menuItems[i].equals(getString(R.string.make_admin_text_info)) && (!isUserPresent || ChannelUserMapper.UserRole.ADMIN.getValue().equals(channelUserMapper.getRole()) || (channel != null && Channel.GroupType.BROADCAST.getValue().equals(channel.getType())))) {
            continue;
        }
        if (menuItems[i].equals(getString(R.string.make_admin_text_info))) {
            menu.add(Menu.NONE, i, i, menuItems[i]);
        } else {
            menu.add(Menu.NONE, i, i, menuItems[i] + " " + contact.getDisplayName());
        }
    }
}
Also used : AdapterView(android.widget.AdapterView) ChannelUserMapper(com.applozic.mobicommons.people.channel.ChannelUserMapper) Contact(com.applozic.mobicommons.people.contact.Contact)

Example 19 with ChannelUserMapper

use of com.applozic.mobicommons.people.channel.ChannelUserMapper in project Applozic-Android-SDK by AppLozic.

the class ChannelInfoActivity method onContextItemSelected.

@Override
public boolean onContextItemSelected(MenuItem item) {
    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
    int position = info.position;
    if (channelUserMapperList.size() <= position) {
        return true;
    }
    if (channel == null) {
        return true;
    }
    ChannelUserMapper channelUserMapper = channelUserMapperList.get(position);
    switch(item.getItemId()) {
        case 0:
            Intent startConversationIntent = new Intent(ChannelInfoActivity.this, ConversationActivity.class);
            startConversationIntent.putExtra(ConversationUIService.USER_ID, channelUserMapper.getUserKey());
            startActivity(startConversationIntent);
            finish();
            break;
        case 1:
            removeChannelUser(channel, channelUserMapper);
            break;
        case 2:
            if (Utils.isInternetAvailable(getApplicationContext())) {
                AlTask.execute(new ChannelUserRoleAsyncTask(this, channelUserMapper, 1));
            } else {
                Toast toast = Toast.makeText(this, getString(R.string.you_dont_have_any_network_access_info), Toast.LENGTH_SHORT);
                toast.setGravity(Gravity.CENTER, 0, 0);
                toast.show();
            }
            break;
        default:
            return super.onContextItemSelected(item);
    }
    return true;
}
Also used : Toast(android.widget.Toast) AdapterView(android.widget.AdapterView) Intent(android.content.Intent) ChannelUserMapper(com.applozic.mobicommons.people.channel.ChannelUserMapper)

Example 20 with ChannelUserMapper

use of com.applozic.mobicommons.people.channel.ChannelUserMapper in project Applozic-Android-SDK by AppLozic.

the class ChannelService method addMemberToChannelWithResponseProcess.

/**
 * Adds a given user to a channel.
 *
 * <p>Data for this addition is updated both remotely and locally.</p>
 *
 * @param channelKey the channel key (to identify the channel)
 * @param userId the id of the user to add to the channel
 * @return the {@link ApiResponse} for the request
 */
@Nullable
public ApiResponse addMemberToChannelWithResponseProcess(@Nullable Integer channelKey, @Nullable String userId) {
    if (channelKey == null && TextUtils.isEmpty(userId)) {
        return null;
    }
    ApiResponse apiResponse = channelClientService.addMemberToChannel(channelKey, userId);
    if (apiResponse == null) {
        return null;
    }
    if (apiResponse.isSuccess()) {
        ChannelUserMapper channelUserMapper = new ChannelUserMapper(channelKey, userId);
        channelDatabaseService.addChannelUserMapper(channelUserMapper);
    }
    return apiResponse;
}
Also used : ChannelUserMapper(com.applozic.mobicommons.people.channel.ChannelUserMapper) ChannelFeedApiResponse(com.applozic.mobicomkit.feed.ChannelFeedApiResponse) ApiResponse(com.applozic.mobicomkit.feed.ApiResponse) Nullable(androidx.annotation.Nullable)

Aggregations

ChannelUserMapper (com.applozic.mobicommons.people.channel.ChannelUserMapper)22 Channel (com.applozic.mobicommons.people.channel.Channel)7 ChannelUsersFeed (com.applozic.mobicomkit.feed.ChannelUsersFeed)4 Contact (com.applozic.mobicommons.people.contact.Contact)4 Cursor (android.database.Cursor)3 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)3 ApiResponse (com.applozic.mobicomkit.feed.ApiResponse)3 ChannelFeed (com.applozic.mobicomkit.feed.ChannelFeed)3 ChannelFeedApiResponse (com.applozic.mobicomkit.feed.ChannelFeedApiResponse)3 ArrayList (java.util.ArrayList)3 HashSet (java.util.HashSet)3 AdapterView (android.widget.AdapterView)2 ChannelDatabaseService (com.applozic.mobicomkit.channel.database.ChannelDatabaseService)2 SyncChannelFeed (com.applozic.mobicomkit.sync.SyncChannelFeed)2 Collections.disjoint (java.util.Collections.disjoint)2 Test (org.junit.Test)2 Context (android.content.Context)1 Intent (android.content.Intent)1 AppCompatActivity (android.support.v7.app.AppCompatActivity)1 SpannableString (android.text.SpannableString)1