From 02c9aa229963507163d75c0eee748b69c6e4b30f Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Mon, 8 Feb 2010 18:36:16 +0100 Subject: [PATCH] start GUI binding --- res/layout/main.xml | 2 +- src/org/linphone/Linphone.java | 79 +++++++++++++++++++++ src/org/linphone/core/LinphoneCore.java | 2 + src/org/linphone/core/LinphoneCoreImpl.java | 5 ++ 4 files changed, 87 insertions(+), 1 deletion(-) diff --git a/res/layout/main.xml b/res/layout/main.xml index 08dfa960c..51da56e53 100644 --- a/res/layout/main.xml +++ b/res/layout/main.xml @@ -18,7 +18,7 @@ - + diff --git a/src/org/linphone/Linphone.java b/src/org/linphone/Linphone.java index 2d306b7bf..8a79f54dd 100644 --- a/src/org/linphone/Linphone.java +++ b/src/org/linphone/Linphone.java @@ -42,6 +42,11 @@ import android.util.Log; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; +import android.view.View; +import android.view.View.OnClickListener; +import android.widget.Button; +import android.widget.ImageButton; +import android.widget.TextView; import android.widget.Toast; public class Linphone extends Activity implements LinphoneCoreListener { @@ -56,6 +61,22 @@ public class Linphone extends Activity implements LinphoneCoreListener { private LinphoneCore mLinphoneCore; private SharedPreferences mPref; Timer mTimer = new Timer("Linphone scheduler"); + + private TextView mAddress; + private ImageButton mCall; + private ImageButton mHangup; + private Button mZero; + private Button mOne; + private Button mTwo; + private Button mThree ; + private Button mFour; + private Button mFive; + private Button mSix; + private Button mSeven; + private Button mEight; + private Button mNine; + private Button mStar; + private Button mHash; static Linphone getLinphone() { if (theLinphone == null) { @@ -91,6 +112,64 @@ public class Linphone extends Activity implements LinphoneCoreListener { }; mTimer.scheduleAtFixedRate(lTask, 0, 100); + + mAddress = (TextView) findViewById(R.id.SipUri); + + mCall = (ImageButton) findViewById(R.id.Call); + mCall.setOnClickListener(new OnClickListener() { + public void onClick(View v) { + mLinphoneCore.invite(mAddress.getText().toString()); + } + + }); + mHangup = (ImageButton) findViewById(R.id.HangUp); + mHangup.setOnClickListener(new OnClickListener() { + public void onClick(View v) { + mLinphoneCore.terminateCall(); + } + + }); + + class DialKeyListener implements OnClickListener { + final String mKeyCode; + final TextView mAddressView; + DialKeyListener(TextView anAddress, char aKeyCode) { + mKeyCode = String.valueOf(aKeyCode); + mAddressView = anAddress; + } + public void onClick(View v) { + mAddressView.append(mKeyCode); + } + + }; + + mZero = (Button) findViewById(R.id.Button00) ; + mZero.setOnClickListener(new DialKeyListener(mAddress,'0')); + mOne = (Button) findViewById(R.id.Button01) ; + mOne.setOnClickListener(new DialKeyListener(mAddress,'1')); + mTwo = (Button) findViewById(R.id.Button02); + mTwo.setOnClickListener(new DialKeyListener(mAddress,'2')); + mThree = (Button) findViewById(R.id.Button03); + mThree.setOnClickListener(new DialKeyListener(mAddress,'3')); + mFour = (Button) findViewById(R.id.Button04); + mFour.setOnClickListener(new DialKeyListener(mAddress,'4')); + mFive = (Button) findViewById(R.id.Button05); + mFive.setOnClickListener(new DialKeyListener(mAddress,'5')); + mSix = (Button) findViewById(R.id.Button06); + mSix.setOnClickListener(new DialKeyListener(mAddress,'6')); + mSeven = (Button) findViewById(R.id.Button07); + mSeven.setOnClickListener(new DialKeyListener(mAddress,'7')); + mEight = (Button) findViewById(R.id.Button08); + mEight.setOnClickListener(new DialKeyListener(mAddress,'8')); + mNine = (Button) findViewById(R.id.Button09); + mNine.setOnClickListener(new DialKeyListener(mAddress,'9')); + mStar = (Button) findViewById(R.id.ButtonStar); + mStar.setOnClickListener(new DialKeyListener(mAddress,'*')); + mHash = (Button) findViewById(R.id.ButtonHash); + mHash.setOnClickListener(new DialKeyListener(mAddress,'#')); + + + } catch (Exception e) { Log.e(TAG,"Cannot start linphone",e); } diff --git a/src/org/linphone/core/LinphoneCore.java b/src/org/linphone/core/LinphoneCore.java index 4e608452c..8ae0effd3 100644 --- a/src/org/linphone/core/LinphoneCore.java +++ b/src/org/linphone/core/LinphoneCore.java @@ -88,5 +88,7 @@ public interface LinphoneCore { public void invite(String uri); + public void terminateCall(); + public void iterate(); } diff --git a/src/org/linphone/core/LinphoneCoreImpl.java b/src/org/linphone/core/LinphoneCoreImpl.java index 2cc292911..0e4956566 100644 --- a/src/org/linphone/core/LinphoneCoreImpl.java +++ b/src/org/linphone/core/LinphoneCoreImpl.java @@ -37,6 +37,8 @@ class LinphoneCoreImpl implements LinphoneCore { private native void clearProxyConfigs(long nativePtr); private native void addAuthInfo(long nativePtr,long authInfoNativePtr); private native void invite(long nativePtr,String uri); + private native void terminateCall(long nativePtr); + LinphoneCoreImpl(LinphoneCoreListener listener, File userConfig,File factoryConfig,Object userdata) throws IOException { mListener=listener; nativePtr = newLinphoneCore(listener,userConfig.getCanonicalPath(),factoryConfig.getCanonicalPath(),userdata); @@ -82,6 +84,9 @@ class LinphoneCoreImpl implements LinphoneCore { public void clearProxyConfigs() { clearProxyConfigs(nativePtr); } + public void terminateCall() { + terminateCall(nativePtr); + } }