Skip to content

Commit 02ce017

Browse files
authored
Convert the LoginClient to kotlin (commons-app#5479)
* 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
1 parent 0541aac commit 02ce017

File tree

14 files changed

+370
-450
lines changed

14 files changed

+370
-450
lines changed

app/src/main/java/fr/free/nrw/commons/auth/LoginActivity.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,10 @@
3131
import fr.free.nrw.commons.databinding.ActivityLoginBinding;
3232
import fr.free.nrw.commons.utils.ActivityUtils;
3333
import java.util.Locale;
34-
import org.wikipedia.AppAdapter;
3534
import org.wikipedia.dataclient.ServiceFactory;
3635
import org.wikipedia.dataclient.WikiSite;
3736
import org.wikipedia.dataclient.mwapi.MwQueryResponse;
38-
import fr.free.nrw.commons.auth.login.LoginClient.LoginCallback;
37+
import fr.free.nrw.commons.auth.login.LoginCallback;
3938

4039
import javax.inject.Inject;
4140
import javax.inject.Named;

app/src/main/java/fr/free/nrw/commons/auth/csrf/CsrfTokenClient.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import org.wikipedia.dataclient.SharedPreferenceCookieManager
88
import org.wikipedia.dataclient.WikiSite
99
import org.wikipedia.dataclient.mwapi.MwQueryResponse
1010
import fr.free.nrw.commons.auth.login.LoginClient
11-
import fr.free.nrw.commons.auth.login.LoginClient.LoginCallback
12-
import fr.free.nrw.commons.auth.login.LoginClient.LoginFailedException
11+
import fr.free.nrw.commons.auth.login.LoginCallback
12+
import fr.free.nrw.commons.auth.login.LoginFailedException
1313
import fr.free.nrw.commons.auth.login.LoginResult
1414
import retrofit2.Call
1515
import retrofit2.Response
@@ -129,7 +129,7 @@ class CsrfTokenClient(
129129
) = LoginClient()
130130
.request(csrfWikiSite, username, password, object : LoginCallback {
131131
override fun success(loginResult: LoginResult) {
132-
if (loginResult.pass()) {
132+
if (loginResult.pass) {
133133
sessionManager.updateAccount(loginResult)
134134
retryCallback()
135135
} else {
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package fr.free.nrw.commons.auth.login
2+
3+
interface LoginCallback {
4+
fun success(loginResult: LoginResult)
5+
fun twoFactorPrompt(caught: Throwable, token: String?)
6+
fun passwordResetPrompt(token: String?)
7+
fun error(caught: Throwable)
8+
}

app/src/main/java/fr/free/nrw/commons/auth/login/LoginClient.java

Lines changed: 0 additions & 259 deletions
This file was deleted.

0 commit comments

Comments
 (0)