Added third party sip account login warning fragment

This commit is contained in:
Sylvain Berfini 2023-09-06 11:35:16 +02:00
parent 7b48d41d29
commit 4f03015486
6 changed files with 460 additions and 4 deletions

View file

@ -93,7 +93,7 @@ class LoginFragment : GenericFragment() {
}
binding.setThirdPartySipAccountLoginClickListener {
val action = LoginFragmentDirections.actionLoginFragmentToThirdPartySipAccountLoginFragment()
val action = LoginFragmentDirections.actionLoginFragmentToThirdPartySipAccountWarningFragment()
findNavController().navigate(action)
}

View file

@ -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 <http://www.gnu.org/licenses/>.
*/
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)
}
}
}

View file

@ -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 <http://www.gnu.org/licenses/>.
*/
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<Event<Boolean>>()
@UiThread
fun dismiss() {
dismissEvent.value = Event(true)
}
fun denyConditions() {
// TODO
}
@UiThread
fun acceptConditions() {
// TODO
}
}

View file

@ -0,0 +1,164 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:bind="http://schemas.android.com/tools">
<data>
<import type="android.view.View" />
<import type="android.text.InputType" />
<variable
name="backClickListener"
type="View.OnClickListener" />
<variable
name="contactClickListener"
type="View.OnClickListener" />
<variable
name="createAccountClickListener"
type="View.OnClickListener" />
<variable
name="loginClickListener"
type="View.OnClickListener" />
</data>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white">
<ImageView
android:onClick="@{backClickListener}"
android:id="@+id/back"
android:layout_width="@dimen/icon_size"
android:layout_height="@dimen/icon_size"
android:layout_marginTop="7dp"
android:layout_marginStart="15dp"
android:src="@drawable/caret_left"
app:tint="@color/gray_1"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"/>
<androidx.appcompat.widget.AppCompatTextView
style="@style/default_text_style_800"
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="100dp"
android:text="Use a third party SIP Account"
android:textSize="20sp"
android:textColor="@color/gray_9"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"/>
<ImageView
android:id="@+id/no_chat"
android:layout_width="56dp"
android:layout_height="56dp"
android:layout_marginTop="68dp"
android:layout_marginEnd="30dp"
android:background="@drawable/call_chat_button_background"
android:padding="16dp"
android:src="@drawable/chat_text"
app:tint="@color/gray_1"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toStartOf="@id/no_video"
app:layout_constraintTop_toBottomOf="@id/title"/>
<ImageView
android:id="@+id/no_video"
android:layout_width="56dp"
android:layout_height="56dp"
android:layout_marginTop="68dp"
android:background="@drawable/call_chat_button_background"
android:padding="16dp"
android:src="@drawable/video_camera_slash"
app:tint="@color/gray_1"
app:layout_constraintStart_toEndOf="@id/no_chat"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/title"/>
<androidx.appcompat.widget.AppCompatTextView
style="@style/default_text_style"
android:id="@+id/message"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="42dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:text="Some features require a Linphone account, such as group messaging, video conferences...\n\nThese features are hidden when you register with a third party SIP account.\n\nTo enable it in a commercial projet, please contact us. "
android:textSize="14sp"
android:gravity="center"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/no_chat"/>
<androidx.appcompat.widget.AppCompatTextView
android:onClick="@{contactClickListener}"
style="@style/default_text_style_600"
android:id="@+id/contact"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="42dp"
android:paddingTop="6dp"
android:paddingBottom="6dp"
android:paddingStart="12dp"
android:paddingEnd="12dp"
android:text="linphone.org/contact"
android:textSize="13sp"
android:textColor="@color/secondary_button_label_color"
android:gravity="center"
android:background="@drawable/secondary_button_background"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/message" />
<androidx.appcompat.widget.AppCompatTextView
android:onClick="@{createAccountClickListener}"
style="@style/default_text_style_600"
android:id="@+id/create_linphone_account"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="20dp"
android:paddingTop="@dimen/primary_secondary_buttons_label_padding"
android:paddingBottom="@dimen/primary_secondary_buttons_label_padding"
android:paddingStart="20dp"
android:paddingEnd="20dp"
android:text="I prefer to create an account"
android:textSize="18sp"
android:textColor="@color/secondary_button_label_color"
android:gravity="center"
android:background="@drawable/secondary_button_background"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toTopOf="@id/continue_third_party_account_login" />
<androidx.appcompat.widget.AppCompatTextView
android:onClick="@{loginClickListener}"
style="@style/default_text_style_600"
android:id="@+id/continue_third_party_account_login"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="20dp"
android:paddingTop="@dimen/primary_secondary_buttons_label_padding"
android:paddingBottom="@dimen/primary_secondary_buttons_label_padding"
android:paddingStart="20dp"
android:paddingEnd="20dp"
android:text="I understand"
android:textSize="18sp"
android:textColor="@color/primary_button_label_color"
android:gravity="center"
android:background="@drawable/primary_button_background"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>

