Fix QS RTL
- Reverse order of pages - Change pivot point on date - Default to last page position - Fix animation Bug: 27345063 Change-Id: I91aa03810fd3c78c63a07d4b0e0a10127792de60
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
package com.android.systemui.qs;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.v4.view.PagerAdapter;
|
||||
import android.support.v4.view.ViewPager;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import com.android.internal.widget.PagerAdapter;
|
||||
import com.android.internal.widget.ViewPager;
|
||||
import com.android.systemui.R;
|
||||
import com.android.systemui.qs.QSPanel.QSTileLayout;
|
||||
import com.android.systemui.qs.QSPanel.TileRecord;
|
||||
@@ -37,7 +37,8 @@ public class PagedTileLayout extends ViewPager implements QSTileLayout {
|
||||
public void onPageSelected(int position) {
|
||||
if (mPageIndicator == null) return;
|
||||
if (mPageListener != null) {
|
||||
mPageListener.onPageChanged(position == 0);
|
||||
mPageListener.onPageChanged(isLayoutRtl() ? position == mPages.size() - 1
|
||||
: position == 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,7 +48,8 @@ public class PagedTileLayout extends ViewPager implements QSTileLayout {
|
||||
if (mPageIndicator == null) return;
|
||||
mPageIndicator.setLocation(position + positionOffset);
|
||||
if (mPageListener != null) {
|
||||
mPageListener.onPageChanged(position == 0 && positionOffsetPixels == 0);
|
||||
mPageListener.onPageChanged(positionOffsetPixels == 0 &&
|
||||
(isLayoutRtl() ? position == mPages.size() - 1 : position == 0));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,6 +60,21 @@ public class PagedTileLayout extends ViewPager implements QSTileLayout {
|
||||
setCurrentItem(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRtlPropertiesChanged(int layoutDirection) {
|
||||
super.onRtlPropertiesChanged(layoutDirection);
|
||||
setAdapter(mAdapter);
|
||||
setCurrentItem(0, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCurrentItem(int item, boolean smoothScroll) {
|
||||
if (isLayoutRtl()) {
|
||||
item = mPages.size() - 1 - item;
|
||||
}
|
||||
super.setCurrentItem(item, smoothScroll);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasOverlappingRendering() {
|
||||
return false;
|
||||
@@ -128,6 +145,7 @@ public class PagedTileLayout extends ViewPager implements QSTileLayout {
|
||||
mNumPages = index + 1;
|
||||
mPageIndicator.setNumPages(mNumPages);
|
||||
mAdapter.notifyDataSetChanged();
|
||||
setCurrentItem(0, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -206,6 +224,9 @@ public class PagedTileLayout extends ViewPager implements QSTileLayout {
|
||||
|
||||
public Object instantiateItem(ViewGroup container, int position) {
|
||||
if (DEBUG) Log.d(TAG, "Instantiating " + position);
|
||||
if (isLayoutRtl()) {
|
||||
position = mPages.size() - 1 - position;
|
||||
}
|
||||
ViewGroup view = mPages.get(position);
|
||||
container.addView(view);
|
||||
return view;
|
||||
|
||||
@@ -80,6 +80,10 @@ public class QSAnimator implements Callback, PageListener, Listener, OnLayoutCha
|
||||
}
|
||||
}
|
||||
|
||||
public void onRtlChanged() {
|
||||
updateAnimators();
|
||||
}
|
||||
|
||||
public void setOnKeyguard(boolean onKeyguard) {
|
||||
mOnKeyguard = onKeyguard;
|
||||
if (mOnKeyguard) {
|
||||
@@ -231,7 +235,7 @@ public class QSAnimator implements Callback, PageListener, Listener, OnLayoutCha
|
||||
|
||||
private void getRelativePositionInt(int[] loc1, View view, View parent) {
|
||||
if(view == parent || view == null) return;
|
||||
loc1[0] += view.getLeft();
|
||||
loc1[0] += view.getX();
|
||||
loc1[1] += view.getTop();
|
||||
getRelativePositionInt(loc1, (View) view.getParent(), parent);
|
||||
}
|
||||
@@ -297,7 +301,7 @@ public class QSAnimator implements Callback, PageListener, Listener, OnLayoutCha
|
||||
@Override
|
||||
public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft,
|
||||
int oldTop, int oldRight, int oldBottom) {
|
||||
updateAnimators();
|
||||
mQsPanel.post(mUpdateAnimators);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -76,6 +76,12 @@ public class QSContainer extends FrameLayout {
|
||||
mQSCustomizer.setQsContainer(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRtlPropertiesChanged(int layoutDirection) {
|
||||
super.onRtlPropertiesChanged(layoutDirection);
|
||||
mQSAnimator.onRtlChanged();
|
||||
}
|
||||
|
||||
public void setHost(QSTileHost qsh) {
|
||||
mQSPanel.setHost(qsh, mQSCustomizer);
|
||||
mHeader.setQSPanel(mQSPanel);
|
||||
|
||||
@@ -136,6 +136,12 @@ public class QuickStatusBarHeader extends BaseStatusBarHeader implements
|
||||
updateResources();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRtlPropertiesChanged(int layoutDirection) {
|
||||
super.onRtlPropertiesChanged(layoutDirection);
|
||||
updateResources();
|
||||
}
|
||||
|
||||
private void updateResources() {
|
||||
FontSizeUtils.updateFontSize(mAlarmStatus, R.dimen.qs_date_collapsed_size);
|
||||
FontSizeUtils.updateFontSize(mEmergencyOnly, R.dimen.qs_emergency_calls_only_text_size);
|
||||
@@ -175,6 +181,20 @@ public class QuickStatusBarHeader extends BaseStatusBarHeader implements
|
||||
.addFloat(mMultiUserSwitch, "alpha", 0, 1)
|
||||
.setStartDelay(QSAnimator.EXPANDED_TILE_DELAY)
|
||||
.build();
|
||||
|
||||
final boolean isRtl = isLayoutRtl();
|
||||
if (isRtl && mDateTimeGroup.getWidth() == 0) {
|
||||
mDateTimeGroup.addOnLayoutChangeListener(new OnLayoutChangeListener() {
|
||||
@Override
|
||||
public void onLayoutChange(View v, int left, int top, int right, int bottom,
|
||||
int oldLeft, int oldTop, int oldRight, int oldBottom) {
|
||||
mDateTimeGroup.setPivotX(getWidth());
|
||||
mDateTimeGroup.removeOnLayoutChangeListener(this);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
mDateTimeGroup.setPivotX(isRtl ? mDateTimeGroup.getWidth() : 0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user