Search in sources :

Example 1 with MobiComVCFParser

use of com.applozic.mobicomkit.contact.MobiComVCFParser 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;
}
Also used : VCFContactData(com.applozic.mobicomkit.contact.VCFContactData) Message(com.applozic.mobicomkit.api.conversation.Message) Configuration(android.content.res.Configuration) ViewConfiguration(android.view.ViewConfiguration) MobiComVCFParser(com.applozic.mobicomkit.contact.MobiComVCFParser) DeleteConversationAsyncTask(com.applozic.mobicomkit.uiwidgets.conversation.DeleteConversationAsyncTask) Intent(android.content.Intent) Uri(android.net.Uri) Collections.disjoint(java.util.Collections.disjoint) Context(android.content.Context) File(java.io.File) FileMeta(com.applozic.mobicomkit.api.attachment.FileMeta)

Example 2 with MobiComVCFParser

use of com.applozic.mobicomkit.contact.MobiComVCFParser in project Applozic-Android-SDK by AppLozic.

the class MobiComConversationFragment method onItemClick.

@Override
public boolean onItemClick(int position, MenuItem item) {
    if (messageList.size() <= position || position == -1) {
        return true;
    }
    final Message message = messageList.get(position);
    if (message.isTempDateType() || message.isCustom()) {
        return true;
    }
    switch(item.getItemId()) {
        case 0:
            if (getActivity() == null) {
                break;
            }
            if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.HONEYCOMB) {
                android.text.ClipboardManager clipboard = (android.text.ClipboardManager) ApplozicService.getContext(getContext()).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(ApplozicService.getContext(getContext()).getString(R.string.copied_message), message.getMessage());
                clipboard.setPrimaryClip(clip);
            }
            break;
        case 1:
            conversationUIService.startContactActivityForResult(message, null);
            break;
        case 2:
            messageDatabaseService.deleteMessageFromDb(message);
            deleteMessageFromDeviceList(message.getKeyString());
            Message messageToResend = new Message(message);
            messageToResend.setCreatedAtTime(System.currentTimeMillis() + MobiComUserPreference.getInstance(getActivity()).getDeviceTimeOffset());
            conversationService.sendMessage(messageToResend, userDisplayName);
            break;
        case 3:
            String messageKeyString = message.getKeyString();
            AlTask.execute(new DeleteConversationAsyncTask(conversationService, message, contact));
            deleteMessageFromDeviceList(messageKeyString);
            break;
        case 4:
            final String deleteForAllMessageKey = message.getKeyString();
            final ProgressDialog progressBar = new ProgressDialog(getContext());
            progressBar.show();
            progressBar.setMessage(Utils.getString(getContext(), R.string.delete_thread_text));
            AlTask.execute(new MessageDeleteTask(getContext(), deleteForAllMessageKey, true, new AlCallback() {

                @Override
                public void onSuccess(Object response) {
                    int index = messageList.indexOf(message);
                    message.setAsDeletedForAll();
                    messageDatabaseService.replaceExistingMessage(message);
                    updateMessageAtIndex(index, message, recyclerDetailConversationAdapter);
                    if (progressBar != null) {
                        progressBar.dismiss();
                    }
                }

                @Override
                public void onError(Object error) {
                    if (progressBar != null) {
                        progressBar.dismiss();
                    }
                    Toast.makeText(ApplozicService.getContext(getContext()), Utils.getString(getContext(), R.string.delete_conversation_failed), Toast.LENGTH_SHORT).show();
                }
            }));
            break;
        case 5:
            String messageJson = GsonUtils.getJsonFromObject(message, Message.class);
            conversationUIService.startMessageInfoFragment(messageJson);
            break;
        case 6:
            Intent shareIntent = new Intent();
            shareIntent.setAction(Intent.ACTION_SEND);
            if (message.getFilePaths() != null) {
                Uri shareUri = null;
                if (Utils.hasNougat()) {
                    shareUri = ALFileProvider.getUriForFile(ApplozicService.getContext(getContext()), Utils.getMetaDataValue(getActivity(), MobiComKitConstants.PACKAGE_NAME) + ".applozic.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, ApplozicService.getContext(getContext()).getString(R.string.send_message_to)));
            break;
        case 7:
            try {
                Configuration config = ApplozicService.getContext(getContext()).getResources().getConfiguration();
                messageMetaData = new HashMap<>();
                String displayName;
                if (message.getGroupId() != null) {
                    if (loggedInUserId.equals(message.getContactIds()) || TextUtils.isEmpty(message.getContactIds())) {
                        displayName = ApplozicService.getContext(getContext()).getString(R.string.you_string);
                    } else {
                        displayName = appContactService.getContactById(message.getContactIds()).getDisplayName();
                    }
                } else {
                    if (message.isTypeOutbox()) {
                        displayName = ApplozicService.getContext(getContext()).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(ApplozicService.getContext(getContext()).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(ApplozicService.getContext(getContext()).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.getOrCreateVideoThumbnail(message.getFilePaths().get(0)));
                                galleryImageView.setImageBitmap(fileClientService.getOrCreateVideoThumbnail(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(ApplozicService.getContext(getContext()).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(ApplozicService.getContext(getContext()).getString(R.string.contact_string));
                                messageTextView.append(" " + data.getName());
                            }
                        } catch (Exception e) {
                            imageViewForAttachmentType.setImageResource(R.drawable.applozic_ic_person_white);
                            messageTextView.setText(ApplozicService.getContext(getContext()).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(ApplozicService.getContext(getContext()).getString(R.string.attachment_string));
                        } else {
                            messageTextView.setText(message.getMessage());
                        }
                        galleryImageView.setVisibility(View.GONE);
                        imageViewRLayout.setVisibility(View.GONE);
                    }
                    imageViewForAttachmentType.setColorFilter(ContextCompat.getColor(ApplozicService.getContext(getContext()), 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(ApplozicService.getContext(getContext()).getString(R.string.al_location_string));
                    imageViewForAttachmentType.setImageResource(R.drawable.applozic_ic_location_on_white_24dp);
                    imageViewForAttachmentType.setColorFilter(ContextCompat.getColor(ApplozicService.getContext(getContext()), R.color.apploizc_lite_gray_color));
                    messageImageLoader.setLoadingImage(R.drawable.applozic_map_offline_thumbnail);
                    messageImageLoader.loadImage(LocationUtils.loadStaticMap(message.getMessage(), geoApiKey), 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) && (contact != null || (channel != null && !Channel.GroupType.OPEN.getValue().equals(channel.getType())))) {
                        messageDatabaseService.updateMessageReplyType(replyMessageKey, Message.ReplyMessage.REPLY_MESSAGE.getValue());
                    }
                }
                attachReplyCancelLayout.setVisibility(VISIBLE);
                replayRelativeLayout.setVisibility(VISIBLE);
            } catch (Exception e) {
            }
            break;
        case 8:
            AlTask.execute(new AlMessageReportTask(message.getKeyString(), conversationService, new AlCallback() {

                @Override
                public void onSuccess(Object response) {
                    Toast.makeText(getContext(), ApplozicService.getContext(getContext()).getString(R.string.message_reported_successfully), Toast.LENGTH_SHORT).show();
                }

                @Override
                public void onError(Object error) {
                    Toast.makeText(getContext(), ApplozicService.getContext(getContext()).getString(R.string.failed_to_report_message), Toast.LENGTH_SHORT).show();
                }
            }));
            break;
    }
    return true;
}
Also used : VCFContactData(com.applozic.mobicomkit.contact.VCFContactData) AlRichMessage(com.applozic.mobicomkit.uiwidgets.conversation.richmessaging.AlRichMessage) Message(com.applozic.mobicomkit.api.conversation.Message) Configuration(android.content.res.Configuration) ViewConfiguration(android.view.ViewConfiguration) MobiComVCFParser(com.applozic.mobicomkit.contact.MobiComVCFParser) DeleteConversationAsyncTask(com.applozic.mobicomkit.uiwidgets.conversation.DeleteConversationAsyncTask) ProgressDialog(android.app.ProgressDialog) Uri(android.net.Uri) Context(android.content.Context) AlMessageReportTask(com.applozic.mobicomkit.api.conversation.AlMessageReportTask) Intent(android.content.Intent) AlCallback(com.applozic.mobicomkit.listners.AlCallback) Collections.disjoint(java.util.Collections.disjoint) ApplozicException(com.applozic.mobicomkit.exception.ApplozicException) PatternSyntaxException(java.util.regex.PatternSyntaxException) MessageDeleteTask(com.applozic.mobicomkit.api.conversation.MessageDeleteTask) File(java.io.File) FileMeta(com.applozic.mobicomkit.api.attachment.FileMeta)

Example 3 with MobiComVCFParser

use of com.applozic.mobicomkit.contact.MobiComVCFParser 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);
    }
}
Also used : VCFContactData(com.applozic.mobicomkit.contact.VCFContactData) MobiComVCFParser(com.applozic.mobicomkit.contact.MobiComVCFParser) Button(android.widget.Button) TextView(android.widget.TextView) ImageView(android.widget.ImageView) CircleImageView(de.hdodenhof.circleimageview.CircleImageView)

Example 4 with MobiComVCFParser

use of com.applozic.mobicomkit.contact.MobiComVCFParser 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(), alCustomizationSettings.getDateFormatCustomization().getTimeTemplate()));
                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.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() ? deliveredIcon : (message.getScheduledAt() != null ? scheduledIcon : sentIcon));
                    }
                    myHolder.createdAtTime.setCompoundDrawablesWithIntrinsicBounds(null, null, statusIcon, null);
                }
                if (message.isCall()) {
                    myHolder.deliveryStatus.setText("");
                }
                ApplozicDocumentView audioView = new ApplozicDocumentView(activityContext, storagePermissionListener);
                audioView.inflateViewWithMessage(myHolder.view, message);
                audioView.hideView(true);
                if (message.isDeletedForAll()) {
                    myHolder.messageTextView.setCompoundDrawablesWithIntrinsicBounds(context.getResources().getDrawable(R.drawable.round_not_interested_black_24), null, null, null);
                    if (android.os.Build.VERSION.SDK_INT >= 21) {
                        myHolder.messageTextView.getCompoundDrawables()[0].setTint(Color.parseColor(message.isTypeOutbox() ? alCustomizationSettings.getSentMessageTextColor() : alCustomizationSettings.getReceivedMessageTextColor()));
                    }
                    myHolder.messageTextView.setText(R.string.deleted_message_text);
                    myHolder.messageTextView.setTypeface(null, Typeface.ITALIC);
                    myHolder.messageTextView.setVisibility(View.VISIBLE);
                    myHolder.createdAtTime.setText(DateUtils.getFormattedDate(message.getCreatedAtTime(), alCustomizationSettings.getDateFormatCustomization().getTimeTemplate()));
                    myHolder.replyRelativeLayout.setVisibility(GONE);
                    myHolder.richMessageLayout.setVisibility(View.GONE);
                    myHolder.preview.setVisibility(View.GONE);
                    myHolder.attachedFile.setVisibility(View.GONE);
                    myHolder.mainAttachmentLayout.setVisibility(View.GONE);
                    myHolder.attachmentView.setVisibility(View.GONE);
                    myHolder.videoIcon.setVisibility(View.GONE);
                    myHolder.mainContactShareLayout.setVisibility(View.GONE);
                    myHolder.mapImageView.setVisibility(View.GONE);
                    myHolder.urlLoadLayout.setVisibility(View.GONE);
                } else {
                    myHolder.messageTextView.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
                    myHolder.messageTextView.setTypeface(null, Typeface.NORMAL);
                    if (message.getMetadata() != null && !message.getMetadata().isEmpty() && message.getMetadata().containsKey(Message.MetaDataType.AL_REPLY.getValue())) {
                        String keyString = message.getMetaDataValueForKey(Message.MetaDataType.AL_REPLY.getValue());
                        Message messageToBeReplied = new Message();
                        messageToBeReplied.setKeyString(keyString);
                        int indexOfObject = messageList.indexOf(messageToBeReplied);
                        if (indexOfObject != -1) {
                            messageToBeReplied = messageList.get(indexOfObject);
                        } else {
                            messageToBeReplied = messageDatabaseService.getMessage(message.getMetaDataValueForKey(Message.MetaDataType.AL_REPLY.getValue()));
                        }
                        final Message msg = messageToBeReplied;
                        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(MentionHelper.getMessageSpannableStringForMentionsDisplay(context, msg, true, alCustomizationSettings.getConversationMentionSpanColor()));
                                    }
                                    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(MentionHelper.getMessageSpannableStringForMentionsDisplay(context, msg, true, alCustomizationSettings.getConversationMentionSpanColor()));
                                    }
                                    myHolder.imageViewPhoto.setVisibility(View.VISIBLE);
                                    myHolder.imageViewRLayout.setVisibility(View.VISIBLE);
                                    if (msg.getFilePaths() != null && msg.getFilePaths().size() > 0) {
                                        if (imageCache != null && imageCache.getBitmapFromMemCache(msg.getKeyString()) != null) {
                                            myHolder.imageViewPhoto.setImageBitmap(imageCache.getBitmapFromMemCache(msg.getKeyString()));
                                        } else {
                                            if (imageCache != null) {
                                                imageCache.addBitmapToCache(message.getKeyString(), fileClientService.getOrCreateVideoThumbnail(msg.getFilePaths().get(0)));
                                            }
                                            myHolder.imageViewPhoto.setImageBitmap(fileClientService.getOrCreateVideoThumbnail(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(MentionHelper.getMessageSpannableStringForMentionsDisplay(context, msg, true, alCustomizationSettings.getConversationMentionSpanColor()));
                                    }
                                    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(MentionHelper.getMessageSpannableStringForMentionsDisplay(context, msg, true, alCustomizationSettings.getConversationMentionSpanColor()));
                                    }
                                    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(), geoApiKey), myHolder.imageViewPhoto);
                            } else {
                                myHolder.imageViewForAttachmentType.setVisibility(View.GONE);
                                myHolder.imageViewRLayout.setVisibility(View.GONE);
                                myHolder.imageViewPhoto.setVisibility(View.GONE);
                                myHolder.replyMessageTextView.setText(MentionHelper.getMessageSpannableStringForMentionsDisplay(context, msg, true, alCustomizationSettings.getConversationMentionSpanColor()));
                            }
                            myHolder.replyRelativeLayout.setVisibility(View.VISIBLE);
                            myHolder.replyRelativeLayout.setOnClickListener(new View.OnClickListener() {

                                @Override
                                public void onClick(View v) {
                                    ((OnClickReplyInterface) activityContext).onClickOnMessageReply(msg);
                                }
                            });
                        }
                    } else {
                        myHolder.replyRelativeLayout.setVisibility(GONE);
                    }
                    if (TextUtils.isEmpty(message.getMessage())) {
                        myHolder.messageTextView.setVisibility(View.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 (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(activityContext, ConversationActivity.class);
                                    intent.putExtra(ConversationUIService.USER_ID, message.getContactIds());
                                    if (message.getConversationId() != null) {
                                        intent.putExtra(ConversationUIService.CONVERSATION_ID, message.getConversationId());
                                    }
                                    activityContext.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()));
                    if (message.isTypeOutbox() && !message.isCanceled()) {
                        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 (contactDisplayName != null && myHolder.contactImage != null && alCustomizationSettings.isLaunchChatFromProfilePicOrName()) {
                        myHolder.contactImage.setOnClickListener(new View.OnClickListener() {

                            @Override
                            public void onClick(View view) {
                                Intent intent = new Intent(activityContext, ConversationActivity.class);
                                intent.putExtra(ConversationUIService.USER_ID, message.getContactIds());
                                if (message.getConversationId() != null) {
                                    intent.putExtra(ConversationUIService.CONVERSATION_ID, message.getConversationId());
                                }
                                activityContext.startActivity(intent);
                            }
                        });
                        myHolder.alphabeticTextView.setOnClickListener(new View.OnClickListener() {

                            @Override
                            public void onClick(View view) {
                                Intent intent = new Intent(activityContext, ConversationActivity.class);
                                intent.putExtra(ConversationUIService.USER_ID, message.getContactIds());
                                if (message.getConversationId() != null) {
                                    intent.putExtra(ConversationUIService.CONVERSATION_ID, message.getConversationId());
                                }
                                activityContext.startActivity(intent);
                            }
                        });
                    }
                    if (!message.isTypeOutbox()) {
                        loadContactImage(receiverContact, contactDisplayName, message, myHolder.contactImage, myHolder.alphabeticTextView, myHolder.onlineTextView);
                    }
                    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.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);
                                    if (mimeType.contains("gif")) {
                                        Glide.with(context).asGif().load(new File(filePath)).into(myHolder.preview);
                                    } else {
                                        Glide.with(context).load(new File(filePath)).into(myHolder.preview);
                                    }
                                    myHolder.attachmentView.setMessage(message);
                                    myHolder.mediaDownloadProgressBar.setVisibility(View.GONE);
                                    myHolder.attachedFile.setVisibility(View.GONE);
                                    myHolder.attachmentView.setProressBar(myHolder.mediaDownloadProgressBar);
                                    myHolder.attachmentView.setDownloadProgressLayout(myHolder.attachmentDownloadProgressLayout);
                                } 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.getOrCreateVideoThumbnail(filePath));
                                        myHolder.preview.setImageBitmap(fileClientService.getOrCreateVideoThumbnail(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);
                        } 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 (message.isNormalAttachment()) {
                            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(), alCustomizationSettings.getDateFormatCustomization().getTimeTemplate()));
                        }
                    }
                    if (message.isCanceled()) {
                        myHolder.attachmentRetry.setVisibility(View.VISIBLE);
                    } else {
                        myHolder.attachmentRetry.setVisibility(View.GONE);
                    }
                    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);
                                if (sendMessageInterfaceCallBack != null) {
                                    sendMessageInterfaceCallBack.sendMessage(message);
                                }
                            } 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()) {
                                if (storagePermissionListener.isPermissionGranted()) {
                                    showFullView(message);
                                } else {
                                    storagePermissionListener.checkPermission(new ALStoragePermission() {

                                        @Override
                                        public void onAction(boolean didGrant) {
                                            if (didGrant) {
                                                showFullView(message);
                                            }
                                        }
                                    });
                                }
                            } else {
                                if (storagePermissionListener.isPermissionGranted()) {
                                    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.setGifDownloadListener(new GifDownloadImpl(context));
                                    myHolder.attachmentView.setVisibility(View.VISIBLE);
                                    myHolder.attachmentDownloadProgressLayout.setVisibility(View.VISIBLE);
                                } else {
                                    storagePermissionListener.checkPermission(new ALStoragePermission() {

                                        @Override
                                        public void onAction(boolean didGrant) {
                                            if (didGrant) {
                                                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.setGifDownloadListener(new GifDownloadImpl(context));
                                                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) {
                            if (storagePermissionListener.isPermissionGranted()) {
                                showFullView(message);
                            } else {
                                storagePermissionListener.checkPermission(new ALStoragePermission() {

                                    @Override
                                    public void onAction(boolean didGrant) {
                                        if (didGrant) {
                                            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(), alCustomizationSettings.getDateFormatCustomization().getTimeTemplate()));
                    } else if (myHolder.createdAtTime != null && message.isDummyEmptyMessage()) {
                        myHolder.createdAtTime.setText("");
                    } else if (myHolder.createdAtTime != null) {
                        myHolder.createdAtTime.setText(DateUtils.getFormattedDate(message.getCreatedAtTime(), alCustomizationSettings.getDateFormatCustomization().getTimeTemplate()));
                    }
                    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);
                                setMessageText(myHolder.messageTextView, message);
                                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(), geoApiKey), 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));
                                    activityContext.startActivity(intent);
                                }
                            });
                        } else if (message.getContentType() == Message.ContentType.PRICE.getValue()) {
                            myHolder.mapImageView.setVisibility(View.GONE);
                            SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(MentionHelper.getMessageSpannableStringForMentionsDisplay(context, message, true, alCustomizationSettings.getConversationMentionSpanColor()));
                            spannableStringBuilder.insert(0, ConversationUIService.FINAL_PRICE_TEXT);
                            myHolder.messageTextView.setText(spannableStringBuilder);
                        } else if ((message.getContentType() == Message.ContentType.VIDEO_MSG.getValue()) && !message.isAttachmentDownloaded()) {
                            myHolder.preview.setVisibility(View.VISIBLE);
                            myHolder.mapImageView.setVisibility(View.GONE);
                        } else if (message.getContentType() == Message.ContentType.TEXT_HTML.getValue()) {
                            myHolder.mapImageView.setVisibility(View.GONE);
                            setMessageText(myHolder.messageTextView, message);
                        } else {
                            myHolder.mapImageView.setVisibility(View.GONE);
                            myHolder.chatLocation.setVisibility(View.GONE);
                            myHolder.messageTextView.setText(EmoticonUtils.getSmiledText(activityContext, MentionHelper.getMessageSpannableStringForMentionsDisplay(context, message, true, alCustomizationSettings.getConversationMentionSpanColor()), emojiconHandler));
                        }
                        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.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);
                    }
                    if (message.isTypeUrl()) {
                        new AlLinkPreview(activityContext, message, myHolder.urlLoadLayout, alCustomizationSettings).createView();
                    } else {
                        myHolder.urlLoadLayout.setVisibility(View.GONE);
                    }
                    if (message.getMetadata() != null && "300".equals(message.getMetadata().get("contentType"))) {
                        myHolder.richMessageLayout.setVisibility(View.VISIBLE);
                        if (!TextUtils.isEmpty(message.getMessage())) {
                            myHolder.messageTextLayout.setVisibility(View.VISIBLE);
                        } else {
                            myHolder.messageTextLayout.setVisibility(GONE);
                        }
                        try {
                            new AlRichMessage(activityContext, myHolder.richMessageLayout, message, listener, alCustomizationSettings).createRichMessage();
                        } catch (Exception e) {
                            e.printStackTrace();
                            myHolder.richMessageLayout.setVisibility(View.GONE);
                        }
                    } else {
                        myHolder.richMessageLayout.setVisibility(View.GONE);
                        myHolder.messageTextLayout.setVisibility(View.VISIBLE);
                    }
                    // 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);
                    }
                    Spannable mentionsMessageString = MentionHelper.getMessageSpannableStringForMentionsDisplay(context, message, true, alCustomizationSettings.getConversationMentionSpanColor());
                    int startIndex = indexOfSearchQuery(mentionsMessageString.toString());
                    if (startIndex != -1) {
                        final SpannableString highlightedName = new SpannableString(mentionsMessageString);
                        // Sets the span to start at the starting point of the match and end at "length"
                        // characters beyond the starting point
                        highlightedName.setSpan(new ForegroundColorSpan(Color.parseColor(alCustomizationSettings.getMessageSearchTextColor())), startIndex, startIndex + searchString.toString().length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
                        myHolder.messageTextView.setText(highlightedName);
                    }
                }
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : VCFContactData(com.applozic.mobicomkit.contact.VCFContactData) AlRichMessage(com.applozic.mobicomkit.uiwidgets.conversation.richmessaging.AlRichMessage) Message(com.applozic.mobicomkit.api.conversation.Message) Configuration(android.content.res.Configuration) MobiComVCFParser(com.applozic.mobicomkit.contact.MobiComVCFParser) ALStoragePermission(com.applozic.mobicomkit.uiwidgets.uilistener.ALStoragePermission) SpannableString(android.text.SpannableString) ArrayList(java.util.ArrayList) List(java.util.List) ApplozicDocumentView(com.applozic.mobicomkit.uiwidgets.attachmentview.ApplozicDocumentView) OnClickReplyInterface(com.applozic.mobicomkit.uiwidgets.conversation.activity.OnClickReplyInterface) AlLinkPreview(com.applozic.mobicomkit.uiwidgets.conversation.richmessaging.views.AlLinkPreview) ForegroundColorSpan(android.text.style.ForegroundColorSpan) Drawable(android.graphics.drawable.Drawable) GradientDrawable(android.graphics.drawable.GradientDrawable) Intent(android.content.Intent) AlRichMessage(com.applozic.mobicomkit.uiwidgets.conversation.richmessaging.AlRichMessage) ImageView(android.widget.ImageView) CircleImageView(de.hdodenhof.circleimageview.CircleImageView) View(android.view.View) ApplozicDocumentView(com.applozic.mobicomkit.uiwidgets.attachmentview.ApplozicDocumentView) RecyclerView(androidx.recyclerview.widget.RecyclerView) TextView(android.widget.TextView) AttachmentView(com.applozic.mobicomkit.api.attachment.AttachmentView) Date(java.util.Date) GradientDrawable(android.graphics.drawable.GradientDrawable) Contact(com.applozic.mobicommons.people.contact.Contact) SpannableString(android.text.SpannableString) SimpleDateFormat(java.text.SimpleDateFormat) File(java.io.File) FileMeta(com.applozic.mobicomkit.api.attachment.FileMeta) SpannableStringBuilder(android.text.SpannableStringBuilder) Spannable(android.text.Spannable)

