From 4271398147991320157cd9d474fc718c8e3531b4 Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Tue, 22 Mar 2011 14:20:34 +0100 Subject: [PATCH] Hide identity in notifications if no %s in message. --- res/values/custom.xml | 5 +++-- res/values/strings.xml | 5 ++--- src/org/linphone/LinphoneService.java | 26 ++++++++++---------------- 3 files changed, 15 insertions(+), 21 deletions(-) diff --git a/res/values/custom.xml b/res/values/custom.xml index be5f6a2cf..9e67f257b 100644 --- a/res/values/custom.xml +++ b/res/values/custom.xml @@ -15,7 +15,8 @@ false Linphone - true - + true + registered to %s + fails to register to %s \ No newline at end of file diff --git a/res/values/strings.xml b/res/values/strings.xml index a30eaff15..c35cf618d 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -93,9 +93,8 @@ Clear Cannot get call parameters Cannot create default call parameters -Cannot invite destination address [%s] -registered to %s -fails to register to %s +Cannot invite destination address [%s] + started Removes the echo heard by other end Stun server diff --git a/src/org/linphone/LinphoneService.java b/src/org/linphone/LinphoneService.java index 9525fe105..5b0038d15 100644 --- a/src/org/linphone/LinphoneService.java +++ b/src/org/linphone/LinphoneService.java @@ -119,22 +119,16 @@ public final class LinphoneService extends Service implements LinphoneServiceLis - - - private void sendNotification(int level, int text) { + private void sendNotification(int level, int textId) { mNotif.iconLevel = level; mNotif.when=System.currentTimeMillis(); - mNotif.setLatestEventInfo(this, notificationTitle,getString(text), mNotifContentIntent); - mNotificationMgr.notify(NOTIF_ID, mNotif); - } - - private void sendNotificationWithId(int level, int text) { - mNotif.iconLevel = level; - mNotif.when=System.currentTimeMillis(); - String id = LinphoneManager.getLc().getDefaultProxyConfig().getIdentity(); - mNotif.setLatestEventInfo(this, notificationTitle, - String.format(getString(text), id), - mNotifContentIntent); + String text = getString(textId); + if (text.contains("%s")) { + String id = LinphoneManager.getLc().getDefaultProxyConfig().getIdentity(); + text = String.format(text, id); + } + + mNotif.setLatestEventInfo(this, notificationTitle, text, mNotifContentIntent); mNotificationMgr.notify(NOTIF_ID, mNotif); } @@ -191,11 +185,11 @@ public final class LinphoneService extends Service implements LinphoneServiceLis public void onRegistrationStateChanged(final RegistrationState state, final String message) { if (state == RegistrationState.RegistrationOk && LinphoneManager.getLc().getDefaultProxyConfig().isRegistered()) { - sendNotificationWithId(IC_LEVEL_ORANGE, R.string.notification_registered); + sendNotification(IC_LEVEL_ORANGE, R.string.notification_registered); } if (state == RegistrationState.RegistrationFailed) { - sendNotificationWithId(IC_LEVEL_OFFLINE, R.string.notification_register_failure); + sendNotification(IC_LEVEL_OFFLINE, R.string.notification_register_failure); } if (state == RegistrationState.RegistrationOk || state == RegistrationState.RegistrationFailed) {