Exemple #1
0
    public GroupDescription(@NonNull Context context, @Nullable GroupContext groupContext) {
      this.context = context.getApplicationContext();
      this.groupContext = groupContext;

      if (groupContext == null || groupContext.getMembersList().isEmpty()) {
        this.members = null;
      } else {
        this.members =
            RecipientFactory.getRecipientsFromString(
                context, Util.join(groupContext.getMembersList(), ", "), true);
      }
    }
Exemple #2
0
  /** @return external groups */
  public List<GroupSymbol> getAllExternalGroups() {
    if (externalGroups == null) {
      return Collections.emptyList();
    }

    return externalGroups.getAllGroups();
  }
Exemple #3
0
 /** @param root */
 public void setExternalGroupContexts(GroupContext root) {
   if (root == null) {
     this.externalGroups = null;
   } else {
     this.externalGroups = (GroupContext) root.clone();
   }
 }
Exemple #4
0
  public static @NonNull GroupDescription getDescription(
      @NonNull Context context, @Nullable String encodedGroup) {
    if (encodedGroup == null) {
      return new GroupDescription(context, null);
    }

    try {
      GroupContext groupContext = GroupContext.parseFrom(Base64.decode(encodedGroup));
      return new GroupDescription(context, groupContext);
    } catch (IOException e) {
      Log.w(TAG, e);
      return new GroupDescription(context, null);
    }
  }
  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);
  }
Exemple #6
0
    public String toString() {
      if (groupContext == null) {
        return context.getString(R.string.GroupUtil_group_updated);
      }

      StringBuilder description = new StringBuilder();
      String title = groupContext.getName();

      if (members != null) {
        description.append(
            context.getString(R.string.GroupUtil_joined_the_group, members.toShortString()));
      }

      if (title != null && !title.trim().isEmpty()) {
        if (description.length() > 0) description.append(" ");
        description.append(context.getString(R.string.GroupUtil_title_is_now, title));
      }

      if (description.length() > 0) {
        return description.toString();
      } else {
        return context.getString(R.string.GroupUtil_group_updated);
      }
    }