Added animation for in-call numpad
This commit is contained in:
parent
1eb4d3f4ec
commit
bd77288979
5 changed files with 40 additions and 2 deletions
|
@ -20,6 +20,7 @@
|
||||||
package org.linphone.activities.call.fragments
|
package org.linphone.activities.call.fragments
|
||||||
|
|
||||||
import android.Manifest
|
import android.Manifest
|
||||||
|
import android.animation.ValueAnimator
|
||||||
import android.annotation.TargetApi
|
import android.annotation.TargetApi
|
||||||
import android.app.Dialog
|
import android.app.Dialog
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
|
@ -27,7 +28,9 @@ import android.content.pm.PackageManager.PERMISSION_GRANTED
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.os.SystemClock
|
import android.os.SystemClock
|
||||||
import androidx.lifecycle.ViewModelProvider
|
import androidx.lifecycle.ViewModelProvider
|
||||||
|
import com.google.android.flexbox.FlexboxLayout
|
||||||
import org.linphone.LinphoneApplication.Companion.coreContext
|
import org.linphone.LinphoneApplication.Companion.coreContext
|
||||||
|
import org.linphone.LinphoneApplication.Companion.corePreferences
|
||||||
import org.linphone.R
|
import org.linphone.R
|
||||||
import org.linphone.activities.GenericFragment
|
import org.linphone.activities.GenericFragment
|
||||||
import org.linphone.activities.call.viewmodels.CallsViewModel
|
import org.linphone.activities.call.viewmodels.CallsViewModel
|
||||||
|
@ -53,6 +56,9 @@ class ControlsFragment : GenericFragment<CallControlsFragmentBinding>() {
|
||||||
|
|
||||||
override fun getLayoutId(): Int = R.layout.call_controls_fragment
|
override fun getLayoutId(): Int = R.layout.call_controls_fragment
|
||||||
|
|
||||||
|
// We have to use lateinit here because we need to compute the screen width first
|
||||||
|
private lateinit var numpadAnimator: ValueAnimator
|
||||||
|
|
||||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
||||||
super.onActivityCreated(savedInstanceState)
|
super.onActivityCreated(savedInstanceState)
|
||||||
|
|
||||||
|
@ -131,6 +137,18 @@ class ControlsFragment : GenericFragment<CallControlsFragmentBinding>() {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
controlsViewModel.toggleNumpadEvent.observe(viewLifecycleOwner, {
|
||||||
|
it.consume { open ->
|
||||||
|
if (this::numpadAnimator.isInitialized) {
|
||||||
|
if (open) {
|
||||||
|
numpadAnimator.start()
|
||||||
|
} else {
|
||||||
|
numpadAnimator.reverse()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
controlsViewModel.somethingClickedEvent.observe(viewLifecycleOwner, {
|
controlsViewModel.somethingClickedEvent.observe(viewLifecycleOwner, {
|
||||||
it.consume {
|
it.consume {
|
||||||
sharedViewModel.resetHiddenInterfaceTimerInVideoCallEvent.value = Event(true)
|
sharedViewModel.resetHiddenInterfaceTimerInVideoCallEvent.value = Event(true)
|
||||||
|
@ -142,6 +160,22 @@ class ControlsFragment : GenericFragment<CallControlsFragmentBinding>() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onStart() {
|
||||||
|
super.onStart()
|
||||||
|
val screenWidth = requireActivity().windowManager.defaultDisplay.width.toFloat()
|
||||||
|
numpadAnimator = ValueAnimator.ofFloat(screenWidth, 0f).apply {
|
||||||
|
addUpdateListener {
|
||||||
|
val value = it.animatedValue as Float
|
||||||
|
view?.findViewById<FlexboxLayout>(R.id.numpad)?.translationX = -value
|
||||||
|
duration = if (corePreferences.enableAnimations) 500 else 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Hide the numpad here as we can't set the translationX property on include tag in layout
|
||||||
|
if (controlsViewModel.numpadVisibility.value == false) {
|
||||||
|
view?.findViewById<FlexboxLayout>(R.id.numpad)?.translationX = -screenWidth
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun onRequestPermissionsResult(
|
override fun onRequestPermissionsResult(
|
||||||
requestCode: Int,
|
requestCode: Int,
|
||||||
permissions: Array<out String>,
|
permissions: Array<out String>,
|
||||||
|
|
|
@ -100,6 +100,10 @@ class ControlsViewModel : ViewModel() {
|
||||||
|
|
||||||
val audioRoutesMenuTranslateY = MutableLiveData<Float>()
|
val audioRoutesMenuTranslateY = MutableLiveData<Float>()
|
||||||
|
|
||||||
|
val toggleNumpadEvent: MutableLiveData<Event<Boolean>> by lazy {
|
||||||
|
MutableLiveData<Event<Boolean>>()
|
||||||
|
}
|
||||||
|
|
||||||
private val bounceAnimator: ValueAnimator by lazy {
|
private val bounceAnimator: ValueAnimator by lazy {
|
||||||
ValueAnimator.ofFloat(AppUtils.getDimension(R.dimen.tabs_fragment_unread_count_bounce_offset), 0f).apply {
|
ValueAnimator.ofFloat(AppUtils.getDimension(R.dimen.tabs_fragment_unread_count_bounce_offset), 0f).apply {
|
||||||
addUpdateListener {
|
addUpdateListener {
|
||||||
|
@ -293,6 +297,7 @@ class ControlsViewModel : ViewModel() {
|
||||||
fun toggleNumpadVisibility() {
|
fun toggleNumpadVisibility() {
|
||||||
somethingClickedEvent.value = Event(true)
|
somethingClickedEvent.value = Event(true)
|
||||||
numpadVisibility.value = numpadVisibility.value != true
|
numpadVisibility.value = numpadVisibility.value != true
|
||||||
|
toggleNumpadEvent.value = Event(numpadVisibility.value ?: true)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun toggleRoutesMenu() {
|
fun toggleRoutesMenu() {
|
||||||
|
|
|
@ -141,7 +141,6 @@
|
||||||
|
|
||||||
<include
|
<include
|
||||||
layout="@layout/numpad"
|
layout="@layout/numpad"
|
||||||
android:visibility="@{controlsViewModel.numpadVisibility ? View.VISIBLE : View.GONE, default=gone}"
|
|
||||||
bind:keyListener="@{controlsViewModel.onKeyClick}"
|
bind:keyListener="@{controlsViewModel.onKeyClick}"
|
||||||
android:layout_above="@id/primary_buttons_row"
|
android:layout_above="@id/primary_buttons_row"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|
|
@ -256,7 +256,6 @@
|
||||||
|
|
||||||
<include
|
<include
|
||||||
layout="@layout/numpad"
|
layout="@layout/numpad"
|
||||||
android:visibility="@{controlsViewModel.numpadVisibility ? View.VISIBLE : View.GONE, default=gone}"
|
|
||||||
bind:keyListener="@{controlsViewModel.onKeyClick}"
|
bind:keyListener="@{controlsViewModel.onKeyClick}"
|
||||||
android:layout_above="@id/primary_buttons_row"
|
android:layout_above="@id/primary_buttons_row"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
</data>
|
</data>
|
||||||
|
|
||||||
<com.google.android.flexbox.FlexboxLayout
|
<com.google.android.flexbox.FlexboxLayout
|
||||||
|
android:id="@+id/numpad"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:padding="10dp"
|
android:padding="10dp"
|
||||||
|
|
Loading…
Reference in a new issue