Merge "Fixed bugs in PagedTileLayout, QSAnimator using RTL" into qt-dev

This commit is contained in:
Fabian Kozynski
2019-04-12 19:22:33 +00:00
committed by Android (Google) Code Review
2 changed files with 20 additions and 3 deletions

View File

@@ -91,6 +91,7 @@ public class PagedTileLayout extends ViewPager implements QSTileLayout {
if (mLayoutOrientation != newConfig.orientation) { if (mLayoutOrientation != newConfig.orientation) {
mLayoutOrientation = newConfig.orientation; mLayoutOrientation = newConfig.orientation;
setCurrentItem(0, false); setCurrentItem(0, false);
mPageToRestore = 0;
} }
} }
@@ -101,6 +102,7 @@ public class PagedTileLayout extends ViewPager implements QSTileLayout {
mLayoutDirection = layoutDirection; mLayoutDirection = layoutDirection;
setAdapter(mAdapter); setAdapter(mAdapter);
setCurrentItem(0, false); setCurrentItem(0, false);
mPageToRestore = 0;
} }
} }
@@ -112,6 +114,17 @@ public class PagedTileLayout extends ViewPager implements QSTileLayout {
super.setCurrentItem(item, smoothScroll); 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 @Override
public void setListening(boolean listening) { public void setListening(boolean listening) {
if (mListening == listening) return; 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 // marquee. This will ensure that accessibility doesn't announce the TYPE_VIEW_SELECTED
// event on any of the children. // event on any of the children.
setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS); 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++) { for (int i = 0; i < mPages.size(); i++) {
mPages.get(i).setSelected(i == currentItem ? selected : false); mPages.get(i).setSelected(i == currentItem ? selected : false);
} }
@@ -328,7 +341,7 @@ public class PagedTileLayout extends ViewPager implements QSTileLayout {
public int getNumVisibleTiles() { public int getNumVisibleTiles() {
if (mPages.size() == 0) return 0; if (mPages.size() == 0) return 0;
TilePage currentPage = mPages.get(getCurrentItem()); TilePage currentPage = mPages.get(getCurrentPageNumber());
return currentPage.mRecords.size(); return currentPage.mRecords.size();
} }

View File

@@ -213,7 +213,11 @@ public class QSAnimator implements Callback, PageListener, Listener, OnLayoutCha
} else { // These tiles disappear when expanding } else { // These tiles disappear when expanding
firstPageBuilder.addFloat(quickTileView, "alpha", 1, 0); firstPageBuilder.addFloat(quickTileView, "alpha", 1, 0);
translationYBuilder.addFloat(quickTileView, "translationY", 0, yDiff); 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()); mQuickQsViews.add(tileView.getIconWithBackground());