Bug 699492: Animate the tab-list popup [r=mfinkle]
authorSriram Ramasubramanian <sriram@mozilla.com>
Thu, 03 Nov 2011 11:34:58 -0700
changeset 81722 d479ad39237782010f144d4f6254d06e96bef7d3
parent 81721 388c49fba3fd0235071d72d33c8364b7adc677b4
child 81723 40e3d6b1122d5b22d0d8fb733000497869a1548f
push id21573
push userblassey@mozilla.com
push dateTue, 06 Dec 2011 18:57:07 +0000
treeherdermozilla-central@0e397568c71e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle
bugs699492
milestone10.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 699492: Animate the tab-list popup [r=mfinkle]
embedding/android/GeckoApp.java
embedding/android/Makefile.in
embedding/android/TabsTray.java
embedding/android/resources/anim/grow_fade_in.xml
embedding/android/resources/anim/shrink_fade_out.xml
--- a/embedding/android/GeckoApp.java
+++ b/embedding/android/GeckoApp.java
@@ -600,18 +600,19 @@ abstract public class GeckoApp
         Intent intent = new Intent(mAppContext, AwesomeBar.class);
         intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION | Intent.FLAG_ACTIVITY_NO_HISTORY);
         intent.putExtra(AwesomeBar.TYPE_KEY, AwesomeBar.Type.ADD.name());
         startActivityForResult(intent, AWESOMEBAR_REQUEST);
     }
 
     void showTabs() {
         Intent intent = new Intent(mAppContext, TabsTray.class);
-        intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION | Intent.FLAG_ACTIVITY_NO_HISTORY);
+        intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
         startActivity(intent);
+        overridePendingTransition(R.anim.grow_fade_in, 0);
     }
 
     public static void registerOnTabsChangedListener(OnTabsChangedListener listener) {
         if (mTabsChangedListeners == null)
             mTabsChangedListeners = new ArrayList<OnTabsChangedListener>();
         
         mTabsChangedListeners.add(listener);
     }
--- a/embedding/android/Makefile.in
+++ b/embedding/android/Makefile.in
@@ -157,16 +157,21 @@ RES_VALUES = \
   res/values/arrays.xml \
   res/values/colors.xml \
   res/values/styles.xml \
   res/values/themes.xml \
   $(NULL)
 
 RES_XML = res/xml/preferences.xml
 
+RES_ANIM = \
+  res/anim/grow_fade_in.xml \
+  res/anim/shrink_fade_out.xml \
+  $(NULL)
+
 AB_rCD = $(shell echo $(AB_CD) | sed -e s/-/-r/)
 
 JAVA_CLASSPATH = $(ANDROID_SDK)/android.jar
 
 DEFAULT_BRANDPATH = $(DEPTH)/$(MOZ_BRANDING_DIRECTORY)/locales/en-US/brand.dtd
 DEFAULT_STRINGSPATH = locales/en-US/android_strings.dtd
 LOCALIZED_BRANDPATH = $(DEPTH)/dist/bin/chrome/$(AB_CD)/locale/branding/brand.dtd
 LOCALIZED_STRINGSPATH = $(DEPTH)/dist/bin/chrome/android-res/res/values-$(AB_CD)/android_strings.dtd
