From 7d80926069d6d529021e47304cd53bf3d0a7589c Mon Sep 17 00:00:00 2001 From: cyBerta Date: Fri, 15 Mar 2019 11:37:17 +0100 Subject: [PATCH] show truncated message body text in bubble on map --- res/layout/map_bubble_layout.xml | 3 +++ .../securesms/map/GenerateInfoWindowTask.java | 22 +++++++++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/res/layout/map_bubble_layout.xml b/res/layout/map_bubble_layout.xml index 04db1f3e9..10db4fcef 100644 --- a/res/layout/map_bubble_layout.xml +++ b/res/layout/map_bubble_layout.xml @@ -86,6 +86,9 @@ android:id="@+id/conversation_item_body" android:layout_width="wrap_content" android:layout_height="wrap_content" + android:maxWidth="150dp" + android:maxLines="2" + android:ellipsize="end" android:layout_marginLeft="@dimen/message_bubble_horizontal_padding" android:layout_marginRight="@dimen/message_bubble_horizontal_padding" android:layout_marginBottom="@dimen/message_bubble_collapsed_footer_padding" diff --git a/src/org/thoughtcrime/securesms/map/GenerateInfoWindowTask.java b/src/org/thoughtcrime/securesms/map/GenerateInfoWindowTask.java index 4391df9df..96b2a5e8a 100644 --- a/src/org/thoughtcrime/securesms/map/GenerateInfoWindowTask.java +++ b/src/org/thoughtcrime/securesms/map/GenerateInfoWindowTask.java @@ -8,19 +8,27 @@ import android.graphics.Bitmap; import android.os.AsyncTask; import android.util.Log; import android.view.LayoutInflater; +import android.view.View; import android.widget.LinearLayout; import android.widget.TextView; +import com.b44t.messenger.DcMsg; import com.mapbox.geojson.Feature; +import org.thoughtcrime.securesms.ApplicationContext; import org.thoughtcrime.securesms.R; +import org.thoughtcrime.securesms.components.ConversationItemFooter; import org.thoughtcrime.securesms.util.BitmapUtil; +import org.thoughtcrime.securesms.util.DateUtils; +import org.thoughtcrime.securesms.util.DynamicLanguage; import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.HashMap; +import java.util.Locale; import static org.thoughtcrime.securesms.map.MapDataManager.INFO_WINDOW_ID; +import static org.thoughtcrime.securesms.map.MapDataManager.MESSAGE_ID; import static org.thoughtcrime.securesms.map.MapDataManager.TIMESTAMP; /** @@ -61,9 +69,19 @@ public class GenerateInfoWindowTask extends AsyncTask, HashMa LinearLayout bubbleLayout = (LinearLayout) inflater.inflate(R.layout.map_bubble_layout, null); - TextView titleTextView = bubbleLayout.findViewById(R.id.conversation_item_body); - titleTextView.setText("TIMESTAMP: " + feature.getNumberProperty(TIMESTAMP)); bubbleLayout.setBackgroundResource(R.drawable.message_bubble_background_received_alone); + TextView conversationItemBody = bubbleLayout.findViewById(R.id.conversation_item_body); + Locale locale = DynamicLanguage.getSelectedLocale(callbackRef.get().getContext()); + int messageId = (int) feature.getNumberProperty(MESSAGE_ID); + if (messageId != 0) { + DcMsg msg = ApplicationContext.getInstance(callbackRef.get().getContext()).dcContext.getMsg(messageId); + conversationItemBody.setText(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))); + } Bitmap bitmap = BitmapUtil.generate(bubbleLayout);