summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMichael Kolb <kolby@google.com>2011-01-25 15:55:15 -0800
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-01-25 15:55:15 -0800
commitc33e55b70b3b6be64a7a840b828602c426916424 (patch)
treec41a4da5ebb5333c50631a3b6222c6c5cfa972ad /src
parent570d8144c4e1683bf45376e8c4aca894be915485 (diff)
parent2d59c32ee3fc1ed92d57609998f0430ad7695317 (diff)
downloadpackages_apps_Browser-c33e55b70b3b6be64a7a840b828602c426916424.zip
packages_apps_Browser-c33e55b70b3b6be64a7a840b828602c426916424.tar.gz
packages_apps_Browser-c33e55b70b3b6be64a7a840b828602c426916424.tar.bz2
Merge "add tab bar animations" into honeycomb
Diffstat (limited to 'src')
-rw-r--r--src/com/android/browser/Controller.java5
-rw-r--r--src/com/android/browser/TabBar.java68
2 files changed, 66 insertions, 7 deletions
diff --git a/src/com/android/browser/Controller.java b/src/com/android/browser/Controller.java
index 16c57c6..6113e54 100644
--- a/src/com/android/browser/Controller.java
+++ b/src/com/android/browser/Controller.java
@@ -2192,12 +2192,9 @@ public class Controller
removeComboView();
int currentIndex = mTabControl.getCurrentIndex();
int removeIndex = mTabControl.getTabIndex(tab);
- removeTab(tab);
- if (currentIndex >= removeIndex && currentIndex != 0) {
- currentIndex--;
- }
Tab newtab = mTabControl.getTab(currentIndex);
setActiveTab(newtab);
+ removeTab(tab);
}
/**************** TODO: Url loading clean up *******************************/
diff --git a/src/com/android/browser/TabBar.java b/src/com/android/browser/TabBar.java
index 1ab02ed..301165a 100644
--- a/src/com/android/browser/TabBar.java
+++ b/src/com/android/browser/TabBar.java
@@ -18,6 +18,10 @@ package com.android.browser;
import com.android.browser.ScrollWebView.ScrollListener;
+import android.animation.Animator;
+import android.animation.Animator.AnimatorListener;
+import android.animation.AnimatorSet;
+import android.animation.ObjectAnimator;
import android.app.Activity;
import android.content.Context;
import android.content.res.Resources;
@@ -151,6 +155,7 @@ public class TabBar extends LinearLayout
mTabMap.clear();
for (Tab tab : tabs) {
TabView tv = buildTabView(tab);
+ mTabs.addTab(tv);
}
mTabs.setSelectedTab(mTabControl.getCurrentIndex());
}
@@ -286,7 +291,6 @@ public class TabBar extends LinearLayout
TabView tabview = new TabView(mActivity, tab);
mTabMap.put(tab, tabview);
tabview.setOnClickListener(this);
- mTabs.addTab(tabview);
return tabview;
}
@@ -500,6 +504,62 @@ public class TabBar extends LinearLayout
return d;
}
+ private void animateTabOut(final Tab tab, final TabView tv) {
+ ObjectAnimator scalex = ObjectAnimator.ofFloat(tv, "scaleX", 1.0f, 0.0f);
+ ObjectAnimator scaley = ObjectAnimator.ofFloat(tv, "scaleY", 1.0f, 0.0f);
+ AnimatorSet animator = new AnimatorSet();
+ animator.playTogether(scalex, scaley);
+ animator.setDuration(150);
+ animator.addListener(new AnimatorListener() {
+
+ @Override
+ public void onAnimationCancel(Animator animation) {
+ }
+
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ mTabs.removeTab(tv);
+ mTabMap.remove(tab);
+ }
+
+ @Override
+ public void onAnimationRepeat(Animator animation) {
+ }
+
+ @Override
+ public void onAnimationStart(Animator animation) {
+ }
+
+ });
+ animator.start();
+ }
+
+ private void animateTabIn(final Tab tab, final TabView tv) {
+ ObjectAnimator scalex = ObjectAnimator.ofFloat(tv, "scaleX", 0f, 1.0f);
+ scalex.setDuration(150);
+ scalex.addListener(new AnimatorListener() {
+
+ @Override
+ public void onAnimationCancel(Animator animation) {
+ }
+
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ }
+
+ @Override
+ public void onAnimationRepeat(Animator animation) {
+ }
+
+ @Override
+ public void onAnimationStart(Animator animation) {
+ mTabs.addTab(tv);
+ }
+
+ });
+ scalex.start();
+ }
+
// TabChangeListener implementation
public void onSetActiveTab(Tab tab) {
@@ -526,6 +586,7 @@ public class TabBar extends LinearLayout
public void onNewTab(Tab tab) {
TabView tv = buildTabView(tab);
+ animateTabIn(tab, tv);
}
public void onProgress(Tab tab, int progress) {
@@ -538,9 +599,10 @@ public class TabBar extends LinearLayout
public void onRemoveTab(Tab tab) {
TabView tv = mTabMap.get(tab);
if (tv != null) {
- mTabs.removeTab(tv);
+ animateTabOut(tab, tv);
+ } else {
+ mTabMap.remove(tab);
}
- mTabMap.remove(tab);
}
public void onUrlAndTitle(Tab tab, String url, String title) {