Skip to content

Commit

Permalink
Merge pull request TrixiEther#87 from Sweetsound/2ch-emoji-captcha-fo…
Browse files Browse the repository at this point in the history
…rce-white-bg

Fix 2ch emoji_captcha for dark theme
  • Loading branch information
TrixiEther authored Sep 12, 2024
2 parents b525a84 + ed0fc1b commit 8f5f69a
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ private ChanPerformer.ReadCaptchaResult solveEmojiCaptchaLoop(
int maxSize = Math.max(origKeyIcon.getHeight(), origKeyIcon.getWidth());
Bitmap keyBitmap = Bitmap.createBitmap(maxSize, maxSize, Bitmap.Config.ARGB_8888);
Canvas keyCanvas = new Canvas(keyBitmap);
// set key background to white so the black icon would not overlap with dark theme
keyCanvas.drawARGB(255, 255, 255, 255);
int x = Math.max((origKeyIcon.getHeight() - origKeyIcon.getWidth()) / 2, 0);
int y = Math.max((origKeyIcon.getWidth() - origKeyIcon.getHeight()) / 2, 0);
keyCanvas.drawBitmap(origKeyIcon, x, y, null);
Expand Down Expand Up @@ -227,6 +229,12 @@ private Bitmap createTaskWithSelectedBitmap(Bitmap captchaImage, SelectedEmojis
comboBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
Canvas comboImage = new Canvas(comboBitmap);

// Ensure that captcha has white background, so we will have black
// selected icons on white canvas, despite of app theme
if (!selected.bitmaps.isEmpty()) {
comboImage.drawARGB(255, 255, 255, 255);
}

for (int i = 0; i < selected.bitmaps.size(); i++) {
comboImage.drawBitmap(selected.bitmaps.get(i),
i * SelectedEmojis.SIZE_WITH_PADDING, 0f, null);
Expand Down

0 comments on commit 8f5f69a

Please sign in to comment.