-create LinphoneService
-fix landscape ui -create History tab view
This commit is contained in:
parent
652c2e53f0
commit
b372bdca49
20 changed files with 718 additions and 186 deletions
|
@ -4,7 +4,7 @@
|
||||||
android:versionCode="1"
|
android:versionCode="1"
|
||||||
android:versionName="1.0">
|
android:versionName="1.0">
|
||||||
<application android:icon="@drawable/linphone2" android:label="@string/app_name" android:debuggable = "true">
|
<application android:icon="@drawable/linphone2" android:label="@string/app_name" android:debuggable = "true">
|
||||||
<activity android:name=".Linphone"
|
<activity android:name=".LinphoneActivity"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:theme="@android:style/Theme.NoTitleBar">
|
android:theme="@android:style/Theme.NoTitleBar">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
|
@ -27,6 +27,13 @@
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
<activity android:name=".HistoryActivity">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
<service android:name=".LinphoneService">
|
||||||
|
</service>
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
|
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
|
||||||
|
|
BIN
res/drawable/in_call.png
Normal file
BIN
res/drawable/in_call.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.2 KiB |
BIN
res/drawable/out_call.png
Normal file
BIN
res/drawable/out_call.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.2 KiB |
36
res/layout-land/dialer.xml
Normal file
36
res/layout-land/dialer.xml
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:orientation="vertical" android:layout_width="fill_parent"
|
||||||
|
android:layout_height="fill_parent">
|
||||||
|
|
||||||
|
<EditText android:id="@+id/SipUri" android:layout_height="wrap_content"
|
||||||
|
android:hint="sip:" android:layout_width="fill_parent"
|
||||||
|
android:singleLine="true"></EditText>
|
||||||
|
|
||||||
|
<TableLayout android:layout_width="fill_parent" android:id="@+id/Dialer" android:layout_height="fill_parent">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<TableRow android:layout_height="fill_parent" android:layout_width="fill_parent" android:layout_weight="1" android:id="@+id/DialerRow05">
|
||||||
|
|
||||||
|
<ImageButton android:id="@+id/Call"
|
||||||
|
android:layout_height="fill_parent" android:src="@drawable/green"
|
||||||
|
android:layout_width="fill_parent" android:layout_weight="0.25">
|
||||||
|
</ImageButton>
|
||||||
|
|
||||||
|
|
||||||
|
<ImageButton android:id="@+id/HangUp" android:src="@drawable/red"
|
||||||
|
android:layout_height="fill_parent" android:layout_width="fill_parent"
|
||||||
|
android:layout_weight="0.25"></ImageButton>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</TableRow><TableRow android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/DialerRow06"></TableRow>
|
||||||
|
|
||||||
|
<EditText android:layout_width="fill_parent" android:id="@+id/status_label" android:clickable="false" android:focusable="false" android:cursorVisible="false" android:textSize="12sp" android:height="15sp" android:layout_height="wrap_content"></EditText></TableLayout>
|
||||||
|
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
|
@ -1,39 +1,89 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical" android:layout_width="fill_parent"
|
||||||
android:layout_width="fill_parent"
|
android:layout_height="fill_parent">
|
||||||
android:layout_height="fill_parent"
|
|
||||||
>
|
|
||||||
|
|
||||||
<EditText android:id="@+id/SipUri" android:layout_height="wrap_content" android:hint="sip:" android:layout_width="fill_parent" android:singleLine="true"></EditText>
|
<EditText android:id="@+id/SipUri" android:layout_height="wrap_content"
|
||||||
|
android:hint="sip:" android:layout_width="fill_parent"
|
||||||
|
android:singleLine="true"></EditText>
|
||||||
|
|
||||||
<TableLayout android:layout_width="fill_parent" android:id="@+id/Dialer" android:layout_height="280dip">
|
<TableLayout android:layout_width="fill_parent" android:id="@+id/Dialer"
|
||||||
<TableRow android:layout_height="fill_parent" android:layout_weight="1" android:id="@+id/DialerRow01" android:layout_width="fill_parent">
|
android:layout_height="fill_parent">
|
||||||
<Button android:id="@+id/Button01" android:text="1" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="0.25"></Button>
|
<TableRow android:layout_height="fill_parent"
|
||||||
<Button android:id="@+id/Button02" android:text="2" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="0.25"></Button>
|
android:layout_weight="1" android:id="@+id/DialerRow01"
|
||||||
<Button android:id="@+id/Button03" android:text="3" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="0.5"></Button>
|
android:layout_width="fill_parent">
|
||||||
</TableRow><TableRow android:layout_height="fill_parent" android:layout_weight="1" android:id="@+id/DialerRow02" android:layout_width="fill_parent"><Button android:id="@+id/Button04" android:text="4" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="0.25"></Button>
|
<Button android:id="@+id/Button01" android:text="1"
|
||||||
<Button android:text="5" android:id="@+id/Button05" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="0.25"></Button>
|
android:layout_width="fill_parent" android:layout_height="fill_parent"
|
||||||
<Button android:id="@+id/Button06" android:text="6" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="0.5"></Button>
|
android:layout_weight="0.25"></Button>
|
||||||
</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/Button02" android:text="2"
|
||||||
<Button android:id="@+id/Button08" android:text="8" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="0.25"></Button>
|
android:layout_width="fill_parent" android:layout_height="fill_parent"
|
||||||
<Button android:text="9" android:id="@+id/Button09" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="0.5"></Button>
|
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:id="@+id/Button03" android:text="3"
|
||||||
<Button android:layout_width="fill_parent" android:layout_height="fill_parent" android:text="0+" android:id="@+id/Button00" android:layout_weight="0.25"></Button>
|
android:layout_width="fill_parent" android:layout_height="fill_parent"
|
||||||
<Button android:layout_width="fill_parent" android:layout_height="fill_parent" android:id="@+id/ButtonHash" android:text="#" android:layout_weight="0.5"></Button>
|
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">
|
</TableRow>
|
||||||
|
<TableRow android:layout_height="fill_parent"
|
||||||
|
android:layout_weight="1" android:id="@+id/DialerRow02"
|
||||||
|
android:layout_width="fill_parent">
|
||||||
|
<Button android:id="@+id/Button04" android:text="4"
|
||||||
|
android:layout_width="fill_parent" android:layout_height="fill_parent"
|
||||||
|
android:layout_weight="0.25"></Button>
|
||||||
|
<Button android:text="5" android:id="@+id/Button05"
|
||||||
|
android:layout_width="fill_parent" android:layout_height="fill_parent"
|
||||||
|
android:layout_weight="0.25"></Button>
|
||||||
|
<Button android:id="@+id/Button06" android:text="6"
|
||||||
|
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/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: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:layout_width="fill_parent" android:layout_weight="1"
|
||||||
|
android:id="@+id/DialerRow05">
|
||||||
|
|
||||||
<ImageButton android:id="@+id/Call" android:layout_height="fill_parent" android:src="@drawable/green" android:layout_width="fill_parent" android:layout_weight="0.25">
|
<ImageButton android:id="@+id/Call"
|
||||||
|
android:layout_height="fill_parent" android:src="@drawable/green"
|
||||||
|
android:layout_width="fill_parent" android:layout_weight="0.25">
|
||||||
</ImageButton>
|
</ImageButton>
|
||||||
|
|
||||||
|
|
||||||
<ImageButton android:id="@+id/HangUp" android:src="@drawable/red" android:layout_height="fill_parent" android:layout_width="fill_parent" android:layout_weight="0.25"></ImageButton>
|
<ImageButton android:id="@+id/HangUp" android:src="@drawable/red"
|
||||||
|
android:layout_height="fill_parent" android:layout_width="fill_parent"
|
||||||
|
android:layout_weight="0.25"></ImageButton>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</TableRow>
|
</TableRow>
|
||||||
|
|
||||||
|
|
||||||
|
<EditText android:layout_width="fill_parent" android:id="@+id/status_label"
|
||||||
|
android:clickable="false" android:focusable="false"
|
||||||
|
android:cursorVisible="false" android:textSize="12sp" android:height="15sp"
|
||||||
|
android:layout_height="wrap_content"></EditText>
|
||||||
</TableLayout>
|
</TableLayout>
|
||||||
|
|
||||||
<EditText android:layout_width="fill_parent" android:id="@+id/status_label" android:clickable="false" android:focusable="false" android:cursorVisible="false" android:textSize="12sp" android:height="15sp" android:layout_height="wrap_content"></EditText>
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
44
res/layout/history_cell.xml
Normal file
44
res/layout/history_cell.xml
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?> <!-- from Android Layout Tricks #1 -->
|
||||||
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="?android:attr/listPreferredItemHeight"
|
||||||
|
android:padding="6dip">
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/history_cell_icon"
|
||||||
|
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="fill_parent"
|
||||||
|
|
||||||
|
android:layout_alignParentTop="true"
|
||||||
|
android:layout_alignParentBottom="true"
|
||||||
|
android:layout_marginRight="6dip"
|
||||||
|
|
||||||
|
android:src="@drawable/icon" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/history_cell_second_line"
|
||||||
|
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="26dip"
|
||||||
|
|
||||||
|
android:layout_toRightOf="@id/history_cell_icon"
|
||||||
|
android:layout_alignParentBottom="true"
|
||||||
|
android:layout_alignParentRight="true"
|
||||||
|
|
||||||
|
android:singleLine="true"
|
||||||
|
android:ellipsize="marquee" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/history_cell_first_line"
|
||||||
|
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
|
||||||
|
android:layout_toRightOf="@id/history_cell_icon"
|
||||||
|
android:layout_alignParentRight="true"
|
||||||
|
android:layout_alignParentTop="true"
|
||||||
|
android:layout_above="@id/history_cell_second_line"
|
||||||
|
android:layout_alignWithParentIfMissing="true"
|
||||||
|
|
||||||
|
android:gravity="center_vertical"/>
|
||||||
|
</RelativeLayout>
|
|
@ -7,7 +7,7 @@
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="fill_parent"
|
android:layout_height="fill_parent"
|
||||||
android:padding="5dp">
|
><!-- android:padding="5dp"-->
|
||||||
<TabWidget
|
<TabWidget
|
||||||
android:id="@android:id/tabs"
|
android:id="@android:id/tabs"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
|
@ -15,7 +15,7 @@
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:id="@android:id/tabcontent"
|
android:id="@android:id/tabcontent"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="fill_parent"
|
android:layout_height="fill_parent"/>
|
||||||
android:padding="5dp" />
|
<!-- android:padding="5dp" /-->
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</TabHost>
|
</TabHost>
|
|
@ -21,4 +21,5 @@
|
||||||
<string name="no">No</string>
|
<string name="no">No</string>
|
||||||
<string name="config_error">%s, do you want to return to the settings page ?</string>
|
<string name="config_error">%s, do you want to return to the settings page ?</string>
|
||||||
<string name="warning_already_incall">Cannot initiate a new call because a call is already engaged</string>
|
<string name="warning_already_incall">Cannot initiate a new call because a call is already engaged</string>
|
||||||
|
<string name="tab_history">History</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -1,3 +1,21 @@
|
||||||
|
/*
|
||||||
|
ContactPickerActivity.java
|
||||||
|
Copyright (C) 2010 Belledonne Communications, Grenoble, France
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU General Public License
|
||||||
|
as published by the Free Software Foundation; either version 2
|
||||||
|
of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
package org.linphone;
|
package org.linphone;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
@ -51,7 +69,7 @@ public class ContactPickerActivity extends Activity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Linphone.getLinphone().getTabHost().setCurrentTabByTag(Linphone.DIALER_TAB);
|
LinphoneActivity.instance().getTabHost().setCurrentTabByTag(LinphoneActivity.DIALER_TAB);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,21 @@
|
||||||
|
/*
|
||||||
|
DialerActivity.java
|
||||||
|
Copyright (C) 2010 Belledonne Communications, Grenoble, France
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU General Public License
|
||||||
|
as published by the Free Software Foundation; either version 2
|
||||||
|
of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
package org.linphone;
|
package org.linphone;
|
||||||
|
|
||||||
import org.linphone.core.LinphoneAddress;
|
import org.linphone.core.LinphoneAddress;
|
||||||
|
@ -9,6 +27,7 @@ import org.linphone.core.LinphoneCore.GeneralState;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.res.Configuration;
|
||||||
import android.media.AudioManager;
|
import android.media.AudioManager;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
@ -20,7 +39,7 @@ import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
public class DialerActivity extends Activity implements LinphoneCoreListener {
|
public class DialerActivity extends Activity implements LinphoneCoreListener {
|
||||||
private LinphoneCore mLinphoneCore;
|
|
||||||
private TextView mAddress;
|
private TextView mAddress;
|
||||||
private TextView mStatus;
|
private TextView mStatus;
|
||||||
private ImageButton mCall;
|
private ImageButton mCall;
|
||||||
|
@ -62,18 +81,19 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
|
||||||
setContentView(R.layout.dialer);
|
setContentView(R.layout.dialer);
|
||||||
mAudioManager = ((AudioManager)getSystemService(Context.AUDIO_SERVICE));
|
mAudioManager = ((AudioManager)getSystemService(Context.AUDIO_SERVICE));
|
||||||
try {
|
try {
|
||||||
theDialer = this;
|
|
||||||
mLinphoneCore = Linphone.getLinphone().getLinphoneCore();
|
|
||||||
mAddress = (TextView) findViewById(R.id.SipUri);
|
mAddress = (TextView) findViewById(R.id.SipUri);
|
||||||
|
|
||||||
mCall = (ImageButton) findViewById(R.id.Call);
|
mCall = (ImageButton) findViewById(R.id.Call);
|
||||||
mCall.setOnClickListener(new OnClickListener() {
|
mCall.setOnClickListener(new OnClickListener() {
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
if (mLinphoneCore.isInComingInvitePending()) {
|
LinphoneCore lLinphoneCore = LinphoneService.instance().getLinphoneCore();
|
||||||
mLinphoneCore.acceptCall();
|
if (lLinphoneCore.isInComingInvitePending()) {
|
||||||
|
lLinphoneCore.acceptCall();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (mLinphoneCore.isIncall()) {
|
if (lLinphoneCore.isIncall()) {
|
||||||
Toast toast = Toast.makeText(DialerActivity.this, getString(R.string.warning_already_incall), Toast.LENGTH_LONG);
|
Toast toast = Toast.makeText(DialerActivity.this, getString(R.string.warning_already_incall), Toast.LENGTH_LONG);
|
||||||
toast.show();
|
toast.show();
|
||||||
return;
|
return;
|
||||||
|
@ -83,7 +103,7 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
|
||||||
if (lRawAddress.startsWith("sip:")) {
|
if (lRawAddress.startsWith("sip:")) {
|
||||||
lCallingUri=lRawAddress;
|
lCallingUri=lRawAddress;
|
||||||
} else {
|
} else {
|
||||||
LinphoneProxyConfig lProxy = mLinphoneCore.getDefaultProxyConfig();
|
LinphoneProxyConfig lProxy = lLinphoneCore.getDefaultProxyConfig();
|
||||||
String lDomain=null;
|
String lDomain=null;
|
||||||
String lNormalizedNumber=lRawAddress;
|
String lNormalizedNumber=lRawAddress;
|
||||||
if (lProxy!=null) {
|
if (lProxy!=null) {
|
||||||
|
@ -95,15 +115,17 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
|
||||||
, mDisplayName);
|
, mDisplayName);
|
||||||
lCallingUri = lAddress.toUri();
|
lCallingUri = lAddress.toUri();
|
||||||
}
|
}
|
||||||
mLinphoneCore.invite(lCallingUri);
|
lLinphoneCore.invite(lCallingUri);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
mHangup = (ImageButton) findViewById(R.id.HangUp);
|
mHangup = (ImageButton) findViewById(R.id.HangUp);
|
||||||
mHangup.setEnabled(false);
|
mHangup.setEnabled(false);
|
||||||
mHangup.setOnClickListener(new OnClickListener() {
|
mHangup.setOnClickListener(new OnClickListener() {
|
||||||
|
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
mLinphoneCore.terminateCall();
|
LinphoneCore lLinphoneCore = LinphoneService.instance().getLinphoneCore();
|
||||||
|
lLinphoneCore.terminateCall();
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -121,7 +143,10 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
mZero = (Button) findViewById(R.id.Button00) ;
|
mZero = (Button) findViewById(R.id.Button00) ;
|
||||||
|
if (mZero != null) {
|
||||||
|
|
||||||
mZero.setOnClickListener(new DialKeyListener(mAddress,'0'));
|
mZero.setOnClickListener(new DialKeyListener(mAddress,'0'));
|
||||||
mOne = (Button) findViewById(R.id.Button01) ;
|
mOne = (Button) findViewById(R.id.Button01) ;
|
||||||
mOne.setOnClickListener(new DialKeyListener(mAddress,'1'));
|
mOne.setOnClickListener(new DialKeyListener(mAddress,'1'));
|
||||||
|
@ -145,11 +170,12 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
|
||||||
mStar.setOnClickListener(new DialKeyListener(mAddress,'*'));
|
mStar.setOnClickListener(new DialKeyListener(mAddress,'*'));
|
||||||
mHash = (Button) findViewById(R.id.ButtonHash);
|
mHash = (Button) findViewById(R.id.ButtonHash);
|
||||||
mHash.setOnClickListener(new DialKeyListener(mAddress,'#'));
|
mHash.setOnClickListener(new DialKeyListener(mAddress,'#'));
|
||||||
|
}
|
||||||
mStatus = (TextView) findViewById(R.id.status_label);
|
mStatus = (TextView) findViewById(R.id.status_label);
|
||||||
|
theDialer = this;
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e(Linphone.TAG,"Cannot start linphone",e);
|
Log.e(LinphoneService.TAG,"Cannot start linphone",e);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
106
src/org/linphone/HistoryActivity.java
Normal file
106
src/org/linphone/HistoryActivity.java
Normal file
|
@ -0,0 +1,106 @@
|
||||||
|
/*
|
||||||
|
DialerActivity.java
|
||||||
|
Copyright (C) 2010 Belledonne Communications, Grenoble, France
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU General Public License
|
||||||
|
as published by the Free Software Foundation; either version 2
|
||||||
|
of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
package org.linphone;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.linphone.core.LinphoneAddress;
|
||||||
|
import org.linphone.core.LinphoneCallLog;
|
||||||
|
import org.linphone.core.LinphoneCallLog.CallDirection;
|
||||||
|
|
||||||
|
import android.app.ListActivity;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.BaseAdapter;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
public class HistoryActivity extends ListActivity {
|
||||||
|
LayoutInflater mInflater;
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
mInflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
setListAdapter(new CallHistoryAdapter(this));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class CallHistoryAdapter extends BaseAdapter {
|
||||||
|
private final Context mContext;
|
||||||
|
final List<LinphoneCallLog> mLogs;
|
||||||
|
CallHistoryAdapter(Context aContext) {
|
||||||
|
mContext = aContext;
|
||||||
|
mLogs = LinphoneService.instance().getLinphoneCore().getCallLogs();
|
||||||
|
}
|
||||||
|
public int getCount() {
|
||||||
|
return mLogs.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object getItem(int position) {
|
||||||
|
return position;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getItemId(int position) {
|
||||||
|
|
||||||
|
return position;
|
||||||
|
}
|
||||||
|
|
||||||
|
public View getView(int position, View convertView, ViewGroup parent) {
|
||||||
|
LinphoneCallLog lLog = mLogs.get(position);
|
||||||
|
View lView=null;
|
||||||
|
LinphoneAddress lAddress;
|
||||||
|
lView = mInflater.inflate(R.layout.history_cell, null);
|
||||||
|
TextView lFirstLineView = (TextView) lView.findViewById(R.id.history_cell_first_line);
|
||||||
|
TextView lSecondLineView = (TextView) lView.findViewById(R.id.history_cell_second_line);
|
||||||
|
ImageView lDirectionImage = (ImageView) lView.findViewById(R.id.history_cell_icon);
|
||||||
|
|
||||||
|
if (lLog.getDirection() == CallDirection.Callincoming) {
|
||||||
|
lAddress = lLog.getFrom();
|
||||||
|
lDirectionImage.setImageResource(R.drawable.in_call);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
lAddress = lLog.getTo();
|
||||||
|
lDirectionImage.setImageResource(R.drawable.out_call);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lAddress.getDisplayName() == null) {
|
||||||
|
lFirstLineView.setText(lAddress.getUserName());
|
||||||
|
lSecondLineView.setVisibility(View.GONE);
|
||||||
|
} else {
|
||||||
|
lFirstLineView.setText(lAddress.getDisplayName());
|
||||||
|
lSecondLineView.setText(lAddress.getUserName());
|
||||||
|
}
|
||||||
|
|
||||||
|
return lView;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
166
src/org/linphone/LinphoneActivity.java
Normal file
166
src/org/linphone/LinphoneActivity.java
Normal file
|
@ -0,0 +1,166 @@
|
||||||
|
/*
|
||||||
|
LinphoneActivity.java
|
||||||
|
Copyright (C) 2010 Belledonne Communications, Grenoble, France
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU General Public License
|
||||||
|
as published by the Free Software Foundation; either version 2
|
||||||
|
of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
package org.linphone;
|
||||||
|
|
||||||
|
|
||||||
|
import android.app.AlertDialog;
|
||||||
|
import android.app.TabActivity;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.DialogInterface;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.media.AudioManager;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.view.Menu;
|
||||||
|
import android.view.MenuInflater;
|
||||||
|
import android.view.MenuItem;
|
||||||
|
import android.widget.TabHost;
|
||||||
|
|
||||||
|
public class LinphoneActivity extends TabActivity {
|
||||||
|
public static String DIALER_TAB = "dialer";
|
||||||
|
private AudioManager mAudioManager;
|
||||||
|
private static LinphoneActivity theLinphoneActivity;
|
||||||
|
|
||||||
|
protected static LinphoneActivity instance()
|
||||||
|
{
|
||||||
|
if (theLinphoneActivity == null) {
|
||||||
|
throw new RuntimeException("LinphoneActivity not instanciated yet");
|
||||||
|
} else {
|
||||||
|
return theLinphoneActivity;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.main);
|
||||||
|
theLinphoneActivity = this;
|
||||||
|
|
||||||
|
|
||||||
|
mAudioManager = ((AudioManager)getSystemService(Context.AUDIO_SERVICE));
|
||||||
|
|
||||||
|
TabHost lTabHost = getTabHost(); // The activity TabHost
|
||||||
|
TabHost.TabSpec spec; // Reusable TabSpec for each tab
|
||||||
|
|
||||||
|
|
||||||
|
//Call History
|
||||||
|
Intent lHistoryItent = new Intent().setClass(this, HistoryActivity.class);
|
||||||
|
|
||||||
|
spec = lTabHost.newTabSpec("history").setIndicator(getString(R.string.tab_history),
|
||||||
|
null)
|
||||||
|
.setContent(lHistoryItent);
|
||||||
|
lTabHost.addTab(spec);
|
||||||
|
|
||||||
|
// dialer
|
||||||
|
Intent lDialerIntent = new Intent().setClass(this, DialerActivity.class);
|
||||||
|
|
||||||
|
// Initialize a TabSpec for each tab and add it to the TabHost
|
||||||
|
spec = lTabHost.newTabSpec("dialer").setIndicator(getString(R.string.tab_dialer),
|
||||||
|
getResources().getDrawable(android.R.drawable.ic_menu_call))
|
||||||
|
.setContent(lDialerIntent);
|
||||||
|
lTabHost.addTab(spec);
|
||||||
|
|
||||||
|
// contact pick
|
||||||
|
Intent lContactItent = new Intent().setClass(this, ContactPickerActivity.class);
|
||||||
|
|
||||||
|
spec = lTabHost.newTabSpec("contact").setIndicator(getString(R.string.tab_contact),
|
||||||
|
null)
|
||||||
|
.setContent(lContactItent);
|
||||||
|
lTabHost.addTab(spec);
|
||||||
|
|
||||||
|
lTabHost.setCurrentTabByTag("dialer");
|
||||||
|
// start linphone as background
|
||||||
|
Intent intent = new Intent(Intent.ACTION_MAIN);
|
||||||
|
intent.setClass(this, LinphoneService.class);
|
||||||
|
startService(intent);
|
||||||
|
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
protected void onDestroy() {
|
||||||
|
super.onDestroy();
|
||||||
|
if (isFinishing()) {
|
||||||
|
//restaure audio settings
|
||||||
|
mAudioManager.setSpeakerphoneOn(true);
|
||||||
|
mAudioManager.setMode(AudioManager.MODE_NORMAL);
|
||||||
|
mAudioManager.setRouting(AudioManager.MODE_NORMAL,
|
||||||
|
AudioManager.ROUTE_SPEAKER, AudioManager.ROUTE_ALL);
|
||||||
|
|
||||||
|
Intent intent = new Intent(Intent.ACTION_MAIN);
|
||||||
|
intent.setClass(this, LinphoneService.class);
|
||||||
|
stopService(intent);
|
||||||
|
}
|
||||||
|
theLinphoneActivity = null;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
|
// Inflate the currently selected menu XML resource.
|
||||||
|
MenuInflater inflater = getMenuInflater();
|
||||||
|
inflater.inflate(R.menu.linphone_activity_menu, menu);
|
||||||
|
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
|
switch (item.getItemId()) {
|
||||||
|
case R.id.menu_settings:
|
||||||
|
startprefActivity();
|
||||||
|
return true;
|
||||||
|
case R.id.menu_exit:
|
||||||
|
finish();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
Log.e(LinphoneService.TAG, "Unknown menu item ["+item+"]");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
private void startprefActivity() {
|
||||||
|
Intent intent = new Intent(Intent.ACTION_MAIN);
|
||||||
|
intent.setClass(this, LinphonePreferencesActivity.class);
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
public void initFromConf() throws LinphoneException {
|
||||||
|
|
||||||
|
try {
|
||||||
|
LinphoneService.instance().initFromConf();
|
||||||
|
} catch (LinphoneConfigException e) {
|
||||||
|
handleBadConfig(e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
private void handleBadConfig(String message) {
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||||
|
builder.setMessage(String.format(getString(R.string.config_error),message))
|
||||||
|
.setCancelable(false)
|
||||||
|
.setPositiveButton(getString(R.string.yes), new DialogInterface.OnClickListener() {
|
||||||
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
|
startprefActivity();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.setNegativeButton(getString(R.string.no), new DialogInterface.OnClickListener() {
|
||||||
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
|
dialog.cancel();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
builder.create().show();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
40
src/org/linphone/LinphoneConfigException.java
Normal file
40
src/org/linphone/LinphoneConfigException.java
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
/*
|
||||||
|
LinphoneCoreException.java
|
||||||
|
Copyright (C) 2010 Belledonne Communications, Grenoble, France
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU General Public License
|
||||||
|
as published by the Free Software Foundation; either version 2
|
||||||
|
of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
package org.linphone;
|
||||||
|
|
||||||
|
@SuppressWarnings("serial")
|
||||||
|
public class LinphoneConfigException extends LinphoneException {
|
||||||
|
|
||||||
|
public LinphoneConfigException() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public LinphoneConfigException(String detailMessage, Throwable throwable) {
|
||||||
|
super(detailMessage, throwable);
|
||||||
|
}
|
||||||
|
|
||||||
|
public LinphoneConfigException(String detailMessage) {
|
||||||
|
super(detailMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
public LinphoneConfigException(Throwable throwable) {
|
||||||
|
super(throwable);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -36,9 +36,9 @@ public class LinphonePreferencesActivity extends PreferenceActivity {
|
||||||
protected void onStop() {
|
protected void onStop() {
|
||||||
super.onStop();
|
super.onStop();
|
||||||
try {
|
try {
|
||||||
Linphone.getLinphone().initFromConf();
|
LinphoneActivity.instance().initFromConf();
|
||||||
} catch (LinphoneCoreException e) {
|
} catch (LinphoneException e) {
|
||||||
Log.e(Linphone.TAG, "cannot update config",e);
|
Log.e(LinphoneService.TAG, "cannot update config",e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,12 +35,16 @@ import org.linphone.core.LinphoneProxyConfig;
|
||||||
|
|
||||||
|
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
|
import android.app.Service;
|
||||||
import android.app.TabActivity;
|
import android.app.TabActivity;
|
||||||
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
import android.media.AudioManager;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
|
import android.os.IBinder;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
@ -50,7 +54,7 @@ import android.view.MenuItem;
|
||||||
import android.widget.TabHost;
|
import android.widget.TabHost;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
public class Linphone extends TabActivity implements LinphoneCoreListener {
|
public class LinphoneService extends Service implements LinphoneCoreListener {
|
||||||
static final public String TAG="Linphone";
|
static final public String TAG="Linphone";
|
||||||
/** Called when the activity is first created. */
|
/** Called when the activity is first created. */
|
||||||
private static String LINPHONE_FACTORY_RC = "/data/data/org.linphone/files/linphonerc";
|
private static String LINPHONE_FACTORY_RC = "/data/data/org.linphone/files/linphonerc";
|
||||||
|
@ -58,26 +62,26 @@ public class Linphone extends TabActivity implements LinphoneCoreListener {
|
||||||
private static String RING_SND = "/data/data/org.linphone/files/oldphone_mono.wav";
|
private static String RING_SND = "/data/data/org.linphone/files/oldphone_mono.wav";
|
||||||
private static String RINGBACK_SND = "/data/data/org.linphone/files/ringback.wav";
|
private static String RINGBACK_SND = "/data/data/org.linphone/files/ringback.wav";
|
||||||
|
|
||||||
private static Linphone theLinphone;
|
private static LinphoneService theLinphone;
|
||||||
private LinphoneCore mLinphoneCore;
|
private LinphoneCore mLinphoneCore;
|
||||||
private SharedPreferences mPref;
|
private SharedPreferences mPref;
|
||||||
Timer mTimer = new Timer("Linphone scheduler");
|
Timer mTimer = new Timer("Linphone scheduler");
|
||||||
public static String DIALER_TAB = "dialer";
|
|
||||||
|
|
||||||
private Handler mIteratehandler;
|
private Handler mIteratehandler;
|
||||||
|
|
||||||
static Linphone getLinphone() {
|
static LinphoneService instance() {
|
||||||
if (theLinphone == null) {
|
if (theLinphone == null) {
|
||||||
throw new RuntimeException("LinphoneActivity not instanciated yet");
|
throw new RuntimeException("LinphoneActivity not instanciated yet");
|
||||||
} else {
|
} else {
|
||||||
return theLinphone;
|
return theLinphone;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate() {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate();
|
||||||
setContentView(R.layout.main);
|
|
||||||
theLinphone = this;
|
theLinphone = this;
|
||||||
|
|
||||||
mPref = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
|
mPref = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
|
||||||
try {
|
try {
|
||||||
copyAssetsFromPackage();
|
copyAssetsFromPackage();
|
||||||
|
@ -106,31 +110,6 @@ public class Linphone extends TabActivity implements LinphoneCoreListener {
|
||||||
mTimer.scheduleAtFixedRate(lTask, 0, 100);
|
mTimer.scheduleAtFixedRate(lTask, 0, 100);
|
||||||
|
|
||||||
|
|
||||||
TabHost lTabHost = getTabHost(); // The activity TabHost
|
|
||||||
TabHost.TabSpec spec; // Reusable TabSpec for each tab
|
|
||||||
|
|
||||||
|
|
||||||
// Create an Intent to launch an Activity for the tab (to be reused)
|
|
||||||
Intent lDialerIntent = new Intent().setClass(this, DialerActivity.class);
|
|
||||||
|
|
||||||
// Initialize a TabSpec for each tab and add it to the TabHost
|
|
||||||
spec = lTabHost.newTabSpec("dialer").setIndicator(getString(R.string.tab_dialer),
|
|
||||||
getResources().getDrawable(android.R.drawable.ic_menu_call))
|
|
||||||
.setContent(lDialerIntent);
|
|
||||||
lTabHost.addTab(spec);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Do the same for the other tabs
|
|
||||||
Intent lContactItent = new Intent().setClass(this, ContactPickerActivity.class);
|
|
||||||
|
|
||||||
spec = lTabHost.newTabSpec("contact").setIndicator(getString(R.string.tab_contact),
|
|
||||||
null)
|
|
||||||
.setContent(lContactItent);
|
|
||||||
lTabHost.addTab(spec);
|
|
||||||
|
|
||||||
lTabHost.setCurrentTabByTag("dialer");
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -141,11 +120,7 @@ public class Linphone extends TabActivity implements LinphoneCoreListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onDestroy() {
|
|
||||||
super.onDestroy();
|
|
||||||
if (isFinishing()) System.exit(0); // FIXME to destroy liblinphone
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void copyAssetsFromPackage() throws IOException {
|
private void copyAssetsFromPackage() throws IOException {
|
||||||
|
@ -204,53 +179,24 @@ public class Linphone extends TabActivity implements LinphoneCoreListener {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
}
|
}
|
||||||
@Override
|
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
|
||||||
// Inflate the currently selected menu XML resource.
|
|
||||||
MenuInflater inflater = getMenuInflater();
|
|
||||||
inflater.inflate(R.menu.linphone_activity_menu, menu);
|
|
||||||
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
public void initFromConf() throws LinphoneConfigException, LinphoneException {
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
|
||||||
switch (item.getItemId()) {
|
|
||||||
case R.id.menu_settings:
|
|
||||||
startprefActivity();
|
|
||||||
return true;
|
|
||||||
case R.id.menu_exit:
|
|
||||||
finish();
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
Log.e(TAG, "Unknown menu item ["+item+"]");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void initFromConf() throws LinphoneCoreException {
|
|
||||||
//1 read proxy config from preferences
|
//1 read proxy config from preferences
|
||||||
String lUserName = mPref.getString(getString(R.string.pref_username_key), null);
|
String lUserName = mPref.getString(getString(R.string.pref_username_key), null);
|
||||||
if (lUserName == null) {
|
if (lUserName == null) {
|
||||||
handleBadConfig(getString(R.string.wrong_username));
|
throw new LinphoneConfigException(getString(R.string.wrong_username));
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String lPasswd = mPref.getString(getString(R.string.pref_passwd_key), null);
|
String lPasswd = mPref.getString(getString(R.string.pref_passwd_key), null);
|
||||||
if (lPasswd == null) {
|
if (lPasswd == null) {
|
||||||
handleBadConfig(getString(R.string.wrong_passwd));
|
throw new LinphoneConfigException(getString(R.string.wrong_passwd));
|
||||||
return;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String lDomain = mPref.getString(getString(R.string.pref_domain_key), null);
|
String lDomain = mPref.getString(getString(R.string.pref_domain_key), null);
|
||||||
if (lDomain == null) {
|
if (lDomain == null) {
|
||||||
handleBadConfig(getString(R.string.wrong_domain));
|
throw new LinphoneConfigException(getString(R.string.wrong_domain));
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -266,6 +212,7 @@ public class Linphone extends TabActivity implements LinphoneCoreListener {
|
||||||
//get Default proxy if any
|
//get Default proxy if any
|
||||||
LinphoneProxyConfig lDefaultProxyConfig = mLinphoneCore.getDefaultProxyConfig();
|
LinphoneProxyConfig lDefaultProxyConfig = mLinphoneCore.getDefaultProxyConfig();
|
||||||
String lIdentity = "sip:"+lUserName+"@"+lDomain;
|
String lIdentity = "sip:"+lUserName+"@"+lDomain;
|
||||||
|
try {
|
||||||
if (lDefaultProxyConfig == null) {
|
if (lDefaultProxyConfig == null) {
|
||||||
lDefaultProxyConfig = mLinphoneCore.createProxyConfig(lIdentity, lProxy, null,true);
|
lDefaultProxyConfig = mLinphoneCore.createProxyConfig(lIdentity, lProxy, null,true);
|
||||||
mLinphoneCore.addtProxyConfig(lDefaultProxyConfig);
|
mLinphoneCore.addtProxyConfig(lDefaultProxyConfig);
|
||||||
|
@ -289,32 +236,27 @@ public class Linphone extends TabActivity implements LinphoneCoreListener {
|
||||||
//escape +
|
//escape +
|
||||||
lDefaultProxyConfig.setDialEscapePlus(true);
|
lDefaultProxyConfig.setDialEscapePlus(true);
|
||||||
}
|
}
|
||||||
|
}catch (LinphoneCoreException e) {
|
||||||
|
throw new LinphoneException(e);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleBadConfig(String message) {
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
|
||||||
builder.setMessage(String.format(getString(R.string.config_error),message))
|
|
||||||
.setCancelable(false)
|
|
||||||
.setPositiveButton(getString(R.string.yes), new DialogInterface.OnClickListener() {
|
|
||||||
public void onClick(DialogInterface dialog, int id) {
|
|
||||||
startprefActivity();
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.setNegativeButton(getString(R.string.no), new DialogInterface.OnClickListener() {
|
|
||||||
public void onClick(DialogInterface dialog, int id) {
|
|
||||||
dialog.cancel();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
builder.create().show();
|
|
||||||
}
|
|
||||||
private void startprefActivity() {
|
|
||||||
Intent intent = new Intent(Intent.ACTION_MAIN);
|
|
||||||
intent.setClass(Linphone.this, LinphonePreferencesActivity.class);
|
|
||||||
startActivity(intent);
|
|
||||||
}
|
|
||||||
protected LinphoneCore getLinphoneCore() {
|
protected LinphoneCore getLinphoneCore() {
|
||||||
return mLinphoneCore;
|
return mLinphoneCore;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IBinder onBind(Intent intent) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroy() {
|
||||||
|
super.onDestroy();
|
||||||
|
System.exit(0); // FIXME to destroy liblinphone
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
31
src/org/linphone/core/LinphoneCallLog.java
Normal file
31
src/org/linphone/core/LinphoneCallLog.java
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
/*
|
||||||
|
LinPhoneCallLog.java
|
||||||
|
Copyright (C) 2010 Belledonne Communications, Grenoble, France
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU General Public License
|
||||||
|
as published by the Free Software Foundation; either version 2
|
||||||
|
of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
package org.linphone.core;
|
||||||
|
|
||||||
|
public interface LinphoneCallLog {
|
||||||
|
public enum CallDirection {
|
||||||
|
CallOutgoing,Callincoming
|
||||||
|
}
|
||||||
|
|
||||||
|
public LinphoneAddress getFrom();
|
||||||
|
|
||||||
|
public LinphoneAddress getTo ();
|
||||||
|
|
||||||
|
public LinphoneCallLog.CallDirection getDirection();
|
||||||
|
}
|
46
src/org/linphone/core/LinphoneCallLogImpl.java
Normal file
46
src/org/linphone/core/LinphoneCallLogImpl.java
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
/*
|
||||||
|
LinPhoneCallLogImpl.java
|
||||||
|
Copyright (C) 2010 Belledonne Communications, Grenoble, France
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU General Public License
|
||||||
|
as published by the Free Software Foundation; either version 2
|
||||||
|
of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
package org.linphone.core;
|
||||||
|
|
||||||
|
|
||||||
|
class LinphoneCallLogImpl implements LinphoneCallLog {
|
||||||
|
|
||||||
|
protected final long nativePtr;
|
||||||
|
|
||||||
|
private native long getFrom(long nativePtr);
|
||||||
|
private native long getTo(long nativePtr);
|
||||||
|
private native boolean isIncoming(long nativePtr);
|
||||||
|
LinphoneCallLogImpl(long aNativePtr) {
|
||||||
|
nativePtr = aNativePtr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public CallDirection getDirection() {
|
||||||
|
return isIncoming(nativePtr)?CallDirection.Callincoming:CallDirection.CallOutgoing;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LinphoneAddress getFrom() {
|
||||||
|
return new LinphoneAddressImpl(getFrom(nativePtr));
|
||||||
|
}
|
||||||
|
|
||||||
|
public LinphoneAddress getTo() {
|
||||||
|
return new LinphoneAddressImpl(getTo(nativePtr));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -18,6 +18,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
package org.linphone.core;
|
package org.linphone.core;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public interface LinphoneCore {
|
public interface LinphoneCore {
|
||||||
|
@ -116,4 +118,9 @@ public interface LinphoneCore {
|
||||||
public void acceptCall();
|
public void acceptCall();
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return a list of LinphoneCallLog
|
||||||
|
*/
|
||||||
|
public List<LinphoneCallLog> getCallLogs();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,8 @@ package org.linphone.core;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
class LinphoneCoreImpl implements LinphoneCore {
|
class LinphoneCoreImpl implements LinphoneCore {
|
||||||
|
@ -42,6 +44,9 @@ class LinphoneCoreImpl implements LinphoneCore {
|
||||||
private native boolean isInCall(long nativePtr);
|
private native boolean isInCall(long nativePtr);
|
||||||
private native boolean isInComingInvitePending(long nativePtr);
|
private native boolean isInComingInvitePending(long nativePtr);
|
||||||
private native void acceptCall(long nativePtr);
|
private native void acceptCall(long nativePtr);
|
||||||
|
private native long getCallLog(long nativePtr,int position);
|
||||||
|
private native int getNumberOfCallLogs(long nativePtr);
|
||||||
|
|
||||||
|
|
||||||
LinphoneCoreImpl(LinphoneCoreListener listener, File userConfig,File factoryConfig,Object userdata) throws IOException {
|
LinphoneCoreImpl(LinphoneCoreListener listener, File userConfig,File factoryConfig,Object userdata) throws IOException {
|
||||||
mListener=listener;
|
mListener=listener;
|
||||||
|
@ -109,4 +114,11 @@ class LinphoneCoreImpl implements LinphoneCore {
|
||||||
acceptCall(nativePtr);
|
acceptCall(nativePtr);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
public List<LinphoneCallLog> getCallLogs() {
|
||||||
|
List<LinphoneCallLog> logs = new ArrayList<LinphoneCallLog>();
|
||||||
|
for (int i=0;i < getNumberOfCallLogs(nativePtr);i++) {
|
||||||
|
logs.add(new LinphoneCallLogImpl(getCallLog(nativePtr, i)));
|
||||||
|
}
|
||||||
|
return logs;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
package org.linphone.core;
|
package org.linphone.core;
|
||||||
|
|
||||||
import org.linphone.Linphone;
|
import org.linphone.LinphoneService;
|
||||||
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
@ -35,14 +35,14 @@ class LinphoneProxyConfigImpl implements LinphoneProxyConfig {
|
||||||
setProxy(proxy);
|
setProxy(proxy);
|
||||||
enableRegister(enableRegister);
|
enableRegister(enableRegister);
|
||||||
ownPtr=true;
|
ownPtr=true;
|
||||||
Log.w(Linphone.TAG, "route ["+route+"] not used yet");
|
Log.w(LinphoneService.TAG, "route ["+route+"] not used yet");
|
||||||
}
|
}
|
||||||
protected LinphoneProxyConfigImpl(long aNativePtr) {
|
protected LinphoneProxyConfigImpl(long aNativePtr) {
|
||||||
nativePtr = aNativePtr;
|
nativePtr = aNativePtr;
|
||||||
ownPtr=false;
|
ownPtr=false;
|
||||||
}
|
}
|
||||||
protected void finalize() throws Throwable {
|
protected void finalize() throws Throwable {
|
||||||
Log.e(Linphone.TAG,"fixme, should release underlying proxy config");
|
Log.e(LinphoneService.TAG,"fixme, should release underlying proxy config");
|
||||||
// FIXME if (ownPtr) delete(nativePtr);
|
// FIXME if (ownPtr) delete(nativePtr);
|
||||||
}
|
}
|
||||||
private native long newLinphoneProxyConfig();
|
private native long newLinphoneProxyConfig();
|
||||||
|
|
Loading…
Reference in a new issue