diff --git a/vector/src/main/AndroidManifest.xml b/vector/src/main/AndroidManifest.xml index 5b56107ef7..8e9e534f7a 100644 --- a/vector/src/main/AndroidManifest.xml +++ b/vector/src/main/AndroidManifest.xml @@ -113,45 +113,35 @@ - + + + + + + + + + + + + + - - - + android:windowSoftInputMode="adjustResize" /> - - - - - - - - - - - - - - - - - - + android:windowSoftInputMode="adjustResize" /> (), ToolbarCo putExtra(EXTRA_CONFIG, loginConfig) } } + + fun redirectIntent(context: Context, data: Uri?): Intent { + return Intent(context, LoginActivity::class.java).apply { + setData(data) + } + } } } diff --git a/vector/src/main/java/im/vector/app/features/login/SSORedirectRouterActivity.kt b/vector/src/main/java/im/vector/app/features/login/SSORedirectRouterActivity.kt new file mode 100644 index 0000000000..29f8559362 --- /dev/null +++ b/vector/src/main/java/im/vector/app/features/login/SSORedirectRouterActivity.kt @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2021 New Vector Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package im.vector.app.features.login + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import dagger.hilt.android.AndroidEntryPoint +import im.vector.app.features.navigation.Navigator +import javax.inject.Inject + +@AndroidEntryPoint +class SSORedirectRouterActivity : AppCompatActivity() { + + @Inject lateinit var navigator: Navigator + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + navigator.loginSSORedirect(this, intent.data) + finish() + } +} diff --git a/vector/src/main/java/im/vector/app/features/login2/LoginActivity2.kt b/vector/src/main/java/im/vector/app/features/login2/LoginActivity2.kt index 8f1b20aa7f..e32ace35b2 100644 --- a/vector/src/main/java/im/vector/app/features/login2/LoginActivity2.kt +++ b/vector/src/main/java/im/vector/app/features/login2/LoginActivity2.kt @@ -18,6 +18,7 @@ package im.vector.app.features.login2 import android.content.Context import android.content.Intent +import android.net.Uri import android.view.View import android.view.ViewGroup import androidx.core.view.ViewCompat @@ -40,6 +41,7 @@ import im.vector.app.core.platform.ToolbarConfigurable import im.vector.app.core.platform.VectorBaseActivity import im.vector.app.databinding.ActivityLoginBinding import im.vector.app.features.home.HomeActivity +import im.vector.app.features.login.LoginActivity import im.vector.app.features.login.LoginCaptchaFragmentArgument import im.vector.app.features.login.LoginConfig import im.vector.app.features.login.LoginGenericTextInputFormFragmentArgument @@ -396,5 +398,11 @@ open class LoginActivity2 : VectorBaseActivity(), ToolbarC putExtra(EXTRA_CONFIG, loginConfig) } } + + fun redirectIntent(context: Context, data: Uri?): Intent { + return Intent(context, LoginActivity2::class.java).apply { + setData(data) + } + } } } diff --git a/vector/src/main/java/im/vector/app/features/navigation/DefaultNavigator.kt b/vector/src/main/java/im/vector/app/features/navigation/DefaultNavigator.kt index af43dc6fe7..ff57528c16 100644 --- a/vector/src/main/java/im/vector/app/features/navigation/DefaultNavigator.kt +++ b/vector/src/main/java/im/vector/app/features/navigation/DefaultNavigator.kt @@ -19,6 +19,7 @@ package im.vector.app.features.navigation import android.app.Activity import android.content.Context import android.content.Intent +import android.net.Uri import android.os.Build import android.view.View import android.view.Window @@ -118,6 +119,14 @@ class DefaultNavigator @Inject constructor( context.startActivity(intent) } + override fun loginSSORedirect(context: Context, data: Uri?) { + val intent = when (features.loginType()) { + VectorFeatures.LoginType.V1 -> LoginActivity.redirectIntent(context, data) + VectorFeatures.LoginType.V2 -> LoginActivity2.redirectIntent(context, data) + } + context.startActivity(intent) + } + override fun softLogout(context: Context) { val intent = when (features.loginType()) { VectorFeatures.LoginType.V1 -> SoftLogoutActivity.newIntent(context) diff --git a/vector/src/main/java/im/vector/app/features/navigation/Navigator.kt b/vector/src/main/java/im/vector/app/features/navigation/Navigator.kt index e0c6eb26bb..a1f40f07c0 100644 --- a/vector/src/main/java/im/vector/app/features/navigation/Navigator.kt +++ b/vector/src/main/java/im/vector/app/features/navigation/Navigator.kt @@ -19,6 +19,7 @@ package im.vector.app.features.navigation import android.app.Activity import android.content.Context import android.content.Intent +import android.net.Uri import android.view.View import androidx.activity.result.ActivityResultLauncher import androidx.core.util.Pair @@ -41,6 +42,8 @@ interface Navigator { fun openLogin(context: Context, loginConfig: LoginConfig? = null, flags: Int = 0) + fun loginSSORedirect(context: Context, data: Uri?) + fun softLogout(context: Context) fun openRoom(context: Context, roomId: String, eventId: String? = null, buildTask: Boolean = false)