|
|
@ -28,6 +28,7 @@ import android.view.MenuItem |
|
|
|
import android.view.View |
|
|
|
import android.view.View |
|
|
|
import android.widget.TextView |
|
|
|
import android.widget.TextView |
|
|
|
import androidx.appcompat.app.AlertDialog |
|
|
|
import androidx.appcompat.app.AlertDialog |
|
|
|
|
|
|
|
import com.bumptech.glide.Glide |
|
|
|
import com.keylesspalace.tusky.di.Injectable |
|
|
|
import com.keylesspalace.tusky.di.Injectable |
|
|
|
import com.keylesspalace.tusky.entity.AccessToken |
|
|
|
import com.keylesspalace.tusky.entity.AccessToken |
|
|
|
import com.keylesspalace.tusky.entity.AppCredentials |
|
|
|
import com.keylesspalace.tusky.entity.AppCredentials |
|
|
@ -62,6 +63,18 @@ class LoginActivity : BaseActivity(), Injectable { |
|
|
|
|
|
|
|
|
|
|
|
setContentView(R.layout.activity_login) |
|
|
|
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(BuildConfig.CUSTOM_LOGO_URL.isNotBlank()) { |
|
|
|
|
|
|
|
Glide.with(loginLogo) |
|
|
|
|
|
|
|
.load(BuildConfig.CUSTOM_LOGO_URL) |
|
|
|
|
|
|
|
.placeholder(null) |
|
|
|
|
|
|
|
.into(loginLogo) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
preferences = getSharedPreferences( |
|
|
|
preferences = getSharedPreferences( |
|
|
|
getString(R.string.preferences_file_key), Context.MODE_PRIVATE) |
|
|
|
getString(R.string.preferences_file_key), Context.MODE_PRIVATE) |
|
|
|
|
|
|
|
|
|
|
@ -162,7 +175,7 @@ class LoginActivity : BaseActivity(), Injectable { |
|
|
|
|
|
|
|
|
|
|
|
mastodonApi |
|
|
|
mastodonApi |
|
|
|
.authenticateApp(domain, getString(R.string.app_name), oauthRedirectUri, |
|
|
|
.authenticateApp(domain, getString(R.string.app_name), oauthRedirectUri, |
|
|
|
OAUTH_SCOPES, getString(R.string.app_website)) |
|
|
|
OAUTH_SCOPES, getString(R.string.tusky_website)) |
|
|
|
.enqueue(callback) |
|
|
|
.enqueue(callback) |
|
|
|
setLoading(true) |
|
|
|
setLoading(true) |
|
|
|
|
|
|
|
|
|
|
@ -174,9 +187,9 @@ class LoginActivity : BaseActivity(), Injectable { |
|
|
|
val endpoint = MastodonApi.ENDPOINT_AUTHORIZE |
|
|
|
val endpoint = MastodonApi.ENDPOINT_AUTHORIZE |
|
|
|
val parameters = mapOf( |
|
|
|
val parameters = mapOf( |
|
|
|
"client_id" to clientId, |
|
|
|
"client_id" to clientId, |
|
|
|
"redirect_uri" to oauthRedirectUri, |
|
|
|
"redirect_uri" to oauthRedirectUri, |
|
|
|
"response_type" to "code", |
|
|
|
"response_type" to "code", |
|
|
|
"scope" to OAUTH_SCOPES |
|
|
|
"scope" to OAUTH_SCOPES |
|
|
|
) |
|
|
|
) |
|
|
|
val url = "https://" + domain + endpoint + "?" + toQueryString(parameters) |
|
|
|
val url = "https://" + domain + endpoint + "?" + toQueryString(parameters) |
|
|
|
val uri = Uri.parse(url) |
|
|
|
val uri = Uri.parse(url) |
|
|
@ -336,7 +349,7 @@ class LoginActivity : BaseActivity(), Injectable { |
|
|
|
.setToolbarColor(toolbarColor) |
|
|
|
.setToolbarColor(toolbarColor) |
|
|
|
.build() |
|
|
|
.build() |
|
|
|
try { |
|
|
|
try { |
|
|
|
customTabsIntent.launchUrl(context, uri) |
|
|
|
customTabsIntent.launchUrl(context, uri) |
|
|
|
} catch (e: ActivityNotFoundException) { |
|
|
|
} catch (e: ActivityNotFoundException) { |
|
|
|
Log.w(TAG, "Activity was not found for intent $customTabsIntent") |
|
|
|
Log.w(TAG, "Activity was not found for intent $customTabsIntent") |
|
|
|
return false |
|
|
|
return false |
|
|
|