From c51ccb1ab7a097e9e4962816fdb36d0f8324e4d2 Mon Sep 17 00:00:00 2001
From: Alexandre Lision <alexandre.lision@savoirfairelinux.com>
Date: Wed, 11 Sep 2013 16:00:30 -0400
Subject: [PATCH] * #29924: numbers of calls and conferences Removed useless
 log

---
 jni/sflphone                                  |   2 +-
 res/layout/frag_home.xml                      |  63 ++++++++-
 res/values/strings.xml                        |   6 +
 .../sflphone/account/HistoryHandler.java      |  22 ++--
 .../adapters/AccountSelectionAdapter.java     |   4 +-
 .../adapters/ContactPictureLoader.java        |   2 +-
 .../client/AccountPreferenceActivity.java     |  13 +-
 .../sflphone/client/CallActivity.java         |  10 +-
 .../sflphone/client/SFLPhoneHomeActivity.java | 120 +++++++-----------
 .../sflphone/fragments/DialingFragment.java   |   2 +-
 .../sflphone/fragments/HomeFragment.java      |  14 +-
 .../sflphone/fragments/MenuFragment.java      |   3 +-
 .../sflphone/loaders/HistoryLoader.java       |   4 +-
 .../sflphone/model/Bubble.java                |   2 +-
 .../sflphone/model/BubblesView.java           |   4 +-
 .../sflphone/service/SipService.java          |  11 +-
 .../sflphone/views/ClearableEditText.java     |   6 +
 17 files changed, 179 insertions(+), 109 deletions(-)

diff --git a/jni/sflphone b/jni/sflphone
index 9308e26d2..0c721afda 160000
--- a/jni/sflphone
+++ b/jni/sflphone
@@ -1 +1 @@
-Subproject commit 9308e26d2c4302bb089f73e9735ebf10723a1616
+Subproject commit 0c721afda0980f5d05c42b03b2555f8f6156773e
diff --git a/res/layout/frag_home.xml b/res/layout/frag_home.xml
index 73c389f65..ab471c5a0 100644
--- a/res/layout/frag_home.xml
+++ b/res/layout/frag_home.xml
@@ -33,18 +33,73 @@ as that of the covered work.
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
+    android:background="@color/lighter_gray"
     android:orientation="vertical"
     android:paddingLeft="8dp"
-    android:background="@color/lighter_gray"
     android:paddingRight="8dp" >
 
+    <LinearLayout
+        android:id="@+id/linear1"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_above="@+id/linear2"
+        android:layout_alignParentLeft="true"
+        android:orientation="horizontal"
+        android:weightSum="4" >
+
+        <TextView
+            android:id="@+id/calls_counter"
+            android:layout_width="0dp"
+            android:layout_height="wrap_content"
+            android:layout_weight="1"
+            android:gravity="center"
+            android:text="0"
+            android:textSize="40sp" />
+
+        <TextView
+            android:id="@+id/textView2"
+            android:layout_width="0dp"
+            android:layout_height="wrap_content"
+            android:layout_weight="3"
+            android:text="Calls"
+            android:textSize="30sp" />
+    </LinearLayout>
+
+    <LinearLayout
+        android:id="@+id/linear2"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_alignParentLeft="true"
+        android:layout_centerInParent="true"
+        android:orientation="horizontal"
+        android:weightSum="4" >
+
+        <TextView
+            android:id="@+id/confs_counter"
+            android:layout_width="0dp"
+            android:layout_height="wrap_content"
+            android:layout_weight="1"
+            android:gravity="center"
+            android:text="0"
+            android:textSize="40sp" />
+
+        <TextView
+            android:id="@+id/textView4"
+            android:layout_width="0dp"
+            android:layout_height="wrap_content"
+            android:layout_weight="3"
+            android:text="Conferences"
+            android:textSize="30sp" />
+    </LinearLayout>
 
     <Button
         android:id="@+id/access_callactivity"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
-        android:layout_centerInParent="true"
-        android:text="Current Calls" />
-
+        android:layout_alignParentBottom="true"
+        android:layout_centerHorizontal="true"
+        android:layout_marginBottom="134dp"
+        android:text="Go to current calls"
+        android:visibility="gone" />
 
 </RelativeLayout>
\ No newline at end of file
diff --git a/res/values/strings.xml b/res/values/strings.xml
index d93d4e5c2..b5b9ac109 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -41,6 +41,9 @@ as that of the covered work.
     <string name="title_section2">History</string>
     <string name="title_activity_sflphone_home">SFLphone</string>
     
