diff --git a/AndroidManifest.xml b/AndroidManifest.xml index a4a4a194e..3af217811 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -40,6 +40,11 @@ + + + + + diff --git a/res/drawable/linphone_3_250x130.png b/res/drawable/linphone_3_250x130.png new file mode 100644 index 000000000..020e943b6 Binary files /dev/null and b/res/drawable/linphone_3_250x130.png differ diff --git a/res/layout/about.xml b/res/layout/about.xml new file mode 100644 index 000000000..bdb5351a5 --- /dev/null +++ b/res/layout/about.xml @@ -0,0 +1,7 @@ + + + + + diff --git a/res/layout/dialer.xml b/res/layout/dialer.xml index a39483f34..f270162bb 100644 --- a/res/layout/dialer.xml +++ b/res/layout/dialer.xml @@ -11,7 +11,7 @@ android:hint="sip:" android:layout_width="fill_parent" android:lines="1" android:layout_weight="0.2"> + android:layout_width="fill_parent" android:text="<-" android:layout_weight="0.8" android:textSize="20sp" android:textStyle="bold"> @@ -25,41 +25,41 @@ android:layout_weight="1" android:id="@+id/DialerRow01" android:layout_width="fill_parent"> + android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="0.33" android:textStyle="bold" android:textSize="20sp"> + android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="0.33" android:textStyle="bold" android:textSize="20sp"> + android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="0.33" android:textStyle="bold" android:textSize="20sp"> + android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="0.33" android:textStyle="bold" android:textSize="20sp"> + android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="0.33" android:textStyle="bold" android:textSize="20sp"> + android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="0.33" android:textStyle="bold" android:textSize="20sp"> + android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="0.33" android:textStyle="bold" android:textSize="20sp"> + android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="0.33" android:textStyle="bold" android:textSize="20sp"> + android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="0.33" android:textStyle="bold" android:textSize="20sp"> + android:id="@+id/ButtonStar" android:layout_weight="0.33" android:textStyle="bold" android:textSize="20sp"> + android:layout_height="fill_parent" android:text="0+" android:id="@+id/Button00" android:layout_weight="0.33" android:textStyle="bold" android:textSize="20sp"> + android:text="#" android:layout_weight="0.33" android:textStyle="bold" android:textSize="20sp"> diff --git a/res/values/strings.xml b/res/values/strings.xml index a5cc7cbf4..6a5fe0d9a 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -1,5 +1,6 @@ + Linphone 3.1.2 SIP (rfc 3261) Compatible Internet phone \n http://www.linphone.org About Audio Exit @@ -24,4 +25,5 @@ %s, do you want to return to the settings page ? Cannot initiate a new call because a call is already engaged History +Cannot build destination address from [%s] diff --git a/src/org/linphone/AboutActivity.java b/src/org/linphone/AboutActivity.java new file mode 100644 index 000000000..e860ed064 --- /dev/null +++ b/src/org/linphone/AboutActivity.java @@ -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); + } +} diff --git a/src/org/linphone/DialerActivity.java b/src/org/linphone/DialerActivity.java index 759c06e16..5537ba0d3 100644 --- a/src/org/linphone/DialerActivity.java +++ b/src/org/linphone/DialerActivity.java @@ -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) { diff --git a/src/org/linphone/LinphoneActivity.java b/src/org/linphone/LinphoneActivity.java index f649ff749..8b9e8dc12 100644 --- a/src/org/linphone/LinphoneActivity.java +++ b/src/org/linphone/LinphoneActivity.java @@ -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; diff --git a/src/org/linphone/LinphonePreferencesActivity.java b/src/org/linphone/LinphonePreferencesActivity.java index 8c04785cc..2c57729cf 100644 --- a/src/org/linphone/LinphonePreferencesActivity.java +++ b/src/org/linphone/LinphonePreferencesActivity.java @@ -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); } + } } } diff --git a/src/org/linphone/NetworkManager.java b/src/org/linphone/NetworkManager.java index 1f07bad54..e47b6f5ca 100644 --- a/src/org/linphone/NetworkManager.java +++ b/src/org/linphone/NetworkManager.java @@ -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); diff --git a/src/org/linphone/core/LinphoneAddress.java b/src/org/linphone/core/LinphoneAddress.java index 619bd4fb8..86271674c 100644 --- a/src/org/linphone/core/LinphoneAddress.java +++ b/src/org/linphone/core/LinphoneAddress.java @@ -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)} */ diff --git a/src/org/linphone/core/LinphoneAddressImpl.java b/src/org/linphone/core/LinphoneAddressImpl.java index fd80db86e..50036ac7d 100644 --- a/src/org/linphone/core/LinphoneAddressImpl.java +++ b/src/org/linphone/core/LinphoneAddressImpl.java @@ -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); + } } diff --git a/src/org/linphone/core/LinphoneCore.java b/src/org/linphone/core/LinphoneCore.java index 753dfa12f..4245c5518 100644 --- a/src/org/linphone/core/LinphoneCore.java +++ b/src/org/linphone/core/LinphoneCore.java @@ -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; } diff --git a/src/org/linphone/core/LinphoneCoreImpl.java b/src/org/linphone/core/LinphoneCoreImpl.java index eda069112..173d5846c 100644 --- a/src/org/linphone/core/LinphoneCoreImpl.java +++ b/src/org/linphone/core/LinphoneCoreImpl.java @@ -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); + } }