diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index c12e89e812..a6eac279b6 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -5,7 +5,7 @@
android:versionCode="131"
android:versionName="2.20.0">
-
+
-
+
-
-
+
diff --git a/res/drawable/conversation_item_sent_indicator_text_shape_dark.xml b/res/drawable/conversation_item_sent_indicator_text_shape_dark.xml
index 4e55dfe701..d02a391561 100644
--- a/res/drawable/conversation_item_sent_indicator_text_shape_dark.xml
+++ b/res/drawable/conversation_item_sent_indicator_text_shape_dark.xml
@@ -10,7 +10,7 @@
-
-
+
diff --git a/res/drawable/triangle_tick_incoming_dark.xml b/res/drawable/triangle_tick_incoming_dark.xml
deleted file mode 100644
index 14bbf0f8ee..0000000000
--- a/res/drawable/triangle_tick_incoming_dark.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
diff --git a/res/drawable/triangle_tick_incoming_light.xml b/res/drawable/triangle_tick_incoming_light.xml
deleted file mode 100644
index a738f898cf..0000000000
--- a/res/drawable/triangle_tick_incoming_light.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
diff --git a/res/drawable/triangle_tick_outgoing_pending_push_dark.xml b/res/drawable/triangle_tick_outgoing_pending_push_dark.xml
deleted file mode 100644
index e360878584..0000000000
--- a/res/drawable/triangle_tick_outgoing_pending_push_dark.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
diff --git a/res/drawable/triangle_tick_outgoing_pending_push_light.xml b/res/drawable/triangle_tick_outgoing_pending_push_light.xml
deleted file mode 100644
index 056df3823c..0000000000
--- a/res/drawable/triangle_tick_outgoing_pending_push_light.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
diff --git a/res/drawable/triangle_tick_outgoing_pending_sms_dark.xml b/res/drawable/triangle_tick_outgoing_pending_sms_dark.xml
deleted file mode 100644
index 97cf746c5f..0000000000
--- a/res/drawable/triangle_tick_outgoing_pending_sms_dark.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
diff --git a/res/drawable/triangle_tick_outgoing_pending_sms_light.xml b/res/drawable/triangle_tick_outgoing_pending_sms_light.xml
deleted file mode 100644
index dfe7b6a946..0000000000
--- a/res/drawable/triangle_tick_outgoing_pending_sms_light.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
diff --git a/res/drawable/triangle_tick_outgoing_sent_push_dark.xml b/res/drawable/triangle_tick_outgoing_sent_push_dark.xml
deleted file mode 100644
index fa237ea7fb..0000000000
--- a/res/drawable/triangle_tick_outgoing_sent_push_dark.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
diff --git a/res/drawable/triangle_tick_outgoing_sent_push_light.xml b/res/drawable/triangle_tick_outgoing_sent_push_light.xml
deleted file mode 100644
index d0f22ac0db..0000000000
--- a/res/drawable/triangle_tick_outgoing_sent_push_light.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
diff --git a/res/drawable/triangle_tick_outgoing_sent_sms_dark.xml b/res/drawable/triangle_tick_outgoing_sent_sms_dark.xml
deleted file mode 100644
index 45abd07706..0000000000
--- a/res/drawable/triangle_tick_outgoing_sent_sms_dark.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
diff --git a/res/drawable/triangle_tick_outgoing_sent_sms_light.xml b/res/drawable/triangle_tick_outgoing_sent_sms_light.xml
deleted file mode 100644
index e85fedc804..0000000000
--- a/res/drawable/triangle_tick_outgoing_sent_sms_light.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
diff --git a/res/layout/conversation_activity.xml b/res/layout/conversation_activity.xml
index 59d5ff1083..5c7bdf651c 100644
--- a/res/layout/conversation_activity.xml
+++ b/res/layout/conversation_activity.xml
@@ -1,9 +1,10 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/res/layout/conversation_bubble_outgoing.xml b/res/layout/conversation_bubble_outgoing.xml
deleted file mode 100644
index 8a148e0437..0000000000
--- a/res/layout/conversation_bubble_outgoing.xml
+++ /dev/null
@@ -1,139 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/res/layout/conversation_item_activity.xml b/res/layout/conversation_item_activity.xml
index 0087083bb0..79adc8789b 100644
--- a/res/layout/conversation_item_activity.xml
+++ b/res/layout/conversation_item_activity.xml
@@ -25,7 +25,7 @@
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_gravity="right"
android:fontFamily="sans-serif-light"
- android:textColor="?conversation_sent_text_secondary_color"
+ android:textColor="?conversation_item_sent_text_secondary_color"
android:text="date"
android:layout_marginBottom="8dp"
android:visibility="gone"/>
diff --git a/res/layout/conversation_item_pending.xml b/res/layout/conversation_item_pending.xml
new file mode 100644
index 0000000000..116287978b
--- /dev/null
+++ b/res/layout/conversation_item_pending.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/res/layout/conversation_item_pending_v11.xml b/res/layout/conversation_item_pending_v11.xml
new file mode 100644
index 0000000000..2465b4ff6b
--- /dev/null
+++ b/res/layout/conversation_item_pending_v11.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/res/layout/conversation_item_received.xml b/res/layout/conversation_item_received.xml
index 46b1d4b1e2..98220bfe0f 100644
--- a/res/layout/conversation_item_received.xml
+++ b/res/layout/conversation_item_received.xml
@@ -7,6 +7,7 @@
android:background="?conversation_item_background"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
+ xmlns:dots="http://schemas.android.com/apk/res-auto"
xmlns:app="http://schemas.android.com/apk/res-auto">
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/res/layout/conversation_item_sent.xml b/res/layout/conversation_item_sent.xml
index 551dbe1731..bec59cb68f 100644
--- a/res/layout/conversation_item_sent.xml
+++ b/res/layout/conversation_item_sent.xml
@@ -46,25 +46,151 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/res/values/attrs.xml b/res/values/attrs.xml
index bf69ebc9c2..e0f94d8291 100644
--- a/res/values/attrs.xml
+++ b/res/values/attrs.xml
@@ -13,9 +13,6 @@
-
-
-
@@ -26,9 +23,9 @@
+
-
@@ -57,20 +54,11 @@
-
-
-
-
+
+
+
+
-
-
-
-
-
-
-
-
-
diff --git a/res/values/colors.xml b/res/values/colors.xml
index 75634142db..f1483bc90a 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -35,20 +35,7 @@
#400099cc
#33ffffff
#66ffffff
- #ff284e0a
- #ff64a926
- #ffd5d5d5
- #ff222222
- #5564A926
- #90284e0a
- #ff2090ea
- #ff183b7a
- #ff5cace6
- #ff122d5e
- #fff3f3f3
- #ff333333
- #ffefefef
- #ff222222
+
#ffeeeeee
#ff333333
#ffd5d5d5
diff --git a/res/values/themes.xml b/res/values/themes.xml
index 6ac92c8023..3c7fc3d7ce 100644
--- a/res/values/themes.xml
+++ b/res/values/themes.xml
@@ -77,9 +77,6 @@
- @drawable/divet_lower_right_dark
- #99000000
- - #ffffffff
- - #bbffffff
- - #99000000
- #ff333333
- #99333333
@@ -88,9 +85,9 @@
- #66000000
- #44000000
+ - #eeeeee
- #22000000
- #ff111111
- - @drawable/ic_delivery_delivered_dark
- @drawable/ic_send_sms_insecure
- @drawable/ic_send_push
- @color/white
@@ -118,21 +115,12 @@
- @drawable/emoji_category_symbol_light
- @drawable/emoji_category_emoticons_light
+ - #99000000
+ - @color/white
+ - #bb000000
+ - #99000000
- @drawable/conversation_item_background
- - @color/conversation_item_received_background_light
- - @color/conversation_item_sent_background_light
- - @color/conversation_item_sent_push_background_light
- - @color/conversation_item_sent_pending_background_light
- - @color/conversation_item_sent_push_pending_background_light
- @drawable/conversation_item_sent_indicator_text_shape
- - @color/conversation_item_received_shadow_light
- - #99ffffff
-
- - @drawable/triangle_tick_incoming_light
- - @drawable/triangle_tick_outgoing_sent_sms_light
- - @drawable/triangle_tick_outgoing_sent_push_light
- - @drawable/triangle_tick_outgoing_pending_sms_light
- - @drawable/triangle_tick_outgoing_pending_push_light
- @drawable/ic_info_outline_light
- @drawable/ic_warning_light
@@ -151,7 +139,7 @@
- @drawable/ic_launch_white_24dp
- @drawable/ic_unlocked_white_24dp
- @drawable/ic_lock_white_24dp
- - @drawable/ic_lock_white_18dp
+ - @drawable/ic_lock_black_18dp
- @drawable/ic_lock_black_18dp
- @drawable/ic_delete_white_24dp
- @drawable/ic_select_all_white_24dp
@@ -199,9 +187,6 @@
- @drawable/share_list_divider_shape_dark
- #99ffffff
- - #ffffffff
- - #aaeeeeee
- - #99ffffff
- #ffeeeeee
- #99eeeeee
@@ -211,20 +196,11 @@
- #66eeeeee
- @drawable/conversation_item_background_dark
- - @color/conversation_item_received_background_dark
- - @color/conversation_item_sent_background_dark
- - @color/conversation_item_sent_push_background_dark
- - @color/conversation_item_sent_pending_background_dark
- - @color/conversation_item_sent_push_pending_background_dark
+ - #ff333333
+ - #ffffffff
+ - #aaeeeeee
+ - #99ffffff
- @drawable/conversation_item_sent_indicator_text_shape_dark
- - @color/conversation_item_received_shadow_dark
- - #99000000
-
- - @drawable/triangle_tick_incoming_dark
- - @drawable/triangle_tick_outgoing_sent_sms_dark
- - @drawable/triangle_tick_outgoing_sent_push_dark
- - @drawable/triangle_tick_outgoing_pending_sms_dark
- - @drawable/triangle_tick_outgoing_pending_push_dark
- @drawable/ic_info_outline_dark
- @drawable/ic_warning_dark
@@ -239,9 +215,9 @@
- @color/textsecure_primary_dark
- @drawable/divet_lower_right_light
+ - #22ffffff
- #22ffffff
- #ffeeeeee
- - @drawable/ic_delivery_delivered_dark
- @drawable/ic_send_sms_insecure_dark
- @drawable/ic_send_push
- @color/black
diff --git a/src/org/thoughtcrime/securesms/ConversationItem.java b/src/org/thoughtcrime/securesms/ConversationItem.java
index 2d6a62ed72..d22b80b5c9 100644
--- a/src/org/thoughtcrime/securesms/ConversationItem.java
+++ b/src/org/thoughtcrime/securesms/ConversationItem.java
@@ -21,11 +21,15 @@ import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.res.TypedArray;
+import android.graphics.PorterDuff;
+import android.os.Build;
import android.support.annotation.NonNull;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.Log;
+import android.view.LayoutInflater;
import android.view.View;
+import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
@@ -36,7 +40,6 @@ import com.afollestad.materialdialogs.AlertDialogWrapper;
import org.thoughtcrime.securesms.ConversationFragment.SelectionClickListener;
import org.thoughtcrime.securesms.components.AvatarImageView;
-import org.thoughtcrime.securesms.components.BubbleContainer;
import org.thoughtcrime.securesms.components.ThumbnailView;
import org.thoughtcrime.securesms.crypto.MasterSecret;
import org.thoughtcrime.securesms.database.DatabaseFactory;
@@ -82,12 +85,14 @@ public class ConversationItem extends LinearLayout {
private TextView indicatorText;
private TextView groupStatusText;
private ImageView secureImage;
- private ImageView failedImage;
private AvatarImageView contactPhoto;
- private ImageView deliveryImage;
- private ImageView pendingIndicator;
- private BubbleContainer bubbleContainer;
+ private ImageView failedIndicator;
+ private ImageView deliveredIndicator;
+ private ImageView sentIndicator;
+ private View pendingIndicator;
+ private ImageView pendingApprovalIndicator;
+ private StatusManager statusManager;
private Set batchSelected;
private SelectionClickListener selectionClickListener;
private ThumbnailView mediaThumbnail;
@@ -113,20 +118,28 @@ public class ConversationItem extends LinearLayout {
protected void onFinishInflate() {
super.onFinishInflate();
- this.bodyText = (TextView) findViewById(R.id.conversation_item_body);
- this.dateText = (TextView) findViewById(R.id.conversation_item_date);
- this.indicatorText = (TextView) findViewById(R.id.indicator_text);
- this.groupStatusText = (TextView) findViewById(R.id.group_message_status);
- this.secureImage = (ImageView)findViewById(R.id.sms_secure_indicator);
- this.failedImage = (ImageView)findViewById(R.id.sms_failed_indicator);
- this.mmsDownloadButton = (Button) findViewById(R.id.mms_download_button);
- this.mmsDownloadingLabel = (TextView) findViewById(R.id.mms_label_downloading);
- this.contactPhoto = (AvatarImageView) findViewById(R.id.contact_photo);
- this.deliveryImage = (ImageView)findViewById(R.id.delivered_indicator);
- this.bodyBubble = findViewById(R.id.body_bubble);
- this.pendingIndicator = (ImageView)findViewById(R.id.pending_approval_indicator);
- this.bubbleContainer = (BubbleContainer)findViewById(R.id.bubble);
- this.mediaThumbnail = (ThumbnailView)findViewById(R.id.image_view);
+ ViewGroup pendingIndicatorStub = (ViewGroup) findViewById(R.id.pending_indicator_stub);
+ LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+
+ if (Build.VERSION.SDK_INT >= 11) inflater.inflate(R.layout.conversation_item_pending_v11, pendingIndicatorStub, true);
+ else inflater.inflate(R.layout.conversation_item_pending, pendingIndicatorStub, true);
+
+ this.bodyText = (TextView) findViewById(R.id.conversation_item_body);
+ this.dateText = (TextView) findViewById(R.id.conversation_item_date);
+ this.indicatorText = (TextView) findViewById(R.id.indicator_text);
+ this.groupStatusText = (TextView) findViewById(R.id.group_message_status);
+ this.secureImage = (ImageView) findViewById(R.id.secure_indicator);
+ this.failedIndicator = (ImageView) findViewById(R.id.sms_failed_indicator);
+ this.mmsDownloadButton = (Button) findViewById(R.id.mms_download_button);
+ this.mmsDownloadingLabel = (TextView) findViewById(R.id.mms_label_downloading);
+ this.contactPhoto = (AvatarImageView) findViewById(R.id.contact_photo);
+ this.deliveredIndicator = (ImageView) findViewById(R.id.delivered_indicator);
+ this.sentIndicator = (ImageView) findViewById(R.id.sent_indicator);
+ this.bodyBubble = findViewById(R.id.body_bubble);
+ this.pendingApprovalIndicator = (ImageView) findViewById(R.id.pending_approval_indicator);
+ this.pendingIndicator = findViewById(R.id.pending_indicator);
+ this.mediaThumbnail = (ThumbnailView) findViewById(R.id.image_view);
+ this.statusManager = new StatusManager(pendingIndicator, sentIndicator, deliveredIndicator, failedIndicator, pendingApprovalIndicator);
setOnClickListener(clickListener);
if (mmsDownloadButton != null) mmsDownloadButton.setOnClickListener(mmsDownloadClickListener);
@@ -175,33 +188,12 @@ public class ConversationItem extends LinearLayout {
/// MessageRecord Attribute Parsers
private void setBubbleState(MessageRecord messageRecord) {
- final int transportationState;
- if ((messageRecord.isPending() || messageRecord.isFailed()) &&
- pushDestination &&
- !messageRecord.isForcedSms())
- {
- transportationState = BubbleContainer.TRANSPORT_STATE_PUSH_PENDING;
- } else if (messageRecord.isPending() ||
- messageRecord.isFailed() ||
- messageRecord.isPendingInsecureSmsFallback())
- {
- transportationState = BubbleContainer.TRANSPORT_STATE_SMS_PENDING;
- } else if (messageRecord.isPush()) {
- transportationState = BubbleContainer.TRANSPORT_STATE_PUSH_SENT;
- } else {
- transportationState = BubbleContainer.TRANSPORT_STATE_SMS_SENT;
- }
+ int[] attributes = new int[]{R.attr.conversation_item_bubble_background};
+ TypedArray colors = context.obtainStyledAttributes(attributes);
- final int mediaCaptionState;
- if (!hasMedia(messageRecord)) {
- mediaCaptionState = BubbleContainer.MEDIA_STATE_NO_MEDIA;
- } else if (isCaptionlessMms(messageRecord)) {
- mediaCaptionState = BubbleContainer.MEDIA_STATE_CAPTIONLESS;
- } else {
- mediaCaptionState = BubbleContainer.MEDIA_STATE_CAPTIONED;
- }
+ bodyBubble.getBackground().setColorFilter(colors.getColor(0, 0xFFFFFF), PorterDuff.Mode.SRC_ATOP);
- bubbleContainer.setState(transportationState, mediaCaptionState);
+ colors.recycle();
}
private void setSelectionBackgroundDrawables(MessageRecord messageRecord) {
@@ -252,9 +244,18 @@ public class ConversationItem extends LinearLayout {
private void setMediaAttributes(MessageRecord messageRecord) {
if (messageRecord.isMmsNotification()) {
+ mediaThumbnail.setVisibility(View.GONE);
+ bodyText.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
setNotificationMmsAttributes((NotificationMmsMessageRecord) messageRecord);
- } else if (messageRecord.isMms()) {
- resolveMedia((MediaMmsMessageRecord) messageRecord);
+ } else if (hasMedia(messageRecord)) {
+ mediaThumbnail.setVisibility(View.VISIBLE);
+ mediaThumbnail.setImageResource(masterSecret, messageRecord.getId(),
+ messageRecord.getDateReceived(),
+ ((MediaMmsMessageRecord)messageRecord).getSlideDeckFuture());
+ bodyText.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
+ } else {
+ mediaThumbnail.setVisibility(View.GONE);
+ bodyText.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
}
}
@@ -265,32 +266,29 @@ public class ConversationItem extends LinearLayout {
}
private void setStatusIcons(MessageRecord messageRecord) {
- failedImage.setVisibility(messageRecord.isFailed() ? View.VISIBLE : View.GONE);
- if (messageRecord.isOutgoing()) pendingIndicator.setVisibility(View.GONE);
- if (messageRecord.isOutgoing()) indicatorText.setVisibility(View.GONE);
+ mmsDownloadButton.setVisibility(View.GONE);
+ mmsDownloadingLabel.setVisibility(View.GONE);
+ indicatorText.setVisibility(View.GONE);
secureImage.setVisibility(messageRecord.isSecure() ? View.VISIBLE : View.GONE);
bodyText.setCompoundDrawablesWithIntrinsicBounds(0, 0, messageRecord.isKeyExchange() ? R.drawable.ic_menu_login : 0, 0);
- deliveryImage.setVisibility(!messageRecord.isKeyExchange() && messageRecord.isDelivered() ? View.VISIBLE : View.GONE);
- mmsDownloadButton.setVisibility(View.GONE);
- mmsDownloadingLabel.setVisibility(View.GONE);
-
- if (messageRecord.isFailed()) setFailedStatusIcons();
- else if (messageRecord.isPendingInsecureSmsFallback()) setFallbackStatusIcons();
- else if (messageRecord.isPending()) dateText.setText(" ยทยทยท ");
- else setSentStatusIcons();
- }
-
- private void setSentStatusIcons() {
final long timestamp;
+
if (messageRecord.isPush()) timestamp = messageRecord.getDateSent();
else timestamp = messageRecord.getDateReceived();
dateText.setText(DateUtils.getExtendedRelativeTimeSpanString(getContext(), locale, timestamp));
+
+ if (messageRecord.isFailed()) setFailedStatusIcons();
+ else if (messageRecord.isPendingInsecureSmsFallback()) setFallbackStatusIcons();
+ else if (messageRecord.isPending()) statusManager.displayPending();
+ else if (messageRecord.isDelivered()) statusManager.displayDelivered();
+ else statusManager.displaySent();
}
private void setFailedStatusIcons() {
+ statusManager.displayFailed();
dateText.setText(R.string.ConversationItem_error_not_delivered);
if (indicatorText != null) {
indicatorText.setText(R.string.ConversationItem_click_for_details);
@@ -299,7 +297,7 @@ public class ConversationItem extends LinearLayout {
}
private void setFallbackStatusIcons() {
- pendingIndicator.setVisibility(View.VISIBLE);
+ statusManager.displayPendingApproval();
indicatorText.setVisibility(View.VISIBLE);
indicatorText.setText(R.string.ConversationItem_click_to_approve_unencrypted);
}
@@ -307,7 +305,7 @@ public class ConversationItem extends LinearLayout {
private void setMinimumWidth() {
if (indicatorText != null && indicatorText.getVisibility() == View.VISIBLE && indicatorText.getText() != null) {
final float density = getResources().getDisplayMetrics().density;
- bodyBubble.setMinimumWidth(indicatorText.getText().length() * (int) (6.5 * density));
+ bodyBubble.setMinimumWidth(indicatorText.getText().length() * (int) (6.5 * density) + (int) (22.0 * density));
} else {
bodyBubble.setMinimumWidth(0);
}
@@ -357,14 +355,6 @@ public class ConversationItem extends LinearLayout {
}
}
- private void resolveMedia(MediaMmsMessageRecord messageRecord) {
- if (hasMedia(messageRecord)) {
- mediaThumbnail.setImageResource(masterSecret, messageRecord.getId(),
- messageRecord.getDateReceived(),
- messageRecord.getSlideDeckFuture());
- }
- }
-
/// Helper Methods
private void setContactPhotoForRecipient(final Recipient recipient) {
@@ -538,4 +528,73 @@ public class ConversationItem extends LinearLayout {
});
builder.show();
}
+
+ private static class StatusManager {
+
+ private final View pendingIndicator;
+ private final View sentIndicator;
+ private final View deliveredIndicator;
+
+ private final View failedIndicator;
+ private final View approvalIndicator;
+
+
+ public StatusManager(View pendingIndicator, View sentIndicator,
+ View deliveredIndicator, View failedIndicator,
+ View approvalIndicator)
+ {
+ this.pendingIndicator = pendingIndicator;
+ this.sentIndicator = sentIndicator;
+ this.deliveredIndicator = deliveredIndicator;
+ this.failedIndicator = failedIndicator;
+ this.approvalIndicator = approvalIndicator;
+ }
+
+ public void displayFailed() {
+ pendingIndicator.setVisibility(View.GONE);
+ sentIndicator.setVisibility(View.GONE);
+ deliveredIndicator.setVisibility(View.GONE);
+ approvalIndicator.setVisibility(View.GONE);
+
+ failedIndicator.setVisibility(View.VISIBLE);
+ }
+
+ public void displayPendingApproval() {
+ pendingIndicator.setVisibility(View.GONE);
+ sentIndicator.setVisibility(View.GONE);
+ deliveredIndicator.setVisibility(View.GONE);
+ failedIndicator.setVisibility(View.GONE);
+
+ approvalIndicator.setVisibility(View.VISIBLE);
+ }
+
+ public void displayPending() {
+ sentIndicator.setVisibility(View.GONE);
+ deliveredIndicator.setVisibility(View.GONE);
+ failedIndicator.setVisibility(View.GONE);
+ approvalIndicator.setVisibility(View.GONE);
+
+ pendingIndicator.setVisibility(View.VISIBLE);
+ }
+
+ public void displaySent() {
+ pendingIndicator.setVisibility(View.GONE);
+ deliveredIndicator.setVisibility(View.GONE);
+ failedIndicator.setVisibility(View.GONE);
+ approvalIndicator.setVisibility(View.GONE);
+
+ sentIndicator.setVisibility(View.VISIBLE);
+ }
+
+ public void displayDelivered() {
+ pendingIndicator.setVisibility(View.GONE);
+ failedIndicator.setVisibility(View.GONE);
+ approvalIndicator.setVisibility(View.GONE);
+ sentIndicator.setVisibility(View.GONE);
+
+ deliveredIndicator.setVisibility(View.VISIBLE);
+ }
+
+ }
+
}
diff --git a/src/org/thoughtcrime/securesms/components/BubbleContainer.java b/src/org/thoughtcrime/securesms/components/BubbleContainer.java
deleted file mode 100644
index c390f5406a..0000000000
--- a/src/org/thoughtcrime/securesms/components/BubbleContainer.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/**
- * Copyright (C) 2015 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 .
- */
-package org.thoughtcrime.securesms.components;
-
-import android.annotation.TargetApi;
-import android.content.Context;
-import android.graphics.Color;
-import android.graphics.drawable.ColorDrawable;
-import android.graphics.drawable.Drawable;
-import android.os.Build.VERSION_CODES;
-import android.support.annotation.IntDef;
-import android.util.AttributeSet;
-import android.view.View;
-import android.widget.RelativeLayout;
-
-import org.thoughtcrime.securesms.R;
-import org.thoughtcrime.securesms.util.ResUtil;
-import org.thoughtcrime.securesms.util.ViewUtil;
-
-public abstract class BubbleContainer extends RelativeLayout {
- @SuppressWarnings("unused")
- private static final String TAG = BubbleContainer.class.getSimpleName();
-
- public static final int TRANSPORT_STATE_PUSH_SENT = 0;
- public static final int TRANSPORT_STATE_SMS_SENT = 1;
- public static final int TRANSPORT_STATE_SMS_PENDING = 2;
- public static final int TRANSPORT_STATE_PUSH_PENDING = 3;
-
- public static final int MEDIA_STATE_NO_MEDIA = 0;
- public static final int MEDIA_STATE_CAPTIONLESS = 1;
- public static final int MEDIA_STATE_CAPTIONED = 2;
-
- @IntDef({TRANSPORT_STATE_PUSH_SENT, TRANSPORT_STATE_PUSH_PENDING, TRANSPORT_STATE_SMS_SENT, TRANSPORT_STATE_SMS_PENDING})
- public @interface TransportState {}
-
- @IntDef({MEDIA_STATE_NO_MEDIA, MEDIA_STATE_CAPTIONLESS, MEDIA_STATE_CAPTIONED})
- public @interface MediaState {}
-
- private View bodyBubble;
- private View triangleTick;
- private ThumbnailView media;
- private int shadowColor;
- private int mmsPendingOverlayColor;
-
- public BubbleContainer(Context context) {
- super(context);
- initialize();
- }
-
- public BubbleContainer(Context context, AttributeSet attrs) {
- super(context, attrs);
- initialize();
- }
-
- public BubbleContainer(Context context, AttributeSet attrs, int defStyleAttr) {
- super(context, attrs, defStyleAttr);
- initialize();
- }
-
- @TargetApi(VERSION_CODES.LOLLIPOP)
- public BubbleContainer(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
- super(context, attrs, defStyleAttr, defStyleRes);
- initialize();
- }
-
- protected abstract void onCreateView();
- protected abstract int getForegroundColor(@TransportState int transportState);
- protected abstract boolean[] getMessageCorners(@MediaState int mediaState);
- protected abstract boolean[] getMediaCorners(@MediaState int mediaState);
- protected abstract int getTriangleTickRes(@TransportState int transportState);
-
- protected void initialize() {
- onCreateView();
- this.bodyBubble = findViewById(R.id.body_bubble );
- this.triangleTick = findViewById(R.id.triangle_tick);
- this.media = (ThumbnailView) findViewById(R.id.image_view);
-
- this.shadowColor = ResUtil.getColor(getContext(), R.attr.conversation_item_shadow);
- this.mmsPendingOverlayColor = ResUtil.getColor(getContext(), R.attr.conversation_item_mms_pending_mask);
- }
-
- public void setState(@TransportState int transportState, @MediaState int mediaState) {
- updateBodyBubble(transportState, mediaState);
- if (isMediaPresent(mediaState)) {
- updateMediaBubble(transportState, mediaState);
- }
- setMediaVisibility(mediaState);
- setAlignment(mediaState);
- setMediaPendingMask(transportState);
- }
-
- private void updateBodyBubble(@TransportState int transportState, @MediaState int mediaState) {
- final boolean hasShadow = mediaState == MEDIA_STATE_CAPTIONED || mediaState == MEDIA_STATE_NO_MEDIA;
- final BubbleDrawableBuilder builder = new BubbleDrawableBuilder();
- final int color = getForegroundColor(transportState);
-
- final Drawable bodyDrawable = builder.setColor(color)
- .setShadowColor(shadowColor)
- .setCorners(getMessageCorners(mediaState))
- .setHasShadow(hasShadow)
- .create(getContext());
- ViewUtil.setBackgroundSavingPadding(triangleTick, getTriangleTickRes(transportState));
- ViewUtil.setBackgroundSavingPadding(bodyBubble, bodyDrawable);
- }
-
- private void updateMediaBubble(@TransportState int transportState, @MediaState int mediaState) {
- final int foregroundColor = getForegroundColor(transportState);
- final BubbleDrawableBuilder builder = new BubbleDrawableBuilder();
-
- final Drawable mediaDrawable = builder.setColor(foregroundColor)
- .setShadowColor(shadowColor)
- .setCorners(getMediaCorners(mediaState))
- .setHasShadow(false)
- .create(getContext());
- ViewUtil.setBackgroundSavingPadding(media, mediaDrawable);
- media.setBorderColor(foregroundColor);
- }
-
- private void setMediaVisibility(@MediaState int mediaState) {
- if (!isMediaPresent(mediaState)) media.setVisibility(View.GONE);
- else media.setVisibility(View.VISIBLE);
- }
-
- private void setMediaPendingMask(@TransportState int transportState) {
- if (isPending(transportState)) {
- media.setForeground(new ColorDrawable(mmsPendingOverlayColor));
- } else {
- media.setForeground(new ColorDrawable(Color.TRANSPARENT));
- }
- }
-
- private void setAlignment(@MediaState int mediaState) {
- RelativeLayout.LayoutParams parentParams = (RelativeLayout.LayoutParams) bodyBubble.getLayoutParams();
- if (mediaState == MEDIA_STATE_CAPTIONLESS) {
- parentParams.addRule(RelativeLayout.BELOW, 0);
- parentParams.addRule(RelativeLayout.ALIGN_BOTTOM, R.id.thumbnail_container);
- } else if (mediaState == MEDIA_STATE_CAPTIONED) {
- parentParams.addRule(RelativeLayout.BELOW, R.id.thumbnail_container);
- parentParams.addRule(RelativeLayout.ALIGN_BOTTOM, 0);
- } else {
- parentParams.addRule(RelativeLayout.BELOW, 0);
- parentParams.addRule(RelativeLayout.ALIGN_BOTTOM, 0);
- }
- bodyBubble.setLayoutParams(parentParams);
- }
-
- private boolean isMediaPresent(@MediaState int mediaState) {
- return mediaState != MEDIA_STATE_NO_MEDIA;
- }
-
- private boolean isPending(@TransportState int transportState) {
- return transportState == TRANSPORT_STATE_PUSH_PENDING || transportState == TRANSPORT_STATE_SMS_PENDING;
- }
-}
\ No newline at end of file
diff --git a/src/org/thoughtcrime/securesms/components/IncomingBubbleContainer.java b/src/org/thoughtcrime/securesms/components/IncomingBubbleContainer.java
deleted file mode 100644
index d6f054edd2..0000000000
--- a/src/org/thoughtcrime/securesms/components/IncomingBubbleContainer.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/**
- * Copyright (C) 2015 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 .
- */
-package org.thoughtcrime.securesms.components;
-
-import android.content.Context;
-import android.support.annotation.DrawableRes;
-import android.util.AttributeSet;
-import android.util.Log;
-import android.view.LayoutInflater;
-
-import org.thoughtcrime.securesms.R;
-import org.thoughtcrime.securesms.util.ResUtil;
-
-public class IncomingBubbleContainer extends BubbleContainer {
- private static final String TAG = IncomingBubbleContainer.class.getSimpleName();
-
- private static final boolean[] CORNERS_MESSAGE_CAPTIONED = new boolean[]{false, true, true, true };
- private static final boolean[] CORNERS_MEDIA_CAPTIONED = new boolean[]{true, true, true, false};
- private static final boolean[] CORNERS_ROUNDED = new boolean[]{true, true, true, true };
-
- private int foregroundColor;
- private int triangleTickRes;
-
- @SuppressWarnings("UnusedDeclaration")
- public IncomingBubbleContainer(Context context) {
- super(context);
- }
-
- @SuppressWarnings("UnusedDeclaration")
- public IncomingBubbleContainer(Context context, AttributeSet attrs) {
- super(context, attrs);
- }
-
- @SuppressWarnings("UnusedDeclaration")
- public IncomingBubbleContainer(Context context, AttributeSet attrs, int defStyleAttr) {
- super(context, attrs, defStyleAttr);
- }
-
- @SuppressWarnings("UnusedDeclaration")
- public IncomingBubbleContainer(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
- super(context, attrs, defStyleAttr, defStyleRes);
- }
-
- @Override
- protected void onCreateView() {
- Log.w(TAG, "onCreateView()");
- LayoutInflater inflater = LayoutInflater.from(getContext());
- inflater.inflate(R.layout.conversation_bubble_incoming, this, true);
-
- this.foregroundColor = ResUtil.getColor(getContext(), R.attr.conversation_item_received_background);
- this.triangleTickRes = ResUtil.getDrawableRes(getContext(), R.attr.triangle_tick_incoming);
- }
-
- @Override
- protected int getForegroundColor(@TransportState int transportState) {
- return foregroundColor;
- }
-
- @Override
- protected boolean[] getMessageCorners(@MediaState int mediaState) {
- return mediaState == MEDIA_STATE_CAPTIONED ? CORNERS_MESSAGE_CAPTIONED : CORNERS_ROUNDED;
- }
-
- @Override
- protected boolean[] getMediaCorners(@MediaState int mediaState) {
- return mediaState == MEDIA_STATE_CAPTIONED ? CORNERS_MEDIA_CAPTIONED : CORNERS_ROUNDED;
- }
-
- @Override
- protected int getTriangleTickRes(@TransportState int transportState) {
- return triangleTickRes;
- }
-}
diff --git a/src/org/thoughtcrime/securesms/components/OutgoingBubbleContainer.java b/src/org/thoughtcrime/securesms/components/OutgoingBubbleContainer.java
deleted file mode 100644
index 61e94a32e2..0000000000
--- a/src/org/thoughtcrime/securesms/components/OutgoingBubbleContainer.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/**
- * Copyright (C) 2015 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 .
- */
-package org.thoughtcrime.securesms.components;
-
-import android.content.Context;
-import android.content.res.TypedArray;
-import android.support.annotation.DrawableRes;
-import android.util.AttributeSet;
-import android.util.SparseIntArray;
-import android.view.LayoutInflater;
-
-import org.thoughtcrime.securesms.R;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-public class OutgoingBubbleContainer extends BubbleContainer {
- private static final boolean[] CORNERS_MESSAGE_CAPTIONED = new boolean[]{true, false, true, true};
- private static final boolean[] CORNERS_MEDIA_CAPTIONED = new boolean[]{true, true, false, true};
- private static final boolean[] CORNERS_ROUNDED = new boolean[]{true, true, true, true};
-
- private static final int[] TRANSPORT_STYLE_ATTRIBUTES = new int[]{R.attr.conversation_item_sent_push_background,
- R.attr.conversation_item_sent_background,
- R.attr.conversation_item_sent_pending_background,
- R.attr.conversation_item_sent_push_pending_background};
-
- private static final int[] TRIANGLE_TICK_ATTRIBUTES = new int[]{R.attr.triangle_tick_outgoing_sent_push,
- R.attr.triangle_tick_outgoing_sent_sms,
- R.attr.triangle_tick_outgoing_pending_sms,
- R.attr.triangle_tick_outgoing_pending_push};
-
- private static final SparseIntArray TRANSPORT_STYLE_MAP = new SparseIntArray(TRANSPORT_STYLE_ATTRIBUTES.length) {{
- put(TRANSPORT_STATE_PUSH_SENT, 0);
- put(TRANSPORT_STATE_SMS_SENT, 1);
- put(TRANSPORT_STATE_SMS_PENDING, 2);
- put(TRANSPORT_STATE_PUSH_PENDING, 3);
- }};
-
- private TypedArray styledDrawables;
- private TypedArray triangleDrawables;
-
- @SuppressWarnings("UnusedDeclaration")
- public OutgoingBubbleContainer(Context context) {
- super(context);
- }
-
- @SuppressWarnings("UnusedDeclaration")
- public OutgoingBubbleContainer(Context context, AttributeSet attrs) {
- super(context, attrs);
- }
-
- @SuppressWarnings("UnusedDeclaration")
- public OutgoingBubbleContainer(Context context, AttributeSet attrs, int defStyleAttr) {
- super(context, attrs, defStyleAttr);
- }
-
- @SuppressWarnings("UnusedDeclaration")
- public OutgoingBubbleContainer(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
- super(context, attrs, defStyleAttr, defStyleRes);
- }
-
- @Override
- protected void onCreateView() {
- LayoutInflater inflater = LayoutInflater.from(getContext());
- inflater.inflate(R.layout.conversation_bubble_outgoing, this, true);
-
- this.styledDrawables = getContext().obtainStyledAttributes(TRANSPORT_STYLE_ATTRIBUTES);
- this.triangleDrawables = getContext().obtainStyledAttributes(TRIANGLE_TICK_ATTRIBUTES );
- }
-
- @Override
- protected int getForegroundColor(@TransportState int transportState) {
- return styledDrawables.getColor(TRANSPORT_STYLE_MAP.get(transportState), -1);
- }
-
- @Override
- protected boolean[] getMessageCorners(@MediaState int mediaState) {
- return mediaState == MEDIA_STATE_CAPTIONED ? CORNERS_MESSAGE_CAPTIONED : CORNERS_ROUNDED;
- }
-
- @Override
- protected boolean[] getMediaCorners(@MediaState int mediaState) {
- return mediaState == MEDIA_STATE_CAPTIONED ? CORNERS_MEDIA_CAPTIONED : CORNERS_ROUNDED;
- }
-
- @Override
- protected int getTriangleTickRes(@TransportState int transportState) {
- return triangleDrawables.getResourceId(TRANSPORT_STYLE_MAP.get(transportState), -1);
- }
-}
diff --git a/src/org/thoughtcrime/securesms/components/ThumbnailView.java b/src/org/thoughtcrime/securesms/components/ThumbnailView.java
index 5668ffef6f..bf3a875b83 100644
--- a/src/org/thoughtcrime/securesms/components/ThumbnailView.java
+++ b/src/org/thoughtcrime/securesms/components/ThumbnailView.java
@@ -14,11 +14,14 @@ import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
+import android.view.ViewGroup;
+import android.view.ViewParent;
import com.bumptech.glide.GenericRequestBuilder;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestListener;
import com.bumptech.glide.request.target.Target;
+import com.makeramen.roundedimageview.RoundedImageView;
import org.thoughtcrime.securesms.R;
import org.thoughtcrime.securesms.crypto.MasterSecret;
@@ -32,7 +35,7 @@ import org.thoughtcrime.securesms.util.Util;
import ws.com.google.android.mms.pdu.PduPart;
-public class ThumbnailView extends ForegroundImageView {
+public class ThumbnailView extends RoundedImageView {
private ListenableFutureTask slideDeckFuture = null;
private SlideDeckListener slideDeckListener = null;
@@ -96,6 +99,13 @@ public class ThumbnailView extends ForegroundImageView {
if (isContextValid()) Glide.clear(this);
}
+ @Override
+ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ View dv = ((Activity) this.getContext()).getWindow().getDecorView();
+ int size = Math.min(dv.getWidth(), dv.getHeight()) * 55 / 100;
+ setMeasuredDimension(size, size);
+ }
+
@TargetApi(VERSION_CODES.JELLY_BEAN_MR1)
private boolean isContextValid() {
return !(getContext() instanceof Activity) ||
@@ -238,4 +248,5 @@ public class ThumbnailView extends ForegroundImageView {
return false;
}
}
+
}
diff --git a/src/org/thoughtcrime/securesms/database/model/SmsMessageRecord.java b/src/org/thoughtcrime/securesms/database/model/SmsMessageRecord.java
index 0b4d432369..dacb89a695 100644
--- a/src/org/thoughtcrime/securesms/database/model/SmsMessageRecord.java
+++ b/src/org/thoughtcrime/securesms/database/model/SmsMessageRecord.java
@@ -50,7 +50,7 @@ public class SmsMessageRecord extends MessageRecord {
int status, List mismatches)
{
super(context, id, body, recipients, individualRecipient, recipientDeviceId,
- dateSent, dateReceived, threadId, receiptCount, getGenericDeliveryStatus(status), type,
+ dateSent, dateReceived, threadId, getGenericDeliveryStatus(status), receiptCount, type,
mismatches, new LinkedList());
}