diff --git a/res/layout/status.xml b/res/layout/status.xml
index bdeeb635e..31a8a3f45 100644
--- a/res/layout/status.xml
+++ b/res/layout/status.xml
@@ -243,6 +243,19 @@
android:textColor="@android:color/white"
android:visibility="gone"
android:textSize="18sp" />
+
+
diff --git a/res/values/non_localizable_strings.xml b/res/values/non_localizable_strings.xml
index 6679fd4ac..46e63ad5d 100644
--- a/res/values/non_localizable_strings.xml
+++ b/res/values/non_localizable_strings.xml
@@ -123,6 +123,7 @@
pref_rfc2833_dtmf_key
pref_sipinfo_dtmf_key
+ pref_voice_mail_key
pref_upnp_enable_key
pref_first_time_linphone_chat_storage
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 5a4528477..98291155c 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -431,6 +431,7 @@
Send RFC2833 DTMFs
Send SIP INFO DTMFs
+ Voice mail uri
Call declined
User not found
diff --git a/res/xml/preferences.xml b/res/xml/preferences.xml
index 3255705d7..c96504ae3 100644
--- a/res/xml/preferences.xml
+++ b/res/xml/preferences.xml
@@ -128,6 +128,10 @@
+
+
diff --git a/src/org/linphone/LinphoneManager.java b/src/org/linphone/LinphoneManager.java
index 118a4bc9f..ab2f49f38 100644
--- a/src/org/linphone/LinphoneManager.java
+++ b/src/org/linphone/LinphoneManager.java
@@ -38,6 +38,7 @@ import java.util.TimerTask;
import org.linphone.LinphoneSimpleListener.ConnectivityChangedListener;
import org.linphone.LinphoneSimpleListener.LinphoneOnAudioChangedListener;
import org.linphone.LinphoneSimpleListener.LinphoneOnAudioChangedListener.AudioState;
+import org.linphone.LinphoneSimpleListener.LinphoneOnNotifyReceivedListener;
import org.linphone.LinphoneSimpleListener.LinphoneOnComposingReceivedListener;
import org.linphone.LinphoneSimpleListener.LinphoneOnDTMFReceivedListener;
import org.linphone.LinphoneSimpleListener.LinphoneOnMessageReceivedListener;
@@ -1365,11 +1366,18 @@ public class LinphoneManager implements LinphoneCoreListener {
SubscriptionState state) {
Log.d("Subscription state changed to "+state+" event name is "+ev.getEventName());
}
+
+ private LinphoneOnNotifyReceivedListener notifyReceivedListener;
+ public void setNotifyReceivedListener(LinphoneOnNotifyReceivedListener listener) {
+ notifyReceivedListener = listener;
+ }
@Override
public void notifyReceived(LinphoneCore lc, LinphoneEvent ev,
String eventName, LinphoneContent content) {
Log.d("Notify received for event "+eventName);
if (content!=null) Log.d("with content "+content.getType()+"/"+content.getSubtype()+" data:"+content.getDataAsString());
+ if (notifyReceivedListener != null)
+ notifyReceivedListener.onNotifyReceived(ev,eventName,content);
}
@Override
public void publishStateChanged(LinphoneCore lc, LinphoneEvent ev,
diff --git a/src/org/linphone/LinphonePreferences.java b/src/org/linphone/LinphonePreferences.java
index ae738396e..429809e4f 100644
--- a/src/org/linphone/LinphonePreferences.java
+++ b/src/org/linphone/LinphonePreferences.java
@@ -785,6 +785,14 @@ public class LinphonePreferences {
public void sendDTMFsAsSipInfo(boolean use) {
getLc().setUseSipInfoForDtmfs(use);
}
+
+ public String getVoiceMailUri() {
+ return getConfig().getString("app", "voice_mail", null);
+ }
+
+ public void setVoiceMailUri(String uri) {
+ getConfig().setString("app", "voice_mail", uri);
+ }
// End of call settings
// Network settings
diff --git a/src/org/linphone/LinphoneSimpleListener.java b/src/org/linphone/LinphoneSimpleListener.java
index 218af877b..d2dbd3cf6 100644
--- a/src/org/linphone/LinphoneSimpleListener.java
+++ b/src/org/linphone/LinphoneSimpleListener.java
@@ -20,6 +20,9 @@ package org.linphone;
import org.linphone.core.LinphoneAddress;
import org.linphone.core.LinphoneCall;
+import org.linphone.core.LinphoneContent;
+import org.linphone.core.LinphoneCore;
+import org.linphone.core.LinphoneEvent;
import org.linphone.core.LinphoneProxyConfig;
import org.linphone.core.LinphoneCall.State;
import org.linphone.core.LinphoneChatMessage;
@@ -79,6 +82,9 @@ public interface LinphoneSimpleListener {
public static interface LinphoneOnDTMFReceivedListener extends LinphoneSimpleListener {
void onDTMFReceived(LinphoneCall call, int dtmf);
}
+ public static interface LinphoneOnNotifyReceivedListener extends LinphoneSimpleListener {
+ void onNotifyReceived(LinphoneEvent ev,String eventName, LinphoneContent content);
+ }
public static interface LinphoneOnComposingReceivedListener extends LinphoneSimpleListener {
void onComposingReceived(LinphoneChatRoom room);
}
diff --git a/src/org/linphone/SettingsFragment.java b/src/org/linphone/SettingsFragment.java
index 3d5a2522d..6892e594a 100644
--- a/src/org/linphone/SettingsFragment.java
+++ b/src/org/linphone/SettingsFragment.java
@@ -627,6 +627,7 @@ public class SettingsFragment extends PreferencesListFragment implements EcCalib
private void initCallSettings() {
CheckBoxPreference rfc2833 = (CheckBoxPreference) findPreference(getString(R.string.pref_rfc2833_dtmf_key));
CheckBoxPreference sipInfo = (CheckBoxPreference) findPreference(getString(R.string.pref_sipinfo_dtmf_key));
+
if (mPrefs.useRfc2833Dtmfs()) {
rfc2833.setChecked(true);
sipInfo.setChecked(false);
@@ -636,6 +637,8 @@ public class SettingsFragment extends PreferencesListFragment implements EcCalib
rfc2833.setChecked(false);
rfc2833.setEnabled(false);
}
+
+ setPreferenceDefaultValueAndSummary(R.string.pref_voice_mail_key, mPrefs.getVoiceMailUri());
}
private void setCallPreferencesListener() {
@@ -651,6 +654,17 @@ public class SettingsFragment extends PreferencesListFragment implements EcCalib
}
});
+ findPreference(getString(R.string.pref_voice_mail_key)).setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ EditTextPreference voiceMail = (EditTextPreference) findPreference(getString(R.string.pref_voice_mail_key));
+ voiceMail.setSummary(newValue.toString());
+ voiceMail.setText(newValue.toString());
+ mPrefs.setVoiceMailUri(newValue.toString());
+ return true;
+ }
+ });
+
findPreference(getString(R.string.pref_sipinfo_dtmf_key)).setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
diff --git a/src/org/linphone/StatusFragment.java b/src/org/linphone/StatusFragment.java
index 78fa8e2e0..27b0ba329 100644
--- a/src/org/linphone/StatusFragment.java
+++ b/src/org/linphone/StatusFragment.java
@@ -22,12 +22,15 @@ import java.util.List;
import java.util.Timer;
import java.util.TimerTask;
+import org.linphone.LinphoneSimpleListener.LinphoneOnNotifyReceivedListener;
import org.linphone.core.LinphoneCall;
import org.linphone.core.LinphoneCallParams;
import org.linphone.core.LinphoneCallStats;
+import org.linphone.core.LinphoneContent;
import org.linphone.core.LinphoneCore;
import org.linphone.core.LinphoneCore.MediaEncryption;
import org.linphone.core.LinphoneCore.RegistrationState;
+import org.linphone.core.LinphoneEvent;
import org.linphone.core.LinphoneProxyConfig;
import org.linphone.core.PayloadType;
import org.linphone.mediastream.Log;
@@ -56,10 +59,10 @@ import android.widget.TextView;
/**
* @author Sylvain Berfini
*/
-public class StatusFragment extends Fragment {
+public class StatusFragment extends Fragment implements LinphoneOnNotifyReceivedListener {
private Handler mHandler = new Handler();
private Handler refreshHandler = new Handler();
- private TextView statusText, exit;
+ private TextView statusText, exit, voicemailCount;
private ImageView statusLed, callQuality, encryption, background;
private ListView sliderContentAccounts;
private TableLayout callStats;
@@ -93,6 +96,8 @@ public class StatusFragment extends Fragment {
sliderContentAccounts = (ListView) view.findViewById(R.id.accounts);
+ voicemailCount = (TextView) view.findViewById(R.id.voicemailCount);
+
exit = (TextView) view.findViewById(R.id.exit);
exit.setOnTouchListener(new View.OnTouchListener() {
@Override
@@ -164,12 +169,14 @@ public class StatusFragment extends Fragment {
if (LinphoneManager.isInstanciated() && LinphoneManager.getLc() != null) {
sliderContentAccounts.setVisibility(View.GONE);
callStats.setVisibility(View.GONE);
+ voicemailCount.setVisibility(View.GONE);
if (isInCall && isAttached && getResources().getBoolean(R.bool.display_call_stats)) {
callStats.setVisibility(View.VISIBLE);
LinphoneCall call = LinphoneManager.getLc().getCurrentCall();
initCallStatsRefresher(call, callStats);
} else if (!isInCall) {
+ voicemailCount.setVisibility(View.VISIBLE);
sliderContentAccounts.setVisibility(View.VISIBLE);
AccountsListAdapter adapter = new AccountsListAdapter();
sliderContentAccounts.setAdapter(adapter);
@@ -363,6 +370,7 @@ public class StatusFragment extends Fragment {
public void refreshStatusItems(final LinphoneCall call, boolean isVideoEnabled) {
if (call != null) {
+ voicemailCount.setVisibility(View.GONE);
MediaEncryption mediaEncryption = call.getCurrentParamsCopy().getMediaEncryption();
if (isVideoEnabled) {
@@ -618,4 +626,24 @@ public class StatusFragment extends Fragment {
return view;
}
}
+
+ @Override
+ public void onNotifyReceived(LinphoneEvent ev, String eventName,
+ LinphoneContent content) {
+
+ if(!content.getType().equals("application")) return;
+ if(!content.getSubtype().equals("imple-message-summary")) return;
+
+ if (content.getData() == null) return;
+
+ //TODO Parse
+ int unreadCount = -1;
+
+ if (unreadCount > 0) {
+ voicemailCount.setText(unreadCount + " unread messages");
+ voicemailCount.setVisibility(View.VISIBLE);
+ } else {
+ voicemailCount.setVisibility(View.GONE);
+ }
+ }
}
diff --git a/src/org/linphone/ui/Digit.java b/src/org/linphone/ui/Digit.java
index 623dd1db9..814102252 100644
--- a/src/org/linphone/ui/Digit.java
+++ b/src/org/linphone/ui/Digit.java
@@ -20,6 +20,7 @@ package org.linphone.ui;
import org.linphone.InCallActivity;
import org.linphone.LinphoneManager;
+import org.linphone.LinphonePreferences;
import org.linphone.LinphoneService;
import org.linphone.R;
import org.linphone.core.LinphoneCore;
@@ -60,6 +61,10 @@ public class Digit extends Button implements AddressAware {
if ("0+".equals(text)) {
setOnLongClickListener(lListener);
}
+
+ if ("1".equals(text)) {
+ setOnLongClickListener(lListener);
+ }
}
public Digit(Context context, AttributeSet attrs, int style) {
@@ -138,13 +143,24 @@ public class Digit extends Button implements AddressAware {
}
public boolean onLongClick(View v) {
+ int id = v.getId();
+ LinphoneCore lc = LinphoneManager.getLc();
+
if (mPlayDtmf) {
if (!linphoneServiceReady()) return true;
// Called if "0+" dtmf
- LinphoneCore lc = LinphoneManager.getLc();
lc.stopDtmf();
}
+ if(id == R.id.Digit1 && lc.getCalls().length == 0){
+ String voiceMail = LinphonePreferences.instance().getVoiceMailUri();
+ if(voiceMail != null){
+ LinphoneManager.getInstance().newOutgoingCall(voiceMail,"");
+ }
+ return true;
+ }
+
+
if (mAddress == null) return true;
int lBegin = mAddress.getSelectionStart();