aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsteckbrief <steckbrief@chefmail.de>2020-04-11 16:38:52 +0200
committersteckbrief <steckbrief@chefmail.de>2020-04-11 16:38:52 +0200
commitde3b30bb34105d74c8a5277edabcbc8bfb65bcc5 (patch)
tree6d76b5870bfc1ed471bef93b25016cb49b5c7a5b
parent25434a72dcdd9653130950802a8346fd487ac1c5 (diff)
Implements FS#309: Rework display of /me messages - Variante 1
-rw-r--r--src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java26
-rw-r--r--src/piratx/res/drawable/mecmd_message_border.xml15
-rw-r--r--src/piratx/res/layout/message_mecmd.xml110
-rw-r--r--src/piratx/res/values/dimens.xml3
4 files changed, 152 insertions, 2 deletions
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 9c6cb5ac9..7e204b665 100644
--- a/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java
+++ b/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java
@@ -46,6 +46,7 @@ import java.util.Locale;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import de.pixart.messenger.BuildConfig;
import de.pixart.messenger.Config;
import de.pixart.messenger.R;
import de.pixart.messenger.crypto.axolotl.FingerprintStatus;
@@ -100,6 +101,7 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie
private static final int RECEIVED = 1;
private static final int STATUS = 2;
private static final int DATE_SEPARATOR = 3;
+ private static final int VIEWTYPE_ME_COMMAND = 4;
boolean isResendable = false;
@@ -165,10 +167,13 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie
@Override
public int getViewTypeCount() {
- return 4;
+ return 5;
}
private int getItemViewType(Message message) {
+ if (BuildConfig.FLAVOR_distribution.equalsIgnoreCase("piratx") && message.hasMeCommand()) {
+ return VIEWTYPE_ME_COMMAND;
+ }
if (message.getType() == Message.TYPE_STATUS) {
if (DATE_SEPARATOR_BODY.equals(message.getBody())) {
return DATE_SEPARATOR;
@@ -962,6 +967,23 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie
viewHolder.status_message = view.findViewById(R.id.status_message);
viewHolder.load_more_messages = view.findViewById(R.id.load_more_messages);
break;
+ case VIEWTYPE_ME_COMMAND:
+ view = activity.getLayoutInflater().inflate(R.layout.message_mecmd, parent, false);
+ viewHolder.message_box = view.findViewById(R.id.message_box);
+ viewHolder.contact_picture = view.findViewById(R.id.message_photo);
+ viewHolder.messageBody = view.findViewById(R.id.message_body);
+ viewHolder.time = view.findViewById(R.id.message_time);
+ viewHolder.indicator = view.findViewById(R.id.security_indicator);
+ viewHolder.indicatorReceived = view.findViewById(R.id.indicator_received);
+ viewHolder.encryption = view.findViewById(R.id.message_encryption);
+ viewHolder.audioPlayer = view.findViewById(R.id.audio_player);
+ viewHolder.download_button = view.findViewById(R.id.download_button);
+ viewHolder.image = view.findViewById(R.id.message_image);
+ viewHolder.gifImage = view.findViewById(R.id.message_image_gif);
+ viewHolder.richlinkview = view.findViewById(R.id.richLinkView);
+ viewHolder.indicatorReceived = view.findViewById(R.id.indicator_received);
+ viewHolder.indicatorRead = view.findViewById(R.id.indicator_read);
+ break;
default:
throw new AssertionError("Unknown view type");
}
@@ -1018,7 +1040,7 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie
}
return view;
} else {
- if (message.getStatus() > Message.STATUS_RECEIVED) {
+ if (message.getStatus() > Message.STATUS_RECEIVED && !message.hasMeCommand()) {
view.findViewById(R.id.placeholder).setVisibility(View.GONE);
viewHolder.contact_picture.setVisibility(View.GONE);
} else {
diff --git a/src/piratx/res/drawable/mecmd_message_border.xml b/src/piratx/res/drawable/mecmd_message_border.xml
new file mode 100644
index 000000000..990d02886
--- /dev/null
+++ b/src/piratx/res/drawable/mecmd_message_border.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+ android:shape="rectangle" >
+
+ <corners android:radius="2dp" />
+
+ <padding
+ android:bottom="1.5dp"
+ android:left="1.5dp"
+ android:right="1.5dp"
+ android:top="1.5dp" />
+
+ <solid android:color="@color/black12" />
+
+</shape> \ No newline at end of file
diff --git a/src/piratx/res/layout/message_mecmd.xml b/src/piratx/res/layout/message_mecmd.xml
new file mode 100644
index 000000000..7d30439b6
--- /dev/null
+++ b/src/piratx/res/layout/message_mecmd.xml
@@ -0,0 +1,110 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ android:paddingStart="8dp"
+ android:paddingLeft="8dp"
+ android:paddingTop="3dp"
+ android:paddingEnd="8dp"
+ android:paddingRight="8dp"
+ android:paddingBottom="3dp">
+
+ <com.makeramen.roundedimageview.RoundedImageView
+ android:id="@+id/message_photo"
+ android:layout_width="@dimen/msg_mecmd_avatar_size"
+ android:layout_height="@dimen/msg_mecmd_avatar_size"
+ android:layout_alignParentStart="true"
+ android:layout_alignParentLeft="true"
+ android:layout_alignParentTop="true"
+ android:scaleType="fitXY"
+ app:riv_corner_radius="@dimen/rounded_image_border" />
+
+ <LinearLayout
+ android:id="@+id/message_box"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentBottom="true"
+ android:layout_marginStart="4dp"
+ android:layout_marginLeft="4dp"
+ android:layout_marginEnd="4dp"
+ android:layout_marginRight="4dp"
+ android:layout_toEndOf="@+id/message_photo"
+ android:layout_toRightOf="@+id/message_photo"
+ android:background="@drawable/message_bubble_received_light"
+ android:longClickable="true"
+ android:minHeight="48dp">
+
+ <LinearLayout
+ android:layout_width="wrap_content"
+ android:layout_height="fill_parent"
+ android:gravity="center_vertical"
+ android:orientation="vertical"
+ android:padding="2dp">
+
+ <include layout="@layout/message_content" />
+
+ <LinearLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="start"
+ android:orientation="horizontal"
+ android:paddingBottom="2dp">
+
+ <TextView
+ android:id="@+id/message_encryption"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_vertical"
+ android:layout_marginEnd="4sp"
+ android:layout_marginRight="4sp"
+ android:gravity="center_vertical"
+ android:textAppearance="@style/TextAppearance.Conversations.Caption.OnDark.Bold" />
+
+ <ImageView
+ android:id="@+id/security_indicator"
+ android:layout_width="?attr/TextSizeCaption"
+ android:layout_height="?attr/TextSizeCaption"
+ android:layout_gravity="center_vertical"
+ android:layout_marginEnd="4sp"
+ android:layout_marginRight="4sp"
+ android:alpha="0.70"
+ android:gravity="center_vertical"
+ android:src="@drawable/ic_lock_black_18dp" />
+
+ <TextView
+ android:id="@+id/message_time"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_vertical"
+ android:gravity="center_vertical"
+ android:text="@string/sending"
+ android:textAppearance="@style/TextAppearance.Conversations.Caption" />
+
+ <ImageView
+ android:id="@+id/indicator_received"
+ android:layout_width="?attr/TextSizeCaption"
+ android:layout_height="?attr/TextSizeCaption"
+ android:layout_gravity="center_vertical"
+ android:layout_marginStart="4sp"
+ android:layout_marginLeft="4sp"
+ android:gravity="center_vertical"
+ android:src="@drawable/ic_received_indicator"
+ android:visibility="gone" />
+
+ <ImageView
+ android:id="@+id/indicator_read"
+ android:layout_width="?attr/TextSizeCaption"
+ android:layout_height="?attr/TextSizeCaption"
+ android:layout_gravity="center_vertical"
+ android:layout_marginStart="-8sp"
+ android:layout_marginLeft="-8sp"
+ android:adjustViewBounds="false"
+ android:gravity="center_vertical"
+ android:src="@drawable/ic_read_indicator"
+ android:visibility="gone" />
+ </LinearLayout>
+ </LinearLayout>
+ </LinearLayout>
+</RelativeLayout>
diff --git a/src/piratx/res/values/dimens.xml b/src/piratx/res/values/dimens.xml
new file mode 100644
index 000000000..d33303c8d
--- /dev/null
+++ b/src/piratx/res/values/dimens.xml
@@ -0,0 +1,3 @@
+<resources>
+ <dimen name="msg_mecmd_avatar_size">24dp</dimen>
+</resources>