diff --git a/app/src/main/java/org/linphone/ui/main/contacts/model/ContactAvatarModel.kt b/app/src/main/java/org/linphone/ui/main/contacts/model/ContactAvatarModel.kt index 9ebbb89a7..a4b91f266 100644 --- a/app/src/main/java/org/linphone/ui/main/contacts/model/ContactAvatarModel.kt +++ b/app/src/main/java/org/linphone/ui/main/contacts/model/ContactAvatarModel.kt @@ -69,7 +69,7 @@ class ContactAvatarModel @WorkerThread constructor(val friend: Friend) : Abstrac friend.addListener(friendListener) initials.postValue(AppUtils.getInitials(friend.name.orEmpty())) - trust.postValue(SecurityLevel.Safe) // TODO FIXME: use API + trust.postValue(SecurityLevel.Encrypted) // TODO FIXME: use API showTrust.postValue(coreContext.core.defaultAccount?.isInSecureMode()) images.postValue(arrayListOf(getAvatarUri(friend).toString())) diff --git a/app/src/main/java/org/linphone/utils/DataBindingUtils.kt b/app/src/main/java/org/linphone/utils/DataBindingUtils.kt index 5bbfcadcc..4969a070b 100644 --- a/app/src/main/java/org/linphone/utils/DataBindingUtils.kt +++ b/app/src/main/java/org/linphone/utils/DataBindingUtils.kt @@ -57,6 +57,7 @@ import coil.imageLoader import coil.load import coil.request.ImageRequest import coil.transform.CircleCropTransformation +import com.google.android.material.imageview.ShapeableImageView import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.coroutineScope import kotlinx.coroutines.launch @@ -65,6 +66,7 @@ import org.linphone.BR import org.linphone.R import org.linphone.contacts.AbstractAvatarModel import org.linphone.contacts.AvatarGenerator +import org.linphone.core.ChatRoom import org.linphone.core.ConsolidatedPresence import org.linphone.core.tools.Log @@ -210,7 +212,7 @@ fun AppCompatTextView.setColor(@ColorRes color: Int) { @UiThread @BindingAdapter("coil") -fun ImageView.loadCircleFileWithCoil(file: String?) { +fun ShapeableImageView.loadCircleFileWithCoil(file: String?) { Log.i("[Data Binding Utils] Loading file [$file] with coil") if (file != null) { load(file) { @@ -221,7 +223,7 @@ fun ImageView.loadCircleFileWithCoil(file: String?) { @UiThread @BindingAdapter("coilAvatar") -fun ImageView.loadAvatarWithCoil(model: AbstractAvatarModel?) { +fun ShapeableImageView.loadAvatarWithCoil(model: AbstractAvatarModel?) { val imageView = this (context as AppCompatActivity).lifecycleScope.launch { loadContactPictureWithCoil(imageView, model) @@ -230,7 +232,7 @@ fun ImageView.loadAvatarWithCoil(model: AbstractAvatarModel?) { @UiThread @BindingAdapter("coilBubbleAvatar") -fun ImageView.loadBubbleAvatarWithCoil(model: AbstractAvatarModel?) { +fun ShapeableImageView.loadBubbleAvatarWithCoil(model: AbstractAvatarModel?) { val imageView = this (context as AppCompatActivity).lifecycleScope.launch { val size = R.dimen.avatar_bubble_size @@ -241,7 +243,7 @@ fun ImageView.loadBubbleAvatarWithCoil(model: AbstractAvatarModel?) { @UiThread @BindingAdapter("coilBigAvatar") -fun ImageView.loadBigAvatarWithCoil(model: AbstractAvatarModel?) { +fun ShapeableImageView.loadBigAvatarWithCoil(model: AbstractAvatarModel?) { val imageView = this (context as AppCompatActivity).lifecycleScope.launch { val size = R.dimen.avatar_big_size @@ -252,7 +254,7 @@ fun ImageView.loadBigAvatarWithCoil(model: AbstractAvatarModel?) { @UiThread @BindingAdapter("coilCallAvatar") -fun ImageView.loadCallAvatarWithCoil(model: AbstractAvatarModel?) { +fun ShapeableImageView.loadCallAvatarWithCoil(model: AbstractAvatarModel?) { val imageView = this (context as AppCompatActivity).lifecycleScope.launch { val size = R.dimen.avatar_in_call_size @@ -263,7 +265,7 @@ fun ImageView.loadCallAvatarWithCoil(model: AbstractAvatarModel?) { @UiThread @BindingAdapter("coilInitials") -fun ImageView.loadInitialsAvatarWithCoil(initials: String?) { +fun ShapeableImageView.loadInitialsAvatarWithCoil(initials: String?) { Log.i("[Data Binding Utils] Displaying initials [$initials] on ImageView") val imageView = this (context as AppCompatActivity).lifecycleScope.launch { @@ -277,7 +279,7 @@ fun ImageView.loadInitialsAvatarWithCoil(initials: String?) { @SuppressLint("ResourceType") private suspend fun loadContactPictureWithCoil( - imageView: ImageView, + imageView: ShapeableImageView, model: AbstractAvatarModel?, @DimenRes size: Int = 0, @DimenRes textSize: Int = 0 @@ -287,6 +289,26 @@ private suspend fun loadContactPictureWithCoil( val context = imageView.context if (model != null) { + if (model.showTrust.value == true) { + when (model.trust.value) { + ChatRoom.SecurityLevel.Safe -> { + imageView.setStrokeColorResource(R.color.blue_info_500) + imageView.setStrokeWidthResource(R.dimen.avatar_trust_border_width) + } + ChatRoom.SecurityLevel.Unsafe -> { + imageView.setStrokeColorResource(R.color.red_danger_500) + imageView.setStrokeWidthResource(R.dimen.avatar_trust_border_width) + } + else -> { + imageView.setStrokeColorResource(R.color.transparent_color) + imageView.setStrokeWidthResource(R.dimen.zero) + } + } + } else { + imageView.setStrokeColorResource(R.color.transparent_color) + imageView.setStrokeWidthResource(R.dimen.zero) + } + val images = model.images.value.orEmpty() val count = images.size if (count == 1) { diff --git a/app/src/main/res/layout/account_list_cell.xml b/app/src/main/res/layout/account_list_cell.xml index b9ded3d37..a1f7f9488 100644 --- a/app/src/main/res/layout/account_list_cell.xml +++ b/app/src/main/res/layout/account_list_cell.xml @@ -25,15 +25,14 @@ app:barrierDirection="right" app:constraint_referenced_ids="name, register_status" /> - - - - - - - diff --git a/app/src/main/res/layout/call_ended_fragment.xml b/app/src/main/res/layout/call_ended_fragment.xml index 5e6e12899..a4ea01037 100644 --- a/app/src/main/res/layout/call_ended_fragment.xml +++ b/app/src/main/res/layout/call_ended_fragment.xml @@ -82,11 +82,11 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent" /> - - - - - - diff --git a/app/src/main/res/layout/chat_list_cell.xml b/app/src/main/res/layout/chat_list_cell.xml index ddcca90ed..8e9f20b76 100644 --- a/app/src/main/res/layout/chat_list_cell.xml +++ b/app/src/main/res/layout/chat_list_cell.xml @@ -30,13 +30,12 @@ android:paddingBottom="4dp" android:background="@drawable/primary_cell_background"> - diff --git a/app/src/main/res/layout/contact_favourite_list_cell.xml b/app/src/main/res/layout/contact_favourite_list_cell.xml index 28091f353..deb8dde70 100644 --- a/app/src/main/res/layout/contact_favourite_list_cell.xml +++ b/app/src/main/res/layout/contact_favourite_list_cell.xml @@ -26,12 +26,11 @@ android:padding="5dp" android:background="@drawable/primary_cell_background"> - diff --git a/app/src/main/res/layout/contact_fragment.xml b/app/src/main/res/layout/contact_fragment.xml index 17e870ea0..6f7f45721 100644 --- a/app/src/main/res/layout/contact_fragment.xml +++ b/app/src/main/res/layout/contact_fragment.xml @@ -96,13 +96,12 @@ app:constraint_referenced_ids="trusted_devices_count, trust_background, trusted_devices_progress, devices, trusted_devices_progress_label" android:visibility="@{viewModel.expandDevicesTrust ? View.VISIBLE : View.GONE}" /> - diff --git a/app/src/main/res/layout/contact_list_cell.xml b/app/src/main/res/layout/contact_list_cell.xml index 5e21dcd8c..ea4dd3f43 100644 --- a/app/src/main/res/layout/contact_list_cell.xml +++ b/app/src/main/res/layout/contact_list_cell.xml @@ -52,15 +52,14 @@ app:layout_constraintTop_toTopOf="parent" app:layout_constraintBottom_toBottomOf="parent"/> - diff --git a/app/src/main/res/layout/contact_new_or_edit_fragment.xml b/app/src/main/res/layout/contact_new_or_edit_fragment.xml index 878c90cd5..df9b0d005 100644 --- a/app/src/main/res/layout/contact_new_or_edit_fragment.xml +++ b/app/src/main/res/layout/contact_new_or_edit_fragment.xml @@ -77,13 +77,13 @@ android:layout_width="match_parent" android:layout_height="wrap_content"> - - diff --git a/app/src/main/res/layout/history_list_cell.xml b/app/src/main/res/layout/history_list_cell.xml index 73a749278..e7041d8d1 100644 --- a/app/src/main/res/layout/history_list_cell.xml +++ b/app/src/main/res/layout/history_list_cell.xml @@ -29,15 +29,14 @@ android:layout_height="wrap_content" android:background="@drawable/primary_cell_background"> - diff --git a/app/src/main/res/layout/meeting_participant_list_cell.xml b/app/src/main/res/layout/meeting_participant_list_cell.xml index cce275f41..15d239de4 100644 --- a/app/src/main/res/layout/meeting_participant_list_cell.xml +++ b/app/src/main/res/layout/meeting_participant_list_cell.xml @@ -15,15 +15,14 @@ android:layout_width="match_parent" android:layout_height="wrap_content"> - - - 50dp 100dp 120dp + 5dp 12dp 26dp @@ -27,6 +28,7 @@ 22dp 3dp 5dp + 2dp 16sp diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 948d03404..bd4fae223 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -146,4 +146,16 @@ @color/switch_track_color @color/transparent_color + +