diff --git a/app/src/main/java/com/keylesspalace/tusky/LoginActivity.kt b/app/src/main/java/com/keylesspalace/tusky/LoginActivity.kt index 7deb2dd7..8938abaa 100644 --- a/app/src/main/java/com/keylesspalace/tusky/LoginActivity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/LoginActivity.kt @@ -55,15 +55,22 @@ class LoginActivity : BaseActivity(), Injectable { val host = BuildConfig.APPLICATION_ID return "$scheme://$host/" } - + override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_login) - if(savedInstanceState == null && BuildConfig.CUSTOM_INSTANCE.isNotBlank() && !isAdditionalLogin()) { - domainEditText.setText(BuildConfig.CUSTOM_INSTANCE) - domainEditText.setSelection(BuildConfig.CUSTOM_INSTANCE.length) + if(savedInstanceState == null ) { + if(BuildConfig.CUSTOM_INSTANCE.isNotBlank() && !isAdditionalLogin()) { + domainEditText.setText(BuildConfig.CUSTOM_INSTANCE) + domainEditText.setSelection(BuildConfig.CUSTOM_INSTANCE.length) + } + appNameEditText.setText(getString(R.string.app_name)) + appNameEditText.setSelection(getString(R.string.app_name).length) + + websiteEditText.setText(getString(R.string.tusky_website)) + websiteEditText.setSelection(getString(R.string.tusky_website).length) } if(BuildConfig.CUSTOM_LOGO_URL.isNotBlank()) { @@ -77,6 +84,7 @@ class LoginActivity : BaseActivity(), Injectable { getString(R.string.preferences_file_key), Context.MODE_PRIVATE) loginButton.setOnClickListener { onButtonClick() } + settingsButton.setOnClickListener { onSettingsButtonClick() } whatsAnInstanceTextView.setOnClickListener { val dialog = AlertDialog.Builder(this) @@ -115,6 +123,15 @@ class LoginActivity : BaseActivity(), Injectable { } return super.onOptionsItemSelected(item) } + + private fun onSettingsButtonClick() { + if(extendedSettings.visibility == View.GONE) { + extendedSettings.visibility = View.VISIBLE + } else { + extendedSettings.visibility = View.GONE + } + + } /** * Obtain the oauth client credentials for this app. This is only necessary the first time the @@ -165,10 +182,17 @@ class LoginActivity : BaseActivity(), Injectable { Log.e(TAG, Log.getStackTraceString(t)) } } - + + var appname = getString(R.string.app_name) + var website = getString(R.string.tusky_website) + if(extendedSettings.visibility == View.VISIBLE) { + appname = appNameEditText.text.toString() + website = websiteEditText.text.toString() + } + mastodonApi - .authenticateApp(domain, getString(R.string.app_name), oauthRedirectUri, - OAUTH_SCOPES, getString(R.string.tusky_website)) + .authenticateApp(domain, appname, oauthRedirectUri, + OAUTH_SCOPES, website) .enqueue(callback) setLoading(true) diff --git a/app/src/main/res/drawable/ic_settings.xml b/app/src/main/res/drawable/ic_settings.xml new file mode 100644 index 00000000..b8520543 --- /dev/null +++ b/app/src/main/res/drawable/ic_settings.xml @@ -0,0 +1,10 @@ + + + + diff --git a/app/src/main/res/layout/activity_login.xml b/app/src/main/res/layout/activity_login.xml index 25844b69..d2c6ec93 100644 --- a/app/src/main/res/layout/activity_login.xml +++ b/app/src/main/res/layout/activity_login.xml @@ -52,16 +52,70 @@ android:ems="10" android:inputType="textUri" /> - - + + + + + + + + + + + + + android:orientation="horizontal"> + + + +