Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
weblate committed Jan 31, 2025
2 parents 7b52bb6 + f0f5345 commit 3013af2
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 33 deletions.
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
36 changes: 14 additions & 22 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,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:
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
6 changes: 5 additions & 1 deletion src/main/java/org/thoughtcrime/securesms/util/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
12 changes: 5 additions & 7 deletions src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -985,13 +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="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="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>
<string name="revive_verifygroup_explain">This QR code to join group \"%1$s\" has been reset and is no longer active.</string>
<string name="revive_qr_code">Activate QR Code</string>
<string name="qrshow_title">QR Invite Code</string>
<string name="qrshow_x_joining">%1$s joins.</string>
Expand Down

0 comments on commit 3013af2

Please sign in to comment.