Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9ff82bf2 authored by Chet Haase's avatar Chet Haase
Browse files

Adding next/prev to fragment animations and to PreferenceActivity

Adding a new concept of "next" and "previous" to fragment.s Previously, fragments would
either be placed onto or taken off of the stack, or would just replace the current
fragment. The new next/prev capability gives the ability to run a transition that is
specific to next/previous operations, such as navigating forward and backward in a list.
New next/prev animations may be associated with a fragment replace operation to get the
next/prev animations built into the system (next animates things up, prev animates them
down).

Change-Id: Ia9f3663bac009376420d845b396ac51b8e4d1647
parent 10bc3652
Loading
Loading
Loading
Loading
+98 −30
Original line number Diff line number Diff line
@@ -2103,7 +2103,7 @@
 type="int"
 transient="false"
 volatile="false"
 value="16843563"
 value="16843567"
 static="true"
 final="true"
 deprecated="not deprecated"
@@ -2125,7 +2125,7 @@
 type="int"
 transient="false"
 volatile="false"
 value="16843572"
 value="16843576"
 static="true"
 final="true"
 deprecated="not deprecated"
@@ -2136,7 +2136,7 @@
 type="int"
 transient="false"
 volatile="false"
 value="16843571"
 value="16843575"
 static="true"
 final="true"
 deprecated="not deprecated"
@@ -2147,7 +2147,7 @@
 type="int"
 transient="false"
 volatile="false"
 value="16843573"
 value="16843577"
 static="true"
 final="true"
 deprecated="not deprecated"
@@ -2191,7 +2191,7 @@
 type="int"
 transient="false"
 volatile="false"
 value="16843580"
 value="16843584"
 static="true"
 final="true"
 deprecated="not deprecated"
@@ -2213,7 +2213,7 @@
 type="int"
 transient="false"
 volatile="false"
 value="16843576"
 value="16843580"
 static="true"
 final="true"
 deprecated="not deprecated"
@@ -2235,7 +2235,7 @@
 type="int"
 transient="false"
 volatile="false"
 value="16843574"
 value="16843578"
 static="true"
 final="true"
 deprecated="not deprecated"
@@ -2246,7 +2246,7 @@
 type="int"
 transient="false"
 volatile="false"
 value="16843581"
 value="16843585"
 static="true"
 final="true"
 deprecated="not deprecated"
@@ -2257,7 +2257,7 @@
 type="int"
 transient="false"
 volatile="false"
 value="16843582"
 value="16843586"
 static="true"
 final="true"
 deprecated="not deprecated"
@@ -2466,7 +2466,7 @@
 type="int"
 transient="false"
 volatile="false"
 value="16843570"
 value="16843574"
 static="true"
 final="true"
 deprecated="not deprecated"
@@ -2807,7 +2807,7 @@
 type="int"
 transient="false"
 volatile="false"
 value="16843589"
 value="16843593"
 static="true"
 final="true"
 deprecated="not deprecated"
@@ -2818,7 +2818,7 @@
 type="int"
 transient="false"
 volatile="false"
 value="16843588"
 value="16843592"
 static="true"
 final="true"
 deprecated="not deprecated"
@@ -4497,6 +4497,28 @@
 visibility="public"
>
</field>
<field name="fragmentNextEnterAnimation"
 type="int"
 transient="false"
 volatile="false"
 value="16843563"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="fragmentNextExitAnimation"
 type="int"
 transient="false"
 volatile="false"
 value="16843564"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="fragmentOpenEnterAnimation"
 type="int"
 transient="false"
@@ -4519,6 +4541,28 @@
 visibility="public"
>
</field>
<field name="fragmentPrevEnterAnimation"
 type="int"
 transient="false"
 volatile="false"
 value="16843565"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="fragmentPrevExitAnimation"
 type="int"
 transient="false"
 volatile="false"
 value="16843566"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="freezesText"
 type="int"
 transient="false"
@@ -4996,7 +5040,7 @@
 type="int"
 transient="false"
 volatile="false"
 value="16843579"
 value="16843583"
 static="true"
 final="true"
 deprecated="not deprecated"
@@ -5117,7 +5161,7 @@
 type="int"
 transient="false"
 volatile="false"
 value="16843566"
 value="16843570"
 static="true"
 final="true"
 deprecated="not deprecated"
@@ -5128,7 +5172,7 @@
 type="int"
 transient="false"
 volatile="false"
 value="16843564"
 value="16843568"
 static="true"
 final="true"
 deprecated="not deprecated"
@@ -5139,7 +5183,7 @@
 type="int"
 transient="false"
 volatile="false"
 value="16843565"
 value="16843569"
 static="true"
 final="true"
 deprecated="not deprecated"
@@ -5502,7 +5546,7 @@
 type="int"
 transient="false"
 volatile="false"
 value="16843575"
 value="16843579"
 static="true"
 final="true"
 deprecated="not deprecated"
@@ -6778,7 +6822,7 @@
 type="int"
 transient="false"
 volatile="false"
 value="16843568"
 value="16843572"
 static="true"
 final="true"
 deprecated="not deprecated"
@@ -6822,7 +6866,7 @@
 type="int"
 transient="false"
 volatile="false"
 value="16843590"
 value="16843594"
 static="true"
 final="true"
 deprecated="not deprecated"
@@ -6833,7 +6877,7 @@
 type="int"
 transient="false"
 volatile="false"
 value="16843584"
 value="16843588"
 static="true"
 final="true"
 deprecated="not deprecated"
@@ -6921,7 +6965,7 @@
 type="int"
 transient="false"
 volatile="false"
 value="16843592"
 value="16843596"
 static="true"
 final="true"
 deprecated="not deprecated"
@@ -7735,7 +7779,7 @@
 type="int"
 transient="false"
 volatile="false"
 value="16843585"
 value="16843589"
 static="true"
 final="true"
 deprecated="not deprecated"
@@ -9044,7 +9088,7 @@
 type="int"
 transient="false"
 volatile="false"
 value="16843569"
 value="16843573"
 static="true"
 final="true"
 deprecated="not deprecated"
@@ -9066,7 +9110,7 @@
 type="int"
 transient="false"
 volatile="false"
 value="16843567"
 value="16843571"
 static="true"
 final="true"
 deprecated="not deprecated"
@@ -9165,7 +9209,7 @@
 type="int"
 transient="false"
 volatile="false"
 value="16843583"
 value="16843587"
 static="true"
 final="true"
 deprecated="not deprecated"
@@ -9396,7 +9440,7 @@
 type="int"
 transient="false"
 volatile="false"
 value="16843578"
 value="16843582"
 static="true"
 final="true"
 deprecated="not deprecated"
@@ -9781,7 +9825,7 @@
 type="int"
 transient="false"
 volatile="false"
 value="16843586"
 value="16843590"
 static="true"
 final="true"
 deprecated="not deprecated"
@@ -9858,7 +9902,7 @@
 type="int"
 transient="false"
 volatile="false"
 value="16843587"
 value="16843591"
 static="true"
 final="true"
 deprecated="not deprecated"
@@ -9902,7 +9946,7 @@
 type="int"
 transient="false"
 volatile="false"
 value="16843591"
 value="16843595"
 static="true"
 final="true"
 deprecated="not deprecated"
@@ -10320,7 +10364,7 @@
 type="int"
 transient="false"
 volatile="false"
 value="16843577"
 value="16843581"
 static="true"
 final="true"
 deprecated="not deprecated"
@@ -30872,6 +30916,17 @@
 visibility="public"
>
</field>
<field name="TRANSIT_FRAGMENT_NEXT"
 type="int"
 transient="false"
 volatile="false"
 value="4099"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="TRANSIT_FRAGMENT_OPEN"
 type="int"
 transient="false"
@@ -30883,6 +30938,17 @@
 visibility="public"
>
</field>
<field name="TRANSIT_FRAGMENT_PREV"
 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"
@@ -143262,6 +143328,8 @@
</parameter>
<parameter name="args" type="android.os.Bundle">
</parameter>
<parameter name="next" type="boolean">
</parameter>
</method>
<field name="EXTRA_NO_HEADERS"
 type="java.lang.String"
+16 −0
Original line number Diff line number Diff line
@@ -1380,6 +1380,12 @@ final class FragmentManagerImpl implements FragmentManager {
            case FragmentTransaction.TRANSIT_FRAGMENT_CLOSE:
                rev = FragmentTransaction.TRANSIT_FRAGMENT_OPEN;
                break;
            case FragmentTransaction.TRANSIT_FRAGMENT_NEXT:
                rev = FragmentTransaction.TRANSIT_FRAGMENT_PREV;
                break;
            case FragmentTransaction.TRANSIT_FRAGMENT_PREV:
                rev = FragmentTransaction.TRANSIT_FRAGMENT_NEXT;
                break;
        }
        return rev;
        
@@ -1398,6 +1404,16 @@ final class FragmentManagerImpl implements FragmentManager {
                    ? com.android.internal.R.styleable.FragmentAnimation_fragmentCloseEnterAnimation
                    : com.android.internal.R.styleable.FragmentAnimation_fragmentCloseExitAnimation;
                break;
            case FragmentTransaction.TRANSIT_FRAGMENT_NEXT:
                animAttr = enter
                    ? com.android.internal.R.styleable.FragmentAnimation_fragmentNextEnterAnimation
                    : com.android.internal.R.styleable.FragmentAnimation_fragmentNextExitAnimation;
                break;
            case FragmentTransaction.TRANSIT_FRAGMENT_PREV:
                animAttr = enter
                    ? com.android.internal.R.styleable.FragmentAnimation_fragmentPrevEnterAnimation
                    : com.android.internal.R.styleable.FragmentAnimation_fragmentPrevExitAnimation;
                break;
        }
        return animAttr;
    }
