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