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