forked from github/szkolny
[Login/Captcha] Update captcha to fit smaller screens. Fix Librus invalid login error with captcha.
This commit is contained in:
parent
f6f1370edf
commit
54121c99a3
@ -144,18 +144,14 @@ class LibrusLoginPortal(val data: DataLibrus, val onSuccess: () -> Unit) {
|
||||
.withResponse(response))
|
||||
return
|
||||
}
|
||||
if (json.getBoolean("captchaRequired") == true) {
|
||||
data.error(ApiError(TAG, ERROR_CAPTCHA_LIBRUS_PORTAL)
|
||||
.withResponse(response)
|
||||
.withApiResponse(json))
|
||||
return
|
||||
}
|
||||
val error = if (response.code() == 200) null else
|
||||
json.getJsonArray("errors")?.getString(0)
|
||||
error?.let { code ->
|
||||
when {
|
||||
code.contains("Sesja logowania wygasła") -> ERROR_LOGIN_LIBRUS_PORTAL_CSRF_EXPIRED
|
||||
code.contains("Upewnij się, że nie") -> ERROR_LOGIN_LIBRUS_PORTAL_INVALID_LOGIN
|
||||
// this doesn't work anyway: `errors` is an object with `g-recaptcha-response` set
|
||||
code.contains("robotem") -> ERROR_CAPTCHA_LIBRUS_PORTAL
|
||||
else -> ERROR_LOGIN_LIBRUS_PORTAL_ACTION_ERROR
|
||||
}.let { errorCode ->
|
||||
data.error(ApiError(TAG, errorCode)
|
||||
@ -164,6 +160,12 @@ class LibrusLoginPortal(val data: DataLibrus, val onSuccess: () -> Unit) {
|
||||
return
|
||||
}
|
||||
}
|
||||
if (json.getBoolean("captchaRequired") == true) {
|
||||
data.error(ApiError(TAG, ERROR_CAPTCHA_LIBRUS_PORTAL)
|
||||
.withResponse(response)
|
||||
.withApiResponse(json))
|
||||
return
|
||||
}
|
||||
authorize(json.getString("redirect", LIBRUS_AUTHORIZE_URL))
|
||||
}
|
||||
|
||||
|
@ -46,6 +46,12 @@ public class CheckableImageView extends AppCompatImageView implements Checkable
|
||||
return drawableState;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||
setMeasuredDimension(getMeasuredWidth(), getMeasuredWidth());
|
||||
}
|
||||
|
||||
@Override public void toggle() {
|
||||
setChecked(!checked);
|
||||
}
|
||||
|
@ -7,7 +7,7 @@
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="386dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
@ -39,30 +39,32 @@
|
||||
</LinearLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/payload"
|
||||
android:layout_width="386dp"
|
||||
android:layout_height="386dp"
|
||||
android:scaleType="centerCrop"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:scaleType="fitXY"
|
||||
android:adjustViewBounds="true"
|
||||
tools:srcCompat="@tools:sample/backgrounds/scenic[1]" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="386dp"
|
||||
android:layout_height="386dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<pl.szczodrzynski.edziennik.utils.CheckableImageView
|
||||
android:id="@+id/image0"
|
||||
android:layout_width="126dp"
|
||||
android:layout_height="126dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:clickable="true"
|
||||
android:background="@drawable/recaptcha_image"
|
||||
android:focusable="true" />
|
||||
@ -75,7 +77,8 @@
|
||||
<pl.szczodrzynski.edziennik.utils.CheckableImageView
|
||||
android:id="@+id/image1"
|
||||
android:layout_width="126dp"
|
||||
android:layout_height="126dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:clickable="true"
|
||||
android:background="@drawable/recaptcha_image"
|
||||
android:focusable="true" />
|
||||
@ -88,7 +91,8 @@
|
||||
<pl.szczodrzynski.edziennik.utils.CheckableImageView
|
||||
android:id="@+id/image2"
|
||||
android:layout_width="126dp"
|
||||
android:layout_height="126dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:clickable="true"
|
||||
android:background="@drawable/recaptcha_image"
|
||||
android:focusable="true" />
|
||||
@ -100,14 +104,15 @@
|
||||
android:background="?colorSurface" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<pl.szczodrzynski.edziennik.utils.CheckableImageView
|
||||
android:id="@+id/image3"
|
||||
android:layout_width="126dp"
|
||||
android:layout_height="126dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:clickable="true"
|
||||
android:background="@drawable/recaptcha_image"
|
||||
android:focusable="true" />
|
||||
@ -120,7 +125,8 @@
|
||||
<pl.szczodrzynski.edziennik.utils.CheckableImageView
|
||||
android:id="@+id/image4"
|
||||
android:layout_width="126dp"
|
||||
android:layout_height="126dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:clickable="true"
|
||||
android:background="@drawable/recaptcha_image"
|
||||
android:focusable="true" />
|
||||
@ -133,7 +139,8 @@
|
||||
<pl.szczodrzynski.edziennik.utils.CheckableImageView
|
||||
android:id="@+id/image5"
|
||||
android:layout_width="126dp"
|
||||
android:layout_height="126dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:clickable="true"
|
||||
android:background="@drawable/recaptcha_image"
|
||||
android:focusable="true" />
|
||||
@ -145,14 +152,15 @@
|
||||
android:background="?colorSurface" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<pl.szczodrzynski.edziennik.utils.CheckableImageView
|
||||
android:id="@+id/image6"
|
||||
android:layout_width="126dp"
|
||||
android:layout_height="126dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:clickable="true"
|
||||
android:background="@drawable/recaptcha_image"
|
||||
android:focusable="true" />
|
||||
@ -165,7 +173,8 @@
|
||||
<pl.szczodrzynski.edziennik.utils.CheckableImageView
|
||||
android:id="@+id/image7"
|
||||
android:layout_width="126dp"
|
||||
android:layout_height="126dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:clickable="true"
|
||||
android:background="@drawable/recaptcha_image"
|
||||
android:focusable="true" />
|
||||
@ -178,7 +187,8 @@
|
||||
<pl.szczodrzynski.edziennik.utils.CheckableImageView
|
||||
android:id="@+id/image8"
|
||||
android:layout_width="126dp"
|
||||
android:layout_height="126dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:clickable="true"
|
||||
android:background="@drawable/recaptcha_image"
|
||||
android:focusable="true" />
|
||||
|
@ -13,7 +13,7 @@
|
||||
android:paddingRight="16dp"
|
||||
android:paddingBottom="8dp">
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
android:layout_width="304dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="78dp"
|
||||
android:layout_gravity="center"
|
||||
android:layout_margin="8dp"
|
||||
|
Loading…
Reference in New Issue
Block a user