diff --git a/res/drawable/conversation_item_sent_pending_shape.xml b/res/drawable/conversation_item_sent_pending_shape.xml
new file mode 100644
index 0000000000..f1be25bf4f
--- /dev/null
+++ b/res/drawable/conversation_item_sent_pending_shape.xml
@@ -0,0 +1,19 @@
+
+
+
+ -
+
+
+
+
+
+
+ -
+
+
+
+
+
+
+
+
diff --git a/res/drawable/conversation_item_sent_pending_shape_dark.xml b/res/drawable/conversation_item_sent_pending_shape_dark.xml
new file mode 100644
index 0000000000..5164247f12
--- /dev/null
+++ b/res/drawable/conversation_item_sent_pending_shape_dark.xml
@@ -0,0 +1,19 @@
+
+
+
+ -
+
+
+
+
+
+
+ -
+
+
+
+
+
+
+
+
diff --git a/res/drawable/conversation_item_sent_pending_triangle_shape.xml b/res/drawable/conversation_item_sent_pending_triangle_shape.xml
new file mode 100644
index 0000000000..279720e4b2
--- /dev/null
+++ b/res/drawable/conversation_item_sent_pending_triangle_shape.xml
@@ -0,0 +1,16 @@
+
+
+ -
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/res/drawable/conversation_item_sent_pending_triangle_shape_dark.xml b/res/drawable/conversation_item_sent_pending_triangle_shape_dark.xml
new file mode 100644
index 0000000000..c29b2e29ea
--- /dev/null
+++ b/res/drawable/conversation_item_sent_pending_triangle_shape_dark.xml
@@ -0,0 +1,16 @@
+
+
+ -
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/res/drawable/conversation_item_sent_push_pending_shape.xml b/res/drawable/conversation_item_sent_push_pending_shape.xml
new file mode 100644
index 0000000000..a7afe1aed7
--- /dev/null
+++ b/res/drawable/conversation_item_sent_push_pending_shape.xml
@@ -0,0 +1,18 @@
+
+
+
+ -
+
+
+
+
+
+
+ -
+
+
+
+
+
+
+
diff --git a/res/drawable/conversation_item_sent_push_pending_shape_dark.xml b/res/drawable/conversation_item_sent_push_pending_shape_dark.xml
new file mode 100644
index 0000000000..acdc77dcc6
--- /dev/null
+++ b/res/drawable/conversation_item_sent_push_pending_shape_dark.xml
@@ -0,0 +1,18 @@
+
+
+
+ -
+
+
+
+
+
+
+ -
+
+
+
+
+
+
+
diff --git a/res/drawable/conversation_item_sent_push_pending_triangle_shape.xml b/res/drawable/conversation_item_sent_push_pending_triangle_shape.xml
new file mode 100644
index 0000000000..8cf5b43ba2
--- /dev/null
+++ b/res/drawable/conversation_item_sent_push_pending_triangle_shape.xml
@@ -0,0 +1,16 @@
+
+
+ -
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/res/drawable/conversation_item_sent_push_pending_triangle_shape_dark.xml b/res/drawable/conversation_item_sent_push_pending_triangle_shape_dark.xml
new file mode 100644
index 0000000000..0992b4e378
--- /dev/null
+++ b/res/drawable/conversation_item_sent_push_pending_triangle_shape_dark.xml
@@ -0,0 +1,16 @@
+
+
+ -
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/res/layout/conversation_item_sent.xml b/res/layout/conversation_item_sent.xml
index c566c16c5f..b1130e963a 100644
--- a/res/layout/conversation_item_sent.xml
+++ b/res/layout/conversation_item_sent.xml
@@ -148,6 +148,7 @@
android:autoLink="none"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
+ android:minWidth="15sp"
android:linksClickable="false"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_gravity="right"
diff --git a/res/values/attrs.xml b/res/values/attrs.xml
index 178fffcc12..aae29431d1 100644
--- a/res/values/attrs.xml
+++ b/res/values/attrs.xml
@@ -33,10 +33,14 @@
+
+
+
+
@@ -67,4 +71,4 @@
-
\ No newline at end of file
+
diff --git a/res/values/colors.xml b/res/values/colors.xml
index 38a561c38c..0d096526d3 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -15,8 +15,12 @@
#ff284e0a
#ff64a926
+ #5564A926
+ #55284e0a
#ff3a7ef2
#ff213b77
+ #ff7bacf2
+ #55213b77
#ff284e0a
#ff284e0a
\ No newline at end of file
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 8ee7498b87..afb2fa8019 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -47,7 +47,6 @@
Message size: %d KB
Expires: %s
Error sending message
- Sending...
Saving Attachment
Saving attachment to SD card...
Save to SD Card?
diff --git a/res/values/themes.xml b/res/values/themes.xml
index 8c76fba9c3..d32a9a2c06 100644
--- a/res/values/themes.xml
+++ b/res/values/themes.xml
@@ -41,6 +41,10 @@
- @drawable/conversation_item_sent_push_triangle_shape
- @drawable/ic_dialog_info_light
- @drawable/ic_dialog_alert_light
+ - @drawable/conversation_item_sent_pending_shape
+ - @drawable/conversation_item_sent_pending_triangle_shape
+ - @drawable/conversation_item_sent_push_pending_shape
+ - @drawable/conversation_item_sent_push_pending_triangle_shape
- @drawable/ic_action_new_holo_light
- @drawable/ic_action_add_group_holo_light
@@ -98,6 +102,10 @@
- @drawable/conversation_item_sent_push_triangle_shape_dark
- @drawable/ic_dialog_info_dark
- @drawable/ic_dialog_alert_dark
+ - @drawable/conversation_item_sent_pending_shape_dark
+ - @drawable/conversation_item_sent_pending_triangle_shape_dark
+ - @drawable/conversation_item_sent_push_pending_shape_dark
+ - @drawable/conversation_item_sent_push_pending_triangle_shape_dark
- @drawable/actionbar_icon_holo_dark
- @drawable/divet_lower_right_light
@@ -163,4 +171,4 @@
- 16dip
-
\ No newline at end of file
+
diff --git a/src/org/thoughtcrime/securesms/ConversationAdapter.java b/src/org/thoughtcrime/securesms/ConversationAdapter.java
index 3cd7cd6af9..47fca05329 100644
--- a/src/org/thoughtcrime/securesms/ConversationAdapter.java
+++ b/src/org/thoughtcrime/securesms/ConversationAdapter.java
@@ -61,16 +61,18 @@ public class ConversationAdapter extends CursorAdapter implements AbsListView.Re
private final Context context;
private final MasterSecret masterSecret;
private final boolean groupThread;
+ private final boolean pushDestination;
private final LayoutInflater inflater;
public ConversationAdapter(Context context, MasterSecret masterSecret,
- Handler failedIconClickHandler, boolean groupThread)
+ Handler failedIconClickHandler, boolean groupThread, boolean pushDestination)
{
super(context, null);
this.context = context;
this.masterSecret = masterSecret;
this.failedIconClickHandler = failedIconClickHandler;
this.groupThread = groupThread;
+ this.pushDestination = pushDestination;
this.inflater = (LayoutInflater)context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
@@ -82,7 +84,7 @@ public class ConversationAdapter extends CursorAdapter implements AbsListView.Re
String type = cursor.getString(cursor.getColumnIndexOrThrow(MmsSmsDatabase.TRANSPORT));
MessageRecord messageRecord = getMessageRecord(id, cursor, type);
- item.set(masterSecret, messageRecord, failedIconClickHandler, groupThread);
+ item.set(masterSecret, messageRecord, failedIconClickHandler, groupThread, pushDestination);
}
@Override
diff --git a/src/org/thoughtcrime/securesms/ConversationFragment.java b/src/org/thoughtcrime/securesms/ConversationFragment.java
index 770bccf997..e7c248ecd1 100644
--- a/src/org/thoughtcrime/securesms/ConversationFragment.java
+++ b/src/org/thoughtcrime/securesms/ConversationFragment.java
@@ -21,6 +21,8 @@ import android.widget.CursorAdapter;
import com.actionbarsherlock.app.SherlockListFragment;
import org.thoughtcrime.securesms.recipients.RecipientFactory;
+import org.thoughtcrime.securesms.util.DirectoryHelper;
+import org.thoughtcrime.securesms.util.Util;
import org.whispersystems.textsecure.crypto.MasterSecret;
import org.thoughtcrime.securesms.database.DatabaseFactory;
import org.thoughtcrime.securesms.database.loaders.ConversationLoader;
@@ -197,7 +199,8 @@ public class ConversationFragment extends SherlockListFragment
if (this.recipients != null && this.threadId != -1) {
this.setListAdapter(new ConversationAdapter(getActivity(), masterSecret,
new FailedIconClickHandler(),
- (!this.recipients.isSingleRecipient()) || this.recipients.isGroupRecipient()));
+ (!this.recipients.isSingleRecipient()) || this.recipients.isGroupRecipient(),
+ DirectoryHelper.isPushDestination(getActivity(), this.recipients.getPrimaryRecipient())));
getListView().setRecyclerListener((ConversationAdapter)getListAdapter());
getLoaderManager().initLoader(0, null, this);
}
diff --git a/src/org/thoughtcrime/securesms/ConversationItem.java b/src/org/thoughtcrime/securesms/ConversationItem.java
index 50992e0b0d..c3665b86a0 100644
--- a/src/org/thoughtcrime/securesms/ConversationItem.java
+++ b/src/org/thoughtcrime/securesms/ConversationItem.java
@@ -25,6 +25,8 @@ import android.content.res.TypedArray;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.media.MediaScannerConnection;
+import android.net.ConnectivityManager;
+import android.net.NetworkInfo;
import android.net.Uri;
import android.os.Build;
import android.os.Environment;
@@ -55,6 +57,8 @@ import org.thoughtcrime.securesms.util.DateUtils;
import org.thoughtcrime.securesms.util.Emoji;
import org.thoughtcrime.securesms.util.Dialogs;
import org.whispersystems.textsecure.crypto.MasterSecret;
+import org.whispersystems.textsecure.directory.Directory;
+import org.whispersystems.textsecure.directory.NotInDirectoryException;
import org.whispersystems.textsecure.storage.Session;
import org.whispersystems.textsecure.util.FutureTaskListener;
import org.whispersystems.textsecure.util.ListenableFutureTask;
@@ -79,12 +83,26 @@ public class ConversationItem extends LinearLayout {
private final int STYLE_ATTRIBUTES[] = new int[]{R.attr.conversation_item_sent_push_background,
R.attr.conversation_item_sent_push_triangle_background,
R.attr.conversation_item_sent_background,
- R.attr.conversation_item_sent_triangle_background};
+ R.attr.conversation_item_sent_triangle_background,
+ R.attr.conversation_item_sent_pending_background,
+ R.attr.conversation_item_sent_pending_triangle_background,
+ R.attr.conversation_item_sent_push_pending_background,
+ R.attr.conversation_item_sent_push_pending_triangle_background};
+
+ private final static int SENT_PUSH = 0;
+ private final static int SENT_PUSH_TRIANGLE = 1;
+ private final static int SENT_SMS = 2;
+ private final static int SENT_SMS_TRIANGLE = 3;
+ private final static int SENT_SMS_PENDING = 4;
+ private final static int SENT_SMS_PENDING_TRIANGLE = 5;
+ private final static int SENT_PUSH_PENDING = 6;
+ private final static int SENT_PUSH_PENDING_TRIANGLE = 7;
private Handler failedIconHandler;
private MessageRecord messageRecord;
private MasterSecret masterSecret;
private boolean groupThread;
+ private boolean pushDestination;
private View conversationParent;
private TextView bodyText;
@@ -145,15 +163,16 @@ public class ConversationItem extends LinearLayout {
}
public void set(MasterSecret masterSecret, MessageRecord messageRecord,
- Handler failedIconHandler, boolean groupThread)
+ Handler failedIconHandler, boolean groupThread, boolean pushDestination)
{
-
this.messageRecord = messageRecord;
this.masterSecret = masterSecret;
this.failedIconHandler = failedIconHandler;
this.groupThread = groupThread;
+ this.pushDestination = pushDestination;
+ setBackgroundDrawables(messageRecord);
setBodyText(messageRecord);
if (!messageRecord.isGroupAction()) {
@@ -194,17 +213,31 @@ public class ConversationItem extends LinearLayout {
/// MessageRecord Attribute Parsers
- private void setBodyText(MessageRecord messageRecord) {
-
+ private void setBackgroundDrawables(MessageRecord messageRecord) {
if (conversationParent != null && backgroundDrawables != null) {
- if (messageRecord.isPush() && messageRecord.isOutgoing()) {
- setViewBackgroundWithoutResettingPadding(conversationParent, backgroundDrawables.getResourceId(0, -1));
- setViewBackgroundWithoutResettingPadding(findViewById(R.id.triangle_tick), backgroundDrawables.getResourceId(1, -1));
- } else if (messageRecord.isOutgoing()) {
- setViewBackgroundWithoutResettingPadding(conversationParent, backgroundDrawables.getResourceId(2, -1));
- setViewBackgroundWithoutResettingPadding(findViewById(R.id.triangle_tick), backgroundDrawables.getResourceId(3, -1));
+ if (messageRecord.isOutgoing()) {
+ final int background;
+ final int triangleBackground;
+ if (messageRecord.isPending() && pushDestination) {
+ background = SENT_PUSH_PENDING;
+ triangleBackground = SENT_PUSH_PENDING_TRIANGLE;
+ } else if (messageRecord.isPending()) {
+ background = SENT_SMS_PENDING;
+ triangleBackground = SENT_SMS_PENDING_TRIANGLE;
+ } else if (messageRecord.isPush()) {
+ background = SENT_PUSH;
+ triangleBackground = SENT_PUSH_TRIANGLE;
+ } else {
+ background = SENT_SMS;
+ triangleBackground = SENT_SMS_TRIANGLE;
+ }
+ setViewBackgroundWithoutResettingPadding(conversationParent, backgroundDrawables.getResourceId(background, -1));
+ setViewBackgroundWithoutResettingPadding(findViewById(R.id.triangle_tick), backgroundDrawables.getResourceId(triangleBackground, -1));
}
}
+ }
+
+ private void setBodyText(MessageRecord messageRecord) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
bodyText.setText(Emoji.getInstance(context).emojify(messageRecord.getDisplayBody(), Emoji.EMOJI_LARGE),
@@ -233,7 +266,7 @@ public class ConversationItem extends LinearLayout {
if (messageRecord.isFailed()) {
dateText.setText(R.string.ConversationItem_error_sending_message);
} else if (messageRecord.isPending()) {
- dateText.setText(R.string.ConversationItem_sending);
+ dateText.setText(" ยทยทยท ");
} else {
final long timestamp = (messageRecord.isOutgoing() ?
messageRecord.getDateSent() :
diff --git a/src/org/thoughtcrime/securesms/service/SmsSender.java b/src/org/thoughtcrime/securesms/service/SmsSender.java
index 197d8c7876..8d7b328edc 100644
--- a/src/org/thoughtcrime/securesms/service/SmsSender.java
+++ b/src/org/thoughtcrime/securesms/service/SmsSender.java
@@ -119,10 +119,9 @@ public class SmsSender {
Cursor cursor = database.getMessage(messageId);
SmsDatabase.Reader reader = database.readerFor(cursor);
- database.markAsSent(messageId);
-
- if (upgraded) database.markAsSecure(messageId);
if (push) database.markAsPush(messageId);
+ if (upgraded) database.markAsSecure(messageId);
+ database.markAsSent(messageId);
SmsMessageRecord record = reader.getNext();
diff --git a/src/org/thoughtcrime/securesms/util/DirectoryHelper.java b/src/org/thoughtcrime/securesms/util/DirectoryHelper.java
index 604bf48bef..b8a86275b8 100644
--- a/src/org/thoughtcrime/securesms/util/DirectoryHelper.java
+++ b/src/org/thoughtcrime/securesms/util/DirectoryHelper.java
@@ -1,18 +1,23 @@
package org.thoughtcrime.securesms.util;
import android.content.Context;
+import android.util.Log;
import org.thoughtcrime.securesms.push.PushServiceSocketFactory;
+import org.thoughtcrime.securesms.recipients.Recipient;
import org.whispersystems.textsecure.directory.Directory;
+import org.whispersystems.textsecure.directory.NotInDirectoryException;
import org.whispersystems.textsecure.push.ContactTokenDetails;
import org.whispersystems.textsecure.push.PushServiceSocket;
import org.whispersystems.textsecure.util.DirectoryUtil;
+import org.whispersystems.textsecure.util.InvalidNumberException;
import java.util.List;
import java.util.Map;
import java.util.Set;
public class DirectoryHelper {
+ private static final String TAG = DirectoryHelper.class.getSimpleName();
public static void refreshDirectory(final Context context) {
refreshDirectory(context, PushServiceSocketFactory.create(context));
@@ -38,4 +43,21 @@ public class DirectoryHelper {
directory.setNumbers(activeTokens, eligibleContactNumbers);
}
}
+
+ public static boolean isPushDestination(Context context, Recipient recipient) {
+ try {
+ if (!TextSecurePreferences.isPushRegistered(context)) return false;
+ if (GroupUtil.isEncodedGroup(recipient.getNumber())) return true;
+
+ String number = recipient.getNumber();
+ String e164number = Util.canonicalizeNumber(context, number);
+
+ return Directory.getInstance(context).isActiveNumber(e164number);
+ } catch (InvalidNumberException e) {
+ Log.w(TAG, e);
+ return false;
+ } catch (NotInDirectoryException e) {
+ return false;
+ }
+ }
}