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

Commit 58258791 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix QS expansion animations"

parents c78799cc a74a7c07
Loading
Loading
Loading
Loading
+6 −1
Original line number Original line Diff line number Diff line
@@ -34,7 +34,7 @@ public interface QS extends FragmentBase {


    String ACTION = "com.android.systemui.action.PLUGIN_QS";
    String ACTION = "com.android.systemui.action.PLUGIN_QS";


    int VERSION = 12;
    int VERSION = 13;


    String TAG = "QS";
    String TAG = "QS";


@@ -70,6 +70,11 @@ public interface QS extends FragmentBase {
    void setContainerController(QSContainerController controller);
    void setContainerController(QSContainerController controller);
    void setExpandClickListener(OnClickListener onClickListener);
    void setExpandClickListener(OnClickListener onClickListener);


    /**
     * Returns the height difference between the QSPanel container and the QuickQSPanel container
     */
    int getHeightDiff();

    View getHeader();
    View getHeader();


    default void setHasNotifications(boolean hasNotifications) {
    default void setHasNotifications(boolean hasNotifications) {
+3 −1
Original line number Original line Diff line number Diff line
@@ -20,4 +20,6 @@
    android:id="@+id/qs_pager"
    android:id="@+id/qs_pager"
    android:layout_width="match_parent"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_height="0dp"
    android:layout_weight="1"/>
    android:layout_weight="1"
    android:clipChildren="false"
    android:clipToPadding="false" />
+27 −3
Original line number Original line Diff line number Diff line
@@ -30,6 +30,7 @@ import com.android.systemui.qs.QSPanel.QSTileLayout;
import com.android.systemui.qs.QSPanelControllerBase.TileRecord;
import com.android.systemui.qs.QSPanelControllerBase.TileRecord;


import java.util.ArrayList;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.Set;


public class PagedTileLayout extends ViewPager implements QSTileLayout {
public class PagedTileLayout extends ViewPager implements QSTileLayout {
@@ -332,6 +333,18 @@ public class PagedTileLayout extends ViewPager implements QSTileLayout {
        mPageListener = listener;
        mPageListener = listener;
    }
    }


    public List<String> getSpecsForPage(int page) {
        ArrayList<String> out = new ArrayList<>();
        if (page < 0) return out;
        int perPage = mPages.get(0).maxTiles();
        int startOfPage = page * perPage;
        int endOfPage = (page + 1) * perPage;
        for (int i = startOfPage; i < endOfPage && i < mTiles.size(); i++) {
            out.add(mTiles.get(i).tile.getTileSpec());
        }
        return out;
    }

    private void distributeTiles() {
    private void distributeTiles() {
        emptyAndInflateOrRemovePages();
        emptyAndInflateOrRemovePages();


@@ -491,6 +504,11 @@ public class PagedTileLayout extends ViewPager implements QSTileLayout {
        return currentPage.mRecords.size();
        return currentPage.mRecords.size();
    }
    }


    public int getNumTilesFirstPage() {
        if (mPages.size() == 0) return 0;
        return mPages.get(0).mRecords.size();
    }

    public void startTileReveal(Set<String> tileSpecs, final Runnable postAnimation) {
    public void startTileReveal(Set<String> tileSpecs, final Runnable postAnimation) {
        if (tileSpecs.isEmpty() || mPages.size() < 2 || getScrollX() != 0 || !beginFakeDrag()) {
        if (tileSpecs.isEmpty() || mPages.size() < 2 || getScrollX() != 0 || !beginFakeDrag()) {
            // Do not start the reveal animation unless there are tiles to animate, multiple
            // Do not start the reveal animation unless there are tiles to animate, multiple
@@ -556,8 +574,9 @@ public class PagedTileLayout extends ViewPager implements QSTileLayout {
                    updateSelected();
                    updateSelected();
                    if (mPageIndicator == null) return;
                    if (mPageIndicator == null) return;
                    if (mPageListener != null) {
                    if (mPageListener != null) {
                        int pageNumber = isLayoutRtl() ? mPages.size() - 1 - position : position;
                        mPageListener.onPageChanged(isLayoutRtl() ? position == mPages.size() - 1
                        mPageListener.onPageChanged(isLayoutRtl() ? position == mPages.size() - 1
                                : position == 0);
                                : position == 0, pageNumber);
                    }
                    }
                }
                }


@@ -575,8 +594,12 @@ public class PagedTileLayout extends ViewPager implements QSTileLayout {
                    mPageIndicatorPosition = position + positionOffset;
                    mPageIndicatorPosition = position + positionOffset;
                    mPageIndicator.setLocation(mPageIndicatorPosition);
                    mPageIndicator.setLocation(mPageIndicatorPosition);
                    if (mPageListener != null) {
                    if (mPageListener != null) {
                        int pageNumber = isLayoutRtl() ? mPages.size() - 1 - position : position;
                        mPageListener.onPageChanged(positionOffsetPixels == 0 &&
                        mPageListener.onPageChanged(positionOffsetPixels == 0 &&
                                (isLayoutRtl() ? position == mPages.size() - 1 : position == 0));
                                (isLayoutRtl() ? position == mPages.size() - 1 : position == 0),
                                // Send only valid page number on integer pages
                                positionOffsetPixels == 0 ? pageNumber : PageListener.INVALID_PAGE
                        );
                    }
                    }
                }
                }


@@ -626,6 +649,7 @@ public class PagedTileLayout extends ViewPager implements QSTileLayout {
    };
    };


    public interface PageListener {
    public interface PageListener {
        void onPageChanged(boolean isFirst);
        int INVALID_PAGE = -1;
        void onPageChanged(boolean isFirst, int pageNumber);
    }
    }
}
}
+208 −72

File changed.

Preview size limit exceeded, changes collapsed.

+7 −2
Original line number Original line Diff line number Diff line
@@ -503,6 +503,12 @@ public class QSFragment extends LifecycleFragment implements QS, CommandQueue.Ca
                isTransitioningToFullShade ? progress : mSquishinessFraction);
                isTransitioningToFullShade ? progress : mSquishinessFraction);
    }
    }


    @Override
    public int getHeightDiff() {
        return mQSPanelScrollView.getBottom() - mHeader.getBottom()
                + mHeader.getPaddingBottom();
    }

    @Override
    @Override
    public void setQsExpansion(float expansion, float panelExpansionFraction,
    public void setQsExpansion(float expansion, float panelExpansionFraction,
            float proposedTranslation, float squishinessFraction) {
            float proposedTranslation, float squishinessFraction) {
@@ -537,8 +543,7 @@ public class QSFragment extends LifecycleFragment implements QS, CommandQueue.Ca


        boolean fullyExpanded = expansion == 1;
        boolean fullyExpanded = expansion == 1;
        boolean fullyCollapsed = expansion == 0.0f;
        boolean fullyCollapsed = expansion == 0.0f;
        int heightDiff = mQSPanelScrollView.getBottom() - mHeader.getBottom()
        int heightDiff = getHeightDiff();
                + mHeader.getPaddingBottom();
        float panelTranslationY = translationScaleY * heightDiff;
        float panelTranslationY = translationScaleY * heightDiff;


        // Let the views animate their contents correctly by giving them the necessary context.
        // Let the views animate their contents correctly by giving them the necessary context.
Loading