From 8936223b84caffb21117b0cd5e4373277b3d539b Mon Sep 17 00:00:00 2001 From: M66B Date: Tue, 4 Sep 2018 07:56:30 +0000 Subject: [PATCH] Small improvements --- .../eu/faircode/email/AdapterMessage.java | 15 ++++---- .../eu/faircode/email/FragmentMessage.java | 36 ++++++------------- app/src/main/res/layout/fragment_message.xml | 33 +++++++++-------- app/src/main/res/layout/item_message.xml | 27 +++++++------- 4 files changed, 49 insertions(+), 62 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/AdapterMessage.java b/app/src/main/java/eu/faircode/email/AdapterMessage.java index 48bce38763..8010f305aa 100644 --- a/app/src/main/java/eu/faircode/email/AdapterMessage.java +++ b/app/src/main/java/eu/faircode/email/AdapterMessage.java @@ -60,12 +60,12 @@ public class AdapterMessage extends PagedListAdapter 0 ? View.VISIBLE : View.GONE); @@ -131,11 +129,12 @@ public class AdapterMessage extends PagedListAdapter 1 ? View.VISIBLE : View.GONE); + ivThread.setVisibility(View.VISIBLE); } if (debug) { diff --git a/app/src/main/java/eu/faircode/email/FragmentMessage.java b/app/src/main/java/eu/faircode/email/FragmentMessage.java index 99e40ff8bc..5053019054 100644 --- a/app/src/main/java/eu/faircode/email/FragmentMessage.java +++ b/app/src/main/java/eu/faircode/email/FragmentMessage.java @@ -113,7 +113,6 @@ public class FragmentMessage extends FragmentEx { private ViewGroup view; private View vwAnswerAnchor; private TextView tvFrom; - private TextView tvSize; private TextView tvTime; private TextView tvTo; private TextView tvSubject; @@ -131,6 +130,7 @@ public class FragmentMessage extends FragmentEx { private BottomNavigationView bottom_navigation; private ProgressBar pbWait; private Group grpHeader; + private Group grpThread; private Group grpAddresses; private Group grpAttachments; private Group grpError; @@ -198,7 +198,6 @@ public class FragmentMessage extends FragmentEx { // Get controls vwAnswerAnchor = view.findViewById(R.id.vwAnswerAnchor); tvFrom = view.findViewById(R.id.tvFrom); - tvSize = view.findViewById(R.id.tvSize); tvTime = view.findViewById(R.id.tvTime); tvTo = view.findViewById(R.id.tvTo); tvSubject = view.findViewById(R.id.tvSubject); @@ -216,6 +215,7 @@ public class FragmentMessage extends FragmentEx { bottom_navigation = view.findViewById(R.id.bottom_navigation); pbWait = view.findViewById(R.id.pbWait); grpHeader = view.findViewById(R.id.grpHeader); + grpThread = view.findViewById(R.id.grpThread); grpAddresses = view.findViewById(R.id.grpAddresses); grpAttachments = view.findViewById(R.id.grpAttachments); grpError = view.findViewById(R.id.grpError); @@ -223,13 +223,6 @@ public class FragmentMessage extends FragmentEx { setHasOptionsMenu(true); - tvCount.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - onMenuThread(); - } - }); - tvBody.setMovementMethod(new LinkMovementMethod() { public boolean onTouchEvent(TextView widget, Spannable buffer, MotionEvent event) { if (event.getAction() != MotionEvent.ACTION_UP) @@ -300,12 +293,11 @@ public class FragmentMessage extends FragmentEx { vSeparatorBody.setVisibility(View.GONE); fab.setVisibility(View.GONE); - tvCount.setVisibility(View.GONE); + grpThread.setVisibility(View.GONE); grpAddresses.setVisibility(View.GONE); grpAttachments.setVisibility(View.GONE); grpError.setVisibility(View.GONE); - tvCount.setTag(tvCount.getVisibility()); tvCc.setTag(grpAddresses.getVisibility()); tvError.setTag(grpError.getVisibility()); } @@ -324,7 +316,7 @@ public class FragmentMessage extends FragmentEx { RecyclerView.Adapter adapter = rvAttachment.getAdapter(); - tvCount.setVisibility((int) tvCount.getTag()); + grpThread.setVisibility(View.VISIBLE); grpAddresses.setVisibility((int) tvCc.getTag()); grpAttachments.setVisibility(adapter != null && adapter.getItemCount() > 0 ? View.VISIBLE : View.GONE); grpError.setVisibility((int) tvError.getTag()); @@ -367,13 +359,11 @@ public class FragmentMessage extends FragmentEx { grpMessage.setVisibility(View.GONE); pbBody.setVisibility(View.GONE); bottom_navigation.setVisibility(View.GONE); - tvCount.setVisibility(View.GONE); + grpThread.setVisibility(View.GONE); grpError.setVisibility(View.GONE); fab.setVisibility(View.GONE); pbWait.setVisibility(View.VISIBLE); - tvSize.setText(null); - rvAttachment.setHasFixedSize(false); LinearLayoutManager llm = new LinearLayoutManager(getContext()); rvAttachment.setLayoutManager(llm); @@ -382,9 +372,7 @@ public class FragmentMessage extends FragmentEx { adapter = new AdapterAttachment(getContext(), getViewLifecycleOwner(), true); rvAttachment.setAdapter(adapter); - tvCount.setTag(View.GONE); tvCc.setTag(View.GONE); - rvAttachment.setTag(View.GONE); tvError.setTag(View.GONE); return view; @@ -402,7 +390,6 @@ public class FragmentMessage extends FragmentEx { outState.putSerializable("message", message); outState.putBoolean("free", free); if (free) { - outState.putInt("tag_count", (int) tvCount.getTag()); outState.putInt("tag_cc", (int) tvCc.getTag()); outState.putInt("tag_error", (int) tvError.getTag()); } @@ -430,9 +417,7 @@ public class FragmentMessage extends FragmentEx { } else { free = savedInstanceState.getBoolean("free"); if (free) { - tvCount.setTag(savedInstanceState.getInt("tag_count")); tvCc.setTag(savedInstanceState.getInt("tag_cc")); - rvAttachment.setTag(savedInstanceState.getInt("tag_attachment")); tvError.setTag(savedInstanceState.getInt("tag_error")); } } @@ -465,11 +450,11 @@ public class FragmentMessage extends FragmentEx { vSeparatorBody.setVisibility(free ? View.GONE : View.VISIBLE); if (free) { - tvCount.setVisibility((int) tvCount.getTag()); + grpThread.setVisibility(View.GONE); grpAddresses.setVisibility((int) tvCc.getTag()); grpError.setVisibility((int) tvError.getTag()); } else { - tvCount.setVisibility(!free && message.count > 1 ? View.VISIBLE : View.GONE); + grpThread.setVisibility(!free ? View.VISIBLE : View.GONE); grpError.setVisibility(free || message.error == null ? View.GONE : View.VISIBLE); } @@ -578,9 +563,9 @@ public class FragmentMessage extends FragmentEx { boolean inOutbox = EntityFolder.OUTBOX.equals(message.folderType); menu.findItem(R.id.menu_addresses).setVisible(!free); - menu.findItem(R.id.menu_thread).setVisible(!free && message.count > 1); - menu.findItem(R.id.menu_forward).setVisible(!free && !inOutbox); - menu.findItem(R.id.menu_reply_all).setVisible(!free && message.cc != null && !inOutbox); + menu.findItem(R.id.menu_thread).setVisible(message.count > 1); + menu.findItem(R.id.menu_forward).setVisible(!inOutbox); + menu.findItem(R.id.menu_reply_all).setVisible(message.cc != null && !inOutbox); menu.findItem(R.id.menu_decrypt).setVisible(!inOutbox); } @@ -1059,7 +1044,6 @@ public class FragmentMessage extends FragmentEx { SpannedString ss = new SpannedString(body); boolean has_images = (ss.getSpans(0, ss.length(), ImageSpan.class).length > 0); - tvSize.setText(Helper.humanReadableByteCount(args.getInt("size"), false)); tvBody.setText(body); tvBody.setTag(true); btnImages.setVisibility(has_images && !show_images ? View.VISIBLE : View.GONE); diff --git a/app/src/main/res/layout/fragment_message.xml b/app/src/main/res/layout/fragment_message.xml index c0a0155bdc..ee1a5eb261 100644 --- a/app/src/main/res/layout/fragment_message.xml +++ b/app/src/main/res/layout/fragment_message.xml @@ -25,22 +25,10 @@ android:text="From" android:textAppearance="@style/TextAppearance.AppCompat.Medium" android:textIsSelectable="true" - app:layout_constraintEnd_toStartOf="@+id/tvSize" + app:layout_constraintEnd_toStartOf="@+id/tvTime" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> - - + + @@ -335,6 +334,12 @@ android:layout_height="0dp" app:constraint_referenced_ids="tvFrom,tvToTitle,tvTo,tvSize,tvTime,tvSubject" /> + + - - + app:layout_constraintEnd_toStartOf="@+id/ivThread" /> + +