From ed0fc1b797b33141bc501487988db8a8fbda4a08 Mon Sep 17 00:00:00 2001 From: Sweetsound <poisonawaits@gmail.com> Date: Mon, 9 Sep 2024 18:33:06 +0300 Subject: [PATCH] Fix 2ch emoji_captcha for dark theme --- .../dashchan/chan/dvach/DvachEmojiCaptchaProvider.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/extensions/dvach/src/com/mishiranu/dashchan/chan/dvach/DvachEmojiCaptchaProvider.java b/extensions/dvach/src/com/mishiranu/dashchan/chan/dvach/DvachEmojiCaptchaProvider.java index 454e9fd5..ed1a4887 100644 --- a/extensions/dvach/src/com/mishiranu/dashchan/chan/dvach/DvachEmojiCaptchaProvider.java +++ b/extensions/dvach/src/com/mishiranu/dashchan/chan/dvach/DvachEmojiCaptchaProvider.java @@ -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); @@ -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);