From 92e13a2e6b6bcd03826a907921453f43b76e45fd Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Tue, 1 Feb 2022 11:16:43 +0100 Subject: [PATCH] Added warning fragment before configuring a generic SIP account --- .../org/linphone/activities/Navigation.kt | 14 +++- .../GenericAccountWarningFragment.kt | 41 ++++++++++++ .../assistant/fragments/WelcomeFragment.kt | 3 +- ...stant_generic_account_warning_fragment.xml | 65 +++++++++++++++++++ .../res/navigation/assistant_nav_graph.xml | 13 +++- app/src/main/res/values-fr/strings.xml | 2 + app/src/main/res/values/strings.xml | 3 + 7 files changed, 135 insertions(+), 6 deletions(-) create mode 100644 app/src/main/java/org/linphone/activities/assistant/fragments/GenericAccountWarningFragment.kt create mode 100644 app/src/main/res/layout/assistant_generic_account_warning_fragment.xml diff --git a/app/src/main/java/org/linphone/activities/Navigation.kt b/app/src/main/java/org/linphone/activities/Navigation.kt index abfe51e11..1431e5a6a 100644 --- a/app/src/main/java/org/linphone/activities/Navigation.kt +++ b/app/src/main/java/org/linphone/activities/Navigation.kt @@ -802,10 +802,10 @@ internal fun WelcomeFragment.navigateToAccountLogin() { } } -internal fun WelcomeFragment.navigateToGenericLogin() { +internal fun WelcomeFragment.navigateToGenericLoginWarning() { if (findNavController().currentDestination?.id == R.id.welcomeFragment) { findNavController().navigate( - R.id.action_welcomeFragment_to_genericAccountLoginFragment, + R.id.action_welcomeFragment_to_genericAccountWarningFragment, null, popupTo() ) @@ -842,6 +842,16 @@ internal fun AccountLoginFragment.navigateToPhoneAccountValidation(args: Bundle? } } +internal fun GenericAccountWarningFragment.navigateToGenericLogin() { + if (findNavController().currentDestination?.id == R.id.genericAccountWarningFragment) { + findNavController().navigate( + R.id.action_genericAccountWarningFragment_to_genericAccountLoginFragment, + null, + popupTo(R.id.welcomeFragment, popUpInclusive = false) + ) + } +} + internal fun GenericAccountLoginFragment.navigateToEchoCancellerCalibration() { if (findNavController().currentDestination?.id == R.id.genericAccountLoginFragment) { findNavController().navigate( diff --git a/app/src/main/java/org/linphone/activities/assistant/fragments/GenericAccountWarningFragment.kt b/app/src/main/java/org/linphone/activities/assistant/fragments/GenericAccountWarningFragment.kt new file mode 100644 index 000000000..8c41c0653 --- /dev/null +++ b/app/src/main/java/org/linphone/activities/assistant/fragments/GenericAccountWarningFragment.kt @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2010-2022 Belledonne Communications SARL. + * + * This file is part of linphone-android + * (see https://www.linphone.org). + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.linphone.activities.assistant.fragments + +import android.os.Bundle +import android.view.View +import org.linphone.R +import org.linphone.activities.GenericFragment +import org.linphone.activities.navigateToGenericLogin +import org.linphone.databinding.AssistantGenericAccountWarningFragmentBinding + +class GenericAccountWarningFragment : GenericFragment() { + override fun getLayoutId(): Int = R.layout.assistant_generic_account_warning_fragment + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + + binding.lifecycleOwner = viewLifecycleOwner + + binding.setUnderstoodClickListener { + navigateToGenericLogin() + } + } +} diff --git a/app/src/main/java/org/linphone/activities/assistant/fragments/WelcomeFragment.kt b/app/src/main/java/org/linphone/activities/assistant/fragments/WelcomeFragment.kt index aba6fa79f..012f63682 100644 --- a/app/src/main/java/org/linphone/activities/assistant/fragments/WelcomeFragment.kt +++ b/app/src/main/java/org/linphone/activities/assistant/fragments/WelcomeFragment.kt @@ -35,7 +35,6 @@ import org.linphone.activities.* import org.linphone.activities.assistant.viewmodels.WelcomeViewModel import org.linphone.activities.navigateToAccountLogin import org.linphone.activities.navigateToEmailAccountCreation -import org.linphone.activities.navigateToGenericLogin import org.linphone.activities.navigateToRemoteProvisioning import org.linphone.databinding.AssistantWelcomeFragmentBinding @@ -65,7 +64,7 @@ class WelcomeFragment : GenericFragment() { } binding.setGenericAccountLoginClickListener { - navigateToGenericLogin() + navigateToGenericLoginWarning() } binding.setRemoteProvisioningClickListener { diff --git a/app/src/main/res/layout/assistant_generic_account_warning_fragment.xml b/app/src/main/res/layout/assistant_generic_account_warning_fragment.xml new file mode 100644 index 000000000..b4ab8d0c1 --- /dev/null +++ b/app/src/main/res/layout/assistant_generic_account_warning_fragment.xml @@ -0,0 +1,65 @@ + + + + + + + + + + + + + + + + + + +