use of com.applozic.mobicomkit.contact.VCFContactData in project Applozic-Android-SDK by AppLozic.
the class MobiComConversationFragment method onItemClick.
@Override
public boolean onItemClick(int position, MenuItem item) {
if (messageList.size() <= position) {
return true;
}
Message message = messageList.get(position);
if (message.isTempDateType() || message.isCustom()) {
return true;
}
switch(item.getItemId()) {
case 0:
if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.HONEYCOMB) {
android.text.ClipboardManager clipboard = (android.text.ClipboardManager) getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
clipboard.setText(message.getMessage());
} else {
android.content.ClipboardManager clipboard = (android.content.ClipboardManager) getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
android.content.ClipData clip = android.content.ClipData.newPlainText(getContext().getString(R.string.copied_message), message.getMessage());
clipboard.setPrimaryClip(clip);
}
break;
case 1:
conversationUIService.startContactActivityForResult(message, null);
break;
case 2:
Message messageToResend = new Message(message);
// messageToResend.setCreatedAtTime(new Date().getTime());
messageToResend.setCreatedAtTime(System.currentTimeMillis() + MobiComUserPreference.getInstance(getActivity()).getDeviceTimeOffset());
conversationService.sendMessage(messageToResend, messageIntentClass);
break;
case 3:
String messageKeyString = message.getKeyString();
new DeleteConversationAsyncTask(conversationService, message, contact).execute();
deleteMessageFromDeviceList(messageKeyString);
break;
case 4:
String messageJson = GsonUtils.getJsonFromObject(message, Message.class);
conversationUIService.startMessageInfoFragment(messageJson);
break;
case 5:
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
if (message.getFilePaths() != null) {
Uri shareUri = null;
if (Utils.hasNougat()) {
shareUri = FileProvider.getUriForFile(getActivity(), Utils.getMetaDataValue(getActivity(), MobiComKitConstants.PACKAGE_NAME) + ".provider", new File(message.getFilePaths().get(0)));
} else {
shareUri = Uri.fromFile(new File(message.getFilePaths().get(0)));
}
shareIntent.setDataAndType(shareUri, "text/x-vcard");
shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
shareIntent.putExtra(Intent.EXTRA_STREAM, shareUri);
if (!TextUtils.isEmpty(message.getMessage())) {
shareIntent.putExtra(Intent.EXTRA_TEXT, message.getMessage());
}
shareIntent.setType(FileUtils.getMimeType(new File(message.getFilePaths().get(0))));
} else {
shareIntent.putExtra(Intent.EXTRA_TEXT, message.getMessage());
shareIntent.setType("text/plain");
}
startActivity(Intent.createChooser(shareIntent, getString(R.string.send_message_to)));
break;
case 6:
try {
Configuration config = getActivity().getResources().getConfiguration();
messageMetaData = new HashMap<>();
String displayName;
if (message.getGroupId() != null) {
if (MobiComUserPreference.getInstance(getActivity()).getUserId().equals(message.getContactIds()) || TextUtils.isEmpty(message.getContactIds())) {
displayName = getString(R.string.you_string);
} else {
displayName = appContactService.getContactById(message.getContactIds()).getDisplayName();
}
} else {
if (message.isTypeOutbox()) {
displayName = getString(R.string.you_string);
} else {
displayName = appContactService.getContactById(message.getContactIds()).getDisplayName();
}
}
nameTextView.setText(displayName);
if (message.hasAttachment()) {
FileMeta fileMeta = message.getFileMetas();
imageViewForAttachmentType.setVisibility(VISIBLE);
if (fileMeta.getContentType().contains("image")) {
imageViewForAttachmentType.setImageResource(R.drawable.applozic_ic_image_camera_alt);
if (TextUtils.isEmpty(message.getMessage())) {
messageTextView.setText(getString(R.string.photo_string));
} else {
messageTextView.setText(message.getMessage());
}
galleryImageView.setVisibility(VISIBLE);
imageViewRLayout.setVisibility(VISIBLE);
imageThumbnailLoader.loadImage(message, galleryImageView);
} else if (fileMeta.getContentType().contains("video")) {
imageViewForAttachmentType.setImageResource(R.drawable.applozic_ic_action_video);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
if (config.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL) {
imageViewForAttachmentType.setScaleX(-1);
}
}
if (TextUtils.isEmpty(message.getMessage())) {
messageTextView.setText(getString(R.string.video_string));
} else {
messageTextView.setText(message.getMessage());
}
if (message.getFilePaths() != null && message.getFilePaths().size() > 0) {
if (imageCache.getBitmapFromMemCache(message.getKeyString()) != null) {
galleryImageView.setImageBitmap(imageCache.getBitmapFromMemCache(message.getKeyString()));
} else {
imageCache.addBitmapToCache(message.getKeyString(), fileClientService.createAndSaveVideoThumbnail(message.getFilePaths().get(0)));
galleryImageView.setImageBitmap(fileClientService.createAndSaveVideoThumbnail(message.getFilePaths().get(0)));
}
}
galleryImageView.setVisibility(VISIBLE);
imageViewRLayout.setVisibility(VISIBLE);
} else if (fileMeta.getContentType().contains("audio")) {
imageViewForAttachmentType.setImageResource(R.drawable.applozic_ic_music_note);
if (TextUtils.isEmpty(message.getMessage())) {
messageTextView.setText(getString(R.string.audio_string));
} else {
messageTextView.setText(message.getMessage());
}
galleryImageView.setVisibility(View.GONE);
imageViewRLayout.setVisibility(View.GONE);
} else if (message.isContactMessage()) {
MobiComVCFParser parser = new MobiComVCFParser();
imageViewForAttachmentType.setImageResource(R.drawable.applozic_ic_person_white);
try {
VCFContactData data = parser.parseCVFContactData(message.getFilePaths().get(0));
if (data != null) {
messageTextView.setText(getString(R.string.contact_string));
messageTextView.append(" " + data.getName());
}
} catch (Exception e) {
imageViewForAttachmentType.setImageResource(R.drawable.applozic_ic_person_white);
messageTextView.setText(getString(R.string.contact_string));
}
galleryImageView.setVisibility(View.GONE);
imageViewRLayout.setVisibility(View.GONE);
} else {
imageViewForAttachmentType.setImageResource(R.drawable.applozic_ic_action_attachment);
if (TextUtils.isEmpty(message.getMessage())) {
messageTextView.setText(getString(R.string.attachment_string));
} else {
messageTextView.setText(message.getMessage());
}
galleryImageView.setVisibility(View.GONE);
imageViewRLayout.setVisibility(View.GONE);
}
imageViewForAttachmentType.setColorFilter(ContextCompat.getColor(getActivity(), R.color.apploizc_lite_gray_color));
} else if (message.getContentType() == Message.ContentType.LOCATION.getValue()) {
imageViewForAttachmentType.setVisibility(VISIBLE);
galleryImageView.setVisibility(VISIBLE);
imageViewRLayout.setVisibility(VISIBLE);
messageTextView.setText(getString(R.string.al_location_string));
imageViewForAttachmentType.setImageResource(R.drawable.applozic_ic_location_on_white_24dp);
imageViewForAttachmentType.setColorFilter(ContextCompat.getColor(getActivity(), R.color.apploizc_lite_gray_color));
messageImageLoader.setLoadingImage(R.drawable.applozic_map_offline_thumbnail);
messageImageLoader.loadImage(LocationUtils.loadStaticMap(message.getMessage()), galleryImageView);
} else {
imageViewForAttachmentType.setVisibility(View.GONE);
imageViewRLayout.setVisibility(View.GONE);
galleryImageView.setVisibility(View.GONE);
messageTextView.setText(message.getMessage());
}
messageMetaData.put(Message.MetaDataType.AL_REPLY.getValue(), message.getKeyString());
if (messageMetaData != null && !messageMetaData.isEmpty()) {
String replyMessageKey = messageMetaData.get(Message.MetaDataType.AL_REPLY.getValue());
if (!TextUtils.isEmpty(replyMessageKey)) {
messageDatabaseService.updateMessageReplyType(replyMessageKey, Message.ReplyMessage.REPLY_MESSAGE.getValue());
}
}
attachReplyCancelLayout.setVisibility(VISIBLE);
replayRelativeLayout.setVisibility(VISIBLE);
} catch (Exception e) {
}
break;
}
return true;
}
use of com.applozic.mobicomkit.contact.VCFContactData in project Applozic-Android-SDK by AppLozic.
the class MobiComConversationFragment method onContextItemSelected.
@Override
public boolean onContextItemSelected(MenuItem item) {
int position = positionInSmsList;
if (messageList.size() <= position) {
return true;
}
Message message = messageList.get(position);
if (message.isTempDateType() || message.isCustom()) {
return true;
}
switch(item.getItemId()) {
case 0:
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
android.text.ClipboardManager clipboard = (android.text.ClipboardManager) getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
clipboard.setText(message.getMessage());
} else {
android.content.ClipboardManager clipboard = (android.content.ClipboardManager) getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
android.content.ClipData clip = android.content.ClipData.newPlainText(getContext().getString(R.string.copied_message), message.getMessage());
clipboard.setPrimaryClip(clip);
}
break;
case 1:
conversationUIService.startContactActivityForResult(message, null);
break;
case 2:
Message messageToResend = new Message(message);
// messageToResend.setCreatedAtTime(new Date().getTime());
messageToResend.setCreatedAtTime(System.currentTimeMillis() + MobiComUserPreference.getInstance(getActivity()).getDeviceTimeOffset());
conversationService.sendMessage(messageToResend, messageIntentClass);
break;
case 3:
String messageKeyString = message.getKeyString();
new DeleteConversationAsyncTask(conversationService, message, contact).execute();
deleteMessageFromDeviceList(messageKeyString);
break;
case 4:
String messageJson = GsonUtils.getJsonFromObject(message, Message.class);
conversationUIService.startMessageInfoFragment(messageJson);
break;
case 5:
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
if (message.getFilePaths() != null) {
Uri shareUri = null;
if (Utils.hasNougat()) {
shareUri = FileProvider.getUriForFile(getActivity(), Utils.getMetaDataValue(getActivity(), MobiComKitConstants.PACKAGE_NAME) + ".provider", new File(message.getFilePaths().get(0)));
} else {
shareUri = Uri.fromFile(new File(message.getFilePaths().get(0)));
}
shareIntent.setDataAndType(shareUri, "text/x-vcard");
shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
shareIntent.putExtra(Intent.EXTRA_STREAM, shareUri);
if (!TextUtils.isEmpty(message.getMessage())) {
shareIntent.putExtra(Intent.EXTRA_TEXT, message.getMessage());
}
shareIntent.setType(FileUtils.getMimeType(new File(message.getFilePaths().get(0))));
} else {
shareIntent.putExtra(Intent.EXTRA_TEXT, message.getMessage());
shareIntent.setType("text/plain");
}
startActivity(Intent.createChooser(shareIntent, getString(R.string.send_message_to)));
break;
case 6:
try {
Configuration config = getActivity().getResources().getConfiguration();
messageMetaData = new HashMap<>();
String displayName;
if (message.getGroupId() != null) {
if (MobiComUserPreference.getInstance(getActivity()).getUserId().equals(message.getContactIds()) || TextUtils.isEmpty(message.getContactIds())) {
displayName = getString(R.string.you_string);
} else {
displayName = appContactService.getContactById(message.getContactIds()).getDisplayName();
}
} else {
if (message.isTypeOutbox()) {
displayName = getString(R.string.you_string);
} else {
displayName = appContactService.getContactById(message.getContactIds()).getDisplayName();
}
}
nameTextView.setText(displayName);
if (message.hasAttachment()) {
FileMeta fileMeta = message.getFileMetas();
imageViewForAttachmentType.setVisibility(VISIBLE);
if (fileMeta.getContentType().contains("image")) {
imageViewForAttachmentType.setImageResource(R.drawable.applozic_ic_image_camera_alt);
if (TextUtils.isEmpty(message.getMessage())) {
messageTextView.setText(getString(R.string.photo_string));
} else {
messageTextView.setText(message.getMessage());
}
galleryImageView.setVisibility(VISIBLE);
imageViewRLayout.setVisibility(VISIBLE);
imageThumbnailLoader.loadImage(message, galleryImageView);
} else if (fileMeta.getContentType().contains("video")) {
imageViewForAttachmentType.setImageResource(R.drawable.applozic_ic_action_video);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
if (config.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL) {
imageViewForAttachmentType.setScaleX(-1);
}
}
if (TextUtils.isEmpty(message.getMessage())) {
messageTextView.setText(getString(R.string.video_string));
} else {
messageTextView.setText(message.getMessage());
}
if (message.getFilePaths() != null && message.getFilePaths().size() > 0) {
if (imageCache.getBitmapFromMemCache(message.getKeyString()) != null) {
galleryImageView.setImageBitmap(imageCache.getBitmapFromMemCache(message.getKeyString()));
} else {
imageCache.addBitmapToCache(message.getKeyString(), fileClientService.createAndSaveVideoThumbnail(message.getFilePaths().get(0)));
galleryImageView.setImageBitmap(fileClientService.createAndSaveVideoThumbnail(message.getFilePaths().get(0)));
}
}
galleryImageView.setVisibility(VISIBLE);
imageViewRLayout.setVisibility(VISIBLE);
} else if (fileMeta.getContentType().contains("audio")) {
imageViewForAttachmentType.setImageResource(R.drawable.applozic_ic_music_note);
if (TextUtils.isEmpty(message.getMessage())) {
messageTextView.setText(getString(R.string.audio_string));
} else {
messageTextView.setText(message.getMessage());
}
galleryImageView.setVisibility(View.GONE);
imageViewRLayout.setVisibility(View.GONE);
} else if (message.isContactMessage()) {
MobiComVCFParser parser = new MobiComVCFParser();
imageViewForAttachmentType.setImageResource(R.drawable.applozic_ic_person_white);
try {
VCFContactData data = parser.parseCVFContactData(message.getFilePaths().get(0));
if (data != null) {
messageTextView.setText(getString(R.string.contact_string));
messageTextView.append(" " + data.getName());
}
} catch (Exception e) {
imageViewForAttachmentType.setImageResource(R.drawable.applozic_ic_person_white);
messageTextView.setText(getString(R.string.contact_string));
}
galleryImageView.setVisibility(View.GONE);
imageViewRLayout.setVisibility(View.GONE);
} else {
imageViewForAttachmentType.setImageResource(R.drawable.applozic_ic_action_attachment);
if (TextUtils.isEmpty(message.getMessage())) {
messageTextView.setText(getString(R.string.attachment_string));
} else {
messageTextView.setText(message.getMessage());
}
galleryImageView.setVisibility(View.GONE);
imageViewRLayout.setVisibility(View.GONE);
}
imageViewForAttachmentType.setColorFilter(ContextCompat.getColor(getActivity(), R.color.apploizc_lite_gray_color));
} else if (message.getContentType() == Message.ContentType.LOCATION.getValue()) {
imageViewForAttachmentType.setVisibility(VISIBLE);
galleryImageView.setVisibility(VISIBLE);
imageViewRLayout.setVisibility(VISIBLE);
messageTextView.setText(getString(R.string.al_location_string));
imageViewForAttachmentType.setImageResource(R.drawable.applozic_ic_location_on_white_24dp);
imageViewForAttachmentType.setColorFilter(ContextCompat.getColor(getActivity(), R.color.apploizc_lite_gray_color));
messageImageLoader.setLoadingImage(R.drawable.applozic_map_offline_thumbnail);
messageImageLoader.loadImage(LocationUtils.loadStaticMap(message.getMessage()), galleryImageView);
} else {
imageViewForAttachmentType.setVisibility(View.GONE);
imageViewRLayout.setVisibility(View.GONE);
galleryImageView.setVisibility(View.GONE);
messageTextView.setText(message.getMessage());
}
messageMetaData.put(Message.MetaDataType.AL_REPLY.getValue(), message.getKeyString());
if (messageMetaData != null && !messageMetaData.isEmpty()) {
String replyMessageKey = messageMetaData.get(Message.MetaDataType.AL_REPLY.getValue());
if (!TextUtils.isEmpty(replyMessageKey)) {
messageDatabaseService.updateMessageReplyType(replyMessageKey, Message.ReplyMessage.REPLY_MESSAGE.getValue());
}
}
attachReplyCancelLayout.setVisibility(VISIBLE);
replayRelativeLayout.setVisibility(VISIBLE);
} catch (Exception e) {
}
break;
}
return true;
}
use of com.applozic.mobicomkit.contact.VCFContactData in project Applozic-Android-SDK by AppLozic.
the class DetailedConversationAdapter method setupContactShareView.
private void setupContactShareView(final Message message, MyViewHolder myViewHolder) {
myViewHolder.mainContactShareLayout.setVisibility(View.VISIBLE);
myViewHolder.mainContactShareLayout.setLayoutParams(getImageLayoutParam(false));
MobiComVCFParser parser = new MobiComVCFParser();
try {
VCFContactData data = parser.parseCVFContactData(message.getFilePaths().get(0));
myViewHolder.shareContactName.setText(data.getName());
int resId = message.isTypeOutbox() ? Color.parseColor(alCustomizationSettings.getSentMessageTextColor()) : Color.parseColor(alCustomizationSettings.getReceivedMessageTextColor());
myViewHolder.shareContactName.setTextColor(resId);
myViewHolder.shareContactNo.setTextColor(resId);
myViewHolder.shareEmailContact.setTextColor(resId);
myViewHolder.addContactButton.setTextColor(resId);
if (data.getProfilePic() != null) {
if (imageCache.getBitmapFromMemCache(message.getKeyString()) == null) {
imageCache.addBitmapToCache(message.getKeyString(), data.getProfilePic());
}
myViewHolder.shareContactImage.setImageBitmap(imageCache.getBitmapFromMemCache(message.getKeyString()));
}
if (!TextUtils.isEmpty(data.getTelephoneNumber())) {
myViewHolder.shareContactNo.setText(data.getTelephoneNumber());
} else {
myViewHolder.shareContactNo.setVisibility(View.GONE);
}
if (data.getEmail() != null) {
myViewHolder.shareEmailContact.setText(data.getEmail());
} else {
myViewHolder.shareEmailContact.setVisibility(View.GONE);
}
myViewHolder.addContactButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
Uri outputUri = null;
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
if (Utils.hasNougat()) {
outputUri = FileProvider.getUriForFile(context, Utils.getMetaDataValue(context, MobiComKitConstants.PACKAGE_NAME) + ".provider", new File(message.getFilePaths().get(0)));
} else {
outputUri = Uri.fromFile(new File(message.getFilePaths().get(0)));
}
if (intent.resolveActivity(context.getPackageManager()) != null) {
intent.setDataAndType(outputUri, "text/x-vcard");
context.startActivity(intent);
} else {
Toast.makeText(context, R.string.info_app_not_found_to_open_file, Toast.LENGTH_LONG).show();
}
}
});
} catch (Exception e) {
Utils.printLog(context, "DetailedConvAdapter", "Exception in parsing");
}
}
use of com.applozic.mobicomkit.contact.VCFContactData in project Applozic-Android-SDK by AppLozic.
the class DetailedConversationAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
int type = getItemViewType(position);
final Message message = getItem(position);
try {
if (type == 2) {
MyViewHolder2 myViewHolder2 = (MyViewHolder2) holder;
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MMM dd, yyyy");
SimpleDateFormat simpleDateFormatDay = new SimpleDateFormat("EEEE");
Date date = new Date(message.getCreatedAtTime());
myViewHolder2.dateView.setTextColor(Color.parseColor(alCustomizationSettings.getConversationDateTextColor().trim()));
myViewHolder2.dayTextView.setTextColor(Color.parseColor(alCustomizationSettings.getConversationDayTextColor().trim()));
if (DateUtils.isSameDay(message.getCreatedAtTime())) {
myViewHolder2.dayTextView.setVisibility(View.VISIBLE);
myViewHolder2.dateView.setVisibility(GONE);
myViewHolder2.dayTextView.setText(R.string.today);
} else {
myViewHolder2.dayTextView.setVisibility(View.VISIBLE);
myViewHolder2.dateView.setVisibility(View.VISIBLE);
myViewHolder2.dayTextView.setText(simpleDateFormatDay.format(date));
myViewHolder2.dateView.setText(simpleDateFormat.format(date));
}
return;
} else if (type == 3) {
MyViewHolder3 myViewHolder3 = (MyViewHolder3) holder;
myViewHolder3.customContentTextView.setText(message.getMessage());
myViewHolder3.customContentTextView.setVisibility(View.VISIBLE);
return;
} else if (type == 4) {
MyViewHolder4 myViewHolder4 = (MyViewHolder4) holder;
GradientDrawable bgGradientDrawable = (GradientDrawable) myViewHolder4.channelMessageTextView.getBackground();
bgGradientDrawable.setColor(Color.parseColor(alCustomizationSettings.getChannelCustomMessageBgColor()));
bgGradientDrawable.setStroke(3, Color.parseColor(alCustomizationSettings.getChannelCustomMessageBorderColor()));
myViewHolder4.channelMessageTextView.setTextColor(Color.parseColor(alCustomizationSettings.getChannelCustomMessageTextColor()));
myViewHolder4.channelMessageTextView.setText(message.getMessage());
return;
} else if (type == 5) {
MyViewHolder5 myViewHolder5 = (MyViewHolder5) holder;
if (message != null) {
myViewHolder5.timeTextView.setText(DateUtils.getFormattedDate(message.getCreatedAtTime()));
if (message.getMetadata() != null) {
myViewHolder5.statusTextView.setText(VideoCallNotificationHelper.getStatus(message.getMetadata()));
}
if (VideoCallNotificationHelper.isMissedCall(message)) {
myViewHolder5.imageView.setImageResource(R.drawable.ic_communication_call_missed);
}
if (VideoCallNotificationHelper.isAudioCall(message)) {
myViewHolder5.imageView.setImageResource(R.drawable.applozic_ic_action_call);
} else {
myViewHolder5.imageView.setImageResource(R.drawable.ic_videocam_white_24px);
}
if (message.getMetadata() != null) {
if (message.getMetadata().get(VideoCallNotificationHelper.MSG_TYPE).equals(VideoCallNotificationHelper.CALL_END)) {
String duration = message.getMetadata().get(VideoCallNotificationHelper.CALL_DURATION);
if (!TextUtils.isEmpty(duration)) {
myViewHolder5.durationTextView.setVisibility(View.VISIBLE);
duration = Utils.getTimeDurationInFormat(Long.parseLong(duration));
myViewHolder5.durationTextView.setText(duration);
}
} else {
myViewHolder5.durationTextView.setVisibility(View.GONE);
}
}
}
} else {
final MyViewHolder myHolder = (MyViewHolder) holder;
if (message != null) {
Contact receiverContact = null;
Contact contactDisplayName = null;
if (message.getGroupId() == null) {
List<String> items = Arrays.asList(message.getContactIds().split("\\s*,\\s*"));
List<String> userIds = null;
if (!TextUtils.isEmpty(message.getContactIds())) {
userIds = Arrays.asList(message.getContactIds().split("\\s*,\\s*"));
}
if (individual) {
receiverContact = contact;
contact.setContactNumber(items.get(0));
if (userIds != null) {
contact.setUserId(userIds.get(0));
}
} else {
receiverContact = contactService.getContactReceiver(items, userIds);
}
} else {
if (!TextUtils.isEmpty(message.getContactIds())) {
contactDisplayName = contactService.getContactById(message.getContactIds());
}
}
Configuration config = context.getResources().getConfiguration();
if (message.getMetadata() != null && !message.getMetadata().isEmpty() && message.getMetadata().containsKey(Message.MetaDataType.AL_REPLY.getValue())) {
final Message msg = messageDatabaseService.getMessage(message.getMetaDataValueForKey(Message.MetaDataType.AL_REPLY.getValue()));
if (msg != null) {
String displayName;
myHolder.replyRelativeLayout.setBackgroundColor(message.isTypeOutbox() ? Color.parseColor(alCustomizationSettings.getReplyMessageLayoutSentMessageBackground()) : Color.parseColor(alCustomizationSettings.getReplyMessageLayoutReceivedMessageBackground()));
myHolder.replyNameTextView.setTextColor(message.isTypeOutbox() ? Color.parseColor(alCustomizationSettings.getSentMessageTextColor()) : Color.parseColor(alCustomizationSettings.getReceivedMessageTextColor()));
myHolder.replyMessageTextView.setTextColor(message.isTypeOutbox() ? Color.parseColor(alCustomizationSettings.getSentMessageTextColor()) : Color.parseColor(alCustomizationSettings.getReceivedMessageTextColor()));
if (msg.getGroupId() != null) {
if (MobiComUserPreference.getInstance(context).getUserId().equals(msg.getContactIds()) || TextUtils.isEmpty(msg.getContactIds())) {
displayName = context.getString(R.string.you_string);
} else {
displayName = contactService.getContactById(msg.getContactIds()).getDisplayName();
}
} else {
if (msg.isTypeOutbox()) {
displayName = context.getString(R.string.you_string);
} else {
displayName = contactService.getContactById(msg.getContactIds()).getDisplayName();
}
}
myHolder.replyNameTextView.setText(displayName);
if (msg.hasAttachment()) {
FileMeta fileMeta = msg.getFileMetas();
myHolder.imageViewForAttachmentType.setVisibility(View.VISIBLE);
if (fileMeta.getContentType().contains("image")) {
myHolder.imageViewForAttachmentType.setImageResource(R.drawable.applozic_ic_image_camera_alt);
if (TextUtils.isEmpty(msg.getMessage())) {
myHolder.replyMessageTextView.setText(context.getString(R.string.photo_string));
} else {
myHolder.replyMessageTextView.setText(msg.getMessage());
}
myHolder.imageViewPhoto.setVisibility(View.VISIBLE);
myHolder.imageViewRLayout.setVisibility(View.VISIBLE);
imageThumbnailLoader.loadImage(msg, myHolder.imageViewPhoto);
} else if (fileMeta.getContentType().contains("video")) {
myHolder.imageViewForAttachmentType.setImageResource(R.drawable.applozic_ic_action_video);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
if (config.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL) {
myHolder.imageViewForAttachmentType.setScaleX(-1);
}
}
if (TextUtils.isEmpty(msg.getMessage())) {
myHolder.replyMessageTextView.setText(context.getString(R.string.video_string));
} else {
myHolder.replyMessageTextView.setText(msg.getMessage());
}
myHolder.imageViewPhoto.setVisibility(View.VISIBLE);
myHolder.imageViewRLayout.setVisibility(View.VISIBLE);
if (msg.getFilePaths() != null && msg.getFilePaths().size() > 0) {
if (imageCache.getBitmapFromMemCache(msg.getKeyString()) != null) {
myHolder.imageViewPhoto.setImageBitmap(imageCache.getBitmapFromMemCache(msg.getKeyString()));
} else {
imageCache.addBitmapToCache(message.getKeyString(), fileClientService.createAndSaveVideoThumbnail(msg.getFilePaths().get(0)));
myHolder.imageViewPhoto.setImageBitmap(fileClientService.createAndSaveVideoThumbnail(msg.getFilePaths().get(0)));
}
}
} else if (fileMeta.getContentType().contains("audio")) {
myHolder.imageViewForAttachmentType.setImageResource(R.drawable.applozic_ic_music_note);
if (TextUtils.isEmpty(msg.getMessage())) {
myHolder.replyMessageTextView.setText(context.getString(R.string.audio_string));
} else {
myHolder.replyMessageTextView.setText(msg.getMessage());
}
myHolder.imageViewPhoto.setVisibility(View.GONE);
myHolder.imageViewRLayout.setVisibility(View.GONE);
} else if (msg.isContactMessage()) {
MobiComVCFParser parser = new MobiComVCFParser();
try {
VCFContactData data = parser.parseCVFContactData(msg.getFilePaths().get(0));
if (data != null) {
myHolder.imageViewForAttachmentType.setImageResource(R.drawable.applozic_ic_person_white);
myHolder.replyMessageTextView.setText(context.getString(R.string.contact_string));
myHolder.replyMessageTextView.append(" " + data.getName());
}
} catch (Exception e) {
myHolder.imageViewForAttachmentType.setImageResource(R.drawable.applozic_ic_person_white);
myHolder.replyMessageTextView.setText(context.getString(R.string.contact_string));
}
myHolder.imageViewPhoto.setVisibility(View.GONE);
myHolder.imageViewRLayout.setVisibility(View.GONE);
} else {
myHolder.imageViewForAttachmentType.setImageResource(R.drawable.applozic_ic_action_attachment);
if (TextUtils.isEmpty(msg.getMessage())) {
myHolder.replyMessageTextView.setText(context.getString(R.string.attachment_string));
} else {
myHolder.replyMessageTextView.setText(msg.getMessage());
}
myHolder.imageViewPhoto.setVisibility(View.GONE);
myHolder.imageViewRLayout.setVisibility(View.GONE);
}
myHolder.imageViewForAttachmentType.setColorFilter(Color.parseColor(message.isTypeOutbox() ? alCustomizationSettings.getSentMessageTextColor() : alCustomizationSettings.getReceivedMessageTextColor()));
} else if (msg.getContentType() == Message.ContentType.LOCATION.getValue()) {
myHolder.imageViewForAttachmentType.setVisibility(View.VISIBLE);
myHolder.imageViewPhoto.setVisibility(View.VISIBLE);
myHolder.imageViewRLayout.setVisibility(View.VISIBLE);
myHolder.replyMessageTextView.setText(context.getString(R.string.al_location_string));
myHolder.imageViewForAttachmentType.setColorFilter(Color.parseColor(message.isTypeOutbox() ? alCustomizationSettings.getSentMessageTextColor() : alCustomizationSettings.getReceivedMessageTextColor()));
myHolder.imageViewForAttachmentType.setImageResource(R.drawable.applozic_ic_location_on_white_24dp);
loadImage.setLoadingImage(R.drawable.applozic_map_offline_thumbnail);
loadImage.loadImage(LocationUtils.loadStaticMap(msg.getMessage()), myHolder.imageViewPhoto);
} else {
myHolder.imageViewForAttachmentType.setVisibility(View.GONE);
myHolder.imageViewRLayout.setVisibility(View.GONE);
myHolder.imageViewPhoto.setVisibility(View.GONE);
myHolder.replyMessageTextView.setText(msg.getMessage());
}
myHolder.replyRelativeLayout.setVisibility(View.VISIBLE);
myHolder.replyRelativeLayout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
((OnClickReplyInterface) context).onClickOnMessageReply(msg);
}
});
}
} else {
myHolder.replyRelativeLayout.setVisibility(GONE);
}
if (TextUtils.isEmpty(message.getMessage())) {
myHolder.messageTextView.setVisibility(View.GONE);
}
myHolder.messageTextView.setVisibility(View.GONE);
myHolder.mapImageView.setVisibility(GONE);
if (channel != null) {
if (!message.hasAttachment() && TextUtils.isEmpty(message.getMessage()) && message.getMetadata() == null) {
myHolder.messageTextView.setText("");
}
}
if (myHolder.chatLocation != null) {
myHolder.chatLocation.setVisibility(View.GONE);
}
if (myHolder.attachedFile != null) {
// myHolder.attachedFile.setText("");
myHolder.attachedFile.setVisibility(View.GONE);
}
if (myHolder.attachmentIcon != null) {
myHolder.attachmentIcon.setVisibility(View.GONE);
}
if (channel != null && myHolder.nameTextView != null && contactDisplayName != null) {
myHolder.nameTextView.setVisibility(Channel.GroupType.GROUPOFTWO.getValue().equals(channel.getType()) ? View.GONE : View.VISIBLE);
if (alCustomizationSettings.isLaunchChatFromProfilePicOrName()) {
myHolder.nameTextView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(context, ConversationActivity.class);
intent.putExtra(ConversationUIService.USER_ID, message.getContactIds());
if (message.getConversationId() != null) {
intent.putExtra(ConversationUIService.CONVERSATION_ID, message.getConversationId());
}
context.startActivity(intent);
}
});
}
String userId = contactDisplayName.getDisplayName();
char firstLetter = contactDisplayName.getDisplayName().charAt(0);
if (userId.length() > 0) {
myHolder.nameTextView.setText(String.valueOf(userId));
}
Character colorKey = AlphaNumberColorUtil.alphabetBackgroundColorMap.containsKey(firstLetter) ? firstLetter : null;
myHolder.nameTextView.setTextColor(context.getResources().getColor(AlphaNumberColorUtil.alphabetBackgroundColorMap.get(colorKey)));
}
myHolder.createdAtTime.setTextColor(Color.parseColor(alCustomizationSettings.getMessageTimeTextColor()));
myHolder.attachmentDownloadLayout.setVisibility(View.GONE);
// myHolder.preview.setVisibility(message.hasAttachment() ? View.VISIBLE : View.GONE);
myHolder.attachmentView.setVisibility(View.GONE);
if (message.isTypeOutbox() && !message.isCanceled()) {
myHolder.mediaUploadProgressBar.setVisibility(View.GONE);
myHolder.mediaUploadProgressBar.setVisibility(message.isAttachmentUploadInProgress() ? View.VISIBLE : View.GONE);
} else {
myHolder.mediaUploadProgressBar.setVisibility(View.GONE);
}
if (myHolder.attachedFile != null) {
myHolder.attachedFile.setVisibility(message.hasAttachment() ? View.VISIBLE : View.GONE);
}
if (individual && message.getTimeToLive() != null) {
myHolder.selfDestruct.setText("Self destruct in " + message.getTimeToLive() + " mins");
myHolder.selfDestruct.setVisibility(View.VISIBLE);
} else {
myHolder.selfDestruct.setText("");
myHolder.selfDestruct.setVisibility(View.GONE);
}
if (myHolder.sentOrReceived != null) {
if ((!message.isCall()) || message.isDummyEmptyMessage()) {
myHolder.sentOrReceived.setVisibility(View.GONE);
} else if (message.isCall()) {
myHolder.sentOrReceived.setImageResource(R.drawable.applozic_ic_action_call_holo_light);
} else if (getItemViewType(position) == 0) {
myHolder.sentOrReceived.setImageResource(R.drawable.mobicom_social_forward);
} else {
myHolder.sentOrReceived.setImageResource(R.drawable.mobicom_social_reply);
}
if (message.isCall()) {
myHolder.messageTextView.setTextColor(context.getResources().getColor(message.isIncomingCall() ? R.color.incoming_call : R.color.outgoing_call));
}
}
if (myHolder.nameTextLayout != null && contact != null) {
myHolder.nameTextLayout.setVisibility(View.GONE);
}
if (message.isCall() || message.isDummyEmptyMessage()) {
myHolder.createdAtTime.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
} else if (!message.isSentToServer() && message.isTypeOutbox() && (contact != null || channel != null && !Channel.GroupType.OPEN.getValue().equals(channel.getType()))) {
myHolder.createdAtTime.setCompoundDrawablesWithIntrinsicBounds(null, null, message.getScheduledAt() != null ? scheduledIcon : pendingIcon, null);
} else if (message.getKeyString() != null && message.isTypeOutbox() && message.isSentToServer() && (contact != null || channel != null && !Channel.GroupType.OPEN.getValue().equals(channel.getType()))) {
Drawable statusIcon;
if (message.isDeliveredAndRead()) {
statusIcon = context.getResources().getDrawable(R.drawable.applozic_ic_action_message_read);
} else {
statusIcon = (message.getDelivered() || (contact != null && new Support(context).isSupportNumber(contact.getFormattedContactNumber())) ? deliveredIcon : (message.getScheduledAt() != null ? scheduledIcon : sentIcon));
}
myHolder.createdAtTime.setCompoundDrawablesWithIntrinsicBounds(null, null, statusIcon, null);
}
if (message.isCall()) {
myHolder.deliveryStatus.setText("");
}
if (contactDisplayName != null && myHolder.contactImage != null && alCustomizationSettings.isLaunchChatFromProfilePicOrName()) {
myHolder.contactImage.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(context, ConversationActivity.class);
intent.putExtra(ConversationUIService.USER_ID, message.getContactIds());
if (message.getConversationId() != null) {
intent.putExtra(ConversationUIService.CONVERSATION_ID, message.getConversationId());
}
context.startActivity(intent);
}
});
myHolder.alphabeticTextView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(context, ConversationActivity.class);
intent.putExtra(ConversationUIService.USER_ID, message.getContactIds());
if (message.getConversationId() != null) {
intent.putExtra(ConversationUIService.CONVERSATION_ID, message.getConversationId());
}
context.startActivity(intent);
}
});
}
if (message.isTypeOutbox()) {
loadContactImage(senderContact, contactDisplayName, message, myHolder.contactImage, myHolder.alphabeticTextView, myHolder.onlineTextView);
} else {
loadContactImage(receiverContact, contactDisplayName, message, myHolder.contactImage, myHolder.alphabeticTextView, myHolder.onlineTextView);
}
ApplozicDocumentView audioView = new ApplozicDocumentView(this.context);
audioView.inflateViewWithMessage(myHolder.view, message);
audioView.hideView(true);
if (message.hasAttachment() && myHolder.attachedFile != null & !(message.getContentType() == Message.ContentType.TEXT_URL.getValue())) {
myHolder.mainAttachmentLayout.setLayoutParams(getImageLayoutParam(false));
myHolder.mainAttachmentLayout.setVisibility(View.VISIBLE);
if (message.getFileMetas() != null && (message.getFileMetas().getContentType().contains("image") || message.getFileMetas().getContentType().contains("video"))) {
myHolder.attachedFile.setVisibility(View.GONE);
}
if (message.isAttachmentDownloaded()) {
myHolder.mapImageView.setVisibility(View.GONE);
// myHolder.preview.setVisibility(View.GONE);
String[] filePaths = new String[message.getFilePaths().size()];
int i = 0;
for (final String filePath : message.getFilePaths()) {
filePaths[i++] = filePath;
final String mimeType = FileUtils.getMimeType(filePath);
if (mimeType != null && mimeType.startsWith("image")) {
// myHolder.attachmentView.setImageBitmap(null);
myHolder.attachmentView.setVisibility(View.GONE);
myHolder.videoIcon.setVisibility(View.GONE);
myHolder.preview.setVisibility(View.VISIBLE);
myHolder.preview.setImageBitmap(null);
myHolder.attachmentDownloadLayout.setVisibility(View.GONE);
myHolder.attachmentDownloadProgressLayout.setVisibility(View.GONE);
Glide.with(context).load(new File(filePath)).into(myHolder.preview);
/*Bitmap bitmap = BitmapFactory.decodeFile(filePath);
myHolder.preview.setImageBitmap(bitmap);*/
// Picasso.with(context).load(new File(filePath)).into(myHolder.preview);
myHolder.attachmentView.setMessage(message);
myHolder.mediaDownloadProgressBar.setVisibility(View.GONE);
// myHolder.mediaUploadProgressBar.setVisibility(GONE);
myHolder.attachedFile.setVisibility(View.GONE);
myHolder.attachmentView.setProressBar(myHolder.mediaDownloadProgressBar);
myHolder.attachmentView.setDownloadProgressLayout(myHolder.attachmentDownloadProgressLayout);
/**/
/*myHolder.attachmentView.setVisibility(View.VISIBLE);
myHolder.videoIcon.setVisibility(View.GONE);
myHolder.preview.setVisibility(View.GONE);*/
} else if (mimeType != null && mimeType.startsWith("video")) {
myHolder.preview.setVisibility(View.VISIBLE);
myHolder.videoIcon.setVisibility(View.VISIBLE);
myHolder.mediaDownloadProgressBar.setVisibility(View.GONE);
myHolder.attachmentDownloadLayout.setVisibility(View.GONE);
myHolder.attachmentDownloadProgressLayout.setVisibility(View.GONE);
myHolder.attachedFile.setVisibility(View.GONE);
if (imageCache.getBitmapFromMemCache(message.getKeyString()) != null) {
myHolder.preview.setImageBitmap(imageCache.getBitmapFromMemCache(message.getKeyString()));
} else {
imageCache.addBitmapToCache(message.getKeyString(), fileClientService.createAndSaveVideoThumbnail(filePath));
myHolder.preview.setImageBitmap(fileClientService.createAndSaveVideoThumbnail(filePath));
}
} else {
myHolder.preview.setVisibility(View.GONE);
myHolder.mediaDownloadProgressBar.setVisibility(View.GONE);
myHolder.attachmentDownloadLayout.setVisibility(View.GONE);
myHolder.attachmentDownloadProgressLayout.setVisibility(View.GONE);
showAttachmentIconAndText(myHolder.attachedFile, message, mimeType);
}
}
} else if (message.isAttachmentUploadInProgress()) {
// showPreview(smListItem, preview, attachmentDownloadLayout);
myHolder.preview.setImageDrawable(null);
myHolder.preview.setImageBitmap(null);
myHolder.attachmentDownloadProgressLayout.setVisibility(View.VISIBLE);
myHolder.mediaDownloadProgressBar.setVisibility(View.VISIBLE);
myHolder.videoIcon.setVisibility(GONE);
myHolder.attachmentView.setProressBar(myHolder.mediaDownloadProgressBar);
myHolder.attachmentView.setDownloadProgressLayout(myHolder.attachmentDownloadProgressLayout);
myHolder.attachmentView.setMessage(message);
myHolder.attachmentView.setVisibility(View.VISIBLE);
myHolder.attachedFile.setVisibility(GONE);
myHolder.attachmentIcon.setVisibility(GONE);
} else if (AttachmentManager.isAttachmentInProgress(message.getKeyString())) {
// ondraw is called and thread is assigned to the attachment view...
myHolder.preview.setImageDrawable(null);
myHolder.preview.setImageBitmap(null);
myHolder.attachmentView.setMessage(message);
myHolder.attachmentView.setVisibility(View.VISIBLE);
myHolder.mediaDownloadProgressBar.setVisibility(View.VISIBLE);
myHolder.attachmentView.setProressBar(myHolder.mediaDownloadProgressBar);
myHolder.attachmentView.setDownloadProgressLayout(myHolder.attachmentDownloadProgressLayout);
myHolder.preview.setVisibility(View.VISIBLE);
showPreview(message, myHolder.preview, myHolder.attachmentDownloadLayout);
FileMeta fileMeta = message.getFileMetas();
final String mimeType = FileUtils.getMimeType(fileMeta.getName());
if (!fileMeta.getContentType().contains("image") && !fileMeta.getContentType().contains("video")) {
showAttachmentIconAndText(myHolder.attachedFile, message, mimeType);
}
myHolder.downloadSizeTextView.setText(fileMeta.getSizeInReadableFormat());
myHolder.attachmentView.setDownloadProgressLayout(myHolder.attachmentDownloadProgressLayout);
myHolder.attachmentDownloadProgressLayout.setVisibility(View.VISIBLE);
} else {
String fileKeys = message.getFileMetaKeyStrings();
int i = 0;
myHolder.preview.setVisibility(View.GONE);
// showPreview(null, myHolder.preview, myHolder.attachmentDownloadLayout);
showPreview(message, myHolder.preview, myHolder.attachmentDownloadLayout);
myHolder.preview.setVisibility(View.VISIBLE);
myHolder.videoIcon.setVisibility(View.GONE);
// for (String fileKey : message.getFileMetaKeyStrings()) {
if (message.getFileMetas() != null) {
FileMeta fileMeta = message.getFileMetas();
myHolder.attachmentDownloadLayout.setVisibility(View.VISIBLE);
myHolder.attachmentDownloadProgressLayout.setVisibility(View.GONE);
myHolder.downloadSizeTextView.setText(fileMeta.getSizeInReadableFormat());
final String mimeType = FileUtils.getMimeType(fileMeta.getName());
if (!fileMeta.getContentType().contains("image") && !fileMeta.getContentType().contains("video")) {
showAttachmentIconAndText(myHolder.attachedFile, message, mimeType);
}
}
}
if (isNormalAttachment(message)) {
myHolder.videoIcon.setVisibility(View.GONE);
myHolder.attachedFile.setVisibility(View.GONE);
myHolder.mainAttachmentLayout.setVisibility(View.GONE);
myHolder.mainContactShareLayout.setVisibility(View.GONE);
myHolder.chatLocation.setVisibility(View.GONE);
myHolder.preview.setVisibility(View.GONE);
audioView.hideView(false);
myHolder.createdAtTime.setText(DateUtils.getFormattedDate(message.getCreatedAtTime()));
}
}
if (message.isCanceled()) {
myHolder.attachmentRetry.setVisibility(View.VISIBLE);
}
myHolder.attachmentRetry.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (Utils.isInternetAvailable(context)) {
File file = null;
if (message != null && message.getFilePaths() != null) {
file = new File(message.getFilePaths().get(0));
}
if (file != null && !file.exists()) {
Toast.makeText(context, context.getString(R.string.file_does_not_exist), Toast.LENGTH_SHORT).show();
return;
}
Toast.makeText(context, context.getString(R.string.applozic_resending_attachment), Toast.LENGTH_LONG).show();
myHolder.mediaUploadProgressBar.setVisibility(View.VISIBLE);
myHolder.attachmentRetry.setVisibility(View.GONE);
// updating Cancel Flag to smListItem....
message.setCanceled(false);
messageDatabaseService.updateCanceledFlag(message.getMessageId(), 0);
conversationService.sendMessage(message, messageIntentClass);
} else {
Toast.makeText(context, context.getString(R.string.internet_connection_not_available), Toast.LENGTH_SHORT).show();
}
}
});
myHolder.attachmentDownloadProgressLayout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
myHolder.attachmentView.setVisibility(View.GONE);
myHolder.attachmentView.cancelDownload();
myHolder.attachmentDownloadProgressLayout.setVisibility(View.GONE);
message.setAttDownloadInProgress(false);
}
});
// final ProgressBar mediaDownloadProgressBar = mediaDownloadProgressBar;
myHolder.preview.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// 3. if deleted from sd crad only ...ask user to download it again or skip ...
if (message.getContentType() == Message.ContentType.TEXT_URL.getValue()) {
return;
}
if (message.isAttachmentDownloaded()) {
showFullView(message);
// return;
} else {
// if (message.isTypeOutbox() || message.isSentToServer()) {
myHolder.attachmentDownloadLayout.setVisibility(View.GONE);
myHolder.mediaDownloadProgressBar.setVisibility(View.VISIBLE);
myHolder.attachmentView.setProressBar(myHolder.mediaDownloadProgressBar);
myHolder.attachmentView.setDownloadProgressLayout(myHolder.attachmentDownloadProgressLayout);
myHolder.attachmentView.setMessage(message);
myHolder.attachmentView.setVisibility(View.VISIBLE);
myHolder.attachmentDownloadProgressLayout.setVisibility(View.VISIBLE);
}
}
});
myHolder.preview.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
return false;
}
});
myHolder.attachmentView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
showFullView(message);
}
});
myHolder.attachmentView.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
return false;
}
});
if (myHolder.attachedFile != null) {
myHolder.attachedFile.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
return false;
}
});
}
if (message.getScheduledAt() != null) {
myHolder.createdAtTime.setText(DateUtils.getFormattedDate(message.getScheduledAt()));
} else if (myHolder.createdAtTime != null && message.isDummyEmptyMessage()) {
myHolder.createdAtTime.setText("");
} else if (myHolder.createdAtTime != null) {
myHolder.createdAtTime.setText(DateUtils.getFormattedDate(message.getCreatedAtTime()));
}
String mimeType = "";
if (TextUtils.isEmpty(message.getMessage())) {
myHolder.messageTextView.setVisibility(message.hasAttachment() ? View.GONE : View.GONE);
} else {
myHolder.messageTextView.setVisibility(message.getContentType() == Message.ContentType.LOCATION.getValue() ? View.GONE : View.VISIBLE);
}
if (myHolder.messageTextView != null) {
myHolder.messageTextView.setTextColor(message.isTypeOutbox() ? Color.parseColor(alCustomizationSettings.getSentMessageTextColor()) : Color.parseColor(alCustomizationSettings.getReceivedMessageTextColor()));
myHolder.messageTextView.setLinkTextColor(message.isTypeOutbox() ? Color.parseColor(alCustomizationSettings.getSentMessageLinkTextColor()) : Color.parseColor(alCustomizationSettings.getReceivedMessageLinkTextColor()));
if (message.getContentType() == Message.ContentType.TEXT_URL.getValue()) {
try {
myHolder.mapImageView.setVisibility(View.GONE);
myHolder.attachedFile.setVisibility(View.GONE);
myHolder.preview.setVisibility(View.VISIBLE);
myHolder.messageTextView.setText(message.getMessage());
loadImage.setImageFadeIn(false);
loadImage.loadImage(message.getFileMetas().getBlobKeyString(), myHolder.preview);
myHolder.attachmentDownloadLayout.setVisibility(View.GONE);
} catch (Exception e) {
}
} else if (message.getContentType() == Message.ContentType.LOCATION.getValue()) {
// attachedFile.setVisibility(View.GONE);
// preview.setVisibility(View.GONE);
myHolder.chatLocation.setLayoutParams(getImageLayoutParam(false));
myHolder.chatLocation.setVisibility(View.VISIBLE);
loadImage.setImageFadeIn(false);
// Default image while loading image.
myHolder.mapImageView.setVisibility(View.VISIBLE);
loadImage.setLoadingImage(R.drawable.applozic_map_offline_thumbnail);
loadImage.loadImage(LocationUtils.loadStaticMap(message.getMessage()), myHolder.mapImageView);
myHolder.messageTextView.setVisibility(View.GONE);
myHolder.preview.setVisibility(View.GONE);
myHolder.mapImageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String uri = String.format(Locale.ENGLISH, "http://maps.google.com/maps?q=" + LocationUtils.getLocationFromMessage(message.getMessage()));
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
context.startActivity(intent);
}
});
} else if (message.getContentType() == Message.ContentType.PRICE.getValue()) {
myHolder.mapImageView.setVisibility(View.GONE);
myHolder.messageTextView.setText(ConversationUIService.FINAL_PRICE_TEXT + message.getMessage());
} else if ((message.getContentType() == Message.ContentType.VIDEO_MSG.getValue()) && !message.isAttachmentDownloaded()) {
myHolder.preview.setVisibility(View.VISIBLE);
myHolder.mapImageView.setVisibility(View.GONE);
myHolder.preview.setImageResource(R.drawable.applozic_video_default_thumbnail);
} else if (message.getContentType() == Message.ContentType.TEXT_HTML.getValue()) {
myHolder.mapImageView.setVisibility(View.GONE);
myHolder.messageTextView.setText(message.getMessage());
} else {
myHolder.mapImageView.setVisibility(View.GONE);
myHolder.chatLocation.setVisibility(View.GONE);
// myHolder.attachedFile.setVisibility(View.GONE);
// myHolder.preview.setVisibility(View.GONE);
myHolder.messageTextView.setText(EmoticonUtils.getSmiledText(context, message.getMessage(), emojiconHandler));
/*if (mimeType != null && myHolder.attachmentIcon != null) {
myHolder.messageTextView.setVisibility(TextUtils.isEmpty(message.getMessage()) ? View.GONE : View.VISIBLE);
if (mimeType.startsWith("image")) {
myHolder.attachmentIcon.setImageResource(R.drawable.applozic_ic_action_camera);
} else if (mimeType.startsWith("video")) {
myHolder.attachmentIcon.setImageResource(R.drawable.applozic_ic_action_video);
}
}*/
}
if (myHolder.messageTextLayout != null) {
GradientDrawable bgShape = (GradientDrawable) myHolder.messageTextLayout.getBackground();
bgShape.setColor(message.isTypeOutbox() ? Color.parseColor(alCustomizationSettings.getSentMessageBackgroundColor()) : Color.parseColor(alCustomizationSettings.getReceivedMessageBackgroundColor()));
bgShape.setStroke(3, message.isTypeOutbox() ? Color.parseColor(alCustomizationSettings.getSentMessageBorderColor()) : Color.parseColor(alCustomizationSettings.getReceivedMessageBackgroundColor()));
}
}
if (!message.hasAttachment()) {
myHolder.preview.setVisibility(View.GONE);
myHolder.attachedFile.setVisibility(View.GONE);
myHolder.mainAttachmentLayout.setVisibility(View.GONE);
myHolder.mediaDownloadProgressBar.setVisibility(View.VISIBLE);
myHolder.attachmentView.setVisibility(View.GONE);
myHolder.videoIcon.setVisibility(View.GONE);
myHolder.attachedFile.setVisibility(View.GONE);
myHolder.mainContactShareLayout.setVisibility(View.GONE);
}
// Handling contact share
if (message.isContactMessage()) {
myHolder.attachedFile.setVisibility(View.GONE);
myHolder.mainAttachmentLayout.setVisibility(View.GONE);
setupContactShareView(message, myHolder);
} else {
myHolder.mainContactShareLayout.setVisibility(View.GONE);
}
int startIndex = indexOfSearchQuery(message.getMessage());
if (startIndex != -1) {
final SpannableString highlightedName = new SpannableString(message.getMessage());
// Sets the span to start at the starting point of the match and end at "length"
// characters beyond the starting point
highlightedName.setSpan(highlightTextSpan, startIndex, startIndex + searchString.toString().length(), 0);
myHolder.messageTextView.setText(highlightedName);
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
use of com.applozic.mobicomkit.contact.VCFContactData in project Applozic-Android-SDK by AppLozic.
the class MessageInfoFragment method setupContactShareView.
/**
* Set up contectMessage
*
* @param message
* @param mainContactShareLayout
*/
private void setupContactShareView(final Message message, LinearLayout mainContactShareLayout) {
mainContactShareLayout.setVisibility(View.VISIBLE);
MobiComVCFParser parser = new MobiComVCFParser();
try {
VCFContactData data = parser.parseCVFContactData(message.getFilePaths().get(0));
ImageView shareContactImage = (ImageView) mainContactShareLayout.findViewById(R.id.contact_share_image);
TextView shareContactName = (TextView) mainContactShareLayout.findViewById(R.id.contact_share_tv_name);
TextView shareContactNo = (TextView) mainContactShareLayout.findViewById(R.id.contact_share_tv_no);
TextView shareEmailContact = (TextView) mainContactShareLayout.findViewById(R.id.contact_share_emailId);
(mainContactShareLayout.findViewById(R.id.divider)).setVisibility(View.GONE);
Button addContactButton = (Button) mainContactShareLayout.findViewById(R.id.contact_share_add_btn);
addContactButton.setVisibility(View.GONE);
shareContactName.setText(data.getName());
if (data.getProfilePic() != null) {
shareContactImage.setImageBitmap(data.getProfilePic());
}
if (!TextUtils.isEmpty(data.getTelephoneNumber())) {
shareContactNo.setText(data.getTelephoneNumber());
} else {
shareContactNo.setVisibility(View.GONE);
}
if (data.getEmail() != null) {
shareEmailContact.setText(data.getEmail());
} else {
shareEmailContact.setVisibility(View.GONE);
}
} catch (Exception e) {
Log.e("DetailedConvAdapter", "Exception in parsing", e);
}
}
Aggregations