+6 −2
Original line number Diff line number Diff line
@@ -106,10 +106,14 @@ public interface FragmentTransaction {
    public final int TRANSIT_UNSET = -1;
    /** No animation for transition. */
    public final int TRANSIT_NONE = 0;
    /** Fragment is being added */
    /** Fragment is being added onto the stack */
    public final int TRANSIT_FRAGMENT_OPEN = 1 | TRANSIT_ENTER_MASK;
    /** Fragment is being removed */
    /** Fragment is being removed from the stack */
    public final int TRANSIT_FRAGMENT_CLOSE = 2 | TRANSIT_EXIT_MASK;
    /** Fragment is being added in a 'next' operation*/
    public final int TRANSIT_FRAGMENT_NEXT = 3 | TRANSIT_ENTER_MASK;
    /** Fragment is being removed in a 'previous' operation */
    public final int TRANSIT_FRAGMENT_PREV = 4 | TRANSIT_EXIT_MASK;

    /**
     * Set specific animation resources to run for the fragments that are
+14 −5
Original line number Diff line number Diff line
@@ -893,11 +893,15 @@ public abstract class PreferenceActivity extends ListActivity implements
        }
    }

    public void switchToHeaderInner(String fragmentName, Bundle args) {
    public void switchToHeaderInner(String fragmentName, Bundle args, boolean next) {
        getFragmentManager().popBackStack(BACK_STACK_PREFS, POP_BACK_STACK_INCLUSIVE);
        Fragment f = Fragment.instantiate(this, fragmentName, args);
        getFragmentManager().openTransaction().replace(
                com.android.internal.R.id.prefs, f).commit();
        FragmentTransaction transaction = getFragmentManager().openTransaction();
        transaction.setTransition(next ?
                FragmentTransaction.TRANSIT_FRAGMENT_NEXT :
                FragmentTransaction.TRANSIT_FRAGMENT_PREV);
        transaction.replace(com.android.internal.R.id.prefs, f);
        transaction.commit();
    }

    /**
@@ -909,7 +913,7 @@ public abstract class PreferenceActivity extends ListActivity implements
     */
    public void switchToHeader(String fragmentName, Bundle args) {
        setSelectedHeader(null);
        switchToHeaderInner(fragmentName, args);
        switchToHeaderInner(fragmentName, args, true);
    }

    /**
@@ -919,7 +923,8 @@ public abstract class PreferenceActivity extends ListActivity implements
     * @param header The new header to display.
     */
    public void switchToHeader(Header header) {
        switchToHeaderInner(header.fragment, header.fragmentArguments);
        switchToHeaderInner(header.fragment, header.fragmentArguments,
                mHeaders.indexOf(header) > mHeaders.indexOf(mCurHeader));
        setSelectedHeader(header);
    }

@@ -979,7 +984,10 @@ public abstract class PreferenceActivity extends ListActivity implements
        FragmentTransaction transaction = getFragmentManager().openTransaction();
        startPreferenceFragment(fragment, transaction);
        if (push) {
            transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
            transaction.addToBackStack(BACK_STACK_PREFS);
        } else {
            transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_NEXT);
        }
        transaction.commit();
    }
@@ -1001,6 +1009,7 @@ public abstract class PreferenceActivity extends ListActivity implements
        FragmentTransaction transaction = getFragmentManager().openTransaction();
        startPreferenceFragment(f, transaction);
        transaction.setBreadCrumbTitle(pref.getTitle());
        transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
        transaction.addToBackStack(BACK_STACK_PREFS);
        transaction.commit();
        return true;
+0 −14
Original line number Diff line number Diff line
@@ -17,20 +17,6 @@
*/
-->
<set xmlns:android="http://schemas.android.com/apk/res/android">
    <objectAnimator
        android:interpolator="@anim/decelerate_interpolator"
        android:valueFrom="2"
        android:valueTo="1"
        android:valueType="floatType"
        android:propertyName="scaleX"
        android:duration="@android:integer/config_mediumAnimTime"/>
    <objectAnimator
        android:interpolator="@anim/decelerate_interpolator"
        android:valueFrom="2"
        android:valueTo="1"
        android:valueType="floatType"
        android:propertyName="scaleY"
        android:duration="@android:integer/config_mediumAnimTime"/>
    <objectAnimator
        android:interpolator="@anim/decelerate_interpolator"
        android:valueFrom="0"
Loading