Commit b1da349e authored by Filipe de Lima Brito's avatar Filipe de Lima Brito

Fix crash after sign in with OAuth account. Fix SAML and Custom OAuth buttons...

Fix crash after sign in with OAuth account. Fix SAML and Custom OAuth buttons not showing. Fix style for Custom OAuth and SAML buttons.
parent c4cd2eeb
......@@ -71,18 +71,21 @@ class LoginOptionsPresenter @Inject constructor(
credentialToken = oauthToken
credentialSecret = oauthSecret
loginMethod = AuthenticationEvent.AuthenticationWithOauth
setupConnectionInfo(currentServer)
doAuthentication(TYPE_LOGIN_OAUTH)
}
fun authenticateWithCas(casToken: String) {
credentialToken = casToken
loginMethod = AuthenticationEvent.AuthenticationWithCas
setupConnectionInfo(currentServer)
doAuthentication(TYPE_LOGIN_CAS)
}
fun authenticateWithSaml(samlToken: String) {
credentialToken = samlToken
loginMethod = AuthenticationEvent.AuthenticationWithSaml
setupConnectionInfo(currentServer)
doAuthentication(TYPE_LOGIN_SAML)
}
......
......@@ -9,6 +9,7 @@ import android.view.View
import android.view.ViewGroup
import android.widget.Button
import android.widget.LinearLayout
import androidx.appcompat.view.ContextThemeWrapper
import androidx.core.view.isVisible
import androidx.fragment.app.Fragment
import chat.rocket.android.R
......@@ -18,11 +19,7 @@ import chat.rocket.android.authentication.domain.model.LoginDeepLinkInfo
import chat.rocket.android.authentication.loginoptions.presentation.LoginOptionsPresenter
import chat.rocket.android.authentication.loginoptions.presentation.LoginOptionsView
import chat.rocket.android.authentication.ui.AuthenticationActivity
import chat.rocket.android.util.extensions.clearLightStatusBar
import chat.rocket.android.util.extensions.inflate
import chat.rocket.android.util.extensions.rotateBy
import chat.rocket.android.util.extensions.showToast
import chat.rocket.android.util.extensions.ui
import chat.rocket.android.util.extensions.*
import chat.rocket.android.webview.oauth.ui.INTENT_OAUTH_CREDENTIAL_SECRET
import chat.rocket.android.webview.oauth.ui.INTENT_OAUTH_CREDENTIAL_TOKEN
import chat.rocket.android.webview.oauth.ui.oauthWebViewIntent
......@@ -290,7 +287,6 @@ class LoginOptionsFragment : Fragment(), LoginOptionsView {
}
}
// OAuth Accounts.
override fun enableLoginByFacebook() = enableAccountButton(button_facebook)
......@@ -337,8 +333,8 @@ class LoginOptionsFragment : Fragment(), LoginOptionsView {
buttonColor: Int
) {
val button = getCustomServiceButton(serviceName, serviceNameColor, buttonColor)
accounts_container.addView(button)
setupButtonListener(button, customOauthUrl, state, REQUEST_CODE_FOR_OAUTH)
accounts_container.addView(button)
}
// SAML account.
......@@ -350,8 +346,8 @@ class LoginOptionsFragment : Fragment(), LoginOptionsView {
buttonColor: Int
) {
val button = getCustomServiceButton(serviceName, serviceNameColor, buttonColor)
accounts_container.addView(button)
setupButtonListener(button, samlUrl, samlToken, REQUEST_CODE_FOR_SAML)
accounts_container.addView(button)
}
override fun showAccountsView() {
......@@ -487,7 +483,11 @@ class LoginOptionsFragment : Fragment(), LoginOptionsView {
val marginTop = resources.getDimensionPixelSize(R.dimen.button_account_margin_top)
params.setMargins(0, marginTop, 0, 0)
val button = Button(context)
val button = Button(
ContextThemeWrapper(context, R.style.Authentication_Button),
null,
R.style.Authentication_Button
)
button.layoutParams = params
button.text = buttonText
button.setTextColor(buttonTextColor)
......
......@@ -124,8 +124,18 @@ abstract class CheckServerPresenter constructor(
if (services.isNotEmpty()) {
state = OauthHelper.getState()
checkEnabledOauthAccounts(services, serverUrl)
checkEnabledCasAccounts(serverUrl)
checkEnabledCustomOauthAccounts(services, serverUrl)
checkEnabledSamlAccounts(services, serverUrl)
}
} catch (exception: RocketChatException) {
Timber.e(exception)
}
}
private fun checkEnabledOauthAccounts(services: List<Map<String,Any>>, serverUrl: String) {
// OAuth accounts.
if (settings.isFacebookAuthenticationEnabled()) {
getServiceMap(services, SERVICE_NAME_FACEBOOK)?.let { serviceMap ->
getOauthClientId(serviceMap)?.let { clientId ->
......@@ -215,15 +225,17 @@ abstract class CheckServerPresenter constructor(
}
}
}
}
// CAS account.
private fun checkEnabledCasAccounts(serverUrl: String) {
if (settings.isCasAuthenticationEnabled()) {
casToken = generateRandomString(17)
casLoginUrl = settings.casLoginUrl().casUrl(serverUrl, casToken.toString())
totalSocialAccountsEnabled++
}
}
// Custom OAuth account.
private fun checkEnabledCustomOauthAccounts(services: List<Map<String,Any>>, serverUrl: String) {
getCustomOauthServices(services).let {
for (serviceMap in it) {
customOauthServiceName = getCustomOauthServiceName(serviceMap)
......@@ -242,7 +254,6 @@ abstract class CheckServerPresenter constructor(
serviceNameTextColor != null &&
serviceButtonColor != null
) {
customOauthUrl = OauthHelper.getCustomOauthUrl(
host,
authorizePath,
......@@ -258,8 +269,9 @@ abstract class CheckServerPresenter constructor(
}
}
}
}
// SAML account.
private fun checkEnabledSamlAccounts(services: List<Map<String,Any>>, serverUrl: String) {
getSamlServices(services).let {
samlToken = generateRandomString(17)
for (serviceMap in it) {
......@@ -282,10 +294,6 @@ abstract class CheckServerPresenter constructor(
}
}
}
} catch (exception: RocketChatException) {
Timber.e(exception)
}
}
internal fun checkIfLoginFormIsEnabled() {
if (settings.isLoginFormEnabled()) {
......
......@@ -12,18 +12,19 @@
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent">
<androidx.constraintlayout.widget.ConstraintLayout
<LinearLayout
android:id="@+id/accounts_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
android:orientation="vertical"
android:visibility="gone"
app:layout_constraintTop_toTopOf="parent"
tools:visibility="visible">
<Button
android:id="@+id/button_facebook"
style="?borderlessButtonStyle"
android:layout_width="0dp"
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="@drawable/rounded_border"
android:clickable="false"
......@@ -36,15 +37,12 @@
android:textColor="@color/colorPrimary"
android:textSize="16sp"
android:visibility="gone"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:visibility="visible" />
<Button
android:id="@+id/button_github"
style="?borderlessButtonStyle"
android:layout_width="0dp"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_marginTop="10dp"
android:background="@drawable/rounded_border"
......@@ -58,15 +56,12 @@
android:textColor="@color/colorPrimary"
android:textSize="16sp"
android:visibility="gone"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/button_facebook"
tools:visibility="visible" />
<Button
android:id="@+id/button_google"
style="?borderlessButtonStyle"
android:layout_width="0dp"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_marginTop="10dp"
android:background="@drawable/rounded_border"
......@@ -80,15 +75,12 @@
android:textColor="@color/colorPrimary"
android:textSize="16sp"
android:visibility="gone"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/button_github"
tools:visibility="visible" />
<Button
android:id="@+id/button_linkedin"
style="?borderlessButtonStyle"
android:layout_width="0dp"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_marginTop="10dp"
android:background="@drawable/rounded_border"
......@@ -102,15 +94,12 @@
android:textColor="@color/colorPrimary"
android:textSize="16sp"
android:visibility="gone"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/button_google"
tools:visibility="visible" />
<Button
android:id="@+id/button_gitlab"
style="?borderlessButtonStyle"
android:layout_width="0dp"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_marginTop="10dp"
android:background="@drawable/rounded_border"
......@@ -124,15 +113,12 @@
android:textColor="@color/colorPrimary"
android:textSize="16sp"
android:visibility="gone"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/button_linkedin"
tools:visibility="visible" />
<Button
android:id="@+id/button_wordpress"
style="?borderlessButtonStyle"
android:layout_width="0dp"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_marginTop="10dp"
android:background="@drawable/rounded_border"
......@@ -146,9 +132,6 @@
android:textColor="@color/colorPrimary"
android:textSize="16sp"
android:visibility="gone"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/button_gitlab"
tools:visibility="visible" />
<Button
......@@ -158,11 +141,8 @@
android:clickable="false"
android:text="@string/action_login_or_sign_up"
android:visibility="gone"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/button_wordpress"
tools:visibility="visible" />
</androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/expand_more_accounts_container"
......
......@@ -80,7 +80,7 @@
</style>
<style name="Authentication.Button" parent="Widget.AppCompat.Button.Borderless">
<item name="android:layout_width">0dp</item>
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">48dp</item>
<item name="android:foreground">?selectableItemBackground</item>
<item name="android:textSize">18sp</item>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment