Commit 9ba67a56 authored by aniket's avatar aniket

set of changes #1

parent f4c434e2
...@@ -151,13 +151,20 @@ class LoginPresenter @Inject constructor( ...@@ -151,13 +151,20 @@ class LoginPresenter @Inject constructor(
client.settingsOauth().services client.settingsOauth().services
} }
if (services.isNotEmpty()) { if (services.isNotEmpty()) {
val state = "{\"loginStyle\":\"popup\",\"credentialToken\":\"${generateRandomString(40)}\",\"isCordova\":true}".encodeToBase64() val state =
"{\"loginStyle\":\"popup\",\"credentialToken\":\"${generateRandomString(40)}\",\"isCordova\":true}".encodeToBase64()
var totalSocialAccountsEnabled = 0 var totalSocialAccountsEnabled = 0
if (settings.isFacebookAuthenticationEnabled()) { if (settings.isFacebookAuthenticationEnabled()) {
val clientId = getOauthClientId(services, SERVICE_NAME_FACEBOOK) val clientId = getOauthClientId(services, SERVICE_NAME_FACEBOOK)
if (clientId != null) { if (clientId != null) {
view.setupFacebookButtonListener(OauthHelper.getFacebookOauthUrl(clientId, currentServer, state), state) view.setupFacebookButtonListener(
OauthHelper.getFacebookOauthUrl(
clientId,
currentServer,
state
), state
)
view.enableLoginByFacebook() view.enableLoginByFacebook()
totalSocialAccountsEnabled++ totalSocialAccountsEnabled++
} }
...@@ -165,7 +172,12 @@ class LoginPresenter @Inject constructor( ...@@ -165,7 +172,12 @@ class LoginPresenter @Inject constructor(
if (settings.isGithubAuthenticationEnabled()) { if (settings.isGithubAuthenticationEnabled()) {
val clientId = getOauthClientId(services, SERVICE_NAME_GITHUB) val clientId = getOauthClientId(services, SERVICE_NAME_GITHUB)
if (clientId != null) { if (clientId != null) {
view.setupGithubButtonListener(OauthHelper.getGithubOauthUrl(clientId, state), state) view.setupGithubButtonListener(
OauthHelper.getGithubOauthUrl(
clientId,
state
), state
)
view.enableLoginByGithub() view.enableLoginByGithub()
totalSocialAccountsEnabled++ totalSocialAccountsEnabled++
} }
...@@ -173,7 +185,13 @@ class LoginPresenter @Inject constructor( ...@@ -173,7 +185,13 @@ class LoginPresenter @Inject constructor(
if (settings.isGoogleAuthenticationEnabled()) { if (settings.isGoogleAuthenticationEnabled()) {
val clientId = getOauthClientId(services, SERVICE_NAME_GOOGLE) val clientId = getOauthClientId(services, SERVICE_NAME_GOOGLE)
if (clientId != null) { if (clientId != null) {
view.setupGoogleButtonListener(OauthHelper.getGoogleOauthUrl(clientId, currentServer, state), state) view.setupGoogleButtonListener(
OauthHelper.getGoogleOauthUrl(
clientId,
currentServer,
state
), state
)
view.enableLoginByGoogle() view.enableLoginByGoogle()
totalSocialAccountsEnabled++ totalSocialAccountsEnabled++
} }
...@@ -181,7 +199,13 @@ class LoginPresenter @Inject constructor( ...@@ -181,7 +199,13 @@ class LoginPresenter @Inject constructor(
if (settings.isLinkedinAuthenticationEnabled()) { if (settings.isLinkedinAuthenticationEnabled()) {
val clientId = getOauthClientId(services, SERVICE_NAME_LINKEDIN) val clientId = getOauthClientId(services, SERVICE_NAME_LINKEDIN)
if (clientId != null) { if (clientId != null) {
view.setupLinkedinButtonListener(OauthHelper.getLinkedinOauthUrl(clientId, currentServer, state), state) view.setupLinkedinButtonListener(
OauthHelper.getLinkedinOauthUrl(
clientId,
currentServer,
state
), state
)
view.enableLoginByLinkedin() view.enableLoginByLinkedin()
totalSocialAccountsEnabled++ totalSocialAccountsEnabled++
} }
...@@ -307,8 +331,8 @@ class LoginPresenter @Inject constructor( ...@@ -307,8 +331,8 @@ class LoginPresenter @Inject constructor(
registerPushToken() registerPushToken()
if (loginType == TYPE_LOGIN_USER_EMAIL) { if (loginType == TYPE_LOGIN_USER_EMAIL) {
loginCredentials = Credential.Builder(usernameOrEmail) loginCredentials = Credential.Builder(usernameOrEmail)
.setPassword(password) .setPassword(password)
.build() .build()
view.saveSmartLockCredentials(loginCredentials) view.saveSmartLockCredentials(loginCredentials)
} }
navigator.toChatList() navigator.toChatList()
...@@ -341,7 +365,7 @@ class LoginPresenter @Inject constructor( ...@@ -341,7 +365,7 @@ class LoginPresenter @Inject constructor(
}.toString() }.toString()
} }
private fun getCustomOauthServices(listMap: List<Map<String, Any>>): List<Map<String, Any>> { private fun getCustomOauthServices(listMap: List<Map<String, Any>>): List<Map<String, Any>> {
return listMap.filter { map -> map["custom"] == true } return listMap.filter { map -> map["custom"] == true }
} }
......
...@@ -10,7 +10,6 @@ import android.os.Build ...@@ -10,7 +10,6 @@ import android.os.Build
import android.os.Bundle import android.os.Bundle
import android.support.v4.app.Fragment import android.support.v4.app.Fragment
import android.text.style.ClickableSpan import android.text.style.ClickableSpan
import android.util.Log
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
...@@ -39,6 +38,7 @@ import com.google.android.gms.common.api.ResolvingResultCallbacks ...@@ -39,6 +38,7 @@ import com.google.android.gms.common.api.ResolvingResultCallbacks
import com.google.android.gms.common.api.Status import com.google.android.gms.common.api.Status
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 timber.log.Timber
import javax.inject.Inject import javax.inject.Inject
...@@ -72,12 +72,11 @@ class LoginFragment : Fragment(), LoginView, GoogleApiClient.ConnectionCallbacks ...@@ -72,12 +72,11 @@ class LoginFragment : Fragment(), LoginView, GoogleApiClient.ConnectionCallbacks
} }
} }
override fun onConnected(p0: Bundle?) { override fun onConnected(bundle: Bundle?) {
saveSmartLockCredentials(credentialsToBeSaved) saveSmartLockCredentials(credentialsToBeSaved)
} }
override fun onConnectionSuspended(p0: Int) { override fun onConnectionSuspended(errorCode: Int) {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
} }
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
...@@ -88,11 +87,11 @@ class LoginFragment : Fragment(), LoginView, GoogleApiClient.ConnectionCallbacks ...@@ -88,11 +87,11 @@ class LoginFragment : Fragment(), LoginView, GoogleApiClient.ConnectionCallbacks
} }
override fun onCreateView( override fun onCreateView(
inflater: LayoutInflater, inflater: LayoutInflater,
container: ViewGroup?, container: ViewGroup?,
savedInstanceState: Bundle? savedInstanceState: Bundle?
): View? = ): View? =
container?.inflate(R.layout.fragment_authentication_log_in) container?.inflate(R.layout.fragment_authentication_log_in)
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
...@@ -118,40 +117,42 @@ class LoginFragment : Fragment(), LoginView, GoogleApiClient.ConnectionCallbacks ...@@ -118,40 +117,42 @@ class LoginFragment : Fragment(), LoginView, GoogleApiClient.ConnectionCallbacks
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
if (resultCode == Activity.RESULT_OK) { if (resultCode == Activity.RESULT_OK) {
if (requestCode == REQUEST_CODE_FOR_CAS) { when (requestCode) {
data?.apply { REQUEST_CODE_FOR_CAS -> data?.apply {
presenter.authenticateWithCas(getStringExtra(INTENT_CAS_TOKEN)) presenter.authenticateWithCas(getStringExtra(INTENT_CAS_TOKEN))
} }
} else if (requestCode == REQUEST_CODE_FOR_OAUTH) { REQUEST_CODE_FOR_OAUTH -> {
isOauthSuccessful = true isOauthSuccessful = true
data?.apply { data?.apply {
presenter.authenticateWithOauth( presenter.authenticateWithOauth(
getStringExtra(INTENT_OAUTH_CREDENTIAL_TOKEN), getStringExtra(INTENT_OAUTH_CREDENTIAL_TOKEN),
getStringExtra(INTENT_OAUTH_CREDENTIAL_SECRET) getStringExtra(INTENT_OAUTH_CREDENTIAL_SECRET)
) )
}
}
MULTIPLE_CREDENTIALS_READ -> {
val loginCredentials: Credential = data!!.getParcelableExtra(Credential.EXTRA_KEY)
handleCredential(loginCredentials)
}
NO_CREDENTIALS_EXIST -> {
//use the hints to autofill sign in forms to reduce the info to be filled
val loginCredentials: Credential = data!!.getParcelableExtra(Credential.EXTRA_KEY)
val email = loginCredentials.id
val password = loginCredentials.password
text_username_or_email.setText(email)
text_password.setText(password)
} }
} else if (requestCode == MULTIPLE_CREDENTIALS_READ) { SAVE_CREDENTIALS -> Toast.makeText(context, "Credentials saved successfully", Toast.LENGTH_SHORT).show()
var loginCredentials: Credential = data!!.getParcelableExtra(Credential.EXTRA_KEY)
handleCredential(loginCredentials)
} else if (requestCode == NO_CREDENTIALS_EXIST) {
//use the hints to autofill sign in forms to reduce the info to be filled
var loginCredentials: Credential = data!!.getParcelableExtra(Credential.EXTRA_KEY)
var email = loginCredentials.id
var password = loginCredentials.password
text_username_or_email.setText(email)
text_password.setText(password)
} else if (requestCode == SAVE_CREDENTIALS) {
Toast.makeText(context, "Credentials saved successfully", Toast.LENGTH_SHORT).show()
} }
} else if (requestCode == SAVE_CREDENTIALS) { } else if (requestCode == SAVE_CREDENTIALS) {
Log.e("STATUS", "ERROR: Cancelled by user") Timber.e("ERROR: Cancelled by user")
} else if (requestCode == MULTIPLE_CREDENTIALS_READ) { } else if (requestCode == MULTIPLE_CREDENTIALS_READ) {
Log.d("STATUS", "failed ") Timber.e("ERROR: Failed reading credentials")
} }
//cancel button pressed by the user in case of reading from smart lock //cancel button pressed by the user in case of reading from smart lock
else if (resultCode == Activity.RESULT_CANCELED && requestCode == REQUEST_CODE_FOR_OAUTH) { else if (resultCode == Activity.RESULT_CANCELED && requestCode == REQUEST_CODE_FOR_OAUTH) {
Log.d("returned", "from oauth") Timber.d("Returned from oauth")
} }
//no hints for user id's exist //no hints for user id's exist
else if (resultCode == CredentialsApi.ACTIVITY_RESULT_NO_HINTS_AVAILABLE) { else if (resultCode == CredentialsApi.ACTIVITY_RESULT_NO_HINTS_AVAILABLE) {
...@@ -166,12 +167,12 @@ class LoginFragment : Fragment(), LoginView, GoogleApiClient.ConnectionCallbacks ...@@ -166,12 +167,12 @@ class LoginFragment : Fragment(), LoginView, GoogleApiClient.ConnectionCallbacks
private fun buildGoogleApiClient() { private fun buildGoogleApiClient() {
googleApiClient = GoogleApiClient.Builder(context!!) googleApiClient = GoogleApiClient.Builder(context!!)
.enableAutoManage(activity!!, { .enableAutoManage(activity!!, {
Log.d("STATUS", "ERROR: connection to client failed") Timber.e("ERROR: Connection to client failed")
}) })
.addConnectionCallbacks(this) .addConnectionCallbacks(this)
.addApi(Auth.CREDENTIALS_API) .addApi(Auth.CREDENTIALS_API)
.build() .build()
} }
override fun onStart() { override fun onStart() {
...@@ -182,42 +183,57 @@ class LoginFragment : Fragment(), LoginView, GoogleApiClient.ConnectionCallbacks ...@@ -182,42 +183,57 @@ class LoginFragment : Fragment(), LoginView, GoogleApiClient.ConnectionCallbacks
} }
private fun requestCredentials() { private fun requestCredentials() {
var request: CredentialRequest = CredentialRequest.Builder() val request: CredentialRequest = CredentialRequest.Builder()
.setPasswordLoginSupported(true) .setPasswordLoginSupported(true)
.build() .build()
Auth.CredentialsApi.request(googleApiClient, request).setResultCallback { credentialRequestResult -> Auth.CredentialsApi.request(googleApiClient, request)
val status = credentialRequestResult.status .setResultCallback { credentialRequestResult ->
if (status.isSuccess) { val status = credentialRequestResult.status
// Auto sign-in success if (status.isSuccess) {
handleCredential(credentialRequestResult.credential) // Auto sign-in success
} else if (status.statusCode == CommonStatusCodes.RESOLUTION_REQUIRED) { handleCredential(credentialRequestResult.credential)
resolveResult(status, MULTIPLE_CREDENTIALS_READ) } else if (status.statusCode == CommonStatusCodes.RESOLUTION_REQUIRED) {
} else if (status.statusCode == CommonStatusCodes.SIGN_IN_REQUIRED) { resolveResult(status, MULTIPLE_CREDENTIALS_READ)
} else if (status.statusCode == CommonStatusCodes.SIGN_IN_REQUIRED) {
//build a dialog for possible account hints
var hintRequest: HintRequest = HintRequest.Builder() //build a dialog for possible account hints
.setHintPickerConfig(CredentialPickerConfig.Builder() val hintRequest: HintRequest = HintRequest.Builder()
.setHintPickerConfig(
CredentialPickerConfig.Builder()
.setShowCancelButton(true) .setShowCancelButton(true)
.build()) .build()
)
.setEmailAddressIdentifierSupported(true) .setEmailAddressIdentifierSupported(true)
.setAccountTypes(IdentityProviders.GOOGLE) .setAccountTypes(IdentityProviders.GOOGLE)
.build() .build()
var intent: PendingIntent = Auth.CredentialsApi.getHintPickerIntent(googleApiClient, hintRequest) val intent: PendingIntent =
try { Auth.CredentialsApi.getHintPickerIntent(googleApiClient, hintRequest)
startIntentSenderForResult(intent.intentSender, NO_CREDENTIALS_EXIST, null, 0, 0, 0, null) try {
} catch (e: IntentSender.SendIntentException) { startIntentSenderForResult(
Log.e("STATUS", "ERROR: Could not start hint picker Intent", e); intent.intentSender,
NO_CREDENTIALS_EXIST,
null,
0,
0,
0,
null
)
} catch (e: IntentSender.SendIntentException) {
Timber.e("STATUS", "ERROR: Could not start hint picker Intent", e);
}
} else {
Timber.d("STATUS", "ERROR: nothing happening")
} }
} else {
Log.d("STATUS", "ERROR: nothing happening")
} }
}
} }
private fun handleCredential(loginCredentials: Credential) { private fun handleCredential(loginCredentials: Credential) {
if (loginCredentials.accountType == null) { if (loginCredentials.accountType == null) {
presenter.authenticateWithUserAndPassword(loginCredentials.id, loginCredentials.password!!) presenter.authenticateWithUserAndPassword(
loginCredentials.id,
loginCredentials.password!!
)
} }
} }
...@@ -225,7 +241,7 @@ class LoginFragment : Fragment(), LoginView, GoogleApiClient.ConnectionCallbacks ...@@ -225,7 +241,7 @@ class LoginFragment : Fragment(), LoginView, GoogleApiClient.ConnectionCallbacks
try { try {
status.startResolutionForResult(activity, requestCode) status.startResolutionForResult(activity, requestCode)
} catch (e: IntentSender.SendIntentException) { } catch (e: IntentSender.SendIntentException) {
Log.e("STATUS", "Failed to send Credentials intent.", e) Timber.e("STATUS", "Failed to send Credentials intent.", e)
} }
} }
...@@ -236,31 +252,31 @@ class LoginFragment : Fragment(), LoginView, GoogleApiClient.ConnectionCallbacks ...@@ -236,31 +252,31 @@ class LoginFragment : Fragment(), LoginView, GoogleApiClient.ConnectionCallbacks
} }
Auth.CredentialsApi.save(googleApiClient, credentialsToBeSaved).setResultCallback( Auth.CredentialsApi.save(googleApiClient, credentialsToBeSaved).setResultCallback(
object : ResolvingResultCallbacks<Status>(activity!!, SAVE_CREDENTIALS) { object : ResolvingResultCallbacks<Status>(activity!!, SAVE_CREDENTIALS) {
override fun onSuccess(status: Status) { override fun onSuccess(status: Status) {
Log.d("STATUS", "save:SUCCESS:$status") Timber.d("STATUS", "save:SUCCESS:$status")
credentialsToBeSaved = null credentialsToBeSaved = null
} }
override fun onUnresolvableFailure(status: Status) { override fun onUnresolvableFailure(status: Status) {
Log.w("STATUS", "save:FAILURE:$status") Timber.w("STATUS", "save:FAILURE:$status")
credentialsToBeSaved = null credentialsToBeSaved = null
} }
}) })
} }
private fun tintEditTextDrawableStart() { private fun tintEditTextDrawableStart() {
ui { ui {
val personDrawable = val personDrawable =
DrawableHelper.getDrawableFromId(R.drawable.ic_assignment_ind_black_24dp, it) DrawableHelper.getDrawableFromId(R.drawable.ic_assignment_ind_black_24dp, it)
val lockDrawable = DrawableHelper.getDrawableFromId(R.drawable.ic_lock_black_24dp, it) val lockDrawable = DrawableHelper.getDrawableFromId(R.drawable.ic_lock_black_24dp, it)
val drawables = arrayOf(personDrawable, lockDrawable) val drawables = arrayOf(personDrawable, lockDrawable)
DrawableHelper.wrapDrawables(drawables) DrawableHelper.wrapDrawables(drawables)
DrawableHelper.tintDrawables(drawables, it, R.color.colorDrawableTintGrey) DrawableHelper.tintDrawables(drawables, it, R.color.colorDrawableTintGrey)
DrawableHelper.compoundDrawables( DrawableHelper.compoundDrawables(
arrayOf(text_username_or_email, text_password), arrayOf(text_username_or_email, text_password),
drawables drawables
) )
} }
} }
...@@ -311,8 +327,8 @@ class LoginFragment : Fragment(), LoginView, GoogleApiClient.ConnectionCallbacks ...@@ -311,8 +327,8 @@ class LoginFragment : Fragment(), LoginView, GoogleApiClient.ConnectionCallbacks
ui { ui {
button_log_in.setOnClickListener { button_log_in.setOnClickListener {
presenter.authenticateWithUserAndPassword( presenter.authenticateWithUserAndPassword(
text_username_or_email.textContent, text_username_or_email.textContent,
text_password.textContent text_password.textContent
) )
} }
} }
...@@ -350,8 +366,8 @@ class LoginFragment : Fragment(), LoginView, GoogleApiClient.ConnectionCallbacks ...@@ -350,8 +366,8 @@ class LoginFragment : Fragment(), LoginView, GoogleApiClient.ConnectionCallbacks
ui { activity -> ui { activity ->
button_cas.setOnClickListener { button_cas.setOnClickListener {
startActivityForResult( startActivityForResult(
activity.casWebViewIntent(casUrl, casToken), activity.casWebViewIntent(casUrl, casToken),
REQUEST_CODE_FOR_CAS REQUEST_CODE_FOR_CAS
) )
activity.overridePendingTransition(R.anim.slide_up, R.anim.hold) activity.overridePendingTransition(R.anim.slide_up, R.anim.hold)
} }
...@@ -443,8 +459,8 @@ class LoginFragment : Fragment(), LoginView, GoogleApiClient.ConnectionCallbacks ...@@ -443,8 +459,8 @@ class LoginFragment : Fragment(), LoginView, GoogleApiClient.ConnectionCallbacks
ui { activity -> ui { activity ->
button_facebook.setOnClickListener { button_facebook.setOnClickListener {
startActivityForResult( startActivityForResult(
activity.oauthWebViewIntent(facebookOauthUrl, state), activity.oauthWebViewIntent(facebookOauthUrl, state),
REQUEST_CODE_FOR_OAUTH REQUEST_CODE_FOR_OAUTH
) )
activity.overridePendingTransition(R.anim.slide_up, R.anim.hold) activity.overridePendingTransition(R.anim.slide_up, R.anim.hold)
} }
...@@ -461,8 +477,8 @@ class LoginFragment : Fragment(), LoginView, GoogleApiClient.ConnectionCallbacks ...@@ -461,8 +477,8 @@ class LoginFragment : Fragment(), LoginView, GoogleApiClient.ConnectionCallbacks
ui { activity -> ui { activity ->
button_github.setOnClickListener { button_github.setOnClickListener {
startActivityForResult( startActivityForResult(
activity.oauthWebViewIntent(githubUrl, state), activity.oauthWebViewIntent(githubUrl, state),
REQUEST_CODE_FOR_OAUTH REQUEST_CODE_FOR_OAUTH
) )
activity.overridePendingTransition(R.anim.slide_up, R.anim.hold) activity.overridePendingTransition(R.anim.slide_up, R.anim.hold)
} }
...@@ -481,8 +497,8 @@ class LoginFragment : Fragment(), LoginView, GoogleApiClient.ConnectionCallbacks ...@@ -481,8 +497,8 @@ class LoginFragment : Fragment(), LoginView, GoogleApiClient.ConnectionCallbacks
ui { activity -> ui { activity ->
button_google.setOnClickListener { button_google.setOnClickListener {
startActivityForResult( startActivityForResult(
activity.oauthWebViewIntent(googleUrl, state), activity.oauthWebViewIntent(googleUrl, state),
REQUEST_CODE_FOR_OAUTH REQUEST_CODE_FOR_OAUTH
) )
activity.overridePendingTransition(R.anim.slide_up, R.anim.hold) activity.overridePendingTransition(R.anim.slide_up, R.anim.hold)
} }
...@@ -499,8 +515,8 @@ class LoginFragment : Fragment(), LoginView, GoogleApiClient.ConnectionCallbacks ...@@ -499,8 +515,8 @@ class LoginFragment : Fragment(), LoginView, GoogleApiClient.ConnectionCallbacks
ui { activity -> ui { activity ->
button_linkedin.setOnClickListener { button_linkedin.setOnClickListener {
startActivityForResult( startActivityForResult(
activity.oauthWebViewIntent(linkedinUrl, state), activity.oauthWebViewIntent(linkedinUrl, state),
REQUEST_CODE_FOR_OAUTH REQUEST_CODE_FOR_OAUTH
) )
activity.overridePendingTransition(R.anim.slide_up, R.anim.hold) activity.overridePendingTransition(R.anim.slide_up, R.anim.hold)
} }
...@@ -529,8 +545,8 @@ class LoginFragment : Fragment(), LoginView, GoogleApiClient.ConnectionCallbacks ...@@ -529,8 +545,8 @@ class LoginFragment : Fragment(), LoginView, GoogleApiClient.ConnectionCallbacks
ui { activity -> ui { activity ->
button_gitlab.setOnClickListener { button_gitlab.setOnClickListener {
startActivityForResult( startActivityForResult(
activity.oauthWebViewIntent(gitlabUrl, state), activity.oauthWebViewIntent(gitlabUrl, state),
REQUEST_CODE_FOR_OAUTH REQUEST_CODE_FOR_OAUTH
) )
activity.overridePendingTransition(R.anim.slide_up, R.anim.hold) activity.overridePendingTransition(R.anim.slide_up, R.anim.hold)
} }
...@@ -538,11 +554,11 @@ class LoginFragment : Fragment(), LoginView, GoogleApiClient.ConnectionCallbacks ...@@ -538,11 +554,11 @@ class LoginFragment : Fragment(), LoginView, GoogleApiClient.ConnectionCallbacks
} }
override fun addCustomOauthServiceButton( override fun addCustomOauthServiceButton(
customOauthUrl: String, customOauthUrl: String,
state: String, state: String,
serviceName: String, serviceName: String,
serviceNameColor: Int, serviceNameColor: Int,
buttonColor: Int buttonColor: Int
) { ) {
ui { activity -> ui { activity ->
val button = getCustomOauthButton(serviceName, serviceNameColor, buttonColor) val button = getCustomOauthButton(serviceName, serviceNameColor, buttonColor)
...@@ -550,8 +566,8 @@ class LoginFragment : Fragment(), LoginView, GoogleApiClient.ConnectionCallbacks ...@@ -550,8 +566,8 @@ class LoginFragment : Fragment(), LoginView, GoogleApiClient.ConnectionCallbacks
button.setOnClickListener { button.setOnClickListener {
startActivityForResult( startActivityForResult(
activity.oauthWebViewIntent(customOauthUrl, state), activity.oauthWebViewIntent(customOauthUrl, state),
REQUEST_CODE_FOR_OAUTH REQUEST_CODE_FOR_OAUTH
) )
activity.overridePendingTransition(R.anim.slide_up, R.anim.hold) activity.overridePendingTransition(R.anim.slide_up, R.anim.hold)
} }
...@@ -599,9 +615,9 @@ class LoginFragment : Fragment(), LoginView, GoogleApiClient.ConnectionCallbacks ...@@ -599,9 +615,9 @@ class LoginFragment : Fragment(), LoginView, GoogleApiClient.ConnectionCallbacks
social_accounts_container.postDelayed(300) { social_accounts_container.postDelayed(300) {
ui { ui {
(0..social_accounts_container.childCount) (0..social_accounts_container.childCount)
.mapNotNull { social_accounts_container.getChildAt(it) as? ImageButton } .mapNotNull { social_accounts_container.getChildAt(it) as? ImageButton }
.filter { it.isClickable } .filter { it.isClickable }
.forEach { it.isVisible = true } .forEach { it.isVisible = true }
} }
} }
} }
...@@ -635,10 +651,10 @@ class LoginFragment : Fragment(), LoginView, GoogleApiClient.ConnectionCallbacks ...@@ -635,10 +651,10 @@ class LoginFragment : Fragment(), LoginView, GoogleApiClient.ConnectionCallbacks
private fun showThreeSocialAccountsMethods() { private fun showThreeSocialAccountsMethods() {
(0..social_accounts_container.childCount) (0..social_accounts_container.childCount)
.mapNotNull { social_accounts_container.getChildAt(it) as? ImageButton } .mapNotNull { social_accounts_container.getChildAt(it) as? ImageButton }
.filter { it.isClickable } .filter { it.isClickable }
.take(3) .take(3)
.forEach { it.isVisible = true } .forEach { it.isVisible = true }
} }
private fun showOauthView() { private fun showOauthView() {
...@@ -663,28 +679,28 @@ class LoginFragment : Fragment(), LoginView, GoogleApiClient.ConnectionCallbacks ...@@ -663,28 +679,28 @@ class LoginFragment : Fragment(), LoginView, GoogleApiClient.ConnectionCallbacks
private fun enabledOauthAccountsImageButtons(): Int { private fun enabledOauthAccountsImageButtons(): Int {
return (0..social_accounts_container.childCount) return (0..social_accounts_container.childCount)
.mapNotNull { social_accounts_container.getChildAt(it) as? ImageButton } .mapNotNull { social_accounts_container.getChildAt(it) as? ImageButton }
.filter { it.isClickable } .filter { it.isClickable }
.size .size
} }
private fun enabledServicesAccountsButtons(): Int { private fun enabledServicesAccountsButtons(): Int {
return (0..social_accounts_container.childCount) return (0..social_accounts_container.childCount)
.mapNotNull { social_accounts_container.getChildAt(it) as? Button } .mapNotNull { social_accounts_container.getChildAt(it) as? Button }
.size .size
} }
/** /**
* Gets a stylized custom OAuth button. * Gets a stylized custom OAuth button.
*/ */
private fun getCustomOauthButton( private fun getCustomOauthButton(
buttonText: String, buttonText: String,
buttonTextColor: Int, buttonTextColor: Int,
buttonBgColor: Int buttonBgColor: Int
): Button { ): Button {
val params: LinearLayout.LayoutParams = LinearLayout.LayoutParams( val params: LinearLayout.LayoutParams = LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT LinearLayout.LayoutParams.WRAP_CONTENT
) )
val margin = resources.getDimensionPixelSize(R.dimen.screen_edge_left_and_right_margins) val margin = resources.getDimensionPixelSize(R.dimen.screen_edge_left_and_right_margins)
......
...@@ -23,15 +23,17 @@ import chat.rocket.core.model.Myself ...@@ -23,15 +23,17 @@ import chat.rocket.core.model.Myself
import com.google.android.gms.auth.api.credentials.Credential import com.google.android.gms.auth.api.credentials.Credential
import javax.inject.Inject import javax.inject.Inject
class SignupPresenter @Inject constructor(private val view: SignupView, class SignupPresenter @Inject constructor(
private val strategy: CancelStrategy, private val view: SignupView,
private val navigator: AuthenticationNavigator, private val strategy: CancelStrategy,
private val localRepository: LocalRepository, private val navigator: AuthenticationNavigator,
private val serverInteractor: GetCurrentServerInteractor, private val localRepository: LocalRepository,
private val factory: RocketChatClientFactory, private val serverInteractor: GetCurrentServerInteractor,
private val saveAccountInteractor: SaveAccountInteractor, private val factory: RocketChatClientFactory,
private val getAccountsInteractor: GetAccountsInteractor, private val saveAccountInteractor: SaveAccountInteractor,
settingsInteractor: GetSettingsInteractor) { private val getAccountsInteractor: GetAccountsInteractor,
settingsInteractor: GetSettingsInteractor
) {
private val currentServer = serverInteractor.get()!! private val currentServer = serverInteractor.get()!!
private val client: RocketChatClient = factory.create(currentServer) private val client: RocketChatClient = factory.create(currentServer)
private var settings: PublicSettings = settingsInteractor.get(serverInteractor.get()!!) private var settings: PublicSettings = settingsInteractor.get(serverInteractor.get()!!)
...@@ -67,9 +69,9 @@ class SignupPresenter @Inject constructor(private val view: SignupView, ...@@ -67,9 +69,9 @@ class SignupPresenter @Inject constructor(private val view: SignupView,
localRepository.save(LocalRepository.CURRENT_USERNAME_KEY, me.username) localRepository.save(LocalRepository.CURRENT_USERNAME_KEY, me.username)
saveAccount(me) saveAccount(me)
registerPushToken() registerPushToken()
var loginCredentials: Credential = Credential.Builder(email) val loginCredentials = Credential.Builder(email)
.setPassword(password) .setPassword(password)
.build() .build()
view.saveSmartLockCredentials(loginCredentials) view.saveSmartLockCredentials(loginCredentials)
navigator.toChatList() navigator.toChatList()
} catch (exception: RocketChatException) { } catch (exception: RocketChatException) {
......
...@@ -29,5 +29,5 @@ interface SignupView : LoadingView, MessageView { ...@@ -29,5 +29,5 @@ interface SignupView : LoadingView, MessageView {
/** /**
* Save credentials via google smart lock * Save credentials via google smart lock
*/ */
fun saveSmartLockCredentials(loginCredential: Credential?) fun saveSmartLockCredentials(loginCredential: Credential)
} }
\ No newline at end of file
...@@ -7,7 +7,6 @@ import android.os.Build ...@@ -7,7 +7,6 @@ import android.os.Build
import android.os.Bundle import android.os.Bundle
import android.support.v4.app.Fragment import android.support.v4.app.Fragment
import android.text.style.ClickableSpan import android.text.style.ClickableSpan
import android.util.Log
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
...@@ -26,6 +25,7 @@ import com.google.android.gms.common.api.ResolvingResultCallbacks ...@@ -26,6 +25,7 @@ import com.google.android.gms.common.api.ResolvingResultCallbacks
import com.google.android.gms.common.api.Status import com.google.android.gms.common.api.Status
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 timber.log.Timber
import javax.inject.Inject import javax.inject.Inject
internal const val SAVE_CREDENTIALS = 1 internal const val SAVE_CREDENTIALS = 1
...@@ -34,7 +34,7 @@ class SignupFragment : Fragment(), SignupView { ...@@ -34,7 +34,7 @@ class SignupFragment : Fragment(), SignupView {
@Inject @Inject
lateinit var presenter: SignupPresenter lateinit var presenter: SignupPresenter
private var credentialsToBeSaved: Credential? = null private lateinit var credentialsToBeSaved: Credential
private val layoutListener = ViewTreeObserver.OnGlobalLayoutListener { private val layoutListener = ViewTreeObserver.OnGlobalLayoutListener {
if (KeyboardHelper.isSoftKeyboardShown(relative_layout.rootView)) { if (KeyboardHelper.isSoftKeyboardShown(relative_layout.rootView)) {
bottom_container.setVisible(false) bottom_container.setVisible(false)
...@@ -56,7 +56,11 @@ class SignupFragment : Fragment(), SignupView { ...@@ -56,7 +56,11 @@ class SignupFragment : Fragment(), SignupView {
AndroidSupportInjection.inject(this) AndroidSupportInjection.inject(this)
} }
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? = inflater.inflate(R.layout.fragment_authentication_sign_up, container, false) override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? = inflater.inflate(R.layout.fragment_authentication_sign_up, container, false)
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
...@@ -70,7 +74,12 @@ class SignupFragment : Fragment(), SignupView { ...@@ -70,7 +74,12 @@ class SignupFragment : Fragment(), SignupView {
setUpNewUserAgreementListener() setUpNewUserAgreementListener()
button_sign_up.setOnClickListener { button_sign_up.setOnClickListener {
presenter.signup(text_username.textContent, text_username.textContent, text_password.textContent, text_email.textContent) presenter.signup(
text_username.textContent,
text_username.textContent,
text_password.textContent,
text_email.textContent
)
} }
} }
...@@ -111,7 +120,7 @@ class SignupFragment : Fragment(), SignupView { ...@@ -111,7 +120,7 @@ class SignupFragment : Fragment(), SignupView {
} }
} }
override fun saveSmartLockCredentials(loginCredential: Credential?) { override fun saveSmartLockCredentials(loginCredential: Credential) {
credentialsToBeSaved = loginCredential credentialsToBeSaved = loginCredential
if (googleApiClient!!.isConnected) { if (googleApiClient!!.isConnected) {
saveCredentials() saveCredentials()
...@@ -123,27 +132,22 @@ class SignupFragment : Fragment(), SignupView { ...@@ -123,27 +132,22 @@ class SignupFragment : Fragment(), SignupView {
if (resultCode == RESULT_OK) { if (resultCode == RESULT_OK) {
Toast.makeText(context, "Credentials saved successfully", Toast.LENGTH_SHORT).show() Toast.makeText(context, "Credentials saved successfully", Toast.LENGTH_SHORT).show()
} else { } else {
Log.e("STATUS", "ERROR: Cancelled by user") Timber.e("ERROR: Cancelled by user")
} }
} }
} }
private fun saveCredentials() { private fun saveCredentials() {
if (credentialsToBeSaved == null) {
return
}
Auth.CredentialsApi.save(googleApiClient, credentialsToBeSaved).setResultCallback( Auth.CredentialsApi.save(googleApiClient, credentialsToBeSaved).setResultCallback(
object : ResolvingResultCallbacks<Status>(activity!!, SAVE_CREDENTIALS) { object : ResolvingResultCallbacks<Status>(activity!!, SAVE_CREDENTIALS) {
override fun onSuccess(status: Status) { override fun onSuccess(status: Status) {
Log.d("STATUS", "save:SUCCESS:$status") Timber.d("save:SUCCESS:$status")
credentialsToBeSaved = null }
}
override fun onUnresolvableFailure(status: Status) { override fun onUnresolvableFailure(status: Status) {
Log.w("STATUS", "save:FAILURE:$status") Timber.w("save:FAILURE:$status")
credentialsToBeSaved = null }
} })
})
} }
override fun showLoading() { override fun showLoading() {
...@@ -178,7 +182,8 @@ class SignupFragment : Fragment(), SignupView { ...@@ -178,7 +182,8 @@ class SignupFragment : Fragment(), SignupView {
private fun tintEditTextDrawableStart() { private fun tintEditTextDrawableStart() {
ui { ui {
val personDrawable = DrawableHelper.getDrawableFromId(R.drawable.ic_person_black_24dp, it) val personDrawable =
DrawableHelper.getDrawableFromId(R.drawable.ic_person_black_24dp, it)
val atDrawable = DrawableHelper.getDrawableFromId(R.drawable.ic_at_black_24dp, it) val atDrawable = DrawableHelper.getDrawableFromId(R.drawable.ic_at_black_24dp, it)
val lockDrawable = DrawableHelper.getDrawableFromId(R.drawable.ic_lock_black_24dp, it) val lockDrawable = DrawableHelper.getDrawableFromId(R.drawable.ic_lock_black_24dp, it)
val emailDrawable = DrawableHelper.getDrawableFromId(R.drawable.ic_email_black_24dp, it) val emailDrawable = DrawableHelper.getDrawableFromId(R.drawable.ic_email_black_24dp, it)
...@@ -186,14 +191,22 @@ class SignupFragment : Fragment(), SignupView { ...@@ -186,14 +191,22 @@ class SignupFragment : Fragment(), SignupView {
val drawables = arrayOf(personDrawable, atDrawable, lockDrawable, emailDrawable) val drawables = arrayOf(personDrawable, atDrawable, lockDrawable, emailDrawable)
DrawableHelper.wrapDrawables(drawables) DrawableHelper.wrapDrawables(drawables)
DrawableHelper.tintDrawables(drawables, it, R.color.colorDrawableTintGrey) DrawableHelper.tintDrawables(drawables, it, R.color.colorDrawableTintGrey)
DrawableHelper.compoundDrawables(arrayOf(text_name, text_username, text_password, text_email), drawables) DrawableHelper.compoundDrawables(
arrayOf(
text_name,
text_username,
text_password,
text_email
), drawables
)
} }
} }
private fun setUpNewUserAgreementListener() { private fun setUpNewUserAgreementListener() {
val termsOfService = getString(R.string.action_terms_of_service) val termsOfService = getString(R.string.action_terms_of_service)
val privacyPolicy = getString(R.string.action_privacy_policy) val privacyPolicy = getString(R.string.action_privacy_policy)
val newUserAgreement = String.format(getString(R.string.msg_new_user_agreement), termsOfService, privacyPolicy) val newUserAgreement =
String.format(getString(R.string.msg_new_user_agreement), termsOfService, privacyPolicy)
text_new_user_agreement.text = newUserAgreement text_new_user_agreement.text = newUserAgreement
...@@ -209,7 +222,11 @@ class SignupFragment : Fragment(), SignupView { ...@@ -209,7 +222,11 @@ class SignupFragment : Fragment(), SignupView {
} }
} }
TextHelper.addLink(text_new_user_agreement, arrayOf(termsOfService, privacyPolicy), arrayOf(termsOfServiceListener, privacyPolicyListener)) TextHelper.addLink(
text_new_user_agreement,
arrayOf(termsOfService, privacyPolicy),
arrayOf(termsOfServiceListener, privacyPolicyListener)
)
} }
private fun enableUserInput(value: Boolean) { private fun enableUserInput(value: Boolean) {
......
...@@ -21,8 +21,10 @@ import kotlinx.coroutines.experimental.launch ...@@ -21,8 +21,10 @@ import kotlinx.coroutines.experimental.launch
import javax.inject.Inject import javax.inject.Inject
class AuthenticationActivity : AppCompatActivity(), HasSupportFragmentInjector { class AuthenticationActivity : AppCompatActivity(), HasSupportFragmentInjector {
@Inject lateinit var fragmentDispatchingAndroidInjector: DispatchingAndroidInjector<Fragment> @Inject
@Inject lateinit var presenter: AuthenticationPresenter lateinit var fragmentDispatchingAndroidInjector: DispatchingAndroidInjector<Fragment>
@Inject
lateinit var presenter: AuthenticationPresenter
val job = Job() val job = Job()
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
...@@ -46,7 +48,7 @@ class AuthenticationActivity : AppCompatActivity(), HasSupportFragmentInjector { ...@@ -46,7 +48,7 @@ class AuthenticationActivity : AppCompatActivity(), HasSupportFragmentInjector {
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data) super.onActivityResult(requestCode, resultCode, data)
val currentFragment = supportFragmentManager.findFragmentById(R.id.fragment_container) val currentFragment = supportFragmentManager.findFragmentById(R.id.fragment_container)
if (currentFragment!=null){ if (currentFragment != null) {
currentFragment.onActivityResult(requestCode, resultCode, data) currentFragment.onActivityResult(requestCode, resultCode, data)
} }
} }
......
...@@ -6,7 +6,6 @@ import android.os.Bundle ...@@ -6,7 +6,6 @@ import android.os.Bundle
import android.support.v4.app.Fragment import android.support.v4.app.Fragment
import android.support.v7.app.AppCompatActivity import android.support.v7.app.AppCompatActivity
import android.support.v7.widget.LinearLayoutManager import android.support.v7.widget.LinearLayoutManager
import android.util.Log
import android.view.Gravity import android.view.Gravity
import android.view.MenuItem import android.view.MenuItem
import android.view.View import android.view.View
...@@ -40,13 +39,8 @@ import kotlinx.coroutines.experimental.launch ...@@ -40,13 +39,8 @@ import kotlinx.coroutines.experimental.launch
import timber.log.Timber import timber.log.Timber
import javax.inject.Inject import javax.inject.Inject
class MainActivity : AppCompatActivity(), MainView, HasActivityInjector, HasSupportFragmentInjector, GoogleApiClient.ConnectionCallbacks { class MainActivity : AppCompatActivity(), MainView, HasActivityInjector, HasSupportFragmentInjector,
override fun onConnected(p0: Bundle?) { GoogleApiClient.ConnectionCallbacks {
}
override fun onConnectionSuspended(p0: Int) {
}
@Inject @Inject
lateinit var activityDispatchingAndroidInjector: DispatchingAndroidInjector<Activity> lateinit var activityDispatchingAndroidInjector: DispatchingAndroidInjector<Activity>
@Inject @Inject
...@@ -55,7 +49,7 @@ class MainActivity : AppCompatActivity(), MainView, HasActivityInjector, HasSupp ...@@ -55,7 +49,7 @@ class MainActivity : AppCompatActivity(), MainView, HasActivityInjector, HasSupp
lateinit var presenter: MainPresenter lateinit var presenter: MainPresenter
private var isFragmentAdded: Boolean = false private var isFragmentAdded: Boolean = false
private var expanded = false private var expanded = false
private var googleApiClient: GoogleApiClient? = null private lateinit var googleApiClient: GoogleApiClient
private val headerLayout by lazy { view_navigation.getHeaderView(0) } private val headerLayout by lazy { view_navigation.getHeaderView(0) }
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
...@@ -66,7 +60,11 @@ class MainActivity : AppCompatActivity(), MainView, HasActivityInjector, HasSupp ...@@ -66,7 +60,11 @@ class MainActivity : AppCompatActivity(), MainView, HasActivityInjector, HasSupp
launch(CommonPool) { launch(CommonPool) {
try { try {
val token = InstanceID.getInstance(this@MainActivity).getToken(getString(R.string.gcm_sender_id), GoogleCloudMessaging.INSTANCE_ID_SCOPE, null) val token = InstanceID.getInstance(this@MainActivity).getToken(
getString(R.string.gcm_sender_id),
GoogleCloudMessaging.INSTANCE_ID_SCOPE,
null
)
Timber.d("GCM token: $token") Timber.d("GCM token: $token")
presenter.refreshToken(token) presenter.refreshToken(token)
} catch (ex: Exception) { } catch (ex: Exception) {
...@@ -80,28 +78,36 @@ class MainActivity : AppCompatActivity(), MainView, HasActivityInjector, HasSupp ...@@ -80,28 +78,36 @@ class MainActivity : AppCompatActivity(), MainView, HasActivityInjector, HasSupp
setupNavigationView() setupNavigationView()
} }
override fun onConnected(bundle: Bundle?) {
}
override fun onConnectionSuspended(errorCode: Int) {
}
private fun buildGoogleApiClient() { private fun buildGoogleApiClient() {
googleApiClient = GoogleApiClient.Builder(this) googleApiClient = GoogleApiClient.Builder(this)
.enableAutoManage(this, { .enableAutoManage(this, {
Log.d("STATUS", "ERROR: connection to client failed") Timber.d("ERROR: connection to client failed")
}) })
.addConnectionCallbacks(this) .addConnectionCallbacks(this)
.addApi(Auth.CREDENTIALS_API) .addApi(Auth.CREDENTIALS_API)
.build() .build()
} }
override fun onStart() { override fun onStart() {
super.onStart() super.onStart()
if (googleApiClient!!.isConnected) { googleApiClient.let {
Log.d("STATUS", "google api client connected successfully") if (it.isConnected) {
Timber.d("Google api client connected successfully")
}
} }
} }
override fun disableAutoSignIn() { override fun disableAutoSignIn() {
if (googleApiClient!!.isConnected) { googleApiClient.let {
Auth.CredentialsApi.disableAutoSignIn(googleApiClient) if (it.isConnected) {
} else { Auth.CredentialsApi.disableAutoSignIn(googleApiClient)
Log.e("STATUS", "Failed to disable auto sign in") }
} }
} }
...@@ -123,7 +129,7 @@ class MainActivity : AppCompatActivity(), MainView, HasActivityInjector, HasSupp ...@@ -123,7 +129,7 @@ class MainActivity : AppCompatActivity(), MainView, HasActivityInjector, HasSupp
override fun showUserStatus(userStatus: UserStatus) { override fun showUserStatus(userStatus: UserStatus) {
headerLayout.apply { headerLayout.apply {
image_user_status.setImageDrawable( image_user_status.setImageDrawable(
DrawableHelper.getUserStatusDrawable(userStatus, this.context) DrawableHelper.getUserStatusDrawable(userStatus, this.context)
) )
} }
} }
...@@ -134,7 +140,7 @@ class MainActivity : AppCompatActivity(), MainView, HasActivityInjector, HasSupp ...@@ -134,7 +140,7 @@ class MainActivity : AppCompatActivity(), MainView, HasActivityInjector, HasSupp
with(viewModel) { with(viewModel) {
if (userStatus != null) { if (userStatus != null) {
image_user_status.setImageDrawable( image_user_status.setImageDrawable(
DrawableHelper.getUserStatusDrawable(userStatus, context) DrawableHelper.getUserStatusDrawable(userStatus, context)
) )
} }
if (userDisplayName != null) { if (userDisplayName != null) {
...@@ -158,19 +164,29 @@ class MainActivity : AppCompatActivity(), MainView, HasActivityInjector, HasSupp ...@@ -158,19 +164,29 @@ class MainActivity : AppCompatActivity(), MainView, HasActivityInjector, HasSupp
override fun alertNotRecommendedVersion() { override fun alertNotRecommendedVersion() {
AlertDialog.Builder(this) AlertDialog.Builder(this)
.setMessage(getString(R.string.msg_ver_not_recommended, BuildConfig.RECOMMENDED_SERVER_VERSION)) .setMessage(
.setPositiveButton(R.string.msg_ok, null) getString(
.create() R.string.msg_ver_not_recommended,
.show() BuildConfig.RECOMMENDED_SERVER_VERSION
)
)
.setPositiveButton(R.string.msg_ok, null)
.create()
.show()
} }
override fun blockAndAlertNotRequiredVersion() { override fun blockAndAlertNotRequiredVersion() {
AlertDialog.Builder(this) AlertDialog.Builder(this)
.setMessage(getString(R.string.msg_ver_not_minimum, BuildConfig.REQUIRED_SERVER_VERSION)) .setMessage(
.setOnDismissListener { presenter.logout() } getString(
.setPositiveButton(R.string.msg_ok, null) R.string.msg_ver_not_minimum,
.create() BuildConfig.REQUIRED_SERVER_VERSION
.show() )
)
.setOnDismissListener { presenter.logout() }
.setPositiveButton(R.string.msg_ok, null)
.create()
.show()
} }
private fun setupAccountsList(header: View, accounts: List<Account>) { private fun setupAccountsList(header: View, accounts: List<Account>) {
...@@ -215,7 +231,8 @@ class MainActivity : AppCompatActivity(), MainView, HasActivityInjector, HasSupp ...@@ -215,7 +231,8 @@ class MainActivity : AppCompatActivity(), MainView, HasActivityInjector, HasSupp
override fun activityInjector(): AndroidInjector<Activity> = activityDispatchingAndroidInjector override fun activityInjector(): AndroidInjector<Activity> = activityDispatchingAndroidInjector
override fun supportFragmentInjector(): AndroidInjector<Fragment> = fragmentDispatchingAndroidInjector override fun supportFragmentInjector(): AndroidInjector<Fragment> =
fragmentDispatchingAndroidInjector
private fun setupToolbar() { private fun setupToolbar() {
setSupportActionBar(toolbar) setSupportActionBar(toolbar)
......
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