View file

@ -0,0 +1,126 @@
<?xml version="1.0" encoding="utf-8"?>
<layout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<data>
<import type="android.view.View" />
<variable
name="viewModel"
type="org.linphone.ui.assistant.model.ConfirmConditionsAndPolicyDialogModel" />
</data>
<androidx.constraintlayout.widget.ConstraintLayout
android:onClick="@{() -> viewModel.dismiss()}"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="true"
android:focusable="true">
<ImageView
android:id="@+id/dialog_background_shadow"
android:layout_width="0dp"
android:layout_height="0dp"
android:src="@drawable/shape_dialog_orange_shadow"
app:layout_constraintBottom_toBottomOf="@id/anchor"
app:layout_constraintEnd_toEndOf="@id/dialog_background"
app:layout_constraintStart_toStartOf="@id/dialog_background"
app:layout_constraintTop_toTopOf="@id/dialog_background" />
<ImageView
android:id="@+id/dialog_background"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="12dp"
android:layout_marginEnd="12dp"
android:layout_marginBottom="2dp"
android:src="@drawable/shape_dialog_background"
app:layout_constraintBottom_toBottomOf="@id/anchor"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@id/title" />
<androidx.appcompat.widget.AppCompatTextView
style="@style/default_text_style_800"
android:id="@+id/title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="15dp"
android:paddingTop="@dimen/dialog_top_bottom_margin"
android:text="Conditions de service"
android:textSize="16sp"
app:layout_constraintVertical_chainStyle="packed"
app:layout_constraintBottom_toTopOf="@id/message"
app:layout_constraintStart_toStartOf="@id/dialog_background"
app:layout_constraintEnd_toEndOf="@id/dialog_background"
app:layout_constraintTop_toTopOf="parent" />
<androidx.appcompat.widget.AppCompatTextView
style="@style/default_text_style"
android:id="@+id/message"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="15dp"
android:layout_marginEnd="15dp"
android:layout_marginTop="10dp"
android:text="En continuant, vous acceptez ces conditions, notre politique de confidentialité et nos conditions d'utilisation."
android:textSize="14sp"
app:layout_constraintBottom_toTopOf="@id/cancel"
app:layout_constraintStart_toStartOf="@id/dialog_background"
app:layout_constraintEnd_toEndOf="@id/dialog_background"
app:layout_constraintTop_toBottomOf="@id/title" />
<androidx.appcompat.widget.AppCompatTextView
android:onClick="@{() -> viewModel.denyConditions()}"
style="@style/default_text_style_600"
android:id="@+id/cancel"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:layout_marginStart="15dp"
android:layout_marginEnd="15dp"
android:paddingBottom="@dimen/primary_secondary_buttons_label_padding"
android:paddingTop="@dimen/primary_secondary_buttons_label_padding"
android:gravity="center"
android:background="@drawable/secondary_button_background"
android:text="Deny"
android:textSize="18sp"
android:textColor="@color/secondary_button_label_color"
app:layout_constraintStart_toStartOf="@id/dialog_background"
app:layout_constraintEnd_toEndOf="@id/dialog_background"
app:layout_constraintTop_toBottomOf="@id/message"
app:layout_constraintBottom_toTopOf="@id/confirm"/>
<androidx.appcompat.widget.AppCompatTextView
android:onClick="@{() -> viewModel.acceptConditions()}"
style="@style/default_text_style_600"
android:id="@+id/confirm"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginStart="15dp"
android:layout_marginEnd="15dp"
android:paddingBottom="@dimen/primary_secondary_buttons_label_padding"
android:paddingTop="@dimen/primary_secondary_buttons_label_padding"
android:gravity="center"
android:background="@drawable/primary_button_background"
android:text="Accept"
android:textSize="18sp"
android:textColor="@color/primary_button_label_color"
app:layout_constraintStart_toStartOf="@id/dialog_background"
app:layout_constraintEnd_toEndOf="@id/dialog_background"
app:layout_constraintTop_toBottomOf="@id/cancel"
app:layout_constraintBottom_toTopOf="@id/anchor"/>
<View
android:id="@+id/anchor"
android:layout_width="wrap_content"
android:layout_height="@dimen/dialog_top_bottom_margin"
app:layout_constraintTop_toBottomOf="@id/confirm"
app:layout_constraintStart_toStartOf="@id/dialog_background"
app:layout_constraintEnd_toEndOf="@id/dialog_background"
app:layout_constraintBottom_toBottomOf="parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>

