diff --git a/src/main/java/org/thoughtcrime/securesms/qr/QrActivity.java b/src/main/java/org/thoughtcrime/securesms/qr/QrActivity.java index 75d14b70d..fc8a8069c 100644 --- a/src/main/java/org/thoughtcrime/securesms/qr/QrActivity.java +++ b/src/main/java/org/thoughtcrime/securesms/qr/QrActivity.java @@ -113,9 +113,12 @@ public boolean onPrepareOptionsMenu(Menu menu) { menu.clear(); getMenuInflater().inflate(R.menu.qr_show, menu); menu.findItem(R.id.new_classic_contact).setVisible(!DcHelper.getContext(this).isChatmail()); + + Util.redMenuItem(menu, R.id.withdraw); if(tabLayout.getSelectedTabPosition() == TAB_SCAN) { menu.findItem(R.id.withdraw).setVisible(false); } + return super.onPrepareOptionsMenu(menu); } diff --git a/src/main/java/org/thoughtcrime/securesms/qr/QrCodeHandler.java b/src/main/java/org/thoughtcrime/securesms/qr/QrCodeHandler.java index 25c021744..5a2c934b6 100644 --- a/src/main/java/org/thoughtcrime/securesms/qr/QrCodeHandler.java +++ b/src/main/java/org/thoughtcrime/securesms/qr/QrCodeHandler.java @@ -115,35 +115,27 @@ public void handleQrData(String rawString) { break; case DcContext.DC_QR_WITHDRAW_VERIFYCONTACT: - builder.setMessage(activity.getString(R.string.withdraw_verifycontact_explain)); - builder.setPositiveButton(R.string.withdraw_qr_code, (dialog, which) -> { - dcContext.setConfigFromQr(rawString); - }); - builder.setNegativeButton(R.string.cancel, null); - break; - - case DcContext.DC_QR_REVIVE_VERIFYCONTACT: - builder.setMessage(activity.getString(R.string.revive_verifycontact_explain)); - builder.setPositiveButton(R.string.revive_qr_code, (dialog, which) -> { - dcContext.setConfigFromQr(rawString); - }); - builder.setNegativeButton(R.string.cancel, null); - break; - case DcContext.DC_QR_WITHDRAW_VERIFYGROUP: - builder.setMessage(activity.getString(R.string.withdraw_verifygroup_explain, qrParsed.getText1())); - builder.setPositiveButton(R.string.withdraw_qr_code, (dialog, which) -> { + String message = qrParsed.getState() == DcContext.DC_QR_WITHDRAW_VERIFYCONTACT ? activity.getString(R.string.withdraw_verifycontact_explain) + : activity.getString(R.string.withdraw_verifygroup_explain, qrParsed.getText1()); + builder.setTitle(R.string.qrshow_title); + builder.setMessage(message); + builder.setNeutralButton(R.string.reset, (dialog, which) -> { dcContext.setConfigFromQr(rawString); }); - builder.setNegativeButton(R.string.cancel, null); - break; + builder.setPositiveButton(R.string.ok, null); + AlertDialog withdrawDialog = builder.show(); + Util.redButton(withdrawDialog, AlertDialog.BUTTON_NEUTRAL); + return; + case DcContext.DC_QR_REVIVE_VERIFYCONTACT: case DcContext.DC_QR_REVIVE_VERIFYGROUP: - builder.setMessage(activity.getString(R.string.revive_verifygroup_explain, qrParsed.getText1())); - builder.setPositiveButton(R.string.revive_qr_code, (dialog, which) -> { + builder.setTitle(R.string.qrshow_title); + builder.setMessage(activity.getString(R.string.revive_verifycontact_explain)); + builder.setNeutralButton(R.string.revive_qr_code, (dialog, which) -> { dcContext.setConfigFromQr(rawString); }); - builder.setNegativeButton(R.string.cancel, null); + builder.setPositiveButton(R.string.ok, null); break; default: diff --git a/src/main/java/org/thoughtcrime/securesms/qr/QrShowActivity.java b/src/main/java/org/thoughtcrime/securesms/qr/QrShowActivity.java index 23d0f1e0b..222908c71 100644 --- a/src/main/java/org/thoughtcrime/securesms/qr/QrShowActivity.java +++ b/src/main/java/org/thoughtcrime/securesms/qr/QrShowActivity.java @@ -13,6 +13,7 @@ import org.thoughtcrime.securesms.connect.DcEventCenter; import org.thoughtcrime.securesms.connect.DcHelper; import org.thoughtcrime.securesms.util.DynamicTheme; +import org.thoughtcrime.securesms.util.Util; public class QrShowActivity extends AppCompatActivity { @@ -68,6 +69,7 @@ public boolean onCreateOptionsMenu(Menu menu) { menu.findItem(R.id.new_classic_contact).setVisible(false); menu.findItem(R.id.paste).setVisible(false); menu.findItem(R.id.load_from_image).setVisible(false); + Util.redMenuItem(menu, R.id.withdraw); return super.onCreateOptionsMenu(menu); } diff --git a/src/main/java/org/thoughtcrime/securesms/qr/QrShowFragment.java b/src/main/java/org/thoughtcrime/securesms/qr/QrShowFragment.java index 2d4d4ee9e..b05bcec4d 100644 --- a/src/main/java/org/thoughtcrime/securesms/qr/QrShowFragment.java +++ b/src/main/java/org/thoughtcrime/securesms/qr/QrShowFragment.java @@ -138,15 +138,19 @@ public void copyQrData() { public void withdrawQr() { Activity activity = getActivity(); + String message = chatId == 0 ? activity.getString(R.string.withdraw_verifycontact_explain) + : activity.getString(R.string.withdraw_verifygroup_explain, dcContext.getChat(chatId).getName()); AlertDialog.Builder builder = new AlertDialog.Builder(activity); - builder.setMessage(activity.getString(R.string.withdraw_verifycontact_explain)); - builder.setPositiveButton(R.string.withdraw_qr_code, (dialog, which) -> { + builder.setTitle(R.string.withdraw_qr_code); + builder.setMessage(message); + builder.setPositiveButton(R.string.reset, (dialog, which) -> { DcContext dcContext = DcHelper.getContext(activity); dcContext.setConfigFromQr(dcContext.getSecurejoinQr(chatId)); activity.finish(); }); builder.setNegativeButton(R.string.cancel, null); - builder.create().show(); + AlertDialog dialog = builder.show(); + Util.redPositiveButton(dialog); } public void showInviteLinkDialog() { diff --git a/src/main/java/org/thoughtcrime/securesms/util/Util.java b/src/main/java/org/thoughtcrime/securesms/util/Util.java index cf180e97e..6f98a8667 100644 --- a/src/main/java/org/thoughtcrime/securesms/util/Util.java +++ b/src/main/java/org/thoughtcrime/securesms/util/Util.java @@ -104,8 +104,12 @@ public static void redMenuItem(Menu menu, int id) { } public static void redPositiveButton(AlertDialog dialog) { + redButton(dialog, AlertDialog.BUTTON_POSITIVE); + } + + public static void redButton(AlertDialog dialog, int whichButton) { try { - dialog.getButton(AlertDialog.BUTTON_POSITIVE).setTextColor(redDestructiveColor); + dialog.getButton(whichButton).setTextColor(redDestructiveColor); } catch (Exception e) { e.printStackTrace(); } diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index 7a9182aad..282c4ea24 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -985,13 +985,11 @@ Scanned QR code text:\n\n%1$s Scanned QR code URL:\n\n%1$s Fingerprint - This QR code can be scanned by others to contact you.\n\nYou can deactivate the QR code here and reactivate it by scanning it again. - This QR code can be scanned by others to join the group \"%1$s\".\n\nYou can deactivate the QR code here and reactivate it by scanning it again. - Deactivate QR Code - - This QR code could be scanned by others to contact you.\n\nThe QR code is not active on this device. - - This QR code could be scanned by others to join the group \"%1$s\".\n\nThe QR code is not active on this device. + This QR code can be scanned by others to contact you.\n\nYou can reset it, so that the existing QR code or invite link will no longer work. + This QR code can be scanned by others to join the group \"%1$s\".\n\nYou can reset it, so that the existing QR code or invite link will no longer work. + Reset QR Code + This QR code has been reset and is no longer active. + This QR code to join group \"%1$s\" has been reset and is no longer active. Activate QR Code QR Invite Code %1$s joins.