private Recipients getSyncMessageDestination(TextSecureMessage message) { if (message.getGroupInfo().isPresent()) { return RecipientFactory.getRecipientsFromString( context, GroupUtil.getEncodedId(message.getGroupInfo().get().getGroupId()), false); } else { return RecipientFactory.getRecipientsFromString( context, message.getSyncContext().get().getDestination(), false); } }
private Pair<Long, Recipients> handlePushOperation( byte[] groupId, String groupName, byte[] avatar, Set<String> e164numbers) throws InvalidNumberException { String groupRecipientId = GroupUtil.getEncodedId(groupId); Recipients groupRecipient = RecipientFactory.getRecipientsFromString(this, groupRecipientId, false); GroupContext context = GroupContext.newBuilder() .setId(ByteString.copyFrom(groupId)) .setType(GroupContext.Type.UPDATE) .setName(groupName) .addAllMembers(e164numbers) .build(); OutgoingGroupMediaMessage outgoingMessage = new OutgoingGroupMediaMessage(this, groupRecipient, context, avatar); long threadId = MessageSender.send(this, masterSecret, outgoingMessage, -1, false); return new Pair<>(threadId, groupRecipient); }
private void initializeResources() { groupRecipient = RecipientFactory.getRecipientForId( this, getIntent().getLongExtra(GROUP_RECIPIENT_EXTRA, -1), true); groupThread = getIntent().getLongExtra(GROUP_THREAD_EXTRA, -1); if (groupRecipient != null) { final String encodedGroupId = groupRecipient.getNumber(); if (encodedGroupId != null) { try { groupId = GroupUtil.getDecodedId(encodedGroupId); } catch (IOException ioe) { Log.w(TAG, "Couldn't decode the encoded groupId passed in via intent", ioe); groupId = null; } if (groupId != null) { new FillExistingGroupInfoAsyncTask().execute(); } } } lv = (ListView) findViewById(R.id.selected_contacts_list); avatar = (ImageView) findViewById(R.id.avatar); groupName = (EditText) findViewById(R.id.group_name); creatingText = (TextView) findViewById(R.id.creating_group_text); recipientsPanel = (PushRecipientsPanel) findViewById(R.id.recipients); groupName.addTextChangedListener( new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {} @Override public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {} @Override public void afterTextChanged(Editable editable) { final int prefixResId = (groupId != null) ? R.string.GroupCreateActivity_actionbar_update_title : R.string.GroupCreateActivity_actionbar_title; if (editable.length() > 0) { getSupportActionBar().setTitle(getString(prefixResId) + ": " + editable.toString()); } else { getSupportActionBar().setTitle(prefixResId); } } }); SelectedRecipientsAdapter adapter = new SelectedRecipientsAdapter( this, android.R.id.text1, new ArrayList<SelectedRecipientsAdapter.RecipientWrapper>()); adapter.setOnRecipientDeletedListener( new SelectedRecipientsAdapter.OnRecipientDeletedListener() { @Override public void onRecipientDeleted(Recipient recipient) { removeSelectedContact(recipient); } }); lv.setAdapter(adapter); recipientsPanel.setPanelChangeListener( new PushRecipientsPanel.RecipientsPanelChangedListener() { @Override public void onRecipientsPanelUpdate(Recipients recipients) { Log.i(TAG, "onRecipientsPanelUpdate received."); if (recipients != null) { addAllSelectedContacts(recipients.getRecipientsList()); syncAdapterWithSelectedContacts(); } } }); (findViewById(R.id.contacts_button)).setOnClickListener(new AddRecipientButtonListener()); avatar.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View view) { Crop.pickImage(GroupCreateActivity.this); } }); ((RecipientsEditor) findViewById(R.id.recipients_text)) .setHint(R.string.recipients_panel__add_member); }