From 123c7b211974bee0c7e32af3d7acd635c7c2345d Mon Sep 17 00:00:00 2001 From: Moxie Marlinspike Date: Thu, 24 Sep 2015 16:53:48 -0700 Subject: [PATCH] Extract RedPhone string resources // FREEBIE --- res/layout/redphone_call_card.xml | 2 +- res/layout/redphone_call_controls.xml | 6 +-- res/values/strings.xml | 36 ++++++++++++++- src/org/thoughtcrime/redphone/RedPhone.java | 44 +++++++++---------- .../redphone/audio/OutgoingRinger.java | 13 +----- .../redphone/ui/NotificationBarManager.java | 8 ++-- .../securesms/ConversationActivity.java | 2 +- 7 files changed, 66 insertions(+), 45 deletions(-) diff --git a/res/layout/redphone_call_card.xml b/res/layout/redphone_call_card.xml index c494b586f..0b442b922 100644 --- a/res/layout/redphone_call_card.xml +++ b/res/layout/redphone_call_card.xml @@ -124,7 +124,7 @@ android:maxLines="1" android:ellipsize="end" android:visibility="visible" - android:text="RedPhone Call" + android:text="@string/redphone_call_card__signal_call" /> diff --git a/res/layout/redphone_call_controls.xml b/res/layout/redphone_call_controls.xml index e676c1661..cecc9ffad 100644 --- a/res/layout/redphone_call_controls.xml +++ b/res/layout/redphone_call_controls.xml @@ -137,7 +137,7 @@ android:layout_weight="1" android:src="@drawable/redphone_ic_end_call" android:background="@drawable/selectable_item_background" - android:contentDescription="end call"/> + android:contentDescription="@string/redphone_call_controls__end_call"/> @@ -199,7 +199,7 @@ Are you sure you want to unblock this contact? Unblock Attachment exceeds size limits for the type of message you\'re sending. + Camera unavailable Message details @@ -271,6 +272,11 @@ Error connecting to MMS provider... Error reading wireless provider MMS settings... + + Signal call in progress + Missed call from %s + Missed Signal call + Multimedia message @@ -328,6 +334,28 @@ Enabled Disabled + + Answering + Ending call + Dialing + Canceling call + Call rejected + Ringing + Busy + Connected + Connecting + Handshake failed! + Recipient unavailable + Performing handshake + Server failed! + Client failed + Fatal Error + Login failed! + Message from the server + Number not registered! + The number you dialed does not support secure voice! + Got it + Connect With Signal Select your country @@ -632,6 +660,12 @@ Color Color for this contact + + Signal Call + end call + Audio + Mute + Verify your phone number to connect with Signal. @@ -1009,8 +1043,6 @@ Transport icon - - Camera unavailable diff --git a/src/org/thoughtcrime/redphone/RedPhone.java b/src/org/thoughtcrime/redphone/RedPhone.java index ebb302b41..fdfd3c3c8 100644 --- a/src/org/thoughtcrime/redphone/RedPhone.java +++ b/src/org/thoughtcrime/redphone/RedPhone.java @@ -158,7 +158,7 @@ public class RedPhone extends Activity { private void handleAnswerCall() { state = STATE_ANSWERING; - callScreen.setActiveCall(redPhoneService.getRecipient(), "Answering"); + callScreen.setActiveCall(redPhoneService.getRecipient(), getString(org.thoughtcrime.securesms.R.string.RedPhone_answering)); Intent intent = new Intent(this, RedPhoneService.class); intent.setAction(RedPhoneService.ACTION_ANSWER_CALL); @@ -172,7 +172,7 @@ public class RedPhone extends Activity { intent.setAction(RedPhoneService.ACTION_DENY_CALL); startService(intent); - callScreen.setActiveCall(redPhoneService.getRecipient(), "Ending call"); + callScreen.setActiveCall(redPhoneService.getRecipient(), getString(org.thoughtcrime.securesms.R.string.RedPhone_ending_call)); delayedFinish(); } @@ -183,7 +183,7 @@ public class RedPhone extends Activity { private void handleOutgoingCall(Recipient recipient) { state = STATE_DIALING; - callScreen.setActiveCall(recipient, "Dialing"); + callScreen.setActiveCall(recipient, getString(org.thoughtcrime.securesms.R.string.RedPhone_dialing)); } private void handleTerminate( int terminationType ) { @@ -192,12 +192,12 @@ public class RedPhone extends Activity { if( state == STATE_DIALING ) { if (terminationType == LOCAL_TERMINATE) { - callScreen.setActiveCall(redPhoneService.getRecipient(), "Canceling call"); + callScreen.setActiveCall(redPhoneService.getRecipient(), getString(org.thoughtcrime.securesms.R.string.RedPhone_canceling_call)); } else { - callScreen.setActiveCall(redPhoneService.getRecipient(), "Call rejected"); + callScreen.setActiveCall(redPhoneService.getRecipient(), getString(R.string.RedPhone_call_rejected)); } } else if (state != STATE_IDLE) { - callScreen.setActiveCall(redPhoneService.getRecipient(), "Ending call"); + callScreen.setActiveCall(redPhoneService.getRecipient(), getString(R.string.RedPhone_ending_call)); } state = STATE_IDLE; @@ -205,11 +205,11 @@ public class RedPhone extends Activity { } private void handleCallRinging() { - callScreen.setActiveCall(redPhoneService.getRecipient(), "Ringing"); + callScreen.setActiveCall(redPhoneService.getRecipient(), getString(R.string.RedPhone_ringing)); } private void handleCallBusy() { - callScreen.setActiveCall(redPhoneService.getRecipient(), "Busy"); + callScreen.setActiveCall(redPhoneService.getRecipient(), getString(R.string.RedPhone_busy)); state = STATE_IDLE; delayedFinish(BUSY_SIGNAL_DELAY_FINISH); @@ -217,7 +217,7 @@ public class RedPhone extends Activity { private void handleCallConnected(SASInfo sas) { getWindow().addFlags(WindowManager.LayoutParams.FLAG_IGNORE_CHEEK_PRESSES); - callScreen.setActiveCall(redPhoneService.getRecipient(), "Connected", sas); + callScreen.setActiveCall(redPhoneService.getRecipient(), getString(R.string.RedPhone_connected), sas); state = STATE_CONNECTED; redPhoneService.notifyCallConnectionUIUpdateComplete(); @@ -228,40 +228,40 @@ public class RedPhone extends Activity { } private void handleConnectingToInitiator() { - callScreen.setActiveCall(redPhoneService.getRecipient(), "Connecting"); + callScreen.setActiveCall(redPhoneService.getRecipient(), getString(R.string.RedPhone_connecting)); } private void handleHandshakeFailed() { state = STATE_IDLE; - callScreen.setActiveCall(redPhoneService.getRecipient(), "Handshake failed!"); + callScreen.setActiveCall(redPhoneService.getRecipient(), getString(R.string.RedPhone_handshake_failed)); delayedFinish(); } private void handleRecipientUnavailable() { state = STATE_IDLE; - callScreen.setActiveCall(redPhoneService.getRecipient(), "Recipient unavailable"); + callScreen.setActiveCall(redPhoneService.getRecipient(), getString(R.string.RedPhone_recipient_unavailable)); delayedFinish(); } private void handlePerformingHandshake() { - callScreen.setActiveCall(redPhoneService.getRecipient(), "Performing handshake"); + callScreen.setActiveCall(redPhoneService.getRecipient(), getString(R.string.RedPhone_performing_handshake)); } private void handleServerFailure() { state = STATE_IDLE; - callScreen.setActiveCall(redPhoneService.getRecipient(), "Server failed!"); + callScreen.setActiveCall(redPhoneService.getRecipient(), getString(R.string.RedPhone_network_failed)); delayedFinish(); } private void handleClientFailure(String msg) { state = STATE_IDLE; - callScreen.setActiveCall(redPhoneService.getRecipient(), "Client failed"); + callScreen.setActiveCall(redPhoneService.getRecipient(), getString(R.string.RedPhone_client_failed)); if( msg != null && !isFinishing() ) { AlertDialog.Builder ad = new AlertDialog.Builder(this); - ad.setTitle("Fatal Error"); + ad.setTitle(R.string.RedPhone_fatal_error); ad.setMessage(msg); ad.setCancelable(false); - ad.setPositiveButton("Ok", new OnClickListener() { + ad.setPositiveButton(android.R.string.ok, new OnClickListener() { public void onClick(DialogInterface dialog, int arg) { RedPhone.this.handleTerminate(LOCAL_TERMINATE); } @@ -272,14 +272,14 @@ public class RedPhone extends Activity { private void handleLoginFailed() { state = STATE_IDLE; - callScreen.setActiveCall(redPhoneService.getRecipient(), "Login failed!"); + callScreen.setActiveCall(redPhoneService.getRecipient(), getString(R.string.RedPhone_login_failed)); delayedFinish(); } private void handleServerMessage(String message) { if( isFinishing() ) return; //we're already shutting down, this might crash AlertDialog.Builder ad = new AlertDialog.Builder(this); - ad.setTitle("Message from the server"); + ad.setTitle(R.string.RedPhone_message_from_the_server); ad.setMessage(message); ad.setCancelable(false); ad.setPositiveButton(android.R.string.ok, new OnClickListener() { @@ -293,11 +293,11 @@ public class RedPhone extends Activity { private void handleNoSuchUser(final Recipient recipient) { if (isFinishing()) return; // XXX Stuart added this check above, not sure why, so I'm repeating in ignorance. - moxie AlertDialogWrapper.Builder dialog = new AlertDialogWrapper.Builder(this); - dialog.setTitle("Number not registered!"); + dialog.setTitle(R.string.RedPhone_number_not_registered); dialog.setIconAttribute(R.attr.dialog_alert_icon); - dialog.setMessage("The number you dialed does not support secure voice!"); + dialog.setMessage(R.string.RedPhone_the_number_you_dialed_does_not_support_secure_voice); dialog.setCancelable(true); - dialog.setPositiveButton("Got it", new OnClickListener() { + dialog.setPositiveButton(R.string.RedPhone_got_it, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { RedPhone.this.handleTerminate(LOCAL_TERMINATE); diff --git a/src/org/thoughtcrime/redphone/audio/OutgoingRinger.java b/src/org/thoughtcrime/redphone/audio/OutgoingRinger.java index 860b780e5..fe29ea992 100644 --- a/src/org/thoughtcrime/redphone/audio/OutgoingRinger.java +++ b/src/org/thoughtcrime/redphone/audio/OutgoingRinger.java @@ -96,21 +96,10 @@ public class OutgoingRinger implements MediaPlayer.OnCompletionListener, MediaPl try { mediaPlayer.setDataSource(context, dataUri); - } catch (IllegalArgumentException e) { + } catch (IllegalArgumentException | SecurityException | IllegalStateException | IOException e) { Log.w(TAG, e); // TODO Auto-generated catch block return; - } catch (SecurityException e) { - // TODO Auto-generated catch block - Log.w(TAG, e); - return; - } catch (IllegalStateException e) { - Log.w(TAG, e); - return; - } catch (IOException e) { - // TODO Auto-generated catch block - Log.w(TAG, e); - return; } try { mediaPlayer.prepareAsync(); diff --git a/src/org/thoughtcrime/redphone/ui/NotificationBarManager.java b/src/org/thoughtcrime/redphone/ui/NotificationBarManager.java index 47c2c4d19..41142f0d6 100644 --- a/src/org/thoughtcrime/redphone/ui/NotificationBarManager.java +++ b/src/org/thoughtcrime/redphone/ui/NotificationBarManager.java @@ -58,7 +58,7 @@ public class NotificationBarManager { Intent contentIntent = new Intent(context, RedPhone.class); contentIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, contentIntent, 0); - String notificationText = "Signal call in progress"; + String notificationText = context.getString(R.string.NotificationBarManager_signal_call_in_progress); Notification notification = new Notification(R.drawable.redphone_stat_sys_phone_call, null, System.currentTimeMillis()); @@ -79,9 +79,9 @@ public class NotificationBarManager { NotificationCompat.Builder builder = new NotificationCompat.Builder(context); builder.setSmallIcon(R.drawable.ic_call_missed_grey600_24dp); builder.setWhen(System.currentTimeMillis()); - builder.setTicker(String.format("Missed call from %s", notifyRecipients.toShortString())); - builder.setContentTitle("Missed Signal call"); - builder.setContentText(String.format("Missed call from %s", notifyRecipients.toShortString())); + builder.setTicker(context.getString(R.string.NotificationBarManager_missed_call_from_s, notifyRecipients.toShortString())); + builder.setContentTitle(context.getString(R.string.NotificationBarManager_missed_signal_call)); + builder.setContentText(context.getString(R.string.NotificationBarManager_missed_call_from_s, notifyRecipients.toShortString())); builder.setContentIntent(pendingIntent); builder.setDefaults(Notification.DEFAULT_VIBRATE); builder.setAutoCancel(true); diff --git a/src/org/thoughtcrime/securesms/ConversationActivity.java b/src/org/thoughtcrime/securesms/ConversationActivity.java index 7ee554635..b62a7cb79 100644 --- a/src/org/thoughtcrime/securesms/ConversationActivity.java +++ b/src/org/thoughtcrime/securesms/ConversationActivity.java @@ -1323,7 +1323,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity @Override public void onCameraFail(FailureReason reason) { - Toast.makeText(this, R.string.quick_camera_unavailable, Toast.LENGTH_SHORT).show(); + Toast.makeText(this, R.string.ConversationActivity_quick_camera_unavailable, Toast.LENGTH_SHORT).show(); quickAttachmentDrawer.hide(false); quickAttachmentToggle.disable(); }