Fixed direct call from address book

This commit is contained in:
Sylvain Berfini 2017-07-07 16:10:03 +02:00
parent 04887af28e
commit 7832bc03d9
3 changed files with 41 additions and 2 deletions

View file

@ -169,6 +169,15 @@ public class DialerFragment extends Fragment {
shouldEmptyAddressField = true; shouldEmptyAddressField = true;
} }
resetLayout(isCallTransferOngoing); resetLayout(isCallTransferOngoing);
String addressWaitingToBeCalled = LinphoneActivity.instance().mAddressWaitingToBeCalled;
if (addressWaitingToBeCalled != null) {
mAddress.setText(addressWaitingToBeCalled);
if (getResources().getBoolean(R.bool.automatically_start_intercepted_outgoing_gsm_call)) {
newOutgoingCall(addressWaitingToBeCalled);
}
LinphoneActivity.instance().mAddressWaitingToBeCalled = null;
}
} }
public void resetLayout(boolean callTransfer) { public void resetLayout(boolean callTransfer) {

View file

@ -141,6 +141,8 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick
private boolean callTransfer = false; private boolean callTransfer = false;
private boolean isOnBackground = false; private boolean isOnBackground = false;
public String mAddressWaitingToBeCalled;
static final boolean isInstanciated() { static final boolean isInstanciated() {
return instance != null; return instance != null;
} }
@ -1428,6 +1430,8 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick
@Override @Override
protected void onNewIntent(Intent intent) { protected void onNewIntent(Intent intent) {
super.onNewIntent(intent); super.onNewIntent(intent);
if (getCurrentFragment() == FragmentsAvailable.SETTINGS) { if (getCurrentFragment() == FragmentsAvailable.SETTINGS) {
if (fragment instanceof SettingsFragment) { if (fragment instanceof SettingsFragment) {
@ -1465,6 +1469,11 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick
} else { } else {
((DialerFragment) dialerFragment).newOutgoingCall(intent); ((DialerFragment) dialerFragment).newOutgoingCall(intent);
} }
} else {
if (extras != null && extras.containsKey("SipUriOrNumber")) {
mAddressWaitingToBeCalled = extras.getString("SipUriOrNumber");
goToDialerFragment();
}
} }
if (LinphoneManager.getLc().getCalls().length > 0) { if (LinphoneManager.getLc().getCalls().length > 0) {
// If a call is ringing, start incomingcallactivity // If a call is ringing, start incomingcallactivity

View file

@ -21,6 +21,7 @@ package org.linphone;
import static android.content.Intent.ACTION_MAIN; import static android.content.Intent.ACTION_MAIN;
import org.linphone.assistant.RemoteProvisioningActivity; import org.linphone.assistant.RemoteProvisioningActivity;
import org.linphone.mediastream.Log;
import org.linphone.mediastream.Version; import org.linphone.mediastream.Version;
import org.linphone.tutorials.TutorialLauncherActivity; import org.linphone.tutorials.TutorialLauncherActivity;
@ -41,13 +42,14 @@ public class LinphoneLauncherActivity extends Activity {
private Handler mHandler; private Handler mHandler;
private ServiceWaitThread mServiceThread; private ServiceWaitThread mServiceThread;
private String addressToCall;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
// Hack to avoid to draw twice LinphoneActivity on tablets // Hack to avoid to draw twice LinphoneActivity on tablets
if (getResources().getBoolean(R.bool.orientation_portrait_only)) { if (getResources().getBoolean(R.bool.orientation_portrait_only)) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
} }
setContentView(R.layout.launch_screen); setContentView(R.layout.launch_screen);
@ -55,7 +57,6 @@ public class LinphoneLauncherActivity extends Activity {
mHandler = new Handler(); mHandler = new Handler();
if (LinphoneService.isReady()) { if (LinphoneService.isReady()) {
onServiceReady(); onServiceReady();
} else { } else {
@ -64,6 +65,21 @@ public class LinphoneLauncherActivity extends Activity {
mServiceThread = new ServiceWaitThread(); mServiceThread = new ServiceWaitThread();
mServiceThread.start(); mServiceThread.start();
} }
Intent intent = getIntent();
if (intent != null) {
String action = intent.getAction();
if (Intent.ACTION_CALL.equals(action)) {
if (intent.getData() != null) {
addressToCall = intent.getData().toString();
addressToCall = addressToCall.replace("%40", "@");
addressToCall = addressToCall.replace("%3A", ":");
if (addressToCall.startsWith("sip:")) {
addressToCall = addressToCall.substring("sip:".length());
}
}
}
}
} }
protected void onServiceReady() { protected void onServiceReady() {
@ -98,6 +114,11 @@ public class LinphoneLauncherActivity extends Activity {
} }
} }
} }
if (addressToCall != null) {
newIntent.putExtra("SipUriOrNumber", addressToCall);
Log.i("Intent has address to call : " + addressToCall);
addressToCall = null;
}
startActivity(newIntent); startActivity(newIntent);
if (classToStart == LinphoneActivity.class && LinphoneActivity.isInstanciated() && msgShared != null) { if (classToStart == LinphoneActivity.class && LinphoneActivity.isInstanciated() && msgShared != null) {
LinphoneActivity.instance().displayChat(null, msgShared); LinphoneActivity.instance().displayChat(null, msgShared);