Merge pull request #6296 from thundernest/view_pager_margin

Change the separator between message view pages
This commit is contained in:
cketti 2022-09-12 13:09:04 +02:00 committed by GitHub
commit cc9f2fa801
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View file

@ -8,8 +8,8 @@ import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.DividerItemDecoration
import androidx.viewpager2.adapter.FragmentStateAdapter
import androidx.viewpager2.widget.MarginPageTransformer
import androidx.viewpager2.widget.ViewPager2
import com.fsck.k9.controller.MessageReference
import com.fsck.k9.ui.R
@ -88,10 +88,13 @@ class MessageViewContainerFragment : Fragment() {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
val view = inflater.inflate(R.layout.message_view_container, container, false)
val resources = inflater.context.resources
val pageMargin = resources.getDimension(R.dimen.message_view_pager_page_margin).toInt()
viewPager = view.findViewById(R.id.message_viewpager)
viewPager.isUserInputEnabled = true
viewPager.offscreenPageLimit = ViewPager2.OFFSCREEN_PAGE_LIMIT_DEFAULT
viewPager.addItemDecoration(DividerItemDecoration(context, DividerItemDecoration.HORIZONTAL))
viewPager.setPageTransformer(MarginPageTransformer(pageMargin))
viewPager.registerOnPageChangeCallback(object : ViewPager2.OnPageChangeCallback() {
// The message list is updated each time the active message is changed. To avoid message list updates
// during the animation, we only set the active message after the animation has finished.

View file

@ -7,4 +7,6 @@
<dimen name="input_label_vertical_spacing">8dp</dimen>
<dimen name="input_label_horizontal_spacing">4dp</dimen>
<dimen name="account_setup_margin_between_items_incoming_and_outgoing">12dp</dimen>
<dimen name="message_view_pager_page_margin">16dp</dimen>
</resources>