Skip to content

Commit 8f5f69a

Browse files
authored
Merge pull request #87 from Sweetsound/2ch-emoji-captcha-force-white-bg
Fix 2ch emoji_captcha for dark theme
2 parents b525a84 + ed0fc1b commit 8f5f69a

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

extensions/dvach/src/com/mishiranu/dashchan/chan/dvach/DvachEmojiCaptchaProvider.java

+8
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ private ChanPerformer.ReadCaptchaResult solveEmojiCaptchaLoop(
101101
int maxSize = Math.max(origKeyIcon.getHeight(), origKeyIcon.getWidth());
102102
Bitmap keyBitmap = Bitmap.createBitmap(maxSize, maxSize, Bitmap.Config.ARGB_8888);
103103
Canvas keyCanvas = new Canvas(keyBitmap);
104+
// set key background to white so the black icon would not overlap with dark theme
105+
keyCanvas.drawARGB(255, 255, 255, 255);
104106
int x = Math.max((origKeyIcon.getHeight() - origKeyIcon.getWidth()) / 2, 0);
105107
int y = Math.max((origKeyIcon.getWidth() - origKeyIcon.getHeight()) / 2, 0);
106108
keyCanvas.drawBitmap(origKeyIcon, x, y, null);
@@ -227,6 +229,12 @@ private Bitmap createTaskWithSelectedBitmap(Bitmap captchaImage, SelectedEmojis
227229
comboBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
228230
Canvas comboImage = new Canvas(comboBitmap);
229231

232+
// Ensure that captcha has white background, so we will have black
233+
// selected icons on white canvas, despite of app theme
234+
if (!selected.bitmaps.isEmpty()) {
235+
comboImage.drawARGB(255, 255, 255, 255);
236+
}
237+
230238
for (int i = 0; i < selected.bitmaps.size(); i++) {
231239
comboImage.drawBitmap(selected.bitmaps.get(i),
232240
i * SelectedEmojis.SIZE_WITH_PADDING, 0f, null);

0 commit comments

Comments
 (0)