Merge "Add the search button in CallLog/Favorites"
diff --git a/res/layout/contact_tile_regular.xml b/res/layout/contact_tile_square.xml
similarity index 96%
rename from res/layout/contact_tile_regular.xml
rename to res/layout/contact_tile_square.xml
index 0c02318..ca79cef 100644
--- a/res/layout/contact_tile_regular.xml
+++ b/res/layout/contact_tile_square.xml
@@ -15,7 +15,7 @@
 -->
 <view
     xmlns:android="http://schemas.android.com/apk/res/android"
-    class="com.android.contacts.list.ContactTileView"
+    class="com.android.contacts.list.ContactTileSquareView"
     android:focusable="true"
     android:padding="1px"
     android:background="@drawable/list_selector" >
diff --git a/src/com/android/contacts/activities/PeopleActivity.java b/src/com/android/contacts/activities/PeopleActivity.java
index e373a6b..0bec6cc 100644
--- a/src/com/android/contacts/activities/PeopleActivity.java
+++ b/src/com/android/contacts/activities/PeopleActivity.java
@@ -350,7 +350,7 @@
     private void setSelectedTab(TabState tab) {
         mSelectedTab = tab;
 
-        if (mFrequentFragment != null) {
+        if (mContentPaneDisplayed) {
             switch (mSelectedTab) {
                 case FAVORITES:
                     mFavoritesView.setVisibility(View.VISIBLE);
@@ -492,10 +492,13 @@
     public void onAction(Action action) {
         switch (action) {
             case START_SEARCH_MODE:
+                // Checking if multi fragments are being displayed
+                if (mContentPaneDisplayed) {
+                    mFavoritesView.setVisibility(View.GONE);
+                    mBrowserView.setVisibility(View.VISIBLE);
+                    mDetailsView.setVisibility(View.VISIBLE);
+                }
                 // Bring the contact list fragment (and detail fragment if applicable) to the front
-                mFavoritesView.setVisibility(View.GONE);
-                mBrowserView.setVisibility(View.VISIBLE);
-                mDetailsView.setVisibility(View.VISIBLE);
                 FragmentTransaction ft = getFragmentManager().beginTransaction();
                 ft.show(mContactsFragment);
                 if (mContactDetailFragment != null) ft.show(mContactDetailFragment);
diff --git a/src/com/android/contacts/list/ContactTileAdapter.java b/src/com/android/contacts/list/ContactTileAdapter.java
index 86f6b33..5d5e6cb 100644
--- a/src/com/android/contacts/list/ContactTileAdapter.java
+++ b/src/com/android/contacts/list/ContactTileAdapter.java
@@ -40,7 +40,7 @@
  * Also allows for a configurable number of columns and {@link DisplayType}
  */
 public class ContactTileAdapter extends BaseAdapter {
-    private static final String TAG = "ContactTileAdapter";
+    private static final String TAG = ContactTileAdapter.class.getSimpleName();
 
     /**
      * mContacts2 is only used if {@link DisplayType} is Strequent
@@ -292,7 +292,7 @@
         int columnCount = -1;
 
         switch (itemViewType) {
-            case ViewTypes.REGULAR:
+            case ViewTypes.SQUARE:
                 if (contactTileRowView == null) {
                     // Creating new row if needed
                     contactTileRowView = new ContactTileRow(mContext, layoutResId, true);
@@ -327,8 +327,8 @@
 
     private int getLayoutResourceId(int viewType) {
         switch (viewType) {
-            case ViewTypes.REGULAR:
-                return R.layout.contact_tile_regular;
+            case ViewTypes.SQUARE:
+                return R.layout.contact_tile_square;
             case ViewTypes.SINGLE_ROW:
                 return R.layout.contact_tile_single;
             default:
@@ -343,8 +343,8 @@
     /**
      * Returns view type based on {@link DisplayType}.
      * {@link DisplayType#STARRED_ONLY} and {@link DisplayType#GROUP_MEMBERS}
-     * are {@link ViewTypes#REGULAR}.
-     * {@link DisplayType#FREQUENT_ONLY} is {@link ViewTypes#SMALL}.
+     * are {@link ViewTypes#SQUARE}.
+     * {@link DisplayType#FREQUENT_ONLY} is {@link ViewTypes#SINGLE_ROW}.
      * {@link DisplayType#STREQUENT} mixes both {@link ViewTypes}
      * and also adds in {@link ViewTypes#DIVIDER}.
      */
@@ -353,7 +353,7 @@
         switch (mDisplayType) {
             case STREQUENT:
                 if (position < mDividerRowIndex) {
-                    return ViewTypes.REGULAR;
+                    return ViewTypes.SQUARE;
                 } else if (position == mDividerRowIndex) {
                     return ViewTypes.DIVIDER;
                 } else {
@@ -361,7 +361,7 @@
                 }
             case STARRED_ONLY:
             case GROUP_MEMBERS:
-                return ViewTypes.REGULAR;
+                return ViewTypes.SQUARE;
             case FREQUENT_ONLY:
                 return ViewTypes.SINGLE_ROW;
             default:
@@ -399,8 +399,11 @@
             ContactTileView contactTile;
 
             if (getChildCount() <= tileIndex) {
-                contactTile = (ContactTileView) inflate(mContext, mLayoutResId, null);
-                contactTile.setIsSquare(mIsContactTileSquare);
+                if (mIsContactTileSquare) {
+                    contactTile = (ContactTileSquareView) inflate(mContext, mLayoutResId, null);
+                } else {
+                    contactTile = (ContactTileView) inflate(mContext, mLayoutResId, null);
+                }
                 contactTile.setLayoutParams(new LinearLayout.LayoutParams(0,
                         LinearLayout.LayoutParams.WRAP_CONTENT, 1.0f));
                 contactTile.setPhotoManager(mPhotoManager);
@@ -430,7 +433,7 @@
 
     private static class ViewTypes {
         public static final int COUNT = 3;
-        public static final int REGULAR = 0;
+        public static final int SQUARE = 0;
         public static final int DIVIDER = 1;
         public static final int SINGLE_ROW = 2;
     }
diff --git a/src/com/android/contacts/list/ContactTileSquareView.java b/src/com/android/contacts/list/ContactTileSquareView.java
new file mode 100644
index 0000000..7716481
--- /dev/null
+++ b/src/com/android/contacts/list/ContactTileSquareView.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.contacts.list;
+
+import android.content.Context;
+import android.util.AttributeSet;
+
+/**
+ * A ContactTileSquare displays the contact's picture overlayed with their name
+ * in a perfect square.
+ */
+public class ContactTileSquareView extends ContactTileView {
+    private final static String TAG = ContactTileSquareView.class.getSimpleName();
+
+    public ContactTileSquareView(Context context, AttributeSet attrs) {
+        super(context, attrs);
+    }
+
+    @Override
+    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+        // Getting how much space is currently available and telling our
+        // Children to split it.
+        int width = getDefaultSize(getSuggestedMinimumWidth(), widthMeasureSpec);
+        int childMeasureSpec = MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY);
+        measureChildren(childMeasureSpec, childMeasureSpec);
+        setMeasuredDimension(width, width);
+    }
+}
diff --git a/src/com/android/contacts/list/ContactTileView.java b/src/com/android/contacts/list/ContactTileView.java
index 883e3f0..ad711cf 100644
--- a/src/com/android/contacts/list/ContactTileView.java
+++ b/src/com/android/contacts/list/ContactTileView.java
@@ -32,21 +32,12 @@
  * A ContactTile displays the contact's picture overlayed with their name
  */
 public class ContactTileView extends FrameLayout {
-    private final static String TAG = "ContactTileView";
+    private final static String TAG = ContactTileView.class.getSimpleName();
 
-    /**
-     * This divides into the width to define the height when
-     * {link DisplayTypes@SINLGE_ROW} is true.
-     */
-    private final static int HEIGHT_RATIO = 5;
     private Uri mLookupUri;
     private ImageView mPhoto;
     private TextView mName;
     private ContactPhotoManager mPhotoManager = null;
-    /**
-     * Is set to true if the {@link ContactTileView} is a square.
-     */
-    private boolean mIsSquare;
 
     public ContactTileView(Context context, AttributeSet attrs) {
         super(context, attrs);
@@ -59,18 +50,14 @@
         mPhoto = (ImageView) findViewById(R.id.contact_tile_image);
     }
 
-    public boolean isSquare() {
-        return mIsSquare;
-    }
-
-    public void setIsSquare(boolean isSquare) {
-        mIsSquare = isSquare;
-    }
-
     public void setPhotoManager(ContactPhotoManager photoManager) {
         mPhotoManager = photoManager;
     }
 
+    /**
+     * Populates the data members to be displayed from the
+     * fields in {@link ContactEntry}
+     */
     public void loadFromContact(ContactEntry entry) {
         if (entry != null) {
             mName.setText(entry.name);
@@ -91,14 +78,4 @@
     public Uri getLookupUri() {
         return mLookupUri;
     }
-
-    @Override
-    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
-        // Getting how much space is currently available and telling our
-        // Children to split it.
-        int width = getDefaultSize(getSuggestedMinimumWidth(), widthMeasureSpec);
-        int childMeasureSpec = MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY);
-        measureChildren(childMeasureSpec, childMeasureSpec);
-        setMeasuredDimension(width, width / (mIsSquare ? 1 : HEIGHT_RATIO));
-    }
 }
diff --git a/src/com/android/contacts/vcard/ExportProcessor.java b/src/com/android/contacts/vcard/ExportProcessor.java
index e9697d3..6dc2c34 100644
--- a/src/com/android/contacts/vcard/ExportProcessor.java
+++ b/src/com/android/contacts/vcard/ExportProcessor.java
@@ -237,7 +237,7 @@
         final Notification notification =
                 VCardService.constructProgressNotification(mService, VCardService.TYPE_EXPORT,
                         description, tickerText, mJobId, displayName, totalCount, currentCount);
-        mNotificationManager.notify(mJobId, notification);
+        mNotificationManager.notify(VCardService.DEFAULT_NOTIFICATION_TAG, mJobId, notification);
     }
 
     private void doCancelNotification() {
@@ -246,7 +246,7 @@
                 mExportRequest.destUri.getLastPathSegment());
         final Notification notification =
                 VCardService.constructCancelNotification(mService, description);
-        mNotificationManager.notify(mJobId, notification);
+        mNotificationManager.notify(VCardService.DEFAULT_NOTIFICATION_TAG, mJobId, notification);
     }
 
     private void doFinishNotification(final String title, final String description) {
@@ -254,7 +254,7 @@
         final Intent intent = new Intent(mService, PeopleActivity.class);
         final Notification notification =
                 VCardService.constructFinishNotification(mService, title, description, intent);
-        mNotificationManager.notify(mJobId, notification);
+        mNotificationManager.notify(VCardService.DEFAULT_NOTIFICATION_TAG, mJobId, notification);
     }
 
     @Override
diff --git a/src/com/android/contacts/vcard/ImportProcessor.java b/src/com/android/contacts/vcard/ImportProcessor.java
index 4ea1ead..1f5779a 100644
--- a/src/com/android/contacts/vcard/ImportProcessor.java
+++ b/src/com/android/contacts/vcard/ImportProcessor.java
@@ -180,7 +180,7 @@
                 mImportRequest.originalUri.getLastPathSegment());
         final Notification notification =
                 VCardService.constructCancelNotification(mService, description);
-        mNotificationManager.notify(mJobId, notification);
+        mNotificationManager.notify(VCardService.DEFAULT_NOTIFICATION_TAG, mJobId, notification);
     }
 
     private void doFinishNotification(final Uri createdUri) {
@@ -199,7 +199,7 @@
         final Notification notification =
                    VCardService.constructFinishNotification(mService,
                            description, null, intent);
-        mNotificationManager.notify(mJobId, notification);
+        mNotificationManager.notify(VCardService.DEFAULT_NOTIFICATION_TAG, mJobId, notification);
     }
 
     private boolean readOneVCard(Uri uri, int vcardType, String charset,
diff --git a/src/com/android/contacts/vcard/ImportProgressNotifier.java b/src/com/android/contacts/vcard/ImportProgressNotifier.java
index d6d0f3f..698487d 100644
--- a/src/com/android/contacts/vcard/ImportProgressNotifier.java
+++ b/src/com/android/contacts/vcard/ImportProgressNotifier.java
@@ -71,7 +71,7 @@
         final Notification notification = VCardService.constructProgressNotification(
                 mContext.getApplicationContext(), VCardService.TYPE_IMPORT, description, tickerText,
                 mJobId, mDisplayName, mTotalCount, mCurrentCount);
-        mNotificationManager.notify(mJobId, notification);
+        mNotificationManager.notify(VCardService.DEFAULT_NOTIFICATION_TAG, mJobId, notification);
     }
 
     public synchronized void addTotalCount(int additionalCount) {
diff --git a/src/com/android/contacts/vcard/ImportVCardActivity.java b/src/com/android/contacts/vcard/ImportVCardActivity.java
index 1397dd7..2cfd71a 100644
--- a/src/com/android/contacts/vcard/ImportVCardActivity.java
+++ b/src/com/android/contacts/vcard/ImportVCardActivity.java
@@ -107,7 +107,7 @@
     /**
      * Notification id used when error happened before sending an import request to VCardServer.
      */
-    private static final int DEFAULT_NOTIFICATION_ID = 1000;
+    private static final int FAILURE_NOTIFICATION_ID = 1;
 
     final static String CACHED_URIS = "cached_uris";
 
@@ -974,7 +974,8 @@
                 VCardService.constructImportFailureNotification(
                         ImportVCardActivity.this,
                         getString(reasonId));
-        notificationManager.notify(DEFAULT_NOTIFICATION_ID, notification);
+        notificationManager.notify(VCardService.FAILURE_NOTIFICATION_TAG, FAILURE_NOTIFICATION_ID,
+                notification);
         mHandler.post(new Runnable() {
             @Override
             public void run() {
diff --git a/src/com/android/contacts/vcard/VCardService.java b/src/com/android/contacts/vcard/VCardService.java
index e927757..261c1c8 100644
--- a/src/com/android/contacts/vcard/VCardService.java
+++ b/src/com/android/contacts/vcard/VCardService.java
@@ -59,6 +59,17 @@
 // works fine enough. Investigate the feasibility.
 public class VCardService extends Service {
     private final static String LOG_TAG = "VCardService";
+
+    /** The tag used by vCard-related notifications. */
+    /* package */ static final String DEFAULT_NOTIFICATION_TAG = "VCardServiceProgress";
+    /**
+     * The tag used by vCard-related failure notifications.
+     * <p>
+     * Use a different tag from {@link #DEFAULT_NOTIFICATION_TAG} so that failures do not get
+     * replaced by other notifications and vice-versa.
+     */
+    /* package */ static final String FAILURE_NOTIFICATION_TAG = "VCardServiceFailure";
+
     /* package */ final static boolean DEBUG = false;
 
     /* package */ static final int MSG_IMPORT_REQUEST = 1;
@@ -153,6 +164,7 @@
     /* ** vCard exporter params ** */
     // If true, VCardExporter is able to emits files longer than 8.3 format.
     private static final boolean ALLOW_LONG_FILE_NAME = false;
+
     private String mTargetDirectory;
     private String mFileNamePrefix;
     private String mFileNameSuffix;
@@ -258,7 +270,8 @@
                         constructProgressNotification(
                                 this, TYPE_IMPORT, message, message, mCurrentJobId,
                                 displayName, -1, 0);
-                mNotificationManager.notify(mCurrentJobId, notification);
+                mNotificationManager.notify(VCardService.DEFAULT_NOTIFICATION_TAG, mCurrentJobId,
+                        notification);
                 mCurrentJobId++;
             } else {
                 // TODO: a little unkind to show Toast in this case, which is shown just a moment.
@@ -292,7 +305,7 @@
             final Notification notification =
                     constructProgressNotification(this, TYPE_EXPORT, message, message,
                             mCurrentJobId, displayName, -1, 0);
-            mNotificationManager.notify(mCurrentJobId, notification);
+            mNotificationManager.notify(VCardService.DEFAULT_NOTIFICATION_TAG, mCurrentJobId, notification);
             mCurrentJobId++;
         } else {
             Toast.makeText(this, getString(R.string.vcard_export_request_rejected_message),
@@ -330,7 +343,7 @@
                     getString(R.string.importing_vcard_canceled_title, request.displayName) :
                             getString(R.string.exporting_vcard_canceled_title, request.displayName);
             final Notification notification = constructCancelNotification(this, description);
-            mNotificationManager.notify(jobId, notification);
+            mNotificationManager.notify(VCardService.DEFAULT_NOTIFICATION_TAG, jobId, notification);
             if (processor.getType() == TYPE_EXPORT) {
                 final String path =
                         ((ExportProcessor)processor).getRequest().destUri.getEncodedPath();