diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/conversations/ConversationsAdapter.kt b/presentation/src/main/java/com/moez/QKSMS/feature/conversations/ConversationsAdapter.kt
index f35caac4b..b9a05e44a 100644
--- a/presentation/src/main/java/com/moez/QKSMS/feature/conversations/ConversationsAdapter.kt
+++ b/presentation/src/main/java/com/moez/QKSMS/feature/conversations/ConversationsAdapter.kt
@@ -18,9 +18,12 @@
*/
package com.moez.QKSMS.feature.conversations
+import android.animation.AnimatorInflater
+import android.animation.AnimatorSet
import android.content.Context
import android.graphics.Typeface
import android.view.LayoutInflater
+import android.view.View
import android.view.ViewGroup
import androidx.core.view.isVisible
import com.moez.QKSMS.R
@@ -70,7 +73,11 @@ class ConversationsAdapter @Inject constructor(
view.setOnClickListener {
val conversation = getItem(adapterPosition) ?: return@setOnClickListener
when (toggleSelection(conversation.id, false)) {
- true -> view.isActivated = isSelected(conversation.id)
+ true -> {
+ view.isActivated = isSelected(conversation.id)
+ // add selection image
+ flipAvatarPic(view)
+ }
false -> navigator.showConversation(conversation.id)
}
}
@@ -78,6 +85,8 @@ class ConversationsAdapter @Inject constructor(
val conversation = getItem(adapterPosition) ?: return@setOnLongClickListener true
toggleSelection(conversation.id)
view.isActivated = isSelected(conversation.id)
+ // add selection image
+ flipAvatarPic(view)
true
}
}
@@ -87,7 +96,10 @@ class ConversationsAdapter @Inject constructor(
val conversation = getItem(position) ?: return
val view = viewHolder.containerView
+ val origActivated = view.isActivated
view.isActivated = isSelected(conversation.id)
+ // add selection image
+ if (origActivated != view.isActivated) flipAvatarPic(view)
view.avatars.contacts = conversation.recipients
view.title.collapseEnabled = conversation.recipients.size > 1
@@ -108,4 +120,24 @@ class ConversationsAdapter @Inject constructor(
override fun getItemViewType(position: Int): Int {
return if (getItem(position)?.unread == false) 0 else 1
}
+
+ // add selection image
+ private fun flipAvatarPic(parentView: View) {
+ if (parentView.isActivated) {
+ animatorFlipViews(parentView.avatars, parentView.checked)
+ } else {
+ animatorFlipViews(parentView.checked, parentView.avatars)
+ }
+ }
+
+ private fun animatorFlipViews(oldView: View, newView: View) {
+ val animatorSetOldView = AnimatorInflater.loadAnimator(oldView.context, R.animator.flip_front) as AnimatorSet
+ animatorSetOldView.setTarget(oldView)
+ val animatorSetNewView = AnimatorInflater.loadAnimator(newView.context, R.animator.flip_back) as AnimatorSet
+ animatorSetNewView.setTarget(newView)
+
+ val combAnimatorSet = AnimatorSet()
+ combAnimatorSet.playSequentially(animatorSetOldView,animatorSetNewView)
+ combAnimatorSet.start()
+ }
}
\ No newline at end of file
diff --git a/presentation/src/main/res/animator/flip_back.xml b/presentation/src/main/res/animator/flip_back.xml
new file mode 100644
index 000000000..44a13a1f5
--- /dev/null
+++ b/presentation/src/main/res/animator/flip_back.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/presentation/src/main/res/animator/flip_front.xml b/presentation/src/main/res/animator/flip_front.xml
new file mode 100644
index 000000000..75ec3d142
--- /dev/null
+++ b/presentation/src/main/res/animator/flip_front.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/presentation/src/main/res/drawable/ic_check_circle_24dp.xml b/presentation/src/main/res/drawable/ic_check_circle_24dp.xml
new file mode 100644
index 000000000..cfdbfc787
--- /dev/null
+++ b/presentation/src/main/res/drawable/ic_check_circle_24dp.xml
@@ -0,0 +1,8 @@
+
+
+
+
diff --git a/presentation/src/main/res/layout/conversation_list_item.xml b/presentation/src/main/res/layout/conversation_list_item.xml
index e4159c53e..911cbe657 100644
--- a/presentation/src/main/res/layout/conversation_list_item.xml
+++ b/presentation/src/main/res/layout/conversation_list_item.xml
@@ -30,6 +30,17 @@
android:paddingEnd="16dp"
android:paddingBottom="12dp">
+
+