From 2061d381252c5a56ffcdfcc4b5be86c2dab1bfb1 Mon Sep 17 00:00:00 2001 From: M66B Date: Mon, 1 Apr 2019 08:44:04 +0200 Subject: [PATCH] Use item decorator --- .../java/eu/faircode/email/AdapterFolder.java | 14 +++++++-- .../eu/faircode/email/AdapterMessage.java | 2 +- .../eu/faircode/email/FragmentAccounts.java | 5 ++++ .../eu/faircode/email/FragmentAnswers.java | 5 ++++ .../eu/faircode/email/FragmentFolders.java | 5 ++++ .../eu/faircode/email/FragmentIdentities.java | 5 ++++ .../eu/faircode/email/FragmentMessages.java | 5 ++++ app/src/main/res/drawable/divider.xml | 6 ++++ app/src/main/res/layout/item_account.xml | 8 ----- app/src/main/res/layout/item_answer.xml | 16 ++-------- app/src/main/res/layout/item_folder.xml | 29 ++++++++++++++----- app/src/main/res/layout/item_identity.xml | 8 ----- .../main/res/layout/item_message_compact.xml | 8 ----- .../main/res/layout/item_message_normal.xml | 8 ----- 14 files changed, 66 insertions(+), 58 deletions(-) create mode 100644 app/src/main/res/drawable/divider.xml diff --git a/app/src/main/java/eu/faircode/email/AdapterFolder.java b/app/src/main/java/eu/faircode/email/AdapterFolder.java index d17b39e775..592d2e4dfb 100644 --- a/app/src/main/java/eu/faircode/email/AdapterFolder.java +++ b/app/src/main/java/eu/faircode/email/AdapterFolder.java @@ -49,11 +49,13 @@ import java.util.Locale; import androidx.annotation.NonNull; import androidx.appcompat.widget.PopupMenu; +import androidx.constraintlayout.widget.Group; import androidx.lifecycle.LifecycleOwner; import androidx.lifecycle.Observer; import androidx.localbroadcastmanager.content.LocalBroadcastManager; import androidx.preference.PreferenceManager; import androidx.recyclerview.widget.DiffUtil; +import androidx.recyclerview.widget.DividerItemDecoration; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.ListUpdateCallback; import androidx.recyclerview.widget.RecyclerView; @@ -96,6 +98,7 @@ public class AdapterFolder extends RecyclerView.Adapter 0 && folder.childs > 0) { if (folder.collapsed) { - rvChilds.setVisibility(View.GONE); + grpChilds.setVisibility(View.GONE); childs.set(account, folder, level + 1, new ArrayList()); } else { DB db = DB.getInstance(context); cowner.start(); - rvChilds.setVisibility(View.VISIBLE); + grpChilds.setVisibility(View.VISIBLE); childs.set(folder.account, folder, level + 1, properties.getChilds(folder.id)); db.folder().liveFolders(folder.account, folder.id).observe(cowner, new Observer>() { @Override @@ -277,7 +285,7 @@ public class AdapterFolder extends RecyclerView.Adapter()); } } diff --git a/app/src/main/java/eu/faircode/email/AdapterMessage.java b/app/src/main/java/eu/faircode/email/AdapterMessage.java index 391bee44a7..99cc721c72 100644 --- a/app/src/main/java/eu/faircode/email/AdapterMessage.java +++ b/app/src/main/java/eu/faircode/email/AdapterMessage.java @@ -372,7 +372,7 @@ public class AdapterMessage extends RecyclerView.Adapter childs) { diff --git a/app/src/main/java/eu/faircode/email/FragmentIdentities.java b/app/src/main/java/eu/faircode/email/FragmentIdentities.java index 0eb5eb3a43..cef1c01f46 100644 --- a/app/src/main/java/eu/faircode/email/FragmentIdentities.java +++ b/app/src/main/java/eu/faircode/email/FragmentIdentities.java @@ -36,6 +36,7 @@ import androidx.annotation.Nullable; import androidx.constraintlayout.widget.Group; import androidx.fragment.app.FragmentTransaction; import androidx.lifecycle.Observer; +import androidx.recyclerview.widget.DividerItemDecoration; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; @@ -67,6 +68,10 @@ public class FragmentIdentities extends FragmentBase { LinearLayoutManager llm = new LinearLayoutManager(getContext()); rvIdentity.setLayoutManager(llm); + DividerItemDecoration itemDecorator = new DividerItemDecoration(getContext(), DividerItemDecoration.VERTICAL); + itemDecorator.setDrawable(getContext().getDrawable(R.drawable.divider)); + rvIdentity.addItemDecoration(itemDecorator); + adapter = new AdapterIdentity(getContext()); rvIdentity.setAdapter(adapter); diff --git a/app/src/main/java/eu/faircode/email/FragmentMessages.java b/app/src/main/java/eu/faircode/email/FragmentMessages.java index 6d812961e9..54ad166bed 100644 --- a/app/src/main/java/eu/faircode/email/FragmentMessages.java +++ b/app/src/main/java/eu/faircode/email/FragmentMessages.java @@ -90,6 +90,7 @@ import androidx.preference.PreferenceManager; import androidx.recyclerview.selection.Selection; import androidx.recyclerview.selection.SelectionTracker; import androidx.recyclerview.selection.StorageStrategy; +import androidx.recyclerview.widget.DividerItemDecoration; import androidx.recyclerview.widget.ItemTouchHelper; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; @@ -309,6 +310,10 @@ public class FragmentMessages extends FragmentBase { LinearLayoutManager llm = new LinearLayoutManager(getContext()); rvMessage.setLayoutManager(llm); + DividerItemDecoration itemDecorator = new DividerItemDecoration(getContext(), DividerItemDecoration.VERTICAL); + itemDecorator.setDrawable(getContext().getDrawable(R.drawable.divider)); + rvMessage.addItemDecoration(itemDecorator); + boolean compact = prefs.getBoolean("compact", false); int zoom = prefs.getInt("zoom", compact ? 0 : 1); String sort = prefs.getString("sort", "time"); diff --git a/app/src/main/res/drawable/divider.xml b/app/src/main/res/drawable/divider.xml new file mode 100644 index 0000000000..eda2253e18 --- /dev/null +++ b/app/src/main/res/drawable/divider.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/item_account.xml b/app/src/main/res/layout/item_account.xml index 62102a6447..16ba09563b 100644 --- a/app/src/main/res/layout/item_account.xml +++ b/app/src/main/res/layout/item_account.xml @@ -175,14 +175,6 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/tvError" /> - - + android:layout_height="wrap_content" + android:padding="6dp"> - - \ No newline at end of file diff --git a/app/src/main/res/layout/item_folder.xml b/app/src/main/res/layout/item_folder.xml index f770560220..212725f618 100644 --- a/app/src/main/res/layout/item_folder.xml +++ b/app/src/main/res/layout/item_folder.xml @@ -15,7 +15,7 @@ android:layout_width="6dp" android:layout_height="0dp" android:background="@color/colorAccent" - app:layout_constraintBottom_toTopOf="@+id/vSeparator" + app:layout_constraintBottom_toBottomOf="@+id/paddingBottom" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> @@ -46,7 +46,7 @@ android:paddingStart="12dp" android:paddingEnd="12dp" android:src="@drawable/baseline_expand_less_24" - app:layout_constraintBottom_toTopOf="@+id/vSeparator" + app:layout_constraintBottom_toBottomOf="@+id/paddingBottom" app:layout_constraintStart_toEndOf="@+id/vwLevel" app:layout_constraintTop_toTopOf="parent" /> @@ -173,11 +173,10 @@ app:layout_constraintTop_toBottomOf="@id/tvKeywords" /> @@ -186,17 +185,31 @@ android:layout_width="0dp" android:layout_height="0dp" android:background="?android:attr/selectableItemBackground" - app:layout_constraintBottom_toTopOf="@id/vSeparator" + app:layout_constraintBottom_toBottomOf="@id/paddingBottom" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> + + + app:layout_constraintTop_toBottomOf="@id/vSeparatorChilds" /> + + \ No newline at end of file diff --git a/app/src/main/res/layout/item_identity.xml b/app/src/main/res/layout/item_identity.xml index a0fd450391..fb1ca2cf0b 100644 --- a/app/src/main/res/layout/item_identity.xml +++ b/app/src/main/res/layout/item_identity.xml @@ -149,13 +149,5 @@ android:layout_height="3dp" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/tvError" /> - - diff --git a/app/src/main/res/layout/item_message_compact.xml b/app/src/main/res/layout/item_message_compact.xml index 0596f16c04..3d14987a67 100644 --- a/app/src/main/res/layout/item_message_compact.xml +++ b/app/src/main/res/layout/item_message_compact.xml @@ -581,14 +581,6 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/vwBody" /> - - - -