mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-24 04:58:45 +00:00
Tie CallLogViewModel lifecycle to the activity.
This commit is contained in:
committed by
Cody Henthorne
parent
e5e86e639a
commit
e7b18bd3a2
@@ -17,6 +17,7 @@ import androidx.core.app.SharedElementCallback
|
||||
import androidx.core.view.MenuProvider
|
||||
import androidx.core.view.ViewCompat
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import androidx.fragment.app.viewModels
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import androidx.transition.TransitionInflater
|
||||
@@ -75,7 +76,7 @@ class CallLogFragment : Fragment(R.layout.call_log_fragment), CallLogAdapter.Cal
|
||||
private val TAG = Log.tag(CallLogFragment::class.java)
|
||||
}
|
||||
|
||||
private val viewModel: CallLogViewModel by viewModels()
|
||||
private val viewModel: CallLogViewModel by activityViewModels()
|
||||
private val binding: CallLogFragmentBinding by ViewBinderDelegate(CallLogFragmentBinding::bind)
|
||||
private val disposables = LifecycleDisposable()
|
||||
private val callLogContextMenu = CallLogContextMenu(this, this)
|
||||
@@ -311,6 +312,12 @@ class CallLogFragment : Fragment(R.layout.call_log_fragment), CallLogAdapter.Cal
|
||||
val progress = 1 - verticalOffset.toFloat() / -layout.height
|
||||
binding.pullView.onUserDrag(progress)
|
||||
}
|
||||
|
||||
if (viewModel.filterSnapshot != CallLogFilter.ALL) {
|
||||
binding.root.doAfterNextLayout {
|
||||
binding.pullView.openImmediate()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreateACallLinkClicked() {
|
||||
|
||||
@@ -8,7 +8,6 @@ import androidx.lifecycle.LifecycleOwner
|
||||
import org.signal.core.util.logging.Log
|
||||
import org.thoughtcrime.securesms.util.Util
|
||||
import java.util.concurrent.TimeUnit
|
||||
import kotlin.math.max
|
||||
|
||||
/**
|
||||
* Lifecycle-aware class which will call onTick every 1 minute.
|
||||
|
||||
@@ -23,6 +23,7 @@ import org.thoughtcrime.securesms.util.VibrateUtil
|
||||
import org.thoughtcrime.securesms.util.doOnEachLayout
|
||||
import kotlin.math.max
|
||||
import kotlin.math.min
|
||||
import kotlin.time.Duration
|
||||
import kotlin.time.Duration.Companion.milliseconds
|
||||
|
||||
/**
|
||||
@@ -193,6 +194,18 @@ class ConversationListFilterPullView @JvmOverloads constructor(
|
||||
return state == FilterPullState.OPEN
|
||||
}
|
||||
|
||||
fun openImmediate() {
|
||||
if (state == FilterPullState.CLOSED) {
|
||||
setState(FilterPullState.OPEN_APEX, source)
|
||||
setState(FilterPullState.OPENING, source)
|
||||
animatePillIn(
|
||||
source = ConversationFilterSource.OVERFLOW,
|
||||
animationStartDelay = 0.milliseconds,
|
||||
animationDuration = 0.milliseconds
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun open(source: ConversationFilterSource) {
|
||||
setState(FilterPullState.OPENING, source)
|
||||
animatePillIn(source)
|
||||
@@ -214,15 +227,19 @@ class ConversationListFilterPullView @JvmOverloads constructor(
|
||||
})
|
||||
}
|
||||
|
||||
private fun animatePillIn(source: ConversationFilterSource) {
|
||||
private fun animatePillIn(
|
||||
source: ConversationFilterSource,
|
||||
animationStartDelay: Duration = 300.milliseconds,
|
||||
animationDuration: Duration = 300.milliseconds
|
||||
) {
|
||||
binding.filterText.visibility = VISIBLE
|
||||
binding.filterText.alpha = 0f
|
||||
binding.filterText.isEnabled = true
|
||||
|
||||
pillAnimator?.cancel()
|
||||
pillAnimator = ObjectAnimator.ofFloat(binding.filterText, ALPHA, 1f).apply {
|
||||
startDelay = 300
|
||||
duration = 300
|
||||
startDelay = animationStartDelay.inWholeMilliseconds
|
||||
duration = animationDuration.inWholeMilliseconds
|
||||
doOnEnd {
|
||||
setState(FilterPullState.OPEN, source)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user