mirror of
https://github.com/deltachat/deltachat-android.git
synced 2025-10-03 17:59:39 +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
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue