From e52b54017e7ef9fc075aa8c875a9ed9ce469509c Mon Sep 17 00:00:00 2001 From: Mike Barnes Date: Thu, 17 Dec 2020 20:28:59 +1100 Subject: [PATCH] Direct registration button --- app/build.gradle | 1 + .../com/keylesspalace/tusky/LoginActivity.kt | 16 ++++++++++++++++ app/src/main/res/layout/activity_login.xml | 9 +++++++++ app/src/main/res/values/strings.xml | 2 ++ instance-build.gradle | 5 ++++- 5 files changed, 32 insertions(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index 1416975a..f74c6e4e 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -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 { diff --git a/app/src/main/java/com/keylesspalace/tusky/LoginActivity.kt b/app/src/main/java/com/keylesspalace/tusky/LoginActivity.kt index f68b2337..2269d328 100644 --- a/app/src/main/java/com/keylesspalace/tusky/LoginActivity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/LoginActivity.kt @@ -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 diff --git a/app/src/main/res/layout/activity_login.xml b/app/src/main/res/layout/activity_login.xml index 70c91242..839a9fc6 100644 --- a/app/src/main/res/layout/activity_login.xml +++ b/app/src/main/res/layout/activity_login.xml @@ -62,6 +62,15 @@ android:gravity="center" android:text="@string/action_login" /> + + Your private note about this account Saved! + Register New Account + diff --git a/instance-build.gradle b/instance-build.gradle index faea306e..a7095124 100644 --- a/instance-build.gradle +++ b/instance-build.gradle @@ -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" \ No newline at end of file +ext.SUPPORT_ACCOUNT_URL = "https://social.chinwag.org/@ChinwagNews" + +// New account registration link +ext.REGISTER_ACCOUNT_URL = "https://social.chinwag.org/auth/sign_up"