feat: Long-press copy button to choose raw or formatted body#1613
Merged
Conversation
Tap on the copy button in a transaction's request/response payload still copies the body verbatim, preserving the prior default. A long-press now opens a popup with explicit "Copy raw" and "Copy formatted" choices, the latter going through the existing pretty-printer. Adds matching toasts and Spanish/Russian translations; drops the now-unused chucker_request_copied / chucker_response_copied strings. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Adds a long-press copy affordance on the transaction payload screen so users can explicitly copy either the raw body or a pretty-printed (“formatted”) version, while keeping the existing tap-to-copy-raw behavior.
Changes:
- Extend the payload “copy” row to support both tap (default/raw) and long-press (popup menu) actions.
- Add a popup menu to choose between copying raw vs formatted request/response bodies.
- Add new menu + localized strings for the new copy options and toast messages.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
library/src/main/kotlin/com/chuckerteam/chucker/internal/ui/transaction/TransactionPayloadFragment.kt |
Wires tap-to-copy-raw and long-press popup; adds raw/formatted copy helpers and updated toast messages. |
library/src/main/kotlin/com/chuckerteam/chucker/internal/ui/transaction/TransactionPayloadAdapter.kt |
Adds a long-press callback on the copy button to open the popup menu. |
library/src/main/res/menu/chucker_copy_payload.xml |
New popup menu with “copy raw” and “copy formatted”. |
library/src/main/res/values/strings.xml |
Adds new copy option + toast strings; removes old generic copied strings. |
library/src/main/res/values-es/strings.xml |
Spanish translations for new copy option + toast strings. |
library/src/main/res/values-ru/strings.xml |
Russian translations for new copy option + toast strings. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Switches the copy popup to androidx.appcompat.widget.PopupMenu so it picks up AppCompat theming consistent with the rest of the screen, and moves getFormattedRequestBody / getFormattedResponseBody off the main thread via lifecycleScope + Dispatchers.Default to avoid jank on large JSON/XML bodies. The clipboard write and toast still run on the main thread once formatting completes. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
cortinico
reviewed
Apr 27, 2026
cortinico
left a comment
Member
There was a problem hiding this comment.
Can you also update the CHANGELOG.md file please?
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
cortinico
reviewed
Apr 28, 2026
- Rename copyDefault to copyRawPayWrapper for clarity - Restore Request Copied / Response Copied toasts for the raw path - Title-case new copy menu and toast strings (en/es/ru) - Add TransactionBodyAdapter tests covering tap, long-press, and menu inflation Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
cortinico
approved these changes
Apr 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The transaction payload screen has a single copy button next to each request/response body. Today, tapping it copies
transaction.requestBody/responseBodyverbatim — even though the body is rendered pretty-printed and syntax-highlighted on screen, so users often paste a one-line JSON blob and lose the on-screen formatting.This PR keeps the existing tap behaviour (copy raw body) and adds a long-press affordance that opens a popup with two explicit choices:
transaction.requestBody/responseBodyverbatim (same as the tap default).HttpTransaction.getFormattedRequestBody()/getFormattedResponseBody(), which delegates to the existingFormatUtils.formatJson/formatXml/formatUrlEncodedFormpretty-printers based on the recorded content type.Implementation notes
TransactionBodyAdapterconstructor now takes two callbacks:onCopyBodyListener: () -> Unit(tap) andonCopyMenuListener: (View) -> Unit(long-press, anchor for the popup).CopyViewHolderwires bothsetOnClickListenerandsetOnLongClickListeneronresponseCopy. Long-click consumes the event by returningtrue.TransactionPayloadFragmentreplacescopyResponse()with three private helpers —copyDefault(),copyRawPayload(transaction),copyFormattedPayload(transaction)— andshowCopyMenu(anchor)to inflateR.menu.chucker_copy_payloadviaPopupMenu. Thewhen (payloadType)is exhaustive, noelsebranch, mirroring the prior code.library/src/main/res/menu/chucker_copy_payload.xmlwithcopy_rawandcopy_formatteditems.chucker_copy_raw,chucker_copy_formatted, and per-mode toast strings (chucker_request_copied_raw,chucker_request_copied_formatted,chucker_response_copied_raw,chucker_response_copied_formatted) invalues/,values-es/, andvalues-ru/. Removed the now-unusedchucker_request_copied/chucker_response_copied. The pre-existingchucker_copy_responseis retained becausechucker_transaction_item_copy.xmlstill uses it as the copy button'scontentDescription.Behaviour matrix
requestBodyresponseBodyrequestBodyresponseBodygetFormattedRequestBody()getFormattedResponseBody()Bodies that are empty are skipped (no toast, no clipboard write).
Feature video
Screen_recording_20260427_161124.mp4
Test plan
./gradlew :library:assembleDebug(project requires JDK 21 — I was unable to run this locally; CI should validate).application/x-www-form-urlencodedbody to confirm the formatted path uses the right pretty-printer for each content type.values-es) and Russian (values-ru) toast strings render via locale switch.🤖 Generated with Claude Code