mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 19:38:08 +00:00
Add back buttons in new fragments
This commit is contained in:
parent
89c7e734d4
commit
489483e22a
10 changed files with 155 additions and 50 deletions
|
|
@ -55,7 +55,9 @@ class ContactsManager @UiThread constructor(context: Context) {
|
|||
private val friendListListener: FriendListListenerStub = object : FriendListListenerStub() {
|
||||
@WorkerThread
|
||||
override fun onPresenceReceived(list: FriendList, friends: Array<Friend>) {
|
||||
Log.i("$TAG Presence received")
|
||||
Log.i(
|
||||
"$TAG Presence received for list [${list.displayName}] and [${friends.size}] friends"
|
||||
)
|
||||
for (listener in listeners) {
|
||||
listener.onContactsLoaded()
|
||||
}
|
||||
|
|
@ -65,11 +67,14 @@ class ContactsManager @UiThread constructor(context: Context) {
|
|||
private val coreListener: CoreListenerStub = object : CoreListenerStub() {
|
||||
@WorkerThread
|
||||
override fun onFriendListCreated(core: Core, friendList: FriendList) {
|
||||
Log.i("$TAG Friend list [${friendList.displayName}] created")
|
||||
friendList.addListener(friendListListener)
|
||||
friendList.updateSubscriptions()
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
override fun onFriendListRemoved(core: Core, friendList: FriendList) {
|
||||
Log.i("$TAG Friend list [${friendList.displayName}] remoed")
|
||||
friendList.removeListener(friendListListener)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -106,15 +106,18 @@ class ContactsListFragment : GenericFragment() {
|
|||
listViewModel.contactsList.observe(
|
||||
viewLifecycleOwner
|
||||
) {
|
||||
val emptyAdapter = adapter.itemCount == 0
|
||||
val currentCount = adapter.itemCount
|
||||
adapter.submitList(it)
|
||||
Log.i("$TAG Contacts list updated with [${it.size}] items")
|
||||
|
||||
if (emptyAdapter) {
|
||||
if (currentCount == 0) {
|
||||
(view.parent as? ViewGroup)?.doOnPreDraw {
|
||||
startPostponedEnterTransition()
|
||||
sharedViewModel.contactsListReadyToBeDisplayedEvent.value = Event(true)
|
||||
}
|
||||
} else if (currentCount < it.size) {
|
||||
Log.i("$TAG Contacts list updated with new items, scrolling to top")
|
||||
binding.contactsList.smoothScrollToPosition(0)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import android.view.LayoutInflater
|
|||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import org.linphone.databinding.RecordingsFragmentBinding
|
||||
import org.linphone.ui.main.fragment.GenericFragment
|
||||
|
||||
|
|
@ -20,8 +21,16 @@ class RecordingsFragment : GenericFragment() {
|
|||
return binding.root
|
||||
}
|
||||
|
||||
override fun goBack() {
|
||||
findNavController().popBackStack()
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
binding.lifecycleOwner = viewLifecycleOwner
|
||||
|
||||
binding.setBackClickListener {
|
||||
goBack()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import android.view.LayoutInflater
|
|||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import org.linphone.databinding.HelpFragmentBinding
|
||||
import org.linphone.ui.main.fragment.GenericFragment
|
||||
|
||||
|
|
@ -21,8 +22,16 @@ class HelpFragment : GenericFragment() {
|
|||
return binding.root
|
||||
}
|
||||
|
||||
override fun goBack() {
|
||||
findNavController().popBackStack()
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
binding.lifecycleOwner = viewLifecycleOwner
|
||||
|
||||
binding.setBackClickListener {
|
||||
goBack()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import android.view.LayoutInflater
|
|||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import org.linphone.databinding.SettingsFragmentBinding
|
||||
import org.linphone.ui.main.fragment.GenericFragment
|
||||
|
||||
|
|
@ -21,8 +22,16 @@ class SettingsFragment : GenericFragment() {
|
|||
return binding.root
|
||||
}
|
||||
|
||||
override fun goBack() {
|
||||
findNavController().popBackStack()
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
binding.lifecycleOwner = viewLifecycleOwner
|
||||
|
||||
binding.setBackClickListener {
|
||||
goBack()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ class CallsViewModel @UiThread constructor() : ViewModel() {
|
|||
|
||||
private val alertListener = object : AlertListenerStub() {
|
||||
@WorkerThread
|
||||
override fun onOnTerminated(alert: Alert) {
|
||||
override fun onTerminated(alert: Alert) {
|
||||
val remote = alert.call.remoteAddress.asStringUriOnly()
|
||||
Log.w("$TAG Alert of type [${alert.type}] dismissed for call from [$remote]")
|
||||
alert.removeListener(this)
|
||||
|
|
@ -89,7 +89,7 @@ class CallsViewModel @UiThread constructor() : ViewModel() {
|
|||
}
|
||||
|
||||
@WorkerThread
|
||||
override fun onOnAlert(core: Core, alert: Alert) {
|
||||
override fun onNewAlertTriggered(core: Core, alert: Alert) {
|
||||
val remote = alert.call.remoteAddress.asStringUriOnly()
|
||||
Log.w("$TAG Alert of type [${alert.type}] triggered for call from [$remote]")
|
||||
alert.addListener(alertListener)
|
||||
|
|
|
|||
|
|
@ -272,53 +272,27 @@ fun AvatarView.loadContactAvatar(contact: ContactAvatarModel?) {
|
|||
if (contact == null) {
|
||||
loadImage(R.drawable.contact_avatar)
|
||||
} else {
|
||||
val lifecycleOwner = findViewTreeLifecycleOwner()
|
||||
if (lifecycleOwner != null) {
|
||||
contact.avatar.observe(lifecycleOwner) { uri ->
|
||||
loadImage(
|
||||
data = uri,
|
||||
onStart = {
|
||||
// Use initials as placeholder
|
||||
avatarInitials = contact.initials
|
||||
val uri = contact.avatar.value
|
||||
loadImage(
|
||||
data = uri,
|
||||
onStart = {
|
||||
// Use initials as placeholder
|
||||
avatarInitials = contact.initials
|
||||
|
||||
if (contact.showTrust.value == true) {
|
||||
avatarBorderColor =
|
||||
resources.getColor(R.color.trusted_blue, context.theme)
|
||||
avatarBorderWidth =
|
||||
AppUtils.getDimension(R.dimen.avatar_trust_border_width).toInt()
|
||||
} else {
|
||||
avatarBorderWidth = AppUtils.getDimension(R.dimen.zero).toInt()
|
||||
}
|
||||
},
|
||||
onSuccess = { _, _ ->
|
||||
// If loading is successful, remove initials otherwise image won't be visible
|
||||
avatarInitials = ""
|
||||
}
|
||||
)
|
||||
}
|
||||
} else {
|
||||
val uri = contact.avatar.value
|
||||
loadImage(
|
||||
data = uri,
|
||||
onStart = {
|
||||
// Use initials as placeholder
|
||||
avatarInitials = contact.initials
|
||||
|
||||
if (contact.showTrust.value == true) {
|
||||
avatarBorderColor =
|
||||
resources.getColor(R.color.trusted_blue, context.theme)
|
||||
avatarBorderWidth =
|
||||
AppUtils.getDimension(R.dimen.avatar_trust_border_width).toInt()
|
||||
} else {
|
||||
avatarBorderWidth = AppUtils.getDimension(R.dimen.zero).toInt()
|
||||
}
|
||||
},
|
||||
onSuccess = { _, _ ->
|
||||
// If loading is successful, remove initials otherwise image won't be visible
|
||||
avatarInitials = ""
|
||||
if (contact.showTrust.value == true) {
|
||||
avatarBorderColor =
|
||||
resources.getColor(R.color.trusted_blue, context.theme)
|
||||
avatarBorderWidth =
|
||||
AppUtils.getDimension(R.dimen.avatar_trust_border_width).toInt()
|
||||
} else {
|
||||
avatarBorderWidth = AppUtils.getDimension(R.dimen.zero).toInt()
|
||||
}
|
||||
)
|
||||
}
|
||||
},
|
||||
onSuccess = { _, _ ->
|
||||
// If loading is successful, remove initials otherwise image won't be visible
|
||||
avatarInitials = ""
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,9 @@
|
|||
|
||||
<data>
|
||||
<import type="android.view.View" />
|
||||
<variable
|
||||
name="backClickListener"
|
||||
type="View.OnClickListener" />
|
||||
</data>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
|
|
@ -12,6 +15,35 @@
|
|||
android:layout_height="match_parent"
|
||||
android:background="@color/white">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/back"
|
||||
android:onClick="@{backClickListener}"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="35dp"
|
||||
android:layout_marginStart="10dp"
|
||||
android:adjustViewBounds="true"
|
||||
android:padding="5dp"
|
||||
android:src="@drawable/caret_left"
|
||||
android:drawableTint="@color/primary_color"
|
||||
app:layout_constraintBottom_toBottomOf="@id/title"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@id/title" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="@style/default_text_style_800"
|
||||
android:id="@+id/title"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="@dimen/top_bar_height"
|
||||
android:layout_marginStart="10dp"
|
||||
android:layout_marginEnd="10dp"
|
||||
android:gravity="center_vertical"
|
||||
android:text="Help"
|
||||
android:textColor="@color/primary_color"
|
||||
android:textSize="16sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/back"
|
||||
app:layout_constraintTop_toTopOf="parent"/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</layout>
|
||||
|
|
@ -5,6 +5,9 @@
|
|||
|
||||
<data>
|
||||
<import type="android.view.View" />
|
||||
<variable
|
||||
name="backClickListener"
|
||||
type="View.OnClickListener" />
|
||||
</data>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
|
|
@ -12,6 +15,35 @@
|
|||
android:layout_height="match_parent"
|
||||
android:background="@color/white">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/back"
|
||||
android:onClick="@{backClickListener}"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="35dp"
|
||||
android:layout_marginStart="10dp"
|
||||
android:adjustViewBounds="true"
|
||||
android:padding="5dp"
|
||||
android:src="@drawable/caret_left"
|
||||
android:drawableTint="@color/primary_color"
|
||||
app:layout_constraintBottom_toBottomOf="@id/title"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@id/title" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="@style/default_text_style_800"
|
||||
android:id="@+id/title"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="@dimen/top_bar_height"
|
||||
android:layout_marginStart="10dp"
|
||||
android:layout_marginEnd="10dp"
|
||||
android:gravity="center_vertical"
|
||||
android:text="Recordings"
|
||||
android:textColor="@color/primary_color"
|
||||
android:textSize="16sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/back"
|
||||
app:layout_constraintTop_toTopOf="parent"/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</layout>
|
||||
|
|
@ -5,6 +5,9 @@
|
|||
|
||||
<data>
|
||||
<import type="android.view.View" />
|
||||
<variable
|
||||
name="backClickListener"
|
||||
type="View.OnClickListener" />
|
||||
</data>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
|
|
@ -12,6 +15,35 @@
|
|||
android:layout_height="match_parent"
|
||||
android:background="@color/white">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/back"
|
||||
android:onClick="@{backClickListener}"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="35dp"
|
||||
android:layout_marginStart="10dp"
|
||||
android:adjustViewBounds="true"
|
||||
android:padding="5dp"
|
||||
android:src="@drawable/caret_left"
|
||||
android:drawableTint="@color/primary_color"
|
||||
app:layout_constraintBottom_toBottomOf="@id/title"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@id/title" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="@style/default_text_style_800"
|
||||
android:id="@+id/title"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="@dimen/top_bar_height"
|
||||
android:layout_marginStart="10dp"
|
||||
android:layout_marginEnd="10dp"
|
||||
android:gravity="center_vertical"
|
||||
android:text="Settings"
|
||||
android:textColor="@color/primary_color"
|
||||
android:textSize="16sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/back"
|
||||
app:layout_constraintTop_toTopOf="parent"/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</layout>
|
||||
Loading…
Add table
Reference in a new issue