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

@ -111,6 +111,7 @@
<string name="ConversationActivity_transport_textsecure">TextSecure</string>
<string name="ConversationActivity_get_with_it">Get with it: %s</string>
<string name="ConversationActivity_install_textsecure">Install TextSecure: %s</string>
<string name="ConversationActivity_error_leaving_group">Error leaving group...</string>
<!-- ConversationFragment -->
<string name="ConversationFragment_message_details">Message details</string>
@ -150,13 +151,9 @@
</string>
<string name="ExportFragment_cancel">Cancel</string>
<string name="ExportFragment_exporting">Exporting</string>
<string name="ExportFragment_exporting_plaintext_to_sd_card">Exporting plaintext to SD card...
</string>
<string name="ExportFragment_error_unable_to_write_to_sd_card">Error, unable to write to SD
card!
</string>
<string name="ExportFragment_error_while_writing_to_sd_card">Error while writing to SD card.
</string>
<string name="ExportFragment_exporting_plaintext_to_sd_card">Exporting plaintext to SD card...</string>
<string name="ExportFragment_error_unable_to_write_to_sd_card">Error, unable to write to SD card!</string>
<string name="ExportFragment_error_while_writing_to_sd_card">Error while writing to SD card.</string>
<string name="ExportFragment_success">Success!</string>
<!-- GcmRefreshJob -->
@ -177,11 +174,12 @@
<string name="GroupCreateActivity_menu_create_title">Create group</string>
<string name="GroupCreateActivity_creating_group">Creating %1$s&#8230;</string>
<string name="GroupCreateActivity_updating_group">Updating %1$s...</string>
<string name="GroupCreateActivity_loading_group_details">Loading group details</string>
<string name="GroupCreateActivity_cannot_add_non_push_to_existing_group">Cannot add non-TextSecure contacts to an existing TextSecure group</string>
<string name="GroupCreateActivity_loading_group_details">Loading group details...</string>
<!-- GroupMembersDialog -->
<string name="GroupMembersDialog_me">Me</string>
<string name="GroupMembersDialog_members">Members...</string>
<!-- ImportExportActivity -->
<string name="ImportExportActivity_import">Import</string>
@ -232,6 +230,8 @@
<!-- MessageRecord -->
<string name="MessageRecord_message_encrypted_with_a_legacy_protocol_version_that_is_no_longer_supported">Received a message encrypted using an old version of TextSecure that is no longer supported. Please ask the sender to upgrade to the most recent version and resend the message.</string>
<string name="MessageRecord_left_group">You have left the group.</string>
<string name="MessageRecord_updated_group">Updated the group.</string>
<!-- PassphraseChangeActivity -->
<string name="PassphraseChangeActivity_passphrases_dont_match_exclamation">Passphrases don\'t match!</string>
@ -513,6 +513,11 @@
<string name="MmsPreferencesFragment__invalid_uri">The text entered was not a valid URI</string>
<string name="MmsPreferencesFragment__invalid_host">The text entered was not a valid host</string>
<!-- GroupUtil -->
<string name="GroupUtil_joined_the_group">%1$s joined the group.</string>
<string name="GroupUtil_group_updated">Group updated.</string>
<string name="GroupUtil_title_is_now">Title is now \'%1$s\'.</string>
<!-- prompt_passphrase_activity -->
<string name="prompt_passphrase_activity__unlock">Unlock</string>
@ -817,6 +822,7 @@
<!-- MediaPreviewActivity -->
<string name="MediaPreviewActivity_you">You</string>
<string name="MediaPreviewActivity_cant_display">Failed to preview this image</string>
<string name="MediaPreviewActivity_unssuported_media_type">Unsupported media type</string>
<!-- media_preview -->
<string name="media_preview__save_title">Save</string>

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