public void handleSendAndRecordButtonView(boolean isSendButtonVisible) { sendButton.setVisibility(alCustomizationSettings.isRecordButton() && (contact != null || channel != null && !Channel.GroupType.OPEN.getValue().equals(channel.getType())) ? isSendButtonVisible ? View.VISIBLE : View.GONE : View.VISIBLE); recordButton.setVisibility(alCustomizationSettings.isRecordButton() && (contact != null || channel != null && !Channel.GroupType.OPEN.getValue().equals(channel.getType())) ? isSendButtonVisible ? View.GONE : View.VISIBLE : View.GONE); }
public void leaveChannel(final Channel channel) { AlertDialog.Builder alertDialog = new AlertDialog.Builder(this). setPositiveButton(R.string.channel_exit, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { new ChannelAsync(channel, ChannelInfoActivity.this).execute(); } }); alertDialog.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { } }); if (channel.getType() != null) { alertDialog.setMessage(getString(R.string.leave_channel).replace(getString(R.string.groupType_info), Channel.GroupType.BROADCAST.getValue().equals(channel.getType()) ? getString(R.string.broadcast_string) : getString(R.string.group_string))); } alertDialog.setCancelable(true); alertDialog.create().show(); }
public static String getWithUserId(Channel channel, String loggedInUserId) { try { if (Channel.GroupType.GROUPOFTWO.getValue().equals(channel.getType())) { String[] userIdSplit = new String[2]; if (!TextUtils.isEmpty(channel.getClientGroupId())) { userIdSplit = channel.getClientGroupId().split(":"); String userId1 = userIdSplit[1]; String userId2 = userIdSplit[2]; if (!loggedInUserId.equals(userId2)) { return userId2; } else if (!loggedInUserId.equals(userId1)) { return userId1; } } } } catch (Exception e) { Log.i("ChannelUtils", "Got exception in Group of two"); } return ""; }
public void deleteChannel(final Channel channel) { AlertDialog.Builder alertDialog = new AlertDialog.Builder(this). setPositiveButton(R.string.channel_deleting, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { new ChannelMemberAdd(channel, ChannelInfoActivity.this).execute(); } }); alertDialog.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { } }); if (channel.getType() != null) { alertDialog.setMessage(getString(R.string.delete_channel_messages_and_channel_info).replace(getString(R.string.group_name_info), channel.getName()).replace(getString(R.string.groupType_info), Channel.GroupType.BROADCAST.getValue().equals(channel.getType()) ? getString(R.string.broadcast_string) : getString(R.string.group_string))); } alertDialog.setCancelable(true); alertDialog.create().show(); }
@Override public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { if (typingStarted) { if (contact != null || channel != null && !Channel.GroupType.OPEN.getValue().equals(channel.getType()) || contact != null) { Intent intent = new Intent(getActivity(), ApplozicMqttIntentService.class); intent.putExtra(ApplozicMqttIntentService.CHANNEL, channel); intent.putExtra(ApplozicMqttIntentService.CONTACT, contact); intent.putExtra(ApplozicMqttIntentService.TYPING, typingStarted); ApplozicMqttIntentService.enqueueWork(getActivity(), intent); } } emoticonsFrameLayout.setVisibility(View.GONE); multimediaPopupGrid.setVisibility(View.GONE); } }
@Override public void afterTextChanged(Editable s) { try { if (!TextUtils.isEmpty(s.toString()) && s.toString().trim().length() > 0 && !typingStarted) { typingStarted = true; if (contact != null || (channel != null && !Channel.GroupType.OPEN.getValue().equals(channel.getType()))) { Applozic.publishTypingStatus(getContext(), channel, contact, true); } } else if (s.toString().trim().length() == 0 && typingStarted) { typingStarted = false; if (contact != null || (channel != null && !Channel.GroupType.OPEN.getValue().equals(channel.getType()))) { Applozic.publishTypingStatus(getContext(), channel, contact, false); } } if (listener != null) { listener.onTyping(editText, typingStarted); } } catch (Exception e) { } } });
public void afterTextChanged(Editable s) { try { if (!TextUtils.isEmpty(s.toString()) && s.toString().trim().length() > 0 && !typingStarted) { typingStarted = true; handleSendAndRecordButtonView(true); if (contact != null || channel != null && !Channel.GroupType.OPEN.getValue().equals(channel.getType()) || contact != null) { Applozic.publishTypingStatus(getContext(), channel, contact, typingStarted); } } else if (s.toString().trim().length() == 0 && typingStarted) { typingStarted = false; handleSendAndRecordButtonView(false); if (contact != null || channel != null && !Channel.GroupType.OPEN.getValue().equals(channel.getType()) || contact != null) { Applozic.publishTypingStatus(getContext(), channel, contact, typingStarted); } } } catch (Exception e) { } //sendButton.setVisibility((s == null || s.toString().trim().length() == 0) && TextUtils.isEmpty(filePath) ? View.GONE : View.VISIBLE); //attachButton.setVisibility(s == null || s.toString().trim().length() == 0 ? View.VISIBLE : View.GONE); } });
public static String getChannelTitleName(Channel channel, String loggedInUserId) { if (!TextUtils.isEmpty(loggedInUserId)) { if (Channel.GroupType.SELLER.getValue().equals(channel.getType())) { String[] userIdSplit = new String[1]; if (!TextUtils.isEmpty(channel.getName())) { userIdSplit = channel.getName().split(":"); } if (loggedInUserId.equals(channel.getAdminKey())) { return channel.getName(); } else { return userIdSplit[0]; } } else { return channel.getName(); } } return ""; }
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { int position = this.getLayoutPosition(); if (mItems.size() <= position) { return; } Message message = mItems.get(position); menu.setHeaderTitle(R.string.conversation_options); String[] menuItems = context.getResources().getStringArray(R.array.conversation_options_menu); properties.setMessage(message); boolean isChannelDeleted = properties.getChannel() != null && properties.getChannel().isDeleted(); boolean isUserPresentInGroup = properties.getChannel() != null && ChannelService.getInstance(context).processIsUserPresentInChannel(properties.getChannel().getKey()); for (int i = 0; i < menuItems.length; i++) { if ((message.getGroupId() == null || (properties.getChannel() != null && (Channel.GroupType.GROUPOFTWO.getValue().equals(properties.getChannel().getType()) || Channel.GroupType.SUPPORT_GROUP.getValue().equals(properties.getChannel().getType())))) && (menuItems[i].equals(context.getResources().getString(R.string.delete_group)) || menuItems[i].equals(context.getResources().getString(R.string.exit_group)))) { continue; } if (menuItems[i].equals(context.getResources().getString(R.string.exit_group)) && (isChannelDeleted || !isUserPresentInGroup)) { continue; } if (menuItems[i].equals(context.getResources().getString(R.string.delete_group)) && (isUserPresentInGroup || !isChannelDeleted)) { continue; } if (menuItems[i].equals(context.getResources().getString(R.string.delete_conversation))) { continue; } MenuItem item = menu.add(Menu.NONE, i, i, menuItems[i]); item.setOnMenuItemClickListener(onEditMenu); } }
@Override public void onFocusChange(View v, boolean hasFocus) { if (listener != null) { listener.onFocus(editText, hasFocus); } if (hasFocus && typingStarted && (contact != null || (channel != null && !Channel.GroupType.OPEN.getValue().equals(channel.getType())))) { Applozic.publishTypingStatus(getContext(), channel, contact, typingStarted); } } });
public void updateTitle() { StringBuffer stringBufferTitle = new StringBuffer(); if (contact != null) { stringBufferTitle.append(contact.getDisplayName()); } else if (channel != null) { if (Channel.GroupType.GROUPOFTWO.getValue().equals(channel.getType())) { String userId = ChannelService.getInstance(getActivity()).getGroupOfTwoReceiverUserId(channel.getKey()); if (!TextUtils.isEmpty(userId)) { Contact withUserContact = appContactService.getContactById(userId); stringBufferTitle.append(withUserContact.getDisplayName()); } } else { stringBufferTitle.append(ChannelUtils.getChannelTitleName(channel, MobiComUserPreference.getInstance(getActivity()).getUserId())); } } if (stringBufferTitle != null && getActivity() != null) { setToolbarTitle(stringBufferTitle.toString()); } }
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;
String notificationTitle = null; if (channel != null) { if (Channel.GroupType.GROUPOFTWO.getValue().equals(channel.getType())) { String userId = ChannelService.getInstance(context).getGroupOfTwoReceiverUserId(channel.getKey()); if (!TextUtils.isEmpty(userId)) { } else if (Channel.GroupType.SUPPORT_GROUP.getValue().equals(channel.getType())) { String userId = message.getTo(); if (!TextUtils.isEmpty(userId)) {
public void updateChannelTitle() { if (!Channel.GroupType.GROUPOFTWO.getValue().equals(channel.getType())) { Channel newChannel = ChannelService.getInstance(getActivity()).getChannelByChannelKey(channel.getKey()); if (newChannel != null && !TextUtils.isEmpty(channel.getName()) && !channel.getName().equals(newChannel.getName())) { title = ChannelUtils.getChannelTitleName(newChannel, MobiComUserPreference.getInstance(getActivity()).getUserId()); channel = newChannel; if (getActivity() != null) { setToolbarTitle(title); } } } }
public void updateContextBasedGroup() { if (channel != null) { Channel channelInfo = ChannelService.getInstance(getActivity()).getChannelInfo(channel.getKey()); if ((Channel.GroupType.GROUPOFTWO.getValue().equals(channelInfo.getType())) && channel.isContextBasedChat()) { Conversation conversation = new Conversation(); TopicDetail topic = new TopicDetail(); topic.setTitle(channelInfo.getMetadata().get(Channel.GroupMetaDataType.TITLE.getValue())); topic.setSubtitle(channelInfo.getMetadata().get(Channel.GroupMetaDataType.PRICE.getValue())); topic.setLink(channelInfo.getMetadata().get(Channel.GroupMetaDataType.LINK.getValue())); conversation.setTopicDetail(topic.getJson()); conversationList.get(0).setTopicDetail(topic.getJson()); applozicContextSpinnerAdapter.notifyDataSetChanged(); } } }
public void updateLastSeenStatus() { if (this.getActivity() == null) { return; } if (contact != null) { contact = appContactService.getContactById(contact.getContactIds()); } if (contact != null) { processUpdateLastSeenStatus(contact); } else if (channel != null && Channel.GroupType.GROUPOFTWO.getValue().equals(channel.getType())) { String userId = ChannelService.getInstance(getActivity()).getGroupOfTwoReceiverUserId(channel.getKey()); if (!TextUtils.isEmpty(userId)) { Contact withUserContact = appContactService.getContactById(userId); processUpdateLastSeenStatus(withUserContact); } } }
protected void sendMessage() { if (channel != null) { if (Channel.GroupType.GROUPOFTWO.getValue().equals(channel.getType())) { String userId = ChannelService.getInstance(getActivity()).getGroupOfTwoReceiverUserId(channel.getKey()); if (!TextUtils.isEmpty(userId)) { Contact withUserContact = appContactService.getContactById(userId); if (withUserContact.isBlocked()) { userBlockDialog(false, withUserContact, true); } else { processSendMessage(); } } } else if (Channel.GroupType.OPEN.getValue().equals(channel.getType())) { if (Utils.isInternetAvailable(getActivity())) { processSendMessage(); } else { Toast.makeText(getActivity(), getActivity().getString(R.string.internet_connection_not_available), Toast.LENGTH_SHORT).show(); } } else { processSendMessage(); } } else if (contact != null) { if (contact.isBlocked()) { userBlockDialog(false, contact, false); } else { processSendMessage(); } } }
public String getNameForInviteDialog() { if (contact != null) { return contact.getDisplayName(); } else if (channel != null) { if (Channel.GroupType.GROUPOFTWO.getValue().equals(channel.getType())) { String userId = ChannelService.getInstance(getActivity()).getGroupOfTwoReceiverUserId(channel.getKey()); if (!TextUtils.isEmpty(userId)) { Contact withUserContact = appContactService.getContactById(userId); return withUserContact.getDisplayName(); } } else { return ChannelUtils.getChannelTitleName(channel, MobiComUserPreference.getInstance(getActivity()).getUserId()); } } return ""; }
public CharSequence getMessageBody(Message message, int count, Channel channel, Contact contact) { String notificationText; if (message.getContentType() == Message.ContentType.LOCATION.getValue()) { notificationText = getText(0); } else if (message.getContentType() == Message.ContentType.AUDIO_MSG.getValue()) { notificationText = getText(1); } else if (message.getContentType() == Message.ContentType.VIDEO_MSG.getValue()) { notificationText = getText(2); } else if (message.hasAttachment() && TextUtils.isEmpty(message.getMessage())) { notificationText = getText(3); } else { notificationText = message.getMessage(); } CharSequence messageBody; Contact messageContactDisplayName = contact != null ? contact : appContactService.getContactById(message.getTo()); if (message.getGroupId() != null) { if (Channel.GroupType.GROUPOFTWO.getValue().equals(channel.getType()) || Channel.GroupType.SUPPORT_GROUP.getValue().equals(channel.getType())) { messageBody = Utils.getStyleStringForMessage(notificationText); } else { messageBody = Utils.getStyledStringForChannel(messageContactDisplayName.getDisplayName(), channel.getName(), notificationText); } } else { if (count < 2) { messageBody = Utils.getStyleStringForMessage(notificationText); } else { messageBody = Utils.getStyledStringForContact(messageContactDisplayName.getDisplayName(), notificationText); } } return messageBody; }
/** * This method returns the receiver's name from the message object that this instance holds currently. * * @return If the message belongs to group it will return group's name and if it belongs to user, the display name of the user will be returned. */ public String getReceiver() { if (message.getGroupId() == null) { return contact.getDisplayName(); } else { if (channel != null) { if (Channel.GroupType.GROUPOFTWO.getValue().equals(channel.getType())) { Contact withUserContact = contactService.getContactById(ChannelService.getInstance(context).getGroupOfTwoReceiverUserId(channel.getKey())); if (withUserContact != null) { return withUserContact.getDisplayName(); } } else { return ChannelUtils.getChannelTitleName(channel, MobiComUserPreference.getInstance(context).getUserId()); } } } return null; }