mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 11:28:06 +00:00
Updated conversation info participant cell with missing menu + added debug logs
This commit is contained in:
parent
6c72fb9689
commit
3ce702fc0d
5 changed files with 148 additions and 25 deletions
|
|
@ -106,6 +106,7 @@ class ContactsManager @UiThread constructor(context: Context) {
|
|||
try {
|
||||
listeners.add(listener)
|
||||
} catch (cme: ConcurrentModificationException) {
|
||||
Log.e("$TAG Can't add listener: $cme")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -118,6 +119,7 @@ class ContactsManager @UiThread constructor(context: Context) {
|
|||
try {
|
||||
listeners.remove(listener)
|
||||
} catch (cme: ConcurrentModificationException) {
|
||||
Log.e("$TAG Can't remove listener: $cme")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -157,16 +159,30 @@ class ContactsManager @UiThread constructor(context: Context) {
|
|||
clonedAddress.clean()
|
||||
val sipUri = clonedAddress.asStringUriOnly()
|
||||
|
||||
Log.d("$TAG Looking for friend with address [$sipUri]")
|
||||
Log.d("$TAG Looking for friend with SIP URI [$sipUri]")
|
||||
val username = clonedAddress.username
|
||||
val found = coreContext.core.findFriend(clonedAddress)
|
||||
return found ?: if (!username.isNullOrEmpty() && username.startsWith("+")) {
|
||||
return if (found != null) {
|
||||
Log.i("$TAG Friend [${found.name}] was found using SIP URI [$sipUri]")
|
||||
found
|
||||
} else if (!username.isNullOrEmpty() && username.startsWith("+")) {
|
||||
Log.i("$TAG Looking for friend with phone number [$username]")
|
||||
val foundUsingPhoneNumber = coreContext.core.findFriendByPhoneNumber(
|
||||
username
|
||||
)
|
||||
foundUsingPhoneNumber ?: findNativeContact(sipUri, true, username)
|
||||
val foundUsingPhoneNumber = coreContext.core.findFriendByPhoneNumber(username)
|
||||
if (foundUsingPhoneNumber != null) {
|
||||
Log.i(
|
||||
"$TAG Friend [${foundUsingPhoneNumber.name}] was found using phone number [$username]"
|
||||
)
|
||||
foundUsingPhoneNumber
|
||||
} else {
|
||||
Log.i(
|
||||
"$TAG Friend wasn't found using phone number [$username], looking in native address book directly"
|
||||
)
|
||||
findNativeContact(sipUri, true, username)
|
||||
}
|
||||
} else {
|
||||
Log.i(
|
||||
"$TAG Friend wasn't found using SIP URI [$sipUri] and username [$username] isn't a phone number, looking in native address book directly"
|
||||
)
|
||||
findNativeContact(sipUri, false)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ import org.linphone.ui.main.chat.model.ParticipantModel
|
|||
import org.linphone.ui.main.chat.viewmodel.ConversationInfoViewModel
|
||||
import org.linphone.ui.main.fragment.GenericFragment
|
||||
import org.linphone.utils.DialogUtils
|
||||
import org.linphone.utils.Event
|
||||
|
||||
@UiThread
|
||||
class ConversationInfoFragment : GenericFragment() {
|
||||
|
|
@ -212,6 +213,9 @@ class ConversationInfoFragment : GenericFragment() {
|
|||
val address = participantModel.sipUri
|
||||
val isAdmin = participantModel.isParticipantAdmin
|
||||
popupView.isParticipantAdmin = isAdmin
|
||||
popupView.isMeAdmin = participantModel.isMyselfAdmin
|
||||
val friendRefKey = participantModel.avatarModel.friend.refKey
|
||||
popupView.isParticipantContact = !friendRefKey.isNullOrEmpty()
|
||||
|
||||
popupView.setRemoveParticipantClickListener {
|
||||
Log.w("$TAG Trying to remove participant [$address]")
|
||||
|
|
@ -231,6 +235,26 @@ class ConversationInfoFragment : GenericFragment() {
|
|||
popupWindow.dismiss()
|
||||
}
|
||||
|
||||
popupView.setSeeContactProfileClickListener {
|
||||
Log.w("$TAG Trying to display participant [$address] contact page")
|
||||
if (!friendRefKey.isNullOrEmpty()) {
|
||||
sharedViewModel.navigateToContactsEvent.value = Event(true)
|
||||
sharedViewModel.showContactEvent.value = Event(friendRefKey)
|
||||
} else {
|
||||
Log.e("$TAG Can't go to contact page, friend ref key is null or empty!")
|
||||
// TODO: show toast
|
||||
}
|
||||
popupWindow.dismiss()
|
||||
}
|
||||
|
||||
popupView.setAddToContactsClickListener {
|
||||
Log.w("$TAG Trying to add participant [${participantModel.sipUri}] to contacts")
|
||||
sharedViewModel.sipAddressToAddToNewContact = participantModel.sipUri
|
||||
sharedViewModel.navigateToContactsEvent.value = Event(true)
|
||||
sharedViewModel.showNewContactEvent.value = Event(true)
|
||||
popupWindow.dismiss()
|
||||
}
|
||||
|
||||
// Elevation is for showing a shadow around the popup
|
||||
popupWindow.elevation = 20f
|
||||
popupWindow.showAsDropDown(view, 0, 0, Gravity.BOTTOM)
|
||||
|
|
|
|||
|
|
@ -9,15 +9,27 @@
|
|||
<variable
|
||||
name="removeParticipantClickListener"
|
||||
type="View.OnClickListener" />
|
||||
<variable
|
||||
name="seeContactProfileClickListener"
|
||||
type="View.OnClickListener" />
|
||||
<variable
|
||||
name="addToContactsClickListener"
|
||||
type="View.OnClickListener" />
|
||||
<variable
|
||||
name="setAdminClickListener"
|
||||
type="View.OnClickListener" />
|
||||
<variable
|
||||
name="unsetAdminClickListener"
|
||||
type="View.OnClickListener" />
|
||||
<variable
|
||||
name="isParticipantContact"
|
||||
type="Boolean" />
|
||||
<variable
|
||||
name="isParticipantAdmin"
|
||||
type="Boolean" />
|
||||
<variable
|
||||
name="isMeAdmin"
|
||||
type="Boolean" />
|
||||
</data>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
|
|
@ -27,41 +39,97 @@
|
|||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="@style/default_text_style"
|
||||
android:id="@+id/set_admin"
|
||||
android:onClick="@{setAdminClickListener}"
|
||||
android:layout_width="wrap_content"
|
||||
android:id="@+id/show_contact"
|
||||
android:onClick="@{seeContactProfileClickListener}"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="20dp"
|
||||
android:layout_marginStart="20dp"
|
||||
android:layout_marginEnd="20dp"
|
||||
android:visibility="@{isParticipantContact ? View.VISIBLE : View.GONE}"
|
||||
android:text="@string/conversation_info_menu_go_to_contact"
|
||||
android:textSize="14sp"
|
||||
android:textColor="@color/gray_main2_500"
|
||||
android:maxLines="1"
|
||||
android:ellipsize="end"
|
||||
android:drawableStart="@drawable/address_book"
|
||||
android:drawablePadding="5dp"
|
||||
app:drawableTint="@color/gray_main2_700"
|
||||
app:layout_constraintHorizontal_bias="0"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toTopOf="@id/add_to_contacts"/>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="@style/default_text_style"
|
||||
android:id="@+id/add_to_contacts"
|
||||
android:onClick="@{addToContactsClickListener}"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:paddingEnd="20dp"
|
||||
android:paddingStart="20dp"
|
||||
android:visibility="@{isParticipantAdmin ? View.GONE : View.VISIBLE}"
|
||||
android:layout_marginStart="20dp"
|
||||
android:layout_marginEnd="20dp"
|
||||
android:visibility="@{isParticipantContact ? View.GONE : View.VISIBLE, default=gone}"
|
||||
android:text="@string/conversation_info_menu_add_to_contacts"
|
||||
android:textSize="14sp"
|
||||
android:textColor="@color/gray_main2_500"
|
||||
android:maxLines="1"
|
||||
android:ellipsize="end"
|
||||
android:drawableStart="@drawable/user_plus"
|
||||
android:drawablePadding="5dp"
|
||||
app:drawableTint="@color/gray_main2_700"
|
||||
app:layout_constraintHorizontal_bias="0"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/show_contact"
|
||||
app:layout_constraintBottom_toTopOf="@id/set_admin"/>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="@style/default_text_style"
|
||||
android:id="@+id/set_admin"
|
||||
android:onClick="@{setAdminClickListener}"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginStart="20dp"
|
||||
android:layout_marginEnd="20dp"
|
||||
android:visibility="@{isParticipantAdmin || !isMeAdmin ? View.GONE : View.VISIBLE}"
|
||||
android:text="@string/conversation_info_admin_menu_set_participant_admin"
|
||||
android:textSize="14sp"
|
||||
android:textColor="@color/gray_main2_500"
|
||||
android:maxLines="1"
|
||||
android:ellipsize="end"
|
||||
android:drawableStart="@drawable/user_circle"
|
||||
android:drawablePadding="5dp"
|
||||
app:drawableTint="@color/gray_main2_700"
|
||||
app:layout_constraintHorizontal_bias="0"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/add_to_contacts"
|
||||
app:layout_constraintBottom_toTopOf="@id/unset_admin"/>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="@style/default_text_style"
|
||||
android:id="@+id/unset_admin"
|
||||
android:onClick="@{unsetAdminClickListener}"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:paddingEnd="20dp"
|
||||
android:paddingStart="20dp"
|
||||
android:visibility="@{isParticipantAdmin ? View.VISIBLE : View.GONE, default=gone}"
|
||||
android:layout_marginStart="20dp"
|
||||
android:layout_marginEnd="20dp"
|
||||
android:visibility="@{isParticipantAdmin && isMeAdmin ? View.VISIBLE : View.GONE, default=gone}"
|
||||
android:text="@string/conversation_info_admin_menu_unset_participant_admin"
|
||||
android:textSize="14sp"
|
||||
android:textColor="@color/gray_main2_500"
|
||||
android:maxLines="1"
|
||||
android:ellipsize="end"
|
||||
android:drawableStart="@drawable/user_circle"
|
||||
android:drawablePadding="5dp"
|
||||
app:drawableTint="@color/gray_main2_700"
|
||||
app:layout_constraintHorizontal_bias="0"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/set_admin"
|
||||
app:layout_constraintBottom_toTopOf="@id/separator"/>
|
||||
|
||||
|
|
@ -73,7 +141,7 @@
|
|||
android:layout_marginEnd="20dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:background="@color/gray_main2_400"
|
||||
android:visibility="gone"
|
||||
android:visibility="@{isMeAdmin ? View.VISIBLE : View.GONE}"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/unset_admin"
|
||||
|
|
@ -83,21 +151,35 @@
|
|||
style="@style/default_text_style"
|
||||
android:id="@+id/remove_participant"
|
||||
android:onClick="@{removeParticipantClickListener}"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:paddingEnd="20dp"
|
||||
android:paddingStart="20dp"
|
||||
android:layout_marginStart="20dp"
|
||||
android:layout_marginEnd="20dp"
|
||||
android:text="@string/conversation_info_admin_menu_remove_participant"
|
||||
android:textSize="14sp"
|
||||
android:textColor="@color/red_danger_500"
|
||||
android:maxLines="1"
|
||||
android:ellipsize="end"
|
||||
android:visibility="@{isMeAdmin ? View.VISIBLE : View.GONE}"
|
||||
android:drawableStart="@drawable/trash_simple"
|
||||
android:drawablePadding="5dp"
|
||||
app:drawableTint="@color/red_danger_500"
|
||||
app:layout_constraintHorizontal_bias="0"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/separator"
|
||||
app:layout_constraintBottom_toBottomOf="parent"/>
|
||||
app:layout_constraintBottom_toTopOf="@id/bottom_anchor"/>
|
||||
|
||||
<View
|
||||
android:id="@+id/bottom_anchor"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginBottom="20dp"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/remove_participant"
|
||||
app:layout_constraintBottom_toBottomOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
android:onClick="@{() -> model.onClicked()}"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/primary_cell_background"
|
||||
android:background="@color/white"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginEnd="16dp">
|
||||
|
||||
|
|
@ -87,7 +87,6 @@
|
|||
android:layout_width="@dimen/icon_size"
|
||||
android:layout_height="@dimen/icon_size"
|
||||
android:src="@drawable/dots_three_vertical"
|
||||
android:visibility="@{model.isMyselfAdmin ? View.VISIBLE : View.GONE}"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/name"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
|
|
|
|||
|
|
@ -370,6 +370,8 @@
|
|||
<string name="conversation_info_admin_menu_remove_participant">Remove from the group</string>
|
||||
<string name="conversation_info_admin_menu_set_participant_admin">Give admin rights</string>
|
||||
<string name="conversation_info_admin_menu_unset_participant_admin">Remove admin rights</string>
|
||||
<string name="conversation_info_menu_go_to_contact">See contact profile</string>
|
||||
<string name="conversation_info_menu_add_to_contacts">Add to contacts</string>
|
||||
|
||||
<string name="conversation_event_conference_created">You have joined the group</string>
|
||||
<string name="conversation_event_conference_destroyed">You have left the group</string>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue