Skip to content

Commit

Permalink
Convert the LoginClient to kotlin (#5479)
Browse files Browse the repository at this point in the history
* Convert the result classes to kotlin

* Convert response and callback to kotlin

* Cleanup code-quality warnings before converting

* Converted the LoginClient to kotlin

* Updated the UserExtendedInfoClientTest to be kotlin, and live in the correct spot
  • Loading branch information
psh authored Jan 27, 2024
1 parent 0541aac commit 02ce017
Show file tree
Hide file tree
Showing 14 changed files with 370 additions and 450 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,10 @@
import fr.free.nrw.commons.databinding.ActivityLoginBinding;
import fr.free.nrw.commons.utils.ActivityUtils;
import java.util.Locale;
import org.wikipedia.AppAdapter;
import org.wikipedia.dataclient.ServiceFactory;
import org.wikipedia.dataclient.WikiSite;
import org.wikipedia.dataclient.mwapi.MwQueryResponse;
import fr.free.nrw.commons.auth.login.LoginClient.LoginCallback;
import fr.free.nrw.commons.auth.login.LoginCallback;

import javax.inject.Inject;
import javax.inject.Named;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import org.wikipedia.dataclient.SharedPreferenceCookieManager
import org.wikipedia.dataclient.WikiSite
import org.wikipedia.dataclient.mwapi.MwQueryResponse
import fr.free.nrw.commons.auth.login.LoginClient
import fr.free.nrw.commons.auth.login.LoginClient.LoginCallback
import fr.free.nrw.commons.auth.login.LoginClient.LoginFailedException
import fr.free.nrw.commons.auth.login.LoginCallback
import fr.free.nrw.commons.auth.login.LoginFailedException
import fr.free.nrw.commons.auth.login.LoginResult
import retrofit2.Call
import retrofit2.Response
Expand Down Expand Up @@ -129,7 +129,7 @@ class CsrfTokenClient(
) = LoginClient()
.request(csrfWikiSite, username, password, object : LoginCallback {
override fun success(loginResult: LoginResult) {
if (loginResult.pass()) {
if (loginResult.pass) {
sessionManager.updateAccount(loginResult)
retryCallback()
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package fr.free.nrw.commons.auth.login

interface LoginCallback {
fun success(loginResult: LoginResult)
fun twoFactorPrompt(caught: Throwable, token: String?)
fun passwordResetPrompt(token: String?)
fun error(caught: Throwable)
}
259 changes: 0 additions & 259 deletions app/src/main/java/fr/free/nrw/commons/auth/login/LoginClient.java

This file was deleted.

Loading

0 comments on commit 02ce017

Please sign in to comment.