start GUI binding
This commit is contained in:
parent
c4411985bd
commit
02c9aa2299
4 changed files with 87 additions and 1 deletions
|
@ -18,7 +18,7 @@
|
|||
</TableRow><TableRow android:layout_weight="1" android:layout_height="fill_parent" android:id="@+id/DialerRow03" android:layout_width="fill_parent"><Button android:text="7" android:id="@+id/Button07" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="0.25"></Button>
|
||||
<Button android:id="@+id/Button08" android:text="8" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="0.25"></Button>
|
||||
<Button android:text="9" android:id="@+id/Button09" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="0.5"></Button>
|
||||
</TableRow><TableRow android:layout_weight="1" android:layout_height="fill_parent" android:id="@+id/DialerRow04" android:layout_width="fill_parent"><Button android:layout_width="fill_parent" android:layout_height="fill_parent" android:id="@+id/ButtonStart" android:text="*" android:layout_weight="0.25"></Button>
|
||||
</TableRow><TableRow android:layout_weight="1" android:layout_height="fill_parent" android:id="@+id/DialerRow04" android:layout_width="fill_parent"><Button android:layout_width="fill_parent" android:layout_height="fill_parent" android:text="*" android:layout_weight="0.25" android:id="@+id/ButtonStar"></Button>
|
||||
<Button android:layout_width="fill_parent" android:layout_height="fill_parent" android:text="0+" android:id="@+id/Button00" android:layout_weight="0.25"></Button>
|
||||
<Button android:layout_width="fill_parent" android:layout_height="fill_parent" android:id="@+id/ButtonHash" android:text="#" android:layout_weight="0.5"></Button>
|
||||
</TableRow><TableRow android:layout_height="fill_parent" android:id="@+id/DialerRow00" android:layout_width="fill_parent" android:layout_weight="1">
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -88,5 +88,7 @@ public interface LinphoneCore {
|
|||
|
||||
public void invite(String uri);
|
||||
|
||||
public void terminateCall();
|
||||
|
||||
public void iterate();
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue