Respect user DTMF_TONE_WHEN_DIALING settings value.
When not in call and audible tones disalbed, don't call linphoneCore with playdtmf.
This commit is contained in:
parent
4d79c4e618
commit
58dc345e77
3 changed files with 34 additions and 12 deletions
|
@ -23,10 +23,13 @@ import org.linphone.core.LinphoneAddress;
|
||||||
import org.linphone.core.LinphoneCore;
|
import org.linphone.core.LinphoneCore;
|
||||||
import org.linphone.core.LinphoneCoreException;
|
import org.linphone.core.LinphoneCoreException;
|
||||||
|
|
||||||
|
import android.content.ContentResolver;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.media.AudioManager;
|
import android.media.AudioManager;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
|
import android.provider.Settings;
|
||||||
|
import android.provider.Settings.SettingNotFoundException;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
|
|
||||||
public class LinphoneManager {
|
public class LinphoneManager {
|
||||||
|
@ -163,4 +166,21 @@ public class LinphoneManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void playDtmf(char dtmf) {
|
||||||
|
if (getLc().isIncall()) {
|
||||||
|
// Play if in call as it will not go to speaker
|
||||||
|
getLc().playDtmf(dtmf, -1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ContentResolver r = LinphoneService.instance().getContentResolver();
|
||||||
|
try {
|
||||||
|
if (Settings.System.getInt(r, Settings.System.DTMF_TONE_WHEN_DIALING) == 0) {
|
||||||
|
// audible touch disabled: don't play
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} catch (SettingNotFoundException e) {}
|
||||||
|
|
||||||
|
getLc().playDtmf(dtmf, -1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,6 @@ import org.linphone.core.LinphoneAuthInfo;
|
||||||
import org.linphone.core.LinphoneCall;
|
import org.linphone.core.LinphoneCall;
|
||||||
import org.linphone.core.LinphoneChatRoom;
|
import org.linphone.core.LinphoneChatRoom;
|
||||||
import org.linphone.core.LinphoneCore;
|
import org.linphone.core.LinphoneCore;
|
||||||
import org.linphone.core.LinphoneCore.EcCalibratorStatus;
|
|
||||||
import org.linphone.core.LinphoneCoreException;
|
import org.linphone.core.LinphoneCoreException;
|
||||||
import org.linphone.core.LinphoneCoreFactory;
|
import org.linphone.core.LinphoneCoreFactory;
|
||||||
import org.linphone.core.LinphoneCoreListener;
|
import org.linphone.core.LinphoneCoreListener;
|
||||||
|
@ -38,6 +37,7 @@ import org.linphone.core.LinphoneFriend;
|
||||||
import org.linphone.core.LinphoneProxyConfig;
|
import org.linphone.core.LinphoneProxyConfig;
|
||||||
import org.linphone.core.PayloadType;
|
import org.linphone.core.PayloadType;
|
||||||
import org.linphone.core.LinphoneCall.State;
|
import org.linphone.core.LinphoneCall.State;
|
||||||
|
import org.linphone.core.LinphoneCore.EcCalibratorStatus;
|
||||||
import org.linphone.core.LinphoneCore.FirewallPolicy;
|
import org.linphone.core.LinphoneCore.FirewallPolicy;
|
||||||
import org.linphone.core.LinphoneCore.GlobalState;
|
import org.linphone.core.LinphoneCore.GlobalState;
|
||||||
|
|
||||||
|
@ -46,6 +46,7 @@ import android.app.NotificationManager;
|
||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
import android.app.Service;
|
import android.app.Service;
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
|
import android.content.ContentResolver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
|
@ -539,5 +540,7 @@ public class LinphoneService extends Service implements LinphoneCoreListener {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -81,12 +81,16 @@ public class Digit extends Button implements OnLongClickListener, AddressAwareWi
|
||||||
private class DialKeyListener implements OnClickListener, OnTouchListener {
|
private class DialKeyListener implements OnClickListener, OnTouchListener {
|
||||||
final CharSequence mKeyCode;
|
final CharSequence mKeyCode;
|
||||||
boolean mIsDtmfStarted=false;
|
boolean mIsDtmfStarted=false;
|
||||||
|
|
||||||
DialKeyListener() {
|
DialKeyListener() {
|
||||||
mKeyCode = Digit.this.getText().subSequence(0, 1);
|
mKeyCode = Digit.this.getText().subSequence(0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
LinphoneCore lc = LinphoneManager.getLc();
|
LinphoneCore lc = LinphoneManager.getLc();
|
||||||
stopDtmf();
|
lc.stopDtmf();
|
||||||
|
mIsDtmfStarted =false;
|
||||||
|
|
||||||
if (lc.isIncall()) {
|
if (lc.isIncall()) {
|
||||||
lc.sendDtmf(mKeyCode.charAt(0));
|
lc.sendDtmf(mKeyCode.charAt(0));
|
||||||
} else {
|
} else {
|
||||||
|
@ -100,24 +104,19 @@ public class Digit extends Button implements OnLongClickListener, AddressAwareWi
|
||||||
mAddress.clearDisplayedName();
|
mAddress.clearDisplayedName();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean onTouch(View v, MotionEvent event) {
|
public boolean onTouch(View v, MotionEvent event) {
|
||||||
|
LinphoneCore lc = LinphoneManager.getLc();
|
||||||
if (event.getAction() == MotionEvent.ACTION_DOWN && mIsDtmfStarted ==false) {
|
if (event.getAction() == MotionEvent.ACTION_DOWN && mIsDtmfStarted ==false) {
|
||||||
LinphoneCore lc = LinphoneManager.getLc();
|
LinphoneManager.getInstance().playDtmf(mKeyCode.charAt(0));
|
||||||
lc.playDtmf(mKeyCode.charAt(0), -1);
|
|
||||||
mIsDtmfStarted=true;
|
mIsDtmfStarted=true;
|
||||||
} else {
|
} else {
|
||||||
if (event.getAction() == MotionEvent.ACTION_UP)
|
if (event.getAction() == MotionEvent.ACTION_UP)
|
||||||
stopDtmf();
|
lc.stopDtmf();
|
||||||
|
mIsDtmfStarted =false;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void stopDtmf() {
|
|
||||||
LinphoneCore lc = LinphoneManager.getLc();
|
|
||||||
lc.stopDtmf();
|
|
||||||
mIsDtmfStarted =false;
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
public void setAddressWidget(AddressText address) {
|
public void setAddressWidget(AddressText address) {
|
||||||
|
|
Loading…
Reference in a new issue