mirror of
https://github.com/nextcloud/talk-android
synced 2025-03-06 14:27:24 +00:00
Allow to add emails as particpants
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
parent
e40e3d6c07
commit
98fa8642d3
@ -191,6 +191,7 @@ public class ContactsController extends BaseController implements SearchView.OnQ
|
||||
|
||||
private Set<String> selectedUserIds;
|
||||
private Set<String> selectedGroupIds;
|
||||
private Set<String> selectedEmails;
|
||||
private List<String> existingParticipants;
|
||||
private boolean isAddingParticipantsView;
|
||||
private String conversationToken;
|
||||
@ -217,6 +218,7 @@ public class ContactsController extends BaseController implements SearchView.OnQ
|
||||
}
|
||||
}
|
||||
|
||||
selectedEmails = new HashSet<>();
|
||||
selectedGroupIds = new HashSet<>();
|
||||
selectedUserIds = new HashSet<>();
|
||||
}
|
||||
@ -367,24 +369,28 @@ public class ContactsController extends BaseController implements SearchView.OnQ
|
||||
}
|
||||
|
||||
ArrayList<String> userIdsArray = new ArrayList<>(selectedUserIds);
|
||||
ArrayList<String> emailsArray = new ArrayList<>(selectedEmails);
|
||||
ArrayList<String> groupIdsArray = new ArrayList<>(selectedGroupIds);
|
||||
|
||||
|
||||
bundle.putParcelable(BundleKeys.INSTANCE.getKEY_CONVERSATION_TYPE(), Parcels.wrap(roomType));
|
||||
bundle.putStringArrayList(BundleKeys.INSTANCE.getKEY_INVITED_PARTICIPANTS(), userIdsArray);
|
||||
bundle.putStringArrayList(BundleKeys.INSTANCE.getKEY_INVITED_GROUP(), groupIdsArray);
|
||||
bundle.putStringArrayList(BundleKeys.INSTANCE.getKEY_INVITED_EMAIL(), emailsArray);
|
||||
bundle.putInt(BundleKeys.INSTANCE.getKEY_OPERATION_CODE(), 11);
|
||||
prepareAndShowBottomSheetWithBundle(bundle, true);
|
||||
}
|
||||
} else {
|
||||
String[] userIdsArray = selectedUserIds.toArray(new String[selectedUserIds.size()]);
|
||||
String[] groupIdsArray = selectedGroupIds.toArray(new String[selectedGroupIds.size()]);
|
||||
String[] emailsArray = selectedEmails.toArray(new String[selectedEmails.size()]);
|
||||
|
||||
Data.Builder data = new Data.Builder();
|
||||
data.putLong(BundleKeys.INSTANCE.getKEY_INTERNAL_USER_ID(), currentUser.getId());
|
||||
data.putString(BundleKeys.INSTANCE.getKEY_TOKEN(), conversationToken);
|
||||
data.putStringArray(BundleKeys.INSTANCE.getKEY_SELECTED_USERS(), userIdsArray);
|
||||
data.putStringArray(BundleKeys.INSTANCE.getKEY_SELECTED_GROUPS(), groupIdsArray);
|
||||
data.putStringArray(BundleKeys.INSTANCE.getKEY_SELECTED_EMAILS(), emailsArray);
|
||||
|
||||
OneTimeWorkRequest addParticipantsToConversationWorker =
|
||||
new OneTimeWorkRequest.Builder(AddParticipantsToConversation.class).setInputData(data.build()).build();
|
||||
@ -467,15 +473,22 @@ public class ContactsController extends BaseController implements SearchView.OnQ
|
||||
modifiedQueryMap.put("itemId", conversationToken);
|
||||
}
|
||||
|
||||
List<String> shareTypesList = null;
|
||||
List<String> shareTypesList;
|
||||
|
||||
shareTypesList = new ArrayList<>();
|
||||
// users
|
||||
shareTypesList.add("0");
|
||||
shareTypesList = new ArrayList<>();
|
||||
// users
|
||||
shareTypesList.add("0");
|
||||
if (!isAddingParticipantsView) {
|
||||
// groups
|
||||
shareTypesList.add("1");
|
||||
} else if (currentUser.hasSpreedFeatureCapability("invite-groups-and-mails")) {
|
||||
// groups
|
||||
shareTypesList.add("1");
|
||||
// emails
|
||||
shareTypesList.add("4");
|
||||
}
|
||||
|
||||
modifiedQueryMap.put("shareTypes[]", shareTypesList);
|
||||
modifiedQueryMap.put("shareTypes[]", shareTypesList);
|
||||
|
||||
ncApi.getContactsWithSearchParam(
|
||||
credentials,
|
||||
@ -747,7 +760,7 @@ public class ContactsController extends BaseController implements SearchView.OnQ
|
||||
|
||||
private void checkAndHandleDoneMenuItem() {
|
||||
if (adapter != null && doneMenuItem != null) {
|
||||
if ((selectedGroupIds.size() + selectedUserIds.size() > 0) || isPublicCall) {
|
||||
if ((selectedEmails.size() + selectedGroupIds.size() + selectedUserIds.size() > 0) || isPublicCall) {
|
||||
doneMenuItem.setVisible(true);
|
||||
} else {
|
||||
doneMenuItem.setVisible(false);
|
||||
@ -899,6 +912,12 @@ public class ContactsController extends BaseController implements SearchView.OnQ
|
||||
} else {
|
||||
selectedGroupIds.remove(participant.getActorId());
|
||||
}
|
||||
} else if ("emails".equals(participant.getSource())) {
|
||||
if (participant.isSelected()) {
|
||||
selectedEmails.add(participant.getActorId());
|
||||
} else {
|
||||
selectedEmails.remove(participant.getActorId());
|
||||
}
|
||||
} else {
|
||||
if (participant.isSelected()) {
|
||||
selectedUserIds.add(participant.getActorId());
|
||||
|
@ -582,10 +582,13 @@ public class OperationsMenuController extends BaseController {
|
||||
if ((localInvitedGroups.size() > 0 && currentUser.hasSpreedFeatureCapability("invite-groups-and-mails"))) {
|
||||
for (int i = 0; i < localInvitedGroups.size(); i++) {
|
||||
final String groupId = localInvitedGroups.get(i);
|
||||
retrofitBucket = ApiUtils.getRetrofitBucketForAddGroupParticipant(apiVersion,
|
||||
currentUser.getBaseUrl(),
|
||||
conversation.getToken(),
|
||||
groupId);
|
||||
retrofitBucket = ApiUtils.getRetrofitBucketForAddParticipantWithSource(
|
||||
apiVersion,
|
||||
currentUser.getBaseUrl(),
|
||||
conversation.getToken(),
|
||||
"groups",
|
||||
groupId
|
||||
);
|
||||
|
||||
ncApi.addParticipant(credentials, retrofitBucket.getUrl(), retrofitBucket.getQueryMap())
|
||||
.subscribeOn(Schedulers.io())
|
||||
|
@ -64,6 +64,7 @@ public class AddParticipantsToConversation extends Worker {
|
||||
Data data = getInputData();
|
||||
String[] selectedUserIds = data.getStringArray(BundleKeys.INSTANCE.getKEY_SELECTED_USERS());
|
||||
String[] selectedGroupIds = data.getStringArray(BundleKeys.INSTANCE.getKEY_SELECTED_GROUPS());
|
||||
String[] selectedEmails = data.getStringArray(BundleKeys.INSTANCE.getKEY_SELECTED_EMAILS());
|
||||
UserEntity user = userUtils.getUserWithInternalId(data.getLong(BundleKeys.INSTANCE.getKEY_INTERNAL_USER_ID(), -1));
|
||||
|
||||
int apiVersion = ApiUtils.getConversationApiVersion(user, new int[] {ApiUtils.APIv4, 1});
|
||||
@ -83,8 +84,27 @@ public class AddParticipantsToConversation extends Worker {
|
||||
}
|
||||
|
||||
for (String groupId : selectedGroupIds) {
|
||||
retrofitBucket = ApiUtils.getRetrofitBucketForAddGroupParticipant(apiVersion, user.getBaseUrl(), conversationToken,
|
||||
groupId);
|
||||
retrofitBucket = ApiUtils.getRetrofitBucketForAddParticipantWithSource(
|
||||
apiVersion,
|
||||
user.getBaseUrl(),
|
||||
conversationToken,
|
||||
"groups",
|
||||
groupId
|
||||
);
|
||||
|
||||
ncApi.addParticipant(credentials, retrofitBucket.getUrl(), retrofitBucket.getQueryMap())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.blockingSubscribe();
|
||||
}
|
||||
|
||||
for (String email : selectedEmails) {
|
||||
retrofitBucket = ApiUtils.getRetrofitBucketForAddParticipantWithSource(
|
||||
apiVersion,
|
||||
user.getBaseUrl(),
|
||||
conversationToken,
|
||||
"emails",
|
||||
email
|
||||
);
|
||||
|
||||
ncApi.addParticipant(credentials, retrofitBucket.getUrl(), retrofitBucket.getQueryMap())
|
||||
.subscribeOn(Schedulers.io())
|
||||
|
@ -289,15 +289,15 @@ public class ApiUtils {
|
||||
|
||||
}
|
||||
|
||||
public static RetrofitBucket getRetrofitBucketForAddGroupParticipant(int version, String baseUrl, String token, String group) {
|
||||
RetrofitBucket retrofitBucket = getRetrofitBucketForAddParticipant(version, baseUrl, token, group);
|
||||
retrofitBucket.getQueryMap().put("source", "groups");
|
||||
return retrofitBucket;
|
||||
}
|
||||
|
||||
public static RetrofitBucket getRetrofitBucketForAddMailParticipant(int version, String baseUrl, String token, String mail) {
|
||||
RetrofitBucket retrofitBucket = getRetrofitBucketForAddParticipant(version, baseUrl, token, mail);
|
||||
retrofitBucket.getQueryMap().put("source", "emails");
|
||||
public static RetrofitBucket getRetrofitBucketForAddParticipantWithSource(
|
||||
int version,
|
||||
String baseUrl,
|
||||
String token,
|
||||
String source,
|
||||
String id
|
||||
) {
|
||||
RetrofitBucket retrofitBucket = getRetrofitBucketForAddParticipant(version, baseUrl, token, id);
|
||||
retrofitBucket.getQueryMap().put("source", source);
|
||||
return retrofitBucket;
|
||||
}
|
||||
|
||||
|
@ -23,6 +23,7 @@ package com.nextcloud.talk.utils.bundle
|
||||
object BundleKeys {
|
||||
val KEY_SELECTED_USERS = "KEY_SELECTED_USERS"
|
||||
val KEY_SELECTED_GROUPS = "KEY_SELECTED_GROUPS"
|
||||
val KEY_SELECTED_EMAILS = "KEY_SELECTED_EMAILS"
|
||||
val KEY_USERNAME = "KEY_USERNAME"
|
||||
val KEY_TOKEN = "KEY_TOKEN"
|
||||
val KEY_BASE_URL = "KEY_BASE_URL"
|
||||
@ -49,6 +50,7 @@ object BundleKeys {
|
||||
val KEY_CONVERSATION_TYPE = "KEY_CONVERSATION_TYPE"
|
||||
val KEY_INVITED_PARTICIPANTS = "KEY_INVITED_PARTICIPANTS"
|
||||
val KEY_INVITED_GROUP = "KEY_INVITED_GROUP"
|
||||
val KEY_INVITED_EMAIL = "KEY_INVITED_EMAIL"
|
||||
val KEY_CONVERSATION_NAME = "KEY_CONVERSATION_NAME"
|
||||
val KEY_CALL_VOICE_ONLY = "KEY_CALL_VOICE_ONLY"
|
||||
val KEY_ACTIVE_CONVERSATION = "KEY_ACTIVE_CONVERSATION"
|
||||
|
Loading…
Reference in New Issue
Block a user