mirror of
https://github.com/oxen-io/session-android.git
synced 2025-10-27 22:38:53 +00:00
committed by
Moxie Marlinspike
parent
e277f9f6d1
commit
d7419caa4b
@@ -429,8 +429,8 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
builder.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
Context self = ConversationActivity.this;
|
||||
try {
|
||||
Context self = ConversationActivity.this;
|
||||
byte[] groupId = GroupUtil.getDecodedId(getRecipients().getPrimaryRecipient().getNumber());
|
||||
DatabaseFactory.getGroupDatabase(self).setActive(groupId, false);
|
||||
|
||||
@@ -446,7 +446,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
initializeEnabledCheck();
|
||||
} catch (IOException e) {
|
||||
Log.w(TAG, e);
|
||||
Toast.makeText(ConversationActivity.this, "Error leaving group....", Toast.LENGTH_LONG).show();
|
||||
Toast.makeText(self, R.string.ConversationActivity_error_leaving_group, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -34,7 +34,7 @@ public class GroupMembersDialog extends AsyncTask<Void, Void, Recipients> {
|
||||
|
||||
@Override
|
||||
public void onPreExecute() {
|
||||
progress = ProgressDialog.show(context, "Members...", "Members...", true, false);
|
||||
progress = ProgressDialog.show(context, context.getString(R.string.GroupMembersDialog_members), context.getString(R.string.GroupMembersDialog_members), true, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -126,7 +126,7 @@ public class MediaPreviewActivity extends PassphraseRequiredActionBarActivity {
|
||||
|
||||
if (!isContentTypeSupported(mediaType)) {
|
||||
Log.w(TAG, "Unsupported media type sent to MediaPreviewActivity, finishing.");
|
||||
Toast.makeText(getApplicationContext(), "Unsupported media type", Toast.LENGTH_LONG).show();
|
||||
Toast.makeText(getApplicationContext(), R.string.MediaPreviewActivity_unssuported_media_type, Toast.LENGTH_LONG).show();
|
||||
finish();
|
||||
}
|
||||
|
||||
|
||||
@@ -95,11 +95,11 @@ public abstract class MessageRecord extends DisplayRecord {
|
||||
@Override
|
||||
public SpannableString getDisplayBody() {
|
||||
if (isGroupUpdate() && isOutgoing()) {
|
||||
return emphasisAdded("Updated the group.");
|
||||
return emphasisAdded(context.getString(R.string.MessageRecord_updated_group));
|
||||
} else if (isGroupUpdate()) {
|
||||
return emphasisAdded(GroupUtil.getDescription(getBody().getBody()));
|
||||
return emphasisAdded(GroupUtil.getDescription(context, getBody().getBody()));
|
||||
} else if (isGroupQuit() && isOutgoing()) {
|
||||
return emphasisAdded("You have left the group.");
|
||||
return emphasisAdded(context.getString(R.string.MessageRecord_left_group));
|
||||
} else if (isGroupQuit()) {
|
||||
return emphasisAdded(context.getString(R.string.ConversationItem_group_action_left, getIndividualRecipient().toShortString()));
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ public class ThreadRecord extends DisplayRecord {
|
||||
if (SmsDatabase.Types.isDecryptInProgressType(type)) {
|
||||
return emphasisAdded(context.getString(R.string.MessageDisplayHelper_decrypting_please_wait));
|
||||
} else if (isGroupUpdate()) {
|
||||
return emphasisAdded(GroupUtil.getDescription(getBody().getBody()));
|
||||
return emphasisAdded(GroupUtil.getDescription(context, getBody().getBody()));
|
||||
} else if (isGroupQuit()) {
|
||||
return emphasisAdded(context.getString(R.string.ThreadRecord_left_the_group));
|
||||
} else if (isKeyExchange()) {
|
||||
|
||||
@@ -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