summaryrefslogtreecommitdiffstats
path: root/packages/SystemUI
diff options
context:
space:
mode:
authorRoman Birg <roman@cyngn.com>2016-01-27 16:32:18 -0800
committerRoman Birg <roman@cyngn.com>2016-02-01 14:12:31 -0800
commit2482eb8191c2d397a4fa1e9e0401696007e844e7 (patch)
tree03e20688bef8dd28234504f6adac8557ff637bf6 /packages/SystemUI
parent8b7fa883def9b0b7bc8ad8fb404b963e88976e0e (diff)
downloadframeworks_base-2482eb8191c2d397a4fa1e9e0401696007e844e7.zip
frameworks_base-2482eb8191c2d397a4fa1e9e0401696007e844e7.tar.gz
frameworks_base-2482eb8191c2d397a4fa1e9e0401696007e844e7.tar.bz2
SystemUI: smoother tile transitions when moving to 1st row
When moving a tile to the first row, make sure not to do any extra work unless we actually changed dual states. Also no need to re-calculate the state. Animate all the things together. Ref: CYNGNOS-1644 Change-Id: Id462838633c22c67607d5bd94d0e0faee8ea3464 Signed-off-by: Roman Birg <roman@cyngn.com>
Diffstat (limited to 'packages/SystemUI')
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/QSDragPanel.java27
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/QSPage.java6
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/QSTileView.java71
3 files changed, 66 insertions, 38 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSDragPanel.java b/packages/SystemUI/src/com/android/systemui/qs/QSDragPanel.java
index 732e4d1..4687b95 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QSDragPanel.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QSDragPanel.java
@@ -1243,6 +1243,7 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On
float destinationY = mDraggingRecord.destination.y + mViewPager.getTop();
mDraggingRecord.tileView.animate()
+ .withLayer()
.x(destinationX)
.y(destinationY) // part of the viewpager now
.setListener(new AnimatorListenerAdapter() {
@@ -1493,14 +1494,11 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On
tilePageSource.addTransientView(ti.tileView, 0);
ti.tileView.animate()
+ .withLayer()
.x(ti.destination.x + getWidth())
.y(ti.destination.y)
.setListener(new AnimatorListenerAdapter() {
@Override
- public void onAnimationStart(Animator animation) {
- }
-
- @Override
public void onAnimationEnd(Animator animation) {
tilePageSource.removeTransientView(ti.tileView);
ti.page = tilePageTarget.getPageIndex();
@@ -1515,12 +1513,21 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On
} else {
ti.tileView.animate()
+ .withLayer()
.x(ti.destination.x)
.y(ti.destination.y)
.setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
mCurrentlyAnimating.remove(ti);
+ final boolean dual = getPage(ti.destinationPage).dualRecord(ti);
+ if (ti.tileView.setDual(dual, ti.tile.hasDualTargetsDetails())) {
+ if (DEBUG_DRAG) {
+ Log.w(TAG, ti + " changed dual state to : "
+ + ti.tileView.isDual());
+ }
+ }
+ requestLayout();
}
});
}
@@ -1541,6 +1548,7 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On
tilePageSource.addTransientView(last.tileView, 0);
last.tileView.animate()
+ .withLayer()
.x(last.destination.x + getWidth())
.y(last.destination.y)
.setListener(new AnimatorListenerAdapter() {
@@ -1562,6 +1570,7 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On
});
} else {
last.tileView.animate()
+ .withLayer()
.x(last.destination.x)
.y(last.destination.y)
.setListener(new AnimatorListenerAdapter() {
@@ -1572,6 +1581,7 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On
}
mCurrentlyAnimating.remove(last);
+ requestLayout();
}
});
}
@@ -1619,7 +1629,7 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On
ti.col = lastCol;
ti.destination.x = getLeft(lastRow, lastCol, columnCountF,
- lastPage == 0 && lastRow == 0);
+ lastPage == 0 && lastRow == 0 && mFirstRowLarge);
ti.destination.y = getRowTop(lastRow);
final boolean dual = getPage(ti.destinationPage).dualRecord(ti);
@@ -1636,6 +1646,7 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On
originalPage.removeView(ti.tileView);
ti.tileView.animate()
+ .withLayer()
.x(ti.destination.x)
.y(ti.destination.y)
.setListener(new AnimatorListenerAdapter() {
@@ -1656,21 +1667,19 @@ public class QSDragPanel extends QSPanel implements View.OnDragListener, View.On
});
} else {
ti.tileView.animate()
+ .withLayer()
.x(ti.destination.x)
.y(ti.destination.y)
.setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
+ mCurrentlyAnimating.remove(ti);
if (ti.tileView.setDual(dual, ti.tile.hasDualTargetsDetails())) {
if (DEBUG_DRAG) {
Log.w(TAG, ti + " changed dual state to : "
+ ti.tileView.isDual());
}
- ti.tileView.handleStateChanged(ti.tile.getState());
- ti.tileView.invalidate();
}
-
- mCurrentlyAnimating.remove(ti);
requestLayout();
}
});
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSPage.java b/packages/SystemUI/src/com/android/systemui/qs/QSPage.java
index b06ad35..7871a62 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QSPage.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QSPage.java
@@ -122,7 +122,11 @@ public class QSPage extends ViewGroup {
} else {
right = left + tileWith;
}
- if (mPanel.isAnimating(record)) continue;
+ if (mPanel.isAnimating(record)) {
+ record.tileView.layout(record.tileView.getLeft(), record.tileView.getTop(),
+ record.tileView.getRight(), record.tileView.getBottom());
+ continue;
+ }
if (false) {
Log.v(TAG + "-" + mPage, "laying out " + record + ", top: " + top + ", left: " + left);
Log.d(TAG, record + " wiping translations: "
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSTileView.java b/packages/SystemUI/src/com/android/systemui/qs/QSTileView.java
index a95fac3..7c63782 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QSTileView.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QSTileView.java
@@ -132,34 +132,34 @@ public class QSTileView extends ViewGroup {
private void recreateLabel() {
CharSequence labelText = null;
CharSequence labelDescription = null;
- if (mLabel != null) {
+ if (mLabel != null && mLabel.isAttachedToWindow()) {
labelText = mLabel.getText();
removeView(mLabel);
- mLabel = null;
}
- if (mDualLabel != null) {
+ if (mDualLabel != null && mDualLabel.isAttachedToWindow()) {
labelText = mDualLabel.getText();
labelDescription = mDualLabel.getContentDescription();
removeView(mDualLabel);
- mDualLabel = null;
}
final Resources res = mContext.getResources();
if (mDual) {
- mDualLabel = new QSDualTileLabel(mContext);
- mDualLabel.setId(View.generateViewId());
- mDualLabel.setBackgroundResource(R.drawable.btn_borderless_rect);
- if (mDualDetails) {
- mDualLabel.setFirstLineCaret(mContext.getDrawable(R.drawable.qs_dual_tile_caret));
+ if (mDualLabel == null) {
+ mDualLabel = new QSDualTileLabel(mContext);
+ mDualLabel.setId(View.generateViewId());
+ mDualLabel.setBackgroundResource(R.drawable.btn_borderless_rect);
+ if (mDualDetails) {
+ mDualLabel.setFirstLineCaret(mContext.getDrawable(R.drawable.qs_dual_tile_caret));
+ }
+ mDualLabel.setTextColor(mContext.getColor(R.color.qs_tile_text));
+ mDualLabel.setPadding(0, mDualTileVerticalPaddingPx, 0, mDualTileVerticalPaddingPx);
+ mDualLabel.setTypeface(CONDENSED);
+ mDualLabel.setTextSize(TypedValue.COMPLEX_UNIT_PX,
+ res.getDimensionPixelSize(R.dimen.qs_tile_text_size));
+ mDualLabel.setClickable(true);
+ mDualLabel.setFocusable(true);
+ mDualLabel.setOnClickListener(mDualDetails ? mClickSecondary : mClickPrimary);
+ mDualLabel.setOnLongClickListener(mLongClick);
}
- mDualLabel.setTextColor(mContext.getColor(R.color.qs_tile_text));
- mDualLabel.setPadding(0, mDualTileVerticalPaddingPx, 0, mDualTileVerticalPaddingPx);
- mDualLabel.setTypeface(CONDENSED);
- mDualLabel.setTextSize(TypedValue.COMPLEX_UNIT_PX,
- res.getDimensionPixelSize(R.dimen.qs_tile_text_size));
- mDualLabel.setClickable(true);
- mDualLabel.setFocusable(true);
- mDualLabel.setOnClickListener(mDualDetails ? mClickSecondary : mClickPrimary);
- mDualLabel.setOnLongClickListener(mLongClick);
if (labelText != null) {
mDualLabel.setText(labelText);
}
@@ -169,16 +169,18 @@ public class QSTileView extends ViewGroup {
addView(mDualLabel);
mDualLabel.setAccessibilityTraversalAfter(mTopBackgroundView.getId());
} else {
- mLabel = new TextView(mContext);
- mLabel.setTextColor(mContext.getColor(R.color.qs_tile_text));
- mLabel.setGravity(Gravity.CENTER_HORIZONTAL);
- mLabel.setMinLines(2);
- mLabel.setPadding(0, 0, 0, 0);
- mLabel.setTypeface(CONDENSED);
- mLabel.setTextSize(TypedValue.COMPLEX_UNIT_PX,
- res.getDimensionPixelSize(R.dimen.qs_tile_text_size));
- mLabel.setClickable(false);
- mLabel.setFocusable(false);
+ if (mLabel == null) {
+ mLabel = new TextView(mContext);
+ mLabel.setTextColor(mContext.getColor(R.color.qs_tile_text));
+ mLabel.setGravity(Gravity.CENTER_HORIZONTAL);
+ mLabel.setMinLines(2);
+ mLabel.setPadding(0, 0, 0, 0);
+ mLabel.setTypeface(CONDENSED);
+ mLabel.setTextSize(TypedValue.COMPLEX_UNIT_PX,
+ res.getDimensionPixelSize(R.dimen.qs_tile_text_size));
+ mLabel.setClickable(false);
+ mLabel.setFocusable(false);
+ }
if (labelText != null) {
mLabel.setText(labelText);
}
@@ -218,6 +220,10 @@ public class QSTileView extends ViewGroup {
setFocusable(!dual);
mDivider.setVisibility(dual ? VISIBLE : GONE);
mTopBackgroundView.setVisibility(dual ? VISIBLE : GONE);
+
+ if (changed) {
+ getParent().requestLayout();
+ }
postInvalidate();
return changed;
}
@@ -416,6 +422,15 @@ public class QSTileView extends ViewGroup {
mRipple.setVisible(!editing, false);
}
}
+
+ // clean up extra label view if needed
+ if (!editing) {
+ if (mDual && mLabel != null) {
+ mLabel = null;
+ } else if (!mDual && mDualLabel != null) {
+ mDualLabel = null;
+ }
+ }
}
private class H extends Handler {