Commit 03e702cb authored by Lucio Maciel's avatar Lucio Maciel

Move smartlock to Play flavor...

parent 3c260fe3
...@@ -108,9 +108,6 @@ dependencies { ...@@ -108,9 +108,6 @@ dependencies {
kapt libraries.daggerProcessor kapt libraries.daggerProcessor
kapt libraries.daggerAndroidApt kapt libraries.daggerAndroidApt
playImplementation libraries.fcm
playImplementation libraries.playServicesAuth
implementation libraries.room implementation libraries.room
kapt libraries.roomProcessor kapt libraries.roomProcessor
implementation libraries.lifecycleExtensions implementation libraries.lifecycleExtensions
...@@ -143,6 +140,9 @@ dependencies { ...@@ -143,6 +140,9 @@ dependencies {
implementation "com.github.luciofm:livedata-ktx:b1e8bbc25a" implementation "com.github.luciofm:livedata-ktx:b1e8bbc25a"
playImplementation libraries.fcm
playImplementation libraries.playServicesAuth
playImplementation('com.crashlytics.sdk.android:crashlytics:2.9.4@aar') { playImplementation('com.crashlytics.sdk.android:crashlytics:2.9.4@aar') {
transitive = true transitive = true
} }
......
package chat.rocket.android.helper
import android.app.Activity
import android.content.Intent
import androidx.fragment.app.FragmentActivity
fun FragmentActivity.saveCredentials(id: String, password: String) {
}
fun Activity.requestStoredCredentials(): Pair<String, String>? = null
fun getCredentials(data: Intent): Pair<String, String>? = null
fun hasCredentialsSupport() = false
\ No newline at end of file
...@@ -4,6 +4,7 @@ import android.os.Bundle ...@@ -4,6 +4,7 @@ import android.os.Bundle
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import androidx.core.view.isVisible
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import chat.rocket.android.BuildConfig import chat.rocket.android.BuildConfig
import chat.rocket.android.R import chat.rocket.android.R
...@@ -31,6 +32,7 @@ class AboutFragment : Fragment() { ...@@ -31,6 +32,7 @@ class AboutFragment : Fragment() {
private fun setupViews() { private fun setupViews() {
text_version_name.text = getString(R.string.msg_version, BuildConfig.VERSION_NAME) text_version_name.text = getString(R.string.msg_version, BuildConfig.VERSION_NAME)
text_build_number.text = getString(R.string.msg_build, BuildConfig.VERSION_CODE) text_build_number.text = getString(R.string.msg_build, BuildConfig.VERSION_CODE)
text_foss.isVisible = BuildConfig.FLAVOR == "foss"
} }
private fun setupToolbar() { private fun setupToolbar() {
......
...@@ -2,7 +2,6 @@ package chat.rocket.android.authentication.login.presentation ...@@ -2,7 +2,6 @@ package chat.rocket.android.authentication.login.presentation
import chat.rocket.android.core.behaviours.LoadingView import chat.rocket.android.core.behaviours.LoadingView
import chat.rocket.android.core.behaviours.MessageView import chat.rocket.android.core.behaviours.MessageView
import com.google.android.gms.auth.api.credentials.Credential
interface LoginView : LoadingView, MessageView { interface LoginView : LoadingView, MessageView {
......
...@@ -30,11 +30,13 @@ import chat.rocket.android.webview.oauth.ui.INTENT_OAUTH_CREDENTIAL_SECRET ...@@ -30,11 +30,13 @@ 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.INTENT_OAUTH_CREDENTIAL_TOKEN
import chat.rocket.android.webview.oauth.ui.oauthWebViewIntent import chat.rocket.android.webview.oauth.ui.oauthWebViewIntent
import chat.rocket.common.util.ifNull import chat.rocket.common.util.ifNull
import com.google.android.gms.auth.api.credentials.*
import dagger.android.support.AndroidSupportInjection import dagger.android.support.AndroidSupportInjection
import kotlinx.android.synthetic.main.fragment_authentication_log_in.* import kotlinx.android.synthetic.main.fragment_authentication_log_in.*
import javax.inject.Inject import javax.inject.Inject
internal const val REQUEST_CODE_FOR_SIGN_IN_REQUIRED = 1
internal const val REQUEST_CODE_FOR_MULTIPLE_ACCOUNTS_RESOLUTION = 2
internal const val REQUEST_CODE_FOR_SAVE_RESOLUTION = 3
internal const val REQUEST_CODE_FOR_CAS = 4 internal const val REQUEST_CODE_FOR_CAS = 4
internal const val REQUEST_CODE_FOR_SAML = 5 internal const val REQUEST_CODE_FOR_SAML = 5
internal const val REQUEST_CODE_FOR_OAUTH = 6 internal const val REQUEST_CODE_FOR_OAUTH = 6
...@@ -48,7 +50,6 @@ class LoginFragment : Fragment(), LoginView { ...@@ -48,7 +50,6 @@ class LoginFragment : Fragment(), LoginView {
} }
private var isGlobalLayoutListenerSetUp = false private var isGlobalLayoutListenerSetUp = false
private var deepLinkInfo: LoginDeepLinkInfo? = null private var deepLinkInfo: LoginDeepLinkInfo? = null
private val credentialsClient by lazy { Credentials.getClient(requireActivity()) }
companion object { companion object {
private const val DEEP_LINK_INFO = "DeepLinkInfo" private const val DEEP_LINK_INFO = "DeepLinkInfo"
...@@ -85,6 +86,10 @@ class LoginFragment : Fragment(), LoginView { ...@@ -85,6 +86,10 @@ class LoginFragment : Fragment(), LoginView {
}.ifNull { }.ifNull {
presenter.setupView() presenter.setupView()
} }
if (!hasCredentialsSupport()) {
image_key.isVisible = false
}
} }
override fun onDestroyView() { override fun onDestroyView() {
...@@ -100,13 +105,15 @@ class LoginFragment : Fragment(), LoginView { ...@@ -100,13 +105,15 @@ class LoginFragment : Fragment(), LoginView {
if (data != null) { if (data != null) {
when (requestCode) { when (requestCode) {
REQUEST_CODE_FOR_MULTIPLE_ACCOUNTS_RESOLUTION -> { REQUEST_CODE_FOR_MULTIPLE_ACCOUNTS_RESOLUTION -> {
onCredentialRetrieved(data.getParcelableExtra(Credential.EXTRA_KEY)) getCredentials(data)?.let {
onCredentialRetrieved(it.first, it.second)
}
} }
REQUEST_CODE_FOR_SIGN_IN_REQUIRED -> { REQUEST_CODE_FOR_SIGN_IN_REQUIRED -> {
//use the hints to autofill sign in forms to reduce the info to be filled. getCredentials(data)?.let { credential ->
val credential: Credential = data.getParcelableExtra(Credential.EXTRA_KEY) text_username_or_email.setText(credential.first)
text_username_or_email.setText(credential.id) text_password.setText(credential.second)
text_password.setText(credential.password) }
} }
REQUEST_CODE_FOR_SAVE_RESOLUTION -> { REQUEST_CODE_FOR_SAVE_RESOLUTION -> {
showMessage(getString(R.string.message_credentials_saved_successfully)) showMessage(getString(R.string.message_credentials_saved_successfully))
...@@ -154,19 +161,19 @@ class LoginFragment : Fragment(), LoginView { ...@@ -154,19 +161,19 @@ class LoginFragment : Fragment(), LoginView {
private fun requestStoredCredentials() { private fun requestStoredCredentials() {
activity?.let { activity?.let {
SmartLockHelper.requestStoredCredentials(credentialsClient, it)?.let { it.requestStoredCredentials()?.let { credentials ->
onCredentialRetrieved(it) onCredentialRetrieved(credentials.first, credentials.second)
} }
} }
} }
private fun onCredentialRetrieved(credential: Credential) { private fun onCredentialRetrieved(id: String, password: String) {
presenter.authenticateWithUserAndPassword(credential.id, credential.password.toString()) presenter.authenticateWithUserAndPassword(id, password)
} }
override fun saveSmartLockCredentials(id: String, password: String) { override fun saveSmartLockCredentials(id: String, password: String) {
activity?.let { activity?.let {
SmartLockHelper.save(credentialsClient, it, id, password) it.saveCredentials(id, password)
} }
} }
......
...@@ -2,7 +2,6 @@ package chat.rocket.android.authentication.signup.presentation ...@@ -2,7 +2,6 @@ package chat.rocket.android.authentication.signup.presentation
import chat.rocket.android.core.behaviours.LoadingView import chat.rocket.android.core.behaviours.LoadingView
import chat.rocket.android.core.behaviours.MessageView import chat.rocket.android.core.behaviours.MessageView
import com.google.android.gms.auth.api.credentials.Credential
interface SignupView : LoadingView, MessageView { interface SignupView : LoadingView, MessageView {
......
...@@ -16,10 +16,9 @@ import chat.rocket.android.R.string.message_credentials_saved_successfully ...@@ -16,10 +16,9 @@ import chat.rocket.android.R.string.message_credentials_saved_successfully
import chat.rocket.android.authentication.signup.presentation.SignupPresenter import chat.rocket.android.authentication.signup.presentation.SignupPresenter
import chat.rocket.android.authentication.signup.presentation.SignupView import chat.rocket.android.authentication.signup.presentation.SignupView
import chat.rocket.android.helper.KeyboardHelper import chat.rocket.android.helper.KeyboardHelper
import chat.rocket.android.helper.SmartLockHelper
import chat.rocket.android.helper.TextHelper import chat.rocket.android.helper.TextHelper
import chat.rocket.android.helper.saveCredentials
import chat.rocket.android.util.extensions.* import chat.rocket.android.util.extensions.*
import com.google.android.gms.auth.api.credentials.Credentials
import dagger.android.support.AndroidSupportInjection import dagger.android.support.AndroidSupportInjection
import kotlinx.android.synthetic.main.fragment_authentication_sign_up.* import kotlinx.android.synthetic.main.fragment_authentication_sign_up.*
import javax.inject.Inject import javax.inject.Inject
...@@ -156,7 +155,7 @@ class SignupFragment : Fragment(), SignupView { ...@@ -156,7 +155,7 @@ class SignupFragment : Fragment(), SignupView {
override fun saveSmartLockCredentials(id: String, password: String) { override fun saveSmartLockCredentials(id: String, password: String) {
activity?.let { activity?.let {
SmartLockHelper.save(Credentials.getClient(it), it, id, password) it.saveCredentials(id, password)
} }
} }
......
...@@ -48,4 +48,16 @@ ...@@ -48,4 +48,16 @@
android:layout_marginTop="8dp" android:layout_marginTop="8dp"
android:textColor="@color/colorSecondaryText" /> android:textColor="@color/colorSecondaryText" />
<TextView
android:id="@+id/text_foss"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/foss"
android:visibility="gone"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/text_build_number"
android:layout_marginTop="8dp"
android:textColor="@color/colorSecondaryText" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
android:src="@drawable/ic_vpn_key_black_24dp" android:src="@drawable/ic_vpn_key_black_24dp"
android:tint="@color/colorDrawableTintGrey" android:tint="@color/colorDrawableTintGrey"
android:visibility="gone" android:visibility="gone"
tools:visibility="visible"
app:layout_constraintBottom_toBottomOf="@+id/text_username_or_email" app:layout_constraintBottom_toBottomOf="@+id/text_username_or_email"
app:layout_constraintEnd_toEndOf="@+id/text_username_or_email" app:layout_constraintEnd_toEndOf="@+id/text_username_or_email"
app:layout_constraintTop_toTopOf="@+id/text_username_or_email" /> app:layout_constraintTop_toTopOf="@+id/text_username_or_email" />
......
<resources> <resources xmlns:tools="http://schemas.android.com/tools">
<string name="app_name" translatable="false">Rocket.Chat</string> <string name="app_name" translatable="false">Rocket.Chat</string>
<!-- Titles --> <!-- Titles -->
...@@ -276,4 +276,6 @@ ...@@ -276,4 +276,6 @@
<string name="notif_success_sending">Message sent to %1$s!</string> <string name="notif_success_sending">Message sent to %1$s!</string>
<string name="read_by">Read by</string> <string name="read_by">Read by</string>
<string name="message_information_title">Message information</string> <string name="message_information_title">Message information</string>
<string name="foss" tools:ignore="MissingTranslation">(FOSS)</string>
</resources> </resources>
\ No newline at end of file
package chat.rocket.android.helper
import android.app.Activity
import android.content.Intent
import androidx.fragment.app.FragmentActivity
import com.google.android.gms.auth.api.credentials.Credential
import com.google.android.gms.auth.api.credentials.Credentials
fun FragmentActivity.saveCredentials(id: String, password: String) {
val credentialsClient = Credentials.getClient(this)
SmartLockHelper.save(credentialsClient, this, id, password)
}
fun Activity.requestStoredCredentials(): Pair<String, String>? {
val credentialsClient = Credentials.getClient(this)
return SmartLockHelper.requestStoredCredentials(credentialsClient, this)?.let {
null
}
}
fun getCredentials(data: Intent): Pair<String, String>? {
val credentials: Credential = data.getParcelableExtra(Credential.EXTRA_KEY)
return credentials?.let { cred ->
cred.password?.let {
Pair(cred.id, it)
}
}
}
fun hasCredentialsSupport() = true
\ No newline at end of file
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