add about menu

This commit is contained in:
Jehan Monnier 2010-03-16 18:15:00 +01:00
parent b983a3a071
commit a16ef1961d
14 changed files with 130 additions and 38 deletions

View file

@ -40,6 +40,11 @@
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
<activity android:name=".AboutActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
<service android:name=".LinphoneService">
</service>

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

7
res/layout/about.xml Normal file
View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:orientation="vertical" android:gravity="center" android:layout_height="fill_parent">
<ImageView android:id="@+id/ImageView01" android:layout_height="wrap_content" android:src="@drawable/linphone_3_250x130" android:layout_width="wrap_content"></ImageView>
<TextView android:id="@+id/TextView01" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/about_text" android:autoLink="web" android:gravity="center" android:paddingTop="50sp" android:textStyle="bold"></TextView>
</LinearLayout>

View file

@ -11,7 +11,7 @@
android:hint="sip:" android:layout_width="fill_parent"
android:lines="1" android:layout_weight="0.2"></EditText>
<Button android:layout_height="wrap_content" android:id="@+id/Erase"
android:layout_width="fill_parent" android:text="&lt;-" android:layout_weight="0.8"></Button>
android:layout_width="fill_parent" android:text="&lt;-" android:layout_weight="0.8" android:textSize="20sp" android:textStyle="bold"></Button>
</LinearLayout>
@ -25,41 +25,41 @@
android:layout_weight="1" android:id="@+id/DialerRow01"
android:layout_width="fill_parent">
<Button android:id="@+id/Button01" android:text="1"
android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="0.33"></Button>
android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="0.33" android:textStyle="bold" android:textSize="20sp"></Button>
<Button android:id="@+id/Button02" android:text="2"
android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="0.33"></Button>
android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="0.33" android:textStyle="bold" android:textSize="20sp"></Button>
<Button android:id="@+id/Button03" android:text="3"
android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="0.33"></Button>
android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="0.33" android:textStyle="bold" android:textSize="20sp"></Button>
</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.33"></Button>
android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="0.33" android:textStyle="bold" android:textSize="20sp"></Button>
<Button android:text="5" android:id="@+id/Button05"
android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="0.33"></Button>
android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="0.33" android:textStyle="bold" android:textSize="20sp"></Button>
<Button android:id="@+id/Button06" android:text="6"
android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="0.33"></Button>
android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="0.33" android:textStyle="bold" android:textSize="20sp"></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.33"></Button>
android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="0.33" android:textStyle="bold" android:textSize="20sp"></Button>
<Button android:id="@+id/Button08" android:text="8"
android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="0.33"></Button>
android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="0.33" android:textStyle="bold" android:textSize="20sp"></Button>
<Button android:text="9" android:id="@+id/Button09"
android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="0.33"></Button>
android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="0.33" android:textStyle="bold" android:textSize="20sp"></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:id="@+id/ButtonStar" android:layout_weight="0.33"></Button>
android:id="@+id/ButtonStar" android:layout_weight="0.33" android:textStyle="bold" android:textSize="20sp"></Button>
<Button android:layout_width="fill_parent"
android:layout_height="fill_parent" android:text="0+" android:id="@+id/Button00" android:layout_weight="0.33"></Button>
android:layout_height="fill_parent" android:text="0+" android:id="@+id/Button00" android:layout_weight="0.33" android:textStyle="bold" android:textSize="20sp"></Button>
<Button android:layout_width="fill_parent"
android:layout_height="fill_parent" android:id="@+id/ButtonHash"
android:text="#" android:layout_weight="0.33"></Button>
android:text="#" android:layout_weight="0.33" android:textStyle="bold" android:textSize="20sp"></Button>
</TableRow>

View file

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="about_text">Linphone 3.1.2 SIP (rfc 3261) Compatible Internet phone \n http://www.linphone.org</string>
<string name="menu_about">About</string>
<string name="pref_audio">Audio</string>
<string name="menu_exit">Exit</string>
@ -24,4 +25,5 @@
<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="tab_history">History</string>
<string name="warning_wrong_destination_address">Cannot build destination address from [%s]</string>
</resources>

