Display files in new chat bubble

This commit is contained in:
Sylvain Berfini 2018-11-23 17:24:45 +01:00
parent b9e424a2de
commit 6035ea2732
3 changed files with 36 additions and 19 deletions

View file

@ -69,7 +69,7 @@ public class ChatMessageViewHolder extends RecyclerView.ViewHolder implements Vi
public View rightAnchor;
public RelativeLayout bubbleLayout;
public RelativeLayout background;
public LinearLayout background;
public RelativeLayout avatarLayout;
public ProgressBar sendInProgress;
@ -211,19 +211,23 @@ public class ChatMessageViewHolder extends RecyclerView.ViewHolder implements Vi
String filePath = c.getFilePath();
View content = LayoutInflater.from(mContext).inflate(R.layout.chat_bubble_content, null, false);
View v;
if (FileUtils.isExtensionImage(filePath)) {
ImageView iv = content.findViewById(R.id.image);
iv.setImageURI(Uri.parse(c.getFilePath()));
iv.setTag(c.getFilePath());
iv.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
openFile((String) v.getTag());
}
});
v = content.findViewById(R.id.image);
((ImageView)v).setImageURI(Uri.parse(c.getFilePath()));
} else {
//TODO: display file name and extension ?
v = content.findViewById(R.id.file);
((TextView)v).setText(FileUtils.getNameFromFilePath(filePath));
}
v.setVisibility(View.VISIBLE);
v.setTag(c.getFilePath());
v.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
openFile((String) v.getTag());
}
});
pictures.addView(content);
} else {
//TODO: download button if incoming

View file

@ -97,7 +97,7 @@
android:layout_height="wrap_content"
android:layout_toLeftOf="@id/rightAnchor">
<RelativeLayout
<LinearLayout
android:id="@+id/background"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@ -108,7 +108,8 @@
android:layout_below="@+id/time"
android:layout_toLeftOf="@+id/imdn"
android:paddingBottom="5dp"
android:paddingTop="5dp">
android:paddingTop="5dp"
android:orientation="vertical">
<com.google.android.flexbox.FlexboxLayout
xmlns:app="http://schemas.android.com/apk/res-auto"
@ -127,10 +128,9 @@
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:layout_below="@id/pictures"/>
android:layout_marginBottom="5dp"/>
</RelativeLayout>
</LinearLayout>
<RelativeLayout
android:id="@+id/message_sender_avatar"

View file

@ -1,13 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp">
android:layout_height="wrap_content">
<ImageView
android:id="@+id/image"
android:visibility="gone"
android:adjustViewBounds="true"
android:layout_width="wrap_content"
android:layout_height="100dp"/>
android:layout_height="100dp"
android:layout_margin="5dp"/>
<TextView
android:id="@+id/file"
android:visibility="gone"
android:textAlignment="center"
android:gravity="center"
style="@style/chat_bubble_file_name_font"
android:background="@color/colorN"
android:ellipsize="end"
android:layout_width="150dp"
android:layout_height="100dp"
android:layout_margin="5dp"/>
</RelativeLayout>