Moved several hard-coded UI strings to strings.xml

Closes #2203
This commit is contained in:
guiweber
2014-12-15 09:44:41 -05:00
committed by Moxie Marlinspike
parent e277f9f6d1
commit d7419caa4b
7 changed files with 33 additions and 25 deletions

View File

@@ -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();
}
}
});

View File

@@ -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

View File

@@ -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();
}

View File

@@ -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()));
}

View File

@@ -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()) {

View File

@@ -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);
}
}
}