fix(captcha): show challenge in centered dialog#6455
Conversation
0a7a9f2 to
b4d3bf8
Compare
There was a problem hiding this comment.
Pull request overview
This PR refactors captcha presentation to use a centered, rounded dialog (instead of a full-screen takeover), and adds a debug-only captcha preview entry to help validate different captcha providers without submitting tokens to the backend.
Changes:
- Rework
CaptchaViewto render captcha challenges inside a centeredDialogwith a dedicated close button and improved teardown/cleanup. - Add a debug entry (“Preview Captcha”) that opens a bottom sheet to launch GCaptcha/HCaptcha/GeeTest previews.
- Update captcha HTML styling and add new localized strings for the preview UI and toast messaging.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| app/src/main/res/values/strings.xml | Adds English strings for captcha preview UI and token-received toast. |
| app/src/main/res/values-zh-rCN/strings.xml | Adds Simplified Chinese strings for captcha preview UI and token-received toast. |
| app/src/main/res/layout/view_captcha_preview_bottom.xml | New bottom-sheet layout listing captcha provider options for debug preview. |
| app/src/main/res/layout/fragment_log_debug.xml | Adds a debug menu entry to open the captcha preview bottom sheet. |
| app/src/main/java/one/mixin/android/widget/CaptchaView.kt | Major refactor: show captcha in centered dialog with close button, progress bar, fallback/timeout handling, and lifecycle cleanup. |
| app/src/main/java/one/mixin/android/ui/setting/LogAndDebugFragment.kt | Wires up debug captcha preview bottom sheet and launches CaptchaView in no-fallback mode. |
| app/src/main/java/one/mixin/android/ui/setting/delete/DeleteAccountFragment.kt | Switches captcha teardown to release() and removes manual WebView attachment/back handling. |
| app/src/main/java/one/mixin/android/ui/landing/VerificationFragment.kt | Switches captcha hiding/teardown to dialog-based hide()/release() and removes manual WebView attachment/back handling. |
| app/src/main/java/one/mixin/android/ui/landing/MobileFragment.kt | Adds captcha release() on view teardown and removes manual WebView attachment/back handling. |
| app/src/main/java/one/mixin/android/ui/landing/MnemonicPhraseFragment.kt | Adds captcha release() on view teardown; updates stop handling to set failure state; removes manual WebView attachment. |
| app/src/main/assets/captcha.html | Adds CSS to better size captcha content within the new dialog container. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if (!fallbackEnabled) { | ||
| updateProgress(100) | ||
| callback.onStop() | ||
| return | ||
| } |
| if (released) return | ||
| if (value.isBlank()) return | ||
| Timber.e("$TAG postMessage captchaType=$captchaType value=$value") | ||
| cancelRunOnUiThread(stopWebViewRunnable) |
| internal data class CaptchaDialogBarStyle( | ||
| val heightDp: Int, | ||
| @DrawableRes val closeIconResId: Int, | ||
| val closeIconGravity: Int, | ||
| val cornerRadiusDp: Int, | ||
| val progressBelowBar: Boolean, | ||
| ) | ||
|
|
||
| internal fun captchaDialogBarStyle() = | ||
| CaptchaDialogBarStyle( | ||
| heightDp = 48, | ||
| closeIconResId = R.drawable.ic_circle_close, | ||
| closeIconGravity = Gravity.END or Gravity.CENTER_VERTICAL, | ||
| cornerRadiusDp = 12, | ||
| progressBelowBar = true, | ||
| ) |
| override fun onPostToken(value: Pair<CaptchaView.CaptchaType, String>) { | ||
| toast(getString(R.string.Captcha_Preview_Token_Received, value.first.name)) | ||
| } |
|
@copilot resolve the merge conflicts in this pull request |
…l-logs # Conflicts: # app/src/main/java/one/mixin/android/ui/setting/LogAndDebugFragment.kt
Merge conflicts resolved in commit |
CaptchaViewclose button usingR.drawable.ic_circle_close, with proper dialog cleanup on close, dismiss, and fragment teardown.