* #30591: key event hooked, sent to daemon
diff --git a/src/com/savoirfairelinux/sflphone/fragments/CallFragment.java b/src/com/savoirfairelinux/sflphone/fragments/CallFragment.java
index e012af2..f0091c3 100644
--- a/src/com/savoirfairelinux/sflphone/fragments/CallFragment.java
+++ b/src/com/savoirfairelinux/sflphone/fragments/CallFragment.java
@@ -45,21 +45,22 @@
 import android.hardware.SensorEvent;
 import android.hardware.SensorEventListener;
 import android.hardware.SensorManager;
-import android.inputmethodservice.InputMethodService;
 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;
 import android.view.SurfaceHolder;
 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.WindowManager;
 import android.view.inputmethod.InputMethodManager;
 import android.widget.ImageButton;
 import android.widget.TextView;
-import android.widget.Toast;
 
 import com.savoirfairelinux.sflphone.R;
 import com.savoirfairelinux.sflphone.model.Attractor;
@@ -90,8 +91,6 @@
     private SipCall myself;
 
     boolean accepted = false;
-
-    private Bitmap hangup_icon, transfer_icon;
     private Bitmap call_icon;
 
     private SensorManager mSensorManager;
@@ -216,7 +215,6 @@
         super.onDetach();
         mCallbacks = sDummyCallbacks;
         mSensorManager.unregisterListener(this);
-        // rootView.requestDisallowInterceptTouchEvent(false);
     }
 
     @Override
@@ -288,10 +286,7 @@
         view.getHolder().addCallback(this);
 
         callStatusTxt = (TextView) rootView.findViewById(R.id.call_status_txt);
-
-        hangup_icon = BitmapFactory.decodeResource(getResources(), R.drawable.ic_hangup);
         call_icon = BitmapFactory.decodeResource(getResources(), R.drawable.ic_call);
-        transfer_icon = BitmapFactory.decodeResource(getResources(), R.drawable.ic_phones_call_transfer_icon);
 
         ((ImageButton) rootView.findViewById(R.id.dialpad_btn)).setOnClickListener(new OnClickListener() {
 
@@ -302,10 +297,11 @@
             }
         });
 
-        // Do nothing here, the view is not initialized yet.
+        
+        
         return rootView;
     }
-
+    
     private void initNormalStateDisplay() {
         Log.i(TAG, "Start normal display");
 
@@ -329,62 +325,6 @@
         }
 
         model.clearAttractors();
-        // model.addAttractor(new Attractor(new PointF(model.width * 0.9f, model.height * 0.1f), ATTRACTOR_SIZE, new Attractor.Callback() {
-        // @Override
-        // public boolean onBubbleSucked(Bubble b) {
-        // Log.w(TAG, "Bubble sucked ! ");
-        //
-        // if (b.associated_call.getContact().isUser()) {
-        //
-        // try {
-        // if (conf.hasMultipleParticipants())
-        // mCallbacks.getService().hangUpConference(conf.getId());
-        // else
-        // mCallbacks.onCallEnded(conf.getParticipants().get(0));
-        //
-        // model.clearAttractors();
-        // } catch (RemoteException e) {
-        // e.printStackTrace();
-        // }
-        //
-        // } else {
-        // mCallbacks.onCallEnded(b.associated_call);
-        // }
-        // bubbleRemoved(b);
-        // return true;
-        // }
-        // }, hangup_icon));
-
-        // model.addAttractor(new Attractor(new PointF(model.width * .8f, model.height * 0.9f), ATTRACTOR_SIZE, new Attractor.Callback() {
-        // @Override
-        // public boolean onBubbleSucked(Bubble b) {
-        // Log.w(TAG, "Bubble sucked ! ");
-        // makeTransfer(b);
-        // return true;
-        // }
-        // }, transfer_icon));
-
-        // if (conf.hasMultipleParticipants()) {
-        // model.addAttractor(new Attractor(new PointF(model.width / 1.1f, model.height * .9f), ATTRACTOR_SIZE, new Attractor.Callback() {
-        // @Override
-        // public boolean onBubbleSucked(Bubble b) {
-        //
-        // try {
-        // mCallbacks.getService().detachParticipant(b.associated_call.getCallId());
-        // } catch (RemoteException e) {
-        // e.printStackTrace();
-        // }
-        //
-        // bubbleRemoved(b);
-        // return true;
-        // }
-        // }, separate_icon));
-        // }
-
-        // if(mCalls.size() == 1 && mCalls.get(0).isOnHold()){
-        // mCallbacks.onCallResumed(mCalls.get(0));
-        // }
-
     }
 
     private void initIncomingCallDisplay() {
@@ -429,16 +369,6 @@
         }
 
         model.clearAttractors();
-
-        // model.addAttractor(new Attractor(new PointF(model.width / 2f, model.height * .9f), 40, new Attractor.Callback() {
-        // @Override
-        // public boolean onBubbleSucked(Bubble b) {
-        // Log.w(TAG, "Bubble sucked ! ");
-        // mCallbacks.onCallEnded(conf.getParticipants().get(0));
-        // bubbleRemoved(b);
-        // return true;
-        // }
-        // }, hangup_icon));
     }
 
     /**
@@ -483,19 +413,12 @@
                 e.printStackTrace();
             }
         }
-
-        // Log.w(TAG, "conf.getParticipants().size():" + conf.getParticipants().size());
         for (int i = 0; i < conf.getParticipants().size(); ++i) {
-            // conf.getParticipants().get(i).printCallInfo();
-            // Log.w(TAG, "Call id:" + conf.getParticipants().get(i).getCallId());
-            // Log.w(TAG, "Searching:" + callID);
             if (callID.equals(conf.getParticipants().get(i).getCallId())) {
                 if (newState.contentEquals("HUNGUP")) {
-                    // Log.w(TAG, "Call hungup:" + conf.getParticipants().get(i).getContact().getmDisplayName());
                     model.removeBubble(conf.getParticipants().get(i));
                     conf.getParticipants().remove(i);
                 } else {
-                    // Log.w(TAG, "Call:" + conf.getParticipants().get(i).getContact().getmDisplayName() + " state:" + newState);
                     conf.getParticipants().get(i).setCallState(newState);
                 }
             }
@@ -589,20 +512,20 @@
     public void onSensorChanged(SensorEvent event) {
         Log.i(TAG, "onSensorChanged:" + event.sensor.getName());
         Log.i(TAG, "onSensorChanged:" + event.sensor.getType());
-        if (event.values[0] == 0) {
-            // PowerManager pm = (PowerManager) getActivity().getSystemService(Context.POWER_SERVICE);
-            // pm.goToSleep(SystemClock.uptimeMillis());
-            WindowManager.LayoutParams params = getActivity().getWindow().getAttributes();
-            params.flags |= WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
-            params.screenBrightness = 0.004f;
-            getActivity().getWindow().setAttributes(params);
-            // Settings.System.putInt(getActivity().getContentResolver(), Settings.System.SCREEN_OFF_TIMEOUT, 1000);
-        } else {
-            WindowManager.LayoutParams params = getActivity().getWindow().getAttributes();
-            params.flags = WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
-            params.screenBrightness = 1f;
-            getActivity().getWindow().setAttributes(params);
-        }
+//        if (event.values[0] == 0) {
+//            // PowerManager pm = (PowerManager) getActivity().getSystemService(Context.POWER_SERVICE);
+//            // pm.goToSleep(SystemClock.uptimeMillis());
+//            WindowManager.LayoutParams params = getActivity().getWindow().getAttributes();
+//            params.flags |= WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
+//            params.screenBrightness = 0.004f;
+//            getActivity().getWindow().setAttributes(params);
+//            // Settings.System.putInt(getActivity().getContentResolver(), Settings.System.SCREEN_OFF_TIMEOUT, 1000);
+//        } else {
+//            WindowManager.LayoutParams params = getActivity().getWindow().getAttributes();
+//            params.flags = WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
+//            params.screenBrightness = 1f;
+//            getActivity().getWindow().setAttributes(params);
+//        }
         // Sensor.TYPE_PROXIMITY
 
     }
@@ -610,4 +533,14 @@
     public Conference getConference() {
         return conf;
     }
+
+    public void onKeyUp(int keyCode, KeyEvent event) {
+        try {
+            Log.d(TAG, "Sending "+event.getDisplayLabel());
+            String toSend = "" + event.getDisplayLabel();
+            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 2e3b030..94d9270 100644
--- a/src/com/savoirfairelinux/sflphone/fragments/DialingFragment.java
+++ b/src/com/savoirfairelinux/sflphone/fragments/DialingFragment.java
@@ -35,10 +35,14 @@
 import android.app.Fragment;
 import android.content.Context;
 import android.os.Bundle;
+import android.os.RemoteException;
+import android.util.Log;
+import android.view.KeyEvent;
 import android.view.LayoutInflater;
 import android.view.MotionEvent;
 import android.view.View;
 import android.view.View.OnClickListener;
+import android.view.View.OnKeyListener;
 import android.view.View.OnTouchListener;
 import android.view.ViewGroup;
 import android.view.inputmethod.EditorInfo;
@@ -151,9 +155,31 @@
     @Override
     public void onResume() {
         super.onResume();
+        textField.setOnKeyListener(dtmfKeyListener);
     }
 
     @Override
+    public void onPause() {
+        super.onPause();
+        textField.setOnKeyListener(null);
+    }
+
+    OnKeyListener dtmfKeyListener = new OnKeyListener() {
+
+        @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();
+                }
+            }
+            return false;
+        }
+    };
+
+    @Override
     public void onStart() {
         super.onStart();
     }