From f29cb1d27bc6daeee14496ee484e9cbc6de12d9a Mon Sep 17 00:00:00 2001 From: cyBerta Date: Fri, 15 Mar 2019 13:08:28 +0100 Subject: [PATCH] show thumbnails for attached images in map --- res/layout/map_bubble_layout.xml | 85 +++++++------------ .../securesms/map/GenerateInfoWindowTask.java | 29 ++++++- 2 files changed, 56 insertions(+), 58 deletions(-) diff --git a/res/layout/map_bubble_layout.xml b/res/layout/map_bubble_layout.xml index 10db4fcef..19e663e55 100644 --- a/res/layout/map_bubble_layout.xml +++ b/res/layout/map_bubble_layout.xml @@ -44,65 +44,40 @@ - + android:orientation="horizontal" + > - + - - - - - - - + + , HashMa TextView conversationItemBody = bubbleLayout.findViewById(R.id.conversation_item_body); Locale locale = DynamicLanguage.getSelectedLocale(callbackRef.get().getContext()); int messageId = (int) feature.getNumberProperty(MESSAGE_ID); + String msgText; if (messageId != 0) { - DcMsg msg = ApplicationContext.getInstance(callbackRef.get().getContext()).dcContext.getMsg(messageId); - conversationItemBody.setText(msg.getSummarytext(75)); + DcContext dcContext = ApplicationContext.getInstance(callbackRef.get().getContext()).dcContext; + DcMsg msg = dcContext.getMsg(messageId); + if (hasImgThumbnail(msg)) { + ImageView thumbnailView = bubbleLayout.findViewById(R.id.map_bubble_img_thumbnail); + thumbnailView.setImageURI(getThumbnailUri(msg)); + thumbnailView.setVisibility(View.VISIBLE); + msgText = msg.getText(); + } else { + msgText = msg.getSummarytext(75); + } ConversationItemFooter footer = bubbleLayout.findViewById(R.id.conversation_item_footer); footer.setVisibility(View.VISIBLE); footer.setMessageRecord(msg, locale); } else { - conversationItemBody.setText("Reported: " + DateUtils.getExtendedRelativeTimeSpanString(callbackRef.get().getContext(), locale, (long) feature.getNumberProperty(TIMESTAMP))); + msgText = "Reported: " + DateUtils.getExtendedRelativeTimeSpanString(callbackRef.get().getContext(), locale, (long) feature.getNumberProperty(TIMESTAMP)); } + conversationItemBody.setText(msgText); Bitmap bitmap = BitmapUtil.generate(bubbleLayout); String id = feature.getStringProperty(INFO_WINDOW_ID); @@ -126,4 +140,13 @@ public class GenerateInfoWindowTask extends AsyncTask, HashMa Log.e(TAG, "Callback was GC'ed before task finished."); } } + + private boolean hasImgThumbnail(DcMsg messageRecord) { + int type = messageRecord.getType(); + return type==DcMsg.DC_MSG_IMAGE; + } + + public Uri getThumbnailUri(DcMsg dcMsg) { + return Uri.fromFile(new File(dcMsg.getFile())); + } } \ No newline at end of file