diff --git a/src/org/sflphone/account/TLSManager.java b/src/org/sflphone/account/TLSManager.java index 63d3c03acca34d55e94df757914ed89793c14ce4..14c0abf2bc5c6e14b50257dd83a761543a942fcf 100644 --- a/src/org/sflphone/account/TLSManager.java +++ b/src/org/sflphone/account/TLSManager.java @@ -214,7 +214,5 @@ public class TLSManager { checkForRSAKey(myFile.getAbsolutePath()); break; } - - } } \ No newline at end of file diff --git a/src/org/sflphone/client/CallActivity.java b/src/org/sflphone/client/CallActivity.java index abf14503087d3fce34148dc20643a205fcc7ec98..367f8cd23df33e87c1284e5dfc1bdd3a3e8ffc03 100644 --- a/src/org/sflphone/client/CallActivity.java +++ b/src/org/sflphone/client/CallActivity.java @@ -89,15 +89,39 @@ public class CallActivity extends FragmentActivity implements IMFragment.Callbac super.onCreate(savedInstanceState); setContentView(R.layout.activity_call_layout); + Window w = getWindow(); + w.setFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED, WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED); + + setUpSlidingPanel(); + mProximityManager = new CallProximityManager(this, this); + mProximityManager.startTracking(); + + mCurrentCallFragment = new CallFragment(); + mIMFragment = new IMFragment(); + if(!checkExternalCall()) { + mDisplayedConference = getIntent().getParcelableExtra("conference"); + Bundle IMBundle = new Bundle(); + if (getIntent().getBooleanExtra("resuming", false)) { + IMBundle.putParcelableArrayList("messages", mDisplayedConference.getMessages()); + mIMFragment.setArguments(IMBundle); + } else { + IMBundle.putParcelableArrayList("messages", new ArrayList<SipMessage>()); + mIMFragment.setArguments(IMBundle); + } + } + + mSlidingPaneLayout.setCurFragment(mCurrentCallFragment); + getSupportFragmentManager().beginTransaction().replace(R.id.ongoingcall_pane, mCurrentCallFragment) + .replace(R.id.message_list_frame, mIMFragment).commit(); + } + + private void setUpSlidingPanel() { mSlidingPaneLayout = (CallPaneLayout) findViewById(R.id.slidingpanelayout); mSlidingPaneLayout.setParallaxDistance(500); mSlidingPaneLayout.setSliderFadeColor(Color.TRANSPARENT); - Window w = getWindow(); - w.setFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED, WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED); - mSlidingPaneLayout.setPanelSlideListener(new SlidingPaneLayout.PanelSlideListener() { @Override @@ -115,8 +139,10 @@ public class CallActivity extends FragmentActivity implements IMFragment.Callbac getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING); } }); + } - mProximityManager.startTracking(); + @Override + public void onFragmentCreated() { Intent intent = new Intent(this, SipService.class); bindService(intent, mConnection, Context.BIND_AUTO_CREATE); } @@ -175,54 +201,13 @@ public class CallActivity extends FragmentActivity implements IMFragment.Callbac public void onServiceConnected(ComponentName className, IBinder binder) { mService = ISipService.Stub.asInterface(binder); - mCurrentCallFragment = new CallFragment(); - mIMFragment = new IMFragment(); - - Uri u = getIntent().getData(); - if (u != null) { - CallContact c = CallContact.ContactBuilder.buildUnknownContact(u.getSchemeSpecificPart()); + if (mDisplayedConference.getState().contentEquals("NONE")) { try { - 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); - - Bundle args = new Bundle(); - args.putString(SipCall.ID, Integer.toString(Math.abs(new Random().nextInt()))); - args.putParcelable(SipCall.ACCOUNT, acc); - args.putInt(SipCall.STATE, SipCall.state.CALL_STATE_RINGING); - args.putInt(SipCall.TYPE, SipCall.direction.CALL_TYPE_OUTGOING); - args.putParcelable(SipCall.CONTACT, c); - - mDisplayedConference = new Conference(Conference.DEFAULT_ID); - mDisplayedConference.getParticipants().add(new SipCall(args)); + mService.placeCall(mDisplayedConference.getParticipants().get(0)); } catch (RemoteException e) { e.printStackTrace(); - } catch (Exception e) { - e.printStackTrace(); - } - } else { - mDisplayedConference = getIntent().getParcelableExtra("conference"); - if (getIntent().getBooleanExtra("resuming", false)) { - Bundle IMBundle = new Bundle(); - IMBundle.putParcelableArrayList("messages", mDisplayedConference.getMessages()); - mIMFragment.setArguments(IMBundle); - } else { - Bundle IMBundle = new Bundle(); - try { - mService.placeCall(mDisplayedConference.getParticipants().get(0)); - } catch (RemoteException e) { - e.printStackTrace(); - } - IMBundle.putParcelableArrayList("messages", new ArrayList<SipMessage>()); - mIMFragment.setArguments(IMBundle); } } - - mSlidingPaneLayout.setCurFragment(mCurrentCallFragment); - getSupportFragmentManager().beginTransaction().replace(R.id.ongoingcall_pane, mCurrentCallFragment) - .replace(R.id.message_list_frame, mIMFragment).commit(); - } @Override @@ -230,6 +215,34 @@ public class CallActivity extends FragmentActivity implements IMFragment.Callbac } }; + private boolean checkExternalCall() { + Uri u = getIntent().getData(); + if (u != null) { + CallContact c = CallContact.ContactBuilder.buildUnknownContact(u.getSchemeSpecificPart()); + try { + 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); + + Bundle args = new Bundle(); + args.putString(SipCall.ID, Integer.toString(Math.abs(new Random().nextInt()))); + args.putParcelable(SipCall.ACCOUNT, acc); + args.putInt(SipCall.STATE, SipCall.state.CALL_STATE_NONE); + args.putInt(SipCall.TYPE, SipCall.direction.CALL_TYPE_OUTGOING); + args.putParcelable(SipCall.CONTACT, c); + + mDisplayedConference = new Conference(Conference.DEFAULT_ID); + mDisplayedConference.getParticipants().add(new SipCall(args)); + } catch (RemoteException e) { + e.printStackTrace(); + } catch (Exception e) { + e.printStackTrace(); + } + return true; + } + return false; + } @Override public ISipService getService() { @@ -265,12 +278,6 @@ public class CallActivity extends FragmentActivity implements IMFragment.Callbac @Override public void run() { - /*try { - // We hang it up again to avoid infinite failure tone - mService.hangUp(mDisplayedConference.getId()); - } catch (RemoteException e) { - e.printStackTrace(); - }*/ finish(); } }; diff --git a/src/org/sflphone/client/HomeActivity.java b/src/org/sflphone/client/HomeActivity.java index efd1c9d7544e4bf8d91d381b1f8876892418e115..8ccf66972e43ed9b93ae391e9c2ec1ad14082ed0 100644 --- a/src/org/sflphone/client/HomeActivity.java +++ b/src/org/sflphone/client/HomeActivity.java @@ -463,7 +463,7 @@ public class HomeActivity extends FragmentActivity implements DialingFragment.Ca Bundle args = new Bundle(); args.putString(SipCall.ID, Integer.toString(Math.abs(new Random().nextInt()))); args.putParcelable(SipCall.ACCOUNT, fMenu.getSelectedAccount()); - args.putInt(SipCall.STATE, SipCall.state.CALL_STATE_RINGING); + args.putInt(SipCall.STATE, SipCall.state.CALL_STATE_NONE); args.putInt(SipCall.TYPE, SipCall.direction.CALL_TYPE_OUTGOING); Cursor cPhones = getContentResolver().query(Phone.CONTENT_URI, CONTACTS_PHONES_PROJECTION, Phone.CONTACT_ID + " =" + c.getId(), @@ -506,7 +506,7 @@ public class HomeActivity extends FragmentActivity implements DialingFragment.Ca Bundle args = new Bundle(); args.putString(SipCall.ID, Integer.toString(Math.abs(new Random().nextInt()))); args.putParcelable(SipCall.ACCOUNT, usedAccount); - args.putInt(SipCall.STATE, SipCall.state.CALL_STATE_RINGING); + args.putInt(SipCall.STATE, SipCall.state.CALL_STATE_NONE); args.putInt(SipCall.TYPE, SipCall.direction.CALL_TYPE_OUTGOING); args.putParcelable(SipCall.CONTACT, to.getContact()); @@ -533,7 +533,7 @@ public class HomeActivity extends FragmentActivity implements DialingFragment.Ca Bundle args = new Bundle(); args.putString(SipCall.ID, Integer.toString(Math.abs(new Random().nextInt()))); args.putParcelable(SipCall.ACCOUNT, usedAccount); - args.putInt(SipCall.STATE, SipCall.state.CALL_STATE_RINGING); + args.putInt(SipCall.STATE, SipCall.state.CALL_STATE_NONE); args.putInt(SipCall.TYPE, SipCall.direction.CALL_TYPE_OUTGOING); args.putParcelable(SipCall.CONTACT, CallContact.ContactBuilder.buildUnknownContact(to)); diff --git a/src/org/sflphone/fragments/CallFragment.java b/src/org/sflphone/fragments/CallFragment.java index 8e9c51147b86c2234268bf747cb2bda9856c1f7d..e339894892c26cfdd8cad678a3b10b1cfcee0690 100644 --- a/src/org/sflphone/fragments/CallFragment.java +++ b/src/org/sflphone/fragments/CallFragment.java @@ -112,6 +112,8 @@ public class CallFragment extends CallableWrapperFragment implements CallInterfa if (mScreenWakeLock != null && !mScreenWakeLock.isHeld()) { mScreenWakeLock.acquire(); } + + mCallbacks.onFragmentCreated(); } private void initializeWiFiListener() { @@ -134,6 +136,11 @@ public class CallFragment extends CallableWrapperFragment implements CallInterfa */ private static Callbacks sDummyCallbacks = new Callbacks() { + @Override + public void onFragmentCreated() { + + } + @Override public ISipService getService() { return null; @@ -167,6 +174,8 @@ public class CallFragment extends CallableWrapperFragment implements CallInterfa */ public interface Callbacks { + public void onFragmentCreated(); + public ISipService getService(); public void startTimer(); @@ -398,7 +407,7 @@ public class CallFragment extends CallableWrapperFragment implements CallInterfa private void updateSecurityDisplay() { - //First we check if at least one participan use a security layer. + //First we check if at least one participant use a security layer. if (!getConference().useSecureLayer()) return; @@ -540,7 +549,7 @@ public class CallFragment extends CallableWrapperFragment implements CallInterfa } public boolean draggingBubble() { - return mBubbleView == null ? false : mBubbleView.isDraggingBubble(); + return mBubbleView != null && mBubbleView.isDraggingBubble(); } @Override @@ -613,7 +622,7 @@ public class CallFragment extends CallableWrapperFragment implements CallInterfa break; default: String toSend = Character.toString(event.getDisplayLabel()); - toSend.toUpperCase(Locale.getDefault()); + toSend = toSend.toUpperCase(Locale.getDefault()); Log.d(TAG, "toSend " + toSend); mCallbacks.getService().playDtmf(toSend); break; diff --git a/src/org/sflphone/model/SipCall.java b/src/org/sflphone/model/SipCall.java index e8d6ac3fc2c2f86df72fed73a0e3d6dd4788f8f8..87d6191aa41f6c62b1d041a04907b005a23ce334 100644 --- a/src/org/sflphone/model/SipCall.java +++ b/src/org/sflphone/model/SipCall.java @@ -208,15 +208,14 @@ public class SipCall implements Parcelable { return mContact; } - public void setmContact(CallContact contacts) { - mContact = contacts; - } - public String getCallStateString() { String text_state; switch (mCallState) { + case state.CALL_STATE_NONE: + text_state = "NONE"; + break; case state.CALL_STATE_RINGING: text_state = "RINGING"; break;