Direct registration button

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

View file

@ -30,6 +30,7 @@ android {
buildConfigField("String", "CUSTOM_LOGO_URL", "\"$CUSTOM_LOGO_URL\"")
buildConfigField("String", "CUSTOM_INSTANCE", "\"$CUSTOM_INSTANCE\"")
buildConfigField("String", "SUPPORT_ACCOUNT_URL", "\"$SUPPORT_ACCOUNT_URL\"")
buildConfigField("String", "REGISTER_ACCOUNT_URL", "\"$REGISTER_ACCOUNT_URL\"")
kapt {
arguments {

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

View file

@ -62,6 +62,15 @@
android:gravity="center"
android:text="@string/action_login" />
<com.google.android.material.button.MaterialButton
android:id="@+id/registerButton"
style="@style/TuskyButton"
android:layout_width="250dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:gravity="center"
android:text="@string/action_register" />
<TextView
android:id="@+id/whatsAnInstanceTextView"
android:layout_width="250dp"

View file

@ -578,4 +578,6 @@
<string name="account_note_hint">Your private note about this account</string>
<string name="account_note_saved">Saved!</string>
<string name="action_register">Register New Account</string>
</resources>

View file

@ -16,4 +16,7 @@ ext.CUSTOM_LOGO_URL = "https://static.chinwag.org/chinwag-logo-simple-1024.png"
ext.CUSTOM_INSTANCE = "social.chinwag.org"
// link to your support account. Will be linked on the about page when not empty.
ext.SUPPORT_ACCOUNT_URL = "https://social.chinwag.org/@ChinwagNews"
ext.SUPPORT_ACCOUNT_URL = "https://social.chinwag.org/@ChinwagNews"
// New account registration link
ext.REGISTER_ACCOUNT_URL = "https://social.chinwag.org/auth/sign_up"