View file

@ -0,0 +1,31 @@
/*
AboutActivity.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.Activity;
import android.os.Bundle;
public class AboutActivity extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.about);
}
}

View file

@ -20,6 +20,7 @@ package org.linphone;
import org.linphone.core.LinphoneAddress;
import org.linphone.core.LinphoneCore;
import org.linphone.core.LinphoneCoreException;
import org.linphone.core.LinphoneCoreFactory;
import org.linphone.core.LinphoneCoreListener;
import org.linphone.core.LinphoneProxyConfig;
@ -107,7 +108,15 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
mErase.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
mAddress.getEditableText().delete(mAddress.getEditableText().length()-1, mAddress.getEditableText().length());
if (mAddress.length() >0) {
int lBegin = mAddress.getSelectionStart();
if (lBegin == -1) {
lBegin = mAddress.getEditableText().length()-1;
}
if (lBegin >0) {
mAddress.getEditableText().delete(lBegin-1,lBegin);
}
}
}
});
@ -124,24 +133,18 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
toast.show();
return;
}
String lRawAddress = mAddress.getText().toString();
String lCallingUri=null;
if (lRawAddress.startsWith("sip:")) {
lCallingUri=lRawAddress;
} else {
LinphoneProxyConfig lProxy = lLinphoneCore.getDefaultProxyConfig();
String lDomain=null;
String lNormalizedNumber=lRawAddress;
if (lProxy!=null) {
lNormalizedNumber = lProxy.normalizePhoneNumber(lNormalizedNumber);
lDomain = lProxy.getDomain();
}
LinphoneAddress lAddress = LinphoneCoreFactory.instance().createLinphoneAddress(lNormalizedNumber
, lDomain
, mDisplayName);
lCallingUri = lAddress.toUri();
LinphoneAddress lAddress;
try {
lAddress = lLinphoneCore.interpretUrl( mAddress.getText().toString());
} catch (LinphoneCoreException e) {
Toast toast = Toast.makeText(DialerActivity.this
,String.format(getString(R.string.warning_wrong_destination_address),mAddress.getText().toString())
, Toast.LENGTH_LONG);
toast.show();
return;
}
lLinphoneCore.invite(lCallingUri);
lAddress.setDisplayName(mDisplayName);
lLinphoneCore.invite(lAddress);
}
});
@ -303,7 +306,11 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
}
case GSTATE_CALL_IN_CONNECTED:
case GSTATE_CALL_OUT_CONNECTED: {
routeAudioToReceiver();
if (mSpeaker.isChecked()) {
routeAudioToSpeaker();
} else {
routeAudioToReceiver();
}
setVolumeControlStream(AudioManager.STREAM_VOICE_CALL);
break;
}
@ -321,7 +328,7 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
}
}
public void inviteReceived(LinphoneCore lc, String from) {
// TODO Auto-generated method stub
// TODO Auto-generated method stub
}
public void show(LinphoneCore lc) {

View file

@ -160,6 +160,10 @@ public class LinphoneActivity extends TabActivity implements SensorEventListener
case R.id.menu_exit:
finish();
break;
case R.id.menu_about:
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.setClass(this, AboutActivity.class);
startActivity(intent);
default:
Log.e(LinphoneService.TAG, "Unknown menu item ["+item+"]");
break;

View file

@ -33,13 +33,15 @@ public class LinphonePreferencesActivity extends PreferenceActivity {
}
@Override
protected void onStop() {
super.onStop();
protected void onPause() {
super.onPause();
if (isFinishing()) {
try {
LinphoneActivity.instance().initFromConf();
} catch (LinphoneException e) {
Log.e(LinphoneService.TAG, "cannot update config",e);
}
}
}
}

View file

@ -35,8 +35,11 @@ public class NetworkManager extends BroadcastReceiver {
NetworkInfo lNetworkInfo = (NetworkInfo) intent.getParcelableExtra(ConnectivityManager.EXTRA_NETWORK_INFO);
Log.i(LinphoneService.TAG, "Network info ["+lNetworkInfo+"]");
Boolean lNoConnectivity = intent.getBooleanExtra(ConnectivityManager.EXTRA_NO_CONNECTIVITY,false);
//Boolean lIsFailOver = intent.getBooleanExtra(ConnectivityManager.EXTRA_IS_FAILOVER,false);
if (lNoConnectivity| ((lNetworkInfo.getState() == NetworkInfo.State.DISCONNECTED) /*&& !lIsFailOver*/)) {
if (!LinphoneService.isready()) {
Log.i(LinphoneService.TAG, "Linphone service not ready");
return;
}
if (lNoConnectivity| ((lNetworkInfo.getState() == NetworkInfo.State.DISCONNECTED) /*&& !lIsFailOver*/)) {
LinphoneService.instance().getLinphoneCore().setNetworkStateReachable(false);
} else if (lNetworkInfo.getState() == NetworkInfo.State.CONNECTED){
LinphoneService.instance().getLinphoneCore().setNetworkStateReachable(true);

View file

@ -34,7 +34,11 @@ public interface LinphoneAddress {
* @return null if not set
*/
public String getDomain();
/**
* set display name
* @param name
*/
public void setDisplayName(String name);
/**
* @return an URI version of the address that can be used to place a call using {@link LinphoneCore#invite(String)}
*/

View file

@ -29,6 +29,8 @@ public class LinphoneAddressImpl implements LinphoneAddress {
private native String getUserName(long ptr);
private native String getDomain(long ptr);
private native String toUri(long ptr);
private native String setDisplayName(long ptr,String name);
protected LinphoneAddressImpl(String username,String domain,String displayName) {
nativePtr = newLinphoneAddressImpl("sip:"+username+"@"+domain, displayName);
@ -56,5 +58,8 @@ public class LinphoneAddressImpl implements LinphoneAddress {
public String toUri() {
return toUri(nativePtr);
}
public void setDisplayName(String name) {
setDisplayName(nativePtr,name);
}
}

View file

@ -90,6 +90,8 @@ public interface LinphoneCore {
public void invite(String uri);
public void invite(LinphoneAddress to);
public void terminateCall();
/**
* get the remote address in case of in/out call
@ -151,6 +153,13 @@ public interface LinphoneCore {
* @param isMuted
*/
public void muteMic(boolean isMuted);
/**
* Build an address according to the current proxy config. In case destination is not a sip uri, the default proxy domain is automatically appended
* @param destination
* @return
* @throws If no LinphonrAddress can be built from destination
*/
public LinphoneAddress interpretUrl(String destination) throws LinphoneCoreException;
}

View file

@ -52,6 +52,8 @@ class LinphoneCoreImpl implements LinphoneCore {
private native void setSoftPlayLevel(long nativeptr, float gain);
private native float getSoftPlayLevel(long nativeptr);
private native void muteMic(long nativePtr,boolean isMuted);
private native long interpretUrl(long nativePtr,String destination);
private native void inviteAddress(long nativePtr,long to);
LinphoneCoreImpl(LinphoneCoreListener listener, File userConfig,File factoryConfig,Object userdata) throws IOException {
@ -169,4 +171,15 @@ class LinphoneCoreImpl implements LinphoneCore {
public void muteMic(boolean isMuted) {
muteMic(nativePtr,isMuted);
}
public LinphoneAddress interpretUrl(String destination) throws LinphoneCoreException {
long lAddress = interpretUrl(nativePtr,destination);
if (lAddress != 0) {
return new LinphoneAddressImpl(lAddress);
} else {
throw new LinphoneCoreException("Cannot interpret ["+destination+"]");
}
}
public void invite(LinphoneAddress to) {
inviteAddress(nativePtr,((LinphoneAddressImpl)to).nativePtr);
}
}