mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
@@ -31,19 +31,6 @@
|
||||
android:clipToPadding="false"
|
||||
android:orientation="vertical">
|
||||
|
||||
<org.thoughtcrime.securesms.components.QuoteView
|
||||
android:id="@+id/quote_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="6dp"
|
||||
android:layout_marginRight="6dp"
|
||||
android:layout_marginTop="6dp"
|
||||
android:visibility="gone"
|
||||
app:message_type="preview"
|
||||
app:quote_colorPrimary="?attr/conversation_item_outgoing_text_primary_color"
|
||||
app:quote_colorSecondary="?attr/conversation_item_outgoing_text_primary_color"
|
||||
tools:visibility="visible"/>
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
@@ -28,10 +28,12 @@
|
||||
android:textColor="?conversation_item_outgoing_text_secondary_color"
|
||||
tools:text="30 mins"/>
|
||||
|
||||
<org.thoughtcrime.securesms.components.DeliveryStatusView
|
||||
android:id="@+id/footer_delivery_status"
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"/>
|
||||
<ImageView android:id="@+id/delivery_indicator"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical|end"
|
||||
android:layout_marginLeft="6dp"
|
||||
android:tint="?attr/conversation_item_outgoing_text_secondary_color"
|
||||
android:visibility="gone" />
|
||||
|
||||
</merge>
|
||||
|
||||
@@ -87,19 +87,6 @@
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<org.thoughtcrime.securesms.components.QuoteView
|
||||
android:id="@+id/quote_view"
|
||||
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="incoming"
|
||||
app:quote_colorPrimary="?attr/conversation_item_quote_text_color"
|
||||
app:quote_colorSecondary="?attr/conversation_item_quote_text_color"
|
||||
tools:visibility="visible"/>
|
||||
|
||||
<ViewStub
|
||||
android:id="@+id/image_view_stub"
|
||||
android:layout_width="wrap_content"
|
||||
|
||||
@@ -65,19 +65,6 @@
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<org.thoughtcrime.securesms.components.QuoteView
|
||||
android:id="@+id/quote_view"
|
||||
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"/>
|
||||
|
||||
<ViewStub
|
||||
android:id="@+id/image_view_stub"
|
||||
android:layout_width="wrap_content"
|
||||
|
||||
@@ -101,7 +101,7 @@
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:minHeight="20dp"
|
||||
android:minHeight="21dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
@@ -117,12 +117,13 @@
|
||||
android:textColor="?attr/conversation_list_item_date_color"
|
||||
android:background="@drawable/archived_indicator_background" />
|
||||
|
||||
<org.thoughtcrime.securesms.components.DeliveryStatusView
|
||||
android:id="@+id/delivery_status"
|
||||
android:layout_marginTop="6dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:iconColor="?attr/conversation_list_item_delivery_icon_color"/>
|
||||
<ImageView android:id="@+id/delivery_indicator"
|
||||
android:layout_marginTop="4dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical|end"
|
||||
android:tint="?attr/conversation_item_outgoing_text_secondary_color"
|
||||
android:visibility="gone" />
|
||||
|
||||
<ImageView android:id="@+id/unread_indicator"
|
||||
android:layout_width="24dp"
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<merge xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/pending_indicator"
|
||||
android:layout_width="12dp"
|
||||
android:layout_height="12dp"
|
||||
android:layout_marginRight="2dp"
|
||||
android:layout_gravity="center_vertical|end"
|
||||
android:src="@drawable/ic_delivery_status_sending"
|
||||
android:visibility="gone" />
|
||||
|
||||
<ImageView android:id="@+id/sent_indicator"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical|end"
|
||||
android:src="@drawable/ic_delivery_status_sent"
|
||||
android:paddingLeft="2dp"
|
||||
android:visibility="gone"
|
||||
android:contentDescription="@string/message_delivered" />
|
||||
|
||||
<ImageView android:id="@+id/read_indicator"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical|end"
|
||||
android:src="@drawable/ic_delivery_status_read"
|
||||
android:paddingLeft="2dp"
|
||||
android:visibility="gone"
|
||||
android:contentDescription="@string/message_read"
|
||||
android:tint="@color/core_blue"
|
||||
tools:visibility="visible"/>
|
||||
|
||||
<ImageView android:id="@+id/failed_indicator"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical|end"
|
||||
android:src="@drawable/ic_delivery_status_failed"
|
||||
android:paddingLeft="2dp"
|
||||
android:visibility="gone"
|
||||
android:contentDescription="@string/error"
|
||||
android:tint="@color/core_blue"
|
||||
tools:visibility="visible"/>
|
||||
|
||||
</merge>
|
||||
@@ -1,155 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<merge
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"
|
||||
android:layout_margin="3dp"
|
||||
tools:visibility="visible">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/quote_root"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/quote_bar"
|
||||
android:layout_width="@dimen/quote_corner_radius_bottom"
|
||||
android:layout_height="match_parent"
|
||||
android:src="@color/white"
|
||||
tools:tint="@color/purple_400" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:orientation="vertical"
|
||||
android:layout_weight="1">
|
||||
|
||||
<org.thoughtcrime.securesms.components.emoji.EmojiTextView
|
||||
android:id="@+id/quote_author"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/Signal.Text.Caption"
|
||||
android:textColor="@color/core_black"
|
||||
android:textStyle="bold"
|
||||
android:maxLines="1"
|
||||
android:ellipsize="end"
|
||||
tools:text="Peter Parker" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/quote_attachment_container"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="2dp"
|
||||
android:orientation="horizontal"
|
||||
android:gravity="center_vertical"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="27dp"
|
||||
android:layout_height="35dp"
|
||||
android:layout_marginRight="4dp"
|
||||
android:layout_marginEnd="4dp"
|
||||
android:paddingLeft="-4dp"
|
||||
android:paddingStart="-4dp"
|
||||
android:src="?attr/attachment_document_icon_small" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/quote_attachment_name"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/Signal.Text.Body"
|
||||
android:textColor="@color/core_light_90"
|
||||
android:maxLines="1"
|
||||
android:ellipsize="end"
|
||||
tools:text="The-Amazing-Spider-Man.cba" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/media_type"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginRight="8dp"
|
||||
style="@style/Signal.Text.Caption"
|
||||
android:textColor="@color/core_light_90"
|
||||
android:paddingTop="4dp"
|
||||
android:textStyle="italic"
|
||||
android:visibility="gone"
|
||||
tools:text="Photo"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<org.thoughtcrime.securesms.components.emoji.EmojiTextView
|
||||
android:id="@+id/quote_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/Signal.Text.Body"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="2"
|
||||
tools:text="With great power comes great responsibility."
|
||||
tools:visibility="visible" />
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/quote_thumbnail"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="match_parent"
|
||||
android:scaleType="centerCrop"
|
||||
android:visibility="gone"
|
||||
tools:visibility="gone" />
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/quote_video_overlay"
|
||||
android:layout_width="32dp"
|
||||
android:layout_height="32dp"
|
||||
android:background="@drawable/circle_white"
|
||||
android:layout_gravity="center"
|
||||
android:longClickable="false"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="13dp"
|
||||
android:layout_height="16dp"
|
||||
android:layout_marginLeft="11dp"
|
||||
android:layout_marginStart="11dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:tint="@color/core_blue"
|
||||
android:scaleType="fitXY"
|
||||
app:srcCompat="@drawable/triangle_right" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/quote_dismiss"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="4dp"
|
||||
android:layout_marginRight="4dp"
|
||||
android:layout_marginTop="4dp"
|
||||
android:layout_gravity="top|end"
|
||||
android:background="@drawable/dismiss_background"
|
||||
android:src="@drawable/ic_close_white_18dp"
|
||||
android:tint="@color/gray70" />
|
||||
|
||||
</merge>
|
||||
@@ -170,10 +170,6 @@
|
||||
<attr name="thumbnail_radius" format="dimension" />
|
||||
</declare-styleable>
|
||||
|
||||
<declare-styleable name="DeliveryStatusView">
|
||||
<attr name="iconColor" format="color" />
|
||||
</declare-styleable>
|
||||
|
||||
<declare-styleable name="AudioView">
|
||||
<attr name="widgetBackground" format="color"/>
|
||||
<attr name="foregroundTintColor" format="color" />
|
||||
@@ -212,16 +208,6 @@
|
||||
<attr name="summaryHasRingtone" format="string|reference" />
|
||||
</declare-styleable>
|
||||
|
||||
<declare-styleable name="QuoteView">
|
||||
<attr name="message_type" format="enum">
|
||||
<enum name="preview" value="0" />
|
||||
<enum name="outgoing" value="1" />
|
||||
<enum name="incoming" value="2" />
|
||||
</attr>
|
||||
<attr name="quote_colorPrimary" format="color" />
|
||||
<attr name="quote_colorSecondary" format="color" />
|
||||
</declare-styleable>
|
||||
|
||||
<declare-styleable name="DocumentView">
|
||||
<attr name="doc_titleColor" format="color" />
|
||||
<attr name="doc_captionColor" format="color" />
|
||||
|
||||
@@ -1,19 +1,3 @@
|
||||
/*
|
||||
* Copyright (C) 2013 Open Whisper Systems
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.thoughtcrime.securesms;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
@@ -40,18 +24,8 @@ import org.thoughtcrime.securesms.util.Util;
|
||||
import org.thoughtcrime.securesms.util.SignalProtocolLoggerProvider;
|
||||
import org.thoughtcrime.securesms.util.AndroidSignalProtocolLogger;
|
||||
|
||||
/**
|
||||
* Will be called once when the TextSecure process is created.
|
||||
*
|
||||
* We're using this as an insertion point to patch up the Android PRNG disaster,
|
||||
* to initialize the job manager, and to check for GCM registration freshness.
|
||||
*
|
||||
* @author Moxie Marlinspike
|
||||
*/
|
||||
public class ApplicationContext extends Application implements DefaultLifecycleObserver {
|
||||
|
||||
private static final String TAG = ApplicationContext.class.getName();
|
||||
|
||||
public ApplicationDcContext dcContext;
|
||||
public DcLocationManager dcLocationManager;
|
||||
private JobManager jobManager;
|
||||
|
||||
@@ -903,7 +903,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
|
||||
protected ListenableFuture<Integer> processComposeControls(int action) {
|
||||
return processComposeControls(action, composeText.getTextTrimmed(),
|
||||
attachmentManager.isAttachmentPresent() || inputPanel.getQuote().isPresent()?
|
||||
attachmentManager.isAttachmentPresent()?
|
||||
attachmentManager.buildSlideDeck() : null);
|
||||
}
|
||||
|
||||
@@ -917,7 +917,6 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
composeText.setText("");
|
||||
|
||||
if(slideDeck!=null) {
|
||||
inputPanel.clearQuote();
|
||||
attachmentManager.clear(glideRequests, false);
|
||||
|
||||
try {
|
||||
@@ -1290,36 +1289,6 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
|
||||
@Override
|
||||
public void handleReplyMessage(DcMsg messageRecord) {
|
||||
// Recipient author;
|
||||
//
|
||||
// if (messageRecord.isOutgoing()) {
|
||||
// author = Recipient.from(this, Address.fromSerialized(Prefs.getLocalNumber(this)), true);
|
||||
// } else {
|
||||
// author = messageRecord.getIndividualRecipient();
|
||||
// }
|
||||
//
|
||||
// if (messageRecord.isMms() && !((MmsMessageRecord) messageRecord).getSharedContacts().isEmpty()) {
|
||||
// Contact contact = ((MmsMessageRecord) messageRecord).getSharedContacts().get(0);
|
||||
// String displayName = ContactUtil.getDisplayName(contact);
|
||||
// String body = getString(R.string.ConversationActivity_quoted_contact_message, EmojiStrings.BUST_IN_SILHOUETTE, displayName);
|
||||
// SlideDeck slideDeck = new SlideDeck();
|
||||
//
|
||||
// if (contact.getAvatarAttachment() != null) {
|
||||
// slideDeck.addSlide(MediaUtil.getSlideForAttachment(this, contact.getAvatarAttachment()));
|
||||
// }
|
||||
//
|
||||
// inputPanel.setQuote(GlideApp.with(this),
|
||||
// messageRecord.getDateSent(),
|
||||
// author,
|
||||
// body,
|
||||
// slideDeck);
|
||||
// } else {
|
||||
// inputPanel.setQuote(GlideApp.with(this),
|
||||
// messageRecord.getDateSent(),
|
||||
// author,
|
||||
// messageRecord.getBody(),
|
||||
// messageRecord.isMms() ? ((MmsMessageRecord) messageRecord).getSlideDeck() : new SlideDeck());
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -256,7 +256,7 @@ public class ConversationFragment extends Fragment
|
||||
|
||||
private void initializeListAdapter() {
|
||||
if (this.recipient != null && this.threadId != -1) {
|
||||
ConversationAdapter adapter = new ConversationAdapter(getActivity(), dcContext.getChat((int)this.threadId), GlideApp.with(this), locale, selectionClickListener, this.recipient);
|
||||
ConversationAdapter adapter = new ConversationAdapter(getActivity(), this.recipient.getChat(), GlideApp.with(this), locale, selectionClickListener, this.recipient);
|
||||
list.setAdapter(adapter);
|
||||
list.addItemDecoration(new StickyHeaderDecoration(adapter, false, false));
|
||||
|
||||
|
||||
@@ -47,7 +47,6 @@ import org.thoughtcrime.securesms.components.AvatarImageView;
|
||||
import org.thoughtcrime.securesms.components.ConversationItemFooter;
|
||||
import org.thoughtcrime.securesms.components.ConversationItemThumbnail;
|
||||
import org.thoughtcrime.securesms.components.DocumentView;
|
||||
import org.thoughtcrime.securesms.components.QuoteView;
|
||||
import org.thoughtcrime.securesms.connect.ApplicationDcContext;
|
||||
import org.thoughtcrime.securesms.connect.DcHelper;
|
||||
import org.thoughtcrime.securesms.mms.AudioSlide;
|
||||
@@ -91,7 +90,6 @@ public class ConversationItem extends LinearLayout
|
||||
private GlideRequests glideRequests;
|
||||
|
||||
protected ViewGroup bodyBubble;
|
||||
private QuoteView quoteView;
|
||||
private TextView bodyText;
|
||||
private ConversationItemFooter footer;
|
||||
private TextView groupSender;
|
||||
@@ -147,7 +145,6 @@ public class ConversationItem extends LinearLayout
|
||||
this.audioViewStub = new Stub<>(findViewById(R.id.audio_view_stub));
|
||||
this.documentViewStub = new Stub<>(findViewById(R.id.document_view_stub));
|
||||
this.groupSenderHolder = findViewById(R.id.group_sender_holder);
|
||||
this.quoteView = findViewById(R.id.quote_view);
|
||||
this.container = findViewById(R.id.container);
|
||||
|
||||
setOnClickListener(new ClickListener(null));
|
||||
@@ -188,7 +185,6 @@ public class ConversationItem extends LinearLayout
|
||||
setContactPhoto();
|
||||
setGroupMessageStatus();
|
||||
setAuthor(messageRecord, groupThread);
|
||||
setQuote(messageRecord, groupThread);
|
||||
setMessageSpacing(context);
|
||||
setFooter(messageRecord, locale);
|
||||
}
|
||||
@@ -209,16 +205,6 @@ public class ConversationItem extends LinearLayout
|
||||
|
||||
//boolean needsMeasure = false;
|
||||
|
||||
if (hasQuote(messageRecord)) {
|
||||
int quoteWidth = quoteView.getMeasuredWidth();
|
||||
int availableWidth = getAvailableMessageBubbleWidth(quoteView);
|
||||
|
||||
if (quoteWidth != availableWidth) {
|
||||
quoteView.getLayoutParams().width = availableWidth;
|
||||
//needsMeasure = true;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
ConversationItemFooter activeFooter = getActiveFooter(messageRecord);
|
||||
int availableWidth = getAvailableMessageBubbleWidth(footer);
|
||||
@@ -348,10 +334,6 @@ public class ConversationItem extends LinearLayout
|
||||
return dcMsg.getType()==DcMsg.DC_MSG_FILE && !dcMsg.isSetupMessage();
|
||||
}
|
||||
|
||||
private boolean hasQuote(DcMsg messageRecord) {
|
||||
return false;
|
||||
}
|
||||
|
||||
private void setBodyText(DcMsg messageRecord) {
|
||||
bodyText.setClickable(false);
|
||||
bodyText.setFocusable(false);
|
||||
@@ -377,7 +359,7 @@ public class ConversationItem extends LinearLayout
|
||||
@NonNull Recipient conversationRecipient,
|
||||
boolean isGroupThread)
|
||||
{
|
||||
boolean showControls = !messageRecord.isFailed() && !Util.isOwnNumber(context, conversationRecipient.getAddress());
|
||||
boolean showControls = !messageRecord.isFailed();
|
||||
|
||||
class SetDurationListener implements AudioSlidePlayer.Listener {
|
||||
@Override
|
||||
@@ -497,8 +479,7 @@ public class ConversationItem extends LinearLayout
|
||||
}
|
||||
|
||||
if ((!current.isOutgoing() && isGroupThread)
|
||||
|| current.isForwarded()
|
||||
|| hasQuote(messageRecord)){
|
||||
|| current.isForwarded()){
|
||||
topLeft = 0;
|
||||
topRight = 0;
|
||||
}
|
||||
@@ -541,52 +522,6 @@ public class ConversationItem extends LinearLayout
|
||||
return messageBody;
|
||||
}
|
||||
|
||||
private void setQuote(@NonNull DcMsg current, boolean isGroupThread) {
|
||||
// if (current.isMms() && !current.isMmsNotification() && ((MediaMmsDcMsg)current).getQuote() != null) {
|
||||
// Quote quote = ((MediaMmsDcMsg)current).getQuote();
|
||||
// assert quote != null;
|
||||
// quoteView.setQuote(glideRequests, quote.getId(), Recipient.from(context, quote.getAuthor(), true), quote.getText(), quote.getAttachment());
|
||||
// quoteView.setVisibility(View.VISIBLE);
|
||||
// quoteView.getLayoutParams().width = ViewGroup.LayoutParams.WRAP_CONTENT;
|
||||
//
|
||||
// quoteView.setOnClickListener(view -> {
|
||||
// if (eventListener != null && batchIsEmpty()) {
|
||||
// eventListener.onQuoteClicked((MmsDcMsg) current);
|
||||
// } else {
|
||||
// passthroughClickListener.onClick(view);
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// quoteView.setOnLongClickListener(passthroughClickListener);
|
||||
//
|
||||
// if (isStartOfMessageCluster(current, previous, isGroupThread)) {
|
||||
// if (current.isOutgoing()) {
|
||||
// quoteView.setTopCornerSizes(true, true);
|
||||
// } else if (isGroupThread) {
|
||||
// quoteView.setTopCornerSizes(false, false);
|
||||
// } else {
|
||||
// quoteView.setTopCornerSizes(true, true);
|
||||
// }
|
||||
// } else if (!isSingularMessage(current, previous, next, isGroupThread)) {
|
||||
// if (current.isOutgoing()) {
|
||||
// quoteView.setTopCornerSizes(true, false);
|
||||
// } else {
|
||||
// quoteView.setTopCornerSizes(false, true);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (mediaThumbnailStub.resolved()) {
|
||||
// ViewUtil.setTopMargin(mediaThumbnailStub.get(), readDimen(R.dimen.message_bubble_top_padding));
|
||||
// }
|
||||
// } else {
|
||||
// quoteView.dismiss();
|
||||
//
|
||||
// if (mediaThumbnailStub.resolved()) {
|
||||
// ViewUtil.setTopMargin(mediaThumbnailStub.get(), 0);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
private void setGutterSizes(@NonNull DcMsg current, boolean isGroupThread) {
|
||||
if (isGroupThread && current.isOutgoing()) {
|
||||
ViewUtil.setLeftMargin(container, readDimen(R.dimen.conversation_group_left_gutter));
|
||||
|
||||
@@ -99,7 +99,7 @@ public class ConversationListItem extends RelativeLayout
|
||||
this.subjectView = findViewById(R.id.subject);
|
||||
this.fromView = findViewById(R.id.from_text);
|
||||
this.dateView = findViewById(R.id.date);
|
||||
this.deliveryStatusIndicator = findViewById(R.id.delivery_status);
|
||||
this.deliveryStatusIndicator = new DeliveryStatusView(findViewById(R.id.delivery_indicator));
|
||||
this.contactPhotoImage = findViewById(R.id.contact_photo_image);
|
||||
this.archivedView = findViewById(R.id.archived);
|
||||
this.unreadIndicator = findViewById(R.id.unread_indicator);
|
||||
@@ -177,7 +177,7 @@ public class ConversationListItem extends RelativeLayout
|
||||
thread.isVerified()? R.drawable.ic_verified : 0,
|
||||
0);
|
||||
|
||||
boolean isGroup = dcContext.getChat((int) threadId).isGroup();
|
||||
boolean isGroup = recipient.isGroupRecipient();
|
||||
groupIndicator.setVisibility(isGroup ? VISIBLE : GONE);
|
||||
int color = ResUtil.getColor(getContext(), R.attr.conversation_list_item_contact_color);
|
||||
groupIndicator.setColorFilter(color);
|
||||
|
||||
@@ -501,7 +501,7 @@ public class GroupCreateActivity extends PassphraseRequiredActionBarActivity
|
||||
}
|
||||
|
||||
private void fillExistingGroup(Recipient recipient) {
|
||||
List<Recipient> participants = recipient.getParticipants();
|
||||
List<Recipient> participants = recipient.loadParticipants(this);
|
||||
Recipient[] participantsArray = new Recipient[participants.size()];
|
||||
participantsArray = participants.toArray(participantsArray);
|
||||
if (!isFinishing()) {
|
||||
|
||||
@@ -544,8 +544,8 @@ public class RecipientPreferenceActivity extends PassphraseRequiredActionBarActi
|
||||
.setCancelable(true)
|
||||
.setNegativeButton(android.R.string.cancel, null)
|
||||
.setPositiveButton(R.string.menu_block_contact, (dialog, which) -> {
|
||||
contactToEditRecipient.setBlocked(true);
|
||||
setBlocked(true);
|
||||
contactToEditRecipient.reload(getActivity());
|
||||
}).show();
|
||||
}
|
||||
|
||||
@@ -555,8 +555,8 @@ public class RecipientPreferenceActivity extends PassphraseRequiredActionBarActi
|
||||
.setCancelable(true)
|
||||
.setNegativeButton(android.R.string.cancel, null)
|
||||
.setPositiveButton(R.string.menu_unblock_contact, (dialog, which) -> {
|
||||
contactToEditRecipient.setBlocked(false);
|
||||
setBlocked(false);
|
||||
contactToEditRecipient.reload(getActivity());
|
||||
}).show();
|
||||
}
|
||||
|
||||
|
||||
@@ -24,12 +24,10 @@ public abstract class Attachment {
|
||||
private final int width;
|
||||
private final int height;
|
||||
|
||||
private final boolean quote;
|
||||
|
||||
public Attachment(@NonNull String contentType, int transferState, long size, @Nullable String fileName,
|
||||
@Nullable String location, @Nullable String key, @Nullable String relay,
|
||||
@Nullable byte[] digest, @Nullable String fastPreflightId, boolean voiceNote,
|
||||
int width, int height, boolean quote)
|
||||
int width, int height)
|
||||
{
|
||||
this.contentType = contentType;
|
||||
this.transferState = transferState;
|
||||
@@ -40,7 +38,6 @@ public abstract class Attachment {
|
||||
this.voiceNote = voiceNote;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
this.quote = quote;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -92,8 +89,4 @@ public abstract class Attachment {
|
||||
public int getHeight() {
|
||||
return height;
|
||||
}
|
||||
|
||||
public boolean isQuote() {
|
||||
return quote;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,9 +16,9 @@ public class DatabaseAttachment extends Attachment {
|
||||
String contentType, int transferProgress, long size,
|
||||
String fileName, String location, String key, String relay,
|
||||
byte[] digest, String fastPreflightId, boolean voiceNote,
|
||||
int width, int height, boolean quote)
|
||||
int width, int height)
|
||||
{
|
||||
super(contentType, transferProgress, size, fileName, location, key, relay, digest, fastPreflightId, voiceNote, width, height, quote);
|
||||
super(contentType, transferProgress, size, fileName, location, key, relay, digest, fastPreflightId, voiceNote, width, height);
|
||||
this.attachmentId = attachmentId;
|
||||
this.hasData = hasData;
|
||||
this.hasThumbnail = hasThumbnail;
|
||||
|
||||
@@ -13,12 +13,11 @@ public class DcAttachment extends Attachment {
|
||||
private final DcMsg dcMsg;
|
||||
|
||||
public DcAttachment(DcMsg dcMsg) {
|
||||
// todo: width, height, quote
|
||||
super(dcMsg.getFilemime(), AttachmentDatabase.TRANSFER_PROGRESS_DONE, dcMsg.getFilebytes(),
|
||||
dcMsg.getFilename(),
|
||||
Uri.fromFile(new File(dcMsg.getFile())).toString(), String.valueOf(dcMsg.getId()), null, null,
|
||||
null, dcMsg.getType() == DcMsg.DC_MSG_VOICE,
|
||||
0, 0, false);
|
||||
0, 0);
|
||||
this.dcMsg = dcMsg;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,17 +10,17 @@ public class UriAttachment extends Attachment {
|
||||
private final @Nullable Uri thumbnailUri;
|
||||
|
||||
public UriAttachment(@NonNull Uri uri, @NonNull String contentType, int transferState, long size,
|
||||
@Nullable String fileName, boolean voiceNote, boolean quote)
|
||||
@Nullable String fileName, boolean voiceNote)
|
||||
{
|
||||
this(uri, uri, contentType, transferState, size, 0, 0, fileName, null, voiceNote, quote);
|
||||
this(uri, uri, contentType, transferState, size, 0, 0, fileName, null, voiceNote);
|
||||
}
|
||||
|
||||
public UriAttachment(@NonNull Uri dataUri, @Nullable Uri thumbnailUri,
|
||||
@NonNull String contentType, int transferState, long size, int width, int height,
|
||||
@Nullable String fileName, @Nullable String fastPreflightId,
|
||||
boolean voiceNote, boolean quote)
|
||||
boolean voiceNote)
|
||||
{
|
||||
super(contentType, transferState, size, fileName, null, null, null, null, fastPreflightId, voiceNote, width, height, quote);
|
||||
super(contentType, transferState, size, fileName, null, null, null, null, fastPreflightId, voiceNote, width, height);
|
||||
this.dataUri = dataUri;
|
||||
this.thumbnailUri = thumbnailUri;
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ public class ConversationItemFooter extends LinearLayout {
|
||||
|
||||
dateView = findViewById(R.id.footer_date);
|
||||
secureIndicatorView = findViewById(R.id.footer_secure_indicator);
|
||||
deliveryStatusView = findViewById(R.id.footer_delivery_status);
|
||||
deliveryStatusView = new DeliveryStatusView(findViewById(R.id.delivery_indicator));
|
||||
|
||||
if (attrs != null) {
|
||||
TypedArray typedArray = getContext().getTheme().obtainStyledAttributes(attrs, R.styleable.ConversationItemFooter, 0, 0);
|
||||
|
||||
@@ -1,107 +1,76 @@
|
||||
package org.thoughtcrime.securesms.components;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Color;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.LinearInterpolator;
|
||||
import android.view.animation.RotateAnimation;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.util.ResUtil;
|
||||
|
||||
public class DeliveryStatusView extends FrameLayout {
|
||||
public class DeliveryStatusView {
|
||||
|
||||
private static final String TAG = DeliveryStatusView.class.getSimpleName();
|
||||
private final ImageView deliveryIndicator;
|
||||
private static RotateAnimation animation;
|
||||
private boolean animated;
|
||||
|
||||
private static final RotateAnimation ROTATION_ANIMATION = new RotateAnimation(0, 360f,
|
||||
Animation.RELATIVE_TO_SELF, 0.5f,
|
||||
Animation.RELATIVE_TO_SELF, 0.5f);
|
||||
static {
|
||||
ROTATION_ANIMATION.setInterpolator(new LinearInterpolator());
|
||||
ROTATION_ANIMATION.setDuration(1500);
|
||||
ROTATION_ANIMATION.setRepeatCount(Animation.INFINITE);
|
||||
public DeliveryStatusView(ImageView deliveryIndicator) {
|
||||
this.deliveryIndicator = deliveryIndicator;
|
||||
}
|
||||
|
||||
private final ImageView pendingIndicator;
|
||||
private final ImageView sentIndicator;
|
||||
private final ImageView readIndicator;
|
||||
private final ImageView failedIndicator;
|
||||
private void animate()
|
||||
{
|
||||
if(animation==null) {
|
||||
animation = new RotateAnimation(0, 360f,
|
||||
Animation.RELATIVE_TO_SELF, 0.5f,
|
||||
Animation.RELATIVE_TO_SELF, 0.5f);
|
||||
animation.setInterpolator(new LinearInterpolator());
|
||||
animation.setDuration(1500);
|
||||
animation.setRepeatCount(Animation.INFINITE);
|
||||
}
|
||||
|
||||
public DeliveryStatusView(Context context) {
|
||||
this(context, null);
|
||||
deliveryIndicator.startAnimation(animation);
|
||||
animated = true;
|
||||
}
|
||||
|
||||
public DeliveryStatusView(Context context, AttributeSet attrs) {
|
||||
this(context, attrs, 0);
|
||||
}
|
||||
|
||||
public DeliveryStatusView(final Context context, AttributeSet attrs, int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
|
||||
inflate(context, R.layout.delivery_status_view, this);
|
||||
|
||||
this.sentIndicator = findViewById(R.id.sent_indicator);
|
||||
this.pendingIndicator = findViewById(R.id.pending_indicator);
|
||||
this.readIndicator = findViewById(R.id.read_indicator);
|
||||
this.failedIndicator = findViewById(R.id.failed_indicator);
|
||||
|
||||
if (attrs != null) {
|
||||
TypedArray typedArray = context.getTheme().obtainStyledAttributes(attrs, R.styleable.DeliveryStatusView, 0, 0);
|
||||
int color = ResUtil.getColor(getContext(), R.attr.conversation_item_outgoing_text_secondary_color);
|
||||
setTint(color);
|
||||
typedArray.recycle();
|
||||
private void clearAnimation()
|
||||
{
|
||||
if(animated) {
|
||||
deliveryIndicator.clearAnimation();
|
||||
animated = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void setNone() {
|
||||
this.setVisibility(View.GONE);
|
||||
deliveryIndicator.setVisibility(View.GONE);
|
||||
deliveryIndicator.clearAnimation();
|
||||
}
|
||||
|
||||
public void setPending() {
|
||||
this.setVisibility(View.VISIBLE);
|
||||
pendingIndicator.setVisibility(View.VISIBLE);
|
||||
pendingIndicator.startAnimation(ROTATION_ANIMATION);
|
||||
sentIndicator.setVisibility(View.GONE);
|
||||
readIndicator.setVisibility(View.GONE);
|
||||
failedIndicator.setVisibility(View.GONE);
|
||||
deliveryIndicator.setVisibility(View.VISIBLE);
|
||||
deliveryIndicator.setImageResource(R.drawable.ic_delivery_status_sending);
|
||||
animate();
|
||||
}
|
||||
|
||||
public void setSent() {
|
||||
this.setVisibility(View.VISIBLE);
|
||||
pendingIndicator.setVisibility(View.GONE);
|
||||
pendingIndicator.clearAnimation();
|
||||
sentIndicator.setVisibility(View.VISIBLE);
|
||||
readIndicator.setVisibility(View.GONE);
|
||||
failedIndicator.setVisibility(View.GONE);
|
||||
deliveryIndicator.setVisibility(View.VISIBLE);
|
||||
deliveryIndicator.setImageResource(R.drawable.ic_delivery_status_sent);
|
||||
clearAnimation();
|
||||
}
|
||||
|
||||
public void setRead() {
|
||||
this.setVisibility(View.VISIBLE);
|
||||
pendingIndicator.setVisibility(View.GONE);
|
||||
pendingIndicator.clearAnimation();
|
||||
sentIndicator.setVisibility(View.GONE);
|
||||
readIndicator.setVisibility(View.VISIBLE);
|
||||
failedIndicator.setVisibility(View.GONE);
|
||||
deliveryIndicator.setVisibility(View.VISIBLE);
|
||||
deliveryIndicator.setImageResource(R.drawable.ic_delivery_status_read);
|
||||
clearAnimation();
|
||||
}
|
||||
|
||||
public void setFailed() {
|
||||
this.setVisibility(View.VISIBLE);
|
||||
pendingIndicator.setVisibility(View.GONE);
|
||||
pendingIndicator.clearAnimation();
|
||||
sentIndicator.setVisibility(View.GONE);
|
||||
readIndicator.setVisibility(View.GONE);
|
||||
failedIndicator.setVisibility(View.VISIBLE);
|
||||
deliveryIndicator.setVisibility(View.VISIBLE);
|
||||
deliveryIndicator.setImageResource(R.drawable.ic_delivery_status_failed);
|
||||
clearAnimation();
|
||||
}
|
||||
|
||||
public void setTint(int color) {
|
||||
pendingIndicator.setColorFilter(color);
|
||||
sentIndicator.setColorFilter(color);
|
||||
readIndicator.setColorFilter(color);
|
||||
failedIndicator.setColorFilter(color);
|
||||
deliveryIndicator.setColorFilter(color);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,17 +23,12 @@ import android.widget.Toast;
|
||||
import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.components.emoji.EmojiDrawer;
|
||||
import org.thoughtcrime.securesms.components.emoji.EmojiToggle;
|
||||
import org.thoughtcrime.securesms.mms.GlideRequests;
|
||||
import org.thoughtcrime.securesms.mms.QuoteModel;
|
||||
import org.thoughtcrime.securesms.mms.SlideDeck;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.util.Prefs;
|
||||
import org.thoughtcrime.securesms.util.Util;
|
||||
import org.thoughtcrime.securesms.util.ViewUtil;
|
||||
import org.thoughtcrime.securesms.util.concurrent.AssertedSuccessListener;
|
||||
import org.thoughtcrime.securesms.util.concurrent.ListenableFuture;
|
||||
import org.thoughtcrime.securesms.util.concurrent.SettableFuture;
|
||||
import org.thoughtcrime.securesms.util.guava.Optional;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
@@ -48,7 +43,6 @@ public class InputPanel extends LinearLayout
|
||||
|
||||
private static final int FADE_TIME = 150;
|
||||
|
||||
private QuoteView quoteView;
|
||||
private EmojiToggle emojiToggle;
|
||||
private ComposeText composeText;
|
||||
private View quickCameraToggle;
|
||||
@@ -80,9 +74,6 @@ public class InputPanel extends LinearLayout
|
||||
public void onFinishInflate() {
|
||||
super.onFinishInflate();
|
||||
|
||||
View quoteDismiss = findViewById(R.id.quote_dismiss);
|
||||
|
||||
this.quoteView = findViewById(R.id.quote_view);
|
||||
this.emojiToggle = findViewById(R.id.emoji_toggle);
|
||||
this.composeText = findViewById(R.id.embedded_text_editor);
|
||||
this.quickCameraToggle = findViewById(R.id.quick_camera_toggle);
|
||||
@@ -106,8 +97,6 @@ public class InputPanel extends LinearLayout
|
||||
emojiToggle.setVisibility(View.VISIBLE);
|
||||
emojiVisible = true;
|
||||
}
|
||||
|
||||
quoteDismiss.setOnClickListener(v -> clearQuote());
|
||||
}
|
||||
|
||||
public void setListener(final @NonNull Listener listener) {
|
||||
@@ -120,23 +109,6 @@ public class InputPanel extends LinearLayout
|
||||
composeText.setMediaListener(listener);
|
||||
}
|
||||
|
||||
public void setQuote(@NonNull GlideRequests glideRequests, long id, @NonNull Recipient author, @NonNull String body, @NonNull SlideDeck attachments) {
|
||||
this.quoteView.setQuote(glideRequests, id, author, body, attachments);
|
||||
this.quoteView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
public void clearQuote() {
|
||||
this.quoteView.dismiss();
|
||||
}
|
||||
|
||||
public Optional<QuoteModel> getQuote() {
|
||||
if (quoteView.getQuoteId() > 0 && quoteView.getVisibility() == View.VISIBLE) {
|
||||
return Optional.of(new QuoteModel(quoteView.getQuoteId(), quoteView.getAuthor().getAddress(), quoteView.getBody(), quoteView.getAttachments()));
|
||||
} else {
|
||||
return Optional.absent();
|
||||
}
|
||||
}
|
||||
|
||||
public void setEmojiDrawer(@NonNull EmojiDrawer emojiDrawer) {
|
||||
emojiToggle.attach(emojiDrawer);
|
||||
}
|
||||
|
||||
@@ -1,275 +0,0 @@
|
||||
package org.thoughtcrime.securesms.components;
|
||||
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.os.Build;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.annotation.RequiresApi;
|
||||
import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.annimon.stream.Stream;
|
||||
import com.bumptech.glide.load.engine.DiskCacheStrategy;
|
||||
|
||||
import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.attachments.Attachment;
|
||||
import org.thoughtcrime.securesms.mms.DecryptableStreamUriLoader.DecryptableUri;
|
||||
import org.thoughtcrime.securesms.mms.GlideRequests;
|
||||
import org.thoughtcrime.securesms.mms.Slide;
|
||||
import org.thoughtcrime.securesms.mms.SlideDeck;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.recipients.RecipientModifiedListener;
|
||||
import org.thoughtcrime.securesms.util.ThemeUtil;
|
||||
import org.thoughtcrime.securesms.util.Util;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class QuoteView extends FrameLayout implements RecipientModifiedListener {
|
||||
|
||||
private static final String TAG = QuoteView.class.getSimpleName();
|
||||
|
||||
private static final int MESSAGE_TYPE_PREVIEW = 0;
|
||||
private static final int MESSAGE_TYPE_OUTGOING = 1;
|
||||
private static final int MESSAGE_TYPE_INCOMING = 2;
|
||||
|
||||
private ViewGroup rootView;
|
||||
private TextView authorView;
|
||||
private TextView bodyView;
|
||||
private ImageView quoteBarView;
|
||||
private ImageView thumbnailView;
|
||||
private View attachmentVideoOverlayView;
|
||||
private ViewGroup attachmentContainerView;
|
||||
private TextView attachmentNameView;
|
||||
private ImageView dismissView;
|
||||
|
||||
private long id;
|
||||
private Recipient author;
|
||||
private String body;
|
||||
private TextView mediaDescriptionText;
|
||||
private SlideDeck attachments;
|
||||
private int messageType;
|
||||
private int largeCornerRadius;
|
||||
private int smallCornerRadius;
|
||||
private CornerMask cornerMask;
|
||||
|
||||
|
||||
public QuoteView(Context context) {
|
||||
super(context);
|
||||
initialize(null);
|
||||
}
|
||||
|
||||
public QuoteView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
initialize(attrs);
|
||||
}
|
||||
|
||||
public QuoteView(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
initialize(attrs);
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
public QuoteView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||
super(context, attrs, defStyleAttr, defStyleRes);
|
||||
initialize(attrs);
|
||||
}
|
||||
|
||||
private void initialize(@Nullable AttributeSet attrs) {
|
||||
inflate(getContext(), R.layout.quote_view, this);
|
||||
|
||||
this.rootView = findViewById(R.id.quote_root);
|
||||
this.authorView = findViewById(R.id.quote_author);
|
||||
this.bodyView = findViewById(R.id.quote_text);
|
||||
this.quoteBarView = findViewById(R.id.quote_bar);
|
||||
this.thumbnailView = findViewById(R.id.quote_thumbnail);
|
||||
this.attachmentVideoOverlayView = findViewById(R.id.quote_video_overlay);
|
||||
this.attachmentContainerView = findViewById(R.id.quote_attachment_container);
|
||||
this.attachmentNameView = findViewById(R.id.quote_attachment_name);
|
||||
this.dismissView = findViewById(R.id.quote_dismiss);
|
||||
this.mediaDescriptionText = findViewById(R.id.media_type);
|
||||
this.largeCornerRadius = getResources().getDimensionPixelSize(R.dimen.quote_corner_radius_large);
|
||||
this.smallCornerRadius = getResources().getDimensionPixelSize(R.dimen.quote_corner_radius_bottom);
|
||||
|
||||
cornerMask = new CornerMask(this);
|
||||
cornerMask.setRadii(largeCornerRadius, largeCornerRadius, smallCornerRadius, smallCornerRadius);
|
||||
|
||||
if (attrs != null) {
|
||||
TypedArray typedArray = getContext().getTheme().obtainStyledAttributes(attrs, R.styleable.QuoteView, 0, 0);
|
||||
int primaryColor = typedArray.getColor(R.styleable.QuoteView_quote_colorPrimary, Color.BLACK);
|
||||
int secondaryColor = typedArray.getColor(R.styleable.QuoteView_quote_colorSecondary, Color.BLACK);
|
||||
messageType = typedArray.getInt(R.styleable.QuoteView_message_type, 0);
|
||||
typedArray.recycle();
|
||||
|
||||
dismissView.setVisibility(messageType == MESSAGE_TYPE_PREVIEW ? VISIBLE : GONE);
|
||||
|
||||
authorView.setTextColor(primaryColor);
|
||||
bodyView.setTextColor(primaryColor);
|
||||
attachmentNameView.setTextColor(primaryColor);
|
||||
mediaDescriptionText.setTextColor(secondaryColor);
|
||||
|
||||
if (messageType == MESSAGE_TYPE_PREVIEW) {
|
||||
int radius = getResources().getDimensionPixelOffset(R.dimen.quote_corner_radius_preview);
|
||||
cornerMask.setTopLeftRadius(radius);
|
||||
cornerMask.setTopRightRadius(radius);
|
||||
}
|
||||
}
|
||||
|
||||
dismissView.setOnClickListener(view -> setVisibility(GONE));
|
||||
|
||||
if (cornerMask.isLegacy()) {
|
||||
setWillNotDraw(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
super.onDraw(canvas);
|
||||
if (cornerMask.isLegacy()) {
|
||||
cornerMask.mask(canvas);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dispatchDraw(Canvas canvas) {
|
||||
super.dispatchDraw(canvas);
|
||||
if (!cornerMask.isLegacy()) {
|
||||
cornerMask.mask(canvas);
|
||||
}
|
||||
}
|
||||
|
||||
public void setQuote(GlideRequests glideRequests, long id, @NonNull Recipient author, @Nullable String body, @NonNull SlideDeck attachments) {
|
||||
if (this.author != null) this.author.removeListener(this);
|
||||
|
||||
this.id = id;
|
||||
this.author = author;
|
||||
this.body = body;
|
||||
this.attachments = attachments;
|
||||
|
||||
author.addListener(this);
|
||||
setQuoteAuthor(author);
|
||||
setQuoteText(body, attachments);
|
||||
setQuoteAttachment(glideRequests, attachments);
|
||||
}
|
||||
|
||||
public void setTopCornerSizes(boolean topLeftLarge, boolean topRightLarge) {
|
||||
cornerMask.setTopLeftRadius(topLeftLarge ? largeCornerRadius : smallCornerRadius);
|
||||
cornerMask.setTopRightRadius(topRightLarge ? largeCornerRadius : smallCornerRadius);
|
||||
}
|
||||
|
||||
public void dismiss() {
|
||||
if (this.author != null) this.author.removeListener(this);
|
||||
|
||||
this.id = 0;
|
||||
this.author = null;
|
||||
this.body = null;
|
||||
|
||||
setVisibility(GONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onModified(Recipient recipient) {
|
||||
Util.runOnMain(() -> {
|
||||
if (recipient == author) {
|
||||
setQuoteAuthor(recipient);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void setQuoteAuthor(@NonNull Recipient author) {
|
||||
boolean outgoing = messageType != MESSAGE_TYPE_INCOMING;
|
||||
boolean isOwnNumber = Util.isOwnNumber(getContext(), author.getAddress());
|
||||
|
||||
authorView.setText(isOwnNumber ? getContext().getString(R.string.self)
|
||||
: author.toShortString());
|
||||
|
||||
// We use the raw color resource because Android 4.x was struggling with tints here
|
||||
//quoteBarView.setImageResource(author.getColor().toQuoteBarColorResource(getContext(), outgoing));
|
||||
//rootView.setBackgroundColor(author.getColor().toQuoteBackgroundColor(getContext(), outgoing));
|
||||
}
|
||||
|
||||
private void setQuoteText(@Nullable String body, @NonNull SlideDeck attachments) {
|
||||
if (!TextUtils.isEmpty(body) || !attachments.containsMediaSlide()) {
|
||||
bodyView.setVisibility(VISIBLE);
|
||||
bodyView.setText(body == null ? "" : body);
|
||||
mediaDescriptionText.setVisibility(GONE);
|
||||
return;
|
||||
}
|
||||
|
||||
bodyView.setVisibility(GONE);
|
||||
mediaDescriptionText.setVisibility(VISIBLE);
|
||||
|
||||
List<Slide> audioSlides = Stream.of(attachments.getSlides()).filter(Slide::hasAudio).limit(1).toList();
|
||||
List<Slide> documentSlides = Stream.of(attachments.getSlides()).filter(Slide::hasDocument).limit(1).toList();
|
||||
List<Slide> imageSlides = Stream.of(attachments.getSlides()).filter(Slide::hasImage).limit(1).toList();
|
||||
List<Slide> videoSlides = Stream.of(attachments.getSlides()).filter(Slide::hasVideo).limit(1).toList();
|
||||
|
||||
// Given that most types have images, we specifically check images last
|
||||
if (!audioSlides.isEmpty()) {
|
||||
mediaDescriptionText.setText(R.string.audio);
|
||||
} else if (!documentSlides.isEmpty()) {
|
||||
mediaDescriptionText.setVisibility(GONE);
|
||||
} else if (!videoSlides.isEmpty()) {
|
||||
mediaDescriptionText.setText(R.string.video);
|
||||
} else if (!imageSlides.isEmpty()) {
|
||||
mediaDescriptionText.setText(R.string.image);
|
||||
}
|
||||
}
|
||||
|
||||
private void setQuoteAttachment(@NonNull GlideRequests glideRequests, @NonNull SlideDeck slideDeck) {
|
||||
List<Slide> imageVideoSlides = Stream.of(slideDeck.getSlides()).filter(s -> s.hasImage() || s.hasVideo()).limit(1).toList();
|
||||
List<Slide> documentSlides = Stream.of(attachments.getSlides()).filter(Slide::hasDocument).limit(1).toList();
|
||||
|
||||
attachmentVideoOverlayView.setVisibility(GONE);
|
||||
|
||||
if (!imageVideoSlides.isEmpty() && imageVideoSlides.get(0).getThumbnailUri() != null) {
|
||||
thumbnailView.setVisibility(VISIBLE);
|
||||
attachmentContainerView.setVisibility(GONE);
|
||||
dismissView.setBackgroundResource(R.drawable.dismiss_background);
|
||||
if (imageVideoSlides.get(0).hasVideo()) {
|
||||
attachmentVideoOverlayView.setVisibility(VISIBLE);
|
||||
}
|
||||
glideRequests.load(new DecryptableUri(imageVideoSlides.get(0).getThumbnailUri()))
|
||||
.centerCrop()
|
||||
.diskCacheStrategy(DiskCacheStrategy.RESOURCE)
|
||||
.into(thumbnailView);
|
||||
} else if (!documentSlides.isEmpty()){
|
||||
thumbnailView.setVisibility(GONE);
|
||||
attachmentContainerView.setVisibility(VISIBLE);
|
||||
attachmentNameView.setText(documentSlides.get(0).getFileName().or(""));
|
||||
} else {
|
||||
thumbnailView.setVisibility(GONE);
|
||||
attachmentContainerView.setVisibility(GONE);
|
||||
dismissView.setBackgroundDrawable(null);
|
||||
}
|
||||
|
||||
if (ThemeUtil.isDarkTheme(getContext())) {
|
||||
dismissView.setBackgroundResource(R.drawable.circle_alpha);
|
||||
}
|
||||
}
|
||||
|
||||
public long getQuoteId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public Recipient getAuthor() {
|
||||
return author;
|
||||
}
|
||||
|
||||
public String getBody() {
|
||||
return body;
|
||||
}
|
||||
|
||||
public List<Attachment> getAttachments() {
|
||||
return attachments.asAttachments();
|
||||
}
|
||||
}
|
||||
@@ -232,44 +232,13 @@ public class ApplicationDcContext extends DcContext {
|
||||
|
||||
@NonNull
|
||||
public Recipient getRecipient(DcChat chat) {
|
||||
int[] contactIds = getChatContacts(chat.getId());
|
||||
List<Recipient> participants = new ArrayList<>();
|
||||
for (int contactId : contactIds) {
|
||||
participants.add(getRecipient(RECIPIENT_TYPE_CONTACT, contactId));
|
||||
}
|
||||
Recipient recipient = new Recipient(Address.fromChat(chat.getId()), chat.getName(), participants);
|
||||
if (!chat.isGroup()) {
|
||||
String identifier = Hash.sha256(chat.getName() + chat.getSubtitle());
|
||||
Uri systemContactPhoto = Prefs.getSystemContactPhoto(context, identifier);
|
||||
if (systemContactPhoto != null) {
|
||||
recipient.setSystemContactPhoto(systemContactPhoto);
|
||||
}
|
||||
}
|
||||
return recipient;
|
||||
return new Recipient(context, chat, null);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
|
||||
public Recipient getRecipient(DcContact contact) {
|
||||
Recipient recipient = new Recipient(Address.fromContact(contact.getId()), contact.getDisplayName(), null);
|
||||
String identifier = Hash.sha256(contact.getName() + contact.getAddr());
|
||||
Uri systemContactPhoto = Prefs.getSystemContactPhoto(context, identifier);
|
||||
if (systemContactPhoto != null) {
|
||||
recipient.setSystemContactPhoto(systemContactPhoto);
|
||||
}
|
||||
if (contact.getId() == DcContact.DC_CONTACT_ID_SELF) {
|
||||
recipient.setProfileAvatar("SELF");
|
||||
}
|
||||
int[] blockedContacts = getBlockedContacts();
|
||||
boolean blocked = false;
|
||||
for (int blockedContact : blockedContacts) {
|
||||
if (contact.getId() == blockedContact) {
|
||||
blocked = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
recipient.setBlocked(blocked);
|
||||
return recipient;
|
||||
return new Recipient(context, null, contact);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
|
||||
@@ -2,13 +2,15 @@ package org.thoughtcrime.securesms.contacts.avatars;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.b44t.messenger.DcChat;
|
||||
|
||||
import org.thoughtcrime.securesms.connect.DcHelper;
|
||||
import org.thoughtcrime.securesms.database.Address;
|
||||
|
||||
public class GroupRecordContactPhoto extends LocalFileContactPhoto {
|
||||
|
||||
public GroupRecordContactPhoto(Context context, Address address) {
|
||||
super(context, address);
|
||||
public GroupRecordContactPhoto(Context context, Address address, DcChat dcChat) {
|
||||
super(context, address, dcChat, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -23,7 +25,7 @@ public class GroupRecordContactPhoto extends LocalFileContactPhoto {
|
||||
|
||||
@Override
|
||||
public String getPath(Context context) {
|
||||
String profileImage = DcHelper.getContext(context).getChat(getId()).getProfileImage();
|
||||
String profileImage = dcChat.getProfileImage();
|
||||
return profileImage != null ? profileImage : "";
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,9 @@ import android.net.Uri;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import com.b44t.messenger.DcChat;
|
||||
import com.b44t.messenger.DcContact;
|
||||
|
||||
import org.thoughtcrime.securesms.database.Address;
|
||||
import org.thoughtcrime.securesms.profiles.AvatarHelper;
|
||||
import org.thoughtcrime.securesms.util.Conversions;
|
||||
@@ -17,13 +20,17 @@ import java.security.MessageDigest;
|
||||
public abstract class LocalFileContactPhoto implements ContactPhoto {
|
||||
|
||||
final Address address;
|
||||
final DcChat dcChat;
|
||||
final DcContact dcContact;
|
||||
|
||||
private final int id;
|
||||
|
||||
private final String path;
|
||||
|
||||
LocalFileContactPhoto(Context context, Address address) {
|
||||
LocalFileContactPhoto(Context context, Address address, DcChat dcChat, DcContact dcContact) {
|
||||
this.address = address;
|
||||
this.dcChat = dcChat;
|
||||
this.dcContact = dcContact;
|
||||
id = getId();
|
||||
path = getPath(context);
|
||||
}
|
||||
|
||||
@@ -2,13 +2,15 @@ package org.thoughtcrime.securesms.contacts.avatars;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.b44t.messenger.DcContact;
|
||||
|
||||
import org.thoughtcrime.securesms.connect.DcHelper;
|
||||
import org.thoughtcrime.securesms.database.Address;
|
||||
|
||||
public class ProfileContactPhoto extends LocalFileContactPhoto {
|
||||
|
||||
public ProfileContactPhoto(Context context, Address address) {
|
||||
super(context, address);
|
||||
public ProfileContactPhoto(Context context, Address address, DcContact dcContact) {
|
||||
super(context, address, null, dcContact);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -23,7 +25,7 @@ public class ProfileContactPhoto extends LocalFileContactPhoto {
|
||||
|
||||
@Override
|
||||
public String getPath(Context context) {
|
||||
String profileImage = DcHelper.getContext(context).getContact(getId()).getProfileImage();
|
||||
String profileImage = dcContact.getProfileImage();
|
||||
return profileImage != null ? profileImage : "";
|
||||
}
|
||||
|
||||
|
||||
@@ -587,7 +587,7 @@ public class Contact implements Parcelable {
|
||||
|
||||
private static Attachment attachmentFromUri(@Nullable Uri uri) {
|
||||
if (uri == null) return null;
|
||||
return new UriAttachment(uri, MediaUtil.IMAGE_JPEG, AttachmentDatabase.TRANSFER_PROGRESS_DONE, 0, null, false, false);
|
||||
return new UriAttachment(uri, MediaUtil.IMAGE_JPEG, AttachmentDatabase.TRANSFER_PROGRESS_DONE, 0, null, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -5,7 +5,6 @@ import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
import org.thoughtcrime.securesms.util.GroupUtil;
|
||||
import org.thoughtcrime.securesms.util.NumberUtil;
|
||||
|
||||
public class Address implements Parcelable, Comparable<Address> {
|
||||
@@ -48,31 +47,14 @@ public class Address implements Parcelable, Comparable<Address> {
|
||||
return new Address(serialized);
|
||||
}
|
||||
|
||||
public boolean isGroup() {
|
||||
return GroupUtil.isEncodedGroup(address);
|
||||
}
|
||||
|
||||
public boolean isMmsGroup() {
|
||||
return GroupUtil.isMmsGroup(address);
|
||||
}
|
||||
|
||||
public boolean isEmail() {
|
||||
return NumberUtil.isValidEmail(address);
|
||||
}
|
||||
|
||||
public boolean isPhone() {
|
||||
return !isGroup() && !isEmail();
|
||||
}
|
||||
|
||||
public boolean isDcChat() { return address.startsWith(DC_CHAT_PREFIX); };
|
||||
|
||||
public boolean isDcContact() { return address.startsWith(DC_CONTACT_PREFIX); };
|
||||
|
||||
public @NonNull String toPhoneString() {
|
||||
if (!isPhone()) throw new AssertionError("Not e164: " + address);
|
||||
return address;
|
||||
}
|
||||
|
||||
public @NonNull String toEmailString() {
|
||||
if (!isEmail()) throw new AssertionError("Not email: " + address);
|
||||
return address;
|
||||
|
||||
@@ -49,12 +49,8 @@ public class DcLocationManager implements Observer {
|
||||
public DcLocationManager(Context context) {
|
||||
this.context = context.getApplicationContext();
|
||||
DcLocation.getInstance().addObserver(this);
|
||||
DcChatlist chats = DcHelper.getContext(context).getChatlist(0, null, 0);
|
||||
for (int i = 0; i < chats.getCnt(); i++) {
|
||||
if (DcHelper.getContext(context).isSendingLocationsToChat(chats.getChat(i).getId())) {
|
||||
initializeLocationEngine();
|
||||
return;
|
||||
}
|
||||
if (DcHelper.getContext(context).isSendingLocationsToChat(0)) {
|
||||
initializeLocationEngine();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -42,11 +42,11 @@ public class AudioSlide extends Slide {
|
||||
}
|
||||
|
||||
public AudioSlide(Context context, Uri uri, long dataSize, boolean voiceNote) {
|
||||
super(context, constructAttachmentFromUri(context, uri, MediaUtil.AUDIO_UNSPECIFIED, dataSize, 0, 0, false, null, voiceNote, false));
|
||||
super(context, constructAttachmentFromUri(context, uri, MediaUtil.AUDIO_UNSPECIFIED, dataSize, 0, 0, false, null, voiceNote));
|
||||
}
|
||||
|
||||
public AudioSlide(Context context, Uri uri, long dataSize, String contentType, boolean voiceNote) {
|
||||
super(context, new UriAttachment(uri, null, contentType, AttachmentDatabase.TRANSFER_PROGRESS_STARTED, dataSize, 0, 0, null, null, voiceNote, false));
|
||||
super(context, new UriAttachment(uri, null, contentType, AttachmentDatabase.TRANSFER_PROGRESS_STARTED, dataSize, 0, 0, null, null, voiceNote));
|
||||
}
|
||||
|
||||
public AudioSlide(Context context, Attachment attachment) {
|
||||
|
||||
@@ -29,7 +29,7 @@ public class DocumentSlide extends Slide {
|
||||
@NonNull String contentType, long size,
|
||||
@Nullable String fileName)
|
||||
{
|
||||
super(context, constructAttachmentFromUri(context, uri, contentType, size, 0, 0, true, StorageUtil.getCleanFileName(fileName), false, false));
|
||||
super(context, constructAttachmentFromUri(context, uri, contentType, size, 0, 0, true, StorageUtil.getCleanFileName(fileName), false));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -20,7 +20,7 @@ public class GifSlide extends ImageSlide {
|
||||
}
|
||||
|
||||
public GifSlide(Context context, Uri uri, long size, int width, int height) {
|
||||
super(context, constructAttachmentFromUri(context, uri, MediaUtil.IMAGE_GIF, size, width, height, true, null, false, false));
|
||||
super(context, constructAttachmentFromUri(context, uri, MediaUtil.IMAGE_GIF, size, width, height, true, null, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -44,7 +44,7 @@ public class ImageSlide extends Slide {
|
||||
}
|
||||
|
||||
public ImageSlide(Context context, Uri uri, long size, int width, int height) {
|
||||
super(context, constructAttachmentFromUri(context, uri, MediaUtil.IMAGE_JPEG, size, width, height, true, null, false, false));
|
||||
super(context, constructAttachmentFromUri(context, uri, MediaUtil.IMAGE_JPEG, size, width, height, true, null, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
package org.thoughtcrime.securesms.mms;
|
||||
|
||||
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import org.thoughtcrime.securesms.attachments.Attachment;
|
||||
import org.thoughtcrime.securesms.database.Address;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class QuoteModel {
|
||||
|
||||
private final long id;
|
||||
private final Address author;
|
||||
private final String text;
|
||||
private final List<Attachment> attachments;
|
||||
|
||||
public QuoteModel(long id, Address author, String text, @Nullable List<Attachment> attachments) {
|
||||
this.id = id;
|
||||
this.author = author;
|
||||
this.text = text;
|
||||
this.attachments = attachments;
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public Address getAuthor() {
|
||||
return author;
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
public List<Attachment> getAttachments() {
|
||||
return attachments;
|
||||
}
|
||||
}
|
||||
@@ -140,8 +140,7 @@ public abstract class Slide {
|
||||
int height,
|
||||
boolean hasThumbnail,
|
||||
@Nullable String fileName,
|
||||
boolean voiceNote,
|
||||
boolean quote)
|
||||
boolean voiceNote)
|
||||
{
|
||||
try {
|
||||
String resolvedType = Optional.fromNullable(MediaUtil.getMimeType(context, uri)).or(defaultMime);
|
||||
@@ -155,8 +154,7 @@ public abstract class Slide {
|
||||
height,
|
||||
fileName,
|
||||
fastPreflightId,
|
||||
voiceNote,
|
||||
quote);
|
||||
voiceNote);
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ import org.thoughtcrime.securesms.util.ResUtil;
|
||||
public class VideoSlide extends Slide {
|
||||
|
||||
public VideoSlide(Context context, Uri uri, long dataSize) {
|
||||
super(context, constructAttachmentFromUri(context, uri, MediaUtil.VIDEO_UNSPECIFIED, dataSize, 0, 0, MediaUtil.hasVideoThumbnail(uri), null, false, false));
|
||||
super(context, constructAttachmentFromUri(context, uri, MediaUtil.VIDEO_UNSPECIFIED, dataSize, 0, 0, MediaUtil.hasVideoThumbnail(uri), null, false));
|
||||
}
|
||||
|
||||
public VideoSlide(Context context, DcMsg dcMsg) {
|
||||
|
||||
@@ -42,6 +42,7 @@ import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.connect.ApplicationDcContext;
|
||||
import org.thoughtcrime.securesms.connect.DcHelper;
|
||||
import org.thoughtcrime.securesms.connect.KeepAliveService;
|
||||
import org.thoughtcrime.securesms.database.Address;
|
||||
import org.thoughtcrime.securesms.mms.SlideDeck;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.util.Pair;
|
||||
@@ -390,8 +391,9 @@ public class MessageNotifier {
|
||||
boolean mms = record.isMms() || record.isMediaPending();
|
||||
int chatId = record.getChatId();
|
||||
CharSequence body = record.getDisplayBody();
|
||||
Recipient chatRecipient = Recipient.fromChat(dcContext, msgId);
|
||||
Recipient individualRecipient = Recipient.fromMsg(dcContext, msgId);
|
||||
DcMsg dcMsg = dcContext.getMsg(msgId);
|
||||
Recipient chatRecipient = new Recipient(context, dcContext.getChat(dcMsg.getChatId()), null);
|
||||
Recipient individualRecipient = new Recipient(context, null, dcContext.getContact(dcMsg.getFromId()));
|
||||
SlideDeck slideDeck = new SlideDeck(dcContext.context, record);
|
||||
long timestamp = record.getTimestamp();
|
||||
|
||||
|
||||
@@ -25,6 +25,10 @@ import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.b44t.messenger.DcChat;
|
||||
import com.b44t.messenger.DcContact;
|
||||
import com.b44t.messenger.DcContext;
|
||||
|
||||
import org.thoughtcrime.securesms.connect.ApplicationDcContext;
|
||||
import org.thoughtcrime.securesms.connect.DcHelper;
|
||||
import org.thoughtcrime.securesms.contacts.avatars.ContactPhoto;
|
||||
@@ -34,36 +38,37 @@ import org.thoughtcrime.securesms.contacts.avatars.GroupRecordContactPhoto;
|
||||
import org.thoughtcrime.securesms.contacts.avatars.LocalFileContactPhoto;
|
||||
import org.thoughtcrime.securesms.contacts.avatars.ProfileContactPhoto;
|
||||
import org.thoughtcrime.securesms.contacts.avatars.SystemContactPhoto;
|
||||
import org.thoughtcrime.securesms.contacts.avatars.TransparentContactPhoto;
|
||||
import org.thoughtcrime.securesms.database.Address;
|
||||
import org.thoughtcrime.securesms.util.Hash;
|
||||
import org.thoughtcrime.securesms.util.Prefs;
|
||||
import org.thoughtcrime.securesms.util.Util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
public class Recipient implements RecipientModifiedListener {
|
||||
public class Recipient {
|
||||
|
||||
private final Set<RecipientModifiedListener> listeners = Collections.newSetFromMap(new WeakHashMap<RecipientModifiedListener, Boolean>());
|
||||
|
||||
private final @NonNull Address address;
|
||||
private final @NonNull List<Recipient> participants = new LinkedList<>();
|
||||
|
||||
private @Nullable String name;
|
||||
private @Nullable String customLabel;
|
||||
private boolean resolving;
|
||||
|
||||
private @Nullable Uri systemContactPhoto;
|
||||
private Uri contactUri;
|
||||
private @Nullable Uri messageRingtone = null;
|
||||
private boolean blocked = false;
|
||||
|
||||
private @Nullable String profileName;
|
||||
private @Nullable String profileAvatar;
|
||||
|
||||
// either dcChat or dcContact are set
|
||||
private @Nullable DcChat dcChat;
|
||||
private @Nullable DcContact dcContact;
|
||||
|
||||
public static @NonNull Recipient fromChat(@NonNull Context context, int dcMsgId) {
|
||||
ApplicationDcContext dcContext = DcHelper.getContext(context);
|
||||
return fromChat(dcContext, dcMsgId);
|
||||
@@ -73,10 +78,6 @@ public class Recipient implements RecipientModifiedListener {
|
||||
return dcContext.getRecipient(dcContext.getChat(dcContext.getMsg(dcMsgId).getChatId()));
|
||||
}
|
||||
|
||||
public static @NonNull Recipient fromMsg (@NonNull ApplicationDcContext dcContext, int dcMsgId) {
|
||||
return dcContext.getRecipient(dcContext.getContact(dcContext.getMsg(dcMsgId).getFromId()));
|
||||
}
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
public static @NonNull Recipient from(@NonNull Context context, @NonNull Address address) {
|
||||
if (address == null) throw new AssertionError(address);
|
||||
@@ -95,55 +96,61 @@ public class Recipient implements RecipientModifiedListener {
|
||||
return dcContext.getRecipient(dcContext.getContact(0));
|
||||
}
|
||||
|
||||
public Recipient(@NonNull Address address, @Nullable String name, @Nullable List<Recipient> participants) {
|
||||
this.address = address;
|
||||
public Recipient(@NonNull Context context, @Nullable DcChat dcChat, @Nullable DcContact dcContact) {
|
||||
this.dcChat = dcChat;
|
||||
this.dcContact = dcContact;
|
||||
this.contactUri = null;
|
||||
this.name = name;
|
||||
this.systemContactPhoto = null;
|
||||
this.customLabel = null;
|
||||
this.blocked = false;
|
||||
this.profileName = null;
|
||||
this.profileAvatar = null;
|
||||
this.participants.addAll(participants==null? new LinkedList<>() : participants);
|
||||
this.resolving = false;
|
||||
|
||||
if(dcContact!=null) {
|
||||
this.address = Address.fromContact(dcContact.getId());
|
||||
String identifier = Hash.sha256(dcContact.getDisplayName() + dcContact.getAddr());
|
||||
Uri systemContactPhoto = Prefs.getSystemContactPhoto(context, identifier);
|
||||
if (systemContactPhoto != null) {
|
||||
setSystemContactPhoto(systemContactPhoto);
|
||||
}
|
||||
if (dcContact.getId() == DcContact.DC_CONTACT_ID_SELF) {
|
||||
setProfileAvatar("SELF");
|
||||
}
|
||||
}
|
||||
else if(dcChat!=null) {
|
||||
this.address = Address.fromChat(dcChat.getId());
|
||||
if (!dcChat.isGroup()) {
|
||||
String identifier = Hash.sha256(dcChat.getName() + dcChat.getSubtitle());
|
||||
Uri systemContactPhoto = Prefs.getSystemContactPhoto(context, identifier);
|
||||
if (systemContactPhoto != null) {
|
||||
setSystemContactPhoto(systemContactPhoto);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
this.address = Address.UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized @Nullable Uri getContactUri() {
|
||||
public @Nullable Uri getContactUri() {
|
||||
return this.contactUri;
|
||||
}
|
||||
|
||||
public synchronized @Nullable String getName() {
|
||||
if (this.name == null && isMmsGroupRecipient()) {
|
||||
List<String> names = new LinkedList<>();
|
||||
|
||||
for (Recipient recipient : participants) {
|
||||
names.add(recipient.toShortString());
|
||||
}
|
||||
|
||||
return Util.join(names, ", ");
|
||||
public @Nullable String getName() {
|
||||
if(dcChat!=null) {
|
||||
return dcChat.getName();
|
||||
}
|
||||
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public void setName(@Nullable String name) {
|
||||
boolean notify = false;
|
||||
|
||||
synchronized (this) {
|
||||
if (!Util.equals(this.name, name)) {
|
||||
this.name = name;
|
||||
notify = true;
|
||||
}
|
||||
else if(dcContact!=null) {
|
||||
return dcContact.getDisplayName();
|
||||
}
|
||||
|
||||
if (notify) notifyListeners();
|
||||
return "";
|
||||
}
|
||||
|
||||
public @NonNull Address getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
public synchronized @Nullable String getProfileName() {
|
||||
public @Nullable String getProfileName() {
|
||||
return profileName;
|
||||
}
|
||||
|
||||
@@ -156,43 +163,40 @@ public class Recipient implements RecipientModifiedListener {
|
||||
}
|
||||
|
||||
public boolean isGroupRecipient() {
|
||||
return participants.size() > 1;
|
||||
return dcChat!=null && dcChat.isGroup();
|
||||
}
|
||||
|
||||
public boolean isMmsGroupRecipient() {
|
||||
return address.isMmsGroup();
|
||||
}
|
||||
|
||||
public @NonNull synchronized List<Recipient> getParticipants() {
|
||||
return new LinkedList<>(participants);
|
||||
public @NonNull List<Recipient> loadParticipants(Context context) {
|
||||
List<Recipient> participants = new ArrayList<>();
|
||||
if (dcChat!=null) {
|
||||
ApplicationDcContext dcContext = DcHelper.getContext(context);
|
||||
int[] contactIds = dcContext.getChatContacts(dcChat.getId());
|
||||
for (int contactId : contactIds) {
|
||||
participants.add(dcContext.getRecipient(ApplicationDcContext.RECIPIENT_TYPE_CONTACT, contactId));
|
||||
}
|
||||
}
|
||||
return participants;
|
||||
}
|
||||
|
||||
public synchronized void addListener(RecipientModifiedListener listener) {
|
||||
if (listeners.isEmpty()) {
|
||||
for (Recipient recipient : participants) recipient.addListener(this);
|
||||
}
|
||||
listeners.add(listener);
|
||||
}
|
||||
|
||||
public synchronized void removeListener(RecipientModifiedListener listener) {
|
||||
listeners.remove(listener);
|
||||
|
||||
if (listeners.isEmpty()) {
|
||||
for (Recipient recipient : participants) recipient.removeListener(this);
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized String toShortString() {
|
||||
return (getName() == null ? address.serialize() : getName());
|
||||
return getName();
|
||||
}
|
||||
|
||||
public int getFallbackAvatarColor(Context context) {
|
||||
int rgb = 0x00808080;
|
||||
if(address.isDcContact()) {
|
||||
rgb = DcHelper.getContext(context).getContact(address.getDcContactId()).getColor();
|
||||
if(dcContact!=null) {
|
||||
rgb = dcContact.getColor();
|
||||
}
|
||||
else if(address.isDcChat()){
|
||||
rgb = DcHelper.getContext(context).getChat(address.getDcChatId()).getColor();
|
||||
else if(dcChat!=null){
|
||||
rgb = dcChat.getColor();
|
||||
}
|
||||
int argb = Color.argb(0xFF, Color.red(rgb), Color.green(rgb), Color.blue(rgb));
|
||||
return argb;
|
||||
@@ -203,18 +207,18 @@ public class Recipient implements RecipientModifiedListener {
|
||||
}
|
||||
|
||||
public synchronized @NonNull FallbackContactPhoto getFallbackContactPhoto() {
|
||||
if (isResolving()) return new TransparentContactPhoto();
|
||||
else if (!TextUtils.isEmpty(name)) return new GeneratedContactPhoto(name);
|
||||
String name = getName();
|
||||
if (!TextUtils.isEmpty(name)) return new GeneratedContactPhoto(name);
|
||||
else return new GeneratedContactPhoto("#");
|
||||
}
|
||||
|
||||
public synchronized @Nullable ContactPhoto getContactPhoto(Context context) {
|
||||
LocalFileContactPhoto contactPhoto = null;
|
||||
if (address.isDcChat()) {
|
||||
contactPhoto = new GroupRecordContactPhoto(context, address);
|
||||
if (dcChat!=null) {
|
||||
contactPhoto = new GroupRecordContactPhoto(context, address, dcChat);
|
||||
}
|
||||
else if (address.isDcContact()) {
|
||||
contactPhoto = new ProfileContactPhoto(context, address);
|
||||
else if (dcContact!=null) {
|
||||
contactPhoto = new ProfileContactPhoto(context, address, dcContact);
|
||||
}
|
||||
|
||||
if (contactPhoto!=null) {
|
||||
@@ -252,24 +256,13 @@ public class Recipient implements RecipientModifiedListener {
|
||||
return messageRingtone;
|
||||
}
|
||||
|
||||
public synchronized boolean isBlocked() {
|
||||
return blocked;
|
||||
}
|
||||
|
||||
public void setBlocked(boolean blocked) {
|
||||
synchronized (this) {
|
||||
this.blocked = blocked;
|
||||
public boolean isBlocked() {
|
||||
if (dcContact!=null) {
|
||||
return dcContact.isBlocked();
|
||||
}
|
||||
|
||||
notifyListeners();
|
||||
return false;
|
||||
}
|
||||
|
||||
public synchronized Recipient resolve() {
|
||||
while (resolving) Util.wait(this, 0);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
@@ -296,31 +289,32 @@ public class Recipient implements RecipientModifiedListener {
|
||||
listener.onModified(this);
|
||||
}
|
||||
|
||||
public void reload(Context context)
|
||||
{
|
||||
DcContext dcContext = DcHelper.getContext(context);
|
||||
if(dcContact!=null) {
|
||||
dcContact = dcContext.getContact(dcContact.getId());
|
||||
}
|
||||
else if(dcChat!=null) {
|
||||
dcChat = dcContext.getChat(dcChat.getId());
|
||||
}
|
||||
}
|
||||
|
||||
public DcChat getChat()
|
||||
{
|
||||
return dcChat!=null? dcChat : new DcChat(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Recipient{" +
|
||||
"listeners=" + listeners +
|
||||
", address=" + address +
|
||||
", participants=" + participants +
|
||||
", name='" + name + '\'' +
|
||||
", customLabel='" + customLabel + '\'' +
|
||||
", resolving=" + resolving +
|
||||
", systemContactPhoto=" + systemContactPhoto +
|
||||
", contactUri=" + contactUri +
|
||||
", blocked=" + blocked +
|
||||
", profileName='" + profileName + '\'' +
|
||||
", profileAvatar='" + profileAvatar + '\'' +
|
||||
'}';
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onModified(Recipient recipient) {
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
public synchronized boolean isResolving() {
|
||||
return resolving;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
package org.thoughtcrime.securesms.util;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class GroupUtil {
|
||||
|
||||
private static final String ENCODED_SIGNAL_GROUP_PREFIX = "__textsecure_group__!";
|
||||
private static final String ENCODED_MMS_GROUP_PREFIX = "__signal_mms_group__!";
|
||||
private static final String TAG = GroupUtil.class.getSimpleName();
|
||||
|
||||
public static String getEncodedId(byte[] groupId, boolean mms) {
|
||||
return (mms ? ENCODED_MMS_GROUP_PREFIX : ENCODED_SIGNAL_GROUP_PREFIX) + Hex.toStringCondensed(groupId);
|
||||
}
|
||||
|
||||
public static byte[] getDecodedId(String groupId) throws IOException {
|
||||
if (!isEncodedGroup(groupId)) {
|
||||
throw new IOException("Invalid encoding");
|
||||
}
|
||||
|
||||
return Hex.fromStringCondensed(groupId.split("!", 2)[1]);
|
||||
}
|
||||
|
||||
public static boolean isEncodedGroup(@NonNull String groupId) {
|
||||
return groupId.startsWith(ENCODED_SIGNAL_GROUP_PREFIX) || groupId.startsWith(ENCODED_MMS_GROUP_PREFIX);
|
||||
}
|
||||
|
||||
public static boolean isMmsGroup(@NonNull String groupId) {
|
||||
return groupId.startsWith(ENCODED_MMS_GROUP_PREFIX);
|
||||
}
|
||||
}
|
||||
@@ -138,16 +138,6 @@ public class Util {
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isOwnNumber(Context context, Address address) {
|
||||
if (address.isGroup()) return false;
|
||||
if (address.isEmail()) return false;
|
||||
if (address.isDcChat()) return false;
|
||||
String localNumber = Prefs.getLocalNumber(context);
|
||||
if (TextUtils.isEmpty(localNumber)) return false;
|
||||
|
||||
return localNumber.equals(address.toPhoneString());
|
||||
}
|
||||
|
||||
public static void readFully(InputStream in, byte[] buffer) throws IOException {
|
||||
int offset = 0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user