feat: Adapt to channel-invite QR codes

This commit is contained in:
Hocuri
2025-11-03 22:45:06 +01:00
parent 5ab83e71c8
commit 2881ea7150
8 changed files with 19 additions and 6 deletions
+2
View File
@@ -2,6 +2,8 @@
## Unreleased
* Make it possible to invite members into a channel via a QR code,
and make channels more secure
* metadata protection: protect Date header
* metadata protection: protect Autocrypt header
* better multi-device: synchronize group creation across devices
@@ -53,6 +53,7 @@ public class DcContext {
public final static int DC_QR_ASK_VERIFYCONTACT = 200;
public final static int DC_QR_ASK_VERIFYGROUP = 202;
public final static int DC_QR_ASK_JOIN_BROADCAST= 204;
public final static int DC_QR_FPR_OK = 210;
public final static int DC_QR_FPR_MISMATCH = 220;
public final static int DC_QR_FPR_WITHOUT_ADDR = 230;
@@ -1152,7 +1152,10 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
if (doSend) {
if (dcContext.sendMsg(dcChat.getId(), msg) == 0) {
Util.runOnMain(()-> Toast.makeText(ConversationActivity.this, dcContext.getLastError(), Toast.LENGTH_LONG).show());
String lastError = dcContext.getLastError();
if (!"".equals(lastError)) {
Util.runOnMain(() -> Toast.makeText(ConversationActivity.this, lastError, Toast.LENGTH_LONG).show());
}
future.set(chatId);
return;
}
@@ -110,7 +110,7 @@ public class ProfileActivity extends PassphraseRequiredActionBarActivity
if (chatId != 0) {
DcChat dcChat = dcContext.getChat(chatId);
menu.findItem(R.id.menu_clone).setVisible(chatIsMultiUser && !chatIsInBroadcast && !chatIsMailingList);
menu.findItem(R.id.menu_clone).setVisible(chatIsMultiUser && !chatIsInBroadcast && !chatIsOutBroadcast && !chatIsMailingList);
if (chatIsDeviceTalk) {
menu.findItem(R.id.edit_name).setVisible(false);
menu.findItem(R.id.show_encr_info).setVisible(false);
@@ -314,10 +314,10 @@ public class ProfileAdapter extends RecyclerView.Adapter
itemData.add(new ItemData(ITEM_DIVIDER, null, 0));
if (dcChat != null) {
if (dcChat.canSend() && dcChat.isEncrypted()) {
itemData.add(new ItemData(ITEM_MEMBERS, DcContact.DC_CONTACT_ID_ADD_MEMBER, 0));
if (!isOutBroadcast) {
itemData.add(new ItemData(ITEM_MEMBERS, DcContact.DC_CONTACT_ID_QR_INVITE, 0));
itemData.add(new ItemData(ITEM_MEMBERS, DcContact.DC_CONTACT_ID_ADD_MEMBER, 0));
}
itemData.add(new ItemData(ITEM_MEMBERS, DcContact.DC_CONTACT_ID_QR_INVITE, 0));
}
}
for (int value : memberList) {
@@ -43,6 +43,7 @@ public class QrCodeHandler {
switch (qrParsed.getState()) {
case DcContext.DC_QR_ASK_VERIFYCONTACT:
case DcContext.DC_QR_ASK_VERIFYGROUP:
case DcContext.DC_QR_ASK_JOIN_BROADCAST:
showVerifyContactOrGroup(activity, builder, rawString, qrParsed, name);
break;
@@ -216,6 +217,9 @@ public class QrCodeHandler {
case DcContext.DC_QR_ASK_VERIFYGROUP:
msg = activity.getString(R.string.qrscan_ask_join_group, qrParsed.getText1());
break;
case DcContext.DC_QR_ASK_JOIN_BROADCAST:
msg = activity.getString(R.string.qrscan_ask_join_channel, qrParsed.getText1());
break;
default:
msg = activity.getString(R.string.ask_start_chat_with, name);
break;
@@ -54,7 +54,9 @@ public class SelectedContactsAdapter extends BaseAdapter {
public void changeData(Collection<Integer> contactIds) {
contacts.clear();
contacts.add(DC_CONTACT_ID_ADD_MEMBER);
if (!isBroadcast) {
contacts.add(DC_CONTACT_ID_ADD_MEMBER);
}
if (contactIds != null) {
for (int id : contactIds) {
if (id != DC_CONTACT_ID_SELF) {
@@ -75,7 +77,7 @@ public class SelectedContactsAdapter extends BaseAdapter {
}
public Set<Integer> getContacts() {
final Set<Integer> set = new HashSet<>(contacts.size()-1);
final Set<Integer> set = new HashSet<>(contacts.size());
for (int i = 1; i < contacts.size(); i++) {
set.add(contacts.get(i));
}
+1
View File
@@ -986,6 +986,7 @@
<string name="qrscan_hint_desktop">Move the QR code to the camera</string>
<string name="qrscan_failed">QR code could not be decoded</string>
<string name="qrscan_ask_join_group">Do you want to join the group \"%1$s\"?</string>
<string name="qrscan_ask_join_channel">Do you want to join the channel \"%1$s\"?</string>
<string name="qrscan_fingerprint_mismatch">The scanned fingerprint does not match the last seen for %1$s.</string>
<string name="qrscan_no_addr_found">This QR code contains a fingerprint but no address.\n\nFor an out-of-band-verification, please establish an encrypted connection to the recipient first.</string>
<string name="qrscan_contains_text">Scanned QR code text:\n\n%1$s</string>