Review fixes

Also update google cookies to use dashchan ones
dev
k1rakishou 6 years ago
parent 6b865c246e
commit 2820d23ff7
  1. 9
      Clover/app/src/main/java/org/floens/chan/ui/captcha/v2/CaptchaNoJsHtmlParser.java
  2. 9
      Clover/app/src/main/java/org/floens/chan/ui/captcha/v2/CaptchaNoJsLayoutV2.java
  3. 14
      Clover/app/src/main/java/org/floens/chan/ui/captcha/v2/CaptchaNoJsPresenterV2.java
  4. 4
      Clover/app/src/main/java/org/floens/chan/ui/captcha/v2/CaptchaNoJsV2Adapter.java
  5. 16
      Clover/app/src/main/java/org/floens/chan/ui/layout/ReplyLayout.java
  6. 33
      Clover/app/src/main/res/layout/layout_captcha_challenge_image.xml
  7. 2
      Clover/app/src/main/res/values/strings.xml

@ -383,6 +383,15 @@ public class CaptchaNoJsHtmlParser {
} }
return resultImages; return resultImages;
} catch (Throwable error) {
for (Bitmap bitmap : resultImages) {
if (!bitmap.isRecycled()) {
bitmap.recycle();
}
}
resultImages.clear();
throw error;
} finally { } finally {
if (originalBitmap != null) { if (originalBitmap != null) {
originalBitmap.recycle(); originalBitmap.recycle();

@ -103,6 +103,8 @@ public class CaptchaNoJsLayoutV2 extends FrameLayout
captchaVerifyButton.setOnClickListener(this); captchaVerifyButton.setOnClickListener(this);
useOldCaptchaButton.setOnClickListener(this); useOldCaptchaButton.setOnClickListener(this);
reloadCaptchaButton.setOnClickListener(this); reloadCaptchaButton.setOnClickListener(this);
captchaVerifyButton.setEnabled(false);
} }
@Override @Override
@ -153,6 +155,7 @@ public class CaptchaNoJsLayoutV2 extends FrameLayout
// called on a background thread // called on a background thread
AndroidUtils.runOnUiThread(() -> { AndroidUtils.runOnUiThread(() -> {
captchaVerifyButton.setEnabled(true);
renderCaptchaWindow(captchaInfo); renderCaptchaWindow(captchaInfo);
}); });
} }
@ -162,6 +165,7 @@ public class CaptchaNoJsLayoutV2 extends FrameLayout
// called on a background thread // called on a background thread
AndroidUtils.runOnUiThread(() -> { AndroidUtils.runOnUiThread(() -> {
captchaVerifyButton.setEnabled(true);
callback.onAuthenticationComplete(this, null, verificationToken); callback.onAuthenticationComplete(this, null, verificationToken);
}); });
} }
@ -176,6 +180,7 @@ public class CaptchaNoJsLayoutV2 extends FrameLayout
String message = error.getMessage(); String message = error.getMessage();
showToast(message); showToast(message);
captchaVerifyButton.setEnabled(true);
callback.onFallbackToV1CaptchaView(); callback.onFallbackToV1CaptchaView();
}); });
} }
@ -224,6 +229,8 @@ public class CaptchaNoJsLayoutV2 extends FrameLayout
adapter.setImageSize(imageSize); adapter.setImageSize(imageSize);
adapter.setImages(captchaInfo.challengeImages); adapter.setImages(captchaInfo.challengeImages);
captchaVerifyButton.setEnabled(true);
} catch (Throwable error) { } catch (Throwable error) {
if (callback != null) { if (callback != null) {
callback.onFallbackToV1CaptchaView(); callback.onFallbackToV1CaptchaView();
@ -250,10 +257,10 @@ public class CaptchaNoJsLayoutV2 extends FrameLayout
List<Integer> selectedIds = adapter.getCheckedImageIds(); List<Integer> selectedIds = adapter.getCheckedImageIds();
try { try {
CaptchaNoJsPresenterV2.VerifyError verifyError = presenter.verify(selectedIds); CaptchaNoJsPresenterV2.VerifyError verifyError = presenter.verify(selectedIds);
switch (verifyError) { switch (verifyError) {
case Ok: case Ok:
captchaVerifyButton.setEnabled(false);
break; break;
case NoImagesSelected: case NoImagesSelected:
showToast(getContext().getString(R.string.captcha_layout_v2_you_have_to_select_at_least_one_image)); showToast(getContext().getString(R.string.captcha_layout_v2_you_have_to_select_at_least_one_image));

@ -54,10 +54,10 @@ public class CaptchaNoJsPresenterV2 {
// this should be updated once in 3 months IIRC // this should be updated once in 3 months IIRC
private static final String googleCookies = private static final String googleCookies =
"SID=NwcOCOnxA7PVDPUY_InSzz6saQ93BmWzg7N2276OPwUvtwXkLpfqbs1tYNkxNP0xC_Awmg.; " + "SID=gjaHjfFJPAN5HO3MVVZpjHFKa_249dsfjHa9klsiaflsd99.asHqjsM2lAS; " +
"HSID=AoZX0-3xQ7lN9EMEm; " + "HSID=j7m0aFJ82lPF7Hd9d; " +
"SSID=AWwVsHei8i4VlX3H4; " + "SSID=nJKpa81jOskq7Jsps; " +
"NID=182=ikM1ZwJ0tMSqCiJc8gdretZpOHCnUSsZ2oM7I681KmnkL0DKFOBmFU6zlmTMC_mDnPhBB5mQxsaB0ipTICW9WyCa9nLUbo1Bx-H9jFmOLNhr1E5EezqlyFZcBKEyZgjFYmaY79_5jHMa4uE6v_Vb8HR1Uk9CXbNfw_yIPEsZXZ0t0CURkV-CdxdOIiZ4BAy0oE6w60GJ9kLpOWWSeNZ_lBcn0PkWRj6vmRH6kKrl2exOKnk"; "NID=87=gkOAkg09AKnvJosKq82kgnDnHj8Om2pLskKhdna02msog8HkdHDlasDf";
// TODO: inject this in the future when https://github.com/Floens/Clover/pull/678 is merged // TODO: inject this in the future when https://github.com/Floens/Clover/pull/678 is merged
private final OkHttpClient okHttpClient = new OkHttpClient(); private final OkHttpClient okHttpClient = new OkHttpClient();
@ -127,6 +127,7 @@ public class CaptchaNoJsPresenterV2 {
public void onFailure(Call call, IOException e) { public void onFailure(Call call, IOException e) {
if (callbacks != null) { if (callbacks != null) {
try { try {
prevCaptchaInfo = null;
callbacks.onCaptchaInfoParseError(e); callbacks.onCaptchaInfoParseError(e);
} finally { } finally {
verificationInProgress.set(false); verificationInProgress.set(false);
@ -187,6 +188,7 @@ public class CaptchaNoJsPresenterV2 {
public void onFailure(Call call, IOException e) { public void onFailure(Call call, IOException e) {
if (callbacks != null) { if (callbacks != null) {
try { try {
prevCaptchaInfo = null;
callbacks.onCaptchaInfoParseError(e); callbacks.onCaptchaInfoParseError(e);
} finally { } finally {
captchaRequestInProgress.set(false); captchaRequestInProgress.set(false);
@ -295,6 +297,10 @@ public class CaptchaNoJsPresenterV2 {
if (callbacks != null) { if (callbacks != null) {
callbacks.onCaptchaInfoParsed(captchaInfo); callbacks.onCaptchaInfoParsed(captchaInfo);
} else {
// Return null when callbacks are null to reset prevCaptchaInfo so that we won't
// get stuck without captchaInfo and disabled buttons forever
return null;
} }
return captchaInfo; return captchaInfo;

@ -58,7 +58,7 @@ public class CaptchaNoJsV2Adapter extends BaseAdapter {
convertView = inflater.inflate(R.layout.layout_captcha_challenge_image, parent, false); convertView = inflater.inflate(R.layout.layout_captcha_challenge_image, parent, false);
AppCompatImageView imageView = convertView.findViewById(R.id.captcha_challenge_image); AppCompatImageView imageView = convertView.findViewById(R.id.captcha_challenge_image);
AppCompatImageView blueCheckmark = convertView.findViewById(R.id.captcha_challenge_blue_checkmark); ConstraintLayout blueCheckmarkHolder = convertView.findViewById(R.id.captcha_challenge_blue_checkmark_holder);
ConstraintLayout.LayoutParams layoutParams = new ConstraintLayout.LayoutParams(imageSize, imageSize); ConstraintLayout.LayoutParams layoutParams = new ConstraintLayout.LayoutParams(imageSize, imageSize);
imageView.setLayoutParams(layoutParams); imageView.setLayoutParams(layoutParams);
@ -68,7 +68,7 @@ public class CaptchaNoJsV2Adapter extends BaseAdapter {
boolean isChecked = imageList.get(position).isChecked; boolean isChecked = imageList.get(position).isChecked;
AndroidUtils.animateViewScale(imageView, isChecked, ANIMATION_DURATION); AndroidUtils.animateViewScale(imageView, isChecked, ANIMATION_DURATION);
blueCheckmark.setVisibility(isChecked ? View.VISIBLE : View.GONE); blueCheckmarkHolder.setVisibility(isChecked ? View.VISIBLE : View.GONE);
}); });
if (position >= 0 && position <= imageList.size()) { if (position >= 0 && position <= imageList.size()) {

@ -272,22 +272,22 @@ public class ReplyLayout extends LoadView implements View.OnClickListener, Reply
break; break;
} }
case CAPTCHA2_NOJS: case CAPTCHA2_NOJS:
if (!useV2NoJsCaptcha) { if (useV2NoJsCaptcha) {
// default webview-based captcha view
authenticationLayout = new CaptchaNojsLayoutV1(getContext());
} else {
// new captcha window without webview // new captcha window without webview
authenticationLayout = new CaptchaNoJsLayoutV2(getContext()); authenticationLayout = new CaptchaNoJsLayoutV2(getContext());
} else {
// default webview-based captcha view
authenticationLayout = new CaptchaNojsLayoutV1(getContext());
} }
ImageView resetButton = captchaContainer.findViewById(R.id.reset); ImageView resetButton = captchaContainer.findViewById(R.id.reset);
if (resetButton != null) { if (resetButton != null) {
if (!useV2NoJsCaptcha) { if (useV2NoJsCaptcha) {
// restore the button's visibility when using old v1 captcha view
resetButton.setVisibility(View.VISIBLE);
} else {
// we don't need the default reset button because we have our own // we don't need the default reset button because we have our own
resetButton.setVisibility(View.GONE); resetButton.setVisibility(View.GONE);
} else {
// restore the button's visibility when using old v1 captcha view
resetButton.setVisibility(View.VISIBLE);
} }
} }

@ -14,16 +14,37 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
<android.support.v7.widget.AppCompatImageView <android.support.constraint.ConstraintLayout
android:id="@+id/captcha_challenge_blue_checkmark" android:id="@+id/captcha_challenge_blue_checkmark_holder"
android:layout_width="32dp" android:layout_width="wrap_content"
android:layout_height="32dp" android:layout_height="wrap_content"
android:layout_marginStart="8dp" android:layout_marginStart="8dp"
android:layout_marginLeft="8dp" android:layout_marginLeft="8dp"
android:layout_marginTop="8dp" android:layout_marginTop="8dp"
android:visibility="gone" android:visibility="gone"
android:src="@drawable/ic_blue_checkmark_24dp"
app:layout_constraintStart_toStartOf="@+id/captcha_challenge_image" app:layout_constraintStart_toStartOf="@+id/captcha_challenge_image"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="@+id/captcha_challenge_image">
<View
android:layout_width="18dp"
android:layout_height="18dp"
android:background="#fff"
app:layout_constraintBottom_toBottomOf="@+id/captcha_challenge_blue_checkmark"
app:layout_constraintEnd_toEndOf="@+id/captcha_challenge_blue_checkmark"
app:layout_constraintStart_toStartOf="@+id/captcha_challenge_blue_checkmark"
app:layout_constraintTop_toTopOf="@+id/captcha_challenge_blue_checkmark" />
<android.support.v7.widget.AppCompatImageView
android:id="@+id/captcha_challenge_blue_checkmark"
android:layout_width="32dp"
android:layout_height="32dp"
android:src="@drawable/ic_blue_checkmark_24dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>
</android.support.constraint.ConstraintLayout> </android.support.constraint.ConstraintLayout>

@ -580,7 +580,7 @@ Don't have a 4chan Pass?<br>
<string name="captcha_layout_v2_verify_button_text" tools:ignore="MissingTranslation">Verify</string> <string name="captcha_layout_v2_verify_button_text" tools:ignore="MissingTranslation">Verify</string>
<string name="captcha_layout_v2_reload" tools:ignore="MissingTranslation">Reload</string> <string name="captcha_layout_v2_reload" tools:ignore="MissingTranslation">Reload</string>
<string name="captcha_layout_v2_use_old_captcha" tools:ignore="MissingTranslation">Use old captcha</string> <string name="captcha_layout_v2_use_old_captcha" tools:ignore="MissingTranslation">Use old captcha</string>
<string name="captcha_layout_v2_you_have_to_select_at_least_one_image" tools:ignore="MissingTranslation">You have to selected at least one image (if you see a captcha that does not have any matching images then it is probably a bug fill an issue and use old captcha for a while)</string> <string name="captcha_layout_v2_you_have_to_select_at_least_one_image" tools:ignore="MissingTranslation">You have to select at least one image (if you see a captcha that does not have any matching images then it is probably a bug fill an issue and use old captcha for a while)</string>
<string name="captcha_layout_v2_verification_already_in_progress" tools:ignore="MissingTranslation">Verification is already in progress</string> <string name="captcha_layout_v2_verification_already_in_progress" tools:ignore="MissingTranslation">Verification is already in progress</string>
<string name="captcha_layout_v2_captcha_request_is_already_in_progress" tools:ignore="MissingTranslation">Captcha request is already in progress</string> <string name="captcha_layout_v2_captcha_request_is_already_in_progress" tools:ignore="MissingTranslation">Captcha request is already in progress</string>
<string name="captcha_layout_v2_you_are_requesting_captcha_too_fast" tools:ignore="MissingTranslation">You are requesting captcha too fast</string> <string name="captcha_layout_v2_you_are_requesting_captcha_too_fast" tools:ignore="MissingTranslation">You are requesting captcha too fast</string>

Loading…
Cancel
Save