Merge "Add the HTML5Audio class, to support the audio tag. The corresponding webkit C++ CL is https://android-git.corp.google.com/g/#change,41405"
diff --git a/api/current.xml b/api/current.xml
index 347fc01..8951b3a 100644
--- a/api/current.xml
+++ b/api/current.xml
@@ -19355,6 +19355,19 @@
 <parameter name="ev" type="android.view.MotionEvent">
 </parameter>
 </method>
+<method name="findFragmentById"
+ return="android.app.Fragment"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="id" type="int">
+</parameter>
+</method>
 <method name="findViewById"
  return="android.view.View"
  abstract="false"
@@ -20494,6 +20507,8 @@
  deprecated="not deprecated"
  visibility="public"
 >
+<parameter name="name" type="java.lang.String">
+</parameter>
 </method>
 <method name="registerForContextMenu"
  return="void"
@@ -24841,16 +24856,6 @@
  visibility="public"
 >
 </constructor>
-<constructor name="Fragment"
- type="android.app.Fragment"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<parameter name="name" type="java.lang.String">
-</parameter>
-</constructor>
 <method name="getActivity"
  return="android.app.Activity"
  abstract="false"
@@ -24862,17 +24867,6 @@
  visibility="public"
 >
 </method>
-<method name="getName"
- return="java.lang.String"
- abstract="false"
- native="false"
- synchronized="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-</method>
 <method name="onAttach"
  return="void"
  abstract="false"
@@ -24912,6 +24906,21 @@
 <parameter name="savedInstanceState" type="android.os.Bundle">
 </parameter>
 </method>
+<method name="onCreateAnimation"
+ return="android.view.animation.Animation"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="transit" type="int">
+</parameter>
+<parameter name="enter" type="boolean">
+</parameter>
+</method>
 <method name="onCreateView"
  return="android.view.View"
  abstract="false"
@@ -25076,8 +25085,6 @@
 >
 <parameter name="fragment" type="android.app.Fragment">
 </parameter>
-<parameter name="containerViewId" type="int">
-</parameter>
 </method>
 <method name="add"
  return="android.app.FragmentTransaction"
@@ -25091,8 +25098,6 @@
 >
 <parameter name="fragment" type="android.app.Fragment">
 </parameter>
-<parameter name="name" type="java.lang.String">
-</parameter>
 <parameter name="containerViewId" type="int">
 </parameter>
 </method>
@@ -25106,6 +25111,8 @@
  deprecated="not deprecated"
  visibility="public"
 >
+<parameter name="name" type="java.lang.String">
+</parameter>
 </method>
 <method name="commit"
  return="void"
@@ -25131,6 +25138,256 @@
 <parameter name="fragment" type="android.app.Fragment">
 </parameter>
 </method>
+<method name="replace"
+ return="android.app.FragmentTransaction"
+ abstract="true"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="fragment" type="android.app.Fragment">
+</parameter>
+<parameter name="containerViewId" type="int">
+</parameter>
+</method>
+<method name="setTransition"
+ return="android.app.FragmentTransaction"
+ abstract="true"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="transit" type="int">
+</parameter>
+</method>
+<method name="setTransitionStyle"
+ return="android.app.FragmentTransaction"
+ abstract="true"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="styleRes" type="int">
+</parameter>
+</method>
+<field name="TRANSIT_ACTIVITY_CLOSE"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="8199"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="TRANSIT_ACTIVITY_OPEN"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="4102"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="TRANSIT_ENTER"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="4097"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="TRANSIT_ENTER_MASK"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="4096"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="TRANSIT_EXIT"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="8194"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="TRANSIT_EXIT_MASK"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="8192"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="TRANSIT_HIDE"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="8196"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="TRANSIT_NONE"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="0"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="TRANSIT_PREVIEW_DONE"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="5"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="TRANSIT_SHOW"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="4099"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="TRANSIT_TASK_CLOSE"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="8201"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="TRANSIT_TASK_OPEN"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="4104"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="TRANSIT_TASK_TO_BACK"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="8203"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="TRANSIT_TASK_TO_FRONT"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="4106"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="TRANSIT_UNSET"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="-1"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="TRANSIT_WALLPAPER_CLOSE"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="8204"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="TRANSIT_WALLPAPER_INTRA_CLOSE"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="8207"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="TRANSIT_WALLPAPER_INTRA_OPEN"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="4110"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="TRANSIT_WALLPAPER_OPEN"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="4109"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 </interface>
 <class name="Instrumentation"
  extends="java.lang.Object"
diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java
index 6ffc451..5cb8f89 100644
--- a/core/java/android/app/Activity.java
+++ b/core/java/android/app/Activity.java
@@ -665,20 +665,20 @@
             Runnable, BackStackState {
         ArrayList<Fragment> mAdded;
         ArrayList<Fragment> mRemoved;
+        int mTransition;
+        int mTransitionStyle;
         boolean mAddToBackStack;
+        String mName;
         boolean mCommitted;
         
-        public FragmentTransaction add(Fragment fragment, int containerViewId) {
-            return add(fragment, null, containerViewId);
+        public FragmentTransaction add(Fragment fragment) {
+            return add(fragment, 0);
         }
 
-        public FragmentTransaction add(Fragment fragment, String name, int containerViewId) {
+        public FragmentTransaction add(Fragment fragment, int containerViewId) {
             if (fragment.mActivity != null) {
                 throw new IllegalStateException("Fragment already added: " + fragment);
             }
-            if (name != null) {
-                fragment.mName = name;
-            }
             if (mRemoved != null) {
                 mRemoved.remove(fragment);
             }
@@ -690,6 +690,21 @@
             return this;
         }
 
+        public FragmentTransaction replace(Fragment fragment, int containerViewId) {
+            if (containerViewId == 0) {
+                throw new IllegalArgumentException("Must use non-zero containerViewId");
+            }
+            if (mFragments.mFragments != null) {
+                for (int i=0; i<mFragments.mFragments.size(); i++) {
+                    Fragment old = mFragments.mFragments.get(i);
+                    if (old.mContainerId == containerViewId) {
+                        remove(old);
+                    }
+                }
+            }
+            return add(fragment, containerViewId);
+        }
+        
         public FragmentTransaction remove(Fragment fragment) {
             if (fragment.mActivity == null) {
                 throw new IllegalStateException("Fragment not added: " + fragment);
@@ -704,8 +719,19 @@
             return this;
         }
 
-        public FragmentTransaction addToBackStack() {
+        public FragmentTransaction setTransition(int transition) {
+            mTransition = transition;
+            return this;
+        }
+        
+        public FragmentTransaction setTransitionStyle(int styleRes) {
+            mTransitionStyle = styleRes;
+            return this;
+        }
+        
+        public FragmentTransaction addToBackStack(String name) {
             mAddToBackStack = true;
+            mName = name;
             return this;
         }
 
@@ -718,15 +744,21 @@
         public void run() {
             if (mRemoved != null) {
                 for (int i=mRemoved.size()-1; i>=0; i--) {
-                    mFragments.removeFragment(mRemoved.get(i));
+                    mFragments.removeFragment(mRemoved.get(i), mTransition,
+                            mTransitionStyle);
                 }
             }
             if (mAdded != null) {
                 for (int i=mAdded.size()-1; i>=0; i--) {
-                    mFragments.addFragment(mAdded.get(i), false);
+                    Fragment f = mAdded.get(i);
+                    mFragments.addFragment(f, false);
+                    if (mAddToBackStack) {
+                        f.mBackStackNesting++;
+                    }
                 }
             }
-            mFragments.moveToState(mFragments.mCurState, true);
+            mFragments.moveToState(mFragments.mCurState, mTransition,
+                    mTransitionStyle, true);
             if (mAddToBackStack) {
                 mFragments.addBackStackState(this);
             }
@@ -735,7 +767,13 @@
         public void popFromBackStack() {
             if (mAdded != null) {
                 for (int i=mAdded.size()-1; i>=0; i--) {
-                    mFragments.removeFragment(mAdded.get(i));
+                    Fragment f = mAdded.get(i);
+                    if (mAddToBackStack) {
+                        f.mBackStackNesting--;
+                    }
+                    mFragments.removeFragment(f,
+                            FragmentManager.reverseTransit(mTransition),
+                            mTransitionStyle);
                 }
             }
             if (mRemoved != null) {
@@ -743,7 +781,18 @@
                     mFragments.addFragment(mRemoved.get(i), false);
                 }
             }
-            mFragments.moveToState(mFragments.mCurState, true);
+        }
+        
+        public String getName() {
+            return mName;
+        }
+        
+        public int getTransition() {
+            return mTransition;
+        }
+        
+        public int getTransitionStyle() {
+            return mTransitionStyle;
         }
     }
     
@@ -1744,6 +1793,16 @@
     }
 
     /**
+     * Finds a fragment that was identified by the given id either when inflated
+     * from XML or as the container ID when added in a transaction.  This only
+     * returns fragments that are currently added to the activity's content.
+     * @return The fragment if found or null otherwise.
+     */
+    public Fragment findFragmentById(int id) {
+        return mFragments.findFragmentById(id);
+    }
+    
+    /**
      * Set the activity content from a layout resource.  The resource will be
      * inflated, adding all top-level views to the activity.
      * 
@@ -2010,9 +2069,12 @@
     /**
      * Pop the last fragment transition from the local activity's fragment
      * back stack.  If there is nothing to pop, false is returned.
+     * @param name If non-null, this is the name of a previous back state
+     * to look for; if found, all states up to (but not including) that
+     * state will be popped.  If null, only the top state is popped.
      */
-    public boolean popBackStack() {
-        return mFragments.popBackStackState(mHandler);
+    public boolean popBackStack(String name) {
+        return mFragments.popBackStackState(mHandler, name);
     }
     
     /**
@@ -2021,7 +2083,7 @@
      * but you can override this to do whatever you want.
      */
     public void onBackPressed() {
-        if (!popBackStack()) {
+        if (!popBackStack(null)) {
             finish();
         }
     }
diff --git a/core/java/android/app/Fragment.java b/core/java/android/app/Fragment.java
index a9ef654..c5e9e6f 100644
--- a/core/java/android/app/Fragment.java
+++ b/core/java/android/app/Fragment.java
@@ -24,6 +24,7 @@
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
+import android.view.animation.Animation;
 
 /**
  * A Fragment is a piece of an application's user interface or behavior
@@ -35,9 +36,8 @@
     static final int STARTED = 2;       // Created and started, not resumed.
     static final int RESUMED = 3;       // Created started and resumed.
     
-    String mName;
-    
     int mState = INITIALIZING;
+    int mBackStackNesting;
     Activity mActivity;
     
     boolean mCalled;
@@ -49,14 +49,6 @@
     public Fragment() {
     }
     
-    public Fragment(String name) {
-        mName = name;
-    }
-    
-    public String getName() {
-        return mName;
-    }
-    
     public Activity getActivity() {
         return mActivity;
     }
@@ -69,6 +61,10 @@
         mCalled = true;
     }
     
+    public Animation onCreateAnimation(int transit, boolean enter) {
+        return null;
+    }
+    
     public void onCreate(Bundle savedInstanceState) {
         mCalled = true;
     }
diff --git a/core/java/android/app/FragmentManager.java b/core/java/android/app/FragmentManager.java
index aa99a92..9a4580e 100644
--- a/core/java/android/app/FragmentManager.java
+++ b/core/java/android/app/FragmentManager.java
@@ -16,27 +16,69 @@
 
 package android.app;
 
+import android.content.res.TypedArray;
 import android.os.Bundle;
 import android.os.Handler;
 import android.view.ViewGroup;
+import android.view.animation.Animation;
+import android.view.animation.AnimationUtils;
 
 import java.util.ArrayList;
 
 interface BackStackState {
     public void popFromBackStack();
+    public String getName();
+    public int getTransition();
+    public int getTransitionStyle();
 }
 
 /**
+ * @hide
  * Container for fragments associated with an activity.
  */
-class FragmentManager {
+public class FragmentManager {
     ArrayList<Fragment> mFragments;
     ArrayList<BackStackState> mBackStack;
     
     int mCurState = Fragment.INITIALIZING;
     Activity mActivity;
     
-    void moveToState(Fragment f, int newState) {
+    Animation loadAnimation(Fragment fragment, int transit, boolean enter,
+            int transitionStyle) {
+        Animation animObj = fragment.onCreateAnimation(transitionStyle, enter);
+        if (animObj != null) {
+            return animObj;
+        }
+        
+        if (transit == 0) {
+            return null;
+        }
+        
+        int styleIndex = transitToStyleIndex(transit, enter);
+        if (styleIndex < 0) {
+            return null;
+        }
+        
+        if (transitionStyle == 0 && mActivity.getWindow() != null) {
+            transitionStyle = mActivity.getWindow().getAttributes().windowAnimations;
+        }
+        if (transitionStyle == 0) {
+            return null;
+        }
+        
+        TypedArray attrs = mActivity.obtainStyledAttributes(transitionStyle,
+                com.android.internal.R.styleable.WindowAnimation);
+        int anim = attrs.getResourceId(styleIndex, 0);
+        attrs.recycle();
+        
+        if (anim == 0) {
+            return null;
+        }
+        
+        return AnimationUtils.loadAnimation(mActivity, anim);
+    }
+    
+    void moveToState(Fragment f, int newState, int transit, int transitionStyle) {
         if (f.mState < newState) {
             switch (f.mState) {
                 case Fragment.INITIALIZING:
@@ -66,6 +108,10 @@
                     f.mContainer = container;
                     f.mView = f.onCreateView(mActivity.getLayoutInflater(), container);
                     if (container != null && f.mView != null) {
+                        Animation anim = loadAnimation(f, transit, true, transitionStyle);
+                        if (anim != null) {
+                            f.mView.setAnimation(anim);
+                        }
                         container.addView(f.mView);
                     }
                     
@@ -110,7 +156,11 @@
                     }
                 case Fragment.CREATED:
                     if (newState < Fragment.CREATED) {
-                        if (f.mContainer != null && f.mView != null) {
+                        if (f.mContainer != null) {
+                            Animation anim = loadAnimation(f, transit, false, transitionStyle);
+                            if (anim != null) {
+                                f.mView.setAnimation(anim);
+                            }
                             f.mContainer.removeView(f.mView);
                         }
                         f.mContainer = null;
@@ -137,6 +187,10 @@
     }
     
     void moveToState(int newState, boolean always) {
+        moveToState(newState, 0, 0, always);
+    }
+    
+    void moveToState(int newState, int transit, int transitStyle, boolean always) {
         if (mActivity == null && newState != Fragment.INITIALIZING) {
             throw new IllegalStateException("No activity");
         }
@@ -149,7 +203,7 @@
         if (mFragments != null) {
             for (int i=0; i<mFragments.size(); i++) {
                 Fragment f = mFragments.get(i);
-                moveToState(f, newState);
+                moveToState(f, newState, transit, transitStyle);
             }
         }
     }
@@ -160,13 +214,25 @@
         }
         mFragments.add(fragment);
         if (moveToStateNow) {
-            moveToState(fragment, mCurState);
+            moveToState(fragment, mCurState, 0, 0);
         }
     }
     
-    public void removeFragment(Fragment fragment) {
+    public void removeFragment(Fragment fragment, int transition, int transitionStyle) {
         mFragments.remove(fragment);
-        moveToState(fragment, Fragment.INITIALIZING);
+        moveToState(fragment, Fragment.INITIALIZING, transition, transitionStyle);
+    }
+    
+    public Fragment findFragmentById(int id) {
+        if (mFragments != null) {
+            for (int i=mFragments.size()-1; i>=0; i--) {
+                Fragment f = mFragments.get(i);
+                if (f.mContainerId == id) {
+                    return f;
+                }
+            }
+        }
+        return null;
     }
     
     public void addBackStackState(BackStackState state) {
@@ -176,20 +242,47 @@
         mBackStack.add(state);
     }
     
-    public boolean popBackStackState(Handler handler) {
+    public boolean popBackStackState(Handler handler, String name) {
         if (mBackStack == null) {
             return false;
         }
-        int last = mBackStack.size()-1;
-        if (last < 0) {
-            return false;
-        }
-        final BackStackState bss = mBackStack.remove(last);
-        handler.post(new Runnable() {
-            public void run() {
-                bss.popFromBackStack();
+        if (name == null) {
+            int last = mBackStack.size()-1;
+            if (last < 0) {
+                return false;
             }
-        });
+            final BackStackState bss = mBackStack.remove(last);
+            handler.post(new Runnable() {
+                public void run() {
+                    bss.popFromBackStack();
+                    moveToState(mCurState, reverseTransit(bss.getTransition()),
+                            bss.getTransitionStyle(), true);
+                }
+            });
+        } else {
+            int index = mBackStack.size()-1;
+            while (index >= 0) {
+                BackStackState bss = mBackStack.get(index);
+                if (name.equals(bss.getName())) {
+                    break;
+                }
+            }
+            if (index < 0 || index == mBackStack.size()-1) {
+                return false;
+            }
+            final ArrayList<BackStackState> states = new ArrayList<BackStackState>();
+            for (int i=mBackStack.size()-1; i>index; i--) {
+                states.add(mBackStack.remove(i));
+            }
+            handler.post(new Runnable() {
+                public void run() {
+                    for (int i=0; i<states.size(); i++) {
+                        states.get(i).popFromBackStack();
+                    }
+                    moveToState(mCurState, true);
+                }
+            });
+        }
         return true;
     }
     
@@ -222,4 +315,123 @@
         moveToState(Fragment.INITIALIZING, false);
         mActivity = null;
     }
+    
+    public static int reverseTransit(int transit) {
+        int rev = 0;
+        switch (transit) {
+            case FragmentTransaction.TRANSIT_ENTER:
+                rev = FragmentTransaction.TRANSIT_EXIT;
+                break;
+            case FragmentTransaction.TRANSIT_EXIT:
+                rev = FragmentTransaction.TRANSIT_ENTER;
+                break;
+            case FragmentTransaction.TRANSIT_SHOW:
+                rev = FragmentTransaction.TRANSIT_HIDE;
+                break;
+            case FragmentTransaction.TRANSIT_HIDE:
+                rev = FragmentTransaction.TRANSIT_SHOW;
+                break;
+            case FragmentTransaction.TRANSIT_ACTIVITY_OPEN:
+                rev = FragmentTransaction.TRANSIT_ACTIVITY_CLOSE;
+                break;
+            case FragmentTransaction.TRANSIT_ACTIVITY_CLOSE:
+                rev = FragmentTransaction.TRANSIT_ACTIVITY_OPEN;
+                break;
+            case FragmentTransaction.TRANSIT_TASK_OPEN:
+                rev = FragmentTransaction.TRANSIT_TASK_CLOSE;
+                break;
+            case FragmentTransaction.TRANSIT_TASK_CLOSE:
+                rev = FragmentTransaction.TRANSIT_TASK_OPEN;
+                break;
+            case FragmentTransaction.TRANSIT_TASK_TO_FRONT:
+                rev = FragmentTransaction.TRANSIT_TASK_TO_BACK;
+                break;
+            case FragmentTransaction.TRANSIT_TASK_TO_BACK:
+                rev = FragmentTransaction.TRANSIT_TASK_TO_FRONT;
+                break;
+            case FragmentTransaction.TRANSIT_WALLPAPER_OPEN:
+                rev = FragmentTransaction.TRANSIT_WALLPAPER_CLOSE;
+                break;
+            case FragmentTransaction.TRANSIT_WALLPAPER_CLOSE:
+                rev = FragmentTransaction.TRANSIT_WALLPAPER_OPEN;
+                break;
+            case FragmentTransaction.TRANSIT_WALLPAPER_INTRA_OPEN:
+                rev = FragmentTransaction.TRANSIT_WALLPAPER_INTRA_CLOSE;
+                break;
+            case FragmentTransaction.TRANSIT_WALLPAPER_INTRA_CLOSE:
+                rev = FragmentTransaction.TRANSIT_WALLPAPER_INTRA_OPEN;
+                break;
+        }
+        return rev;
+        
+    }
+    
+    public static int transitToStyleIndex(int transit, boolean enter) {
+        int animAttr = -1;
+        switch (transit) {
+            case FragmentTransaction.TRANSIT_ENTER:
+                animAttr = com.android.internal.R.styleable.WindowAnimation_windowEnterAnimation;
+                break;
+            case FragmentTransaction.TRANSIT_EXIT:
+                animAttr = com.android.internal.R.styleable.WindowAnimation_windowExitAnimation;
+                break;
+            case FragmentTransaction.TRANSIT_SHOW:
+                animAttr = com.android.internal.R.styleable.WindowAnimation_windowShowAnimation;
+                break;
+            case FragmentTransaction.TRANSIT_HIDE:
+                animAttr = com.android.internal.R.styleable.WindowAnimation_windowHideAnimation;
+                break;
+            case FragmentTransaction.TRANSIT_ACTIVITY_OPEN:
+                animAttr = enter
+                        ? com.android.internal.R.styleable.WindowAnimation_activityOpenEnterAnimation
+                        : com.android.internal.R.styleable.WindowAnimation_activityOpenExitAnimation;
+                break;
+            case FragmentTransaction.TRANSIT_ACTIVITY_CLOSE:
+                animAttr = enter
+                        ? com.android.internal.R.styleable.WindowAnimation_activityCloseEnterAnimation
+                        : com.android.internal.R.styleable.WindowAnimation_activityCloseExitAnimation;
+                break;
+            case FragmentTransaction.TRANSIT_TASK_OPEN:
+                animAttr = enter
+                        ? com.android.internal.R.styleable.WindowAnimation_taskOpenEnterAnimation
+                        : com.android.internal.R.styleable.WindowAnimation_taskOpenExitAnimation;
+                break;
+            case FragmentTransaction.TRANSIT_TASK_CLOSE:
+                animAttr = enter
+                        ? com.android.internal.R.styleable.WindowAnimation_taskCloseEnterAnimation
+                        : com.android.internal.R.styleable.WindowAnimation_taskCloseExitAnimation;
+                break;
+            case FragmentTransaction.TRANSIT_TASK_TO_FRONT:
+                animAttr = enter
+                        ? com.android.internal.R.styleable.WindowAnimation_taskToFrontEnterAnimation
+                        : com.android.internal.R.styleable.WindowAnimation_taskToFrontExitAnimation;
+                break;
+            case FragmentTransaction.TRANSIT_TASK_TO_BACK:
+                animAttr = enter
+                        ? com.android.internal.R.styleable.WindowAnimation_taskToBackEnterAnimation
+                        : com.android.internal.R.styleable.WindowAnimation_taskToBackExitAnimation;
+                break;
+            case FragmentTransaction.TRANSIT_WALLPAPER_OPEN:
+                animAttr = enter
+                        ? com.android.internal.R.styleable.WindowAnimation_wallpaperOpenEnterAnimation
+                        : com.android.internal.R.styleable.WindowAnimation_wallpaperOpenExitAnimation;
+                break;
+            case FragmentTransaction.TRANSIT_WALLPAPER_CLOSE:
+                animAttr = enter
+                        ? com.android.internal.R.styleable.WindowAnimation_wallpaperCloseEnterAnimation
+                        : com.android.internal.R.styleable.WindowAnimation_wallpaperCloseExitAnimation;
+                break;
+            case FragmentTransaction.TRANSIT_WALLPAPER_INTRA_OPEN:
+                animAttr = enter
+                        ? com.android.internal.R.styleable.WindowAnimation_wallpaperIntraOpenEnterAnimation
+                        : com.android.internal.R.styleable.WindowAnimation_wallpaperIntraOpenExitAnimation;
+                break;
+            case FragmentTransaction.TRANSIT_WALLPAPER_INTRA_CLOSE:
+                animAttr = enter
+                        ? com.android.internal.R.styleable.WindowAnimation_wallpaperIntraCloseEnterAnimation
+                        : com.android.internal.R.styleable.WindowAnimation_wallpaperIntraCloseExitAnimation;
+                break;
+        }
+        return animAttr;
+    }
 }
diff --git a/core/java/android/app/FragmentTransaction.java b/core/java/android/app/FragmentTransaction.java
index 8ca8364..94d3b88 100644
--- a/core/java/android/app/FragmentTransaction.java
+++ b/core/java/android/app/FragmentTransaction.java
@@ -4,9 +4,69 @@
  * API for performing a set of Fragment operations.
  */
 public interface FragmentTransaction {
+    public FragmentTransaction add(Fragment fragment);
     public FragmentTransaction add(Fragment fragment, int containerViewId);
-    public FragmentTransaction add(Fragment fragment, String name, int containerViewId);
+    public FragmentTransaction replace(Fragment fragment, int containerViewId);
     public FragmentTransaction remove(Fragment fragment);
-    public FragmentTransaction addToBackStack();
+    
+    /**
+     * Bit mask that is set for all enter transition.
+     */
+    public final int TRANSIT_ENTER_MASK = 0x1000;
+    
+    /**
+     * Bit mask that is set for all exit transitions.
+     */
+    public final int TRANSIT_EXIT_MASK = 0x2000;
+    
+    /** Not set up for a transition. */
+    public final int TRANSIT_UNSET = -1;
+    /** No animation for transition. */
+    public final int TRANSIT_NONE = 0;
+    /** Window has been added to the screen. */
+    public final int TRANSIT_ENTER = 1 | TRANSIT_ENTER_MASK;
+    /** Window has been removed from the screen. */
+    public final int TRANSIT_EXIT = 2 | TRANSIT_EXIT_MASK;
+    /** Window has been made visible. */
+    public final int TRANSIT_SHOW = 3 | TRANSIT_ENTER_MASK;
+    /** Window has been made invisible. */
+    public final int TRANSIT_HIDE = 4 | TRANSIT_EXIT_MASK;
+    /** The "application starting" preview window is no longer needed, and will
+     * animate away to show the real window. */
+    public final int TRANSIT_PREVIEW_DONE = 5;
+    /** A window in a new activity is being opened on top of an existing one
+     * in the same task. */
+    public final int TRANSIT_ACTIVITY_OPEN = 6 | TRANSIT_ENTER_MASK;
+    /** The window in the top-most activity is being closed to reveal the
+     * previous activity in the same task. */
+    public final int TRANSIT_ACTIVITY_CLOSE = 7 | TRANSIT_EXIT_MASK;
+    /** A window in a new task is being opened on top of an existing one
+     * in another activity's task. */
+    public final int TRANSIT_TASK_OPEN = 8 | TRANSIT_ENTER_MASK;
+    /** A window in the top-most activity is being closed to reveal the
+     * previous activity in a different task. */
+    public final int TRANSIT_TASK_CLOSE = 9 | TRANSIT_EXIT_MASK;
+    /** A window in an existing task is being displayed on top of an existing one
+     * in another activity's task. */
+    public final int TRANSIT_TASK_TO_FRONT = 10 | TRANSIT_ENTER_MASK;
+    /** A window in an existing task is being put below all other tasks. */
+    public final int TRANSIT_TASK_TO_BACK = 11 | TRANSIT_EXIT_MASK;
+    /** A window in a new activity that doesn't have a wallpaper is being
+     * opened on top of one that does, effectively closing the wallpaper. */
+    public final int TRANSIT_WALLPAPER_CLOSE = 12 | TRANSIT_EXIT_MASK;
+    /** A window in a new activity that does have a wallpaper is being
+     * opened on one that didn't, effectively opening the wallpaper. */
+    public final int TRANSIT_WALLPAPER_OPEN = 13 | TRANSIT_ENTER_MASK;
+    /** A window in a new activity is being opened on top of an existing one,
+     * and both are on top of the wallpaper. */
+    public final int TRANSIT_WALLPAPER_INTRA_OPEN = 14 | TRANSIT_ENTER_MASK;
+    /** The window in the top-most activity is being closed to reveal the
+     * previous activity, and both are on top of he wallpaper. */
+    public final int TRANSIT_WALLPAPER_INTRA_CLOSE = 15 | TRANSIT_EXIT_MASK;
+    
+    public FragmentTransaction setTransition(int transit);
+    public FragmentTransaction setTransitionStyle(int styleRes);
+    
+    public FragmentTransaction addToBackStack(String name);
     public void commit();
 }