Add margin for Preview ViewPager
Bug: 200785962
Test: Videos attached to the bug
Change-Id: I36672acf63ca1d6b67b42440190bb9790a19ad4f
Merged-In: I36672acf63ca1d6b67b42440190bb9790a19ad4f
(cherry picked from commit 26717b837f9058b6586ef8df4b8f90e1228bdcff)
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index a56d8d5..64050a6 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -60,11 +60,13 @@
<dimen name="preview_buttons_margin_horizontal">16dp</dimen>
<dimen name="preview_buttons_margin_bottom">10dp</dimen>
<dimen name="preview_deselect_padding_start">2dp</dimen>
+ <dimen name="preview_viewpager_margin">20dp</dimen>
<!-- PhotoPicker Preview text -->
<dimen name="preview_add_text_size">14sp</dimen>
<dimen name="preview_deselect_text_size">16sp</dimen>
<dimen name="preview_toolbar_scrim_height">96dp</dimen>
<dimen name="preview_deselect_scrim_height">240dp</dimen>
+
<!-- PhotoPicker Work Profile -->
<dimen name="picker_profile_button_margin_bottom">32dp</dimen>
<dimen name="picker_profile_dialog_radius">8dp</dimen>
diff --git a/src/com/android/providers/media/photopicker/ui/PreviewFragment.java b/src/com/android/providers/media/photopicker/ui/PreviewFragment.java
index 14c3695..0abc413 100644
--- a/src/com/android/providers/media/photopicker/ui/PreviewFragment.java
+++ b/src/com/android/providers/media/photopicker/ui/PreviewFragment.java
@@ -31,6 +31,7 @@
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.lifecycle.ViewModelProvider;
+import androidx.viewpager2.widget.MarginPageTransformer;
import androidx.viewpager2.widget.ViewPager2;
import com.android.providers.media.R;
@@ -97,6 +98,8 @@
// Initialize ViewPager2 to swipe between multiple pictures/videos in preview
mViewPager = view.findViewById(R.id.preview_viewPager);
mViewPager.setAdapter(mAdapter);
+ mViewPager.setPageTransformer(new MarginPageTransformer(
+ getResources().getDimensionPixelSize(R.dimen.preview_viewpager_margin)));
Button selectButton = view.findViewById(R.id.preview_select_button);