Direct registration button

This commit is contained in:
Mike Barnes 2020-12-17 20:28:59 +11:00
commit e52b54017e
5 changed files with 32 additions and 1 deletions

View file

@ -80,6 +80,7 @@ class LoginActivity : BaseActivity(), Injectable {
getString(R.string.preferences_file_key), Context.MODE_PRIVATE)
loginButton.setOnClickListener { onButtonClick() }
registerButton.setOnClickListener { onRegisterClick() }
whatsAnInstanceTextView.setOnClickListener {
val dialog = AlertDialog.Builder(this)
@ -119,6 +120,21 @@ class LoginActivity : BaseActivity(), Injectable {
return super.onOptionsItemSelected(item)
}
private fun onRegisterClick() {
registerButton.isEnabled = false
val uri = Uri.parse(BuildConfig.REGISTER_ACCOUNT_URL)
if (!openInCustomTab(uri, this)) {
val viewIntent = Intent(Intent.ACTION_VIEW, uri)
if (viewIntent.resolveActivity(packageManager) != null) {
startActivity(viewIntent)
} else {
domainEditText.error = getString(R.string.error_no_web_browser_found)
setLoading(false)
}
}
}
/**
* Obtain the oauth client credentials for this app. This is only necessary the first time the
* app is run on a given server instance. So, after the first authentication, they are