Skip to content

Commit

Permalink
Enable SSO connection
Browse files Browse the repository at this point in the history
  • Loading branch information
yostyle committed Aug 6, 2024
1 parent 1d955d8 commit f449d83
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 14 deletions.
24 changes: 12 additions & 12 deletions vector/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />

<!-- To be able to install APK from the application -->
<!-- Tchap: Remove the ability to install an app from Tchap (https://github.com/tchapgouv/tchap-android/issues/832)-->
<!-- TCHAP Remove the ability to install an app from Tchap (https://github.com/tchapgouv/tchap-android/issues/832)-->
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" tools:node="remove" />

<!-- Location Sharing -->
Expand All @@ -57,7 +57,7 @@
<!-- Jitsi SDK is now API23+ -->
<uses-sdk tools:overrideLibrary="com.swmansion.gesturehandler,org.jitsi.meet.sdk,com.oney.WebRTCModule,com.learnium.RNDeviceInfo,com.reactnativecommunity.asyncstorage,com.ocetnik.timer,com.calendarevents,com.reactnativecommunity.netinfo,com.kevinresol.react_native_default_preference,com.rnimmersive,com.corbt.keepawake,com.BV.LinearGradient,com.horcrux.svg,com.oblador.performance,com.reactnativecommunity.slider,com.brentvatne.react,com.reactnativecommunity.clipboard,com.swmansion.gesturehandler.react,org.linusu,org.reactnative.maskedview,com.reactnativepagerview,com.swmansion.reanimated,com.th3rdwave.safeareacontext,com.swmansion.rnscreens,org.devio.rn.splashscreen,com.reactnativecommunity.webview,org.wonday.orientation" />

<!-- Tchap: Jitsi libs adds CALENDAR permissions, but we can remove them safely
<!-- TCHAP Jitsi libs adds CALENDAR permissions, but we can remove them safely
according to https://github.com/jitsi/jitsi-meet/issues/4068#issuecomment-480482481 -->
<uses-permission android:name="android.permission.READ_CALENDAR" tools:node="remove" />
<uses-permission android:name="android.permission.WRITE_CALENDAR" tools:node="remove" />
Expand Down Expand Up @@ -99,7 +99,7 @@
android:name="android.max_aspect"
android:value="9.9" />

<!-- Tchap: Temporary disable android auto (https://github.com/tchapgouv/tchap-android/issues/703) -->
<!-- TCHAP Temporary disable android auto (https://github.com/tchapgouv/tchap-android/issues/703) -->
<!-- <meta-data-->
<!-- android:name="com.google.android.gms.car.application"-->
<!-- android:resource="@xml/automotive_app_desc" />-->
Expand All @@ -117,16 +117,16 @@
android:theme="@style/Theme.Vector.Black.Transparent">

<!-- Add intent filter to handle redirection URL after SSO login in external browser -->
<!-- <intent-filter>-->
<!-- <action android:name="android.intent.action.VIEW" />-->
<intent-filter>
<action android:name="android.intent.action.VIEW" />

<!-- <category android:name="android.intent.category.DEFAULT" />-->
<!-- <category android:name="android.intent.category.BROWSABLE" />-->
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />

<!-- <data-->
<!-- android:host="connect"-->
<!-- android:scheme="element" />-->
<!-- </intent-filter>-->
<data
android:host="connect"
android:scheme="tchap" />
</intent-filter>
</activity>

<activity
Expand Down Expand Up @@ -396,7 +396,7 @@
android:exported="false"
android:foregroundServiceType="dataSync" />

<!-- Tchap: this service has been moved to withvoip flavor -->
<!-- TCHAP this service has been moved to withvoip flavor -->
<!-- <service-->
<!-- android:name=".features.call.webrtc.ScreenCaptureAndroidService"-->
<!-- android:exported="false"-->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ class SSORedirectRouterActivity : AppCompatActivity() {

companion object {
// Note that the domain can be displayed to the user for confirmation that he trusts it. So use a human readable string
const val VECTOR_REDIRECT_URL = "element://connect"
const val VECTOR_REDIRECT_URL = "tchap://connect"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ sealed interface OnboardingAction : VectorViewModelAction {
data class Registration(val userId: String) : UserNameEnteredAction
data class Login(val userId: String) : UserNameEnteredAction
}
data class EmailEnteredAction(val email: String) : OnboardingAction
sealed interface AuthenticateAction : OnboardingAction {
data class TchapRegister(val email: String, val password: String, val initialDeviceName: String) : AuthenticateAction
data class TchapLogin(val email: String, val password: String, val initialDeviceName: String) : AuthenticateAction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ class OnboardingViewModel @AssistedInject constructor(

override fun handle(action: OnboardingAction) {
when (action) {
is OnboardingAction.EmailEnteredAction -> handleEmailEntered(action)
is OnboardingAction.SplashAction -> handleSplashAction(action)
is OnboardingAction.UpdateUseCase -> handleUpdateUseCase(action)
OnboardingAction.ResetUseCase -> resetUseCase()
Expand Down Expand Up @@ -209,6 +210,20 @@ class OnboardingViewModel @AssistedInject constructor(
}
}

private fun handleEmailEntered(action: OnboardingAction.EmailEnteredAction) {
currentJob = viewModelScope.launch {
when (val result = getPlatformTask.execute(Params(action.email))) {
is GetPlatformResult.Success -> {
val homeServerUrl = stringProvider.getString(R.string.server_url_prefix) + result.platform.hs
handleHomeserverChange(OnboardingAction.HomeServerChange.EditHomeServer(homeServerUrl))
}
is GetPlatformResult.Failure -> {
// Nothin to do.
}
}
}
}

private fun handleUserNameEntered(action: OnboardingAction.UserNameEnteredAction) {
when (action) {
is OnboardingAction.UserNameEnteredAction.Login -> maybeUpdateHomeserver(action.userId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import android.view.inputmethod.EditorInfo
import androidx.autofill.HintConstants
import androidx.core.text.isDigitsOnly
import androidx.core.view.isVisible
import androidx.core.widget.doOnTextChanged
import androidx.lifecycle.lifecycleScope
import com.airbnb.mvrx.withState
import com.google.android.material.dialog.MaterialAlertDialogBuilder
Expand All @@ -39,7 +40,6 @@ import im.vector.app.features.login.SSORedirectRouterActivity
import im.vector.app.features.login.ServerType
import im.vector.app.features.login.SignMode
import im.vector.app.features.login.SocialLoginButtonsView
import im.vector.app.features.login.SocialLoginButtonsView.Mode
import im.vector.app.features.login.render
import im.vector.app.features.onboarding.OnboardingAction
import im.vector.app.features.onboarding.OnboardingViewEvents
Expand Down Expand Up @@ -89,6 +89,12 @@ class FtueAuthLoginFragment :
setupSubmitButton()
setupForgottenPasswordButton()

views.loginField.doOnTextChanged { text, _, _, _ ->
text.toString().lowercase().trim().let {
if (it.isEmail()) viewModel.handle(OnboardingAction.EmailEnteredAction(it))
}
}

views.passwordField.setOnEditorActionListener { _, actionId, _ ->
if (actionId == EditorInfo.IME_ACTION_DONE) {
submit()
Expand Down

0 comments on commit f449d83

Please sign in to comment.