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

Commit 2482eb81 authored by Roman Birg's avatar Roman Birg
Browse files

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: default avatarRoman Birg <roman@cyngn.com>
parent 8b7fa883
Loading
Loading
Loading
Loading
+18 −9
Original line number Diff line number Diff line
@@ -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,13 +1494,10 @@ 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);
@@ -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();
                            }
                        });
+5 −1
Original line number Diff line number Diff line
@@ -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: "
+43 −28
Original line number Diff line number Diff line
@@ -132,19 +132,18 @@ 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) {
            if (mDualLabel == null) {
                mDualLabel = new QSDualTileLabel(mContext);
                mDualLabel.setId(View.generateViewId());
                mDualLabel.setBackgroundResource(R.drawable.btn_borderless_rect);
@@ -160,6 +159,7 @@ public class QSTileView extends ViewGroup {
                mDualLabel.setFocusable(true);
                mDualLabel.setOnClickListener(mDualDetails ? mClickSecondary : mClickPrimary);
                mDualLabel.setOnLongClickListener(mLongClick);
            }
            if (labelText != null) {
                mDualLabel.setText(labelText);
            }
@@ -169,6 +169,7 @@ public class QSTileView extends ViewGroup {
            addView(mDualLabel);
            mDualLabel.setAccessibilityTraversalAfter(mTopBackgroundView.getId());
        } else {
            if (mLabel == null) {
                mLabel = new TextView(mContext);
                mLabel.setTextColor(mContext.getColor(R.color.qs_tile_text));
                mLabel.setGravity(Gravity.CENTER_HORIZONTAL);
@@ -179,6 +180,7 @@ public class QSTileView extends ViewGroup {
                        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 {