mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
show thumbnails for attached images in map
This commit is contained in:
@@ -44,65 +44,40 @@
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<org.thoughtcrime.securesms.components.QuoteView
|
||||
android:id="@+id/quote_view"
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/message_bubble_top_padding"
|
||||
android:layout_marginLeft="6dp"
|
||||
android:layout_marginRight="6dp"
|
||||
android:visibility="gone"
|
||||
app:message_type="outgoing"
|
||||
app:quote_colorPrimary="?attr/conversation_item_quote_text_color"
|
||||
app:quote_colorSecondary="?attr/conversation_item_quote_text_color"
|
||||
tools:visibility="visible"/>
|
||||
android:orientation="horizontal"
|
||||
>
|
||||
|
||||
<ViewStub
|
||||
android:id="@+id/image_view_stub"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout="@layout/conversation_item_sent_thumbnail" />
|
||||
<ImageView
|
||||
android:id="@+id/map_bubble_img_thumbnail"
|
||||
android:layout_width="75dp"
|
||||
android:layout_height="75dp"
|
||||
android:padding="10dp"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible"
|
||||
/>
|
||||
|
||||
<ViewStub
|
||||
android:id="@+id/audio_view_stub"
|
||||
android:layout="@layout/conversation_item_sent_audio"
|
||||
android:layout_width="210dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/message_bubble_top_padding"
|
||||
android:layout_marginLeft="@dimen/message_bubble_horizontal_padding"
|
||||
android:layout_marginRight="@dimen/message_bubble_horizontal_padding" />
|
||||
|
||||
<ViewStub
|
||||
android:id="@+id/document_view_stub"
|
||||
android:layout="@layout/conversation_item_sent_document"
|
||||
android:layout_width="210dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/message_bubble_top_padding"
|
||||
android:layout_marginBottom="@dimen/message_bubble_collapsed_footer_padding"
|
||||
android:layout_marginLeft="@dimen/message_bubble_horizontal_padding"
|
||||
android:layout_marginRight="@dimen/message_bubble_horizontal_padding" />
|
||||
|
||||
<org.thoughtcrime.securesms.components.emoji.EmojiTextView
|
||||
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"
|
||||
style="@style/Signal.Text.Body"
|
||||
android:paddingTop="@dimen/message_bubble_top_padding"
|
||||
android:textColor="?conversation_item_outgoing_text_primary_color"
|
||||
android:textColorLink="?conversation_item_outgoing_text_primary_color"
|
||||
app:scaleEmojis="true"
|
||||
tools:text="Mango pickle lorem ipsum"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone" />
|
||||
<org.thoughtcrime.securesms.components.emoji.EmojiTextView
|
||||
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_gravity="center_vertical"
|
||||
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"
|
||||
style="@style/Signal.Text.Body"
|
||||
android:paddingTop="@dimen/message_bubble_top_padding"
|
||||
android:textColor="?conversation_item_outgoing_text_primary_color"
|
||||
android:textColorLink="?conversation_item_outgoing_text_primary_color"
|
||||
app:scaleEmojis="true"
|
||||
tools:text="Mango pickle lorem ipsum"/>
|
||||
</LinearLayout>
|
||||
|
||||
<org.thoughtcrime.securesms.components.ConversationItemFooter
|
||||
android:id="@+id/conversation_item_footer"
|
||||
|
||||
@@ -5,13 +5,16 @@ package org.thoughtcrime.securesms.map;
|
||||
*/
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.b44t.messenger.DcContext;
|
||||
import com.b44t.messenger.DcMsg;
|
||||
import com.mapbox.geojson.Feature;
|
||||
|
||||
@@ -22,6 +25,7 @@ import org.thoughtcrime.securesms.util.BitmapUtil;
|
||||
import org.thoughtcrime.securesms.util.DateUtils;
|
||||
import org.thoughtcrime.securesms.util.DynamicLanguage;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@@ -73,16 +77,26 @@ public class GenerateInfoWindowTask extends AsyncTask<ArrayList<Feature>, 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<ArrayList<Feature>, 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()));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user