Add voice mail preference
Add voice mail notification in status bar
This commit is contained in:
parent
5ddbf9fd51
commit
96c1fbabb5
10 changed files with 102 additions and 3 deletions
|
@ -244,6 +244,19 @@
|
|||
android:visibility="gone"
|
||||
android:textSize="18sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/voicemailCount"
|
||||
android:textColor="@android:color/white"
|
||||
android:layout_alignParentRight="true"
|
||||
android:textSize="18sp"
|
||||
android:paddingLeft="5dp"
|
||||
android:paddingRight="10dp"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center_vertical"
|
||||
android:visibility="gone" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
</org.linphone.ui.SlidingDrawer>
|
||||
|
|
|
@ -123,6 +123,7 @@
|
|||
|
||||
<string name="pref_rfc2833_dtmf_key">pref_rfc2833_dtmf_key</string>
|
||||
<string name="pref_sipinfo_dtmf_key">pref_sipinfo_dtmf_key</string>
|
||||
<string name="pref_voice_mail_key">pref_voice_mail_key</string>
|
||||
<string name="pref_upnp_enable_key">pref_upnp_enable_key</string>
|
||||
|
||||
<string name="pref_first_time_linphone_chat_storage">pref_first_time_linphone_chat_storage</string>
|
||||
|
|
|
@ -431,6 +431,7 @@
|
|||
|
||||
<string name="pref_rfc2833_dtmf">Send RFC2833 DTMFs</string>
|
||||
<string name="pref_sipinfo_dtmf">Send SIP INFO DTMFs</string>
|
||||
<string name="pref_voice_mail">Voice mail uri</string>
|
||||
|
||||
<string name="error_call_declined">Call declined</string>
|
||||
<string name="error_user_not_found">User not found</string>
|
||||
|
|
|
@ -129,6 +129,10 @@
|
|||
android:title="@string/pref_rfc2833_dtmf"
|
||||
android:key="@string/pref_rfc2833_dtmf_key"/>
|
||||
|
||||
<EditTextPreference
|
||||
android:title="@string/pref_voice_mail"
|
||||
android:key="@string/pref_voice_mail_key"/>
|
||||
|
||||
</PreferenceScreen>
|
||||
|
||||
<PreferenceScreen
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue