mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-02-07 14:58:24 +00:00
Do not display confirm dialog when leaving new contact fragment without having typed anything
This commit is contained in:
parent
02b372fa3d
commit
b30f44a0a1
8 changed files with 41 additions and 8 deletions
|
|
@ -92,7 +92,7 @@ class ActiveCallFragment : GenericCallFragment() {
|
|||
|
||||
override fun onCreateAnimation(transit: Int, enter: Boolean, nextAnim: Int): Animation? {
|
||||
if (findNavController().currentDestination?.id == R.id.newCallFragment) {
|
||||
// Holds fragment in place while new contact fragment slides over it
|
||||
// Holds fragment in place while new fragment slides over it
|
||||
return AnimationUtils.loadAnimation(activity, R.anim.hold)
|
||||
}
|
||||
return super.onCreateAnimation(transit, enter, nextAnim)
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ class ConversationsListFragment : AbstractTopBarFragment() {
|
|||
findNavController().currentDestination?.id == R.id.startConversationFragment ||
|
||||
findNavController().currentDestination?.id == R.id.meetingWaitingRoomFragment
|
||||
) {
|
||||
// Holds fragment in place while new contact fragment slides over it
|
||||
// Holds fragment in place while new fragment slides over it
|
||||
return AnimationUtils.loadAnimation(activity, R.anim.hold)
|
||||
}
|
||||
return super.onCreateAnimation(transit, enter, nextAnim)
|
||||
|
|
|
|||
|
|
@ -26,6 +26,8 @@ import android.view.Gravity
|
|||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.animation.Animation
|
||||
import android.view.animation.AnimationUtils
|
||||
import android.widget.PopupWindow
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.core.content.FileProvider
|
||||
|
|
@ -69,6 +71,15 @@ class ContactsListFragment : AbstractTopBarFragment() {
|
|||
listViewModel.applyCurrentDefaultAccountFilter()
|
||||
}
|
||||
|
||||
override fun onCreateAnimation(transit: Int, enter: Boolean, nextAnim: Int): Animation? {
|
||||
if (findNavController().currentDestination?.id == R.id.newContactFragment
|
||||
) {
|
||||
// Holds fragment in place while new fragment slides over it
|
||||
return AnimationUtils.loadAnimation(activity, R.anim.hold)
|
||||
}
|
||||
return super.onCreateAnimation(transit, enter, nextAnim)
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ class NewContactFragment : GenericFragment() {
|
|||
|
||||
private val backPressedCallback = object : OnBackPressedCallback(true) {
|
||||
override fun handleOnBackPressed() {
|
||||
showAbortConfirmationDialog()
|
||||
showAbortConfirmationDialogIfNeededOrGoBack()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -119,7 +119,7 @@ class NewContactFragment : GenericFragment() {
|
|||
viewModel.findFriendByRefKey("")
|
||||
|
||||
binding.setBackClickListener {
|
||||
showAbortConfirmationDialog()
|
||||
showAbortConfirmationDialogIfNeededOrGoBack()
|
||||
}
|
||||
|
||||
binding.setPickImageClickListener {
|
||||
|
|
@ -210,7 +210,13 @@ class NewContactFragment : GenericFragment() {
|
|||
pickMedia.launch(PickVisualMediaRequest(ActivityResultContracts.PickVisualMedia.ImageOnly))
|
||||
}
|
||||
|
||||
private fun showAbortConfirmationDialog() {
|
||||
private fun showAbortConfirmationDialogIfNeededOrGoBack() {
|
||||
if (!viewModel.isPendingChanges()) {
|
||||
backPressedCallback.isEnabled = false
|
||||
findNavController().popBackStack()
|
||||
return
|
||||
}
|
||||
|
||||
val model = ConfirmationDialogModel()
|
||||
val dialog = DialogUtils.getCancelContactChangesConfirmationDialog(
|
||||
requireActivity(),
|
||||
|
|
|
|||
|
|
@ -276,4 +276,20 @@ class ContactNewOrEditViewModel @UiThread constructor() : ViewModel() {
|
|||
company.value = ""
|
||||
jobTitle.value = ""
|
||||
}
|
||||
|
||||
@UiThread
|
||||
fun isPendingChanges(): Boolean {
|
||||
if (isEdit.value == true) {
|
||||
// TODO: check if values of each field match friend values
|
||||
return true
|
||||
}
|
||||
|
||||
return !picturePath.value.isNullOrEmpty() ||
|
||||
!firstName.value.isNullOrEmpty() ||
|
||||
!lastName.value.isNullOrEmpty() ||
|
||||
!sipAddresses.firstOrNull()?.value?.value.isNullOrEmpty() ||
|
||||
!phoneNumbers.firstOrNull()?.value?.value.isNullOrEmpty() ||
|
||||
!company.value.isNullOrEmpty() ||
|
||||
!jobTitle.value.isNullOrEmpty()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ class EmptyFragment : Fragment() {
|
|||
|
||||
override fun onCreateAnimation(transit: Int, enter: Boolean, nextAnim: Int): Animation? {
|
||||
if (findNavController().currentDestination?.id == R.id.newContactFragment) {
|
||||
// Holds fragment in place while new contact fragment slides over it
|
||||
// Holds fragment in place while new fragment slides over it
|
||||
return AnimationUtils.loadAnimation(activity, R.anim.hold)
|
||||
}
|
||||
return super.onCreateAnimation(transit, enter, nextAnim)
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ class HistoryListFragment : AbstractTopBarFragment() {
|
|||
if (findNavController().currentDestination?.id == R.id.startCallFragment ||
|
||||
findNavController().currentDestination?.id == R.id.meetingWaitingRoomFragment
|
||||
) {
|
||||
// Holds fragment in place while new contact fragment slides over it
|
||||
// Holds fragment in place while new fragment slides over it
|
||||
return AnimationUtils.loadAnimation(activity, R.anim.hold)
|
||||
}
|
||||
return super.onCreateAnimation(transit, enter, nextAnim)
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ class MeetingsListFragment : AbstractTopBarFragment() {
|
|||
findNavController().currentDestination?.id == R.id.scheduleMeetingFragment ||
|
||||
findNavController().currentDestination?.id == R.id.meetingWaitingRoomFragment
|
||||
) {
|
||||
// Holds fragment in place while new contact fragment slides over it
|
||||
// Holds fragment in place while new fragment slides over it
|
||||
return AnimationUtils.loadAnimation(activity, R.anim.hold)
|
||||
}
|
||||
return super.onCreateAnimation(transit, enter, nextAnim)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue