Skip to content

Commit d7419ca

Browse files
guiwebermoxie0
authored andcommitted
Moved several hard-coded UI strings to strings.xml
Closes signalapp#2203
1 parent e277f9f commit d7419ca

7 files changed

Lines changed: 33 additions & 25 deletions

File tree

res/values/strings.xml

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@
111111
<string name="ConversationActivity_transport_textsecure">TextSecure</string>
112112
<string name="ConversationActivity_get_with_it">Get with it: %s</string>
113113
<string name="ConversationActivity_install_textsecure">Install TextSecure: %s</string>
114+
<string name="ConversationActivity_error_leaving_group">Error leaving group...</string>
114115

115116
<!-- ConversationFragment -->
116117
<string name="ConversationFragment_message_details">Message details</string>
@@ -150,13 +151,9 @@
150151
</string>
151152
<string name="ExportFragment_cancel">Cancel</string>
152153
<string name="ExportFragment_exporting">Exporting</string>
153-
<string name="ExportFragment_exporting_plaintext_to_sd_card">Exporting plaintext to SD card...
154-
</string>
155-
<string name="ExportFragment_error_unable_to_write_to_sd_card">Error, unable to write to SD
156-
card!
157-
</string>
158-
<string name="ExportFragment_error_while_writing_to_sd_card">Error while writing to SD card.
159-
</string>
154+
<string name="ExportFragment_exporting_plaintext_to_sd_card">Exporting plaintext to SD card...</string>
155+
<string name="ExportFragment_error_unable_to_write_to_sd_card">Error, unable to write to SD card!</string>
156+
<string name="ExportFragment_error_while_writing_to_sd_card">Error while writing to SD card.</string>
160157
<string name="ExportFragment_success">Success!</string>
161158

162159
<!-- GcmRefreshJob -->
@@ -177,11 +174,12 @@
177174
<string name="GroupCreateActivity_menu_create_title">Create group</string>
178175
<string name="GroupCreateActivity_creating_group">Creating %1$s&#8230;</string>
179176
<string name="GroupCreateActivity_updating_group">Updating %1$s...</string>
180-
<string name="GroupCreateActivity_loading_group_details">Loading group details</string>
181177
<string name="GroupCreateActivity_cannot_add_non_push_to_existing_group">Cannot add non-TextSecure contacts to an existing TextSecure group</string>
178+
<string name="GroupCreateActivity_loading_group_details">Loading group details...</string>
182179

183180
<!-- GroupMembersDialog -->
184181
<string name="GroupMembersDialog_me">Me</string>
182+
<string name="GroupMembersDialog_members">Members...</string>
185183

186184
<!-- ImportExportActivity -->
187185
<string name="ImportExportActivity_import">Import</string>
@@ -232,6 +230,8 @@
232230

233231
<!-- MessageRecord -->
234232
<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>
233+
<string name="MessageRecord_left_group">You have left the group.</string>
234+
<string name="MessageRecord_updated_group">Updated the group.</string>
235235

236236
<!-- PassphraseChangeActivity -->
237237
<string name="PassphraseChangeActivity_passphrases_dont_match_exclamation">Passphrases don\'t match!</string>
@@ -513,6 +513,11 @@
513513
<string name="MmsPreferencesFragment__invalid_uri">The text entered was not a valid URI</string>
514514
<string name="MmsPreferencesFragment__invalid_host">The text entered was not a valid host</string>
515515

516+
<!-- GroupUtil -->
517+
<string name="GroupUtil_joined_the_group">%1$s joined the group.</string>
518+
<string name="GroupUtil_group_updated">Group updated.</string>
519+
<string name="GroupUtil_title_is_now">Title is now \'%1$s\'.</string>
520+
516521
<!-- prompt_passphrase_activity -->
517522
<string name="prompt_passphrase_activity__unlock">Unlock</string>
518523

@@ -817,6 +822,7 @@
817822
<!-- MediaPreviewActivity -->
818823
<string name="MediaPreviewActivity_you">You</string>
819824
<string name="MediaPreviewActivity_cant_display">Failed to preview this image</string>
825+
<string name="MediaPreviewActivity_unssuported_media_type">Unsupported media type</string>
820826

821827
<!-- media_preview -->
822828
<string name="media_preview__save_title">Save</string>

src/org/thoughtcrime/securesms/ConversationActivity.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -429,8 +429,8 @@ private void handleLeavePushGroup() {
429429
builder.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
430430
@Override
431431
public void onClick(DialogInterface dialog, int which) {
432+
Context self = ConversationActivity.this;
432433
try {
433-
Context self = ConversationActivity.this;
434434
byte[] groupId = GroupUtil.getDecodedId(getRecipients().getPrimaryRecipient().getNumber());
435435
DatabaseFactory.getGroupDatabase(self).setActive(groupId, false);
436436

@@ -446,7 +446,7 @@ public void onClick(DialogInterface dialog, int which) {
446446
initializeEnabledCheck();
447447
} catch (IOException e) {
448448
Log.w(TAG, e);
449-
Toast.makeText(ConversationActivity.this, "Error leaving group....", Toast.LENGTH_LONG).show();
449+
Toast.makeText(self, R.string.ConversationActivity_error_leaving_group, Toast.LENGTH_LONG).show();
450450
}
451451
}
452452
});

