@@ -708,13 +708,10 @@ 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 .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 ();
711+ builder .setPositiveButton (android .R .string .ok , (dialog , which ) -> dialog .dismiss ());
712+ builder .setNeutralButton (R .string .copy_value , (dialog , which ) -> {
713+ copyValueToClipboard ();
716714 });
717- builder .setNegativeButton (android .R .string .ok , (dialog , which ) -> dialog .dismiss ());
718715 AlertDialog dialog = builder .create ();
719716 dialog .show ();
720717 });
@@ -924,9 +921,6 @@ public boolean onOptionsItemSelected(MenuItem item) {
924921 AlertDialog dialog = builder .create ();
925922 dialog .show ();
926923
927- return true ;
928- } else if (id == R .id .action_copy_value ) {
929- copyValueToClipboard (); // <— helper you added earlier
930924 return true ;
931925 }
932926
@@ -1271,10 +1265,9 @@ private void copyValueToClipboard() {
12711265 }
12721266
12731267 ClipboardManager cm = (ClipboardManager ) getSystemService (CLIPBOARD_SERVICE );
1274- ClipData clip = ClipData .newPlainText ("Card value" , value );
1268+ ClipData clip = ClipData .newPlainText (getString ( R . string . cardId ) , value );
12751269 cm .setPrimaryClip (clip );
12761270
12771271 Toast .makeText (this , R .string .copied_to_clipboard , Toast .LENGTH_SHORT ).show ();
12781272 }
1279-
12801273}
0 commit comments