Update MediaPreviewV2 design values.
This commit is contained in:
parent
40ca16bd06
commit
53883ee3d3
7 changed files with 21 additions and 101 deletions
|
@ -1,41 +0,0 @@
|
|||
package org.thoughtcrime.securesms.animation;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
import androidx.viewpager2.widget.ViewPager2;
|
||||
|
||||
/**
|
||||
* Based on https://developer.android.com/training/animation/screen-slide#depth-page
|
||||
*/
|
||||
public final class DepthPageTransformer implements ViewPager.PageTransformer {
|
||||
private static final float MIN_SCALE = 0.75f;
|
||||
|
||||
public void transformPage(@NonNull View view, float position) {
|
||||
final int pageWidth = view.getWidth();
|
||||
|
||||
if (position < -1f) {
|
||||
view.setAlpha(0f);
|
||||
|
||||
} else if (position <= 0f) {
|
||||
view.setAlpha(1f);
|
||||
view.setTranslationX(0f);
|
||||
view.setScaleX(1f);
|
||||
view.setScaleY(1f);
|
||||
|
||||
} else if (position <= 1f) {
|
||||
view.setAlpha(1f - position);
|
||||
|
||||
view.setTranslationX(pageWidth * -position);
|
||||
|
||||
final float scaleFactor = MIN_SCALE + (1f - MIN_SCALE) * (1f - Math.abs(position));
|
||||
|
||||
view.setScaleX(scaleFactor);
|
||||
view.setScaleY(scaleFactor);
|
||||
|
||||
} else {
|
||||
view.setAlpha(0f);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
package org.thoughtcrime.securesms.animation
|
||||
|
||||
import android.view.View
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.viewpager2.widget.ViewPager2
|
||||
|
||||
private const val MIN_SCALE = 0.75f
|
||||
|
||||
/**
|
||||
* Lifted from https://developer.android.com/develop/ui/views/animations/screen-slide-2#depth-page
|
||||
*/
|
||||
@RequiresApi(21)
|
||||
class DepthPageTransformer2 : ViewPager2.PageTransformer {
|
||||
|
||||
override fun transformPage(view: View, position: Float) {
|
||||
view.apply {
|
||||
val pageWidth = width
|
||||
when {
|
||||
position < -1 -> alpha = 0f
|
||||
position <= 0 -> {
|
||||
alpha = 1f
|
||||
translationX = 0f
|
||||
translationZ = 0f
|
||||
scaleX = 1f
|
||||
scaleY = 1f
|
||||
}
|
||||
position <= 1 -> {
|
||||
alpha = 1 - position
|
||||
|
||||
translationX = pageWidth * -position
|
||||
translationZ = -1f
|
||||
|
||||
val scaleFactor = (MIN_SCALE + (1 - MIN_SCALE) * (1 - Math.abs(position)))
|
||||
scaleX = scaleFactor
|
||||
scaleY = scaleFactor
|
||||
}
|
||||
else -> alpha = 0f
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -5,7 +5,6 @@ import android.content.ActivityNotFoundException
|
|||
import android.content.Context
|
||||
import android.content.DialogInterface
|
||||
import android.content.Intent
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.Menu
|
||||
|
@ -19,6 +18,7 @@ import androidx.core.view.WindowInsetsCompat
|
|||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.viewModels
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.viewpager2.widget.MarginPageTransformer
|
||||
import androidx.viewpager2.widget.ViewPager2.OFFSCREEN_PAGE_LIMIT_DEFAULT
|
||||
import androidx.viewpager2.widget.ViewPager2.OnPageChangeCallback
|
||||
import com.google.android.material.appbar.MaterialToolbar
|
||||
|
@ -28,7 +28,6 @@ import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
|
|||
import org.signal.core.util.concurrent.SignalExecutors
|
||||
import org.signal.core.util.logging.Log
|
||||
import org.thoughtcrime.securesms.R
|
||||
import org.thoughtcrime.securesms.animation.DepthPageTransformer2
|
||||
import org.thoughtcrime.securesms.attachments.DatabaseAttachment
|
||||
import org.thoughtcrime.securesms.components.ViewBinderDelegate
|
||||
import org.thoughtcrime.securesms.conversation.mutiselect.forward.MultiselectForwardFragment
|
||||
|
@ -47,6 +46,7 @@ import org.thoughtcrime.securesms.util.LifecycleDisposable
|
|||
import org.thoughtcrime.securesms.util.MediaUtil
|
||||
import org.thoughtcrime.securesms.util.SaveAttachmentTask
|
||||
import org.thoughtcrime.securesms.util.StorageUtil
|
||||
import org.thoughtcrime.securesms.util.ViewUtil
|
||||
import java.util.Locale
|
||||
import java.util.Optional
|
||||
|
||||
|
@ -108,9 +108,7 @@ class MediaPreviewV2Fragment : Fragment(R.layout.fragment_media_preview_v2), Med
|
|||
|
||||
private fun initializeViewPager() {
|
||||
binding.mediaPager.offscreenPageLimit = OFFSCREEN_PAGE_LIMIT_DEFAULT
|
||||
if (Build.VERSION.SDK_INT >= 21) {
|
||||
binding.mediaPager.setPageTransformer(DepthPageTransformer2())
|
||||
}
|
||||
binding.mediaPager.setPageTransformer(MarginPageTransformer(ViewUtil.dpToPx(24)))
|
||||
val adapter = MediaPreviewV2Adapter(this)
|
||||
binding.mediaPager.adapter = adapter
|
||||
binding.mediaPager.registerOnPageChangeCallback(object : OnPageChangeCallback() {
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
|
||||
<corners android:radius="5dp" />
|
||||
<corners android:radius="8dp" />
|
||||
|
||||
<stroke
|
||||
android:width="1px"
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
android:layout_marginStart="@dimen/media_preview_video_timestamp_inset"
|
||||
android:layout_marginTop="@dimen/media_preview_bottom_bar_vertical_outer_margin"
|
||||
android:layout_marginEnd="@dimen/media_preview_video_timestamp_inset"
|
||||
android:layout_marginBottom="@dimen/media_preview_bottom_bar_vertical_inner_margin"
|
||||
android:layout_marginBottom="4dp"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
|
||||
|
@ -53,6 +53,7 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginTop="11dp"
|
||||
android:layout_marginStart="12dp"
|
||||
android:layout_marginEnd="12dp"
|
||||
android:orientation="horizontal"
|
||||
|
@ -63,11 +64,10 @@
|
|||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/media_preview_bottom_bar_vertical_outer_margin"
|
||||
android:layout_marginTop="11dp"
|
||||
android:layout_marginBottom="@dimen/media_preview_bottom_bar_vertical_outer_margin"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal"
|
||||
android:paddingTop="4dp">
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/exo_share"
|
||||
|
@ -100,8 +100,9 @@
|
|||
<org.thoughtcrime.securesms.mediapreview.LottieAnimatedButton
|
||||
android:id="@id/exo_rew"
|
||||
style="@style/MediaPreviewButton"
|
||||
android:layout_width="32dp"
|
||||
android:layout_height="32dp"
|
||||
android:layout_width="@dimen/media_preview_lottie_button_dimen"
|
||||
android:layout_height="@dimen/media_preview_lottie_button_dimen"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:contentDescription="@string/exo_controls_rewind_description"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:background="@drawable/circle_touch_highlight_background_material3"
|
||||
|
@ -134,8 +135,9 @@
|
|||
<org.thoughtcrime.securesms.mediapreview.LottieAnimatedButton
|
||||
android:id="@id/exo_ffwd"
|
||||
style="@style/MediaPreviewButton"
|
||||
android:layout_width="32dp"
|
||||
android:layout_height="32dp"
|
||||
android:layout_width="@dimen/media_preview_lottie_button_dimen"
|
||||
android:layout_height="@dimen/media_preview_lottie_button_dimen"
|
||||
android:layout_marginStart="16dp"
|
||||
android:contentDescription="@string/exo_controls_fastforward_description"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:background="@drawable/circle_touch_highlight_background_material3"
|
||||
|
|
|
@ -27,8 +27,8 @@
|
|||
tools:visibility="visible"/>
|
||||
|
||||
<ImageView
|
||||
android:layout_width="44dp"
|
||||
android:layout_height="44dp"
|
||||
android:layout_width="45dp"
|
||||
android:layout_height="45dp"
|
||||
android:layout_gravity="center"
|
||||
android:src="@drawable/mediapicker_item_border_dark"/>
|
||||
|
||||
|
|
|
@ -235,10 +235,12 @@
|
|||
<dimen name="stories_landing_item_thumb_outline_width">52dp</dimen>
|
||||
<dimen name="stories_landing_item_thumb_outline_height">76dp</dimen>
|
||||
<dimen name="stories_landing_item_text_horizontal_margin">20dp</dimen>
|
||||
<dimen name="media_preview_video_timestamp_inset">24dp</dimen>
|
||||
<dimen name="media_preview_bottom_bar_vertical_inner_margin">24dp</dimen>
|
||||
|
||||
<dimen name="media_preview_video_timestamp_inset">20dp</dimen>
|
||||
<dimen name="media_preview_bottom_bar_vertical_inner_margin">16dp</dimen>
|
||||
<dimen name="media_preview_bottom_bar_vertical_outer_margin">16dp</dimen>
|
||||
<dimen name="exo_media_preview_button_width">48dp</dimen>
|
||||
<dimen name="exo_media_preview_button_height">48dp</dimen>
|
||||
<dimen name="media_preview_button_horizontal_margin">8dp</dimen>
|
||||
<dimen name="media_preview_lottie_button_dimen">36dp</dimen>
|
||||
</resources>
|
||||
|
|
Loading…
Add table
Reference in a new issue