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

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

Fixed bugs in PagedTileLayout, QSAnimator using RTL

* getNumVisibleTiles now returns the correct number when in RTL. It was
not referring to the correct page
* mPageToRestore set properly on configuration changes
* Animation of tiles that do not fit in screen is correct in RTL.

Fixes: 130408545
Test: visual, changing configuration and expanding/collapsing
Change-Id: I62da728631fceaead0f81af1b32a115e961cf58e
parent a0d2d202
Loading
Loading
Loading
Loading
+15 −2
Original line number Diff line number Diff line
@@ -91,6 +91,7 @@ public class PagedTileLayout extends ViewPager implements QSTileLayout {
        if (mLayoutOrientation != newConfig.orientation) {
            mLayoutOrientation = newConfig.orientation;
            setCurrentItem(0, false);
            mPageToRestore = 0;
        }
    }

@@ -101,6 +102,7 @@ public class PagedTileLayout extends ViewPager implements QSTileLayout {
            mLayoutDirection = layoutDirection;
            setAdapter(mAdapter);
            setCurrentItem(0, false);
            mPageToRestore = 0;
        }
    }

@@ -112,6 +114,17 @@ public class PagedTileLayout extends ViewPager implements QSTileLayout {
        super.setCurrentItem(item, smoothScroll);
    }

    /**
     * Obtains the current page number respecting RTL
     */
    private int getCurrentPageNumber() {
        int page = getCurrentItem();
        if (mLayoutDirection == LAYOUT_DIRECTION_RTL) {
            page = mPages.size() - 1 - page;
        }
        return page;
    }

    @Override
    public void setListening(boolean listening) {
        if (mListening == listening) return;
@@ -199,7 +212,7 @@ public class PagedTileLayout extends ViewPager implements QSTileLayout {
        // marquee. This will ensure that accessibility doesn't announce the TYPE_VIEW_SELECTED
        // event on any of the children.
        setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS);
        int currentItem = isLayoutRtl() ? mPages.size() - 1 - getCurrentItem() : getCurrentItem();
        int currentItem = getCurrentPageNumber();
        for (int i = 0; i < mPages.size(); i++) {
            mPages.get(i).setSelected(i == currentItem ? selected : false);
        }
@@ -328,7 +341,7 @@ public class PagedTileLayout extends ViewPager implements QSTileLayout {

    public int getNumVisibleTiles() {
        if (mPages.size() == 0) return 0;
        TilePage currentPage = mPages.get(getCurrentItem());
        TilePage currentPage = mPages.get(getCurrentPageNumber());
        return currentPage.mRecords.size();
    }

+5 −1
Original line number Diff line number Diff line
@@ -213,7 +213,11 @@ public class QSAnimator implements Callback, PageListener, Listener, OnLayoutCha
                } else { // These tiles disappear when expanding
                    firstPageBuilder.addFloat(quickTileView, "alpha", 1, 0);
                    translationYBuilder.addFloat(quickTileView, "translationY", 0, yDiff);
                    translationXBuilder.addFloat(quickTileView, "translationX", 0, xDiff + width);

                    // xDiff is negative here and this makes it "more" negative
                    final int translationX = mQsPanel.isLayoutRtl() ? xDiff - width : xDiff + width;
                    translationXBuilder.addFloat(quickTileView, "translationX", 0,
                            translationX);
                }

                mQuickQsViews.add(tileView.getIconWithBackground());