Added method to disable registration status text in notification and possibility to put something else

This commit is contained in:
Sylvain Berfini 2014-06-27 11:39:42 +02:00
parent a754599bec
commit d828182689

View file

@ -76,6 +76,10 @@ public final class LinphoneService extends Service implements LinphoneServiceLis
* setLatestEventInfo and startActivity() which needs a context. * setLatestEventInfo and startActivity() which needs a context.
*/ */
public static final String START_LINPHONE_LOGS = " ==== Phone information dump ===="; public static final String START_LINPHONE_LOGS = " ==== Phone information dump ====";
public static final int IC_LEVEL_ORANGE=0;
/*private static final int IC_LEVEL_GREEN=1;
private static final int IC_LEVEL_RED=2;*/
public static final int IC_LEVEL_OFFLINE=3;
private static LinphoneService instance; private static LinphoneService instance;
@ -84,11 +88,6 @@ public final class LinphoneService extends Service implements LinphoneServiceLis
private final static int MESSAGE_NOTIF_ID=3; private final static int MESSAGE_NOTIF_ID=3;
private final static int CUSTOM_NOTIF_ID=4; private final static int CUSTOM_NOTIF_ID=4;
private static final int IC_LEVEL_ORANGE=0;
/*private static final int IC_LEVEL_GREEN=1;
private static final int IC_LEVEL_RED=2;*/
private static final int IC_LEVEL_OFFLINE=3;
public static boolean isReady() { public static boolean isReady() {
return instance != null && instance.mTestDelayElapsed; return instance != null && instance.mTestDelayElapsed;
} }
@ -118,6 +117,7 @@ public final class LinphoneService extends Service implements LinphoneServiceLis
private PendingIntent mNotifContentIntent; private PendingIntent mNotifContentIntent;
private PendingIntent mkeepAlivePendingIntent; private PendingIntent mkeepAlivePendingIntent;
private String mNotificationTitle; private String mNotificationTitle;
private boolean mDisableRegistrationStatus;
public int getMessageNotifCount() { public int getMessageNotifCount() {
return mMsgNotifCount; return mMsgNotifCount;
@ -429,7 +429,11 @@ public final class LinphoneService extends Service implements LinphoneServiceLis
} }
} }
private synchronized void sendNotification(int level, int textId) { public void disableNotificationsAutomaticRegistrationStatusContent() {
mDisableRegistrationStatus = true;
}
public synchronized void sendNotification(int level, int textId) {
String text = getString(textId); String text = getString(textId);
if (text.contains("%s") && LinphoneManager.getLc() != null) { if (text.contains("%s") && LinphoneManager.getLc() != null) {
// Test for null lc is to avoid a NPE when Android mess up badly with the String resources. // Test for null lc is to avoid a NPE when Android mess up badly with the String resources.
@ -498,16 +502,18 @@ public final class LinphoneService extends Service implements LinphoneServiceLis
// Log.i("Service not ready, discarding registration state change to ",state.toString()); // Log.i("Service not ready, discarding registration state change to ",state.toString());
// return; // return;
// } // }
if (state == RegistrationState.RegistrationOk && LinphoneManager.getLc().getDefaultProxyConfig() != null && LinphoneManager.getLc().getDefaultProxyConfig().isRegistered()) { if (!mDisableRegistrationStatus) {
sendNotification(IC_LEVEL_ORANGE, R.string.notification_registered); if (state == RegistrationState.RegistrationOk && LinphoneManager.getLc().getDefaultProxyConfig() != null && LinphoneManager.getLc().getDefaultProxyConfig().isRegistered()) {
} sendNotification(IC_LEVEL_ORANGE, R.string.notification_registered);
}
if ((state == RegistrationState.RegistrationFailed || state == RegistrationState.RegistrationCleared) && (LinphoneManager.getLc().getDefaultProxyConfig() == null || !LinphoneManager.getLc().getDefaultProxyConfig().isRegistered())) { if ((state == RegistrationState.RegistrationFailed || state == RegistrationState.RegistrationCleared) && (LinphoneManager.getLc().getDefaultProxyConfig() == null || !LinphoneManager.getLc().getDefaultProxyConfig().isRegistered())) {
sendNotification(IC_LEVEL_OFFLINE, R.string.notification_register_failure); sendNotification(IC_LEVEL_OFFLINE, R.string.notification_register_failure);
} }
if (state == RegistrationState.RegistrationNone) { if (state == RegistrationState.RegistrationNone) {
sendNotification(IC_LEVEL_OFFLINE, R.string.notification_started); sendNotification(IC_LEVEL_OFFLINE, R.string.notification_started);
}
} }
mHandler.post(new Runnable() { mHandler.post(new Runnable() {