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;
}
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) {

View file

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

View file

@ -21,6 +21,7 @@ package org.linphone;
import static android.content.Intent.ACTION_MAIN;
import org.linphone.assistant.RemoteProvisioningActivity;
import org.linphone.mediastream.Log;
import org.linphone.mediastream.Version;
import org.linphone.tutorials.TutorialLauncherActivity;
@ -41,6 +42,7 @@ public class LinphoneLauncherActivity extends Activity {
private Handler mHandler;
private ServiceWaitThread mServiceThread;
private String addressToCall;
@Override
protected void onCreate(Bundle savedInstanceState) {
@ -55,7 +57,6 @@ public class LinphoneLauncherActivity extends Activity {
mHandler = new Handler();
if (LinphoneService.isReady()) {
onServiceReady();
} else {
@ -64,6 +65,21 @@ public class LinphoneLauncherActivity extends Activity {
mServiceThread = new ServiceWaitThread();
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() {
@ -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);
if (classToStart == LinphoneActivity.class && LinphoneActivity.isInstanciated() && msgShared != null) {
LinphoneActivity.instance().displayChat(null, msgShared);