diff --git a/app/src/main/java/be/scri/fragments/AboutFragment.kt b/app/src/main/java/be/scri/fragments/AboutFragment.kt index 4f70f3df..09733f0a 100644 --- a/app/src/main/java/be/scri/fragments/AboutFragment.kt +++ b/app/src/main/java/be/scri/fragments/AboutFragment.kt @@ -1,5 +1,6 @@ package be.scri.fragments +import CustomDividerItemDecoration import android.content.ActivityNotFoundException import android.content.Context import android.content.Intent @@ -12,8 +13,10 @@ import android.view.View import android.view.ViewGroup import android.widget.Toast import androidx.activity.addCallback +import androidx.appcompat.content.res.AppCompatResources.getDrawable import androidx.fragment.app.Fragment import androidx.recyclerview.widget.LinearLayoutManager +import androidx.recyclerview.widget.RecyclerView import be.scri.BuildConfig import be.scri.R import be.scri.activities.MainActivity @@ -56,16 +59,34 @@ class AboutFragment : Fragment() { recyclerView1.layoutManager = LinearLayoutManager(context) recyclerView1.adapter = CustomAdapter(getFirstRecyclerViewData(), requireContext()) recyclerView1.suppressLayout(true) - + recyclerView1.apply { + addCustomItemDecoration() + } val recyclerView2 = binding.recycleView recyclerView2.layoutManager = LinearLayoutManager(context) recyclerView2.adapter = CustomAdapter(getSecondRecyclerViewData(), requireContext()) recyclerView2.suppressLayout(true) - + recyclerView2.apply { + addCustomItemDecoration() + } val recyclerView3 = binding.recycleView3 recyclerView3.layoutManager = LinearLayoutManager(context) recyclerView3.adapter = CustomAdapter(getThirdRecyclerViewData(), requireContext()) recyclerView3.suppressLayout(true) + recyclerView3.apply { + addCustomItemDecoration() + } + } + + private fun RecyclerView.addCustomItemDecoration() { + val itemDecoration = + CustomDividerItemDecoration( + drawable = getDrawable(requireContext(), R.drawable.rv_divider)!!, + width = 1, + marginLeft = 50, + marginRight = 50, + ) + addItemDecoration(itemDecoration) } private fun getFirstRecyclerViewData(): List = diff --git a/app/src/main/java/be/scri/fragments/SettingsFragment.kt b/app/src/main/java/be/scri/fragments/SettingsFragment.kt index c36992cb..bb1bd915 100644 --- a/app/src/main/java/be/scri/fragments/SettingsFragment.kt +++ b/app/src/main/java/be/scri/fragments/SettingsFragment.kt @@ -1,5 +1,6 @@ package be.scri.fragments +import CustomDividerItemDecoration import android.content.Context import android.content.Intent import android.content.res.Configuration @@ -16,6 +17,7 @@ import android.view.ViewGroup import android.view.inputmethod.InputMethodManager import androidx.activity.addCallback import androidx.appcompat.app.AppCompatDelegate +import androidx.appcompat.content.res.AppCompatResources.getDrawable import androidx.fragment.app.Fragment import androidx.recyclerview.widget.LinearLayoutManager import be.scri.R @@ -145,6 +147,16 @@ class SettingsFragment : Fragment() { recyclerView.layoutManager = LinearLayoutManager(requireContext()) recyclerView.adapter = adapter recyclerView.suppressLayout(true) + recyclerView.apply { + val itemDecoration = + CustomDividerItemDecoration( + drawable = getDrawable(requireContext(), R.drawable.rv_divider)!!, + width = 1, + marginLeft = 50, + marginRight = 50, + ) + addItemDecoration(itemDecoration) + } } private fun getRecyclerViewElements(): MutableList { diff --git a/app/src/main/java/be/scri/views/CustomDividerItemDecoration.kt b/app/src/main/java/be/scri/views/CustomDividerItemDecoration.kt new file mode 100644 index 00000000..35c80c9a --- /dev/null +++ b/app/src/main/java/be/scri/views/CustomDividerItemDecoration.kt @@ -0,0 +1,42 @@ +import android.graphics.Canvas +import android.graphics.Rect +import android.graphics.drawable.Drawable +import android.view.View +import androidx.annotation.NonNull +import androidx.recyclerview.widget.RecyclerView + +class CustomDividerItemDecoration( + private val drawable: Drawable, + private val width: Int, + private val marginLeft: Int, + private val marginRight: Int, +) : RecyclerView.ItemDecoration() { + override fun onDraw( + @NonNull canvas: Canvas, + @NonNull parent: RecyclerView, + @NonNull state: RecyclerView.State, + ) { + val left = parent.paddingLeft + marginLeft + val right = parent.width - parent.paddingRight - marginRight + + val childCount = parent.childCount + for (i in 0 until childCount - 1) { // Exclude the last item + val child = parent.getChildAt(i) + val params = child.layoutParams as RecyclerView.LayoutParams + val top = child.bottom + params.bottomMargin + val bottom = top + width + + drawable.setBounds(left, top, right, bottom) + drawable.draw(canvas) + } + } + + override fun getItemOffsets( + outRect: Rect, + view: View, + parent: RecyclerView, + state: RecyclerView.State, + ) { + outRect.set(0, 0, 0, width) + } +} diff --git a/app/src/main/res/drawable/rv_divider.xml b/app/src/main/res/drawable/rv_divider.xml new file mode 100644 index 00000000..68649987 --- /dev/null +++ b/app/src/main/res/drawable/rv_divider.xml @@ -0,0 +1,7 @@ + + + + + + diff --git a/app/src/main/res/layout/card_view_text.xml b/app/src/main/res/layout/card_view_text.xml index 68493a60..e517b7c6 100644 --- a/app/src/main/res/layout/card_view_text.xml +++ b/app/src/main/res/layout/card_view_text.xml @@ -1,16 +1,10 @@ - + - diff --git a/app/src/main/res/layout/card_view_with_image.xml b/app/src/main/res/layout/card_view_with_image.xml index b28b07a3..b7447138 100644 --- a/app/src/main/res/layout/card_view_with_image.xml +++ b/app/src/main/res/layout/card_view_with_image.xml @@ -1,16 +1,9 @@ - + - diff --git a/app/src/main/res/layout/card_view_with_switch.xml b/app/src/main/res/layout/card_view_with_switch.xml index 7d9980b0..4aad215a 100644 --- a/app/src/main/res/layout/card_view_with_switch.xml +++ b/app/src/main/res/layout/card_view_with_switch.xml @@ -1,16 +1,9 @@ - - diff --git a/app/src/main/res/layout/fragment_about.xml b/app/src/main/res/layout/fragment_about.xml index 2a7d2f0f..3d3b2bc8 100644 --- a/app/src/main/res/layout/fragment_about.xml +++ b/app/src/main/res/layout/fragment_about.xml @@ -27,6 +27,9 @@ android:id="@+id/recycleView2" android:layout_width="match_parent" android:layout_height="wrap_content" + android:layout_marginStart="8dp" + android:layout_marginEnd="8dp" + android:background="@drawable/rounded_all_corners" android:layout_marginTop="10dp" /> - diff --git a/app/src/main/res/layout/fragment_language_settings.xml b/app/src/main/res/layout/fragment_language_settings.xml index e8bd3a35..6fd30a2b 100644 --- a/app/src/main/res/layout/fragment_language_settings.xml +++ b/app/src/main/res/layout/fragment_language_settings.xml @@ -29,6 +29,8 @@ android:layout_height="wrap_content" android:layout_marginTop="50dp" android:padding="12dp" + android:layout_marginStart="8dp" + android:layout_marginEnd="8dp" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintHorizontal_bias="0.0" app:layout_constraintStart_toStartOf="parent" @@ -61,6 +63,8 @@ android:layout_marginTop="20dp" android:padding="12dp" app:layout_constraintEnd_toEndOf="parent" + android:layout_marginStart="8dp" + android:layout_marginEnd="8dp" app:layout_constraintHorizontal_bias="0.0" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/functionalityRecyclerView" /> diff --git a/app/src/main/res/layout/fragment_settings.xml b/app/src/main/res/layout/fragment_settings.xml index d7c92236..69917089 100644 --- a/app/src/main/res/layout/fragment_settings.xml +++ b/app/src/main/res/layout/fragment_settings.xml @@ -31,6 +31,10 @@ android:id="@+id/recyclerViewSettings" android:layout_width="match_parent" android:layout_height="wrap_content" + android:layout_marginStart="8dp" + android:layout_marginEnd="8dp" + android:background="@drawable/rounded_all_corners" + /> - - diff --git a/app/src/main/res/values-night-v31/colors.xml b/app/src/main/res/values-night-v31/colors.xml index 35b85ccd..85702247 100644 --- a/app/src/main/res/values-night-v31/colors.xml +++ b/app/src/main/res/values-night-v31/colors.xml @@ -15,6 +15,7 @@ @color/dark_tutorial_button_color @color/dark_button_outline_color #D17B0F + #b2aeae #D17B0F @android:color/darker_gray @color/corner_polygon_color diff --git a/app/src/main/res/values-v31/colors.xml b/app/src/main/res/values-v31/colors.xml index b444dd97..ed30d14c 100644 --- a/app/src/main/res/values-v31/colors.xml +++ b/app/src/main/res/values-v31/colors.xml @@ -16,6 +16,7 @@ @color/light_tutorial_button_color @color/light_tutorial_button_color #000000 + #d7d7d9 #FDAD0D @android:color/darker_gray #FEDE9E