aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/main/java/de/pixart/messenger/entities/Message.java8
-rw-r--r--src/main/java/de/pixart/messenger/ui/ConversationFragment.java36
-rw-r--r--src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java8
-rw-r--r--src/main/res/drawable/date_bubble.xml21
-rw-r--r--src/main/res/layout/message_received.xml4
-rw-r--r--src/main/res/layout/message_sent.xml9
-rw-r--r--src/main/res/layout/message_status.xml28
-rw-r--r--src/main/res/values-de/strings.xml2
-rw-r--r--src/main/res/values/colors.xml1
-rw-r--r--src/main/res/values/strings.xml2
10 files changed, 68 insertions, 51 deletions
diff --git a/src/main/java/de/pixart/messenger/entities/Message.java b/src/main/java/de/pixart/messenger/entities/Message.java
index 59073cb77..f6c578e6c 100644
--- a/src/main/java/de/pixart/messenger/entities/Message.java
+++ b/src/main/java/de/pixart/messenger/entities/Message.java
@@ -189,6 +189,14 @@ public class Message extends AbstractEntity {
cursor.getString(cursor.getColumnIndex(ERROR_MESSAGE)));
}
+ public static Message createDateMessage(Conversation conversation, String body) {
+ final Message message = new Message();
+ message.setType(Message.TYPE_STATUS);
+ message.setConversation(conversation);
+ message.setBody(body);
+ return message;
+ }
+
public static Message createStatusMessage(Conversation conversation, String body) {
final Message message = new Message();
message.setType(Message.TYPE_STATUS);
diff --git a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java
index e0b5b7e11..f2127b48e 100644
--- a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java
+++ b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java
@@ -41,9 +41,11 @@ import android.widget.Toast;
import net.java.otr4j.session.SessionStatus;
+import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
+import java.util.Locale;
import java.util.UUID;
import de.pixart.messenger.Config;
@@ -119,6 +121,9 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
private TextView snackbarMessage;
private TextView snackbarAction;
private Toast messageLoaderToast;
+ SimpleDateFormat sdf = new SimpleDateFormat("EEEE, dd. MMM yyyy", Locale.getDefault());
+ String first = sdf.format(System.currentTimeMillis());
+ String today = sdf.format(System.currentTimeMillis());
private OnScrollListener mOnScrollListener = new OnScrollListener() {
@@ -1264,25 +1269,26 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
if (showLoadMoreMessages(conversation)) {
this.messageList.add(0, Message.createLoadMoreMessage(conversation));
}
- if (conversation.getMode() == Conversation.MODE_SINGLE) {
- ChatState state = conversation.getIncomingChatState();
- if (state == ChatState.COMPOSING) {
- //this.messageList.add(Message.createStatusMessage(conversation, getString(R.string.contact_is_typing, conversation.getName())));
- } else if (state == ChatState.PAUSED) {
- //this.messageList.add(Message.createStatusMessage(conversation, getString(R.string.contact_has_stopped_typing, conversation.getName())));
- } else {
- for (int i = this.messageList.size() - 1; i >= 0; --i) {
- if (this.messageList.get(i).getStatus() == Message.STATUS_RECEIVED) {
- return;
- } else {
- if (this.messageList.get(i).getStatus() == Message.STATUS_SEND_DISPLAYED) {
-// this.messageList.add(i + 1,
-// Message.createStatusMessage(conversation, getString(R.string.contact_has_read_up_to_this_point, conversation.getName())));
-// return;
+
+ // show date in chat view
+ int max = this.messageList.size();
+ if (max == 0 || (max <= 1 && showLoadMoreMessages(conversation))){
+ this.messageList.add(0, Message.createDateMessage(conversation, getString(R.string.start_chatting)));
+ } else if ((max > 0 && !showLoadMoreMessages(conversation)) || (max > 1 && showLoadMoreMessages(conversation))) {
+ for (int i = (max - 1); i > 0; --i) {
+ String last = sdf.format(this.messageList.get(i).getTimeSent());
+ String date = first;
+ if (!last.equals(first)) {
+ if (i < (max - 1)) {
+ if (today.equals(first)) {
+ date = getString(R.string.today);
}
+ this.messageList.add(i + 1, Message.createDateMessage(conversation, date));
}
}
+ first = last;
}
+ this.messageList.add(0, Message.createDateMessage(conversation, first));
}
}
}
diff --git a/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java b/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java
index fa65b3af6..b71e98032 100644
--- a/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java
+++ b/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java
@@ -808,7 +808,6 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie
if (type == STATUS) {
if ("LOAD_MORE".equals(message.getBody())) {
viewHolder.status_message.setVisibility(View.GONE);
- viewHolder.contact_picture.setVisibility(View.GONE);
viewHolder.load_more_messages.setVisibility(View.VISIBLE);
viewHolder.load_more_messages.setOnClickListener(new OnClickListener() {
@Override
@@ -818,14 +817,7 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie
});
} else {
viewHolder.status_message.setVisibility(View.VISIBLE);
- viewHolder.contact_picture.setVisibility(View.VISIBLE);
viewHolder.load_more_messages.setVisibility(View.GONE);
- if (conversation.getMode() == Conversation.MODE_SINGLE) {
- viewHolder.contact_picture.setImageBitmap(activity
- .avatarService().get(conversation.getContact(),
- activity.getPixel(32)));
- viewHolder.contact_picture.setAlpha(0.5f);
- }
viewHolder.status_message.setText(message.getBody());
}
return view;
diff --git a/src/main/res/drawable/date_bubble.xml b/src/main/res/drawable/date_bubble.xml
new file mode 100644
index 000000000..3edf349e9
--- /dev/null
+++ b/src/main/res/drawable/date_bubble.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
+ <corners
+ android:topLeftRadius="5dp"
+ android:topRightRadius="5dp"
+ android:bottomRightRadius="5dp"
+ android:bottomLeftRadius="5dp">
+ </corners>
+ <padding
+ android:bottom="6dp"
+ android:left="6dp"
+ android:right="6dp"
+ android:top="6dp" />
+ <stroke
+ android:width="1dp"
+ android:color="@color/grey500">
+ </stroke>
+ <solid
+ android:color="@color/lightgreen">
+ </solid>
+</shape> \ No newline at end of file
diff --git a/src/main/res/layout/message_received.xml b/src/main/res/layout/message_received.xml
index 45808695e..57279bde8 100644
--- a/src/main/res/layout/message_received.xml
+++ b/src/main/res/layout/message_received.xml
@@ -30,10 +30,8 @@
android:layout_toRightOf="@+id/message_photo"
android:minHeight="48dp"
android:longClickable="true"
- android:layout_marginBottom="4dp"
android:layout_marginLeft="4dp"
- android:layout_marginRight="4dp"
- android:layout_marginTop="-4dp">
+ android:layout_marginRight="4dp">
<LinearLayout
android:layout_width="wrap_content"
diff --git a/src/main/res/layout/message_sent.xml b/src/main/res/layout/message_sent.xml
index b45da4470..d37d418bf 100644
--- a/src/main/res/layout/message_sent.xml
+++ b/src/main/res/layout/message_sent.xml
@@ -27,14 +27,13 @@
android:id="@+id/message_box"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_alignParentBottom="true"
- android:layout_toLeftOf="@+id/message_photo"
android:minHeight="48dp"
android:longClickable="true"
- android:layout_marginBottom="0dp"
+ android:layout_alignParentBottom="true"
+ android:layout_toLeftOf="@+id/message_photo"
+ android:layout_toStartOf="@+id/message_photo"
android:layout_marginLeft="4dp"
- android:layout_marginRight="4dp"
- android:layout_marginTop="4dp" >
+ android:layout_marginRight="4dp">
<LinearLayout
android:layout_width="wrap_content"
diff --git a/src/main/res/layout/message_status.xml b/src/main/res/layout/message_status.xml
index 117f31264..211f1a2e7 100644
--- a/src/main/res/layout/message_status.xml
+++ b/src/main/res/layout/message_status.xml
@@ -19,30 +19,18 @@
android:layout_centerVertical="true"
android:layout_centerHorizontal="true" />
- <com.makeramen.roundedimageview.RoundedImageView
- android:id="@+id/message_photo"
- android:layout_width="32dp"
- android:layout_height="32dp"
- android:layout_alignParentLeft="true"
- android:layout_alignParentTop="true"
- android:layout_marginRight="-1.5dp"
- android:padding="1dp"
- android:scaleType="fitXY"
- android:src="@drawable/ic_profile"
- android:background="@drawable/message_border"
- app:riv_corner_radius="5dp" />
-
<TextView
android:id="@+id/status_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_centerVertical="true"
- android:layout_marginLeft="8dp"
- android:layout_toEndOf="@+id/message_photo"
- android:layout_toRightOf="@+id/message_photo"
- android:text="@string/contact_has_read_up_to_this_point"
- android:textColor="@color/black54"
+ android:text="01.01.2017"
+ android:textColor="@color/black87"
android:textSize="?attr/TextSizeInfo"
- android:textStyle="italic" />
+ android:textStyle="italic"
+ android:background="@drawable/date_bubble"
+ android:layout_alignBaseline="@+id/load_more_messages"
+ android:layout_alignBottom="@+id/load_more_messages"
+ android:layout_centerHorizontal="true"
+ android:layout_margin="8dp" />
</RelativeLayout> \ No newline at end of file
diff --git a/src/main/res/values-de/strings.xml b/src/main/res/values-de/strings.xml
index 904a9924a..eb6af903e 100644
--- a/src/main/res/values-de/strings.xml
+++ b/src/main/res/values-de/strings.xml
@@ -688,5 +688,7 @@
<string name="timeout_30_days">30 Tage</string>
<string name="timeout_6_months">6 Monate</string>
<string name="timeout_7_days">7 Tage</string>
+ <string name="today">Heute</string>
+ <string name="start_chatting">Fange an zu schreiben…</string>
</resources>
diff --git a/src/main/res/values/colors.xml b/src/main/res/values/colors.xml
index 6a3d28c63..33d047d4c 100644
--- a/src/main/res/values/colors.xml
+++ b/src/main/res/values/colors.xml
@@ -21,4 +21,5 @@
<color name="darkwhite">#ffe6e6e6</color>
<color name="lightblue">#ffc7d1e8</color>
<color name="lightred">#ffd55555</color>
+ <color name="lightgreen">#ffb0ecaf</color>
</resources>
diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml
index 06cc6f7e4..bdd6c6fb7 100644
--- a/src/main/res/values/strings.xml
+++ b/src/main/res/values/strings.xml
@@ -737,4 +737,6 @@
<string name="timeout_7_days">7 days</string>
<string name="timeout_30_days">30 days</string>
<string name="timeout_6_months">6 months</string>
+ <string name="today">Today</string>
+ <string name="start_chatting">Start chtatting…</string>
</resources>