mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 19:38:08 +00:00
Removed SSO fragment, only keep activity
This commit is contained in:
parent
5aa949b42c
commit
0fe03e2eec
8 changed files with 123 additions and 284 deletions
|
|
@ -19,10 +19,13 @@
|
|||
*/
|
||||
package org.linphone.ui.assistant
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import net.openid.appauth.AuthorizationException
|
||||
import net.openid.appauth.AuthorizationResponse
|
||||
import org.linphone.R
|
||||
import org.linphone.core.tools.Log
|
||||
import org.linphone.databinding.AssistantSingleSignOnActivityBinding
|
||||
|
|
@ -33,6 +36,8 @@ import org.linphone.ui.assistant.viewmodel.SingleSignOnViewModel
|
|||
class SingleSignOnActivity : GenericActivity() {
|
||||
companion object {
|
||||
private const val TAG = "[Single Sign On Activity]"
|
||||
|
||||
private const val ACTIVITY_RESULT_ID = 666
|
||||
}
|
||||
|
||||
private lateinit var binding: AssistantSingleSignOnActivityBinding
|
||||
|
|
@ -42,13 +47,12 @@ class SingleSignOnActivity : GenericActivity() {
|
|||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
viewModel = run {
|
||||
ViewModelProvider(this)[SingleSignOnViewModel::class.java]
|
||||
}
|
||||
|
||||
binding = DataBindingUtil.setContentView(this, R.layout.assistant_single_sign_on_activity)
|
||||
binding.lifecycleOwner = this
|
||||
|
||||
viewModel = ViewModelProvider(this)[SingleSignOnViewModel::class.java]
|
||||
binding.viewModel = viewModel
|
||||
|
||||
setUpToastsArea(binding.toastsArea)
|
||||
|
||||
if (intent != null) {
|
||||
|
|
@ -62,5 +66,44 @@ class SingleSignOnActivity : GenericActivity() {
|
|||
viewModel.singleSignOnUrl.value = ssoUrl
|
||||
}
|
||||
}
|
||||
|
||||
viewModel.singleSignOnUrl.observe(this) { url ->
|
||||
Log.i("$TAG SSO URL found [$url], setting it up")
|
||||
viewModel.setUp()
|
||||
}
|
||||
|
||||
viewModel.singleSignOnProcessCompletedEvent.observe(this) {
|
||||
it.consume {
|
||||
Log.i("$TAG Process complete, leaving assistant")
|
||||
finish()
|
||||
}
|
||||
}
|
||||
|
||||
viewModel.startAuthIntentEvent.observe(this) {
|
||||
it.consume { intent ->
|
||||
Log.i("$TAG Starting auth intent activity")
|
||||
startActivityForResult(intent, ACTIVITY_RESULT_ID)
|
||||
}
|
||||
}
|
||||
|
||||
viewModel.onErrorEvent.observe(this) {
|
||||
it.consume { errorMessage ->
|
||||
showRedToast(
|
||||
errorMessage,
|
||||
R.drawable.warning_circle
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated("Deprecated in Java")
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
if (requestCode == ACTIVITY_RESULT_ID && data != null) {
|
||||
val resp = AuthorizationResponse.fromIntent(data)
|
||||
val ex = AuthorizationException.fromIntent(data)
|
||||
viewModel.processAuthIntentResponse(resp, ex)
|
||||
}
|
||||
|
||||
super.onActivityResult(requestCode, resultCode, data)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -138,34 +138,8 @@ class LandingFragment : Fragment() {
|
|||
)
|
||||
}
|
||||
}
|
||||
|
||||
/*viewModel.redirectToDigestAuthEvent.observe(viewLifecycleOwner) {
|
||||
it.consume { address ->
|
||||
goToLoginFragment(address)
|
||||
}
|
||||
}
|
||||
|
||||
viewModel.redirectToSingleSignOnEvent.observe(viewLifecycleOwner) {
|
||||
it.consume { address ->
|
||||
goToSingleSignOnFragment(address)
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
/*private fun goToLoginFragment(identity: String) {
|
||||
Log.i(
|
||||
"$TAG Going to Linphone credentials based authentication fragment for SIP account [$identity]"
|
||||
)
|
||||
val action = LandingFragmentDirections.actionLandingFragmentToLoginFragment(identity)
|
||||
findNavController().navigate(action)
|
||||
}
|
||||
|
||||
private fun goToSingleSignOnFragment(identity: String) {
|
||||
Log.i("$TAG Going to Single Sign On fragment for SIP account [$identity]")
|
||||
val action = LandingFragmentDirections.actionLandingFragmentToSingleSignOnFragment()
|
||||
findNavController().navigate(action)
|
||||
}*/
|
||||
|
||||
private fun goToRegisterFragment() {
|
||||
val action = LandingFragmentDirections.actionLandingFragmentToRegisterFragment()
|
||||
findNavController().navigate(action)
|
||||
|
|
|
|||
|
|
@ -1,114 +0,0 @@
|
|||
/*
|
||||
* 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.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import net.openid.appauth.AuthorizationException
|
||||
import net.openid.appauth.AuthorizationResponse
|
||||
import org.linphone.R
|
||||
import org.linphone.core.tools.Log
|
||||
import org.linphone.databinding.AssistantSingleSignOnFragmentBinding
|
||||
import org.linphone.ui.GenericActivity
|
||||
import org.linphone.ui.assistant.viewmodel.SingleSignOnViewModel
|
||||
|
||||
@UiThread
|
||||
class SingleSignOnFragment : Fragment() {
|
||||
companion object {
|
||||
private const val TAG = "[Single Sign On Fragment]"
|
||||
|
||||
private const val ACTIVITY_RESULT_ID = 666
|
||||
}
|
||||
|
||||
private lateinit var binding: AssistantSingleSignOnFragmentBinding
|
||||
|
||||
private lateinit var viewModel: SingleSignOnViewModel
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View {
|
||||
binding = AssistantSingleSignOnFragmentBinding.inflate(layoutInflater)
|
||||
return binding.root
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
binding.lifecycleOwner = viewLifecycleOwner
|
||||
|
||||
viewModel = requireActivity().run {
|
||||
ViewModelProvider(this)[SingleSignOnViewModel::class.java]
|
||||
}
|
||||
binding.viewModel = viewModel
|
||||
|
||||
viewModel.singleSignOnUrl.observe(viewLifecycleOwner) { url ->
|
||||
Log.i("$TAG SSO URL found [$url], setting it up")
|
||||
viewModel.setUp()
|
||||
}
|
||||
|
||||
viewModel.singleSignOnProcessCompletedEvent.observe(viewLifecycleOwner) {
|
||||
it.consume {
|
||||
Log.i("$TAG Process complete, leaving assistant")
|
||||
requireActivity().finish()
|
||||
}
|
||||
}
|
||||
|
||||
viewModel.startAuthIntentEvent.observe(viewLifecycleOwner) {
|
||||
it.consume { intent ->
|
||||
Log.i("$TAG Starting auth intent activity")
|
||||
startActivityForResult(intent, ACTIVITY_RESULT_ID)
|
||||
}
|
||||
}
|
||||
|
||||
viewModel.onErrorEvent.observe(viewLifecycleOwner) {
|
||||
it.consume { errorMessage ->
|
||||
(requireActivity() as GenericActivity).showRedToast(
|
||||
errorMessage,
|
||||
R.drawable.warning_circle
|
||||
)
|
||||
try {
|
||||
findNavController().popBackStack()
|
||||
} catch (ise: IllegalStateException) {
|
||||
// Excepted in SingleSignOnActivity as no NavController is set
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated("Deprecated in Java")
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
if (requestCode == ACTIVITY_RESULT_ID && data != null) {
|
||||
val resp = AuthorizationResponse.fromIntent(data)
|
||||
val ex = AuthorizationException.fromIntent(data)
|
||||
viewModel.processAuthIntentResponse(resp, ex)
|
||||
}
|
||||
|
||||
super.onActivityResult(requestCode, resultCode, data)
|
||||
}
|
||||
}
|
||||
|
|
@ -37,14 +37,6 @@ class LandingViewModel @UiThread constructor() : AccountLoginViewModel() {
|
|||
|
||||
val hideThirdPartyAccount = MutableLiveData<Boolean>()
|
||||
|
||||
/*val redirectToDigestAuthEvent: MutableLiveData<Event<String>> by lazy {
|
||||
MutableLiveData<Event<String>>()
|
||||
}
|
||||
|
||||
val redirectToSingleSignOnEvent: MutableLiveData<Event<String>> by lazy {
|
||||
MutableLiveData<Event<String>>()
|
||||
}*/
|
||||
|
||||
var conditionsAndPrivacyPolicyAccepted = false
|
||||
|
||||
init {
|
||||
|
|
|
|||
|
|
@ -1,45 +1,105 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<data>
|
||||
<import type="android.view.View" />
|
||||
<variable
|
||||
name="viewModel"
|
||||
type="org.linphone.ui.assistant.viewmodel.SingleSignOnViewModel" />
|
||||
</data>
|
||||
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".ui.assistant.AssistantActivity">
|
||||
android:background="?attr/color_main2_000">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.fragment.app.FragmentContainerView
|
||||
android:id="@+id/sso_fragment"
|
||||
android:name="org.linphone.ui.assistant.fragment.SingleSignOnFragment"
|
||||
<ImageView
|
||||
android:id="@+id/back"
|
||||
android:layout_width="@dimen/top_bar_height"
|
||||
android:layout_height="@dimen/top_bar_height"
|
||||
android:padding="15dp"
|
||||
android:src="@drawable/caret_left"
|
||||
android:visibility="invisible"
|
||||
android:contentDescription="@string/content_description_go_back_icon"
|
||||
app:tint="?attr/color_main2_500"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/header"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginTop="19dp"
|
||||
android:src="@drawable/mountains"
|
||||
android:adjustViewBounds="true"
|
||||
android:scaleType="centerCrop"
|
||||
android:contentDescription="@null"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/back"
|
||||
app:layout_constraintBottom_toBottomOf="@id/title"/>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="@style/assistant_page_title_style"
|
||||
android:id="@+id/title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="100dp"
|
||||
android:paddingBottom="27dp"
|
||||
android:text="@string/assistant_login_using_single_sign_on"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/toasts_area"
|
||||
android:layout_width="0dp"
|
||||
<com.google.android.material.progressindicator.CircularProgressIndicator
|
||||
android:id="@+id/progress"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:layout_marginTop="@dimen/toast_top_margin"
|
||||
android:layout_marginStart="15dp"
|
||||
android:layout_marginEnd="15dp"
|
||||
app:layout_constraintWidth_max="@dimen/toast_max_width"
|
||||
android:layout_centerInParent="true"
|
||||
app:indicatorColor="?attr/color_main1_500"
|
||||
android:indeterminate="true"
|
||||
app:layout_constraintVertical_chainStyle="packed"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintBottom_toTopOf="@id/message"/>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="@style/default_text_style_800"
|
||||
android:id="@+id/message"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:text="@string/operation_in_progress_overlay"
|
||||
android:textColor="?attr/color_main1_500"
|
||||
android:textSize="18sp"
|
||||
android:layout_below="@id/progress"
|
||||
android:layout_centerHorizontal="true"
|
||||
app:layout_constraintTop_toBottomOf="@id/progress"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/toasts_area"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:layout_marginTop="@dimen/toast_top_margin"
|
||||
android:layout_marginStart="15dp"
|
||||
android:layout_marginEnd="15dp"
|
||||
app:layout_constraintWidth_max="@dimen/toast_max_width"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
|
||||
</layout>
|
||||
|
|
@ -1,92 +0,0 @@
|
|||
<?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.viewmodel.SingleSignOnViewModel" />
|
||||
</data>
|
||||
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/color_main2_000">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/back"
|
||||
android:layout_width="@dimen/top_bar_height"
|
||||
android:layout_height="@dimen/top_bar_height"
|
||||
android:padding="15dp"
|
||||
android:src="@drawable/caret_left"
|
||||
android:visibility="invisible"
|
||||
android:contentDescription="@string/content_description_go_back_icon"
|
||||
app:tint="?attr/color_main2_500"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/header"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginTop="19dp"
|
||||
android:src="@drawable/mountains"
|
||||
android:adjustViewBounds="true"
|
||||
android:scaleType="centerCrop"
|
||||
android:contentDescription="@null"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/back"
|
||||
app:layout_constraintBottom_toBottomOf="@id/title"/>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="@style/assistant_page_title_style"
|
||||
android:id="@+id/title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="100dp"
|
||||
android:paddingBottom="27dp"
|
||||
android:text="@string/assistant_login_using_single_sign_on"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"/>
|
||||
|
||||
<com.google.android.material.progressindicator.CircularProgressIndicator
|
||||
android:id="@+id/progress"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
app:indicatorColor="?attr/color_main1_500"
|
||||
android:indeterminate="true"
|
||||
app:layout_constraintVertical_chainStyle="packed"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintBottom_toTopOf="@id/message"/>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="@style/default_text_style_800"
|
||||
android:id="@+id/message"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:text="@string/operation_in_progress_overlay"
|
||||
android:textColor="?attr/color_main1_500"
|
||||
android:textSize="18sp"
|
||||
android:layout_below="@id/progress"
|
||||
android:layout_centerHorizontal="true"
|
||||
app:layout_constraintTop_toBottomOf="@id/progress"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
|
||||
</layout>
|
||||
|
|
@ -136,15 +136,6 @@
|
|||
android:label="LandingFragment"
|
||||
tools:layout="@layout/assistant_landing_fragment" >
|
||||
|
||||
<action
|
||||
android:id="@+id/action_landingFragment_to_loginFragment"
|
||||
app:destination="@id/loginFragment"
|
||||
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" />
|
||||
|
||||
<action
|
||||
android:id="@+id/action_landingFragment_to_qrCodeScannerFragment"
|
||||
app:destination="@id/qrCodeScannerFragment"
|
||||
|
|
@ -172,24 +163,9 @@
|
|||
app:popExitAnim="@anim/slide_out_right"
|
||||
app:launchSingleTop="true" />
|
||||
|
||||
<action
|
||||
android:id="@+id/action_landingFragment_to_singleSignOnFragment"
|
||||
app:destination="@id/singleSignOnFragment"
|
||||
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" />
|
||||
<action
|
||||
android:id="@+id/action_landingFragment_to_profileModeFragment"
|
||||
app:destination="@id/profileModeFragment" />
|
||||
|
||||
</fragment>
|
||||
|
||||
<fragment
|
||||
android:id="@+id/singleSignOnFragment"
|
||||
android:name="org.linphone.ui.assistant.fragment.SingleSignOnFragment"
|
||||
android:label="SingleSignOnFragment"
|
||||
tools:layout="@layout/assistant_single_sign_on_fragment" />
|
||||
|
||||
</navigation>
|
||||
|
|
@ -150,7 +150,7 @@
|
|||
<item name="android:textSize">14sp</item>
|
||||
<item name="android:textColor">@color/in_call_label_color</item>
|
||||
<item name="android:gravity">center</item>
|
||||
<item name="maxLines">1</item>
|
||||
<item name="android:maxLines">1</item>
|
||||
<item name="android:ellipsize">end</item>
|
||||
</style>
|
||||
<style name="material_switch_style">
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue