mirror of
https://github.com/deltachat/deltachat-android.git
synced 2025-10-03 09:49:21 +02:00
allow to create new unencrypted group
This commit is contained in:
parent
54f2d2e991
commit
d7c3303cec
13 changed files with 60 additions and 11 deletions
|
@ -17,7 +17,8 @@
|
|||
* Classic email chats/threads get a big email / letter icon making it easy to recognize
|
||||
* After some time, add a device message asking to donate. Can't wait? Donate today at https://delta.chat/donate
|
||||
* Allow to sort profiles up in the profile switcher
|
||||
* Update to core 2.1.0
|
||||
* Add new option to create unencrypted email thread
|
||||
* Update to core 2.2.0
|
||||
|
||||
## v1.58.4
|
||||
2025-05
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 402e42f858514e5c1fbab3c88ad3d5f884009b8b
|
||||
Subproject commit a0f6bdffeb454588f0570c90fdda01ea54a64832
|
|
@ -12,6 +12,7 @@ public class DcContact {
|
|||
public final static int DC_CONTACT_ID_QR_INVITE = -4; // - " -
|
||||
public final static int DC_CONTACT_ID_NEW_BROADCAST = -5; // - " -
|
||||
public final static int DC_CONTACT_ID_ADD_ACCOUNT = -6; // - " -
|
||||
public final static int DC_CONTACT_ID_NEW_UNENCRYPTED_GROUP = -7; // - " -
|
||||
|
||||
public DcContact(long contactCPtr) {
|
||||
this.contactCPtr = contactCPtr;
|
||||
|
|
|
@ -39,6 +39,7 @@ public class DcContext {
|
|||
|
||||
public final static int DC_GCL_VERIFIED_ONLY = 1;
|
||||
public final static int DC_GCL_ADD_SELF = 2;
|
||||
public final static int DC_GCL_ADDRESS = 0x04;
|
||||
public final static int DC_GCL_ARCHIVED_ONLY = 0x01;
|
||||
public final static int DC_GCL_NO_SPECIALS = 0x02;
|
||||
public final static int DC_GCL_ADD_ALLDONE_HINT = 0x04;
|
||||
|
|
|
@ -164,6 +164,10 @@ public class Rpc {
|
|||
return gson.fromJson(getResult("create_broadcast", accountId, chatName), Integer.class);
|
||||
}
|
||||
|
||||
public int createGroupChatUnencrypted(int accountId, String chatName) throws RpcException {
|
||||
return gson.fromJson(getResult("create_group_chat_unencrypted", accountId, chatName), Integer.class);
|
||||
}
|
||||
|
||||
public void setAccountsOrder(List<Integer> order) throws RpcException {
|
||||
getResult("set_accounts_order", order);
|
||||
}
|
||||
|
|
|
@ -83,6 +83,7 @@ public class ContactSelectionListFragment extends Fragment
|
|||
|
||||
public static final String MULTI_SELECT = "multi_select";
|
||||
public static final String SELECT_VERIFIED_EXTRA = "select_verified";
|
||||
public static final String SELECT_UNENCRYPTED_EXTRA = "select_unencrypted_extra";
|
||||
public static final String ALLOW_CREATION = "allow_creation";
|
||||
public static final String PRESELECTED_CONTACTS = "preselected_contacts";
|
||||
public static final int CONTACT_ADDR_RESULT_CODE = 61123;
|
||||
|
@ -251,6 +252,10 @@ public class ContactSelectionListFragment extends Fragment
|
|||
return getActivity().getIntent().getBooleanExtra(SELECT_VERIFIED_EXTRA, false);
|
||||
}
|
||||
|
||||
private boolean isUnencrypted() {
|
||||
return getActivity().getIntent().getBooleanExtra(SELECT_UNENCRYPTED_EXTRA, false);
|
||||
}
|
||||
|
||||
private void initializeCursor() {
|
||||
ContactSelectionListAdapter adapter = new ContactSelectionListAdapter(getActivity(),
|
||||
GlideApp.with(this),
|
||||
|
@ -277,7 +282,7 @@ public class ContactSelectionListFragment extends Fragment
|
|||
final boolean addCreateGroupLinks = allowCreation && !isRelayingMessageContent(getActivity()) && !isMulti();
|
||||
final boolean addScanQRLink = allowCreation && !isMulti();
|
||||
|
||||
final int listflags = DcContext.DC_GCL_ADD_SELF;
|
||||
final int listflags = DcContext.DC_GCL_ADD_SELF | (isUnencrypted()? DcContext.DC_GCL_ADDRESS : 0);
|
||||
return new DcContactsLoader(getActivity(), listflags, cursorFilter, addCreateGroupLinks, addCreateContactLink, addScanQRLink, false);
|
||||
}
|
||||
|
||||
|
|
|
@ -50,6 +50,7 @@ public class GroupCreateActivity extends PassphraseRequiredActionBarActivity
|
|||
|
||||
public static final String EDIT_GROUP_CHAT_ID = "edit_group_chat_id";
|
||||
public static final String CREATE_BROADCAST = "create_broadcast";
|
||||
public static final String UNENCRYPTED = "unencrypted";
|
||||
public static final String CLONE_CHAT_EXTRA = "clone_chat";
|
||||
|
||||
private static final int PICK_CONTACT = 1;
|
||||
|
@ -59,6 +60,7 @@ public class GroupCreateActivity extends PassphraseRequiredActionBarActivity
|
|||
private DcContext dcContext;
|
||||
|
||||
private boolean verified;
|
||||
private boolean unencrypted;
|
||||
private boolean broadcast;
|
||||
private EditText groupName;
|
||||
private ListView lv;
|
||||
|
@ -76,6 +78,7 @@ public class GroupCreateActivity extends PassphraseRequiredActionBarActivity
|
|||
setContentView(R.layout.group_create_activity);
|
||||
verified = false;
|
||||
broadcast = getIntent().getBooleanExtra(CREATE_BROADCAST, false);
|
||||
unencrypted = getIntent().getBooleanExtra(UNENCRYPTED, false);
|
||||
Objects.requireNonNull(getSupportActionBar()).setDisplayHomeAsUpEnabled(true);
|
||||
getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_close_white_24dp);
|
||||
|
||||
|
@ -90,11 +93,14 @@ public class GroupCreateActivity extends PassphraseRequiredActionBarActivity
|
|||
DcChat dcChat = dcContext.getChat(groupChatId);
|
||||
verified = dcChat.isProtected();
|
||||
broadcast = dcChat.isOutBroadcast();
|
||||
unencrypted = !dcChat.isEncrypted();
|
||||
}
|
||||
|
||||
int chatId = getIntent().getIntExtra(CLONE_CHAT_EXTRA, 0);
|
||||
if (chatId != 0) {
|
||||
broadcast = dcContext.getChat(chatId).isOutBroadcast();
|
||||
DcChat dcChat = dcContext.getChat(chatId);
|
||||
broadcast = dcChat.isOutBroadcast();
|
||||
unencrypted = !dcChat.isEncrypted();
|
||||
}
|
||||
|
||||
initializeResources();
|
||||
|
@ -123,6 +129,9 @@ public class GroupCreateActivity extends PassphraseRequiredActionBarActivity
|
|||
else if(broadcast) {
|
||||
title = getString(R.string.new_channel);
|
||||
}
|
||||
else if(unencrypted) {
|
||||
title = getString(R.string.new_email);
|
||||
}
|
||||
else {
|
||||
title = getString(R.string.menu_new_group);
|
||||
}
|
||||
|
@ -137,7 +146,7 @@ public class GroupCreateActivity extends PassphraseRequiredActionBarActivity
|
|||
|
||||
initializeAvatarView();
|
||||
|
||||
SelectedContactsAdapter adapter = new SelectedContactsAdapter(this, GlideApp.with(this), broadcast);
|
||||
SelectedContactsAdapter adapter = new SelectedContactsAdapter(this, GlideApp.with(this), broadcast, unencrypted);
|
||||
adapter.setItemClickListener(this);
|
||||
lv.setAdapter(adapter);
|
||||
|
||||
|
@ -163,6 +172,10 @@ public class GroupCreateActivity extends PassphraseRequiredActionBarActivity
|
|||
if (broadcast) {
|
||||
groupName.setHint(R.string.channel_name);
|
||||
chatHints.setVisibility(View.VISIBLE);
|
||||
} else if (unencrypted) {
|
||||
avatar.setVisibility(View.GONE);
|
||||
groupName.setHint(R.string.subject);
|
||||
chatHints.setVisibility(View.GONE);
|
||||
} else {
|
||||
chatHints.setVisibility(View.GONE);
|
||||
}
|
||||
|
@ -219,7 +232,7 @@ public class GroupCreateActivity extends PassphraseRequiredActionBarActivity
|
|||
if (groupChatId != 0) {
|
||||
updateGroup(groupName);
|
||||
} else {
|
||||
verified = !broadcast && allMembersVerified();
|
||||
verified = !unencrypted && !broadcast && allMembersVerified();
|
||||
createGroup(groupName);
|
||||
}
|
||||
|
||||
|
@ -244,6 +257,7 @@ public class GroupCreateActivity extends PassphraseRequiredActionBarActivity
|
|||
if (contactId == DcContact.DC_CONTACT_ID_ADD_MEMBER) {
|
||||
Intent intent = new Intent(this, ContactMultiSelectionActivity.class);
|
||||
intent.putExtra(ContactSelectionListFragment.SELECT_VERIFIED_EXTRA, verified);
|
||||
intent.putExtra(ContactSelectionListFragment.SELECT_UNENCRYPTED_EXTRA, unencrypted);
|
||||
ArrayList<Integer> preselectedContacts = new ArrayList<>(getAdapter().getContacts());
|
||||
intent.putExtra(ContactSelectionListFragment.PRESELECTED_CONTACTS, preselectedContacts);
|
||||
startActivityForResult(intent, PICK_CONTACT);
|
||||
|
@ -263,6 +277,13 @@ public class GroupCreateActivity extends PassphraseRequiredActionBarActivity
|
|||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
} else if (unencrypted) {
|
||||
try {
|
||||
groupChatId = DcHelper.getRpc(this).createGroupChatUnencrypted(dcContext.getAccountId(), groupName);
|
||||
} catch (RpcException e) {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
groupChatId = dcContext.createGroupChat(verified, groupName);
|
||||
}
|
||||
|
|
|
@ -102,6 +102,10 @@ public class NewConversationActivity extends ContactSelectionActivity {
|
|||
public void onContactSelected(int contactId) {
|
||||
if(contactId == DcContact.DC_CONTACT_ID_NEW_GROUP) {
|
||||
startActivity(new Intent(this, GroupCreateActivity.class));
|
||||
} else if(contactId == DcContact.DC_CONTACT_ID_NEW_UNENCRYPTED_GROUP) {
|
||||
Intent intent = new Intent(this, GroupCreateActivity.class);
|
||||
intent.putExtra(GroupCreateActivity.UNENCRYPTED, true);
|
||||
startActivity(intent);
|
||||
} else if(contactId == DcContact.DC_CONTACT_ID_NEW_BROADCAST) {
|
||||
Intent intent = new Intent(this, GroupCreateActivity.class);
|
||||
intent.putExtra(GroupCreateActivity.CREATE_BROADCAST, true);
|
||||
|
|
|
@ -51,8 +51,13 @@ public class DcContactsLoader extends AsyncLoader<DcContactsLoader.Ret> {
|
|||
}
|
||||
if (query == null && addCreateGroupLinks) {
|
||||
additional_items = Util.appendInt(additional_items, DcContact.DC_CONTACT_ID_NEW_GROUP);
|
||||
|
||||
final boolean broadcastsEnabled = Prefs.isNewBroadcastAvailable(getContext());
|
||||
if (broadcastsEnabled) additional_items = Util.appendInt(additional_items, DcContact.DC_CONTACT_ID_NEW_BROADCAST);
|
||||
|
||||
if (!dcContext.isChatmail()) {
|
||||
additional_items = Util.appendInt(additional_items, DcContact.DC_CONTACT_ID_NEW_UNENCRYPTED_GROUP);
|
||||
}
|
||||
}
|
||||
int[] all_ids = new int[contact_ids.length + additional_items.length];
|
||||
System.arraycopy(additional_items, 0, all_ids, 0, additional_items.length);
|
||||
|
|
|
@ -268,6 +268,8 @@ public class ContactSelectionListAdapter extends RecyclerView.Adapter<ContactSel
|
|||
itemMultiSelect = false; // the item creates a new contact in the list that will be selected instead
|
||||
} else if (id == DcContact.DC_CONTACT_ID_NEW_GROUP) {
|
||||
name = context.getString(R.string.menu_new_group);
|
||||
} else if (id == DcContact.DC_CONTACT_ID_NEW_UNENCRYPTED_GROUP) {
|
||||
name = context.getString(R.string.new_email);
|
||||
} else if (id == DcContact.DC_CONTACT_ID_NEW_BROADCAST) {
|
||||
name = context.getString(R.string.new_channel);
|
||||
} else if (id == DcContact.DC_CONTACT_ID_QR_INVITE) {
|
||||
|
|
|
@ -64,9 +64,12 @@ public class ContactSelectionListItem extends LinearLayout implements RecipientM
|
|||
this.name = name;
|
||||
this.number = number;
|
||||
|
||||
if (specialId==DcContact.DC_CONTACT_ID_NEW_CLASSIC_CONTACT || specialId==DcContact.DC_CONTACT_ID_NEW_GROUP
|
||||
if (specialId==DcContact.DC_CONTACT_ID_NEW_CLASSIC_CONTACT
|
||||
|| specialId==DcContact.DC_CONTACT_ID_NEW_GROUP
|
||||
|| specialId==DcContact.DC_CONTACT_ID_NEW_UNENCRYPTED_GROUP
|
||||
|| specialId==DcContact.DC_CONTACT_ID_NEW_BROADCAST
|
||||
|| specialId==DcContact.DC_CONTACT_ID_ADD_MEMBER || specialId==DcContact.DC_CONTACT_ID_QR_INVITE) {
|
||||
|| specialId==DcContact.DC_CONTACT_ID_ADD_MEMBER
|
||||
|| specialId==DcContact.DC_CONTACT_ID_QR_INVITE) {
|
||||
this.nameView.setTypeface(null, Typeface.BOLD);
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -37,16 +37,18 @@ public class SelectedContactsAdapter extends BaseAdapter {
|
|||
@Nullable private ItemClickListener itemClickListener;
|
||||
@NonNull private final List<Integer> contacts = new LinkedList<>();
|
||||
private final boolean isBroadcast;
|
||||
private final boolean isUnencrypted;
|
||||
@NonNull private final DcContext dcContext;
|
||||
@NonNull private final GlideRequests glideRequests;
|
||||
|
||||
public SelectedContactsAdapter(@NonNull Context context,
|
||||
@NonNull GlideRequests glideRequests,
|
||||
boolean isBroadcast)
|
||||
boolean isBroadcast, boolean isUnencrypted)
|
||||
{
|
||||
this.context = context;
|
||||
this.glideRequests = glideRequests;
|
||||
this.isBroadcast = isBroadcast;
|
||||
this.isUnencrypted = isUnencrypted;
|
||||
this.dcContext = DcHelper.getContext(context);
|
||||
}
|
||||
|
||||
|
@ -112,7 +114,7 @@ public class SelectedContactsAdapter extends BaseAdapter {
|
|||
boolean verified = false;
|
||||
|
||||
if(contactId == DcContact.DC_CONTACT_ID_ADD_MEMBER) {
|
||||
name.setText(context.getString(isBroadcast? R.string.add_recipients : R.string.group_add_members));
|
||||
name.setText(context.getString(isBroadcast || isUnencrypted? R.string.add_recipients : R.string.group_add_members));
|
||||
name.setTypeface(null, Typeface.BOLD);
|
||||
phone.setVisibility(View.GONE);
|
||||
} else {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<item android:title="@string/group_create_button"
|
||||
<item android:title="@string/perm_continue"
|
||||
android:id="@+id/menu_create_group"
|
||||
android:icon="?menu_accept_icon"
|
||||
app:showAsAction="always|withText"/>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue