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) if (intent.getStringExtra("msgShared") != null)
displayChat(null, intent.getStringExtra("msgShared")); displayChat(null, intent.getStringExtra("msgShared"));
doNotGoToCallActivity = false; doNotGoToCallActivity = false;
isOnBackground = 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 @Override
@ -1430,8 +1438,6 @@ 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) {
@ -1449,9 +1455,9 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick
doNotGoToCallActivity = true; doNotGoToCallActivity = true;
changeCurrentFragment(FragmentsAvailable.HISTORY_LIST, null); changeCurrentFragment(FragmentsAvailable.HISTORY_LIST, null);
} else if (extras != null && extras.getBoolean("GoToInapp", false)) { } else if (extras != null && extras.getBoolean("GoToInapp", false)) {
LinphoneService.instance().removeMessageNotification(); LinphoneService.instance().removeMessageNotification();
doNotGoToCallActivity = true; doNotGoToCallActivity = true;
displayInapp(); displayInapp();
} else if (extras != null && extras.getBoolean("Notification", false)) { } else if (extras != null && extras.getBoolean("Notification", false)) {
if (LinphoneManager.getLc().getCallsNb() > 0) { if (LinphoneManager.getLc().getCallsNb() > 0) {
LinphoneCall call = LinphoneManager.getLc().getCalls()[0]; LinphoneCall call = LinphoneManager.getLc().getCalls()[0];

View file

@ -28,6 +28,7 @@ import org.linphone.tutorials.TutorialLauncherActivity;
import android.app.Activity; import android.app.Activity;
import android.content.Intent; import android.content.Intent;
import android.content.pm.ActivityInfo; import android.content.pm.ActivityInfo;
import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
@ -43,6 +44,7 @@ public class LinphoneLauncherActivity extends Activity {
private Handler mHandler; private Handler mHandler;
private ServiceWaitThread mServiceThread; private ServiceWaitThread mServiceThread;
private String addressToCall; private String addressToCall;
private Uri uriToResolve;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
@ -56,16 +58,6 @@ public class LinphoneLauncherActivity extends Activity {
mHandler = new Handler(); 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(); Intent intent = getIntent();
if (intent != null) { if (intent != null) {
String action = intent.getAction(); String action = intent.getAction();
@ -78,8 +70,23 @@ public class LinphoneLauncherActivity extends Activity {
addressToCall = addressToCall.substring("sip:".length()); 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() { 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) { if (addressToCall != null) {
newIntent.putExtra("SipUriOrNumber", addressToCall); newIntent.putExtra("SipUriOrNumber", addressToCall);
Log.i("Intent has address to call : " + addressToCall); Log.i("Intent has address to call : " + addressToCall);