Skip to content

fix(captcha): show challenge in centered dialog#6455

Open
SeniorZhai wants to merge 4 commits into
masterfrom
fix/captcha-critical-logs
Open

fix(captcha): show challenge in centered dialog#6455
SeniorZhai wants to merge 4 commits into
masterfrom
fix/captcha-critical-logs

Conversation

@SeniorZhai

@SeniorZhai SeniorZhai commented Jun 15, 2026

Copy link
Copy Markdown
Member
  • Show captcha challenges inside a centered rounded dialog instead of taking over the full screen.
  • Add a dedicated CaptchaView close button using R.drawable.ic_circle_close, with proper dialog cleanup on close, dismiss, and fragment teardown.
  • Keep captcha timeout fallback behavior for normal flows, while allowing the debug preview to load a specific captcha type without falling back.
  • Add one debug page entry for captcha preview; tapping it opens a bottom sheet with GCaptcha, HCaptcha, and GeeTest options.
  • The debug preview does not submit captcha tokens to the backend; it only shows a local toast when a token is received.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 CaptchaView to render captcha challenges inside a centered Dialog with 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.

Comment on lines +322 to +326
if (!fallbackEnabled) {
updateProgress(100)
callback.onStop()
return
}
Comment on lines +441 to 444
if (released) return
if (value.isBlank()) return
Timber.e("$TAG postMessage captchaType=$captchaType value=$value")
cancelRunOnUiThread(stopWebViewRunnable)
Comment on lines +44 to +59
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,
)
Comment on lines +228 to +230
override fun onPostToken(value: Pair<CaptchaView.CaptchaType, String>) {
toast(getString(R.string.Captcha_Preview_Token_Received, value.first.name))
}
@SeniorZhai

Copy link
Copy Markdown
Member Author

@copilot resolve the merge conflicts in this pull request

…l-logs

# Conflicts:
#	app/src/main/java/one/mixin/android/ui/setting/LogAndDebugFragment.kt

Copilot AI commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

@copilot resolve the merge conflicts in this pull request

Merge conflicts resolved in commit 0fd72b6. The only conflict was in LogAndDebugFragment.kt — I kept the captcha preview functions from this branch (onDestroyView, showCaptchaPreviewBottom, previewCaptcha) alongside the new resetDebugSharedPreferences and debugSharedPreferenceKeys functions from master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants