mirror of
https://github.com/oxen-io/session-android.git
synced 2025-12-03 08:02:24 +00:00
committed by
Moxie Marlinspike
parent
e277f9f6d1
commit
d7419caa4b
@@ -1,5 +1,6 @@
|
||||
package org.thoughtcrime.securesms.util;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import com.google.protobuf.InvalidProtocolBufferException;
|
||||
@@ -7,6 +8,7 @@ import com.google.protobuf.InvalidProtocolBufferException;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import org.thoughtcrime.securesms.R;
|
||||
import static org.whispersystems.textsecure.internal.push.PushMessageProtos.PushMessageContent.GroupContext;
|
||||
|
||||
public class GroupUtil {
|
||||
@@ -29,32 +31,32 @@ public class GroupUtil {
|
||||
return groupId.startsWith(ENCODED_GROUP_PREFIX);
|
||||
}
|
||||
|
||||
public static String getDescription(String encodedGroup) {
|
||||
public static String getDescription(Context context, String encodedGroup) {
|
||||
if (encodedGroup == null) {
|
||||
return "Group updated.";
|
||||
return context.getString(R.string.GroupUtil_group_updated);
|
||||
}
|
||||
|
||||
try {
|
||||
String description = "";
|
||||
GroupContext context = GroupContext.parseFrom(Base64.decode(encodedGroup));
|
||||
List<String> members = context.getMembersList();
|
||||
String title = context.getName();
|
||||
GroupContext groupContext = GroupContext.parseFrom(Base64.decode(encodedGroup));
|
||||
List<String> members = groupContext.getMembersList();
|
||||
String title = groupContext.getName();
|
||||
|
||||
if (!members.isEmpty()) {
|
||||
description += Util.join(members, ", ") + " joined the group.";
|
||||
description += context.getString(R.string.GroupUtil_joined_the_group, Util.join(members, ", "));
|
||||
}
|
||||
|
||||
if (title != null && !title.trim().isEmpty()) {
|
||||
description += " Title is now '" + title + "'.";
|
||||
description += context.getString(R.string.GroupUtil_title_is_now, title);
|
||||
}
|
||||
|
||||
return description;
|
||||
} catch (InvalidProtocolBufferException e) {
|
||||
Log.w("GroupUtil", e);
|
||||
return "Group updated.";
|
||||
return context.getString(R.string.GroupUtil_group_updated);
|
||||
} catch (IOException e) {
|
||||
Log.w("GroupUtil", e);
|
||||
return "Group updated.";
|
||||
return context.getString(R.string.GroupUtil_group_updated);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user