Skip to content

Conversation

@Sentinel-Android
Copy link

What’s new

  • Adds Copy value option to the card-view overflow menu.
  • Copies the card’s cardId to the system clipboard via ClipboardManager.
  • New strings: copy_value, copied_to_clipboard, nothing_to_copy.
  • Placed inside existing overflow submenu → no extra toolbar icons.

UX

  1. Open any card.
  2. Tap ⋮ → Copy value.
  3. OS clipboard toast appears -> paste confirms number.

Build variants tested

  • fossDebug on API 34 emulator
  • Feature is in src/main, so it ships with gplay* too.

No database or schema changes; 100 % additive.

* New menu item 'Copy value' (overflow only)
* Helper copies cardId to system clipboard
* Strings added: copy_value, copied_to_clipboard, nothing_to_copy
* No UI regression; tested on fossDebug
@TheLastProject TheLastProject linked an issue Oct 22, 2025 that may be closed by this pull request
@TheLastProject
Copy link
Member

From a quick check this probably works, but is there any reason you haven't added this to the dialog that appears when tapping the barcode as decided in #2400?

@Sentinel-Android
Copy link
Author

Sentinel-Android commented Oct 23, 2025 via email

@TheLastProject
Copy link
Member

I think it would be better to only implement that version (long-press + new button on the dialog on short press) to keep the menu simpler :)

@Sentinel-Android
Copy link
Author

Sentinel-Android commented Oct 23, 2025 via email

@Sentinel-Android
Copy link
Author

I have implemented the changes you suggested. Please check.

@Sentinel-Android
Copy link
Author

Sentinel-Android commented Oct 24, 2025 via email

builder.setPositiveButton(R.string.ok, (dialogInterface, i) -> dialogInterface.dismiss());
builder.setPositiveButton(R.string.copy_value, (dialog, which) -> {
ClipboardManager cm = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
cm.setPrimaryClip(ClipData.newPlainText("QR value", loyaltyCard.cardId));
Copy link
Member

Choose a reason for hiding this comment

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

"QR value" should be translatable. I think it makes more sense to use the cardId translatable

builder.setTitle(R.string.cardId);
builder.setView(cardIdView);
builder.setPositiveButton(R.string.ok, (dialogInterface, i) -> dialogInterface.dismiss());
builder.setPositiveButton(R.string.copy_value, (dialog, which) -> {
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure if this makes sense as the positive button, the default action probably shouldn't be to copy to clipboard.

Comment on lines +927 to +929
return true;
} else if (id == R.id.action_copy_value) {
copyValueToClipboard(); // <— helper you added earlier
Copy link
Member

Choose a reason for hiding this comment

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

As discussed: not in the 3 dots menu please.

}

ClipboardManager cm = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
ClipData clip = ClipData.newPlainText("Card value", value);
Copy link
Member

Choose a reason for hiding this comment

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

Let's also use the cardId translatable here.

Copy link
Member

Choose a reason for hiding this comment

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

Not needed because we don't want this in the menu

Comment on lines +30 to +34
<item
android:id="@+id/action_copy_value"
android:title="@string/copy_value"
app:showAsAction="ifRoom" />

Copy link
Member

Choose a reason for hiding this comment

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

Also should be removed because we don't want it in the menu

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.

Copy the value of the barcode by pressing on it

2 participants