mirror of
https://github.com/oxen-io/session-android.git
synced 2025-10-20 14:54:09 +00:00
Extract TextSecure strings for i18n.
1) Change all instances which use concatenation to build strings with variables in them to use string formatting instead. 2) Extract all string literals from layouts and menus into strings.xml 3) Extract all string literals from code into strings.xml
This commit is contained in:
@@ -80,7 +80,7 @@ public class ApplicationMigrationService extends Service
|
||||
|
||||
private Notification initializeBackgroundNotification() {
|
||||
Intent intent = new Intent(this, ConversationListActivity.class);
|
||||
Notification notification = new Notification(R.drawable.icon, "Migrating",
|
||||
Notification notification = new Notification(R.drawable.icon, getString(R.string.migrating),
|
||||
System.currentTimeMillis());
|
||||
|
||||
notification.flags = notification.flags | Notification.FLAG_ONGOING_EVENT;
|
||||
@@ -89,7 +89,7 @@ public class ApplicationMigrationService extends Service
|
||||
|
||||
notification.contentIntent = PendingIntent.getActivity(getApplicationContext(), 0, intent, 0);
|
||||
notification.contentView.setImageViewResource(R.id.status_icon, R.drawable.icon);
|
||||
notification.contentView.setTextViewText(R.id.status_text, "Migrating System Text Messages");
|
||||
notification.contentView.setTextViewText(R.id.status_text, getString(R.string.migrating_system_text_messages));
|
||||
notification.contentView.setProgressBar(R.id.status_progress, 10000, 0, false);
|
||||
|
||||
stopForeground(true);
|
||||
|
@@ -142,10 +142,13 @@ public class KeyCachingService extends Service {
|
||||
}
|
||||
|
||||
private void foregroundService() {
|
||||
Notification notification = new Notification(R.drawable.icon_cached, "TextSecure Passphrase Cached", System.currentTimeMillis());
|
||||
Notification notification = new Notification(R.drawable.icon_cached,
|
||||
getString(R.string.textsecure_passphrase_cached),
|
||||
System.currentTimeMillis());
|
||||
Intent intent = new Intent(this, ConversationListActivity.class);
|
||||
PendingIntent launchIntent = PendingIntent.getActivity(getApplicationContext(), 0, intent, 0);
|
||||
notification.setLatestEventInfo(getApplicationContext(), "TextSecure Cached", "TextSecure Passphrase Cached", launchIntent);
|
||||
notification.setLatestEventInfo(getApplicationContext(), getString(R.string.textsecure_cached),
|
||||
getString(R.string.textsecure_passphrase_cached), launchIntent);
|
||||
|
||||
stopForeground(true);
|
||||
startForeground(SERVICE_RUNNING_ID, notification);
|
||||
|
@@ -54,31 +54,27 @@ public class MessageNotifier {
|
||||
|
||||
public static final int NOTIFICATION_ID = 1338;
|
||||
|
||||
private static String buildTickerMessage(int count, Recipients recipients) {
|
||||
private static String buildTickerMessage(Context context, int count, Recipients recipients) {
|
||||
Recipient recipient = recipients.getPrimaryRecipient();
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append('(');
|
||||
builder.append(count);
|
||||
builder.append(')');
|
||||
builder.append(" New messages");
|
||||
|
||||
if (recipient != null) {
|
||||
builder.append(", most recent from: ");
|
||||
builder.append(recipient.getName() == null ? recipient.getNumber() : recipient.getName());
|
||||
if (recipient == null) {
|
||||
return String.format(context.getString(R.string._d_new_messages), count);
|
||||
} else {
|
||||
return String.format(context.getString(R.string._d_new_messages_most_recent_from_s), count,
|
||||
recipient.getName() == null ? recipient.getNumber() : recipient.getName());
|
||||
}
|
||||
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
private static String buildTitleMessage(int count) {
|
||||
return "(" + count + ") New Messages";
|
||||
private static String buildTitleMessage(Context context, int count) {
|
||||
return String.format(context.getString(R.string._d_new_messages), count);
|
||||
}
|
||||
|
||||
private static String buildSubtitleMessage(Recipients recipients) {
|
||||
private static String buildSubtitleMessage(Context context, Recipients recipients) {
|
||||
Recipient recipient = recipients.getPrimaryRecipient();
|
||||
|
||||
if (recipient != null) {
|
||||
return "Most recent from: " + (recipient.getName() == null ? recipient.getNumber() : recipient.getName());
|
||||
return String.format(context.getString(R.string.most_recent_from_s),
|
||||
(recipient.getName() == null ? recipient.getNumber() : recipient.getName()));
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -98,15 +94,15 @@ public class MessageNotifier {
|
||||
private static Recipients getMostRecentRecipients(Context context, Cursor c) {
|
||||
if (c != null && c.moveToLast()) {
|
||||
try {
|
||||
String type = c.getString(c.getColumnIndexOrThrow(MmsSmsDatabase.TRANSPORT));
|
||||
String type = c.getString(c.getColumnIndexOrThrow(MmsSmsDatabase.TRANSPORT));
|
||||
|
||||
if (type.equals("sms"))
|
||||
return getSmsRecipient(context, c);
|
||||
else
|
||||
return getMmsRecipient(context, c);
|
||||
if (type.equals("sms"))
|
||||
return getSmsRecipient(context, c);
|
||||
else
|
||||
return getMmsRecipient(context, c);
|
||||
|
||||
} catch (RecipientFormattingException e) {
|
||||
return new Recipients(new LinkedList<Recipient>());
|
||||
return new Recipients(new LinkedList<Recipient>());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,8 +122,8 @@ public class MessageNotifier {
|
||||
Log.w("SmsNotifier", "Adding thread_id to pending intent: " + threadId);
|
||||
|
||||
if (recipients.getPrimaryRecipient() != null) {
|
||||
intent.putExtra("recipients", recipients);
|
||||
intent.putExtra("thread_id", threadId);
|
||||
intent.putExtra("recipients", recipients);
|
||||
intent.putExtra("thread_id", threadId);
|
||||
}
|
||||
|
||||
intent.setData((Uri.parse("custom://"+System.currentTimeMillis())));
|
||||
@@ -180,9 +176,9 @@ public class MessageNotifier {
|
||||
else if (c == null || !c.moveToFirst()) return;
|
||||
|
||||
Recipients recipients = getMostRecentRecipients(context, c);
|
||||
String ticker = buildTickerMessage(c.getCount(), recipients);
|
||||
String title = buildTitleMessage(c.getCount());
|
||||
String subtitle = buildSubtitleMessage(recipients);
|
||||
String ticker = buildTickerMessage(context, c.getCount(), recipients);
|
||||
String title = buildTitleMessage(context, c.getCount());
|
||||
String subtitle = buildSubtitleMessage(context, recipients);
|
||||
PendingIntent launchIntent = buildPendingIntent(context, c, recipients);
|
||||
|
||||
sendNotification(context, manager, launchIntent, ticker, title, subtitle, signal);
|
||||
|
Reference in New Issue
Block a user