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:
Guillaume Beraudo 2011-02-17 15:34:07 +01:00
parent 4d79c4e618
commit 58dc345e77
3 changed files with 34 additions and 12 deletions

View file

@ -23,10 +23,13 @@ import org.linphone.core.LinphoneAddress;
import org.linphone.core.LinphoneCore;
import org.linphone.core.LinphoneCoreException;
import android.content.ContentResolver;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.media.AudioManager;
import android.os.Build;
import android.provider.Settings;
import android.provider.Settings.SettingNotFoundException;
import android.view.WindowManager;
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);
}
}

View file

@ -30,7 +30,6 @@ import org.linphone.core.LinphoneAuthInfo;
import org.linphone.core.LinphoneCall;
import org.linphone.core.LinphoneChatRoom;
import org.linphone.core.LinphoneCore;
import org.linphone.core.LinphoneCore.EcCalibratorStatus;
import org.linphone.core.LinphoneCoreException;
import org.linphone.core.LinphoneCoreFactory;
import org.linphone.core.LinphoneCoreListener;
@ -38,6 +37,7 @@ import org.linphone.core.LinphoneFriend;
import org.linphone.core.LinphoneProxyConfig;
import org.linphone.core.PayloadType;
import org.linphone.core.LinphoneCall.State;
import org.linphone.core.LinphoneCore.EcCalibratorStatus;
import org.linphone.core.LinphoneCore.FirewallPolicy;
import org.linphone.core.LinphoneCore.GlobalState;
@ -46,6 +46,7 @@ import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.Service;
import android.content.BroadcastReceiver;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
@ -539,5 +540,7 @@ public class LinphoneService extends Service implements LinphoneCoreListener {
}
});
}
}

View file

@ -81,12 +81,16 @@ public class Digit extends Button implements OnLongClickListener, AddressAwareWi
private class DialKeyListener implements OnClickListener, OnTouchListener {
final CharSequence mKeyCode;
boolean mIsDtmfStarted=false;
DialKeyListener() {
mKeyCode = Digit.this.getText().subSequence(0, 1);
}
public void onClick(View v) {
LinphoneCore lc = LinphoneManager.getLc();
stopDtmf();
lc.stopDtmf();
mIsDtmfStarted =false;
if (lc.isIncall()) {
lc.sendDtmf(mKeyCode.charAt(0));
} else {
@ -100,24 +104,19 @@ public class Digit extends Button implements OnLongClickListener, AddressAwareWi
mAddress.clearDisplayedName();
}
}
public boolean onTouch(View v, MotionEvent event) {
LinphoneCore lc = LinphoneManager.getLc();
if (event.getAction() == MotionEvent.ACTION_DOWN && mIsDtmfStarted ==false) {
LinphoneCore lc = LinphoneManager.getLc();
lc.playDtmf(mKeyCode.charAt(0), -1);
LinphoneManager.getInstance().playDtmf(mKeyCode.charAt(0));
mIsDtmfStarted=true;
} else {
if (event.getAction() == MotionEvent.ACTION_UP)
stopDtmf();
lc.stopDtmf();
mIsDtmfStarted =false;
}
return false;
}
private void stopDtmf() {
LinphoneCore lc = LinphoneManager.getLc();
lc.stopDtmf();
mIsDtmfStarted =false;
}
};
public void setAddressWidget(AddressText address) {