當前位置: 首頁>>代碼示例>>Java>>正文


Java GroupUtil.getEncodedId方法代碼示例

本文整理匯總了Java中org.thoughtcrime.securesms.util.GroupUtil.getEncodedId方法的典型用法代碼示例。如果您正苦於以下問題:Java GroupUtil.getEncodedId方法的具體用法?Java GroupUtil.getEncodedId怎麽用?Java GroupUtil.getEncodedId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.thoughtcrime.securesms.util.GroupUtil的用法示例。


在下文中一共展示了GroupUtil.getEncodedId方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: IncomingTextMessage

import org.thoughtcrime.securesms.util.GroupUtil; //導入方法依賴的package包/類
public IncomingTextMessage(String sender, int senderDeviceId, long sentTimestampMillis,
                           String encodedBody, Optional<SignalServiceGroup> group,
                           long expiresInMillis)
{
  this.message              = encodedBody;
  this.sender               = sender;
  this.senderDeviceId       = senderDeviceId;
  this.protocol             = 31337;
  this.serviceCenterAddress = "GCM";
  this.replyPathPresent     = true;
  this.pseudoSubject        = "";
  this.sentTimestampMillis  = sentTimestampMillis;
  this.push                 = true;
  this.subscriptionId       = -1;
  this.expiresInMillis      = expiresInMillis;

  if (group.isPresent()) {
    this.groupId = GroupUtil.getEncodedId(group.get().getGroupId());
  } else {
    this.groupId = null;
  }
}
 
開發者ID:XecureIT,項目名稱:PeSanKita-android,代碼行數:23,代碼來源:IncomingTextMessage.java

示例2: IncomingMediaMessage

import org.thoughtcrime.securesms.util.GroupUtil; //導入方法依賴的package包/類
public IncomingMediaMessage(MasterSecretUnion masterSecret,
                            String from,
                            String to,
                            long sentTimeMillis,
                            int subscriptionId,
                            long expiresIn,
                            boolean expirationUpdate,
                            Optional<String> relay,
                            Optional<String> body,
                            Optional<SignalServiceGroup> group,
                            Optional<List<SignalServiceAttachment>> attachments)
{
  this.push             = true;
  this.from             = from;
  this.sentTimeMillis   = sentTimeMillis;
  this.body             = body.orNull();
  this.subscriptionId   = subscriptionId;
  this.expiresIn        = expiresIn;
  this.expirationUpdate = expirationUpdate;

  if (group.isPresent()) this.groupId = GroupUtil.getEncodedId(group.get().getGroupId());
  else                   this.groupId = null;

  this.to.add(to);
  this.attachments.addAll(PointerAttachment.forPointers(masterSecret, attachments));
}
 
開發者ID:XecureIT,項目名稱:PeSanKita-android,代碼行數:27,代碼來源:IncomingMediaMessage.java

示例3: handlePushOperation

import org.thoughtcrime.securesms.util.GroupUtil; //導入方法依賴的package包/類
private Pair<Long, Recipients> handlePushOperation(byte[] groupId, String groupName, byte[] avatar,
                                                   Set<String> e164numbers)
    throws InvalidNumberException
{

  try {
    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);
  } catch (RecipientFormattingException e) {
    throw new AssertionError(e);
  }
}
 
開發者ID:redcracker,項目名稱:TextSecure,代碼行數:25,代碼來源:GroupCreateActivity.java

示例4: IncomingTextMessage

import org.thoughtcrime.securesms.util.GroupUtil; //導入方法依賴的package包/類
public IncomingTextMessage(String sender, int senderDeviceId, long sentTimestampMillis,
                           String encodedBody, Optional<TextSecureGroup> group)
{
  this.message              = encodedBody;
  this.sender               = sender;
  this.senderDeviceId       = senderDeviceId;
  this.protocol             = 31337;
  this.serviceCenterAddress = "GCM";
  this.replyPathPresent     = true;
  this.pseudoSubject        = "";
  this.sentTimestampMillis  = sentTimestampMillis;
  this.push                 = true;

  if (group.isPresent()) {
    this.groupId = GroupUtil.getEncodedId(group.get().getGroupId());
  } else {
    this.groupId = null;
  }
}
 
開發者ID:redcracker,項目名稱:TextSecure,代碼行數:20,代碼來源:IncomingTextMessage.java

示例5: sendGroupUpdate

