Skip to content
Snippets Groups Projects
Commit 47a72044 authored by Alexandre Lision's avatar Alexandre Lision
Browse files

Incoming calls now displayed event if SFLphone is not in the foreground

parent 59daaafd
No related branches found
No related tags found
No related merge requests found
...@@ -78,35 +78,33 @@ import android.view.WindowManager; ...@@ -78,35 +78,33 @@ import android.view.WindowManager;
public class CallActivity extends Activity implements CallInterface, IMFragment.Callbacks, CallFragment.Callbacks, ProximityDirector { public class CallActivity extends Activity implements CallInterface, IMFragment.Callbacks, CallFragment.Callbacks, ProximityDirector {
static final String TAG = "CallActivity"; static final String TAG = "CallActivity";
private ISipService service; private ISipService mService;
CallReceiver receiver; CallReceiver mReceiver;
CallPaneLayout slidingPaneLayout; CallPaneLayout mSlidingPaneLayout;
IMFragment mIMFragment; IMFragment mIMFragment;
CallFragment mCurrentCallFragment; CallFragment mCurrentCallFragment;
// private boolean fragIsChanging;
/* result code sent in case of call failure */ /* result code sent in case of call failure */
public static int RESULT_FAILURE = -10; public static int RESULT_FAILURE = -10;
private CallProximityManager mProximityManager;
private CallProximityManager proximityManager;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_call_layout); setContentView(R.layout.activity_call_layout);
receiver = new CallReceiver(this); mReceiver = new CallReceiver(this);
proximityManager = new CallProximityManager(this, this); mProximityManager = new CallProximityManager(this, this);
slidingPaneLayout = (CallPaneLayout) findViewById(R.id.slidingpanelayout); mSlidingPaneLayout = (CallPaneLayout) findViewById(R.id.slidingpanelayout);
slidingPaneLayout.setParallaxDistance(500); mSlidingPaneLayout.setParallaxDistance(500);
slidingPaneLayout.setSliderFadeColor(Color.TRANSPARENT); mSlidingPaneLayout.setSliderFadeColor(Color.TRANSPARENT);
slidingPaneLayout.setPanelSlideListener(new SlidingPaneLayout.PanelSlideListener() { mSlidingPaneLayout.setPanelSlideListener(new SlidingPaneLayout.PanelSlideListener() {
@Override @Override
public void onPanelSlide(View view, float offSet) { public void onPanelSlide(View view, float offSet) {
...@@ -124,7 +122,7 @@ public class CallActivity extends Activity implements CallInterface, IMFragment. ...@@ -124,7 +122,7 @@ public class CallActivity extends Activity implements CallInterface, IMFragment.
} }
}); });
proximityManager.startTracking(); mProximityManager.startTracking();
Intent intent = new Intent(this, SipService.class); Intent intent = new Intent(this, SipService.class);
bindService(intent, mConnection, Context.BIND_AUTO_CREATE); bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
} }
...@@ -141,7 +139,7 @@ public class CallActivity extends Activity implements CallInterface, IMFragment. ...@@ -141,7 +139,7 @@ public class CallActivity extends Activity implements CallInterface, IMFragment.
intentFilter.addAction(CallManagerCallBack.CONF_REMOVED); intentFilter.addAction(CallManagerCallBack.CONF_REMOVED);
intentFilter.addAction(CallManagerCallBack.CONF_CHANGED); intentFilter.addAction(CallManagerCallBack.CONF_CHANGED);
intentFilter.addAction(CallManagerCallBack.RECORD_STATE_CHANGED); intentFilter.addAction(CallManagerCallBack.RECORD_STATE_CHANGED);
registerReceiver(receiver, intentFilter); registerReceiver(mReceiver, intentFilter);
super.onResume(); super.onResume();
} }
...@@ -184,10 +182,10 @@ public class CallActivity extends Activity implements CallInterface, IMFragment. ...@@ -184,10 +182,10 @@ public class CallActivity extends Activity implements CallInterface, IMFragment.
@Override @Override
protected void onDestroy() { protected void onDestroy() {
unregisterReceiver(receiver); unregisterReceiver(mReceiver);
unbindService(mConnection); unbindService(mConnection);
proximityManager.stopTracking(); mProximityManager.stopTracking();
proximityManager.release(0); mProximityManager.release(0);
super.onDestroy(); super.onDestroy();
} }
...@@ -195,7 +193,7 @@ public class CallActivity extends Activity implements CallInterface, IMFragment. ...@@ -195,7 +193,7 @@ public class CallActivity extends Activity implements CallInterface, IMFragment.
private ServiceConnection mConnection = new ServiceConnection() { private ServiceConnection mConnection = new ServiceConnection() {
@Override @Override
public void onServiceConnected(ComponentName className, IBinder binder) { public void onServiceConnected(ComponentName className, IBinder binder) {
service = ISipService.Stub.asInterface(binder); mService = ISipService.Stub.asInterface(binder);
mCurrentCallFragment = new CallFragment(); mCurrentCallFragment = new CallFragment();
mIMFragment = new IMFragment(); mIMFragment = new IMFragment();
...@@ -204,11 +202,11 @@ public class CallActivity extends Activity implements CallInterface, IMFragment. ...@@ -204,11 +202,11 @@ public class CallActivity extends Activity implements CallInterface, IMFragment.
if (u != null) { if (u != null) {
CallContact c = CallContact.ContactBuilder.buildUnknownContact(u.getSchemeSpecificPart()); CallContact c = CallContact.ContactBuilder.buildUnknownContact(u.getSchemeSpecificPart());
try { try {
service.destroyNotification(); mService.destroyNotification();
String accountID = (String) service.getAccountList().get(1); // We use the first account to place outgoing calls String accountID = (String) mService.getAccountList().get(1); // We use the first account to place outgoing calls
HashMap<String, String> details = (HashMap<String, String>) service.getAccountDetails(accountID); HashMap<String, String> details = (HashMap<String, String>) mService.getAccountDetails(accountID);
ArrayList<HashMap<String, String>> credentials = (ArrayList<HashMap<String, String>>) service.getCredentials(accountID); ArrayList<HashMap<String, String>> credentials = (ArrayList<HashMap<String, String>>) mService.getCredentials(accountID);
Account acc = new Account(accountID, details, credentials); Account acc = new Account(accountID, details, credentials);
SipCall call = SipCall.SipCallBuilder.getInstance().startCallCreation().setContact(c).setAccount(acc) SipCall call = SipCall.SipCallBuilder.getInstance().startCallCreation().setContact(c).setAccount(acc)
...@@ -245,7 +243,7 @@ public class CallActivity extends Activity implements CallInterface, IMFragment. ...@@ -245,7 +243,7 @@ public class CallActivity extends Activity implements CallInterface, IMFragment.
} }
slidingPaneLayout.setCurFragment(mCurrentCallFragment); mSlidingPaneLayout.setCurFragment(mCurrentCallFragment);
getIntent().getExtras(); getIntent().getExtras();
// mCallsFragment.update(); // mCallsFragment.update();
getFragmentManager().beginTransaction().replace(R.id.ongoingcall_pane, mCurrentCallFragment).commit(); getFragmentManager().beginTransaction().replace(R.id.ongoingcall_pane, mCurrentCallFragment).commit();
...@@ -267,7 +265,7 @@ public class CallActivity extends Activity implements CallInterface, IMFragment. ...@@ -267,7 +265,7 @@ public class CallActivity extends Activity implements CallInterface, IMFragment.
mCurrentCallFragment = new CallFragment(); mCurrentCallFragment = new CallFragment();
mCurrentCallFragment.setArguments(b); mCurrentCallFragment.setArguments(b);
getFragmentManager().beginTransaction().replace(R.id.ongoingcall_pane, mCurrentCallFragment).commit(); getFragmentManager().beginTransaction().replace(R.id.ongoingcall_pane, mCurrentCallFragment).commit();
slidingPaneLayout.setCurFragment(mCurrentCallFragment); mSlidingPaneLayout.setCurFragment(mCurrentCallFragment);
} }
...@@ -279,27 +277,11 @@ public class CallActivity extends Activity implements CallInterface, IMFragment. ...@@ -279,27 +277,11 @@ public class CallActivity extends Activity implements CallInterface, IMFragment.
} }
@SuppressWarnings("unchecked")
// No proper solution with HashMap runtime cast
public void processCallStateChangedSignal(String callID, String newState) { public void processCallStateChangedSignal(String callID, String newState) {
if (mCurrentCallFragment != null) { if (mCurrentCallFragment != null) {
mCurrentCallFragment.changeCallState(callID, newState); mCurrentCallFragment.changeCallState(callID, newState);
} }
mProximityManager.updateProximitySensorMode();
proximityManager.updateProximitySensorMode();
try {
HashMap<String, SipCall> callMap = (HashMap<String, SipCall>) service.getCallList();
HashMap<String, Conference> confMap = (HashMap<String, Conference>) service.getConferenceList();
} catch (RemoteException e) {
Log.e(TAG, e.toString());
}
Log.w(TAG, "processCallStateChangedSignal " + newState);
} }
@Override @Override
...@@ -315,7 +297,7 @@ public class CallActivity extends Activity implements CallInterface, IMFragment. ...@@ -315,7 +297,7 @@ public class CallActivity extends Activity implements CallInterface, IMFragment.
@Override @Override
public ISipService getService() { public ISipService getService() {
return service; return mService;
} }
@Override @Override
...@@ -367,7 +349,7 @@ public class CallActivity extends Activity implements CallInterface, IMFragment. ...@@ -367,7 +349,7 @@ public class CallActivity extends Activity implements CallInterface, IMFragment.
public boolean sendIM(SipMessage msg) { public boolean sendIM(SipMessage msg) {
try { try {
service.sendTextMessage(mCurrentCallFragment.getConference().getId(), msg); mService.sendTextMessage(mCurrentCallFragment.getConference().getId(), msg);
} catch (RemoteException e) { } catch (RemoteException e) {
e.printStackTrace(); e.printStackTrace();
return false; return false;
...@@ -384,9 +366,9 @@ public class CallActivity extends Activity implements CallInterface, IMFragment. ...@@ -384,9 +366,9 @@ public class CallActivity extends Activity implements CallInterface, IMFragment.
public void onCallSuspended() { public void onCallSuspended() {
try { try {
if (mCurrentCallFragment.getConference().hasMultipleParticipants()) { if (mCurrentCallFragment.getConference().hasMultipleParticipants()) {
service.holdConference(mCurrentCallFragment.getConference().getId()); mService.holdConference(mCurrentCallFragment.getConference().getId());
} else { } else {
service.hold(mCurrentCallFragment.getConference().getParticipants().get(0).getCallId()); mService.hold(mCurrentCallFragment.getConference().getParticipants().get(0).getCallId());
} }
} catch (RemoteException e) { } catch (RemoteException e) {
e.printStackTrace(); e.printStackTrace();
...@@ -396,11 +378,11 @@ public class CallActivity extends Activity implements CallInterface, IMFragment. ...@@ -396,11 +378,11 @@ public class CallActivity extends Activity implements CallInterface, IMFragment.
@Override @Override
public void slideChatScreen() { public void slideChatScreen() {
if (slidingPaneLayout.isOpen()) { if (mSlidingPaneLayout.isOpen()) {
slidingPaneLayout.closePane(); mSlidingPaneLayout.closePane();
} else { } else {
mCurrentCallFragment.getBubbleView().stopThread(); mCurrentCallFragment.getBubbleView().stopThread();
slidingPaneLayout.openPane(); mSlidingPaneLayout.openPane();
} }
} }
......
...@@ -5,6 +5,7 @@ import java.util.HashMap; ...@@ -5,6 +5,7 @@ import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map.Entry; import java.util.Map.Entry;
import org.sflphone.client.CallActivity;
import org.sflphone.model.Account; import org.sflphone.model.Account;
import org.sflphone.model.CallContact; import org.sflphone.model.CallContact;
import org.sflphone.model.Conference; import org.sflphone.model.Conference;
...@@ -21,7 +22,6 @@ import android.content.Context; ...@@ -21,7 +22,6 @@ import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.os.RemoteException; import android.os.RemoteException;
import android.os.SystemClock;
import android.util.Log; import android.util.Log;
public class IncomingReceiver extends BroadcastReceiver { public class IncomingReceiver extends BroadcastReceiver {
...@@ -80,19 +80,25 @@ public class IncomingReceiver extends BroadcastReceiver { ...@@ -80,19 +80,25 @@ public class IncomingReceiver extends BroadcastReceiver {
callBuilder.setContact(CallContact.ContactBuilder.buildUnknownContact(b.getString("From"))); callBuilder.setContact(CallContact.ContactBuilder.buildUnknownContact(b.getString("From")));
Intent toSend = new Intent(CallManagerCallBack.INCOMING_CALL); Intent toSend = new Intent(CallManagerCallBack.INCOMING_CALL);
toSend.setClass(callback, CallActivity.class);
toSend.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
SipCall newCall = callBuilder.build(); SipCall newCall = callBuilder.build();
toSend.putExtra("newcall", newCall); toSend.putExtra("newcall", newCall);
HashMap<String, String> callDetails = (HashMap<String, String>) mBinder.getCallDetails(b.getString("CallID")); HashMap<String, String> callDetails = (HashMap<String, String>) mBinder.getCallDetails(b.getString("CallID"));
String stamp = callDetails.get(ServiceConstants.call.TIMESTAMP_START); newCall.setTimestamp_start(Long.parseLong(callDetails.get(ServiceConstants.call.TIMESTAMP_START)));
if(stamp.length() > 0)
newCall.setTimestamp_start(Long.parseLong(stamp));
else
newCall.setTimestamp_start(System.currentTimeMillis() / 1000);
callback.getCurrent_calls().put(newCall.getCallId(), newCall); callback.getCurrent_calls().put(newCall.getCallId(), newCall);
callback.sendBroadcast(toSend); // callback.sendBroadcast(toSend);
Bundle bundle = new Bundle();
Conference tmp = new Conference("-1");
tmp.getParticipants().add(newCall);
bundle.putParcelable("conference", tmp);
toSend.putExtra("resuming", false);
toSend.putExtras(bundle);
callback.startActivity(toSend);
callback.mediaManager.obtainAudioFocus(true); callback.mediaManager.obtainAudioFocus(true);
} catch (RemoteException e1) { } catch (RemoteException e1) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment