Skip to content

Commit 22a63f7

Browse files
committed
Added show attachments size. | #55.
1 parent f983ebf commit 22a63f7

File tree

3 files changed

+36
-15
lines changed

3 files changed

+36
-15
lines changed

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@
5252
import com.flowcrypt.email.util.GeneralUtil;
5353
import com.flowcrypt.email.util.UIUtil;
5454

55+
import org.apache.commons.io.FileUtils;
56+
5557
import java.util.List;
5658

5759
/**
@@ -405,6 +407,11 @@ private void showAttachmentsIfTheyExist() {
405407
.textViewAttchmentName);
406408
textViewAttachmentName.setText(attachmentInfo.getName());
407409

410+
TextView textViewAttachmentSize = (TextView) rootView.findViewById(R.id
411+
.textViewAttachmentSize);
412+
textViewAttachmentSize.setText(FileUtils.byteCountToDisplaySize(attachmentInfo
413+
.getEncodedSize()));
414+
408415
layoutMessageParts.addView(rootView);
409416
}
410417
}
@@ -426,7 +433,7 @@ private void updateMessageView() {
426433
case TEXT:
427434
layoutMessageParts.addView(generateTextPart(messagePart,
428435
layoutInflater));
429-
if(i == 0) { // add a dividing line if first message part is text
436+
if (i == 0) { // add a dividing line if first message part is text
430437
viewFooterOfHeader.setBackgroundColor(UIUtil.getColor(getContext(),
431438
R.color.aluminum));
432439
}

FlowCrypt/src/main/res/layout/attachment_item.xml

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,33 +34,46 @@
3434
app:layout_constraintTop_toTopOf="parent"
3535
app:srcCompat="@mipmap/ic_attachment" />
3636

37-
<TextView
38-
android:id="@+id/textViewAttchmentName"
37+
<LinearLayout
3938
android:layout_width="0dp"
4039
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"
40+
android:orientation="vertical"
41+
android:paddingLeft="@dimen/default_margin_small"
42+
android:paddingRight="@dimen/default_margin_small"
43+
app:layout_constraintBottom_toBottomOf="parent"
4944
app:layout_constraintLeft_toRightOf="@+id/imageViewAttachmentIcon"
5045
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" />
46+
app:layout_constraintTop_toTopOf="parent">
47+
48+
<TextView
49+
android:id="@+id/textViewAttchmentName"
50+
android:layout_width="match_parent"
51+
android:layout_height="wrap_content"
52+
android:ellipsize="middle"
53+
android:maxLines="1"
54+
tools:text="Some very very very very very large file name.txt" />
55+
56+
<TextView
57+
android:id="@+id/textViewAttachmentSize"
58+
android:layout_width="wrap_content"
59+
android:layout_height="wrap_content"
60+
android:textSize="@dimen/default_text_size_very_small"
61+
tools:text="12.02 Mb" />
62+
</LinearLayout>
63+
5364

5465
<ImageButton
5566
android:id="@+id/imageButtonDownloadAttachment"
5667
android:layout_width="wrap_content"
5768
android:layout_height="wrap_content"
5869
android:background="?android:attr/selectableItemBackground"
5970
android:contentDescription="@string/download"
60-
app:layout_constraintBottom_toBottomOf="@+id/textViewAttchmentName"
71+
app:layout_constraintBottom_toBottomOf="parent"
6172
app:layout_constraintRight_toRightOf="parent"
62-
app:layout_constraintTop_toTopOf="@+id/textViewAttchmentName"
73+
app:layout_constraintTop_toTopOf="parent"
6374
app:srcCompat="@mipmap/ic_file_download" />
75+
76+
6477
</android.support.constraint.ConstraintLayout>
6578
</android.support.v7.widget.CardView>
6679

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
<dimen name="default_text_size_big">18sp</dimen>
2626
<dimen name="default_text_size_medium">16sp</dimen>
2727
<dimen name="default_text_size_default">14sp</dimen>
28+
<dimen name="default_text_size_very_small">10sp</dimen>
2829

2930
<dimen name="margin_top_main_screen_button">32dp</dimen>
3031
<dimen name="margin_top_main_screen_button_sign_via_gmail">60dp</dimen>

0 commit comments

Comments
 (0)