Finished ViewModel to Data rework

This commit is contained in:
Sylvain Berfini 2021-04-15 09:58:17 +02:00
parent b803ae9a61
commit 5d89d8b098
26 changed files with 113 additions and 110 deletions

View file

@ -17,19 +17,19 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.linphone.activities.call.viewmodels package org.linphone.activities.call.data
import androidx.lifecycle.MutableLiveData import androidx.lifecycle.MutableLiveData
import org.linphone.contact.GenericContactViewModel import org.linphone.contact.GenericContactData
import org.linphone.core.Conference import org.linphone.core.Conference
import org.linphone.core.Participant import org.linphone.core.Participant
import org.linphone.core.tools.Log import org.linphone.core.tools.Log
class ConferenceParticipantViewModel( class ConferenceParticipantData(
private val conference: Conference, private val conference: Conference,
val participant: Participant val participant: Participant
) : ) :
GenericContactViewModel(participant.address) { GenericContactData(participant.address) {
private val isAdmin = MutableLiveData<Boolean>() private val isAdmin = MutableLiveData<Boolean>()
val isMeAdmin = MutableLiveData<Boolean>() val isMeAdmin = MutableLiveData<Boolean>()

View file

@ -124,7 +124,6 @@ open class CallViewModel(val call: Call) : GenericContactViewModel(call.remoteAd
} }
fun destroy() { fun destroy() {
// TODO: call it from CallsViewModel (after conference rework merge)
call.removeListener(listener) call.removeListener(listener)
} }

View file

@ -53,6 +53,7 @@ class CallsViewModel : ViewModel() {
val currentCall = core.currentCall val currentCall = core.currentCall
if (currentCall == null) { if (currentCall == null) {
currentCallViewModel.value?.destroy()
currentCallViewModel.value = null currentCallViewModel.value = null
} else if (currentCallViewModel.value == null) { } else if (currentCallViewModel.value == null) {
currentCallViewModel.value = CallViewModel(currentCall) currentCallViewModel.value = CallViewModel(currentCall)
@ -89,6 +90,7 @@ class CallsViewModel : ViewModel() {
val currentCall = coreContext.core.currentCall val currentCall = coreContext.core.currentCall
if (currentCall != null) { if (currentCall != null) {
currentCallViewModel.value?.destroy()
currentCallViewModel.value = CallViewModel(currentCall) currentCallViewModel.value = CallViewModel(currentCall)
} }
@ -142,6 +144,7 @@ class CallsViewModel : ViewModel() {
for (pausedCallViewModel in list) { for (pausedCallViewModel in list) {
if (pausedCallViewModel.call == call) { if (pausedCallViewModel.call == call) {
pausedCallViewModel.destroy()
list.remove(pausedCallViewModel) list.remove(pausedCallViewModel)
break break
} }

View file

@ -22,6 +22,7 @@ package org.linphone.activities.call.viewmodels
import androidx.lifecycle.MutableLiveData import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel import androidx.lifecycle.ViewModel
import org.linphone.LinphoneApplication.Companion.coreContext import org.linphone.LinphoneApplication.Companion.coreContext
import org.linphone.activities.call.data.ConferenceParticipantData
import org.linphone.core.* import org.linphone.core.*
import org.linphone.core.tools.Log import org.linphone.core.tools.Log
@ -32,7 +33,7 @@ class ConferenceViewModel : ViewModel() {
val conferenceAddress = MutableLiveData<Address>() val conferenceAddress = MutableLiveData<Address>()
val conferenceParticipants = MutableLiveData<List<ConferenceParticipantViewModel>>() val conferenceParticipants = MutableLiveData<List<ConferenceParticipantData>>()
val isInConference = MutableLiveData<Boolean>() val isInConference = MutableLiveData<Boolean>()
@ -144,10 +145,10 @@ class ConferenceViewModel : ViewModel() {
} }
private fun updateParticipantsList(conference: Conference) { private fun updateParticipantsList(conference: Conference) {
val participants = arrayListOf<ConferenceParticipantViewModel>() val participants = arrayListOf<ConferenceParticipantData>()
for (participant in conference.participantList) { for (participant in conference.participantList) {
Log.i("[Conference VM] Participant found: ${participant.address.asStringUriOnly()}") Log.i("[Conference VM] Participant found: ${participant.address.asStringUriOnly()}")
val viewModel = ConferenceParticipantViewModel(conference, participant) val viewModel = ConferenceParticipantData(conference, participant)
participants.add(viewModel) participants.add(viewModel)
} }
conferenceParticipants.value = participants conferenceParticipants.value = participants

View file

@ -26,7 +26,7 @@ import android.view.LayoutInflater
import android.widget.LinearLayout import android.widget.LinearLayout
import androidx.databinding.DataBindingUtil import androidx.databinding.DataBindingUtil
import org.linphone.R import org.linphone.R
import org.linphone.activities.call.viewmodels.ConferenceParticipantViewModel import org.linphone.activities.call.data.ConferenceParticipantData
import org.linphone.core.tools.Log import org.linphone.core.tools.Log
import org.linphone.databinding.CallConferenceParticipantBinding import org.linphone.databinding.CallConferenceParticipantBinding
@ -58,11 +58,11 @@ class ConferenceParticipantView : LinearLayout {
) )
} }
fun setViewModel(viewModel: ConferenceParticipantViewModel) { fun setData(data: ConferenceParticipantData) {
binding.viewModel = viewModel binding.data = data
val currentTimeSecs = System.currentTimeMillis() val currentTimeSecs = System.currentTimeMillis()
val participantTime = viewModel.participant.creationTime * 1000 // Linphone timestamps are in seconds val participantTime = data.participant.creationTime * 1000 // Linphone timestamps are in seconds
val diff = currentTimeSecs - participantTime val diff = currentTimeSecs - participantTime
Log.i("[Conference Participant] Participant joined conference at $participantTime == ${diff / 1000} seconds ago.") Log.i("[Conference Participant] Participant joined conference at $participantTime == ${diff / 1000} seconds ago.")
binding.callTimer.base = SystemClock.elapsedRealtime() - diff binding.callTimer.base = SystemClock.elapsedRealtime() - diff

View file

@ -119,7 +119,7 @@ class ChatMessagesListAdapter(
override fun onViewRecycled(holder: RecyclerView.ViewHolder) { override fun onViewRecycled(holder: RecyclerView.ViewHolder) {
when (holder) { when (holder) {
is ChatMessageViewHolder -> holder.binding.viewModel?.destroy() is ChatMessageViewHolder -> holder.binding.data?.destroy()
} }
} }
@ -141,7 +141,7 @@ class ChatMessagesListAdapter(
val chatMessage = eventLog.chatMessage val chatMessage = eventLog.chatMessage
chatMessage ?: return chatMessage ?: return
val chatMessageViewModel = ChatMessageData(chatMessage, contentClickedListener) val chatMessageViewModel = ChatMessageData(chatMessage, contentClickedListener)
viewModel = chatMessageViewModel data = chatMessageViewModel
lifecycleOwner = viewLifecycleOwner lifecycleOwner = viewLifecycleOwner
@ -248,7 +248,7 @@ class ChatMessagesListAdapter(
} }
private fun resendMessage() { private fun resendMessage() {
val chatMessage = binding.viewModel?.chatMessage val chatMessage = binding.data?.chatMessage
if (chatMessage != null) { if (chatMessage != null) {
chatMessage.userData = adapterPosition chatMessage.userData = adapterPosition
resendMessageEvent.value = Event(chatMessage) resendMessageEvent.value = Event(chatMessage)
@ -256,7 +256,7 @@ class ChatMessagesListAdapter(
} }
private fun copyTextToClipboard() { private fun copyTextToClipboard() {
val chatMessage = binding.viewModel?.chatMessage val chatMessage = binding.data?.chatMessage
if (chatMessage != null) { if (chatMessage != null) {
val content = chatMessage.contents.find { content -> content.isText } val content = chatMessage.contents.find { content -> content.isText }
if (content != null) { if (content != null) {
@ -269,21 +269,21 @@ class ChatMessagesListAdapter(
} }
private fun forwardMessage() { private fun forwardMessage() {
val chatMessage = binding.viewModel?.chatMessage val chatMessage = binding.data?.chatMessage
if (chatMessage != null) { if (chatMessage != null) {
forwardMessageEvent.value = Event(chatMessage) forwardMessageEvent.value = Event(chatMessage)
} }
} }
private fun showImdnDeliveryFragment() { private fun showImdnDeliveryFragment() {
val chatMessage = binding.viewModel?.chatMessage val chatMessage = binding.data?.chatMessage
if (chatMessage != null) { if (chatMessage != null) {
showImdnForMessageEvent.value = Event(chatMessage) showImdnForMessageEvent.value = Event(chatMessage)
} }
} }
private fun deleteMessage() { private fun deleteMessage() {
val chatMessage = binding.viewModel?.chatMessage val chatMessage = binding.data?.chatMessage
if (chatMessage != null) { if (chatMessage != null) {
chatMessage.userData = adapterPosition chatMessage.userData = adapterPosition
deleteMessageEvent.value = Event(chatMessage) deleteMessageEvent.value = Event(chatMessage)
@ -291,7 +291,7 @@ class ChatMessagesListAdapter(
} }
private fun addSenderToContacts() { private fun addSenderToContacts() {
val chatMessage = binding.viewModel?.chatMessage val chatMessage = binding.data?.chatMessage
if (chatMessage != null) { if (chatMessage != null) {
val copy = chatMessage.fromAddress.clone() val copy = chatMessage.fromAddress.clone()
copy.clean() // To remove gruu if any copy.clean() // To remove gruu if any
@ -306,7 +306,7 @@ class ChatMessagesListAdapter(
fun bind(eventLog: EventLog) { fun bind(eventLog: EventLog) {
with(binding) { with(binding) {
val eventViewModel = EventData(eventLog) val eventViewModel = EventData(eventLog)
viewModel = eventViewModel data = eventViewModel
binding.lifecycleOwner = viewLifecycleOwner binding.lifecycleOwner = viewLifecycleOwner

View file

@ -75,7 +75,7 @@ class ChatRoomCreationContactsAdapter(
fun bind(searchResult: SearchResult) { fun bind(searchResult: SearchResult) {
with(binding) { with(binding) {
val searchResultViewModel = ChatRoomCreationContactData(searchResult) val searchResultViewModel = ChatRoomCreationContactData(searchResult)
viewModel = searchResultViewModel data = searchResultViewModel
lifecycleOwner = viewLifecycleOwner lifecycleOwner = viewLifecycleOwner

View file

@ -56,7 +56,7 @@ class GroupInfoParticipantsAdapter(
} }
override fun onViewRecycled(holder: RecyclerView.ViewHolder) { override fun onViewRecycled(holder: RecyclerView.ViewHolder) {
(holder as ViewHolder).binding.viewModel?.destroy() (holder as ViewHolder).binding.data?.destroy()
} }
fun showAdminControls(show: Boolean) { fun showAdminControls(show: Boolean) {
@ -71,7 +71,7 @@ class GroupInfoParticipantsAdapter(
with(binding) { with(binding) {
val participantViewModel = GroupInfoParticipantData(participant) val participantViewModel = GroupInfoParticipantData(participant)
participantViewModel.showAdminControls.value = showAdmin participantViewModel.showAdminControls.value = showAdmin
viewModel = participantViewModel data = participantViewModel
lifecycleOwner = viewLifecycleOwner lifecycleOwner = viewLifecycleOwner

View file

@ -52,7 +52,7 @@ class ImdnAdapter(
} }
override fun onViewRecycled(holder: RecyclerView.ViewHolder) { override fun onViewRecycled(holder: RecyclerView.ViewHolder) {
(holder as ViewHolder).binding.viewModel?.destroy() (holder as ViewHolder).binding.data?.destroy()
} }
inner class ViewHolder( inner class ViewHolder(
@ -60,7 +60,7 @@ class ImdnAdapter(
) : RecyclerView.ViewHolder(binding.root) { ) : RecyclerView.ViewHolder(binding.root) {
fun bind(participantImdnState: ParticipantImdnState) { fun bind(participantImdnState: ParticipantImdnState) {
with(binding) { with(binding) {
viewModel = ImdnParticipantData(participantImdnState) data = ImdnParticipantData(participantImdnState)
lifecycleOwner = viewLifecycleOwner lifecycleOwner = viewLifecycleOwner

View file

@ -64,7 +64,7 @@ class RecordingsListAdapter(
} }
override fun onViewRecycled(holder: RecyclerView.ViewHolder) { override fun onViewRecycled(holder: RecyclerView.ViewHolder) {
(holder as ViewHolder).binding.viewModel?.destroy() (holder as ViewHolder).binding.data?.destroy()
} }
inner class ViewHolder( inner class ViewHolder(
@ -72,7 +72,7 @@ class RecordingsListAdapter(
) : RecyclerView.ViewHolder(binding.root) { ) : RecyclerView.ViewHolder(binding.root) {
fun bind(recording: RecordingData) { fun bind(recording: RecordingData) {
with(binding) { with(binding) {
viewModel = recording data = recording
lifecycleOwner = viewLifecycleOwner lifecycleOwner = viewLifecycleOwner

View file

@ -51,27 +51,27 @@ class ContactAvatarView : LinearLayout {
) )
} }
fun setViewModel(viewModel: ContactDataInterface) { fun setData(data: ContactDataInterface) {
val contact: Contact? = viewModel.contact.value val contact: Contact? = data.contact.value
val initials = if (contact != null) { val initials = if (contact != null) {
AppUtils.getInitials(contact.fullName ?: contact.firstName + " " + contact.lastName) AppUtils.getInitials(contact.fullName ?: contact.firstName + " " + contact.lastName)
} else { } else {
AppUtils.getInitials(viewModel.displayName) AppUtils.getInitials(data.displayName)
} }
binding.initials = initials binding.initials = initials
binding.generatedAvatarVisibility = initials.isNotEmpty() && initials != "+" binding.generatedAvatarVisibility = initials.isNotEmpty() && initials != "+"
binding.groupChatAvatarVisibility = viewModel.showGroupChatAvatar binding.groupChatAvatarVisibility = data.showGroupChatAvatar
binding.imagePath = contact?.getContactThumbnailPictureUri() binding.imagePath = contact?.getContactThumbnailPictureUri()
binding.borderVisibility = corePreferences.showBorderOnContactAvatar binding.borderVisibility = corePreferences.showBorderOnContactAvatar
binding.securityIcon = when (viewModel.securityLevel) { binding.securityIcon = when (data.securityLevel) {
ChatRoomSecurityLevel.Safe -> R.drawable.security_2_indicator ChatRoomSecurityLevel.Safe -> R.drawable.security_2_indicator
ChatRoomSecurityLevel.Encrypted -> R.drawable.security_1_indicator ChatRoomSecurityLevel.Encrypted -> R.drawable.security_1_indicator
else -> R.drawable.security_alert_indicator else -> R.drawable.security_alert_indicator
} }
binding.securityContentDescription = when (viewModel.securityLevel) { binding.securityContentDescription = when (data.securityLevel) {
ChatRoomSecurityLevel.Safe -> R.string.content_description_security_level_safe ChatRoomSecurityLevel.Safe -> R.string.content_description_security_level_safe
ChatRoomSecurityLevel.Encrypted -> R.string.content_description_security_level_encrypted ChatRoomSecurityLevel.Encrypted -> R.string.content_description_security_level_encrypted
else -> R.string.content_description_security_level_unsafe else -> R.string.content_description_security_level_unsafe

View file

@ -5,12 +5,12 @@
<data> <data>
<variable <variable
name="data" name="data"
type="org.linphone.activities.call.viewmodels.ConferenceParticipantViewModel" /> type="org.linphone.activities.call.data.ConferenceParticipantData" />
</data> </data>
<org.linphone.activities.call.views.ConferenceParticipantView <org.linphone.activities.call.views.ConferenceParticipantView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
bind:viewModel="@{data}"/> bind:data="@{data}"/>
</layout> </layout>

View file

@ -6,8 +6,8 @@
<data> <data>
<import type="android.view.View" /> <import type="android.view.View" />
<variable <variable
name="viewModel" name="data"
type="org.linphone.activities.call.viewmodels.ConferenceParticipantViewModel" /> type="org.linphone.activities.call.data.ConferenceParticipantData" />
</data> </data>
<LinearLayout <LinearLayout
@ -26,7 +26,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center" android:gravity="center"
app:viewModel="@{viewModel}" app:data="@{data}"
tools:layout="@layout/contact_avatar" /> tools:layout="@layout/contact_avatar" />
<LinearLayout <LinearLayout
@ -39,7 +39,7 @@
android:orientation="vertical"> android:orientation="vertical">
<org.linphone.views.MarqueeTextView <org.linphone.views.MarqueeTextView
android:text="@{viewModel.contact.fullName ?? viewModel.displayName}" android:text="@{data.contact.fullName ?? data.displayName}"
style="@style/contact_name_list_cell_font" style="@style/contact_name_list_cell_font"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@ -57,8 +57,8 @@
</LinearLayout> </LinearLayout>
<ImageView <ImageView
android:onClick="@{() -> viewModel.removeFromConference()}" android:onClick="@{() -> data.removeFromConference()}"
android:visibility="@{viewModel.isMeAdmin ? View.VISIBLE : View.GONE, default=gone}" android:visibility="@{data.isMeAdmin ? View.VISIBLE : View.GONE, default=gone}"
android:contentDescription="@string/content_description_remove_from_conference" android:contentDescription="@string/content_description_remove_from_conference"
android:layout_width="30dp" android:layout_width="30dp"
android:layout_height="30dp" android:layout_height="30dp"

View file

@ -24,7 +24,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center" android:gravity="center"
app:viewModel="@{viewModel}" app:data="@{viewModel}"
tools:layout="@layout/contact_avatar" /> tools:layout="@layout/contact_avatar" />
<org.linphone.views.MarqueeTextView <org.linphone.views.MarqueeTextView

View file

@ -21,7 +21,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
tools:layout="@layout/contact_avatar" tools:layout="@layout/contact_avatar"
app:viewModel="@{data}"/> app:data="@{data}"/>
<RelativeLayout <RelativeLayout
android:layout_width="wrap_content" android:layout_width="wrap_content"

View file

@ -10,7 +10,7 @@
name="clickListener" name="clickListener"
type="android.view.View.OnClickListener" /> type="android.view.View.OnClickListener" />
<variable <variable
name="viewModel" name="data"
type="org.linphone.activities.main.chat.data.EventData" /> type="org.linphone.activities.main.chat.data.EventData" />
<variable <variable
name="selectionListViewModel" name="selectionListViewModel"
@ -42,17 +42,17 @@
android:layout_marginBottom="5dp" android:layout_marginBottom="5dp"
android:layout_toLeftOf="@id/select" android:layout_toLeftOf="@id/select"
android:gravity="center" android:gravity="center"
android:background="@{viewModel.security ? @drawable/event_decoration_red : @drawable/event_decoration_gray, default=@drawable/event_decoration_gray}" android:background="@{data.security ? @drawable/event_decoration_red : @drawable/event_decoration_gray, default=@drawable/event_decoration_gray}"
android:orientation="horizontal"> android:orientation="horizontal">
<!-- Ugly hack to prevent last character to be missing half of it, don't know why yet --> <!-- Ugly hack to prevent last character to be missing half of it, don't know why yet -->
<TextView <TextView
android:text="@{viewModel.text + ' '}" android:text="@{data.text + ' '}"
android:textSize="13sp" android:textSize="13sp"
android:fontFamily="sans-serif" android:fontFamily="sans-serif"
android:lineSpacingExtra="0sp" android:lineSpacingExtra="0sp"
android:textStyle="italic" android:textStyle="italic"
android:textColor="@{viewModel.security ? @color/red_color : @color/light_grey_color}" android:textColor="@{data.security ? @color/red_color : @color/light_grey_color}"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingRight="5dp" android:paddingRight="5dp"

View file

@ -17,7 +17,7 @@
name="position" name="position"
type="Integer"/> type="Integer"/>
<variable <variable
name="viewModel" name="data"
type="org.linphone.activities.main.chat.data.ChatMessageData" /> type="org.linphone.activities.main.chat.data.ChatMessageData" />
<variable <variable
name="selectionListViewModel" name="selectionListViewModel"
@ -55,8 +55,8 @@
<ImageView <ImageView
android:id="@+id/imdn" android:id="@+id/imdn"
android:visibility="@{viewModel.chatMessage.outgoing ? (viewModel.showImdn ? View.VISIBLE : View.INVISIBLE) : View.INVISIBLE}" android:visibility="@{data.chatMessage.outgoing ? (data.showImdn ? View.VISIBLE : View.INVISIBLE) : View.INVISIBLE}"
android:src="@{viewModel.imdnIcon, default=@drawable/chat_delivered}" android:src="@{data.imdnIcon, default=@drawable/chat_delivered}"
android:contentDescription="@string/content_description_delivery_status" android:contentDescription="@string/content_description_delivery_status"
android:layout_width="10dp" android:layout_width="10dp"
android:layout_height="10dp" android:layout_height="10dp"
@ -65,36 +65,36 @@
<org.linphone.contact.ContactAvatarView <org.linphone.contact.ContactAvatarView
android:id="@+id/avatar" android:id="@+id/avatar"
android:visibility="@{viewModel.chatMessage.outgoing || selectionListViewModel.isEditionEnabled ? View.GONE : (viewModel.hideAvatar ? View.INVISIBLE : View.VISIBLE)}" android:visibility="@{data.chatMessage.outgoing || selectionListViewModel.isEditionEnabled ? View.GONE : (data.hideAvatar ? View.INVISIBLE : View.VISIBLE)}"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentLeft="true" android:layout_alignParentLeft="true"
android:layout_below="@id/time" android:layout_below="@id/time"
android:layout_marginLeft="10dp" android:layout_marginLeft="10dp"
android:gravity="center" android:gravity="center"
app:viewModel="@{viewModel}" app:data="@{data}"
tools:layout="@layout/contact_avatar" /> tools:layout="@layout/contact_avatar" />
<LinearLayout <LinearLayout
android:id="@+id/background" android:id="@+id/background"
android:onClick="@{clickListener}" android:onClick="@{clickListener}"
android:onLongClick="@{contextMenuClickListener}" android:onLongClick="@{contextMenuClickListener}"
android:background="@{viewModel.backgroundRes, default=@drawable/chat_bubble_outgoing_full}" android:background="@{data.backgroundRes, default=@drawable/chat_bubble_outgoing_full}"
android:descendantFocusability="blocksDescendants" android:descendantFocusability="blocksDescendants"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical" android:orientation="vertical"
android:layout_toLeftOf="@{viewModel.chatMessage.outgoing || selectionListViewModel.isEditionEnabled ? @id/imdn : 0}" android:layout_toLeftOf="@{data.chatMessage.outgoing || selectionListViewModel.isEditionEnabled ? @id/imdn : 0}"
android:layout_toRightOf="@id/avatar" android:layout_toRightOf="@id/avatar"
android:layout_below="@id/time" android:layout_below="@id/time"
android:layout_marginBottom="1dp" android:layout_marginBottom="1dp"
android:layout_marginRight="@{viewModel.chatMessage.outgoing ? @dimen/outgoing_chat_message_bubble_right_margin : @dimen/incoming_chat_message_bubble_right_margin}" android:layout_marginRight="@{data.chatMessage.outgoing ? @dimen/outgoing_chat_message_bubble_right_margin : @dimen/incoming_chat_message_bubble_right_margin}"
android:layout_marginLeft="@{selectionListViewModel.isEditionEnabled ? @dimen/edit_chat_message_bubble_left_margin : !viewModel.chatMessage.outgoing ? @dimen/incoming_chat_message_bubble_left_margin : @dimen/outgoing_chat_message_bubble_left_margin}" android:layout_marginLeft="@{selectionListViewModel.isEditionEnabled ? @dimen/edit_chat_message_bubble_left_margin : !data.chatMessage.outgoing ? @dimen/incoming_chat_message_bubble_left_margin : @dimen/outgoing_chat_message_bubble_left_margin}"
android:paddingTop="5dp" android:paddingTop="5dp"
android:paddingBottom="5dp"> android:paddingBottom="5dp">
<LinearLayout <LinearLayout
android:visibility="@{viewModel.chatMessage.forward ? View.VISIBLE : View.GONE, default=gone}" android:visibility="@{data.chatMessage.forward ? View.VISIBLE : View.GONE, default=gone}"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal" android:orientation="horizontal"
@ -129,20 +129,20 @@
android:layout_marginLeft="5dp" android:layout_marginLeft="5dp"
android:layout_marginRight="5dp" android:layout_marginRight="5dp"
android:longClickable="true" android:longClickable="true"
app:entries="@{viewModel.contents}" app:entries="@{data.contents}"
app:layout="@{@layout/chat_message_content_cell}" app:layout="@{@layout/chat_message_content_cell}"
app:onLongClick="@{contextMenuClickListener}" app:onLongClick="@{contextMenuClickListener}"
app:flexWrap="wrap" app:flexWrap="wrap"
app:alignItems="center" app:alignItems="center"
app:justifyContent="@{viewModel.chatMessage.outgoing ? JustifyContent.FLEX_END : JustifyContent.FLEX_START}"/> app:justifyContent="@{data.chatMessage.outgoing ? JustifyContent.FLEX_END : JustifyContent.FLEX_START}"/>
<org.linphone.activities.main.chat.views.MultiLineWrapContentWidthTextView <org.linphone.activities.main.chat.views.MultiLineWrapContentWidthTextView
android:onClick="@{clickListener}" android:onClick="@{clickListener}"
android:onLongClick="@{contextMenuClickListener}" android:onLongClick="@{contextMenuClickListener}"
android:text="@{viewModel.text}" android:text="@{data.text}"
android:visibility="@{viewModel.text.length > 0 ? View.VISIBLE : View.GONE}" android:visibility="@{data.text.length > 0 ? View.VISIBLE : View.GONE}"
android:autoLink="web" android:autoLink="web"
android:layout_gravity="@{viewModel.chatMessage.outgoing ? Gravity.RIGHT : Gravity.LEFT}" android:layout_gravity="@{data.chatMessage.outgoing ? Gravity.RIGHT : Gravity.LEFT}"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="10dp" android:layout_marginLeft="10dp"
@ -157,7 +157,7 @@
android:lineSpacingExtra="-1.7sp"/> android:lineSpacingExtra="-1.7sp"/>
<LinearLayout <LinearLayout
android:visibility="@{viewModel.chatMessage.ephemeral ? View.VISIBLE : View.GONE, default=gone}" android:visibility="@{data.chatMessage.ephemeral ? View.VISIBLE : View.GONE, default=gone}"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal" android:orientation="horizontal"
@ -167,7 +167,7 @@
android:layout_marginLeft="5dp"> android:layout_marginLeft="5dp">
<TextView <TextView
android:text="@{viewModel.ephemeralLifetime}" android:text="@{data.ephemeralLifetime}"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginRight="5dp" android:layout_marginRight="5dp"
@ -190,13 +190,13 @@
<TextView <TextView
android:id="@+id/time" android:id="@+id/time"
android:text="@{viewModel.chatMessage.outgoing ? viewModel.time : viewModel.time + ` - ` + (viewModel.contact.fullName ?? viewModel.displayName)}" android:text="@{data.chatMessage.outgoing ? data.time : data.time + ` - ` + (data.contact.fullName ?? data.displayName)}"
android:visibility="@{viewModel.hideTime ? View.GONE : View.VISIBLE}" android:visibility="@{data.hideTime ? View.GONE : View.VISIBLE}"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentTop="true" android:layout_alignParentTop="true"
android:layout_alignLeft="@{viewModel.chatMessage.outgoing || selectionListViewModel.isEditionEnabled ? 0 : @id/background}" android:layout_alignLeft="@{data.chatMessage.outgoing || selectionListViewModel.isEditionEnabled ? 0 : @id/background}"
android:layout_alignRight="@{viewModel.chatMessage.outgoing || selectionListViewModel.isEditionEnabled ? @id/background : 0}" android:layout_alignRight="@{data.chatMessage.outgoing || selectionListViewModel.isEditionEnabled ? @id/background : 0}"
android:layout_marginTop="7dp" android:layout_marginTop="7dp"
android:textColor="@color/chat_bubble_text_color" android:textColor="@color/chat_bubble_text_color"
android:textSize="13sp" android:textSize="13sp"
@ -205,7 +205,7 @@
android:lineSpacingExtra="0sp" /> android:lineSpacingExtra="0sp" />
<ProgressBar <ProgressBar
android:visibility="@{viewModel.transferInProgress || viewModel.sendInProgress ? View.VISIBLE : View.GONE}" android:visibility="@{data.transferInProgress || data.sendInProgress ? View.VISIBLE : View.GONE}"
android:layout_width="10dp" android:layout_width="10dp"
android:layout_height="10dp" android:layout_height="10dp"
android:layout_toRightOf="@id/background" android:layout_toRightOf="@id/background"

View file

@ -9,7 +9,7 @@
name="clickListener" name="clickListener"
type="android.view.View.OnClickListener"/> type="android.view.View.OnClickListener"/>
<variable <variable
name="viewModel" name="data"
type="org.linphone.activities.main.chat.data.ChatRoomCreationContactData" /> type="org.linphone.activities.main.chat.data.ChatRoomCreationContactData" />
</data> </data>
@ -19,7 +19,7 @@
<RelativeLayout <RelativeLayout
android:onClick="@{clickListener}" android:onClick="@{clickListener}"
android:enabled="@{!viewModel.isDisabled}" android:enabled="@{!data.isDisabled}"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:gravity="center_vertical" android:gravity="center_vertical"
@ -32,8 +32,8 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:gravity="center" android:gravity="center"
tools:layout="@layout/contact_avatar" tools:layout="@layout/contact_avatar"
app:showLimeCapability="@{viewModel.hasLimeX3DHCapability}" app:showLimeCapability="@{data.hasLimeX3DHCapability}"
app:viewModel="@{viewModel}"/> app:data="@{data}"/>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
@ -47,7 +47,7 @@
android:orientation="vertical"> android:orientation="vertical">
<TextView <TextView
android:text="@{viewModel.contact.fullName ?? viewModel.displayName}" android:text="@{data.contact.fullName ?? data.displayName}"
style="@style/contact_name_list_cell_font" style="@style/contact_name_list_cell_font"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@ -55,7 +55,7 @@
android:lines="1" /> android:lines="1" />
<TextView <TextView
android:text="@{viewModel.sipUri}" android:text="@{data.sipUri}"
style="@style/sip_uri_font" style="@style/sip_uri_font"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@ -66,7 +66,7 @@
</LinearLayout> </LinearLayout>
<ImageView <ImageView
android:visibility="@{viewModel.linphoneUser ? View.VISIBLE : View.INVISIBLE}" android:visibility="@{data.linphoneUser ? View.VISIBLE : View.INVISIBLE}"
android:id="@+id/linphone_user" android:id="@+id/linphone_user"
android:layout_width="30dp" android:layout_width="30dp"
android:layout_height="30dp" android:layout_height="30dp"
@ -77,7 +77,7 @@
android:src="@drawable/linphone_logo_tinted" /> android:src="@drawable/linphone_logo_tinted" />
<ImageView <ImageView
android:visibility="@{viewModel.isSelected ? View.VISIBLE : View.INVISIBLE}" android:visibility="@{data.isSelected ? View.VISIBLE : View.INVISIBLE}"
android:id="@+id/contact_is_select" android:id="@+id/contact_is_select"
android:layout_width="40dp" android:layout_width="40dp"
android:layout_height="40dp" android:layout_height="40dp"
@ -91,7 +91,7 @@
</RelativeLayout> </RelativeLayout>
<View <View
android:visibility="@{viewModel.isDisabled ? View.VISIBLE : View.GONE}" android:visibility="@{data.isDisabled ? View.VISIBLE : View.GONE}"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@color/contact_disabled_color"/> android:background="@color/contact_disabled_color"/>

View file

@ -31,7 +31,7 @@
android:layout_margin="5dp" android:layout_margin="5dp"
android:gravity="center" android:gravity="center"
app:showSecurityLevel="@{true}" app:showSecurityLevel="@{true}"
app:viewModel="@{data}" app:data="@{data}"
tools:layout="@layout/contact_avatar" /> tools:layout="@layout/contact_avatar" />
<LinearLayout <LinearLayout

View file

@ -10,7 +10,7 @@
name="removeClickListener" name="removeClickListener"
type="android.view.View.OnClickListener"/> type="android.view.View.OnClickListener"/>
<variable <variable
name="viewModel" name="data"
type="org.linphone.activities.main.chat.data.GroupInfoParticipantData" /> type="org.linphone.activities.main.chat.data.GroupInfoParticipantData" />
<variable <variable
name="isEncrypted" name="isEncrypted"
@ -28,14 +28,14 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="match_parent" android:layout_height="match_parent"
android:gravity="center" android:gravity="center"
app:showSecurityLevel="@{isEncrypted &amp;&amp; viewModel.securityLevel != ChatRoomSecurityLevel.ClearText}" app:showSecurityLevel="@{isEncrypted &amp;&amp; data.securityLevel != ChatRoomSecurityLevel.ClearText}"
app:showLimeCapability="@{isEncrypted &amp;&amp; viewModel.securityLevel == ChatRoomSecurityLevel.ClearText}" app:showLimeCapability="@{isEncrypted &amp;&amp; data.securityLevel == ChatRoomSecurityLevel.ClearText}"
app:viewModel="@{viewModel}" app:data="@{data}"
tools:layout="@layout/contact_avatar"/> tools:layout="@layout/contact_avatar"/>
<ImageView <ImageView
android:onClick="@{removeClickListener}" android:onClick="@{removeClickListener}"
android:visibility="@{viewModel.showAdminControls ? View.VISIBLE : View.GONE}" android:visibility="@{data.showAdminControls ? View.VISIBLE : View.GONE}"
android:contentDescription="@string/content_description_remove_contact_from_chat_room" android:contentDescription="@string/content_description_remove_contact_from_chat_room"
android:id="@+id/delete" android:id="@+id/delete"
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -47,7 +47,7 @@
android:src="@drawable/chat_group_delete" /> android:src="@drawable/chat_group_delete" />
<LinearLayout <LinearLayout
android:visibility="@{viewModel.showAdminControls ? View.VISIBLE : View.GONE}" android:visibility="@{data.showAdminControls ? View.VISIBLE : View.GONE}"
android:id="@+id/adminLayout" android:id="@+id/adminLayout"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@ -56,8 +56,8 @@
<LinearLayout <LinearLayout
android:id="@+id/isAdminLayout" android:id="@+id/isAdminLayout"
android:onClick="@{() -> viewModel.unSetAdmin()}" android:onClick="@{() -> data.unSetAdmin()}"
android:visibility="@{viewModel.admin ? View.VISIBLE : View.GONE}" android:visibility="@{data.admin ? View.VISIBLE : View.GONE}"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginRight="20dp"> android:layout_marginRight="20dp">
@ -84,8 +84,8 @@
<LinearLayout <LinearLayout
android:id="@+id/isNotAdminLayout" android:id="@+id/isNotAdminLayout"
android:onClick="@{() -> viewModel.setAdmin()}" android:onClick="@{() -> data.setAdmin()}"
android:visibility="@{viewModel.admin ? View.GONE : View.VISIBLE}" android:visibility="@{data.admin ? View.GONE : View.VISIBLE}"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginRight="20dp"> android:layout_marginRight="20dp">
@ -121,14 +121,14 @@
android:orientation="vertical"> android:orientation="vertical">
<org.linphone.views.MarqueeTextView <org.linphone.views.MarqueeTextView
android:text="@{viewModel.contact.fullName ?? viewModel.displayName}" android:text="@{data.contact.fullName ?? data.displayName}"
style="@style/contact_name_list_cell_font" style="@style/contact_name_list_cell_font"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:singleLine="true" /> android:singleLine="true" />
<org.linphone.views.MarqueeTextView <org.linphone.views.MarqueeTextView
android:text="@{viewModel.sipUri}" android:text="@{data.sipUri}"
android:id="@+id/sipUri" android:id="@+id/sipUri"
style="@style/sip_uri_small_font" style="@style/sip_uri_small_font"
android:layout_width="wrap_content" android:layout_width="wrap_content"

View file

@ -55,7 +55,7 @@
layout="@layout/chat_message_list_cell" layout="@layout/chat_message_list_cell"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:viewModel="@{viewModel.chatMessageViewModel}" app:data="@{viewModel.chatMessageViewModel}"
android:layout_margin="20dp" /> android:layout_margin="20dp" />
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView

View file

@ -6,7 +6,7 @@
<data> <data>
<import type="android.view.View"/> <import type="android.view.View"/>
<variable <variable
name="viewModel" name="data"
type="org.linphone.activities.main.chat.data.ImdnParticipantData" /> type="org.linphone.activities.main.chat.data.ImdnParticipantData" />
</data> </data>
@ -22,11 +22,11 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_centerVertical="true" android:layout_centerVertical="true"
tools:layout="@layout/contact_avatar" tools:layout="@layout/contact_avatar"
app:viewModel="@{viewModel}"/> app:data="@{data}"/>
<TextView <TextView
android:id="@+id/time" android:id="@+id/time"
android:text="@{viewModel.time}" android:text="@{data.time}"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentRight="true" android:layout_alignParentRight="true"
@ -44,14 +44,14 @@
android:orientation="vertical"> android:orientation="vertical">
<org.linphone.views.MarqueeTextView <org.linphone.views.MarqueeTextView
android:text="@{viewModel.contact.fullName ?? viewModel.displayName}" android:text="@{data.contact.fullName ?? data.displayName}"
style="@style/contact_name_list_cell_font" style="@style/contact_name_list_cell_font"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:singleLine="true" /> android:singleLine="true" />
<org.linphone.views.MarqueeTextView <org.linphone.views.MarqueeTextView
android:text="@{viewModel.sipUri}" android:text="@{data.sipUri}"
style="@style/sip_uri_small_font" style="@style/sip_uri_small_font"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"

View file

@ -45,7 +45,7 @@
tools:layout="@layout/contact_avatar" tools:layout="@layout/contact_avatar"
android:layout_centerHorizontal="true" android:layout_centerHorizontal="true"
app:showSecurityLevel="@{viewModel.encryptedChatRoom}" app:showSecurityLevel="@{viewModel.encryptedChatRoom}"
app:viewModel="@{viewModel}"/> app:data="@{viewModel}"/>
<TextView <TextView
android:id="@+id/date" android:id="@+id/date"

View file

@ -39,7 +39,7 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:gravity="center" android:gravity="center"
tools:layout="@layout/contact_avatar" tools:layout="@layout/contact_avatar"
app:viewModel="@{viewModel}"/> app:data="@{viewModel}"/>
<LinearLayout <LinearLayout
android:id="@+id/right" android:id="@+id/right"

View file

@ -92,7 +92,7 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_toRightOf="@id/icon" android:layout_toRightOf="@id/icon"
android:gravity="center" android:gravity="center"
app:viewModel="@{viewModel}" app:data="@{viewModel}"
tools:layout="@layout/contact_avatar" /> tools:layout="@layout/contact_avatar" />
<org.linphone.views.MarqueeTextView <org.linphone.views.MarqueeTextView

View file

@ -13,7 +13,7 @@
name="position" name="position"
type="Integer"/> type="Integer"/>
<variable <variable
name="viewModel" name="data"
type="org.linphone.activities.main.recordings.data.RecordingData" /> type="org.linphone.activities.main.recordings.data.RecordingData" />
<variable <variable
name="selectionListViewModel" name="selectionListViewModel"
@ -32,7 +32,7 @@
<ImageView <ImageView
android:id="@+id/record_play_pause" android:id="@+id/record_play_pause"
android:onClick="@{playListener}" android:onClick="@{playListener}"
android:selected="@{viewModel.isPlaying}" android:selected="@{data.isPlaying}"
android:contentDescription="@string/content_description_recording_toggle_play" android:contentDescription="@string/content_description_recording_toggle_play"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="match_parent" android:layout_height="match_parent"
@ -69,7 +69,7 @@
android:layout_alignParentTop="true"> android:layout_alignParentTop="true">
<TextView <TextView
android:text="@{viewModel.name}" android:text="@{data.name}"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" /> android:layout_height="wrap_content" />
@ -79,7 +79,7 @@
android:text=" - " /> android:text=" - " />
<TextView <TextView
android:text="@{viewModel.formattedDate}" android:text="@{data.formattedDate}"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" /> android:layout_height="wrap_content" />
@ -95,7 +95,7 @@
android:orientation="horizontal"> android:orientation="horizontal">
<TextView <TextView
android:text="@{viewModel.formattedPosition}" android:text="@{data.formattedPosition}"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center" /> android:layout_gravity="center" />
@ -106,7 +106,7 @@
android:text="/" /> android:text="/" />
<TextView <TextView
android:text="@{viewModel.formattedDuration}" android:text="@{data.formattedDuration}"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" /> android:layout_height="wrap_content" />
@ -114,9 +114,9 @@
<SeekBar <SeekBar
android:id="@+id/record_progression_bar" android:id="@+id/record_progression_bar"
onProgressChanged="@{(progress) -> viewModel.onProgressChanged(progress)}" onProgressChanged="@{(progress) -> data.onProgressChanged(progress)}"
android:max="@{viewModel.duration}" android:max="@{data.duration}"
android:progress="@{viewModel.position}" android:progress="@{data.position}"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentStart="true" android:layout_alignParentStart="true"