Fixed navigation issue between detail to detail fragments
This commit is contained in:
parent
d675552203
commit
4bf28f2b1c
10 changed files with 93 additions and 38 deletions
|
@ -370,12 +370,20 @@ internal fun ContactEditorFragment.navigateToContact(contact: NativeContact) {
|
|||
findMasterNavController().navigate(Uri.parse(deepLink), getRightToLeftAnimationNavOptions())
|
||||
}
|
||||
|
||||
internal fun DetailContactFragment.navigateToChatRooms(args: Bundle?) {
|
||||
internal fun DetailContactFragment.navigateToChatRoom(args: Bundle?) {
|
||||
if (!resources.getBoolean(R.bool.isTablet)) {
|
||||
findNavController().navigate(
|
||||
R.id.action_detailContactFragment_to_detailChatRoomFragment,
|
||||
args,
|
||||
getRightToLeftAnimationNavOptions()
|
||||
)
|
||||
} else {
|
||||
findMasterNavController().navigate(
|
||||
R.id.action_global_masterChatRoomsFragment,
|
||||
args,
|
||||
getRightToLeftAnimationNavOptions()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
internal fun DetailContactFragment.navigateToDialer(args: Bundle?) {
|
||||
|
@ -432,8 +440,18 @@ internal fun DetailCallLogFragment.navigateToContacts(sipUriToAdd: String) {
|
|||
}
|
||||
|
||||
internal fun DetailCallLogFragment.navigateToContact(contact: NativeContact) {
|
||||
if (!resources.getBoolean(R.bool.isTablet)) {
|
||||
val args = Bundle()
|
||||
args.putString("id", contact.nativeId)
|
||||
findMasterNavController().navigate(
|
||||
R.id.action_detailCallLogFragment_to_detailContactFragment,
|
||||
args,
|
||||
getRightToLeftAnimationNavOptions()
|
||||
)
|
||||
} else {
|
||||
val deepLink = "linphone-android://contact/view/${contact.nativeId}"
|
||||
findMasterNavController().navigate(Uri.parse(deepLink), getRightToLeftAnimationNavOptions())
|
||||
}
|
||||
}
|
||||
|
||||
internal fun DetailCallLogFragment.navigateToFriend(friendAddress: Address) {
|
||||
|
@ -441,12 +459,20 @@ internal fun DetailCallLogFragment.navigateToFriend(friendAddress: Address) {
|
|||
findMasterNavController().navigate(Uri.parse(deepLink), getRightToLeftAnimationNavOptions())
|
||||
}
|
||||
|
||||
internal fun DetailCallLogFragment.navigateToChatRooms(args: Bundle?) {
|
||||
internal fun DetailCallLogFragment.navigateToChatRoom(args: Bundle?) {
|
||||
if (!resources.getBoolean(R.bool.isTablet)) {
|
||||
findNavController().navigate(
|
||||
R.id.action_detailCallLogFragment_to_detailChatRoomFragment,
|
||||
args,
|
||||
getRightToLeftAnimationNavOptions()
|
||||
)
|
||||
} else {
|
||||
findMasterNavController().navigate(
|
||||
R.id.action_global_masterChatRoomsFragment,
|
||||
args,
|
||||
getRightToLeftAnimationNavOptions()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
internal fun DetailCallLogFragment.navigateToDialer(args: Bundle?) {
|
||||
|
|
|
@ -93,6 +93,17 @@ class DetailChatRoomFragment : MasterFragment<ChatRoomDetailFragmentBinding, Cha
|
|||
ViewModelProvider(this).get(SharedMainViewModel::class.java)
|
||||
}
|
||||
|
||||
val localSipUri = arguments?.getString("LocalSipUri")
|
||||
val remoteSipUri = arguments?.getString("RemoteSipUri")
|
||||
arguments?.clear()
|
||||
if (localSipUri != null && remoteSipUri != null) {
|
||||
Log.i("[Chat Room] Found local [$localSipUri] & remote [$remoteSipUri] addresses in arguments")
|
||||
arguments?.clear()
|
||||
val localAddress = Factory.instance().createAddress(localSipUri)
|
||||
val remoteSipAddress = Factory.instance().createAddress(remoteSipUri)
|
||||
sharedViewModel.selectedChatRoom.value = coreContext.core.searchChatRoom(null, localAddress, remoteSipAddress, arrayOfNulls(0))
|
||||
}
|
||||
|
||||
val chatRoom = sharedViewModel.selectedChatRoom.value
|
||||
chatRoom ?: return
|
||||
chatRoomAddress = chatRoom.peerAddress.asStringUriOnly()
|
||||
|
|
|
@ -29,10 +29,9 @@ import androidx.navigation.fragment.findNavController
|
|||
import org.linphone.LinphoneApplication.Companion.coreContext
|
||||
import org.linphone.R
|
||||
import org.linphone.activities.GenericFragment
|
||||
import org.linphone.activities.main.MainActivity
|
||||
import org.linphone.activities.main.*
|
||||
import org.linphone.activities.main.contact.viewmodels.ContactViewModel
|
||||
import org.linphone.activities.main.contact.viewmodels.ContactViewModelFactory
|
||||
import org.linphone.activities.main.navigateToChatRooms
|
||||
import org.linphone.activities.main.navigateToContactEditor
|
||||
import org.linphone.activities.main.navigateToDialer
|
||||
import org.linphone.activities.main.viewmodels.DialogViewModel
|
||||
|
@ -56,6 +55,13 @@ class DetailContactFragment : GenericFragment<ContactDetailFragmentBinding>() {
|
|||
ViewModelProvider(this).get(SharedMainViewModel::class.java)
|
||||
}
|
||||
|
||||
val id = arguments?.getString("id")
|
||||
arguments?.clear()
|
||||
if (id != null) {
|
||||
Log.i("[Contact] Found contact id parameter in arguments: $id")
|
||||
sharedViewModel.selectedContact.value = coreContext.contactsManager.findContactById(id)
|
||||
}
|
||||
|
||||
val contact = sharedViewModel.selectedContact.value
|
||||
contact ?: return
|
||||
|
||||
|
@ -91,7 +97,7 @@ class DetailContactFragment : GenericFragment<ContactDetailFragmentBinding>() {
|
|||
val args = Bundle()
|
||||
args.putString("LocalSipUri", chatRoom.localAddress.asStringUriOnly())
|
||||
args.putString("RemoteSipUri", chatRoom.peerAddress.asStringUriOnly())
|
||||
navigateToChatRooms(args)
|
||||
navigateToChatRoom(args)
|
||||
}
|
||||
})
|
||||
|
||||
|
|
|
@ -104,6 +104,7 @@ class ContactViewModel(private val c: Contact) : ErrorReportingViewModel(), Cont
|
|||
|
||||
if (chatRoom != null) {
|
||||
if (chatRoom.state == ChatRoom.State.Created) {
|
||||
waitForChatRoomCreation.value = false
|
||||
chatRoomCreatedEvent.value = Event(chatRoom)
|
||||
} else {
|
||||
chatRoom.addListener(chatRoomListener)
|
||||
|
|
|
@ -107,7 +107,7 @@ class DetailCallLogFragment : GenericFragment<HistoryDetailFragmentBinding>() {
|
|||
val args = Bundle()
|
||||
args.putString("LocalSipUri", chatRoom.localAddress.asStringUriOnly())
|
||||
args.putString("RemoteSipUri", chatRoom.peerAddress.asStringUriOnly())
|
||||
navigateToChatRooms(args)
|
||||
navigateToChatRoom(args)
|
||||
}
|
||||
})
|
||||
|
||||
|
|
|
@ -138,6 +138,7 @@ class CallLogViewModel(val callLog: CallLog) : GenericContactViewModel(callLog.r
|
|||
val chatRoom = LinphoneUtils.createOneToOneChatRoom(callLog.remoteAddress, isSecured)
|
||||
if (chatRoom != null) {
|
||||
if (chatRoom.state == ChatRoom.State.Created) {
|
||||
waitForChatRoomCreation.value = false
|
||||
chatRoomCreatedEvent.value = Event(chatRoom)
|
||||
} else {
|
||||
chatRoom.addListener(chatRoomListener)
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
android:id="@+id/action_detailContactFragment_to_contactEditorFragment"
|
||||
app:destination="@id/contactEditorFragment" />
|
||||
</fragment>
|
||||
|
||||
<fragment
|
||||
android:id="@+id/contactEditorFragment"
|
||||
android:name="org.linphone.activities.main.contact.fragments.ContactEditorFragment"
|
||||
|
@ -24,24 +25,21 @@
|
|||
app:argType="string"
|
||||
app:nullable="true" />
|
||||
</fragment>
|
||||
|
||||
<fragment
|
||||
android:id="@+id/emptyContactFragment"
|
||||
android:name="org.linphone.activities.main.fragments.EmptyFragment"
|
||||
tools:layout="@layout/empty_fragment"
|
||||
android:label="EmptyFragment" >
|
||||
<action
|
||||
android:id="@+id/action_emptyContactFragment_to_detailContactFragment"
|
||||
app:destination="@id/detailContactFragment"
|
||||
app:launchSingleTop="true"
|
||||
app:popUpTo="@+id/emptyContactFragment"
|
||||
app:popUpToInclusive="true" />
|
||||
</fragment>
|
||||
|
||||
<action
|
||||
android:id="@+id/action_global_detailContactFragment"
|
||||
app:destination="@id/detailContactFragment"
|
||||
app:launchSingleTop="true"
|
||||
app:popUpTo="@+id/emptyContactFragment"
|
||||
app:popUpToInclusive="true" />
|
||||
|
||||
<action
|
||||
android:id="@+id/action_global_contactEditorFragment"
|
||||
app:destination="@id/contactEditorFragment"
|
||||
|
|
|
@ -9,23 +9,19 @@
|
|||
android:id="@+id/emptyFragment"
|
||||
android:name="org.linphone.activities.main.fragments.EmptyFragment"
|
||||
tools:layout="@layout/empty_fragment"
|
||||
android:label="EmptyFragment" >
|
||||
<action
|
||||
android:id="@+id/action_emptyFragment_to_detailCallLogFragment"
|
||||
app:destination="@id/detailCallLogFragment"
|
||||
app:launchSingleTop="true"
|
||||
app:popUpTo="@+id/emptyFragment"
|
||||
app:popUpToInclusive="true" />
|
||||
</fragment>
|
||||
android:label="EmptyFragment"/>
|
||||
|
||||
<fragment
|
||||
android:id="@+id/detailCallLogFragment"
|
||||
android:name="org.linphone.activities.main.history.fragments.DetailCallLogFragment"
|
||||
tools:layout="@layout/history_detail_fragment"
|
||||
android:label="DetailCallLogFragment" />
|
||||
|
||||
<action
|
||||
android:id="@+id/action_global_detailCallLogFragment"
|
||||
app:destination="@id/detailCallLogFragment"
|
||||
app:launchSingleTop="true"
|
||||
app:popUpTo="@+id/emptyFragment"
|
||||
app:popUpToInclusive="true" />
|
||||
|
||||
</navigation>
|
|
@ -9,19 +9,23 @@
|
|||
android:id="@+id/detailContactFragment"
|
||||
android:name="org.linphone.activities.main.contact.fragments.DetailContactFragment"
|
||||
tools:layout="@layout/contact_detail_fragment"
|
||||
android:label="DetailContactFragment" >
|
||||
android:label="DetailContactFragment">
|
||||
|
||||
<action
|
||||
android:id="@+id/action_detailContactFragment_to_contactEditorFragment"
|
||||
app:destination="@id/contactEditorFragment" />
|
||||
|
||||
<action
|
||||
android:id="@+id/action_detailContactFragment_to_detailChatRoomFragment"
|
||||
app:destination="@id/chat_nav_graph.xml"
|
||||
app:launchSingleTop="true" />
|
||||
|
||||
</fragment>
|
||||
|
||||
<fragment
|
||||
android:id="@+id/contactEditorFragment"
|
||||
android:name="org.linphone.activities.main.contact.fragments.ContactEditorFragment"
|
||||
tools:layout="@layout/contact_editor_fragment"
|
||||
android:label="ContactEditorFragment" />
|
||||
<action
|
||||
android:id="@+id/action_global_detailContactFragment"
|
||||
app:destination="@id/detailContactFragment"
|
||||
app:launchSingleTop="true" />
|
||||
|
||||
</navigation>
|
|
@ -9,6 +9,18 @@
|
|||
android:id="@+id/detailCallLogFragment"
|
||||
android:name="org.linphone.activities.main.history.fragments.DetailCallLogFragment"
|
||||
tools:layout="@layout/history_detail_fragment"
|
||||
android:label="DetailCallLogFragment" />
|
||||
android:label="DetailCallLogFragment">
|
||||
|
||||
<action
|
||||
android:id="@+id/action_detailCallLogFragment_to_detailContactFragment"
|
||||
app:destination="@id/contacts_nav_graph.xml"
|
||||
app:launchSingleTop="true" />
|
||||
|
||||
<action
|
||||
android:id="@+id/action_detailCallLogFragment_to_detailChatRoomFragment"
|
||||
app:destination="@id/chat_nav_graph.xml"
|
||||
app:launchSingleTop="true" />
|
||||
|
||||
</fragment>
|
||||
|
||||
</navigation>
|
Loading…
Reference in a new issue