Fixed call from contacts on Samsung

This commit is contained in:
Sylvain Berfini 2017-07-17 11:12:03 +02:00
parent 1d661e7048
commit 8320b11825
2 changed files with 34 additions and 16 deletions

View file

@ -1396,9 +1396,17 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick
if (intent.getStringExtra("msgShared") != null)
displayChat(null, intent.getStringExtra("msgShared"));
doNotGoToCallActivity = false;
isOnBackground = false;
if (intent != null) {
Bundle extras = intent.getExtras();
if (extras != null && extras.containsKey("SipUriOrNumber")) {
mAddressWaitingToBeCalled = extras.getString("SipUriOrNumber");
intent.removeExtra("SipUriOrNumber");
goToDialerFragment();
}
}
}
@Override
@ -1430,8 +1438,6 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
if (getCurrentFragment() == FragmentsAvailable.SETTINGS) {
if (fragment instanceof SettingsFragment) {
@ -1449,9 +1455,9 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick
doNotGoToCallActivity = true;
changeCurrentFragment(FragmentsAvailable.HISTORY_LIST, null);
} else if (extras != null && extras.getBoolean("GoToInapp", false)) {
LinphoneService.instance().removeMessageNotification();
doNotGoToCallActivity = true;
displayInapp();
LinphoneService.instance().removeMessageNotification();
doNotGoToCallActivity = true;
displayInapp();
} else if (extras != null && extras.getBoolean("Notification", false)) {
if (LinphoneManager.getLc().getCallsNb() > 0) {
LinphoneCall call = LinphoneManager.getLc().getCalls()[0];

View file

@ -28,6 +28,7 @@ import org.linphone.tutorials.TutorialLauncherActivity;
import android.app.Activity;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
@ -43,6 +44,7 @@ public class LinphoneLauncherActivity extends Activity {
private Handler mHandler;
private ServiceWaitThread mServiceThread;
private String addressToCall;
private Uri uriToResolve;
@Override
protected void onCreate(Bundle savedInstanceState) {
@ -56,16 +58,6 @@ public class LinphoneLauncherActivity extends Activity {
mHandler = new Handler();
if (LinphoneService.isReady()) {
onServiceReady();
} else {
// start linphone as background
startService(new Intent(ACTION_MAIN).setClass(this, LinphoneService.class));
mServiceThread = new ServiceWaitThread();
mServiceThread.start();
}
Intent intent = getIntent();
if (intent != null) {
String action = intent.getAction();
@ -78,8 +70,23 @@ public class LinphoneLauncherActivity extends Activity {
addressToCall = addressToCall.substring("sip:".length());
}
}
} else if (Intent.ACTION_VIEW.equals(action)) {
if (LinphoneService.isReady()) {
addressToCall = ContactsManager.getInstance().getAddressOrNumberForAndroidContact(getContentResolver(), intent.getData());
} else {
uriToResolve = intent.getData();
}
}
}
if (LinphoneService.isReady()) {
onServiceReady();
} else {
// start linphone as background
startService(new Intent(ACTION_MAIN).setClass(this, LinphoneService.class));
mServiceThread = new ServiceWaitThread();
mServiceThread.start();
}
}
protected void onServiceReady() {
@ -114,6 +121,11 @@ public class LinphoneLauncherActivity extends Activity {
}
}
}
if (uriToResolve != null) {
addressToCall = ContactsManager.getInstance().getAddressOrNumberForAndroidContact(getContentResolver(), uriToResolve);
Log.i("Intent has uri to resolve : " + uriToResolve.toString());
uriToResolve = null;
}
if (addressToCall != null) {
newIntent.putExtra("SipUriOrNumber", addressToCall);
Log.i("Intent has address to call : " + addressToCall);