feat: Add the possibility to withdraw channel invite links and QR codes (#4022)

This commit is contained in:
Hocuri
2025-11-15 19:17:06 +01:00
committed by GitHub
parent adcbf118b6
commit f924a407b3
4 changed files with 20 additions and 3 deletions
@@ -68,8 +68,10 @@ public class DcContext {
public final static int DC_QR_ERROR = 400;
public final static int DC_QR_WITHDRAW_VERIFYCONTACT = 500;
public final static int DC_QR_WITHDRAW_VERIFYGROUP = 502;
public final static int DC_QR_WITHDRAW_JOINBROADCAST = 504;
public final static int DC_QR_REVIVE_VERIFYCONTACT = 510;
public final static int DC_QR_REVIVE_VERIFYGROUP = 512;
public final static int DC_QR_REVIVE_JOINBROADCAST = 514;
public final static int DC_QR_LOGIN = 520;
public final static int DC_SOCKET_AUTO = 0;
@@ -112,8 +112,10 @@ public class QrCodeHandler {
case DcContext.DC_QR_WITHDRAW_VERIFYCONTACT:
case DcContext.DC_QR_WITHDRAW_VERIFYGROUP:
case DcContext.DC_QR_WITHDRAW_JOINBROADCAST:
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());
: qrParsed.getState() == DcContext.DC_QR_WITHDRAW_VERIFYCONTACT ? activity.getString(R.string.withdraw_verifygroup_explain, qrParsed.getText1())
: activity.getString(R.string.withdraw_joinbroadcast_explain, qrParsed.getText1());
builder.setTitle(R.string.qrshow_title);
builder.setMessage(message);
builder.setNeutralButton(R.string.reset, (dialog, which) -> {
@@ -126,6 +128,7 @@ public class QrCodeHandler {
case DcContext.DC_QR_REVIVE_VERIFYCONTACT:
case DcContext.DC_QR_REVIVE_VERIFYGROUP:
case DcContext.DC_QR_REVIVE_JOINBROADCAST:
builder.setTitle(R.string.qrshow_title);
builder.setMessage(activity.getString(R.string.revive_verifycontact_explain));
builder.setNeutralButton(R.string.revive_qr_code, (dialog, which) -> {
@@ -17,6 +17,7 @@ import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.Fragment;
import com.b44t.messenger.DcChat;
import com.b44t.messenger.DcContext;
import com.b44t.messenger.DcEvent;
import com.caverock.androidsvg.SVG;
@@ -143,8 +144,17 @@ public class QrShowFragment extends Fragment implements DcEventCenter.DcEventDel
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());
String message;
if (chatId == 0) {
message = activity.getString(R.string.withdraw_verifycontact_explain);
} else {
DcChat chat = dcContext.getChat(chatId);
if (chat.getType() == DcChat.DC_CHAT_TYPE_GROUP) {
message = activity.getString(R.string.withdraw_verifygroup_explain, chat.getName());
} else {
message = activity.getString(R.string.withdraw_joinbroadcast_explain, chat.getName());
}
}
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
builder.setTitle(R.string.withdraw_qr_code);
builder.setMessage(message);
+2
View File
@@ -1011,9 +1011,11 @@
<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 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_joinbroadcast_explain">This QR code can be scanned by others to join the channel \"%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_joinbroadcast_explain">This QR code to join channel \"%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>