Make tab widget contain account name text view to avoid animation glitch

Internal Bug: 2153912
diff --git a/res/layout-finger/contact_card_layout.xml b/res/layout-finger/contact_card_layout.xml
index fe931ec..3f090f5 100644
--- a/res/layout-finger/contact_card_layout.xml
+++ b/res/layout-finger/contact_card_layout.xml
@@ -36,16 +36,6 @@
             android:layout_width="fill_parent"
             android:layout_height="wrap_content"/>
         
-        <TextView android:id="@+id/account_name"
-            style="?android:attr/listSeparatorTextViewStyle"
-            android:textColor="@*android:color/dim_foreground_dark"
-            android:textSize="12sp"
-            android:textStyle="normal"
-            android:background="@drawable/section_dark"
-            android:paddingLeft="7dp"
-            android:gravity="left|center_vertical"
-            android:visibility="gone" />
-
         <FrameLayout android:id="@android:id/tabcontent"
             android:layout_width="fill_parent"
             android:layout_height="0dip"
diff --git a/res/layout-finger/tab_account_name.xml b/res/layout-finger/tab_account_name.xml
new file mode 100644
index 0000000..c9e1745
--- /dev/null
+++ b/res/layout-finger/tab_account_name.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2009 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.
+-->
+
+<!-- looks like Widget.TextView.ListSeparator -->
+<TextView  xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/account_name"
+    android:background="@drawable/section_dark"
+    android:layout_width="fill_parent"
+    android:layout_height="@dimen/account_name_height"
+    android:layout_below="@+id/tab_scroll_view"
+    android:textStyle="normal"
+    android:textColor="@*android:color/dim_foreground_dark"
+    android:textSize="12sp"
+    android:gravity="left|center_vertical"
+    android:paddingLeft="7dip"
+/>
diff --git a/res/layout-finger/tab_layout.xml b/res/layout-finger/tab_layout.xml
index 23359b7..9a793c3 100644
--- a/res/layout-finger/tab_layout.xml
+++ b/res/layout-finger/tab_layout.xml
@@ -15,6 +15,7 @@
 -->
 
 <HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/tab_scroll_view"
     android:layout_width="fill_parent"
     android:layout_height="wrap_content"
     android:layout_alignParentLeft="true"
diff --git a/res/layout/act_edit.xml b/res/layout/act_edit.xml
index 47f1454..250a0e1 100644
--- a/res/layout/act_edit.xml
+++ b/res/layout/act_edit.xml
@@ -37,16 +37,6 @@
             android:layout_width="fill_parent"
             android:layout_height="wrap_content" />
 
-        <TextView android:id="@+id/account_name"
-            style="?android:attr/listSeparatorTextViewStyle"
-            android:textColor="@*android:color/dim_foreground_dark"
-            android:textSize="12sp"
-            android:textStyle="normal"
-            android:background="@drawable/section_dark"
-            android:paddingLeft="7dp"
-            android:gravity="left|center_vertical"
-            android:visibility="gone" />
-        
         <include
             android:id="@android:id/tabcontent"
             android:layout_width="fill_parent"
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 0742250..4361fd4 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -20,4 +20,5 @@
         
     <!-- The height of the ScrollingTabWidget -->
     <dimen name="tab_height">40dip</dimen>
+    <dimen name="account_name_height">25dip</dimen>
 </resources>
diff --git a/src/com/android/contacts/ScrollingTabWidget.java b/src/com/android/contacts/ScrollingTabWidget.java
index 6974a6e..b45abe4 100644
--- a/src/com/android/contacts/ScrollingTabWidget.java
+++ b/src/com/android/contacts/ScrollingTabWidget.java
@@ -18,12 +18,7 @@
 
 import android.content.Context;
 import android.graphics.Canvas;
-import android.graphics.Rect;
-import android.graphics.drawable.Drawable;
-import android.os.Bundle;
 import android.util.AttributeSet;
-import android.util.Log;
-import android.view.KeyEvent;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
@@ -32,7 +27,6 @@
 import android.view.View.OnFocusChangeListener;
 import android.widget.HorizontalScrollView;
 import android.widget.ImageView;
