diff --git a/twidere/build.gradle b/twidere/build.gradle index c3febfa33..d8314a784 100644 --- a/twidere/build.gradle +++ b/twidere/build.gradle @@ -34,8 +34,8 @@ android { applicationId "org.mariotaku.twidere" minSdkVersion 14 targetSdkVersion 25 - versionCode 261 - versionName '3.4.0' + versionCode 262 + versionName '3.4.1' multiDexEnabled true buildConfigField 'boolean', 'LEAK_CANARY_ENABLED', 'Boolean.parseBoolean("true")' diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/activity/SignInActivity.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/activity/SignInActivity.kt index 08aa577dc..575017316 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/activity/SignInActivity.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/activity/SignInActivity.kt @@ -170,7 +170,7 @@ class SignInActivity : BaseActivity(), OnClickListener, TextWatcher, APIEditorDi } REQUEST_BROWSER_SIGN_IN -> { if (resultCode == Activity.RESULT_OK && data != null) { - doBrowserLogin(data) + handleBrowserLoginResult(data) } } } @@ -226,7 +226,11 @@ class SignInActivity : BaseActivity(), OnClickListener, TextWatcher, APIEditorDi editUsername.text = null editPassword.text = null } - doLogin() + if (apiConfig.credentialsType == Credentials.Type.OAUTH) { + doBrowserLogin() + } else { + doLogin() + } } passwordSignIn -> { executeAfterFragmentResumed { fragment -> @@ -309,7 +313,7 @@ class SignInActivity : BaseActivity(), OnClickListener, TextWatcher, APIEditorDi } } - internal fun openBrowserLogin(): Boolean { + internal fun doBrowserLogin(): Boolean { if (apiConfig.credentialsType != Credentials.Type.OAUTH || signInTask != null && signInTask!!.status == AsyncTask.Status.RUNNING) return true val intent = Intent(this, BrowserSignInActivity::class.java) @@ -322,10 +326,6 @@ class SignInActivity : BaseActivity(), OnClickListener, TextWatcher, APIEditorDi if (signInTask != null && signInTask!!.status == AsyncTask.Status.RUNNING) { signInTask!!.cancel(true) } - if (apiConfig.credentialsType == Credentials.Type.OAUTH) { - openBrowserLogin() - return - } val username = editUsername.text.toString() val password = editPassword.text.toString() @@ -435,7 +435,7 @@ class SignInActivity : BaseActivity(), OnClickListener, TextWatcher, APIEditorDi } } - private fun doBrowserLogin(intent: Intent?) { + private fun handleBrowserLoginResult(intent: Intent?) { if (intent == null) return if (signInTask?.status == AsyncTask.Status.RUNNING) { signInTask?.cancel(true) diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/extension/model/AccountDetailsExtensions.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/extension/model/AccountDetailsExtensions.kt index 6f80cdc91..acbc935ee 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/extension/model/AccountDetailsExtensions.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/extension/model/AccountDetailsExtensions.kt @@ -34,10 +34,13 @@ val AccountExtras.official: Boolean @JvmOverloads -fun AccountDetails.newMicroBlogInstance(context: Context, includeEntities: Boolean = true, includeRetweets: Boolean = true, - extraRequestParams: Map? = - MicroBlogAPIFactory.getExtraParams(type, includeEntities, includeRetweets), - cls: Class): T { +fun AccountDetails.newMicroBlogInstance( + context: Context, + includeEntities: Boolean = true, + includeRetweets: Boolean = true, + extraRequestParams: Map? = MicroBlogAPIFactory.getExtraParams(type, includeEntities, includeRetweets), + cls: Class +): T { return credentials.newMicroBlogInstance(context, type == AccountType.TWITTER, extraRequestParams, cls) } diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/extension/model/CredentialsExtensions.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/extension/model/CredentialsExtensions.kt index 7fadc4774..b3cf41997 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/extension/model/CredentialsExtensions.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/extension/model/CredentialsExtensions.kt @@ -99,20 +99,24 @@ fun Credentials.getEndpoint(cls: Class<*>): Endpoint { return Endpoint(endpointUrl) } -fun Credentials.newMicroBlogInstance(context: Context, - twitterExtraQueries: Boolean = true, - extraRequestParams: Map? = null, - cls: Class): T { +fun Credentials.newMicroBlogInstance( + context: Context, + twitterExtraQueries: Boolean = true, + extraRequestParams: Map? = null, + cls: Class +): T { return newMicroBlogInstance(context, getEndpoint(cls), getAuthorization(), twitterExtraQueries, extraRequestParams, cls) } -fun newMicroBlogInstance(context: Context, - endpoint: Endpoint, - auth: Authorization, - twitterExtraQueries: Boolean = true, - extraRequestParams: Map? = null, - cls: Class): T { +fun newMicroBlogInstance( + context: Context, + endpoint: Endpoint, + auth: Authorization, + twitterExtraQueries: Boolean = true, + extraRequestParams: Map? = null, + cls: Class +): T { val factory = RestAPIFactory() val userAgent: String if (auth is OAuthAuthorization) { diff --git a/twidere/src/main/res/layout/dialog_password_sign_in.xml b/twidere/src/main/res/layout/dialog_password_sign_in.xml index 28967835b..887dac165 100644 --- a/twidere/src/main/res/layout/dialog_password_sign_in.xml +++ b/twidere/src/main/res/layout/dialog_password_sign_in.xml @@ -1,6 +1,7 @@ + app:backgroundTint="?colorAccent"/> + app:backgroundTint="?colorAccent"/> \ No newline at end of file