Show progress spinner if media send takes more than 300ms.
This commit is contained in:
parent
076facbdc2
commit
82e9c620e8
2 changed files with 39 additions and 1 deletions
|
@ -2,13 +2,16 @@ package org.thoughtcrime.securesms.mediasend.v2.review
|
|||
|
||||
import android.animation.Animator
|
||||
import android.animation.AnimatorSet
|
||||
import android.graphics.Color
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.widget.ImageView
|
||||
import android.widget.ProgressBar
|
||||
import android.widget.TextView
|
||||
import android.widget.ViewSwitcher
|
||||
import androidx.activity.OnBackPressedCallback
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import androidx.core.graphics.drawable.DrawableCompat
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.setFragmentResultListener
|
||||
import androidx.fragment.app.viewModels
|
||||
|
@ -31,6 +34,8 @@ import org.thoughtcrime.securesms.permissions.Permissions
|
|||
import org.thoughtcrime.securesms.recipients.RecipientId
|
||||
import org.thoughtcrime.securesms.util.MappingAdapter
|
||||
import org.thoughtcrime.securesms.util.MediaUtil
|
||||
import org.thoughtcrime.securesms.util.views.TouchInterceptingFrameLayout
|
||||
import org.thoughtcrime.securesms.util.visible
|
||||
|
||||
/**
|
||||
* Allows the user to view and edit selected media.
|
||||
|
@ -58,6 +63,8 @@ class MediaReviewFragment : Fragment(R.layout.v2_media_review_fragment) {
|
|||
private lateinit var controls: ConstraintLayout
|
||||
private lateinit var selectionRecycler: RecyclerView
|
||||
private lateinit var controlsShade: View
|
||||
private lateinit var progress: ProgressBar
|
||||
private lateinit var progressWrapper: TouchInterceptingFrameLayout
|
||||
|
||||
private val navigator = MediaSelectionNavigator(
|
||||
toGallery = R.id.action_mediaReviewFragment_to_mediaGalleryFragment,
|
||||
|
@ -86,6 +93,11 @@ class MediaReviewFragment : Fragment(R.layout.v2_media_review_fragment) {
|
|||
selectionRecycler = view.findViewById(R.id.selection_recycler)
|
||||
controlsShade = view.findViewById(R.id.controls_shade)
|
||||
viewOnceMessage = view.findViewById(R.id.view_once_message)
|
||||
progress = view.findViewById(R.id.progress)
|
||||
progressWrapper = view.findViewById(R.id.progress_wrapper)
|
||||
|
||||
DrawableCompat.setTint(progress.indeterminateDrawable, Color.WHITE)
|
||||
progressWrapper.setOnInterceptTouchEventListener { true }
|
||||
|
||||
val pagerAdapter = MediaReviewFragmentPagerAdapter(this)
|
||||
|
||||
|
@ -218,6 +230,12 @@ class MediaReviewFragment : Fragment(R.layout.v2_media_review_fragment) {
|
|||
}
|
||||
|
||||
private fun performSend(selection: List<RecipientId> = listOf()) {
|
||||
progressWrapper.visible = true
|
||||
progressWrapper.animate()
|
||||
.setStartDelay(300)
|
||||
.setInterpolator(MediaAnimations.interpolator)
|
||||
.alpha(1f)
|
||||
|
||||
sharedViewModel
|
||||
.send(selection)
|
||||
.subscribe(
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
android:alpha="0"
|
||||
android:background="@drawable/image_editor_hud_clear_all_background"
|
||||
android:drawablePadding="4dp"
|
||||
android:maxLines="1"
|
||||
android:paddingStart="14dp"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingEnd="14dp"
|
||||
|
@ -43,7 +44,6 @@
|
|||
android:textAppearance="@style/TextAppearance.Signal.Body2"
|
||||
android:textColor="@color/core_white"
|
||||
android:visibility="gone"
|
||||
android:maxLines="1"
|
||||
app:drawableStartCompat="@drawable/ic_arrow_right_16"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
|
@ -281,4 +281,24 @@
|
|||
tools:translationY="0dp" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<org.thoughtcrime.securesms.util.views.TouchInterceptingFrameLayout
|
||||
android:id="@+id/progress_wrapper"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:alpha="0"
|
||||
android:background="@color/transparent_black_60"
|
||||
android:visibility="gone"
|
||||
tools:alpha="1"
|
||||
tools:visibility="visible">
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/progress"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:indeterminate="true"
|
||||
android:indeterminateBehavior="cycle" />
|
||||
</org.thoughtcrime.securesms.util.views.TouchInterceptingFrameLayout>
|
||||
|
||||
</FrameLayout>
|
Loading…
Add table
Reference in a new issue