diff --git a/src/org/linphone/LinphoneManager.java b/src/org/linphone/LinphoneManager.java index a01ccc88f..9aeaf4bd9 100644 --- a/src/org/linphone/LinphoneManager.java +++ b/src/org/linphone/LinphoneManager.java @@ -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); + } } diff --git a/src/org/linphone/LinphoneService.java b/src/org/linphone/LinphoneService.java index 22628deb2..4b84d41f2 100644 --- a/src/org/linphone/LinphoneService.java +++ b/src/org/linphone/LinphoneService.java @@ -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 { } }); } + + } diff --git a/src/org/linphone/ui/Digit.java b/src/org/linphone/ui/Digit.java index 40673c291..8d4547150 100644 --- a/src/org/linphone/ui/Digit.java +++ b/src/org/linphone/ui/Digit.java @@ -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) {