From d9e8aa35c027c8403929a88759686d25391e43a2 Mon Sep 17 00:00:00 2001 From: Fabian Kozynski Date: Fri, 12 Apr 2019 10:09:48 -0400 Subject: 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 --- .../src/com/android/systemui/qs/PagedTileLayout.java | 17 +++++++++++++++-- .../src/com/android/systemui/qs/QSAnimator.java | 6 +++++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/qs/PagedTileLayout.java b/packages/SystemUI/src/com/android/systemui/qs/PagedTileLayout.java index bb159a9ba2e8..ebc3a6adaeee 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/PagedTileLayout.java +++ b/packages/SystemUI/src/com/android/systemui/qs/PagedTileLayout.java @@ -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(); } diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSAnimator.java b/packages/SystemUI/src/com/android/systemui/qs/QSAnimator.java index 8e77851acc8a..ec2feba8291b 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/QSAnimator.java +++ b/packages/SystemUI/src/com/android/systemui/qs/QSAnimator.java @@ -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()); -- cgit v1.2.3-59-g8ed1b