Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refine QR reset wording #3568

Merged
merged 3 commits into from
Jan 31, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/main/java/org/thoughtcrime/securesms/qr/QrActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
32 changes: 11 additions & 21 deletions src/main/java/org/thoughtcrime/securesms/qr/QrCodeHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,35 +115,25 @@ 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);
builder.setPositiveButton(R.string.ok, null);
break;

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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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);
}

Expand Down
10 changes: 7 additions & 3 deletions src/main/java/org/thoughtcrime/securesms/qr/QrShowFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
11 changes: 5 additions & 6 deletions src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -985,12 +985,11 @@
<string name="qrscan_contains_text">Scanned QR code text:\n\n%1$s</string>
<string name="qrscan_contains_url">Scanned QR code URL:\n\n%1$s</string>
<string name="qrscan_fingerprint_label">Fingerprint</string>
<string name="withdraw_verifycontact_explain">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.</string>
<string name="withdraw_verifygroup_explain">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.</string>
<string name="withdraw_qr_code">Deactivate QR Code</string>
<!-- "could" in the meaning of "possible at some point in the past, but no longer possible today" -->
<string name="revive_verifycontact_explain">This QR code could be scanned by others to contact you.\n\nThe QR code is not active on this device.</string>
<!-- "could" in the meaning of "possible at some point in the past, but no longer possible today" -->
<string name="withdraw_verifycontact_explain">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.</string>
<string name="withdraw_verifygroup_explain">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.</string>
<string name="withdraw_qr_code">Reset QR Code</string>
<string name="revive_verifycontact_explain">This QR code has been reset and is no longer active.</string>
<!-- deprecated, use revive_verifycontact_explain -->
<string name="revive_verifygroup_explain">This QR code could be scanned by others to join the group \"%1$s\".\n\nThe QR code is not active on this device.</string>
<string name="revive_qr_code">Activate QR Code</string>
<string name="qrshow_title">QR Invite Code</string>
Expand Down
Loading