* #30591: dtmf working in dial screen
diff --git a/src/com/savoirfairelinux/sflphone/fragments/CallFragment.java b/src/com/savoirfairelinux/sflphone/fragments/CallFragment.java
index f0091c3..b8d031b 100644
--- a/src/com/savoirfairelinux/sflphone/fragments/CallFragment.java
+++ b/src/com/savoirfairelinux/sflphone/fragments/CallFragment.java
@@ -32,6 +32,7 @@
package com.savoirfairelinux.sflphone.fragments;
import java.util.ArrayList;
+import java.util.Locale;
import android.app.Activity;
import android.app.Fragment;
@@ -47,8 +48,6 @@
import android.hardware.SensorManager;
import android.os.Bundle;
import android.os.RemoteException;
-import android.text.Editable;
-import android.text.method.KeyListener;
import android.util.Log;
import android.view.KeyEvent;
import android.view.LayoutInflater;
@@ -56,7 +55,6 @@
import android.view.SurfaceHolder.Callback;
import android.view.View;
import android.view.View.OnClickListener;
-import android.view.View.OnKeyListener;
import android.view.ViewGroup;
import android.view.inputmethod.InputMethodManager;
import android.widget.ImageButton;
@@ -536,8 +534,9 @@
public void onKeyUp(int keyCode, KeyEvent event) {
try {
- Log.d(TAG, "Sending "+event.getDisplayLabel());
String toSend = "" + event.getDisplayLabel();
+ Log.d(TAG,"toSend "+toSend);
+ toSend.toUpperCase(Locale.getDefault());
mCallbacks.getService().playDtmf(toSend);
} catch (RemoteException e) {
e.printStackTrace();
diff --git a/src/com/savoirfairelinux/sflphone/fragments/DialingFragment.java b/src/com/savoirfairelinux/sflphone/fragments/DialingFragment.java
index 94d9270..2db5258 100644
--- a/src/com/savoirfairelinux/sflphone/fragments/DialingFragment.java
+++ b/src/com/savoirfairelinux/sflphone/fragments/DialingFragment.java
@@ -31,11 +31,15 @@
package com.savoirfairelinux.sflphone.fragments;
+import java.util.Locale;
+
import android.app.Activity;
import android.app.Fragment;
import android.content.Context;
import android.os.Bundle;
import android.os.RemoteException;
+import android.text.Editable;
+import android.text.TextWatcher;
import android.util.Log;
import android.view.KeyEvent;
import android.view.LayoutInflater;
@@ -155,27 +159,38 @@
@Override
public void onResume() {
super.onResume();
- textField.setOnKeyListener(dtmfKeyListener);
+ textField.setTextWatcher(dtmfKeyListener);
}
@Override
public void onPause() {
super.onPause();
- textField.setOnKeyListener(null);
+ textField.unsetTextWatcher();
}
- OnKeyListener dtmfKeyListener = new OnKeyListener() {
+ TextWatcher dtmfKeyListener = new TextWatcher() {
@Override
- public boolean onKey(View v, int keyCode, KeyEvent event) {
- if (event.getAction() == KeyEvent.ACTION_UP) {
- try {
- mCallbacks.getService().playDtmf(KeyEvent.keyCodeToString(keyCode));
- } catch (RemoteException e) {
- e.printStackTrace();
- }
+ public void afterTextChanged(Editable s) {
+ }
+
+ @Override
+ public void beforeTextChanged(CharSequence s, int start, int count, int after) {
+ }
+
+ @Override
+ public void onTextChanged(CharSequence s, int start, int before, int count) {
+ if (count - before > 1 || count == 0)
+ return; // pasted a number (not implemented yet)
+
+ try {
+ String toSend = Character.toString(s.charAt(start));
+ Log.d(TAG, "onTextChanged toSend" + toSend);
+ toSend.toUpperCase(Locale.getDefault());
+ mCallbacks.getService().playDtmf(toSend);
+ } catch (RemoteException e) {
+ e.printStackTrace();
}
- return false;
}
};