Make tab widget contain account name text view to avoid animation glitch
Internal Bug: 2153912
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);