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

Commit a74a7c07 authored by Fabian Kozynski's avatar Fabian Kozynski
Browse files

Fix QS expansion animations

* Fix gap between tiles when expanding
* Fix second page collapsing animation: tiles now will shrink and at the
end be replaced by QQS tiles. We need to create the animators as we move
through the pages, as PagedTileLayout only has the current page and the
(up to) two adjacent ones. This means that if the page has not been
added, we don't have correct positions and measures.

See bug for video
Fixes: 207895040
Test: manual

Change-Id: Id2b14b11ace4199ed07f7675b6575cb4b71e93d5
parent f8660097
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -34,7 +34,7 @@ public interface QS extends FragmentBase {

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

    int VERSION = 12;
    int VERSION = 13;

    String TAG = "QS";

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

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

    View getHeader();

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

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

public class PagedTileLayout extends ViewPager implements QSTileLayout {
@@ -332,6 +333,18 @@ public class PagedTileLayout extends ViewPager implements QSTileLayout {
        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() {
        emptyAndInflateOrRemovePages();

@@ -491,6 +504,11 @@ public class PagedTileLayout extends ViewPager implements QSTileLayout {
        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) {
        if (tileSpecs.isEmpty() || mPages.size() < 2 || getScrollX() != 0 || !beginFakeDrag()) {
            // 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();
                    if (mPageIndicator == null) return;
                    if (mPageListener != null) {
                        int pageNumber = isLayoutRtl() ? mPages.size() - 1 - position : position;
                        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;
                    mPageIndicator.setLocation(mPageIndicatorPosition);
                    if (mPageListener != null) {
                        int pageNumber = isLayoutRtl() ? mPages.size() - 1 - position : position;
                        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 {
        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 Diff line number Diff line
@@ -503,6 +503,12 @@ public class QSFragment extends LifecycleFragment implements QS, CommandQueue.Ca
                isTransitioningToFullShade ? progress : mSquishinessFraction);
    }

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

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

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

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