Commit 7db24109 authored by aniket's avatar aniket

changes #2

parent 9ba67a56
...@@ -48,7 +48,7 @@ internal const val MULTIPLE_CREDENTIALS_READ = 3 ...@@ -48,7 +48,7 @@ internal const val MULTIPLE_CREDENTIALS_READ = 3
internal const val NO_CREDENTIALS_EXIST = 4 internal const val NO_CREDENTIALS_EXIST = 4
internal const val SAVE_CREDENTIALS = 5 internal const val SAVE_CREDENTIALS = 5
var googleApiClient: GoogleApiClient? = null lateinit var googleApiClient: GoogleApiClient
class LoginFragment : Fragment(), LoginView, GoogleApiClient.ConnectionCallbacks { class LoginFragment : Fragment(), LoginView, GoogleApiClient.ConnectionCallbacks {
@Inject @Inject
...@@ -131,19 +131,25 @@ class LoginFragment : Fragment(), LoginView, GoogleApiClient.ConnectionCallbacks ...@@ -131,19 +131,25 @@ class LoginFragment : Fragment(), LoginView, GoogleApiClient.ConnectionCallbacks
} }
} }
MULTIPLE_CREDENTIALS_READ -> { MULTIPLE_CREDENTIALS_READ -> {
val loginCredentials: Credential = data!!.getParcelableExtra(Credential.EXTRA_KEY) val loginCredentials: Credential =
data!!.getParcelableExtra(Credential.EXTRA_KEY)
handleCredential(loginCredentials) handleCredential(loginCredentials)
} }
NO_CREDENTIALS_EXIST -> { NO_CREDENTIALS_EXIST -> {
//use the hints to autofill sign in forms to reduce the info to be filled //use the hints to autofill sign in forms to reduce the info to be filled
val loginCredentials: Credential = data!!.getParcelableExtra(Credential.EXTRA_KEY) val loginCredentials: Credential =
data!!.getParcelableExtra(Credential.EXTRA_KEY)
val email = loginCredentials.id val email = loginCredentials.id
val password = loginCredentials.password val password = loginCredentials.password
text_username_or_email.setText(email) text_username_or_email.setText(email)
text_password.setText(password) text_password.setText(password)
} }
SAVE_CREDENTIALS -> Toast.makeText(context, "Credentials saved successfully", Toast.LENGTH_SHORT).show() SAVE_CREDENTIALS -> Toast.makeText(
context,
getString(R.string.message_credentials_saved_successfully),
Toast.LENGTH_SHORT
).show()
} }
} else if (requestCode == SAVE_CREDENTIALS) { } else if (requestCode == SAVE_CREDENTIALS) {
Timber.e("ERROR: Cancelled by user") Timber.e("ERROR: Cancelled by user")
...@@ -161,8 +167,10 @@ class LoginFragment : Fragment(), LoginView, GoogleApiClient.ConnectionCallbacks ...@@ -161,8 +167,10 @@ class LoginFragment : Fragment(), LoginView, GoogleApiClient.ConnectionCallbacks
override fun onDestroy() { override fun onDestroy() {
super.onDestroy() super.onDestroy()
googleApiClient!!.stopAutoManage(activity!!) googleApiClient.let {
googleApiClient!!.disconnect() it.stopAutoManage(activity!!)
it.disconnect()
}
} }
private fun buildGoogleApiClient() { private fun buildGoogleApiClient() {
......
...@@ -6,12 +6,7 @@ import chat.rocket.android.infrastructure.LocalRepository ...@@ -6,12 +6,7 @@ import chat.rocket.android.infrastructure.LocalRepository
import chat.rocket.android.server.domain.* import chat.rocket.android.server.domain.*
import chat.rocket.android.server.domain.model.Account import chat.rocket.android.server.domain.model.Account
import chat.rocket.android.server.infraestructure.RocketChatClientFactory import chat.rocket.android.server.infraestructure.RocketChatClientFactory
import chat.rocket.android.util.extensions.avatarUrl import chat.rocket.android.util.extensions.*
import chat.rocket.android.util.extensions.launchUI
import chat.rocket.android.util.extensions.privacyPolicyUrl
import chat.rocket.android.util.extensions.registerPushToken
import chat.rocket.android.util.extensions.serverLogoUrl
import chat.rocket.android.util.extensions.termsOfServiceUrl
import chat.rocket.android.util.retryIO import chat.rocket.android.util.retryIO
import chat.rocket.common.RocketChatException import chat.rocket.common.RocketChatException
import chat.rocket.common.util.ifNull import chat.rocket.common.util.ifNull
......
...@@ -122,15 +122,21 @@ class SignupFragment : Fragment(), SignupView { ...@@ -122,15 +122,21 @@ class SignupFragment : Fragment(), SignupView {
override fun saveSmartLockCredentials(loginCredential: Credential) { override fun saveSmartLockCredentials(loginCredential: Credential) {
credentialsToBeSaved = loginCredential credentialsToBeSaved = loginCredential
if (googleApiClient!!.isConnected) { googleApiClient.let {
saveCredentials() if (it.isConnected) {
saveCredentials()
}
} }
} }
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
if (requestCode == SAVE_CREDENTIALS) { if (requestCode == SAVE_CREDENTIALS) {
if (resultCode == RESULT_OK) { if (resultCode == RESULT_OK) {
Toast.makeText(context, "Credentials saved successfully", Toast.LENGTH_SHORT).show() Toast.makeText(
context,
getString(R.string.message_credentials_saved_successfully),
Toast.LENGTH_SHORT
).show()
} else { } else {
Timber.e("ERROR: Cancelled by user") Timber.e("ERROR: Cancelled by user")
} }
...@@ -145,7 +151,7 @@ class SignupFragment : Fragment(), SignupView { ...@@ -145,7 +151,7 @@ class SignupFragment : Fragment(), SignupView {
} }
override fun onUnresolvableFailure(status: Status) { override fun onUnresolvableFailure(status: Status) {
Timber.w("save:FAILURE:$status") Timber.e("save:FAILURE:$status")
} }
}) })
} }
......
package chat.rocket.android.main.ui package chat.rocket.android.main.ui
import DrawableHelper
import android.app.Activity import android.app.Activity
import android.app.AlertDialog import android.app.AlertDialog
import android.os.Bundle import android.os.Bundle
...@@ -11,8 +12,8 @@ import android.view.MenuItem ...@@ -11,8 +12,8 @@ import android.view.MenuItem
import android.view.View import android.view.View
import chat.rocket.android.BuildConfig import chat.rocket.android.BuildConfig
import chat.rocket.android.R import chat.rocket.android.R
import chat.rocket.android.main.adapter.Selector
import chat.rocket.android.main.adapter.AccountsAdapter import chat.rocket.android.main.adapter.AccountsAdapter
import chat.rocket.android.main.adapter.Selector
import chat.rocket.android.main.presentation.MainPresenter import chat.rocket.android.main.presentation.MainPresenter
import chat.rocket.android.main.presentation.MainView import chat.rocket.android.main.presentation.MainView
import chat.rocket.android.main.viewmodel.NavHeaderViewModel import chat.rocket.android.main.viewmodel.NavHeaderViewModel
......
...@@ -80,7 +80,8 @@ class OauthWebViewActivity : AppCompatActivity() { ...@@ -80,7 +80,8 @@ class OauthWebViewActivity : AppCompatActivity() {
domStorageEnabled = true domStorageEnabled = true
// TODO Remove this workaround that is required to make Google OAuth to work. We should use Custom Tabs instead. See https://github.com/RocketChat/Rocket.Chat.Android/issues/968 // TODO Remove this workaround that is required to make Google OAuth to work. We should use Custom Tabs instead. See https://github.com/RocketChat/Rocket.Chat.Android/issues/968
if (webPageUrl.contains("google")) { if (webPageUrl.contains("google")) {
userAgentString = "Mozilla/5.0 (Linux; Android 4.1.1; Galaxy Nexus Build/JRO03C) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/43.0.2357.65 Mobile Safari/535.19" userAgentString =
"Mozilla/5.0 (Linux; Android 4.1.1; Galaxy Nexus Build/JRO03C) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/43.0.2357.65 Mobile Safari/535.19"
} }
} }
web_view.webViewClient = object : WebViewClient() { web_view.webViewClient = object : WebViewClient() {
...@@ -113,8 +114,18 @@ class OauthWebViewActivity : AppCompatActivity() { ...@@ -113,8 +114,18 @@ class OauthWebViewActivity : AppCompatActivity() {
private fun getCredentialSecret(json: JSONObject): String = private fun getCredentialSecret(json: JSONObject): String =
json.optString(JSON_CREDENTIAL_SECRET) json.optString(JSON_CREDENTIAL_SECRET)
private fun closeView(activityResult: Int = Activity.RESULT_CANCELED, credentialToken: String? = null, credentialSecret: String? = null) { private fun closeView(
setResult(activityResult, Intent().putExtra(INTENT_OAUTH_CREDENTIAL_TOKEN, credentialToken).putExtra(INTENT_OAUTH_CREDENTIAL_SECRET, credentialSecret)) activityResult: Int = Activity.RESULT_CANCELED,
credentialToken: String? = null,
credentialSecret: String? = null
) {
setResult(
activityResult,
Intent().putExtra(INTENT_OAUTH_CREDENTIAL_TOKEN, credentialToken).putExtra(
INTENT_OAUTH_CREDENTIAL_SECRET,
credentialSecret
)
)
finish() finish()
overridePendingTransition(R.anim.hold, R.anim.slide_down) overridePendingTransition(R.anim.hold, R.anim.slide_down)
} }
......
...@@ -134,6 +134,9 @@ ...@@ -134,6 +134,9 @@
<string name="message_unmuted">Usuario %1$s no silenciado por %2$s</string> <string name="message_unmuted">Usuario %1$s no silenciado por %2$s</string>
<string name="message_role_add">%1$s fue establecido %2$s por %3$s</string> <string name="message_role_add">%1$s fue establecido %2$s por %3$s</string>
<string name="message_role_removed">%1$s ya no es %2$s por %3$s</string> <string name="message_role_removed">%1$s ya no es %2$s por %3$s</string>
// TODO:Add proper translation.
<string name="message_credentials_saved_successfully">Credentials saved successfully</string>
<!-- Message actions --> <!-- Message actions -->
<string name="action_msg_reply">Respuesta</string> <string name="action_msg_reply">Respuesta</string>
......
...@@ -134,6 +134,9 @@ ...@@ -134,6 +134,9 @@
<string name="message_unmuted">Utilisateur %1$s non muté par %2$s</string> <string name="message_unmuted">Utilisateur %1$s non muté par %2$s</string>
<string name="message_role_add">%1$s a été défini %2$s par %3$s</string> <string name="message_role_add">%1$s a été défini %2$s par %3$s</string>
<string name="message_role_removed">%1$s is no longer %2$s par %3$s</string> <string name="message_role_removed">%1$s is no longer %2$s par %3$s</string>
// TODO:Add proper translation.
<string name="message_credentials_saved_successfully">Credentials saved successfully</string>
<!-- Message actions --> <!-- Message actions -->
<string name="action_msg_reply">Répondre</string> <string name="action_msg_reply">Répondre</string>
......
...@@ -136,6 +136,9 @@ ...@@ -136,6 +136,9 @@
<string name="message_unmuted">उपयोगकर्ता %1$s %2$s द्वारा अनम्यूट किया गया</string> <string name="message_unmuted">उपयोगकर्ता %1$s %2$s द्वारा अनम्यूट किया गया</string>
<string name="message_role_add">%1$s %3$s द्वारा %2$s सेट किया गया था</string> <string name="message_role_add">%1$s %3$s द्वारा %2$s सेट किया गया था</string>
<string name="message_role_removed">%1$s अब %3$s द्वारा %2$s नहीं है</string> <string name="message_role_removed">%1$s अब %3$s द्वारा %2$s नहीं है</string>
// TODO:Add proper translation.
<string name="message_credentials_saved_successfully">Credentials saved successfully</string>
<!-- Message actions --> <!-- Message actions -->
<string name="action_msg_reply">जवाब दें</string> <string name="action_msg_reply">जवाब दें</string>
......
...@@ -126,6 +126,9 @@ ...@@ -126,6 +126,9 @@
<string name="message_unmuted">Usuário %1$s saiu do modo mudo por %2$s</string> <string name="message_unmuted">Usuário %1$s saiu do modo mudo por %2$s</string>
<string name="message_role_add">%1$s foi definido %2$s por %3$s</string> <string name="message_role_add">%1$s foi definido %2$s por %3$s</string>
<string name="message_role_removed">%1$s não é mais %2$s por %3$s</string> <string name="message_role_removed">%1$s não é mais %2$s por %3$s</string>
// TODO:Add proper translation.
<string name="message_credentials_saved_successfully">Credentials saved successfully</string>
<!-- Message actions --> <!-- Message actions -->
<string name="action_msg_reply">Responder</string> <string name="action_msg_reply">Responder</string>
......
...@@ -108,6 +108,14 @@ ...@@ -108,6 +108,14 @@
<string name="msg_image_saved_successfully">Image has been saved to gallery</string> <string name="msg_image_saved_successfully">Image has been saved to gallery</string>
<string name="msg_image_saved_failed">Failed to save image</string> <string name="msg_image_saved_failed">Failed to save image</string>
<string name="msg_edited">(edited)</string> <string name="msg_edited">(edited)</string>
// TODO: Add proper translation.
<string name="msg_and">\u0020and\u0020</string>
// TODO: Add proper translation.
<string name="msg_is_typing">\u0020is typing…</string>
// TODO: Add proper translation.
<string name="msg_are_typing">\u0020are typing…</string>
// TODO: Add proper translation.
<string name="msg_several_users_are_typing">Several users are typing…</string>
<string name="msg_no_search_found">No result found</string> <string name="msg_no_search_found">No result found</string>
<!-- System messages --> <!-- System messages -->
...@@ -121,6 +129,13 @@ ...@@ -121,6 +129,13 @@
<string name="message_pinned">Pinned a message:</string> <string name="message_pinned">Pinned a message:</string>
<string name="message_muted">User %1$s muted by %2$s</string> <string name="message_muted">User %1$s muted by %2$s</string>
<string name="message_unmuted">User %1$s unmuted by %2$s</string> <string name="message_unmuted">User %1$s unmuted by %2$s</string>
// TODO: Add proper translation.
<string name="message_role_add">%1$s was set %2$s by %3$s</string>
// TODO: Add proper translation.
<string name="message_role_removed">%1$s is no longer %2$s by %3$s</string>
// TODO: Add proper translation.
<string name="message_credentials_saved_successfully">Credentials saved successfully</string>
<!-- Message actions --> <!-- Message actions -->
<string name="action_msg_reply">Reply</string> <string name="action_msg_reply">Reply</string>
......
...@@ -127,6 +127,7 @@ ...@@ -127,6 +127,7 @@
<string name="message_unmuted">User %1$s unmuted by %2$s</string> <string name="message_unmuted">User %1$s unmuted by %2$s</string>
<string name="message_role_add">%1$s was set %2$s by %3$s</string> <string name="message_role_add">%1$s was set %2$s by %3$s</string>
<string name="message_role_removed">%1$s is no longer %2$s by %3$s</string> <string name="message_role_removed">%1$s is no longer %2$s by %3$s</string>
<string name="message_credentials_saved_successfully">Credentials saved successfully</string>
<!-- Message actions --> <!-- Message actions -->
<string name="action_msg_reply">Reply</string> <string name="action_msg_reply">Reply</string>
......
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