Example 5 with MobiComVCFParser

use of com.applozic.mobicomkit.contact.MobiComVCFParser 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) {
                if (storagePermissionListener.isPermissionGranted()) {
                    Intent intent = new Intent();
                    intent.setAction(Intent.ACTION_VIEW);
                    Uri outputUri = null;
                    intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
                    if (Utils.hasNougat()) {
                        outputUri = ALFileProvider.getUriForFile(context, Utils.getMetaDataValue(context, MobiComKitConstants.PACKAGE_NAME) + ".applozic.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");
                        activityContext.startActivity(intent);
                    } else {
                        Toast.makeText(context, R.string.info_app_not_found_to_open_file, Toast.LENGTH_LONG).show();
                    }
                } else {
                    storagePermissionListener.checkPermission(new ALStoragePermission() {

                        @Override
                        public void onAction(boolean didGrant) {
                            Intent intent = new Intent();
                            intent.setAction(Intent.ACTION_VIEW);
                            Uri outputUri = null;
                            intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
                            if (Utils.hasNougat()) {
                                outputUri = ALFileProvider.getUriForFile(context, Utils.getMetaDataValue(context, MobiComKitConstants.PACKAGE_NAME) + ".applozic.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");
                                activityContext.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");
    }
}
Also used : VCFContactData(com.applozic.mobicomkit.contact.VCFContactData) MobiComVCFParser(com.applozic.mobicomkit.contact.MobiComVCFParser) Intent(android.content.Intent) ALStoragePermission(com.applozic.mobicomkit.uiwidgets.uilistener.ALStoragePermission) ImageView(android.widget.ImageView) CircleImageView(de.hdodenhof.circleimageview.CircleImageView) View(android.view.View) ApplozicDocumentView(com.applozic.mobicomkit.uiwidgets.attachmentview.ApplozicDocumentView) RecyclerView(androidx.recyclerview.widget.RecyclerView) TextView(android.widget.TextView) AttachmentView(com.applozic.mobicomkit.api.attachment.AttachmentView) Uri(android.net.Uri) File(java.io.File)

Aggregations

MobiComVCFParser (com.applozic.mobicomkit.contact.MobiComVCFParser)5 VCFContactData (com.applozic.mobicomkit.contact.VCFContactData)5 Intent (android.content.Intent)4 File (java.io.File)4 Configuration (android.content.res.Configuration)3 Uri (android.net.Uri)3 ImageView (android.widget.ImageView)3 TextView (android.widget.TextView)3 FileMeta (com.applozic.mobicomkit.api.attachment.FileMeta)3 Message (com.applozic.mobicomkit.api.conversation.Message)3 CircleImageView (de.hdodenhof.circleimageview.CircleImageView)3 Context (android.content.Context)2 View (android.view.View)2 ViewConfiguration (android.view.ViewConfiguration)2 RecyclerView (androidx.recyclerview.widget.RecyclerView)2 AttachmentView (com.applozic.mobicomkit.api.attachment.AttachmentView)2 ApplozicDocumentView (com.applozic.mobicomkit.uiwidgets.attachmentview.ApplozicDocumentView)2 DeleteConversationAsyncTask (com.applozic.mobicomkit.uiwidgets.conversation.DeleteConversationAsyncTask)2 AlRichMessage (com.applozic.mobicomkit.uiwidgets.conversation.richmessaging.AlRichMessage)2 ALStoragePermission (com.applozic.mobicomkit.uiwidgets.uilistener.ALStoragePermission)2