Skip to content

Commit 603f233

Browse files
committed
Added show attachments in the message. Without actions. | #55.
1 parent 1fc62c8 commit 603f233

File tree

10 files changed

+103
-0
lines changed

10 files changed

+103
-0
lines changed

FlowCrypt/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ dependencies {
115115
compile "com.android.support:appcompat-v7:${ANDROID_SUPPORT_VERSION}"
116116
compile "com.android.support:design:${ANDROID_SUPPORT_VERSION}"
117117
compile "com.android.support:preference-v14:${ANDROID_SUPPORT_VERSION}"
118+
compile "com.android.support:cardview-v7:${ANDROID_SUPPORT_VERSION}"
118119
compile 'com.android.support.constraint:constraint-layout:1.0.2'
119120

120121
compile "com.google.android.gms:play-services-base:${PLAY_SERVICES_VERSION}"

FlowCrypt/src/main/java/com/flowcrypt/email/api/email/model/AttachmentInfo.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,15 @@ public void writeToParcel(Parcel dest, int flags) {
6060
dest.writeString(this.type);
6161
}
6262

63+
@Override
64+
public String toString() {
65+
return "AttachmentInfo{" +
66+
"name='" + name + '\'' +
67+
", encodedSize=" + encodedSize +
68+
", type='" + type + '\'' +
69+
'}';
70+
}
71+
6372
public String getName() {
6473
return name;
6574
}

FlowCrypt/src/main/java/com/flowcrypt/email/ui/activity/fragment/MessageDetailsFragment.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,11 @@
3232
import com.flowcrypt.email.R;
3333
import com.flowcrypt.email.api.email.Folder;
3434
import com.flowcrypt.email.api.email.FoldersManager;
35+
import com.flowcrypt.email.api.email.model.AttachmentInfo;
3536
import com.flowcrypt.email.api.email.model.GeneralMessageDetails;
3637
import com.flowcrypt.email.api.email.model.IncomingMessageInfo;
3738
import com.flowcrypt.email.database.dao.source.ContactsDaoSource;
39+
import com.flowcrypt.email.database.dao.source.imap.AttachmentDaoSource;
3840
import com.flowcrypt.email.js.PgpContact;
3941
import com.flowcrypt.email.model.MessageEncryptionType;
4042
import com.flowcrypt.email.model.messages.MessagePart;
@@ -50,6 +52,8 @@
5052
import com.flowcrypt.email.util.GeneralUtil;
5153
import com.flowcrypt.email.util.UIUtil;
5254

55+
import java.util.List;
56+
5357
/**
5458
* This fragment describe details of some message.
5559
*
@@ -376,13 +380,34 @@ private void updateViews() {
376380
textViewSenderAddress.setText(incomingMessageInfo.getFrom().get(0));
377381
textViewSubject.setText(subject);
378382
updateMessageView();
383+
showAttachmentsIfTheyExist();
379384

380385
if (incomingMessageInfo.getReceiveDate() != null) {
381386
textViewDate.setText(dateFormat.format(incomingMessageInfo.getReceiveDate()));
382387
}
383388
}
384389
}
385390

391+
private void showAttachmentsIfTheyExist() {
392+
if (generalMessageDetails != null && generalMessageDetails.isMessageHasAttachment()) {
393+
List<AttachmentInfo> attachmentInfoList = new AttachmentDaoSource()
394+
.getAttachmentInfoList(getContext(), generalMessageDetails.getEmail(),
395+
generalMessageDetails.getLabel(), generalMessageDetails.getUid());
396+
LayoutInflater layoutInflater = LayoutInflater.from(getContext());
397+
398+
for (AttachmentInfo attachmentInfo : attachmentInfoList) {
399+
View rootView = layoutInflater.inflate(R.layout.attachment_item,
400+
layoutMessageParts, false);
401+
402+
TextView textViewAttachmentName = (TextView) rootView.findViewById(R.id
403+
.textViewAttchmentName);
404+
textViewAttachmentName.setText(attachmentInfo.getName());
405+
406+
layoutMessageParts.addView(rootView);
407+
}
408+
}
409+
}
410+
386411
private void updateMessageView() {
387412
if (incomingMessageInfo.getMessageParts() != null
388413
&& !incomingMessageInfo.getMessageParts().isEmpty()) {
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<?xml version="1.0" encoding="utf-8"?><!--
2+
~ Business Source License 1.0 © 2017 FlowCrypt Limited ([email protected]).
3+
~ Use limitations apply. See https://github.com/FlowCrypt/flowcrypt-android/blob/master/LICENSE
4+
~ Contributors: DenBond7
5+
-->
6+
7+
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
8+
xmlns:app="http://schemas.android.com/apk/res-auto"
9+
xmlns:tools="http://schemas.android.com/tools"
10+
android:layout_width="@dimen/layout_width_attachment_item"
11+
android:layout_height="@dimen/layout_height_attachment_item"
12+
android:layout_marginBottom="@dimen/default_margin_small"
13+
android:layout_marginLeft="@dimen/default_margin_content"
14+
android:layout_marginRight="@dimen/default_margin_content"
15+
android:layout_marginTop="@dimen/default_margin_small"
16+
android:background="@color/aluminum">
17+
18+
<android.support.constraint.ConstraintLayout
19+
android:layout_width="match_parent"
20+
android:layout_height="match_parent"
21+
android:layout_gravity="center"
22+
android:background="?android:attr/selectableItemBackground"
23+
android:clickable="true"
24+
android:paddingLeft="@dimen/default_margin_content"
25+
android:paddingRight="@dimen/default_margin_content">
26+
27+
<ImageView
28+
android:id="@+id/imageViewAttachmentIcon"
29+
android:layout_width="wrap_content"
30+
android:layout_height="wrap_content"
31+
android:contentDescription="@string/attachment"
32+
app:layout_constraintBottom_toBottomOf="parent"
33+
app:layout_constraintLeft_toLeftOf="parent"
34+
app:layout_constraintTop_toTopOf="parent"
35+
app:srcCompat="@mipmap/ic_attachment" />
36+
37+
<TextView
38+
android:id="@+id/textViewAttchmentName"
39+
android:layout_width="0dp"
40+
android:layout_height="wrap_content"
41+
android:layout_marginEnd="@dimen/default_margin_content_small"
42+
android:layout_marginLeft="@dimen/default_margin_content_small"
43+
android:layout_marginRight="@dimen/default_margin_content_small"
44+
android:layout_marginStart="@dimen/default_margin_content_small"
45+
android:ellipsize="middle"
46+
android:maxLines="1"
47+
app:layout_constraintBottom_toBottomOf="@+id/imageViewAttachmentIcon"
48+
app:layout_constraintHorizontal_bias="0.0"
49+
app:layout_constraintLeft_toRightOf="@+id/imageViewAttachmentIcon"
50+
app:layout_constraintRight_toLeftOf="@+id/imageButtonDownloadAttachment"
51+
app:layout_constraintTop_toTopOf="@+id/imageViewAttachmentIcon"
52+
tools:text="Some very very very very very large file name.txt" />
53+
54+
<ImageButton
55+
android:id="@+id/imageButtonDownloadAttachment"
56+
android:layout_width="wrap_content"
57+
android:layout_height="wrap_content"
58+
android:background="?android:attr/selectableItemBackground"
59+
android:contentDescription="@string/download"
60+
app:layout_constraintBottom_toBottomOf="@+id/textViewAttchmentName"
61+
app:layout_constraintRight_toRightOf="parent"
62+
app:layout_constraintTop_toTopOf="@+id/textViewAttchmentName"
63+
app:srcCompat="@mipmap/ic_file_download" />
64+
</android.support.constraint.ConstraintLayout>
65+
</android.support.v7.widget.CardView>
66+
669 Bytes
Loading
555 Bytes
Loading
932 Bytes
Loading
1.21 KB
Loading
1.89 KB
Loading

FlowCrypt/src/main/res/values/dimens.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,6 @@
5151
<dimen name="margin_between_buttons">32dp</dimen>
5252
<dimen name="user_photo_size">48dp</dimen>
5353
<dimen name="margin_top_splash_icon">68dp</dimen>
54+
<dimen name="layout_height_attachment_item">48dp</dimen>
55+
<dimen name="layout_width_attachment_item">320dp</dimen>
5456
</resources>

0 commit comments

Comments
 (0)