Skip to content

Commit 47eced7

Browse files
Sentinel-AndroidTheLastProject
authored andcommitted
Copy Value button in the dialog box
1 parent fb8543a commit 47eced7

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

app/src/main/java/protect/card_locker/LoyaltyCardViewActivity.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,13 @@ protected void onResume() {
708708
AlertDialog.Builder builder = new MaterialAlertDialogBuilder(LoyaltyCardViewActivity.this);
709709
builder.setTitle(R.string.cardId);
710710
builder.setView(cardIdView);
711-
builder.setPositiveButton(R.string.ok, (dialogInterface, i) -> dialogInterface.dismiss());
711+
builder.setPositiveButton(R.string.copy_value, (dialog, which) -> {
712+
ClipboardManager cm = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
713+
cm.setPrimaryClip(ClipData.newPlainText("QR value", loyaltyCard.cardId));
714+
// Optional app toast; comment out if you rely on Android's privacy toast only
715+
Toast.makeText(this, R.string.copied_to_clipboard, Toast.LENGTH_SHORT).show();
716+
});
717+
builder.setNegativeButton(android.R.string.ok, (dialog, which) -> dialog.dismiss());
712718
AlertDialog dialog = builder.create();
713719
dialog.show();
714720
});

0 commit comments

Comments
 (0)