@@ -269,20 +274,24 @@ RES_DRAWABLE = $(addprefix res/drawable/
 $(RES_VALUES): $(subst res/,$(srcdir)/resources/,$(RES_VALUES))
 	$(NSINSTALL) -D res/values
 	$(NSINSTALL) $^  res/values
 
 $(RES_XML): $(subst res/,$(srcdir)/resources/,$(RES_XML))
 	$(NSINSTALL) -D res/xml
 	$(NSINSTALL) $(srcdir)/resources/xml/* res/xml/
 
-R.java: $(MOZ_APP_ICON) $(RES_LAYOUT) $(RES_DRAWABLE) $(RES_VALUES) $(RES_XML) res/drawable/icon.png res/drawable-hdpi/icon.png res/values/strings.xml AndroidManifest.xml
+$(RES_ANIM)): $(subst res/,$(srcdir)/resources/,$(RES_ANIM))
+	$(NSINSTALL) -D res/anim
+	$(NSINSTALL) $(srcdir)/resources/anim/* res/anim/
+
+R.java: $(MOZ_APP_ICON) $(RES_LAYOUT) $(RES_DRAWABLE) $(RES_VALUES) $(RES_XML) $(RES_ANIM) res/drawable/icon.png res/drawable-hdpi/icon.png res/values/strings.xml AndroidManifest.xml
 	$(AAPT) package -f -M AndroidManifest.xml -I $(ANDROID_SDK)/android.jar -S res -J . --custom-package org.mozilla.gecko
 
-gecko.ap_: AndroidManifest.xml res/drawable/icon.png res/drawable-hdpi/icon.png $(RES_LAYOUT) $(RES_DRAWABLE) $(RES_VALUES) $(RES_XML) res/values/strings.xml FORCE
+gecko.ap_: AndroidManifest.xml res/drawable/icon.png res/drawable-hdpi/icon.png $(RES_LAYOUT) $(RES_DRAWABLE) $(RES_VALUES) $(RES_XML) $(RES_ANIM) res/values/strings.xml FORCE
 	$(AAPT) package -f -M AndroidManifest.xml -I $(ANDROID_SDK)/android.jar  -S res -F $@
 
 res/values/strings.xml: $(DEFAULT_BRANDPATH) $(DEFAULT_STRINGSPATH) $(srcdir)/strings.xml.in
 	mkdir -p res/values
 	$(PYTHON) $(topsrcdir)/config/Preprocessor.py $(DEFINES) \
 	  -DBRANDPATH="$(DEFAULT_BRANDPATH)" \
 	  -DSTRINGSPATH="$(DEFAULT_STRINGSPATH)" \
 	  $(srcdir)/strings.xml.in \
--- a/embedding/android/TabsTray.java
+++ b/embedding/android/TabsTray.java
@@ -73,52 +73,57 @@ public class TabsTray extends Activity i
         setContentView(R.layout.tabs_tray);
 
         mList = (ListView) findViewById(R.id.list);
 
         LinearLayout addTab = (LinearLayout) findViewById(R.id.add_tab);
         addTab.setOnClickListener(new Button.OnClickListener() {
             public void onClick(View v) {
                 GeckoApp.mAppContext.addTab();
-                finish();
+                finishActivity();
             }
         });
 
         // Adding a native divider for the add-tab
         LinearLayout lastDivider = new LinearLayout(this);
         lastDivider.setOrientation(LinearLayout.HORIZONTAL);
         lastDivider.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, mList.getDividerHeight()));
         lastDivider.setBackgroundDrawable(mList.getDivider());
         addTab.addView(lastDivider, 0);
         
         LinearLayout container = (LinearLayout) findViewById(R.id.container);
         container.setOnClickListener(new Button.OnClickListener() {
             public void onClick(View v) {
-                finish();
+                finishActivity();
             }
         });
 
         GeckoApp.registerOnTabsChangedListener(this);
         onTabsChanged();
     }
 
     @Override
     public void onDestroy() {
         super.onDestroy();
         GeckoApp.unregisterOnTabsChangedListener(this);
     } 
    
     public void onTabsChanged() {
         if (Tabs.getInstance().getCount() == 1)
-            finish();
+            finishActivity();
 
         mTabsAdapter = new TabsAdapter(this, Tabs.getInstance().getTabsInOrder());
         mList.setAdapter(mTabsAdapter);
     }
 
+    void finishActivity() {
+        finish();
+        overridePendingTransition(0, R.anim.shrink_fade_out);
+    }
+
     // Adapter to bind tabs into a list 
     private class TabsAdapter extends BaseAdapter {
 	public TabsAdapter(Context context, ArrayList<Tab> tabs) {
             mContext = context;
             mTabs = new ArrayList<Tab>();
             for (int i = 0; i < tabs.size(); i++) {
                 mTabs.add(tabs.get(i));
             }
@@ -148,17 +153,17 @@ public class TabsTray extends Activity i
             
             Tab tab = mTabs.get(position);
 
             RelativeLayout info = (RelativeLayout) convertView.findViewById(R.id.info);
             info.setTag("" + tab.getId());
             info.setOnClickListener(new View.OnClickListener() {
                 public void onClick(View v) {
                     GeckoAppShell.sendEventToGecko(new GeckoEvent("Tab:Select", "" + v.getTag()));
-                    finish();
+                    finishActivity();
                 }
             });
 
             ImageView favicon = (ImageView) convertView.findViewById(R.id.favicon);
 
             Drawable faviconImage = tab.getFavicon();
             if (faviconImage != null)
                 favicon.setImageDrawable(faviconImage);
new file mode 100644
--- /dev/null
+++ b/embedding/android/resources/anim/grow_fade_in.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="utf-8"?>
+<set xmlns:android="http://schemas.android.com/apk/res/android">
+
+    <scale android:fromXScale="1.0"
+           android:toXScale="1.0"
+           android:fromYScale="0.3"
+           android:toYScale="1.0"
+           android:pivotX="0%"
+           android:pivotY="0%"
+           android:duration="150"/>
+
+    <alpha android:interpolator="@android:anim/decelerate_interpolator"
+           android:fromAlpha="0.0"
+           android:toAlpha="1.0"
+           android:duration="150"/>
+
+</set>
new file mode 100644
--- /dev/null
+++ b/embedding/android/resources/anim/shrink_fade_out.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="utf-8"?>
+<set xmlns:android="http://schemas.android.com/apk/res/android">
+
+    <scale android:fromXScale="1.0"
+           android:toXScale="1.0"
+           android:fromYScale="1.0"
+           android:toYScale="0.3"
+           android:pivotX="0%"
+           android:pivotY="0%"
+           android:duration="150"/>
+
+    <alpha android:interpolator="@android:anim/accelerate_interpolator"
+           android:fromAlpha="1.0"
+           android:toAlpha="0.0"
+           android:duration="150"/>
+
+</set>