Hide identity in notifications if no %s in message.

This commit is contained in:
Guillaume Beraudo 2011-03-22 14:20:34 +01:00
parent 73b3782f13
commit 4271398147
3 changed files with 15 additions and 21 deletions

View file

@ -16,6 +16,7 @@
<string name="notification_title">Linphone</string> <string name="notification_title">Linphone</string>
<bool name="allow_edit_in_dialer">true</bool> <bool name="allow_edit_in_dialer">true</bool>
<string name="notification_registered">registered to %s </string>
<string name="notification_register_failure">fails to register to %s</string>
</resources> </resources>

View file

@ -94,8 +94,7 @@
<string name="error_cannot_get_call_parameters">Cannot get call parameters</string> <string name="error_cannot_get_call_parameters">Cannot get call parameters</string>
<string name="error_cannot_create_default_parameters">Cannot create default call parameters</string> <string name="error_cannot_create_default_parameters">Cannot create default call parameters</string>
<string name="error_cannot_invite_address">Cannot invite destination address [%s]</string> <string name="error_cannot_invite_address">Cannot invite destination address [%s]</string>
<string name="notification_registered">registered to %s </string>
<string name="notification_register_failure">fails to register to %s</string>
<string name="notification_started">started</string> <string name="notification_started">started</string>
<string name="pref_echo_cancellation_summary">Removes the echo heard by other end</string> <string name="pref_echo_cancellation_summary">Removes the echo heard by other end</string>
<string name="pref_stun_server">Stun server</string> <string name="pref_stun_server">Stun server</string>

View file

@ -119,22 +119,16 @@ public final class LinphoneService extends Service implements LinphoneServiceLis
private void sendNotification(int level, int textId) {
private void sendNotification(int level, int text) {
mNotif.iconLevel = level; mNotif.iconLevel = level;
mNotif.when=System.currentTimeMillis(); mNotif.when=System.currentTimeMillis();
mNotif.setLatestEventInfo(this, notificationTitle,getString(text), mNotifContentIntent); String text = getString(textId);
mNotificationMgr.notify(NOTIF_ID, mNotif); if (text.contains("%s")) {
String id = LinphoneManager.getLc().getDefaultProxyConfig().getIdentity();
text = String.format(text, id);
} }
private void sendNotificationWithId(int level, int text) { mNotif.setLatestEventInfo(this, notificationTitle, text, mNotifContentIntent);
mNotif.iconLevel = level;
mNotif.when=System.currentTimeMillis();
String id = LinphoneManager.getLc().getDefaultProxyConfig().getIdentity();
mNotif.setLatestEventInfo(this, notificationTitle,
String.format(getString(text), id),
mNotifContentIntent);
mNotificationMgr.notify(NOTIF_ID, mNotif); mNotificationMgr.notify(NOTIF_ID, mNotif);
} }
@ -191,11 +185,11 @@ public final class LinphoneService extends Service implements LinphoneServiceLis
public void onRegistrationStateChanged(final RegistrationState state, public void onRegistrationStateChanged(final RegistrationState state,
final String message) { final String message) {
if (state == RegistrationState.RegistrationOk && LinphoneManager.getLc().getDefaultProxyConfig().isRegistered()) { 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) { 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) { if (state == RegistrationState.RegistrationOk || state == RegistrationState.RegistrationFailed) {