* #25232 Notification working
Overall design improvement
diff --git a/src/com/savoirfairelinux/sflphone/client/CallActivity.java b/src/com/savoirfairelinux/sflphone/client/CallActivity.java
index 41c802b..d0eac58 100644
--- a/src/com/savoirfairelinux/sflphone/client/CallActivity.java
+++ b/src/com/savoirfairelinux/sflphone/client/CallActivity.java
@@ -57,7 +57,6 @@
 import com.savoirfairelinux.sflphone.fragments.CallFragment;
 import com.savoirfairelinux.sflphone.fragments.CallListFragment;
 import com.savoirfairelinux.sflphone.interfaces.CallInterface;
-import com.savoirfairelinux.sflphone.model.CallContact;
 import com.savoirfairelinux.sflphone.model.SipCall;
 import com.savoirfairelinux.sflphone.model.SipCall.state;
 import com.savoirfairelinux.sflphone.service.CallManagerCallBack;
@@ -69,8 +68,6 @@
 	static final String TAG = "CallActivity";
 	private ISipService service;
 
-	private String pendingAction = null;
-
 	private ExecutorService infos_fetcher = Executors.newCachedThreadPool();
 	CallReceiver receiver;
 
@@ -153,12 +150,22 @@
 	protected void onPause() {
 		super.onPause();
 		unregisterReceiver(receiver);
+		try {
+            service.createNotification();
+        } catch (RemoteException e) {
+            Log.e(TAG, e.toString());
+        }
 	}
 
 	@Override
 	protected void onDestroy() {
 		// Log.i(TAG, "Destroying Call Activity for call " + mCall.getCallId());
 		// LocalBroadcastManager.getInstance(this).unregisterReceiver(mMessageReceiver);
+	    try {
+            service.destroyNotification();
+        } catch (RemoteException e) {
+            Log.e(TAG, e.toString());
+        }
 		unbindService(mConnection);
 
 		super.onDestroy();
@@ -174,8 +181,7 @@
 			mCurrentCallFragment.setArguments(getIntent().getExtras());
 			slidingPaneLayout.curFragment = mCurrentCallFragment;
 			getIntent().getExtras();
-			// SipCall info = getIntent().getExtras().getParcelable("CallInfo");
-			// mCallPagerAdapter.addCall(info.mCallID, newCall);
+			mCallsFragment.update();
 			getFragmentManager().beginTransaction().replace(R.id.ongoingcall_pane, mCurrentCallFragment).commit();
 
 		}
@@ -223,45 +229,6 @@
 		}
 
 
-
-		// if (newState.equals("INCOMING")) {
-		// fr.changeCallState(SipCall.state.CALL_STATE_INCOMING);
-		//
-		// } else if (newState.equals("RINGING")) {
-		// fr.changeCallState(SipCall.state.CALL_STATE_RINGING);
-		//
-		// } else if (newState.equals("CURRENT")) {
-		// fr.changeCallState(SipCall.state.CALL_STATE_CURRENT);
-		//
-		// } else if (newState.equals("HUNGUP")) {
-		// // mCallPagerAdapter.remove(callID);
-		// // if (mCallPagerAdapter.getCount() == 0) {
-		// // finish();
-		// // }
-		//
-		// } else if (newState.equals("BUSY")) {
-		// // mCallPagerAdapter.remove(callID);
-		// // if (mCallPagerAdapter.getCount() == 0) {
-		// // finish();
-		// // }
-		//
-		// } else if (newState.equals("FAILURE")) {
-		// // mCallPagerAdapter.remove(callID);
-		// // if (mCallPagerAdapter.getCount() == 0) {
-		// // finish();
-		// // }
-		//
-		// } else if (newState.equals("HOLD")) {
-		// fr.changeCallState(SipCall.state.CALL_STATE_HOLD);
-		//
-		// } else if (newState.equals("UNHOLD")) {
-		// fr.changeCallState(SipCall.state.CALL_STATE_CURRENT);
-		//
-		// } else {
-		// fr.changeCallState(SipCall.state.CALL_STATE_NONE);
-		//
-		// }
-
 		Log.w(TAG, "processCallStateChangedSignal " + newState);
 
 	}
@@ -288,7 +255,7 @@
 		getFragmentManager().beginTransaction().replace(R.id.ongoingcall_pane, mCurrentCallFragment).commit();
 
 		slidingPaneLayout.curFragment = mCurrentCallFragment;
-		slidingPaneLayout.openPane();
+		slidingPaneLayout.closePane();
 
 	}
 
diff --git a/src/com/savoirfairelinux/sflphone/client/RelativePositioningLayout.java b/src/com/savoirfairelinux/sflphone/client/RelativePositioningLayout.java
deleted file mode 100644
index 3e5f611..0000000
--- a/src/com/savoirfairelinux/sflphone/client/RelativePositioningLayout.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package com.savoirfairelinux.sflphone.client;
-
-import android.content.Context;
-import android.util.AttributeSet;
-import android.widget.RelativeLayout;
-
-public class RelativePositioningLayout extends RelativeLayout
-{
-	public RelativePositioningLayout(Context context, AttributeSet attrs)
-	{
-		super(context, attrs);
-	}
-
-	public float getXFraction()
-	{
-		return getX() / getWidth();
-	}
-
-	public void setXFraction(float xFraction)
-	{
-		final int width = getWidth();
-		setX((width > 0) ? (xFraction * width) : -9999);
-	}
-}
\ No newline at end of file
diff --git a/src/com/savoirfairelinux/sflphone/client/SFLPhoneHomeActivity.java b/src/com/savoirfairelinux/sflphone/client/SFLPhoneHomeActivity.java
index ee5e2aa..fedcec9 100644
--- a/src/com/savoirfairelinux/sflphone/client/SFLPhoneHomeActivity.java
+++ b/src/com/savoirfairelinux/sflphone/client/SFLPhoneHomeActivity.java
@@ -33,10 +33,8 @@
 
 import java.util.HashMap;
 
-import android.app.ActionBar;
 import android.app.Activity;
 import android.app.Fragment;
-import android.app.FragmentTransaction;
 import android.content.ComponentName;
 import android.content.Context;
 import android.content.Intent;
@@ -74,18 +72,20 @@
 import com.savoirfairelinux.sflphone.service.SipService;
 import com.savoirfairelinux.sflphone.views.CustomSlidingDrawer;
 
-public class SFLPhoneHomeActivity extends Activity implements ActionBar.TabListener, DialingFragment.Callbacks, ContactListFragment.Callbacks,
+public class SFLPhoneHomeActivity extends Activity implements DialingFragment.Callbacks, ContactListFragment.Callbacks,
         CallElementListFragment.Callbacks, HistoryFragment.Callbacks, CallInterface {
 
     SectionsPagerAdapter mSectionsPagerAdapter = null;
     static final String TAG = "SFLPhoneHomeActivity";
 
+    /**
+     * Fragments used
+     */
     private ContactListFragment mContactsFragment = null;
     private DialingFragment mDialingFragment = null;
     private CallElementListFragment mCallElementList = null;
     private HistoryFragment mHistorySectionFragment = null;
-
-    Fragment fMenu;
+    private Fragment fMenu;
 
     private boolean mBound = false;
     private ISipService service;
@@ -93,7 +93,7 @@
     private CharSequence mDrawerTitle;
     private CharSequence mTitle;
 
-    private static final int REQUEST_CODE_PREFERENCES = 1;
+    public static final int REQUEST_CODE_PREFERENCES = 1;
     private static final int REQUEST_CODE_CALL = 2;
 
     private static final int ACTION_BAR_TAB_DIALING = 0;
@@ -111,7 +111,6 @@
 
     CallReceiver receiver;
 
-    
     private TabHost mTabHost;
 
     // public SFLPhoneHome extends Activity implements ActionBar.TabListener, OnClickListener
@@ -138,8 +137,8 @@
 
         receiver = new CallReceiver(this);
 
-        String libraryPath = getApplicationInfo().dataDir + "/lib";
-        Log.i(TAG, libraryPath);
+        // String libraryPath = getApplicationInfo().dataDir + "/lib";
+        // Log.i(TAG, libraryPath);
 
         // Bind to LocalService
         if (!mBound) {
@@ -191,7 +190,6 @@
 
         mDrawer.setmTrackHandle(findViewById(R.id.handle_title));
 
-
         // Set up the ViewPager with the sections adapter.
         mViewPager = (ViewPager) findViewById(R.id.pager);
         mViewPager.setAdapter(mSectionsPagerAdapter);
@@ -242,17 +240,28 @@
 
     private void initialiseTabHost(Bundle args) {
 
-        
         mTabHost.setup();
         TabInfo tabInfo = null;
-        SFLPhoneHomeActivity.AddTab(this, this.mTabHost, this.mTabHost.newTabSpec("Tab1").setIndicator(mSectionsPagerAdapter.getPageTitle(0),getResources().getDrawable(mSectionsPagerAdapter.getIconOf(0))), (tabInfo = new TabInfo("Tab1",
-                DialingFragment.class, args)));
+        SFLPhoneHomeActivity
+                .AddTab(this,
+                        this.mTabHost,
+                        this.mTabHost.newTabSpec("Tab1").setIndicator(mSectionsPagerAdapter.getPageTitle(0),
+                                getResources().getDrawable(mSectionsPagerAdapter.getIconOf(0))), (tabInfo = new TabInfo("Tab1",
+                                DialingFragment.class, args)));
         this.mapTabInfo.put(tabInfo.tag, tabInfo);
-        SFLPhoneHomeActivity.AddTab(this, this.mTabHost, this.mTabHost.newTabSpec("Tab2").setIndicator(mSectionsPagerAdapter.getPageTitle(1),getResources().getDrawable(mSectionsPagerAdapter.getIconOf(1))), (tabInfo = new TabInfo("Tab2",
-                CallElementListFragment.class, args)));
+        SFLPhoneHomeActivity.AddTab(
+                this,
+                this.mTabHost,
+                this.mTabHost.newTabSpec("Tab2").setIndicator(mSectionsPagerAdapter.getPageTitle(1),
+                        getResources().getDrawable(mSectionsPagerAdapter.getIconOf(1))), (tabInfo = new TabInfo("Tab2",
+                        CallElementListFragment.class, args)));
         this.mapTabInfo.put(tabInfo.tag, tabInfo);
-        SFLPhoneHomeActivity.AddTab(this, this.mTabHost, this.mTabHost.newTabSpec("Tab3").setIndicator(mSectionsPagerAdapter.getPageTitle(2),getResources().getDrawable(mSectionsPagerAdapter.getIconOf(2))), (tabInfo = new TabInfo("Tab3",
-                HistoryFragment.class, args)));
+        SFLPhoneHomeActivity
+                .AddTab(this,
+                        this.mTabHost,
+                        this.mTabHost.newTabSpec("Tab3").setIndicator(mSectionsPagerAdapter.getPageTitle(2),
+                                getResources().getDrawable(mSectionsPagerAdapter.getIconOf(2))), (tabInfo = new TabInfo("Tab3",
+                                HistoryFragment.class, args)));
         this.mapTabInfo.put(tabInfo.tag, tabInfo);
 
         mTabHost.setOnTabChangedListener(new OnTabChangeListener() {
@@ -295,12 +304,14 @@
     protected void onPause() {
         super.onPause();
         unregisterReceiver(receiver);
+
     }
 
     /* activity is no longer visible */
     @Override
     protected void onStop() {
         super.onStop();
+
     }
 
     /* activity finishes itself or is being killed by the system */
@@ -309,8 +320,15 @@
         /* stop the service, if no other bound user, no need to check if it is running */
         if (mBound) {
             Log.i(TAG, "onDestroy: Unbinding service...");
+            try {
+                service.createNotification();
+
+            } catch (RemoteException e) {
+                Log.e(TAG, e.toString());
+            }
             unbindService(mConnection);
             mBound = false;
+
         }
 
         super.onDestroy();
@@ -333,10 +351,12 @@
         public void onServiceConnected(ComponentName className, IBinder binder) {
             service = ISipService.Stub.asInterface(binder);
 
+            try {
+                service.destroyNotification();
+            } catch (RemoteException e) {
+                Log.e(TAG, e.toString());
+            }
             mBound = true;
-            mCallElementList.onServiceSipBinded(service);
-            mHistorySectionFragment.onServiceSipBinded(service);
-            mDialingFragment.onServiceSipBinded(service);
             Log.d(TAG, "Service connected service=" + service);
 
         }
@@ -366,34 +386,17 @@
 
         switch (requestCode) {
         case REQUEST_CODE_PREFERENCES:
-            mCallElementList.onServiceSipBinded(service);
             break;
         case REQUEST_CODE_CALL:
-
+            Log.w(TAG, "Result out of CallActivity");
             break;
         }
 
     }
 
-
-    @Override
-    public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
-    }
-
-    @Override
-    public void onTabSelected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
-        // When the given tab is selected, switch to the corresponding page in the ViewPager.
-        mViewPager.setCurrentItem(tab.getPosition());
-    }
-
-    @Override
-    public void onTabReselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
-        // Log.d(TAG, "onTabReselected");
-    }
-
     @Override
     public void onCallSelected(SipCall c) {
-        // launchCallActivity(c.mCallInfo);
+        launchCallActivity(c, "display");
 
     }
 
@@ -440,14 +443,11 @@
 
         SipCall.SipCallBuilder callBuilder = SipCall.SipCallBuilder.getInstance();
         try {
-            callBuilder.startCallCreation().setAccountID(service.getAccountList().get(0).toString()).setCallType(SipCall.state.CALL_TYPE_OUTGOING);
+            callBuilder.startCallCreation().setAccountID(service.getAccountList().get(1).toString()).setCallType(SipCall.state.CALL_TYPE_OUTGOING);
+            callBuilder.addContact(c);
+            launchCallActivity(callBuilder.build(), "call");
         } catch (RemoteException e1) {
             Log.e(TAG, e1.toString());
-        }
-        callBuilder.addContact(c);
-
-        try {
-            launchCallActivity(callBuilder.build(), "call");
         } catch (Exception e) {
             Log.e(TAG, e.toString());
         }
@@ -473,7 +473,7 @@
     public void onContactDragged() {
 
         mDrawer.close();
-        getActionBar().setSelectedNavigationItem(ACTION_BAR_TAB_CALL);
+        mTabHost.setCurrentTab(1);
 
     }
 
diff --git a/src/com/savoirfairelinux/sflphone/client/receiver/IncomingReceiver.java b/src/com/savoirfairelinux/sflphone/client/receiver/IncomingReceiver.java
new file mode 100644
index 0000000..1fa217a
--- /dev/null
+++ b/src/com/savoirfairelinux/sflphone/client/receiver/IncomingReceiver.java
@@ -0,0 +1,87 @@
+package com.savoirfairelinux.sflphone.client.receiver;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.os.Bundle;
+import android.os.Vibrator;
+import android.util.Log;
+
+import com.savoirfairelinux.sflphone.interfaces.CallInterface;
+import com.savoirfairelinux.sflphone.model.CallContact;
+import com.savoirfairelinux.sflphone.model.SipCall;
+import com.savoirfairelinux.sflphone.service.CallManagerCallBack;
+import com.savoirfairelinux.sflphone.service.ConfigurationManagerCallback;
+import com.savoirfairelinux.sflphone.service.SipService;
+
+public class IncomingReceiver extends BroadcastReceiver{
+    
+    static final String TAG = CallReceiver.class.getSimpleName();
+
+    SipService callback;
+    
+    public IncomingReceiver(SipService client){
+        callback = client;
+    }
+    
+    @Override
+    public void onReceive(Context context, Intent intent) {
+
+        if (intent.getAction().contentEquals(ConfigurationManagerCallback.ACCOUNT_STATE_CHANGED)) {
+            Log.i(TAG, "Received" + intent.getAction());
+        } else if (intent.getAction().contentEquals(ConfigurationManagerCallback.ACCOUNTS_LOADED)) {
+            Log.i(TAG, "Received" + intent.getAction());
+        } else if (intent.getAction().contentEquals(ConfigurationManagerCallback.ACCOUNTS_CHANGED)) {
+            Log.i(TAG, "Received" + intent.getAction());
+        } else if (intent.getAction().contentEquals(CallManagerCallBack.INCOMING_TEXT)) {
+            Log.i(TAG, "Received" + intent.getAction());
+            callback.sendBroadcast(intent);
+        } else if (intent.getAction().contentEquals(CallManagerCallBack.INCOMING_CALL)) {
+            Bundle b = intent.getBundleExtra("com.savoirfairelinux.sflphone.service.newcall");
+
+            SipCall.SipCallBuilder callBuilder = SipCall.SipCallBuilder.getInstance();
+            callBuilder.startCallCreation(b.getString("CallID")).setAccountID(b.getString("AccountID"))
+                    .setCallState(SipCall.state.CALL_STATE_RINGING).setCallType(SipCall.state.CALL_TYPE_INCOMING);
+            callBuilder.addContact(CallContact.ContactBuilder.buildUnknownContact(b.getString("From")));
+
+            Intent toSend = new Intent(CallManagerCallBack.INCOMING_CALL);
+            try {
+                SipCall newCall = callBuilder.build();
+                toSend.putExtra("newcall", newCall);
+                callback.getCurrent_calls().put(newCall.getCallId(), newCall);
+                callback.sendBroadcast(toSend);
+            } catch (Exception e) {
+                Log.e(TAG, e.toString());
+            }
+
+        } else if (intent.getAction().contentEquals(CallManagerCallBack.CALL_STATE_CHANGED)) {
+
+            Bundle b = intent.getBundleExtra("com.savoirfairelinux.sflphone.service.newstate");
+            String newState = b.getString("State");
+            if (newState.equals("INCOMING")) {
+                callback.getCurrent_calls().get(b.getString("CallID")).setCallState(SipCall.state.CALL_STATE_INCOMING);
+            } else if (newState.equals("RINGING")) {
+                callback.getCurrent_calls().get(b.getString("CallID")).setCallState(SipCall.state.CALL_STATE_RINGING);
+            } else if (newState.equals("CURRENT")) {
+                callback.getCurrent_calls().get(b.getString("CallID")).setCallState(SipCall.state.CALL_STATE_CURRENT);
+            } else if (newState.equals("HUNGUP")) {
+                callback.getCurrent_calls().remove(b.getString("CallID"));
+            } else if (newState.equals("BUSY")) {
+                callback.getCurrent_calls().remove(b.getString("CallID"));
+            } else if (newState.equals("FAILURE")) {
+                callback.getCurrent_calls().remove(b.getString("CallID"));
+            } else if (newState.equals("HOLD")) {
+                callback.getCurrent_calls().get(b.getString("CallID")).setCallState(SipCall.state.CALL_STATE_HOLD);
+            } else if (newState.equals("UNHOLD")) {
+                callback.getCurrent_calls().get(b.getString("CallID")).setCallState(SipCall.state.CALL_STATE_CURRENT);
+            } else {
+                callback.getCurrent_calls().get(b.getString("CallID")).setCallState(SipCall.state.CALL_STATE_NONE);
+            }
+
+            callback.sendBroadcast(intent);
+        } else if (intent.getAction().contentEquals(CallManagerCallBack.NEW_CALL_CREATED)) {
+            Log.i(TAG, "Received" + intent.getAction());
+        }
+
+    }
+}