View file

@ -10,6 +10,7 @@
android:name="org.linphone.ui.assistant.fragment.LoginFragment"
android:label="LoginFragment"
tools:layout="@layout/assistant_login_fragment" >
<action
android:id="@+id/action_loginFragment_to_registerFragment"
app:destination="@id/registerFragment"
@ -18,6 +19,7 @@
app:popEnterAnim="@anim/slide_in_left"
app:popExitAnim="@anim/slide_out_right"
app:launchSingleTop="true" />
<action
android:id="@+id/action_loginFragment_to_qrCodeScannerFragment"
app:destination="@id/qrCodeScannerFragment"
@ -26,14 +28,16 @@
app:popEnterAnim="@anim/slide_in_left"
app:popExitAnim="@anim/slide_out_right"
app:launchSingleTop="true" />
<action
android:id="@+id/action_loginFragment_to_thirdPartySipAccountLoginFragment"
app:destination="@id/thirdPartySipAccountLoginFragment"
android:id="@+id/action_loginFragment_to_thirdPartySipAccountWarningFragment"
app:destination="@id/thirdPartySipAccountWarningFragment"
app:enterAnim="@anim/slide_in_right"
app:exitAnim="@anim/slide_out_left"
app:popEnterAnim="@anim/slide_in_left"
app:popExitAnim="@anim/slide_out_right"
app:launchSingleTop="true" />
</fragment>
<fragment
@ -41,6 +45,7 @@
android:name="org.linphone.ui.assistant.fragment.RegisterFragment"
android:label="RegisterFragment"
tools:layout="@layout/assistant_register_fragment" >
<action
android:id="@+id/action_registerFragment_to_registerCodeConfirmationFragment"
app:destination="@id/registerCodeConfirmationFragment"
@ -49,6 +54,7 @@
app:popEnterAnim="@anim/slide_in_left"
app:popExitAnim="@anim/slide_out_right"
app:launchSingleTop="true" />
</fragment>
<fragment
@ -63,19 +69,53 @@
android:label="ThirdPartySipAccountLoginFragment"
tools:layout="@layout/assistant_third_party_sip_account_login_fragment" />
<fragment
android:id="@+id/thirdPartySipAccountWarningFragment"
android:name="org.linphone.ui.assistant.fragment.ThirdPartySipAccountWarningFragment"
android:label="ThirdPartySipAccountWarningFragment"
tools:layout="@layout/assistant_third_party_sip_account_warning_fragment" >
<action
android:id="@+id/action_thirdPartySipAccountWarningFragment_to_thirdPartySipAccountLoginFragment"
app:destination="@id/thirdPartySipAccountLoginFragment"
app:enterAnim="@anim/slide_in_right"
app:exitAnim="@anim/slide_out_left"
app:popEnterAnim="@anim/slide_in_left"
app:popExitAnim="@anim/slide_out_right"
app:launchSingleTop="true"
app:popUpTo="@id/loginFragment"
app:popUpToInclusive="false" />
<action
android:id="@+id/action_thirdPartySipAccountWarningFragment_to_registerFragment"
app:destination="@id/registerFragment"
app:enterAnim="@anim/slide_in_right"
app:exitAnim="@anim/slide_out_left"
app:launchSingleTop="true"
app:popEnterAnim="@anim/slide_in_left"
app:popExitAnim="@anim/slide_out_right"
app:popUpTo="@id/loginFragment"
app:popUpToInclusive="false" />
</fragment>
<fragment
android:id="@+id/registerCodeConfirmationFragment"
android:name="org.linphone.ui.assistant.fragment.RegisterCodeConfirmationFragment"
android:label="RegisterCodeConfirmationFragment"
tools:layout="@layout/assistant_register_confirm_sms_code_fragment" >
<action
android:id="@+id/action_registerCodeConfirmationFragment_to_loginFragment"
app:destination="@id/loginFragment"
app:enterAnim="@anim/slide_in_right"
app:exitAnim="@anim/slide_out_left"
app:launchSingleTop="true"
app:popEnterAnim="@anim/slide_in_left"
app:popExitAnim="@anim/slide_out_right"
app:launchSingleTop="true" />
app:popUpTo="@id/loginFragment"
app:popUpToInclusive="false" />
</fragment>
</navigation>