Added bounce animation to chat unread counter in call activity
This commit is contained in:
parent
de29c590ac
commit
d216eaeef7
3 changed files with 37 additions and 2 deletions
|
@ -20,12 +20,16 @@
|
|||
package org.linphone.activities.call.fragments
|
||||
|
||||
import android.Manifest
|
||||
import android.animation.ValueAnimator
|
||||
import android.annotation.TargetApi
|
||||
import android.app.Dialog
|
||||
import android.content.Intent
|
||||
import android.content.pm.PackageManager.PERMISSION_GRANTED
|
||||
import android.os.Bundle
|
||||
import android.os.SystemClock
|
||||
import android.view.View
|
||||
import android.view.animation.LinearInterpolator
|
||||
import android.widget.TextView
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import org.linphone.LinphoneApplication.Companion.coreContext
|
||||
import org.linphone.R
|
||||
|
@ -53,6 +57,10 @@ class ControlsFragment : GenericFragment<CallControlsFragmentBinding>() {
|
|||
|
||||
override fun getLayoutId(): Int = R.layout.call_controls_fragment
|
||||
|
||||
private val bounceAnimator: ValueAnimator by lazy {
|
||||
ValueAnimator.ofFloat(resources.getDimension(R.dimen.tabs_fragment_unread_count_bounce_offset), 0f)
|
||||
}
|
||||
|
||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
||||
super.onActivityCreated(savedInstanceState)
|
||||
|
||||
|
@ -142,6 +150,29 @@ class ControlsFragment : GenericFragment<CallControlsFragmentBinding>() {
|
|||
}
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
bounceAnimator.addUpdateListener {
|
||||
val value = it.animatedValue as Float
|
||||
view.findViewById<TextView>(R.id.chat_unread_count).translationY = -value
|
||||
}
|
||||
bounceAnimator.interpolator = LinearInterpolator()
|
||||
bounceAnimator.duration = 250
|
||||
bounceAnimator.repeatMode = ValueAnimator.REVERSE
|
||||
bounceAnimator.repeatCount = ValueAnimator.INFINITE
|
||||
}
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
bounceAnimator.start()
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
bounceAnimator.pause()
|
||||
super.onStop()
|
||||
}
|
||||
|
||||
override fun onRequestPermissionsResult(
|
||||
requestCode: Int,
|
||||
permissions: Array<out String>,
|
||||
|
|
|
@ -79,12 +79,16 @@
|
|||
android:src="@drawable/footer_chat" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/chat_unread_count"
|
||||
android:text="@{String.valueOf(viewModel.unreadMessagesCount)}"
|
||||
android:visibility="@{viewModel.unreadMessagesCount == 0 ? View.GONE : View.VISIBLE}"
|
||||
style="@style/unread_count_font"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="15dp"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_marginRight="25dp"
|
||||
android:layout_marginTop="5dp"
|
||||
android:background="@drawable/unread_message_count_bg"
|
||||
android:gravity="center" />
|
||||
|
||||
|
|
Loading…
Reference in a new issue