Fixed issue when navigating back from chat room opened by bubble by removing previous hack that doesn't seems necessary anymore...

This commit is contained in:
Sylvain Berfini 2021-03-29 16:51:53 +02:00
parent 1cf840c8b9
commit 4f6b416b7e
3 changed files with 7 additions and 15 deletions

View file

@ -217,13 +217,15 @@ dependencies {
implementation 'androidx.appcompat:appcompat:1.2.0' implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.media:media:1.2.0' implementation 'androidx.media:media:1.2.0'
// Don't update to fragment-ktx:1.3.2 for now, will break some animations
// https://developer.android.com/jetpack/androidx/releases/fragment#version_132_2
implementation 'androidx.fragment:fragment-ktx:1.3.1' implementation 'androidx.fragment:fragment-ktx:1.3.1'
implementation 'androidx.core:core-ktx:1.5.0-beta03' implementation 'androidx.core:core-ktx:1.5.0-beta03'
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.4' implementation 'androidx.navigation:navigation-fragment-ktx:2.3.4'
implementation 'androidx.navigation:navigation-ui-ktx:2.3.4' implementation 'androidx.navigation:navigation-ui-ktx:2.3.4'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4' implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.0' implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1'
implementation 'androidx.recyclerview:recyclerview:1.1.0' implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'com.google.android.material:material:1.3.0' implementation 'com.google.android.material:material:1.3.0'
@ -245,7 +247,7 @@ dependencies {
implementation 'com.google.firebase:firebase-messaging' implementation 'com.google.firebase:firebase-messaging'
} }
implementation 'org.linphone:linphone-sdk-android:4.5+' implementation 'org.linphone:linphone-sdk-android:5.0+'
// Only enable leak canary prior to release // Only enable leak canary prior to release
//debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.4' //debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.4'

View file

@ -359,6 +359,7 @@ class DetailChatRoomFragment : MasterFragment<ChatRoomDetailFragmentBinding, Cha
private fun goBack() { private fun goBack() {
if (!findNavController().popBackStack(R.id.masterChatRoomsFragment, false)) { if (!findNavController().popBackStack(R.id.masterChatRoomsFragment, false)) {
Log.w("[Chat Room] No MasterChatRoomsFragment found in back stack")
navigateToChatRooms() navigateToChatRooms()
} }
} }

View file

@ -25,7 +25,6 @@ import android.view.View
import androidx.core.view.doOnPreDraw import androidx.core.view.doOnPreDraw
import androidx.databinding.ViewDataBinding import androidx.databinding.ViewDataBinding
import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.ViewModelProvider
import androidx.navigation.fragment.findNavController
import org.linphone.LinphoneApplication import org.linphone.LinphoneApplication
import org.linphone.R import org.linphone.R
import org.linphone.activities.main.adapters.SelectionListAdapter import org.linphone.activities.main.adapters.SelectionListAdapter
@ -97,20 +96,10 @@ abstract class MasterFragment<T : ViewDataBinding, U : SelectionListAdapter<*, *
} }
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
// Do not use postponeEnterTransition when fragment is recreated from the back stack,
// otherwise the previous fragment will be visible until the animation starts
if (LinphoneApplication.corePreferences.enableAnimations) { if (LinphoneApplication.corePreferences.enableAnimations) {
val resume =
findNavController().currentBackStackEntry?.savedStateHandle?.getLiveData<Boolean>("resume")?.value
?: false
if (!resume) {
findNavController().currentBackStackEntry?.savedStateHandle?.set("resume", true)
// To ensure animation will be smooth,
// wait until the adapter is loaded to display the fragment
postponeEnterTransition() postponeEnterTransition()
view.doOnPreDraw { startPostponedEnterTransition() } view.doOnPreDraw { startPostponedEnterTransition() }
} }
}
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
} }