import org.thoughtcrime.securesms.util.GroupUtil; //導入方法依賴的package包/類
private static GroupActionResult sendGroupUpdate(@NonNull  Context      context,
                                                 @NonNull  MasterSecret masterSecret,
                                                 @NonNull  byte[]       groupId,
                                                 @NonNull  Set<String>  e164numbers,
                                                 @NonNull  String       ownerE164number,
                                                 @NonNull  Set<String>  adminE164numbers,
                                                 @Nullable String       groupName,
                                                 @Nullable byte[]       avatar,
                                                 @Nullable Recipients   destRecipients)
{
  Attachment avatarAttachment = null;
  String     groupRecipientId = GroupUtil.getEncodedId(groupId);
  Recipients groupRecipient   = RecipientFactory.getRecipientsFromString(context, groupRecipientId, false);

  GroupContext.Builder groupContextBuilder = GroupContext.newBuilder()
                                                         .setId(ByteString.copyFrom(groupId))
                                                         .setType(GroupContext.Type.UPDATE)
                                                         .addAllMembers(e164numbers)
                                                         .addAllAdmins(adminE164numbers);
  if (groupName != null) groupContextBuilder.setName(groupName);

  if(ownerE164number != null) {
    groupContextBuilder.setOwner(ownerE164number);
  }

  GroupContext groupContext = groupContextBuilder.build();

  if (avatar != null) {
    Uri avatarUri = SingleUseBlobProvider.getInstance().createUri(avatar);
    avatarAttachment = new UriAttachment(avatarUri, ContentType.IMAGE_PNG, AttachmentDatabase.TRANSFER_PROGRESS_DONE, avatar.length);
  }

  OutgoingGroupMediaMessage outgoingMessage = new OutgoingGroupMediaMessage(groupRecipient, groupContext, avatarAttachment, System.currentTimeMillis(), 0);
  long                      threadId        = MessageSender.send(context, masterSecret, outgoingMessage, -1, false, destRecipients);

  return new GroupActionResult(groupRecipient, threadId);
}
 
開發者ID:XecureIT,項目名稱:PeSanKita-android,代碼行數:38,代碼來源:GroupManager.java

示例6: sendGroupUpdate

import org.thoughtcrime.securesms.util.GroupUtil; //導入方法依賴的package包/類
private static GroupActionResult sendGroupUpdate(@NonNull  Context      context,
                                                 @NonNull  MasterSecret masterSecret,
                                                 @NonNull  byte[]       groupId,
                                                 @NonNull  Set<String>  e164numbers,
                                                 @Nullable String       groupName,
                                                 @Nullable byte[]       avatar)
{
  Attachment avatarAttachment = null;
  String     groupRecipientId = GroupUtil.getEncodedId(groupId);
  Recipients groupRecipient   = RecipientFactory.getRecipientsFromString(context, groupRecipientId, false);

  GroupContext.Builder groupContextBuilder = GroupContext.newBuilder()
                                                         .setId(ByteString.copyFrom(groupId))
                                                         .setType(GroupContext.Type.UPDATE)
                                                         .addAllMembers(e164numbers);
  if (groupName != null) groupContextBuilder.setName(groupName);
  GroupContext groupContext = groupContextBuilder.build();

  if (avatar != null) {
    Uri avatarUri = SingleUseBlobProvider.getInstance().createUri(avatar);
    avatarAttachment = new UriAttachment(avatarUri, MediaUtil.IMAGE_PNG, AttachmentDatabase.TRANSFER_PROGRESS_DONE, avatar.length, null, false);
  }

  OutgoingGroupMediaMessage outgoingMessage = new OutgoingGroupMediaMessage(groupRecipient, groupContext, avatarAttachment, System.currentTimeMillis(), 0);
  long                      threadId        = MessageSender.send(context, masterSecret, outgoingMessage, -1, false, null);

  return new GroupActionResult(groupRecipient, threadId);
}
 
開發者ID:CableIM,項目名稱:Cable-Android,代碼行數:29,代碼來源:GroupManager.java

示例7: IncomingMediaMessage

import org.thoughtcrime.securesms.util.GroupUtil; //導入方法依賴的package包/類
public IncomingMediaMessage(MasterSecret masterSecret,
                            String from,
                            String to,
                            long sentTimeMillis,
                            Optional<String> relay,
                            Optional<String> body,
                            Optional<TextSecureGroup> group,
                            Optional<List<TextSecureAttachment>> attachments)
{
  this.headers = new PduHeaders();
  this.body    = new PduBody();
  this.push    = true;

  if (group.isPresent()) {
    this.groupId = GroupUtil.getEncodedId(group.get().getGroupId());
  } else {
    this.groupId = null;
  }

  this.headers.setEncodedStringValue(new EncodedStringValue(from), PduHeaders.FROM);
  this.headers.appendEncodedStringValue(new EncodedStringValue(to), PduHeaders.TO);
  this.headers.setLongInteger(sentTimeMillis / 1000, PduHeaders.DATE);


  if (body.isPresent() && !TextUtils.isEmpty(body.get())) {
    PduPart text = new PduPart();
    text.setData(Util.toUtf8Bytes(body.get()));
    text.setContentType(Util.toIsoBytes("text/plain"));
    text.setCharset(CharacterSets.UTF_8);
    this.body.addPart(text);
  }

  if (attachments.isPresent()) {
    for (TextSecureAttachment attachment : attachments.get()) {
      if (attachment.isPointer()) {
        PduPart media        = new PduPart();
        byte[]  encryptedKey = new MasterCipher(masterSecret).encryptBytes(attachment.asPointer().getKey());

        media.setContentType(Util.toIsoBytes(attachment.getContentType()));
        media.setContentLocation(Util.toIsoBytes(String.valueOf(attachment.asPointer().getId())));
        media.setContentDisposition(Util.toIsoBytes(Base64.encodeBytes(encryptedKey)));

        if (relay.isPresent()) {
          media.setName(Util.toIsoBytes(relay.get()));
        }

        media.setPendingPush(true);

        this.body.addPart(media);
      }
    }
  }
}
 
開發者ID:redcracker,項目名稱:TextSecure,代碼行數:54,代碼來源:IncomingMediaMessage.java


注:本文中的org.thoughtcrime.securesms.util.GroupUtil.getEncodedId方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。