-import android.widget.LinearLayout;
 import android.widget.RelativeLayout;
 
 /*
@@ -82,6 +76,7 @@
         mTabsScrollWrapper = (HorizontalScrollView) mInflater.inflate(
                 R.layout.tab_layout, this, false);
         mTabsView = (TabStripView) mTabsScrollWrapper.findViewById(android.R.id.tabs);
+        View accountNameView = mInflater.inflate(R.layout.tab_account_name, this, false);
 
         mLeftArrowView.setVisibility(View.INVISIBLE);
         mRightArrowView.setVisibility(View.INVISIBLE);
@@ -89,6 +84,7 @@
         addView(mTabsScrollWrapper);
         addView(mLeftArrowView);
         addView(mRightArrowView);
+        addView(accountNameView);
     }
 
     @Override
diff --git a/src/com/android/contacts/ViewContactActivity.java b/src/com/android/contacts/ViewContactActivity.java
index b1910d6..a0f7061 100644
--- a/src/com/android/contacts/ViewContactActivity.java
+++ b/src/com/android/contacts/ViewContactActivity.java
@@ -215,9 +215,9 @@
         mTabWidget.setTabSelectionListener(this);
         mTabWidget.setVisibility(View.GONE);
         mTabsVisible = false;
+        mAccountName = (TextView) mTabWidget.findViewById(R.id.account_name);
 
         mBelowHeader = findViewById(R.id.below_header);
-        mAccountName = (TextView) findViewById(R.id.account_name);
 
         mTabRawContactIdMap = new SparseArray<Long>();
 
@@ -397,12 +397,14 @@
             return;
         }
 
-        float tabHeight = getResources().getDimension(R.dimen.tab_height);
+        final Resources resources = getResources();
+        final float tabHeight = resources.getDimension(R.dimen.tab_height)
+            + resources.getDimension(R.dimen.account_name_height);
         if (show) {
             TranslateAnimation showAnimation = new TranslateAnimation(
                     Animation.ABSOLUTE, 0, Animation.ABSOLUTE, 0,
                     Animation.ABSOLUTE, -tabHeight, Animation.ABSOLUTE, 0);
-            showAnimation.setDuration(getResources().getInteger(
+            showAnimation.setDuration(resources.getInteger(
                     android.R.integer.config_longAnimTime));
 
             showAnimation.setAnimationListener(new AnimationListener() {
@@ -428,7 +430,7 @@
             TranslateAnimation hideTabsAnimation = new TranslateAnimation(
                     Animation.ABSOLUTE, 0, Animation.ABSOLUTE, 0,
                     Animation.ABSOLUTE, 0, Animation.ABSOLUTE, -tabHeight);
-            hideTabsAnimation.setDuration(getResources().getInteger(
+            hideTabsAnimation.setDuration(resources.getInteger(
                     android.R.integer.config_longAnimTime));
             hideTabsAnimation.setAnimationListener(new AnimationListener() {
                 public void onAnimationEnd(Animation animation) {
@@ -446,7 +448,7 @@
             TranslateAnimation hideListAnimation = new TranslateAnimation(
                     Animation.ABSOLUTE, 0, Animation.ABSOLUTE, 0,
                     Animation.ABSOLUTE, tabHeight, Animation.ABSOLUTE, 0);
-            hideListAnimation.setDuration(getResources().getInteger(
+            hideListAnimation.setDuration(resources.getInteger(
                     android.R.integer.config_longAnimTime));
 
 
@@ -945,13 +947,8 @@
                     continue;
                 }
 
-                if (mTabsVisible) {
-                    final String accountName = entValues.getAsString(RawContacts.ACCOUNT_NAME);
-                    mAccountName.setText(getString(R.string.account_name_format, accountName));
-                    mAccountName.setVisibility(View.VISIBLE);
-                } else {
-                    mAccountName.setVisibility(View.GONE);
-                }
+                final String accountName = entValues.getAsString(RawContacts.ACCOUNT_NAME);
+                mAccountName.setText(getString(R.string.account_name_format, accountName));
 
                 for (NamedContentValues subValue : entity.getSubValues()) {
                     ViewEntry entry = new ViewEntry();
diff --git a/src/com/android/contacts/ui/EditContactActivity.java b/src/com/android/contacts/ui/EditContactActivity.java
index 238c3b3..9290b96 100644
--- a/src/com/android/contacts/ui/EditContactActivity.java
+++ b/src/com/android/contacts/ui/EditContactActivity.java
@@ -126,7 +126,7 @@
 
         mTabWidget = (ScrollingTabWidget)this.findViewById(R.id.tab_widget);
         mTabWidget.setTabSelectionListener(this);
-        mAccountName = (TextView)this.findViewById(R.id.account_name);
+        mAccountName = (TextView)mTabWidget.findViewById(R.id.account_name);
 
         // Build editor and listen for photo requests
         mEditor = (ContactEditorView)this.findViewById(android.R.id.tabcontent);
@@ -403,7 +403,6 @@
                 ContactsSource.LEVEL_CONSTRAINTS);
 
         mAccountName.setText(getString(R.string.account_name_format, accountName));
-        mAccountName.setVisibility(View.VISIBLE);
 
         // Assign editor state based on entity and source
         mEditor.setState(entity, source);