From 4f03015486b9d8a4b19679df06eeda3b4a0aff66 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Wed, 6 Sep 2023 11:35:16 +0200 Subject: [PATCH] Added third party sip account login warning fragment --- .../ui/assistant/fragment/LoginFragment.kt | 2 +- .../ThirdPartySipAccountWarningFragment.kt | 84 +++++++++ .../ConfirmConditionsAndPolicyDialogModel.kt | 42 +++++ ...ird_party_sip_account_warning_fragment.xml | 164 ++++++++++++++++++ ...assistant_accept_conditions_and_policy.xml | 126 ++++++++++++++ .../res/navigation/assistant_nav_graph.xml | 46 ++++- 6 files changed, 460 insertions(+), 4 deletions(-) create mode 100644 app/src/main/java/org/linphone/ui/assistant/fragment/ThirdPartySipAccountWarningFragment.kt create mode 100644 app/src/main/java/org/linphone/ui/assistant/model/ConfirmConditionsAndPolicyDialogModel.kt create mode 100644 app/src/main/res/layout/assistant_third_party_sip_account_warning_fragment.xml create mode 100644 app/src/main/res/layout/dialog_assistant_accept_conditions_and_policy.xml diff --git a/app/src/main/java/org/linphone/ui/assistant/fragment/LoginFragment.kt b/app/src/main/java/org/linphone/ui/assistant/fragment/LoginFragment.kt index b20b6d588..586f98df6 100644 --- a/app/src/main/java/org/linphone/ui/assistant/fragment/LoginFragment.kt +++ b/app/src/main/java/org/linphone/ui/assistant/fragment/LoginFragment.kt @@ -93,7 +93,7 @@ class LoginFragment : GenericFragment() { } binding.setThirdPartySipAccountLoginClickListener { - val action = LoginFragmentDirections.actionLoginFragmentToThirdPartySipAccountLoginFragment() + val action = LoginFragmentDirections.actionLoginFragmentToThirdPartySipAccountWarningFragment() findNavController().navigate(action) } diff --git a/app/src/main/java/org/linphone/ui/assistant/fragment/ThirdPartySipAccountWarningFragment.kt b/app/src/main/java/org/linphone/ui/assistant/fragment/ThirdPartySipAccountWarningFragment.kt new file mode 100644 index 000000000..543d1b29b --- /dev/null +++ b/app/src/main/java/org/linphone/ui/assistant/fragment/ThirdPartySipAccountWarningFragment.kt @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2010-2023 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.ui.assistant.fragment + +import android.content.Intent +import android.net.Uri +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.annotation.UiThread +import androidx.navigation.fragment.findNavController +import org.linphone.core.tools.Log +import org.linphone.databinding.AssistantThirdPartySipAccountWarningFragmentBinding +import org.linphone.ui.main.fragment.GenericFragment + +@UiThread +class ThirdPartySipAccountWarningFragment : GenericFragment() { + companion object { + private const val TAG = "[Third Party SIP Account Warning Fragment]" + } + + private lateinit var binding: AssistantThirdPartySipAccountWarningFragmentBinding + + override fun onCreateView( + inflater: LayoutInflater, + container: ViewGroup?, + savedInstanceState: Bundle? + ): View { + binding = AssistantThirdPartySipAccountWarningFragmentBinding.inflate(layoutInflater) + 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() + } + + binding.setContactClickListener { + try { + val url = "https://linphone.org/contact" + val browserIntent = Intent(Intent.ACTION_VIEW, Uri.parse(url)) + startActivity(browserIntent) + } catch (ise: IllegalStateException) { + Log.e("$TAG Can't start ACTION_VIEW intent, IllegalStateException: $ise") + } + } + + binding.setCreateAccountClickListener { + val action = ThirdPartySipAccountWarningFragmentDirections.actionThirdPartySipAccountWarningFragmentToRegisterFragment() + findNavController().navigate(action) + } + + binding.setLoginClickListener { + val action = ThirdPartySipAccountWarningFragmentDirections.actionThirdPartySipAccountWarningFragmentToThirdPartySipAccountLoginFragment() + findNavController().navigate(action) + } + } +} diff --git a/app/src/main/java/org/linphone/ui/assistant/model/ConfirmConditionsAndPolicyDialogModel.kt b/app/src/main/java/org/linphone/ui/assistant/model/ConfirmConditionsAndPolicyDialogModel.kt new file mode 100644 index 000000000..89686c76a --- /dev/null +++ b/app/src/main/java/org/linphone/ui/assistant/model/ConfirmConditionsAndPolicyDialogModel.kt @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2010-2023 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.ui.assistant.model + +import androidx.annotation.UiThread +import androidx.lifecycle.MutableLiveData +import org.linphone.utils.Event + +class ConfirmConditionsAndPolicyDialogModel @UiThread constructor() { + val dismissEvent = MutableLiveData>() + + @UiThread + fun dismiss() { + dismissEvent.value = Event(true) + } + + fun denyConditions() { + // TODO + } + + @UiThread + fun acceptConditions() { + // TODO + } +} diff --git a/app/src/main/res/layout/assistant_third_party_sip_account_warning_fragment.xml b/app/src/main/res/layout/assistant_third_party_sip_account_warning_fragment.xml new file mode 100644 index 000000000..e6c6db747 --- /dev/null +++ b/app/src/main/res/layout/assistant_third_party_sip_account_warning_fragment.xml @@ -0,0 +1,164 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/dialog_assistant_accept_conditions_and_policy.xml b/app/src/main/res/layout/dialog_assistant_accept_conditions_and_policy.xml new file mode 100644 index 000000000..82fb8ee15 --- /dev/null +++ b/app/src/main/res/layout/dialog_assistant_accept_conditions_and_policy.xml @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/navigation/assistant_nav_graph.xml b/app/src/main/res/navigation/assistant_nav_graph.xml index c9b05ccef..37cbc45ed 100644 --- a/app/src/main/res/navigation/assistant_nav_graph.xml +++ b/app/src/main/res/navigation/assistant_nav_graph.xml @@ -10,6 +10,7 @@ android:name="org.linphone.ui.assistant.fragment.LoginFragment" android:label="LoginFragment" tools:layout="@layout/assistant_login_fragment" > + + + + + + + + + + + + + + + + app:popUpTo="@id/loginFragment" + app:popUpToInclusive="false" /> + \ No newline at end of file