+    <string name="create_new_account_dialog_title">No Account Registered</string>
+    <string name="create_new_account_dialog">Would you like to create an account now?</string>
+        
     <!-- AB menus -->
     <string name="ab_account_creation">New Account</string>
     <string name="ab_account_edition_1">Delete</string>
@@ -59,6 +62,9 @@ as that of the covered work.
     <string name="menu_item_settings_advanced">Manage Accounts</string>
     <string name="menu_item_settings_audio">Audio</string>
     <string name="menu_item_settings_interface">Interface</string>
+    
+    <!-- Dialing Fragmennt -->
+    <string name="error_no_number_dialed">Enter a number</string>
 
     <!-- Help -->
     <string name="menu_item_help_gestures">Gestures</string>
diff --git a/src/com/savoirfairelinux/sflphone/account/HistoryHandler.java b/src/com/savoirfairelinux/sflphone/account/HistoryHandler.java
index 754e5e043..9cd73fff7 100644
--- a/src/com/savoirfairelinux/sflphone/account/HistoryHandler.java
+++ b/src/com/savoirfairelinux/sflphone/account/HistoryHandler.java
@@ -24,21 +24,21 @@ public class HistoryHandler {
 
         ArrayList<HashMap<String, String>> nativemap = new ArrayList<HashMap<String, String>>();
 
-        Log.w(TAG, "size history " + swigmap.size());
+//        Log.w(TAG, "size history " + swigmap.size());
 
         for (int i = 0; i < swigmap.size(); ++i) {
             HashMap<String, String> entry = new HashMap<String, String>();
 
-            Log.i(TAG, tryToGet(swigmap.get(i), ServiceConstants.HISTORY_ACCOUNT_ID_KEY));
-            Log.i(TAG, tryToGet(swigmap.get(i), ServiceConstants.HISTORY_CALLID_KEY));
-            Log.i(TAG, tryToGet(swigmap.get(i), ServiceConstants.HISTORY_CONFID_KEY));
-            Log.i(TAG, tryToGet(swigmap.get(i), ServiceConstants.HISTORY_DISPLAY_NAME_KEY));
-            Log.i(TAG, tryToGet(swigmap.get(i), ServiceConstants.HISTORY_PEER_NUMBER_KEY));
-            Log.i(TAG, tryToGet(swigmap.get(i), ServiceConstants.HISTORY_RECORDING_PATH_KEY));
-            Log.i(TAG, tryToGet(swigmap.get(i), ServiceConstants.HISTORY_STATE_KEY));
-            Log.i(TAG, tryToGet(swigmap.get(i), ServiceConstants.HISTORY_TIMESTAMP_START_KEY));
-            Log.i(TAG, tryToGet(swigmap.get(i), ServiceConstants.HISTORY_TIMESTAMP_STOP_KEY));
-            Log.i(TAG, tryToGet(swigmap.get(i), ServiceConstants.HISTORY_AUDIO_CODEC_KEY));
+//            Log.i(TAG, tryToGet(swigmap.get(i), ServiceConstants.HISTORY_ACCOUNT_ID_KEY));
+//            Log.i(TAG, tryToGet(swigmap.get(i), ServiceConstants.HISTORY_CALLID_KEY));
+//            Log.i(TAG, tryToGet(swigmap.get(i), ServiceConstants.HISTORY_CONFID_KEY));
+//            Log.i(TAG, tryToGet(swigmap.get(i), ServiceConstants.HISTORY_DISPLAY_NAME_KEY));
+//            Log.i(TAG, tryToGet(swigmap.get(i), ServiceConstants.HISTORY_PEER_NUMBER_KEY));
+//            Log.i(TAG, tryToGet(swigmap.get(i), ServiceConstants.HISTORY_RECORDING_PATH_KEY));
+//            Log.i(TAG, tryToGet(swigmap.get(i), ServiceConstants.HISTORY_STATE_KEY));
+//            Log.i(TAG, tryToGet(swigmap.get(i), ServiceConstants.HISTORY_TIMESTAMP_START_KEY));
+//            Log.i(TAG, tryToGet(swigmap.get(i), ServiceConstants.HISTORY_TIMESTAMP_STOP_KEY));
+//            Log.i(TAG, tryToGet(swigmap.get(i), ServiceConstants.HISTORY_AUDIO_CODEC_KEY));
 
 
             entry.put(ServiceConstants.HISTORY_ACCOUNT_ID_KEY, tryToGet(swigmap.get(i), ServiceConstants.HISTORY_ACCOUNT_ID_KEY));
diff --git a/src/com/savoirfairelinux/sflphone/adapters/AccountSelectionAdapter.java b/src/com/savoirfairelinux/sflphone/adapters/AccountSelectionAdapter.java
index 13cb87e56..c794cdb89 100644
--- a/src/com/savoirfairelinux/sflphone/adapters/AccountSelectionAdapter.java
+++ b/src/com/savoirfairelinux/sflphone/adapters/AccountSelectionAdapter.java
@@ -22,14 +22,12 @@ public class AccountSelectionAdapter extends BaseAdapter {
 
     ArrayList<Account> accounts;
     Context mContext;
-    ISipService service;
     int selectedAccount = -1;
 
-    public AccountSelectionAdapter(Context cont, ISipService s, ArrayList<Account> newList) {
+    public AccountSelectionAdapter(Context cont, ArrayList<Account> newList) {
         super();
         accounts = newList;
         mContext = cont;
-        service = s;
     }
 
     @Override
diff --git a/src/com/savoirfairelinux/sflphone/adapters/ContactPictureLoader.java b/src/com/savoirfairelinux/sflphone/adapters/ContactPictureLoader.java
index 70cae8edc..591d0c36f 100644
--- a/src/com/savoirfairelinux/sflphone/adapters/ContactPictureLoader.java
+++ b/src/com/savoirfairelinux/sflphone/adapters/ContactPictureLoader.java
@@ -64,7 +64,7 @@ public class ContactPictureLoader implements Runnable {
 
     public static Bitmap loadContactPhoto(ContentResolver cr, long id) {
         Uri uri = ContentUris.withAppendedId(ContactsContract.Contacts.CONTENT_URI, id);
-        InputStream input = ContactsContract.Contacts.openContactPhotoInputStream(cr, uri);
+        InputStream input = ContactsContract.Contacts.openContactPhotoInputStream(cr, uri, true);
         if (input == null) {
             return null;
         }
diff --git a/src/com/savoirfairelinux/sflphone/client/AccountPreferenceActivity.java b/src/com/savoirfairelinux/sflphone/client/AccountPreferenceActivity.java
index 6813e5372..7ff6a69b6 100644
--- a/src/com/savoirfairelinux/sflphone/client/AccountPreferenceActivity.java
+++ b/src/com/savoirfairelinux/sflphone/client/AccountPreferenceActivity.java
@@ -82,6 +82,8 @@ public class AccountPreferenceActivity extends PreferenceActivity {
     private String mAccountID;
     private ArrayList<String> requiredFields = null;
 
+    private boolean isDifferent = false;
+
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
@@ -91,7 +93,6 @@ public class AccountPreferenceActivity extends PreferenceActivity {
         initEdition();
 
         getActionBar().setDisplayHomeAsUpEnabled(true);
-        
 
         requiredFields = new ArrayList<String>();
         requiredFields.add(AccountDetailBasic.CONFIG_ACCOUNT_ALIAS);
@@ -136,8 +137,12 @@ public class AccountPreferenceActivity extends PreferenceActivity {
     @Override
     public void onBackPressed() {
 
-        AlertDialog dialog = createCancelDialog();
-        dialog.show();
+        if (isDifferent) {
+            AlertDialog dialog = createCancelDialog();
+            dialog.show();
+        } else {
+            super.onBackPressed();
+        }
 
     }
 
@@ -239,6 +244,8 @@ public class AccountPreferenceActivity extends PreferenceActivity {
 
     Preference.OnPreferenceChangeListener changeBasicPreferenceListener = new Preference.OnPreferenceChangeListener() {
         public boolean onPreferenceChange(Preference preference, Object newValue) {
+
+            isDifferent = true;
             if (preference instanceof CheckBoxPreference) {
                 if ((Boolean) newValue == true)
                     basicDetails.setDetailString(preference.getKey(), ((Boolean) newValue).toString());
diff --git a/src/com/savoirfairelinux/sflphone/client/CallActivity.java b/src/com/savoirfairelinux/sflphone/client/CallActivity.java
index 5f5d78bcb..5313254be 100644
--- a/src/com/savoirfairelinux/sflphone/client/CallActivity.java
+++ b/src/com/savoirfairelinux/sflphone/client/CallActivity.java
@@ -33,7 +33,6 @@
 
 package com.savoirfairelinux.sflphone.client;
 
-import java.io.File;
 import java.util.HashMap;
 
 import android.app.Activity;
@@ -44,7 +43,6 @@ import android.content.IntentFilter;
 import android.content.ServiceConnection;
 import android.net.Uri;
 import android.os.Bundle;
-import android.os.Environment;
 import android.os.IBinder;
 import android.os.RemoteException;
 import android.support.v4.widget.SlidingPaneLayout;
@@ -77,6 +75,9 @@ public class CallActivity extends Activity implements CallInterface, CallFragmen
     CallListFragment mCallsFragment;
     CallFragment mCurrentCallFragment;
     private boolean fragIsChanging;
+    
+    /* result code sent in c&ase of call failure*/
+    public static int RESULT_FAILURE = -10;
 
     @Override
     protected void onCreate(Bundle savedInstanceState) {
@@ -132,7 +133,7 @@ public class CallActivity extends Activity implements CallInterface, CallFragmen
 
         Intent intent = new Intent(this, SipService.class);
         bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
-        slidingPaneLayout.setCoveredFadeColor(0xFFFF0000);
+        slidingPaneLayout.setCoveredFadeColor(0xFF0000);
     }
 
     /* activity gets back to the foreground and user input */
@@ -232,6 +233,7 @@ public class CallActivity extends Activity implements CallInterface, CallFragmen
         public void onServiceDisconnected(ComponentName arg0) {
         }
     };
+    
 
     @Override
     public void incomingCall(Intent call) {
@@ -265,7 +267,7 @@ public class CallActivity extends Activity implements CallInterface, CallFragmen
             HashMap<String, SipCall> callMap = (HashMap<String, SipCall>) service.getCallList();
             HashMap<String, Conference> confMap = (HashMap<String, Conference>) service.getConferenceList();
             if (callMap.size() == 0 && confMap.size() == 0) {
-
+                finishActivity(RESULT_FAILURE);
                 finish();
             }
         } catch (RemoteException e) {
diff --git a/src/com/savoirfairelinux/sflphone/client/SFLPhoneHomeActivity.java b/src/com/savoirfairelinux/sflphone/client/SFLPhoneHomeActivity.java
index bfe559a19..f25987333 100644
--- a/src/com/savoirfairelinux/sflphone/client/SFLPhoneHomeActivity.java
+++ b/src/com/savoirfairelinux/sflphone/client/SFLPhoneHomeActivity.java
@@ -36,14 +36,19 @@ import java.util.Timer;
 import java.util.TimerTask;
 
 import android.app.Activity;
+import android.app.AlertDialog;
+import android.app.Dialog;
 import android.content.ComponentName;
 import android.content.Context;
+import android.content.DialogInterface;
 import android.content.Intent;
 import android.content.IntentFilter;
 import android.content.ServiceConnection;
 import android.content.res.Configuration;
 import android.database.Cursor;
 import android.graphics.Color;
+import android.media.AudioFormat;
+import android.media.AudioTrack;
 import android.os.Bundle;
 import android.os.IBinder;
 import android.os.RemoteException;
@@ -65,6 +70,7 @@ import android.widget.Toast;
 
 import com.savoirfairelinux.sflphone.R;
 import com.savoirfairelinux.sflphone.adapters.SectionsPagerAdapter;
+import com.savoirfairelinux.sflphone.client.AccountPreferenceActivity.result;
 import com.savoirfairelinux.sflphone.fragments.ContactListFragment;
 import com.savoirfairelinux.sflphone.fragments.DialingFragment;
 import com.savoirfairelinux.sflphone.fragments.HistoryFragment;
@@ -116,7 +122,7 @@ public class SFLPhoneHomeActivity extends Activity implements DialingFragment.Ca
 
     CallReceiver callReceiver;
 
-//    private TabHost mTabHost;
+    // private TabHost mTabHost;
 
     // public SFLPhoneHome extends Activity implements ActionBar.TabListener, OnClickListener
 
@@ -165,8 +171,6 @@ public class SFLPhoneHomeActivity extends Activity implements DialingFragment.Ca
         mContactsFragment.setHandleView((RelativeLayout) findViewById(R.id.slider_button));
 
         mDrawer.setmTrackHandle(findViewById(R.id.handle_title));
-        
-        
 
         // Set up the ViewPager with the sections adapter.
         mViewPager = (ViewPager) findViewById(R.id.pager);
@@ -200,59 +204,25 @@ public class SFLPhoneHomeActivity extends Activity implements DialingFragment.Ca
             }
         };
 
-//        mTabHost = (TabHost) findViewById(android.R.id.tabhost);
+        // mTabHost = (TabHost) findViewById(android.R.id.tabhost);
         mDrawerLayout.setDrawerListener(mDrawerToggle);
 
         mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
             @Override
             public void onPageSelected(int position) {
-//                mTabHost.setCurrentTab(position);
+                // mTabHost.setCurrentTab(position);
             }
         });
 
     }
 
-//    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)));
-//        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", HomeFragment.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)));
-//        this.mapTabInfo.put(tabInfo.tag, tabInfo);
-//
-//        mTabHost.setOnTabChangedListener(new OnTabChangeListener() {
-//
-//            @Override
-//            public void onTabChanged(String tabId) {
-//                int pos = mTabHost.getCurrentTab();
-//                mViewPager.setCurrentItem(pos);
-//
-//            }
-//        });
-//    }
-
     @Override
     protected void onPostCreate(Bundle savedInstanceState) {
         super.onPostCreate(savedInstanceState);
         // Sync the toggle state after onRestoreInstanceState has occurred.
         mDrawerToggle.syncState();
+
+//        Toast.makeText(this, "Mini Buff:"+AudioTrack.getMinBufferSize(8000, AudioFormat.CHANNEL_OUT_STEREO, AudioFormat.ENCODING_PCM_16BIT), Toast.LENGTH_LONG).show();
     }
 
     @Override
@@ -265,6 +235,7 @@ public class SFLPhoneHomeActivity extends Activity implements DialingFragment.Ca
     protected void onStart() {
         Log.i(TAG, "onStart");
         super.onStart();
+
     }
 
     /* user gets back to the activity, e.g. through task manager */
@@ -384,7 +355,7 @@ public class SFLPhoneHomeActivity extends Activity implements DialingFragment.Ca
                 fMenu = new MenuFragment();
                 getFragmentManager().beginTransaction().replace(R.id.left_drawer, fMenu).commit();
                 mSectionsPagerAdapter = new SectionsPagerAdapter(SFLPhoneHomeActivity.this, getFragmentManager());
-                
+
                 final PagerTabStrip strip = PagerTabStrip.class.cast(mViewPager.findViewById(R.id.pts_main));
                 strip.setDrawFullUnderline(false);
                 strip.setTabIndicatorColor(getResources().getColor(R.color.holo_blue_dark));
@@ -392,12 +363,12 @@ public class SFLPhoneHomeActivity extends Activity implements DialingFragment.Ca
                 strip.setNonPrimaryAlpha(0.5f);
                 strip.setTextSpacing(25);
                 strip.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
-                
-                
-//                initialiseTabHost(null);
+
+                // initialiseTabHost(null);
                 mViewPager.setOffscreenPageLimit(2);
                 mViewPager.setAdapter(mSectionsPagerAdapter);
-//                mTabHost.setCurrentTab(1);
+                mViewPager.setCurrentItem(1);
+                // mTabHost.setCurrentTab(1);
                 service.destroyNotification();
                 // mAdapter = new AccountSelectionAdapter(SFLPhoneHomeActivity.this, service, new ArrayList<Account>());
                 // spinnerAccounts.setAdapter(mAdapter);
@@ -439,8 +410,11 @@ public class SFLPhoneHomeActivity extends Activity implements DialingFragment.Ca
             break;
         case REQUEST_CODE_CALL:
             Log.w(TAG, "Result out of CallActivity");
-//            if (mSectionsPagerAdapter != null && mSectionsPagerAdapter.getItem(2) != null)
-//                getLoaderManager().restartLoader(LoaderConstants.HISTORY_LOADER, null, (HistoryFragment) mSectionsPagerAdapter.getItem(2));
+            if (resultCode == CallActivity.RESULT_FAILURE) {
+                Log.w(TAG, "CALL FAILEEEED");
+            }
+            // if (mSectionsPagerAdapter != null && mSectionsPagerAdapter.getItem(2) != null)
+            // getLoaderManager().restartLoader(LoaderConstants.HISTORY_LOADER, null, (HistoryFragment) mSectionsPagerAdapter.getItem(2));
             break;
         }
 
@@ -532,7 +506,8 @@ public class SFLPhoneHomeActivity extends Activity implements DialingFragment.Ca
     public void onCallDialed(String to) {
 
         if (fMenu.getSelectedAccount() == null) {
-            Toast.makeText(this, "No Account Selected", Toast.LENGTH_SHORT).show();
+            // Toast.makeText(this, "No Account Selected", Toast.LENGTH_SHORT).show();
+            createAccountDialog().show();
             return;
         }
 
@@ -548,16 +523,38 @@ public class SFLPhoneHomeActivity extends Activity implements DialingFragment.Ca
 
     }
 
+    private AlertDialog createAccountDialog() {
+        final Activity ownerActivity = this;
+        AlertDialog.Builder builder = new AlertDialog.Builder(ownerActivity);
+
+        builder.setMessage(getResources().getString(R.string.create_new_account_dialog))
+                .setTitle(getResources().getString(R.string.create_new_account_dialog_title))
+                .setPositiveButton(getResources().getString(android.R.string.ok), new DialogInterface.OnClickListener() {
+                    public void onClick(DialogInterface dialog, int whichButton) {
+                        Intent in = new Intent();
+                        in.setClass(ownerActivity, SFLPhonePreferenceActivity.class);
+                        ownerActivity.startActivityForResult(in, SFLPhoneHomeActivity.REQUEST_CODE_PREFERENCES);
+                    }
+                }).setNegativeButton(getResources().getString(android.R.string.cancel), new DialogInterface.OnClickListener() {
+                    public void onClick(DialogInterface dialog, int whichButton) {
+                        dialog.dismiss();
+                    }
+                });
+
+        AlertDialog alertDialog = builder.create();
+        alertDialog.setOwnerActivity(ownerActivity);
+
+        return alertDialog;
+    }
+
     @Override
     public void onContactDragged() {
 
         mDrawer.close();
-//        mTabHost.setCurrentTab(1);
+        // mTabHost.setCurrentTab(1);
 
     }
 
-    private HashMap<String, TabInfo> mapTabInfo = new HashMap<String, SFLPhoneHomeActivity.TabInfo>();
-
     /**
      * A simple factory that returns dummy views to the Tabhost
      * 
@@ -588,25 +585,6 @@ public class SFLPhoneHomeActivity extends Activity implements DialingFragment.Ca
 
     }
 
-    /**
-     * 
-     * @author mwho Maintains extrinsic info of a tab's construct
-     */
-    private class TabInfo {
-        private String tag;
-
-        TabInfo(String tag, Class<?> clazz, Bundle args) {
-            this.tag = tag;
-        }
-
-    }
-
-    private static void AddTab(SFLPhoneHomeActivity activity, TabHost tabHost, TabHost.TabSpec tabSpec, TabInfo tabInfo) {
-        // Attach a Tab view factory to the spec
-        tabSpec.setContent(activity.new TabFactory(activity));
-        tabHost.addTab(tabSpec);
-    }
-
     @Override
     public void openDrawer() {
         mDrawer.animateOpen();
diff --git a/src/com/savoirfairelinux/sflphone/fragments/DialingFragment.java b/src/com/savoirfairelinux/sflphone/fragments/DialingFragment.java
index b96b92966..da4295501 100644
--- a/src/com/savoirfairelinux/sflphone/fragments/DialingFragment.java
+++ b/src/com/savoirfairelinux/sflphone/fragments/DialingFragment.java
@@ -125,7 +125,7 @@ public class DialingFragment extends Fragment {
 
                 String to = textField.getText().toString();
                 if (to.contentEquals("")) {
-                    Toast.makeText(getActivity(), "Enter a number", Toast.LENGTH_LONG).show();
+                    textField.setError(getString(R.string.error_no_number_dialed));
                 } else {
                     mCallbacks.onCallDialed(to);
                 }
diff --git a/src/com/savoirfairelinux/sflphone/fragments/HomeFragment.java b/src/com/savoirfairelinux/sflphone/fragments/HomeFragment.java
index 96cb3f894..77282e57b 100644
--- a/src/com/savoirfairelinux/sflphone/fragments/HomeFragment.java
+++ b/src/com/savoirfairelinux/sflphone/fragments/HomeFragment.java
@@ -44,6 +44,7 @@ import android.view.View;
 import android.view.View.OnClickListener;
 import android.view.ViewGroup;
 import android.widget.Button;
+import android.widget.TextView;
 import android.widget.Toast;
 
 import com.savoirfairelinux.sflphone.R;
@@ -56,6 +57,7 @@ public class HomeFragment extends Fragment {
 
     private Callbacks mCallbacks = sDummyCallbacks;
     Button access_calls;
+    TextView nb_calls, nb_confs;
 
     /**
      * A dummy implementation of the {@link Callbacks} interface that does nothing. Used only when this fragment is not attached to an activity.
@@ -105,7 +107,15 @@ public class HomeFragment extends Fragment {
                 HashMap<String, SipCall> calls = (HashMap<String, SipCall>) mCallbacks.getService().getCallList();
                 HashMap<String, Conference> confs = (HashMap<String, Conference>) mCallbacks.getService().getConferenceList();
                 Log.i(TAG, "Call size " + calls.size());
-                access_calls.setText(calls.size() + " on going calls and "+confs.size()+" conferences");
+                nb_calls.setText(""+calls.size());
+                nb_confs.setText(""+confs.size());
+                
+                if(!calls.isEmpty() || !confs.isEmpty()){
+                    access_calls.setVisibility(View.VISIBLE);
+                } else {
+                    access_calls.setVisibility(View.GONE);
+                }
+//                access_calls.setText(calls.size() + " on going calls and "+confs.size()+" conferences");
 
             } catch (RemoteException e) {
                 Log.e(TAG, e.toString());
@@ -153,6 +163,8 @@ public class HomeFragment extends Fragment {
 
         access_calls = (Button) inflatedView.findViewById(R.id.access_callactivity);
 
+        nb_calls = (TextView) inflatedView.findViewById(R.id.calls_counter);
+        nb_confs = (TextView) inflatedView.findViewById(R.id.confs_counter);
         access_calls.setOnClickListener(new OnClickListener() {
 
             @Override
diff --git a/src/com/savoirfairelinux/sflphone/fragments/MenuFragment.java b/src/com/savoirfairelinux/sflphone/fragments/MenuFragment.java
index ccc59f88b..9d1dedcb9 100644
--- a/src/com/savoirfairelinux/sflphone/fragments/MenuFragment.java
+++ b/src/com/savoirfairelinux/sflphone/fragments/MenuFragment.java
@@ -186,7 +186,7 @@ public class MenuFragment extends Fragment implements LoaderCallbacks<ArrayList<
         });
 
         spinnerAccounts = (Spinner) inflatedView.findViewById(R.id.account_selection);
-        mAccountAdapter = new AccountSelectionAdapter(getActivity(), mCallbacks.getService(), new ArrayList<Account>());
+        mAccountAdapter = new AccountSelectionAdapter(getActivity(), new ArrayList<Account>());
         spinnerAccounts.setAdapter(mAccountAdapter);
         spinnerAccounts.setOnItemSelectedListener(new OnItemSelectedListener() {
 
@@ -268,6 +268,7 @@ public class MenuFragment extends Fragment implements LoaderCallbacks<ArrayList<
     public void updateAllAccounts() {
         if (getActivity() != null)
             getActivity().getLoaderManager().restartLoader(LoaderConstants.ACCOUNTS_LOADER, null, this);
+        mAccountAdapter.setSelectedAccount(-1);
 
     }
 
diff --git a/src/com/savoirfairelinux/sflphone/loaders/HistoryLoader.java b/src/com/savoirfairelinux/sflphone/loaders/HistoryLoader.java
index 52120f608..ad33d90d4 100644
--- a/src/com/savoirfairelinux/sflphone/loaders/HistoryLoader.java
+++ b/src/com/savoirfairelinux/sflphone/loaders/HistoryLoader.java
@@ -44,7 +44,7 @@ public class HistoryLoader extends AsyncTaskLoader<ArrayList<HistoryEntry>> {
         }
         try {
             ArrayList<HashMap<String, String>> history = (ArrayList<HashMap<String, String>>) service.getHistory();
-            Log.i(TAG, "history size:" + history.size());
+//            Log.i(TAG, "history size:" + history.size());
             CallContact.ContactBuilder builder = new CallContact.ContactBuilder();
             for (HashMap<String, String> entry : history) {
                 entry.get(ServiceConstants.HISTORY_ACCOUNT_ID_KEY);
@@ -54,7 +54,7 @@ public class HistoryLoader extends AsyncTaskLoader<ArrayList<HistoryEntry>> {
 
                 String number_called = entry.get(ServiceConstants.HISTORY_PEER_NUMBER_KEY);
 
-                Log.w(TAG, "----------------------Record" + entry.get(ServiceConstants.HISTORY_RECORDING_PATH_KEY));
+//                Log.w(TAG, "----------------------Record" + entry.get(ServiceConstants.HISTORY_RECORDING_PATH_KEY));
                 CallContact c = null;
                 if (historyEntries.containsKey(number_called)) {
                     historyEntries.get(number_called).addHistoryCall(
diff --git a/src/com/savoirfairelinux/sflphone/model/Bubble.java b/src/com/savoirfairelinux/sflphone/model/Bubble.java
index 2f2107907..db6133712 100644
--- a/src/com/savoirfairelinux/sflphone/model/Bubble.java
+++ b/src/com/savoirfairelinux/sflphone/model/Bubble.java
@@ -236,7 +236,7 @@ public class Bubble {
     }
 
     /**
-     * When bubble is expanded we need to check on wich action button the user tap
+     * When the bubble is expanded we need to check on wich action button the user tap
      * 
      * @param x
      * @param y
diff --git a/src/com/savoirfairelinux/sflphone/model/BubblesView.java b/src/com/savoirfairelinux/sflphone/model/BubblesView.java
index 235b680fd..845188eb0 100644
--- a/src/com/savoirfairelinux/sflphone/model/BubblesView.java
+++ b/src/com/savoirfairelinux/sflphone/model/BubblesView.java
@@ -285,11 +285,11 @@ public class BubblesView extends SurfaceView implements SurfaceHolder.Callback,
                                 * density), getNamePaint(first_plan));
 
                         canvas.drawText(getResources().getString(first_plan.getHoldStatus()),
-                                (float) (first_plan.getPosX() - first_plan.getRetractedRadius() * 1.5 * density), first_plan.getPosY(),
+                                (float) (first_plan.getPosX() - first_plan.getRetractedRadius() * 1.5 * density - 15), first_plan.getPosY(),
                                 getNamePaint(first_plan));
 
                         canvas.drawText(getResources().getString(first_plan.getRecordStatus()),
-                                (float) (first_plan.getPosX() + first_plan.getRetractedRadius() * 1.5 * density), first_plan.getPosY(),
+                                (float) (first_plan.getPosX() + first_plan.getRetractedRadius() * 1.5 * density + 15), first_plan.getPosY(),
                                 getNamePaint(first_plan));
 
                     }
diff --git a/src/com/savoirfairelinux/sflphone/service/SipService.java b/src/com/savoirfairelinux/sflphone/service/SipService.java
index 1e2a63702..9f5746d18 100644
--- a/src/com/savoirfairelinux/sflphone/service/SipService.java
+++ b/src/com/savoirfairelinux/sflphone/service/SipService.java
@@ -190,14 +190,12 @@ public class SipService extends Service {
 
         public void execute(Runnable task) {
             // TODO: add wakelock
-            Log.w(TAG, "Sending to targeT");
             Message.obtain(this, 0/* don't care */, task).sendToTarget();
             Log.w(TAG, "SenT!");
         }
 
         @Override
         public void handleMessage(Message msg) {
-            Log.w(TAG, "handleMessage");
             if (msg.obj instanceof Runnable) {
                 executeInternal((Runnable) msg.obj);
             } else {
@@ -206,7 +204,6 @@ public class SipService extends Service {
         }
 
         private void executeInternal(Runnable task) {
-            Log.w(TAG, "executeInternal");
             try {
                 task.run();
             } catch (Throwable t) {
@@ -1088,6 +1085,14 @@ public class SipService extends Service {
         @Override
         public Conference getCurrentCall() throws RemoteException {
             for (SipCall i : current_calls.values()) {
+                
+                // Incoming >> Ongoing
+                if(i.isIncoming()){
+                    Conference tmp = new Conference("-1");
+                    tmp.getParticipants().add(i);
+                    return tmp;
+                }
+                
                 if (i.isOngoing()) {
                     Conference tmp = new Conference("-1");
                     tmp.getParticipants().add(i);
diff --git a/src/com/savoirfairelinux/sflphone/views/ClearableEditText.java b/src/com/savoirfairelinux/sflphone/views/ClearableEditText.java
index b8c92c99b..ff1efdb11 100644
--- a/src/com/savoirfairelinux/sflphone/views/ClearableEditText.java
+++ b/src/com/savoirfairelinux/sflphone/views/ClearableEditText.java
@@ -37,6 +37,7 @@ public class ClearableEditText extends RelativeLayout {
         inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
         inflater.inflate(R.layout.clearable_edit_text, this, true);
         edit_text = (EditText) findViewById(R.id.clearable_edit);
+        
         btn_clear = (Button) findViewById(R.id.clearable_button_clear);
         btn_clear.setVisibility(RelativeLayout.INVISIBLE);
         clearText();
@@ -94,4 +95,9 @@ public class ClearableEditText extends RelativeLayout {
     public EditText getEdit_text() {
         return edit_text;
     }
+
+    public void setError(String string) {
+        edit_text.setError(string);  
+        edit_text.requestFocus();
+    }
 }
-- 
GitLab