src/org/thoughtcrime/securesms/GroupMembersDialog.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public GroupMembersDialog(Context context, Recipients recipients) {
3434

3535
@Override
3636
public void onPreExecute() {
37-
progress = ProgressDialog.show(context, "Members...", "Members...", true, false);
37+
progress = ProgressDialog.show(context, context.getString(R.string.GroupMembersDialog_members), context.getString(R.string.GroupMembersDialog_members), true, false);
3838
}
3939

4040
@Override

src/org/thoughtcrime/securesms/MediaPreviewActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ public void onModified(Recipient recipient) {
126126

127127
if (!isContentTypeSupported(mediaType)) {
128128
Log.w(TAG, "Unsupported media type sent to MediaPreviewActivity, finishing.");
129-
Toast.makeText(getApplicationContext(), "Unsupported media type", Toast.LENGTH_LONG).show();
129+
Toast.makeText(getApplicationContext(), R.string.MediaPreviewActivity_unssuported_media_type, Toast.LENGTH_LONG).show();
130130
finish();
131131
}
132132

src/org/thoughtcrime/securesms/database/model/MessageRecord.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,11 @@ public boolean isAsymmetricEncryption() {
9595
@Override
9696
public SpannableString getDisplayBody() {
9797
if (isGroupUpdate() && isOutgoing()) {
98-
return emphasisAdded("Updated the group.");
98+
return emphasisAdded(context.getString(R.string.MessageRecord_updated_group));
9999
} else if (isGroupUpdate()) {
100-
return emphasisAdded(GroupUtil.getDescription(getBody().getBody()));
100+
return emphasisAdded(GroupUtil.getDescription(context, getBody().getBody()));
101101
} else if (isGroupQuit() && isOutgoing()) {
102-
return emphasisAdded("You have left the group.");
102+
return emphasisAdded(context.getString(R.string.MessageRecord_left_group));
103103
} else if (isGroupQuit()) {
104104
return emphasisAdded(context.getString(R.string.ConversationItem_group_action_left, getIndividualRecipient().toShortString()));
105105
}

src/org/thoughtcrime/securesms/database/model/ThreadRecord.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public SpannableString getDisplayBody() {
5757
if (SmsDatabase.Types.isDecryptInProgressType(type)) {
5858
return emphasisAdded(context.getString(R.string.MessageDisplayHelper_decrypting_please_wait));
5959
} else if (isGroupUpdate()) {
60-
return emphasisAdded(GroupUtil.getDescription(getBody().getBody()));
60+
return emphasisAdded(GroupUtil.getDescription(context, getBody().getBody()));
6161
} else if (isGroupQuit()) {
6262
return emphasisAdded(context.getString(R.string.ThreadRecord_left_the_group));
6363
} else if (isKeyExchange()) {

src/org/thoughtcrime/securesms/util/GroupUtil.java

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
package org.thoughtcrime.securesms.util;
22

3+
import android.content.Context;
34
import android.util.Log;
45

56
import com.google.protobuf.InvalidProtocolBufferException;
67

78
import java.io.IOException;
89
import java.util.List;
910

11+
import org.thoughtcrime.securesms.R;
1012
import static org.whispersystems.textsecure.internal.push.PushMessageProtos.PushMessageContent.GroupContext;
1113

1214
public class GroupUtil {
@@ -29,32 +31,32 @@ public static boolean isEncodedGroup(String groupId) {
2931
return groupId.startsWith(ENCODED_GROUP_PREFIX);
3032
}
3133

32-
public static String getDescription(String encodedGroup) {
34+
public static String getDescription(Context context, String encodedGroup) {
3335
if (encodedGroup == null) {
34-
return "Group updated.";
36+
return context.getString(R.string.GroupUtil_group_updated);
3537
}
3638

3739
try {
3840
String description = "";
39-
GroupContext context = GroupContext.parseFrom(Base64.decode(encodedGroup));
40-
List<String> members = context.getMembersList();
41-
String title = context.getName();
41+
GroupContext groupContext = GroupContext.parseFrom(Base64.decode(encodedGroup));
42+
List<String> members = groupContext.getMembersList();
43+
String title = groupContext.getName();
4244

4345
if (!members.isEmpty()) {
44-
description += Util.join(members, ", ") + " joined the group.";
46+
description += context.getString(R.string.GroupUtil_joined_the_group, Util.join(members, ", "));
4547
}
4648

4749
if (title != null && !title.trim().isEmpty()) {
48-
description += " Title is now '" + title + "'.";
50+
description += context.getString(R.string.GroupUtil_title_is_now, title);
4951
}
5052

5153
return description;
5254
} catch (InvalidProtocolBufferException e) {
5355
Log.w("GroupUtil", e);
54-
return "Group updated.";
56+
return context.getString(R.string.GroupUtil_group_updated);
5557
} catch (IOException e) {
5658
Log.w("GroupUtil", e);
57-
return "Group updated.";
59+
return context.getString(R.string.GroupUtil_group_updated);
5860
}
5961
}
6062
}

0 commit comments

Comments
 (0)