Show message size

This commit is contained in:
M66B 2018-08-23 16:29:00 +00:00
parent 9967118a2f
commit 11d787122e
2 changed files with 20 additions and 2 deletions

View File

@ -72,6 +72,7 @@ import androidx.recyclerview.widget.RecyclerView;
public class FragmentMessage extends FragmentEx { public class FragmentMessage extends FragmentEx {
private ViewGroup view; private ViewGroup view;
private TextView tvFrom; private TextView tvFrom;
private TextView tvSize;
private TextView tvTime; private TextView tvTime;
private TextView tvTo; private TextView tvTo;
private TextView tvSubject; private TextView tvSubject;
@ -112,6 +113,7 @@ public class FragmentMessage extends FragmentEx {
// Get controls // Get controls
tvFrom = view.findViewById(R.id.tvFrom); tvFrom = view.findViewById(R.id.tvFrom);
tvSize = view.findViewById(R.id.tvSize);
tvTime = view.findViewById(R.id.tvTime); tvTime = view.findViewById(R.id.tvTime);
tvTo = view.findViewById(R.id.tvTo); tvTo = view.findViewById(R.id.tvTo);
tvSubject = view.findViewById(R.id.tvSubject); tvSubject = view.findViewById(R.id.tvSubject);
@ -261,6 +263,8 @@ public class FragmentMessage extends FragmentEx {
fab.setVisibility(View.GONE); fab.setVisibility(View.GONE);
pbWait.setVisibility(View.VISIBLE); pbWait.setVisibility(View.VISIBLE);
tvSize.setText(null);
rvAttachment.setHasFixedSize(false); rvAttachment.setHasFixedSize(false);
LinearLayoutManager llm = new LinearLayoutManager(getContext()); LinearLayoutManager llm = new LinearLayoutManager(getContext());
rvAttachment.setLayoutManager(llm); rvAttachment.setLayoutManager(llm);
@ -329,11 +333,13 @@ public class FragmentMessage extends FragmentEx {
@Override @Override
protected Spanned onLoad(Context context, Bundle args) throws Throwable { protected Spanned onLoad(Context context, Bundle args) throws Throwable {
String body = EntityMessage.read(context, args.getLong("id")); String body = EntityMessage.read(context, args.getLong("id"));
args.putInt("size", body.length());
return Html.fromHtml(HtmlHelper.sanitize(getContext(), body, false)); return Html.fromHtml(HtmlHelper.sanitize(getContext(), body, false));
} }
@Override @Override
protected void onLoaded(Bundle args, Spanned body) { protected void onLoaded(Bundle args, Spanned body) {
tvSize.setText(Helper.humanReadableByteCount(args.getInt("size"), false));
tvBody.setText(body); tvBody.setText(body);
grpMessage.setVisibility(View.VISIBLE); grpMessage.setVisibility(View.VISIBLE);
if (!free) if (!free)

View File

@ -17,10 +17,22 @@
android:text="From" android:text="From"
android:textAppearance="@style/TextAppearance.AppCompat.Medium" android:textAppearance="@style/TextAppearance.AppCompat.Medium"
android:textIsSelectable="true" android:textIsSelectable="true"
app:layout_constraintEnd_toStartOf="@+id/tvTime" app:layout_constraintEnd_toStartOf="@+id/tvSize"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/tvSize"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="6dp"
android:maxLines="1"
android:text="123 K"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textIsSelectable="true"
app:layout_constraintEnd_toStartOf="@+id/tvTime"
app:layout_constraintTop_toTopOf="@id/tvFrom" />
<TextView <TextView
android:id="@+id/tvTime" android:id="@+id/tvTime"
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -269,7 +281,7 @@
android:id="@+id/grpHeader" android:id="@+id/grpHeader"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="0dp" android:layout_height="0dp"
app:constraint_referenced_ids="tvFrom,tvToTitle,tvTo,tvTime,tvSubject" /> app:constraint_referenced_ids="tvFrom,tvToTitle,tvTo,tvSize,tvTime,tvSubject" />
<androidx.constraintlayout.widget.Group <androidx.constraintlayout.widget.Group
android:id="@+id/grpAddresses" android:id="@+id/grpAddresses"