diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 8662eeed8..c29c0b4c8 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -13,6 +13,11 @@ + + + + + @@ -24,11 +29,7 @@ - - - - - + @@ -44,7 +45,7 @@ - + @@ -55,6 +56,10 @@ + + + + @@ -64,5 +69,8 @@ + + + \ No newline at end of file diff --git a/libs/armeabi/liblinphone.so b/libs/armeabi/liblinphone.so index a8069cf1b..e62d0a040 100755 Binary files a/libs/armeabi/liblinphone.so and b/libs/armeabi/liblinphone.so differ diff --git a/res/layout/outcall_choser.xml b/res/layout/outcall_choser.xml new file mode 100644 index 000000000..d1c116463 --- /dev/null +++ b/res/layout/outcall_choser.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + diff --git a/res/values/strings.xml b/res/values/strings.xml index 6d624c9f6..d0c3daa10 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -1,5 +1,12 @@ + If set cellular call are redirected to voip when possible + Redirect cellular calls + pref_handle_outcall_key + Start at boot time + pref_autostart_key + Cellular + Choose application to call %s Outbound proxy Outbound proxy pcma diff --git a/res/xml/preferences.xml b/res/xml/preferences.xml index 0f0a597ed..6220a4f1a 100644 --- a/res/xml/preferences.xml +++ b/res/xml/preferences.xml @@ -25,13 +25,15 @@ android:title="@string/pref_codec_pcmu" android:defaultValue="true"> - - + + + diff --git a/src/org/linphone/BootReceiver.java b/src/org/linphone/BootReceiver.java new file mode 100644 index 000000000..36ce67def --- /dev/null +++ b/src/org/linphone/BootReceiver.java @@ -0,0 +1,39 @@ +/* +BootReceiver.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.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; +import android.preference.PreferenceManager; + +public class BootReceiver extends BroadcastReceiver { + + @Override + public void onReceive(Context context, Intent intent) { + + if (PreferenceManager.getDefaultSharedPreferences(context).getBoolean(context.getString(R.string.pref_autostart_key), true)) { + Intent lLinphoneServiceIntent = new Intent(Intent.ACTION_MAIN); + lLinphoneServiceIntent.setClass(context, LinphoneService.class); + context.startService(lLinphoneServiceIntent);; + } + + } + +} diff --git a/src/org/linphone/DialerActivity.java b/src/org/linphone/DialerActivity.java index b42fab66f..71f6dc4b9 100644 --- a/src/org/linphone/DialerActivity.java +++ b/src/org/linphone/DialerActivity.java @@ -115,7 +115,7 @@ public class DialerActivity extends Activity implements LinphoneCoreListener { mPref = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); try { - + mAddress = (TextView) findViewById(R.id.SipUri); mDisplayNameView = (TextView) findViewById(R.id.DisplayNameView); @@ -158,31 +158,7 @@ public class DialerActivity extends Activity implements LinphoneCoreListener { } return; } - if (lLinphoneCore.isIncall()) { - Toast toast = Toast.makeText(DialerActivity.this, getString(R.string.warning_already_incall), Toast.LENGTH_LONG); - toast.show(); - return; - } - 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; - } - lAddress.setDisplayName(mDisplayName); - try { - lLinphoneCore.invite(lAddress); - } catch (LinphoneCoreException e) { - Toast toast = Toast.makeText(DialerActivity.this - ,String.format(getString(R.string.error_cannot_invite_address),mAddress.getText().toString()) - , Toast.LENGTH_LONG); - toast.show(); - return; - } + newOutgoingCall(mAddress.getText().toString(),mDisplayName); } }); @@ -234,6 +210,10 @@ public class DialerActivity extends Activity implements LinphoneCoreListener { mInCallControlRow.setVisibility(View.GONE); mInCallAddressLayout.setVisibility(View.GONE); mDecline.setEnabled(false); + if (LinphoneService.isready() && getIntent().getData() != null) { + newOutgoingCall(getIntent().getData().toString().substring("tel://".length())); + getIntent().setData(null); + } if (LinphoneService.isready()) { LinphoneCore lLinphoenCore = LinphoneService.instance().getLinphoneCore(); if (lLinphoenCore.isIncall()) { @@ -411,9 +391,15 @@ public class DialerActivity extends Activity implements LinphoneCoreListener { if (mPref.getBoolean(PREF_CHECK_CONFIG, false) == false) { builder.create().show(); } + } catch (Exception e ) { Log.e(LinphoneService.TAG,"Cannot get initial config", e); } + if (getIntent().getData() != null) { + newOutgoingCall(getIntent().getData().toString().substring("tel://".length())); + getIntent().setData(null); + } + } else if (state == GeneralState.GSTATE_REG_OK) { //nop } else if (state == GeneralState.GSTATE_CALL_OUT_INVITE) { @@ -502,5 +488,42 @@ public class DialerActivity extends Activity implements LinphoneCoreListener { mDecline.setEnabled(true); routeAudioToSpeaker(); } + public void newOutgoingCall(String aTo) { + newOutgoingCall(aTo,null); + } + public void newOutgoingCall(String aTo, String displayName) { + String lto = aTo; + if (aTo.contains(OutgoingCallReceiver.TAG)) { + lto = aTo.replace(OutgoingCallReceiver.TAG, ""); + } + mAddress.setText(lto); + mDisplayName = displayName; + LinphoneCore lLinphoneCore = LinphoneService.instance().getLinphoneCore(); + if (lLinphoneCore.isIncall()) { + Toast toast = Toast.makeText(DialerActivity.this, getString(R.string.warning_already_incall), Toast.LENGTH_LONG); + toast.show(); + return; + } + LinphoneAddress lAddress; + try { + lAddress = lLinphoneCore.interpretUrl(lto); + } 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; + } + lAddress.setDisplayName(mDisplayName); + try { + lLinphoneCore.invite(lAddress); + } catch (LinphoneCoreException e) { + Toast toast = Toast.makeText(DialerActivity.this + ,String.format(getString(R.string.error_cannot_invite_address),mAddress.getText().toString()) + , Toast.LENGTH_LONG); + toast.show(); + return; + } + } } diff --git a/src/org/linphone/LinphoneActivity.java b/src/org/linphone/LinphoneActivity.java index 918dcf6e4..64adc0aa4 100644 --- a/src/org/linphone/LinphoneActivity.java +++ b/src/org/linphone/LinphoneActivity.java @@ -100,6 +100,7 @@ public class LinphoneActivity extends TabActivity implements SensorEventListener // dialer Intent lDialerIntent = new Intent().setClass(this, DialerActivity.class); + lDialerIntent.setData(getIntent().getData()); // Initialize a TabSpec for each tab and add it to the TabHost spec = lTabHost.newTabSpec("dialer").setIndicator(getString(R.string.tab_dialer), @@ -120,25 +121,15 @@ public class LinphoneActivity extends TabActivity implements SensorEventListener hideScreen(true); } + } @Override protected void onNewIntent(Intent intent) { super.onNewIntent(intent); if (intent.getData() != null) { - //incoming call requested - AlertDialog.Builder builder = new AlertDialog.Builder(this); - builder.setMessage(getString(R.string.place_call_chooser)) - .setCancelable(false) - .setPositiveButton(getString(R.string.yes), new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int id) { - ; - } - }).setNegativeButton(getString(R.string.no), new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int id) { - } - }); - builder.create().show(); + DialerActivity.getDialer().newOutgoingCall(intent.getData().toString().substring("tel://".length())); + intent.setData(null); } } @@ -266,4 +257,6 @@ public class LinphoneActivity extends TabActivity implements SensorEventListener } getWindow().setAttributes(lAttrs); } + + } diff --git a/src/org/linphone/LinphoneService.java b/src/org/linphone/LinphoneService.java index bbd608430..d44a9aac3 100644 --- a/src/org/linphone/LinphoneService.java +++ b/src/org/linphone/LinphoneService.java @@ -43,6 +43,7 @@ import android.app.Service; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; +import android.content.pm.PackageManager; import android.net.ConnectivityManager; import android.net.NetworkInfo; import android.os.Handler; @@ -253,6 +254,7 @@ public class LinphoneService extends Service implements LinphoneCoreListener { boolean lIsDebug = mPref.getBoolean(getString(R.string.pref_debug_key), false); LinphoneCoreFactory.instance().setDebugMode(lIsDebug); + //1 read proxy config from preferences String lUserName = mPref.getString(getString(R.string.pref_username_key), null); if (lUserName == null || lUserName.length()==0) { diff --git a/src/org/linphone/OutgoingCallReceiver.java b/src/org/linphone/OutgoingCallReceiver.java index ab3158760..ff14e8da5 100644 --- a/src/org/linphone/OutgoingCallReceiver.java +++ b/src/org/linphone/OutgoingCallReceiver.java @@ -23,18 +23,36 @@ import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.net.Uri; +import android.preference.PreferenceManager; public class OutgoingCallReceiver extends BroadcastReceiver { - + public static String TAG = ";0000000"; @Override public void onReceive(Context context, Intent intent) { String to = intent.getStringExtra("android.intent.extra.PHONE_NUMBER"); - setResult(Activity.RESULT_OK,null, null); - Intent lIntent = new Intent(); - lIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - lIntent.setClass(context, LinphoneActivity.class); - lIntent.setData(Uri.parse("tel://"+to)); - context.startActivity(lIntent); + if (!to.contains(TAG)) { + if (LinphoneService.isready() && LinphoneService.instance().getLinphoneCore().getDefaultProxyConfig()==null) { + //just return + return; + } + setResult(Activity.RESULT_OK,null, null); + Intent lIntent = new Intent(); + // 1 check config + if (PreferenceManager.getDefaultSharedPreferences(context).getBoolean(context.getString(R.string.pref_handle_outcall_key), false)) { + //start linphone directly + lIntent.setClass(context, LinphoneActivity.class); + } else { + //start activity chooser + lIntent.setAction(Intent.ACTION_CALL); + } + + lIntent.setData(Uri.parse("tel://"+to+TAG)); + lIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + context.startActivity(lIntent); + + } else { + setResult(Activity.RESULT_OK,to.replace(TAG, ""),null); + } } } diff --git a/submodules/linphone b/submodules/linphone index a17cdb896..d1f0a3ceb 160000 --- a/submodules/linphone +++ b/submodules/linphone @@ -1 +1 @@ -Subproject commit a17cdb896f3df16b9715ab1a0bc57992857dfa24 +Subproject commit d1f0a3cebe43f779e486825fe200c4e51940bfb2