blob: c3f7eb1b2ffc3d8ecf7b7cf200f10cb3d967f6f2 [file] [log] [blame]
Jason Monk162011e2016-02-19 08:11:55 -05001/*
2 * Copyright (C) 2016 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 * except in compliance with the License. You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software distributed under the
10 * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
11 * KIND, either express or implied. See the License for the specific language governing
12 * permissions and limitations under the License.
13 */
14
15package com.android.systemui.qs;
16
17import android.util.Log;
18import android.view.View;
Jason Monk8fb77872016-03-03 16:39:42 -050019import android.view.View.OnAttachStateChangeListener;
Jason Monk162011e2016-02-19 08:11:55 -050020import android.view.View.OnLayoutChangeListener;
Jason Monk9ffd9f62016-06-07 16:06:59 -040021
Jason Monkde850bb2017-02-01 19:26:30 -050022import com.android.systemui.Dependency;
Amin Shaikh5da602f2018-02-02 15:00:25 -050023import com.android.systemui.plugins.qs.QS;
24import com.android.systemui.plugins.qs.QSTile;
Jason Monk702e2eb2017-03-03 16:53:44 -050025import com.android.systemui.plugins.qs.QSTileView;
Jason Monk162011e2016-02-19 08:11:55 -050026import com.android.systemui.qs.PagedTileLayout.PageListener;
Jason Monk702e2eb2017-03-03 16:53:44 -050027import com.android.systemui.qs.QSHost.Callback;
Amin Shaikh5da602f2018-02-02 15:00:25 -050028import com.android.systemui.qs.QSPanel.QSTileLayout;
Jason Monk162011e2016-02-19 08:11:55 -050029import com.android.systemui.qs.TouchAnimator.Builder;
30import com.android.systemui.qs.TouchAnimator.Listener;
Jason Monk8fb77872016-03-03 16:39:42 -050031import com.android.systemui.tuner.TunerService;
32import com.android.systemui.tuner.TunerService.Tunable;
Jason Monk162011e2016-02-19 08:11:55 -050033
34import java.util.ArrayList;
35import java.util.Collection;
36
Jason Monk8fb77872016-03-03 16:39:42 -050037public class QSAnimator implements Callback, PageListener, Listener, OnLayoutChangeListener,
38 OnAttachStateChangeListener, Tunable {
Jason Monk162011e2016-02-19 08:11:55 -050039
40 private static final String TAG = "QSAnimator";
41
Jason Monk8fb77872016-03-03 16:39:42 -050042 private static final String ALLOW_FANCY_ANIMATION = "sysui_qs_fancy_anim";
43 private static final String MOVE_FULL_ROWS = "sysui_qs_move_whole_rows";
44
Jason Monkb46059a2016-06-30 14:22:42 -040045 public static final float EXPANDED_TILE_DELAY = .86f;
Jason Monk162011e2016-02-19 08:11:55 -050046
47 private final ArrayList<View> mAllViews = new ArrayList<>();
Rohan Shaha8401992018-01-25 18:22:44 -080048 /**
49 * List of {@link View}s representing Quick Settings that are being animated from the quick QS
50 * position to the normal QS panel.
51 */
52 private final ArrayList<View> mQuickQsViews = new ArrayList<>();
Jason Monk162011e2016-02-19 08:11:55 -050053 private final QuickQSPanel mQuickQsPanel;
54 private final QSPanel mQsPanel;
Jason Monk0ceef212016-11-02 14:05:23 -040055 private final QS mQs;
Jason Monk162011e2016-02-19 08:11:55 -050056
Jason Monk8fb77872016-03-03 16:39:42 -050057 private PagedTileLayout mPagedLayout;
58
Jason Monk162011e2016-02-19 08:11:55 -050059 private boolean mOnFirstPage = true;
60 private TouchAnimator mFirstPageAnimator;
61 private TouchAnimator mFirstPageDelayedAnimator;
Jason Monka97776a2016-03-09 15:13:02 -050062 private TouchAnimator mTranslationXAnimator;
63 private TouchAnimator mTranslationYAnimator;
Jason Monk162011e2016-02-19 08:11:55 -050064 private TouchAnimator mNonfirstPageAnimator;
Amin Shaikh5da602f2018-02-02 15:00:25 -050065 private TouchAnimator mNonfirstPageDelayedAnimator;
Jason Monkb46059a2016-06-30 14:22:42 -040066 private TouchAnimator mBrightnessAnimator;
Jason Monk162011e2016-02-19 08:11:55 -050067
Jason Monk8fb77872016-03-03 16:39:42 -050068 private boolean mOnKeyguard;
69
70 private boolean mAllowFancy;
71 private boolean mFullRows;
72 private int mNumQuickTiles;
Jason Monkbe8612d2016-03-30 16:19:06 -040073 private float mLastPosition;
Jason Monk9ffd9f62016-06-07 16:06:59 -040074 private QSTileHost mHost;
Jason Monk8fb77872016-03-03 16:39:42 -050075
Jason Monk0ceef212016-11-02 14:05:23 -040076 public QSAnimator(QS qs, QuickQSPanel quickPanel, QSPanel panel) {
77 mQs = qs;
Jason Monk162011e2016-02-19 08:11:55 -050078 mQuickQsPanel = quickPanel;
79 mQsPanel = panel;
Jason Monk8fb77872016-03-03 16:39:42 -050080 mQsPanel.addOnAttachStateChangeListener(this);
Jason Monk0ceef212016-11-02 14:05:23 -040081 qs.getView().addOnLayoutChangeListener(this);
82 if (mQsPanel.isAttachedToWindow()) {
83 onViewAttachedToWindow(null);
84 }
Jason Monk162011e2016-02-19 08:11:55 -050085 QSTileLayout tileLayout = mQsPanel.getTileLayout();
86 if (tileLayout instanceof PagedTileLayout) {
Jason Monk8fb77872016-03-03 16:39:42 -050087 mPagedLayout = ((PagedTileLayout) tileLayout);
Jason Monk162011e2016-02-19 08:11:55 -050088 } else {
89 Log.w(TAG, "QS Not using page layout");
90 }
Amin Shaikh5da602f2018-02-02 15:00:25 -050091 panel.setPageListener(this);
Jason Monk162011e2016-02-19 08:11:55 -050092 }
93
Jason Monk51fb85a2016-03-28 14:06:04 -040094 public void onRtlChanged() {
95 updateAnimators();
96 }
97
Jason Monk8fb77872016-03-03 16:39:42 -050098 public void setOnKeyguard(boolean onKeyguard) {
99 mOnKeyguard = onKeyguard;
Jason Monk5737ef32016-04-12 14:35:13 -0400100 mQuickQsPanel.setVisibility(mOnKeyguard ? View.INVISIBLE : View.VISIBLE);
Jason Monk8fb77872016-03-03 16:39:42 -0500101 if (mOnKeyguard) {
102 clearAnimationState();
103 }
104 }
105
Jason Monk162011e2016-02-19 08:11:55 -0500106 public void setHost(QSTileHost qsh) {
Jason Monk9ffd9f62016-06-07 16:06:59 -0400107 mHost = qsh;
Jason Monk162011e2016-02-19 08:11:55 -0500108 qsh.addCallback(this);
Jason Monka9df9992016-03-15 12:41:13 -0400109 updateAnimators();
Jason Monk162011e2016-02-19 08:11:55 -0500110 }
111
112 @Override
Jason Monk8fb77872016-03-03 16:39:42 -0500113 public void onViewAttachedToWindow(View v) {
Jason Monkde850bb2017-02-01 19:26:30 -0500114 Dependency.get(TunerService.class).addTunable(this, ALLOW_FANCY_ANIMATION,
Jason Monk8fb77872016-03-03 16:39:42 -0500115 MOVE_FULL_ROWS, QuickQSPanel.NUM_QUICK_TILES);
116 }
117
118 @Override
119 public void onViewDetachedFromWindow(View v) {
Jason Monk9ffd9f62016-06-07 16:06:59 -0400120 if (mHost != null) {
121 mHost.removeCallback(this);
122 }
Jason Monkde850bb2017-02-01 19:26:30 -0500123 Dependency.get(TunerService.class).removeTunable(this);
Jason Monk8fb77872016-03-03 16:39:42 -0500124 }
125
126 @Override
127 public void onTuningChanged(String key, String newValue) {
128 if (ALLOW_FANCY_ANIMATION.equals(key)) {
129 mAllowFancy = newValue == null || Integer.parseInt(newValue) != 0;
130 if (!mAllowFancy) {
131 clearAnimationState();
132 }
133 } else if (MOVE_FULL_ROWS.equals(key)) {
Jason Monk39a2e702016-03-08 16:41:23 -0500134 mFullRows = newValue == null || Integer.parseInt(newValue) != 0;
Jason Monk8fb77872016-03-03 16:39:42 -0500135 } else if (QuickQSPanel.NUM_QUICK_TILES.equals(key)) {
Jason Monk0ceef212016-11-02 14:05:23 -0400136 mNumQuickTiles = mQuickQsPanel.getNumQuickTiles(mQs.getContext());
Jason Monk8fb77872016-03-03 16:39:42 -0500137 clearAnimationState();
138 }
139 updateAnimators();
140 }
141
142 @Override
Jason Monk66eaf312016-02-25 12:29:29 -0500143 public void onPageChanged(boolean isFirst) {
144 if (mOnFirstPage == isFirst) return;
145 if (!isFirst) {
Jason Monk162011e2016-02-19 08:11:55 -0500146 clearAnimationState();
147 }
Jason Monk66eaf312016-02-25 12:29:29 -0500148 mOnFirstPage = isFirst;
Jason Monk162011e2016-02-19 08:11:55 -0500149 }
150
151 private void updateAnimators() {
152 TouchAnimator.Builder firstPageBuilder = new Builder();
Jason Monkfa0f47a2016-03-08 09:17:56 -0500153 TouchAnimator.Builder translationXBuilder = new Builder();
Jason Monk162011e2016-02-19 08:11:55 -0500154 TouchAnimator.Builder translationYBuilder = new Builder();
Jason Monk98196b02016-03-14 10:33:02 -0400155
Jason Monka9df9992016-03-15 12:41:13 -0400156 if (mQsPanel.getHost() == null) return;
Jason Monk702e2eb2017-03-03 16:53:44 -0500157 Collection<QSTile> tiles = mQsPanel.getHost().getTiles();
Jason Monk162011e2016-02-19 08:11:55 -0500158 int count = 0;
159 int[] loc1 = new int[2];
160 int[] loc2 = new int[2];
Jason Monk789e9c02016-03-28 16:00:09 -0400161 int lastXDiff = 0;
Jason Monk789e9c02016-03-28 16:00:09 -0400162 int lastX = 0;
Jason Monk98196b02016-03-14 10:33:02 -0400163
Jason Monkbc8ffc22016-03-09 10:58:49 -0500164 clearAnimationState();
Jason Monk162011e2016-02-19 08:11:55 -0500165 mAllViews.clear();
Rohan Shaha8401992018-01-25 18:22:44 -0800166 mQuickQsViews.clear();
Jason Monk98196b02016-03-14 10:33:02 -0400167
Jason Monkf13413e2017-02-15 15:49:32 -0500168 QSTileLayout tileLayout = mQsPanel.getTileLayout();
169 mAllViews.add((View) tileLayout);
Jason Monkbdefffd2017-06-26 11:22:21 -0400170 int height = mQs.getView() != null ? mQs.getView().getMeasuredHeight() : 0;
171 int heightDiff = height - mQs.getHeader().getBottom()
Jason Monke5b770e2017-03-03 21:49:29 -0500172 + mQs.getHeader().getPaddingBottom();
173 firstPageBuilder.addFloat(tileLayout, "translationY", heightDiff, 0);
Jason Monk98196b02016-03-14 10:33:02 -0400174
Jason Monk702e2eb2017-03-03 16:53:44 -0500175 for (QSTile tile : tiles) {
176 QSTileView tileView = mQsPanel.getTileView(tile);
Jason Monk6e6af2c2016-09-20 14:34:26 -0400177 if (tileView == null) {
178 Log.e(TAG, "tileView is null " + tile.getTileSpec());
179 continue;
180 }
Xiaohui Chen2f3551b2016-04-07 10:37:25 -0700181 final View tileIcon = tileView.getIcon().getIconView();
Jason Monk0ceef212016-11-02 14:05:23 -0400182 View view = mQs.getView();
Jason Monk8fb77872016-03-03 16:39:42 -0500183 if (count < mNumQuickTiles && mAllowFancy) {
Jason Monk162011e2016-02-19 08:11:55 -0500184 // Quick tiles.
Jason Monk9f1422d2017-03-08 09:11:51 -0500185 QSTileView quickTileView = mQuickQsPanel.getTileView(tile);
186 if (quickTileView == null) continue;
Jason Monk162011e2016-02-19 08:11:55 -0500187
Jason Monk789e9c02016-03-28 16:00:09 -0400188 lastX = loc1[0];
Jason Monk0ceef212016-11-02 14:05:23 -0400189 getRelativePosition(loc1, quickTileView.getIcon().getIconView(), view);
190 getRelativePosition(loc2, tileIcon, view);
Jason Monk162011e2016-02-19 08:11:55 -0500191 final int xDiff = loc2[0] - loc1[0];
192 final int yDiff = loc2[1] - loc1[1];
Jason Monk789e9c02016-03-28 16:00:09 -0400193 lastXDiff = loc1[0] - lastX;
Jason Monk162011e2016-02-19 08:11:55 -0500194 // Move the quick tile right from its location to the new one.
Jason Monkfa0f47a2016-03-08 09:17:56 -0500195 translationXBuilder.addFloat(quickTileView, "translationX", 0, xDiff);
Jason Monk162011e2016-02-19 08:11:55 -0500196 translationYBuilder.addFloat(quickTileView, "translationY", 0, yDiff);
197
198 // Counteract the parent translation on the tile. So we have a static base to
Jason Monke80654b2016-02-24 14:53:57 -0500199 // animate the label position off from.
Jason Monkf13413e2017-02-15 15:49:32 -0500200 //firstPageBuilder.addFloat(tileView, "translationY", mQsPanel.getHeight(), 0);
Jason Monk162011e2016-02-19 08:11:55 -0500201
Jason Monkf13413e2017-02-15 15:49:32 -0500202 // Move the real tile from the quick tile position to its final
Jason Monk162011e2016-02-19 08:11:55 -0500203 // location.
Jason Monkf13413e2017-02-15 15:49:32 -0500204 translationXBuilder.addFloat(tileView, "translationX", -xDiff, 0);
205 translationYBuilder.addFloat(tileView, "translationY", -yDiff, 0);
Jason Monk162011e2016-02-19 08:11:55 -0500206
Rohan Shaha8401992018-01-25 18:22:44 -0800207 mQuickQsViews.add(tileView.getIconWithBackground());
Jason Monk0f0de132016-12-19 15:36:13 -0500208 mAllViews.add(tileView.getIcon());
Jason Monk162011e2016-02-19 08:11:55 -0500209 mAllViews.add(quickTileView);
Jason Monk8fb77872016-03-03 16:39:42 -0500210 } else if (mFullRows && isIconInAnimatedRow(count)) {
Jason Monk789e9c02016-03-28 16:00:09 -0400211 // TODO: Refactor some of this, it shares a lot with the above block.
212 // Move the last tile position over by the last difference between quick tiles.
213 // This makes the extra icons seems as if they are coming from positions in the
214 // quick panel.
215 loc1[0] += lastXDiff;
Jason Monk0ceef212016-11-02 14:05:23 -0400216 getRelativePosition(loc2, tileIcon, view);
Jason Monk789e9c02016-03-28 16:00:09 -0400217 final int xDiff = loc2[0] - loc1[0];
218 final int yDiff = loc2[1] - loc1[1];
219
Jason Monke5b770e2017-03-03 21:49:29 -0500220 firstPageBuilder.addFloat(tileView, "translationY", heightDiff, 0);
Jason Monk789e9c02016-03-28 16:00:09 -0400221 translationXBuilder.addFloat(tileView, "translationX", -xDiff, 0);
Jason Monkf13413e2017-02-15 15:49:32 -0500222 translationYBuilder.addFloat(tileView, "translationY", -yDiff, 0);
Jason Monk789e9c02016-03-28 16:00:09 -0400223 translationYBuilder.addFloat(tileIcon, "translationY", -yDiff, 0);
224
Jason Monk8fb77872016-03-03 16:39:42 -0500225 mAllViews.add(tileIcon);
Jason Monk98196b02016-03-14 10:33:02 -0400226 } else {
Jason Monkb46059a2016-06-30 14:22:42 -0400227 firstPageBuilder.addFloat(tileView, "alpha", 0, 1);
Jason Monke5b770e2017-03-03 21:49:29 -0500228 firstPageBuilder.addFloat(tileView, "translationY", -heightDiff, 0);
Jason Monk162011e2016-02-19 08:11:55 -0500229 }
230 mAllViews.add(tileView);
Jason Monk8fb77872016-03-03 16:39:42 -0500231 count++;
Jason Monk162011e2016-02-19 08:11:55 -0500232 }
Jason Monk8fb77872016-03-03 16:39:42 -0500233 if (mAllowFancy) {
Jason Monkb46059a2016-06-30 14:22:42 -0400234 // Make brightness appear static position and alpha in through second half.
235 View brightness = mQsPanel.getBrightnessView();
236 if (brightness != null) {
Jason Monke5b770e2017-03-03 21:49:29 -0500237 firstPageBuilder.addFloat(brightness, "translationY", heightDiff, 0);
Jason Monkb46059a2016-06-30 14:22:42 -0400238 mBrightnessAnimator = new TouchAnimator.Builder()
239 .addFloat(brightness, "alpha", 0, 1)
240 .setStartDelay(.5f)
241 .build();
242 mAllViews.add(brightness);
243 } else {
244 mBrightnessAnimator = null;
245 }
Jason Monk98196b02016-03-14 10:33:02 -0400246 mFirstPageAnimator = firstPageBuilder
247 .setListener(this)
248 .build();
249 // Fade in the tiles/labels as we reach the final position.
250 mFirstPageDelayedAnimator = new TouchAnimator.Builder()
251 .setStartDelay(EXPANDED_TILE_DELAY)
Amin Shaikh15781d62018-02-16 16:00:13 -0500252 .addFloat(mQsPanel.getPageIndicator(), "alpha", 0, 1)
Jason Monkf13413e2017-02-15 15:49:32 -0500253 .addFloat(tileLayout, "alpha", 0, 1)
Jason Monkce4be852017-03-27 17:09:30 -0400254 .addFloat(mQsPanel.getDivider(), "alpha", 0, 1)
Jason Monkdf36aed2016-07-25 11:21:56 -0400255 .addFloat(mQsPanel.getFooter().getView(), "alpha", 0, 1).build();
Amin Shaikh15781d62018-02-16 16:00:13 -0500256 mAllViews.add(mQsPanel.getPageIndicator());
Jason Monkce4be852017-03-27 17:09:30 -0400257 mAllViews.add(mQsPanel.getDivider());
Jason Monkdf36aed2016-07-25 11:21:56 -0400258 mAllViews.add(mQsPanel.getFooter().getView());
Jason Monk08a79192016-08-02 13:36:52 -0400259 float px = 0;
260 float py = 1;
261 if (tiles.size() <= 3) {
262 px = 1;
263 } else if (tiles.size() <= 6) {
264 px = .4f;
265 }
266 PathInterpolatorBuilder interpolatorBuilder = new PathInterpolatorBuilder(0, 0, px, py);
Jason Monka97776a2016-03-09 15:13:02 -0500267 translationXBuilder.setInterpolator(interpolatorBuilder.getXInterpolator());
268 translationYBuilder.setInterpolator(interpolatorBuilder.getYInterpolator());
269 mTranslationXAnimator = translationXBuilder.build();
270 mTranslationYAnimator = translationYBuilder.build();
Jason Monk8fb77872016-03-03 16:39:42 -0500271 }
Jason Monk162011e2016-02-19 08:11:55 -0500272 mNonfirstPageAnimator = new TouchAnimator.Builder()
273 .addFloat(mQuickQsPanel, "alpha", 1, 0)
Amin Shaikh15781d62018-02-16 16:00:13 -0500274 .addFloat(mQsPanel.getPageIndicator(), "alpha", 0, 1)
Jason Monkce4be852017-03-27 17:09:30 -0400275 .addFloat(mQsPanel.getDivider(), "alpha", 0, 1)
Jason Monk79a9f2f2016-03-10 14:55:22 -0500276 .setListener(mNonFirstPageListener)
Jason Monk162011e2016-02-19 08:11:55 -0500277 .setEndDelay(.5f)
278 .build();
Amin Shaikh5da602f2018-02-02 15:00:25 -0500279 mNonfirstPageDelayedAnimator = new TouchAnimator.Builder()
280 .setStartDelay(.14f)
281 .addFloat(tileLayout, "alpha", 0, 1).build();
Jason Monk162011e2016-02-19 08:11:55 -0500282 }
283
Jason Monk8fb77872016-03-03 16:39:42 -0500284 private boolean isIconInAnimatedRow(int count) {
285 if (mPagedLayout == null) {
286 return false;
287 }
288 final int columnCount = mPagedLayout.getColumnCount();
289 return count < ((mNumQuickTiles + columnCount - 1) / columnCount) * columnCount;
290 }
291
Jason Monk162011e2016-02-19 08:11:55 -0500292 private void getRelativePosition(int[] loc1, View view, View parent) {
293 loc1[0] = 0 + view.getWidth() / 2;
294 loc1[1] = 0;
295 getRelativePositionInt(loc1, view, parent);
296 }
297
298 private void getRelativePositionInt(int[] loc1, View view, View parent) {
299 if(view == parent || view == null) return;
Jason Monk61d118d2016-05-20 14:44:16 -0400300 // Ignore tile pages as they can have some offset we don't want to take into account in
301 // RTL.
302 if (!(view instanceof PagedTileLayout.TilePage)) {
303 loc1[0] += view.getLeft();
304 loc1[1] += view.getTop();
305 }
Jason Monk162011e2016-02-19 08:11:55 -0500306 getRelativePositionInt(loc1, (View) view.getParent(), parent);
307 }
308
309 public void setPosition(float position) {
310 if (mFirstPageAnimator == null) return;
Jason Monk8fb77872016-03-03 16:39:42 -0500311 if (mOnKeyguard) {
312 return;
313 }
Jason Monkbe8612d2016-03-30 16:19:06 -0400314 mLastPosition = position;
Jason Monk8fb77872016-03-03 16:39:42 -0500315 if (mOnFirstPage && mAllowFancy) {
Jason Monk162011e2016-02-19 08:11:55 -0500316 mQuickQsPanel.setAlpha(1);
317 mFirstPageAnimator.setPosition(position);
318 mFirstPageDelayedAnimator.setPosition(position);
Jason Monka97776a2016-03-09 15:13:02 -0500319 mTranslationXAnimator.setPosition(position);
320 mTranslationYAnimator.setPosition(position);
Jason Monkb46059a2016-06-30 14:22:42 -0400321 if (mBrightnessAnimator != null) {
322 mBrightnessAnimator.setPosition(position);
323 }
Jason Monk162011e2016-02-19 08:11:55 -0500324 } else {
325 mNonfirstPageAnimator.setPosition(position);
Amin Shaikh5da602f2018-02-02 15:00:25 -0500326 mNonfirstPageDelayedAnimator.setPosition(position);
Jason Monk162011e2016-02-19 08:11:55 -0500327 }
328 }
329
330 @Override
331 public void onAnimationAtStart() {
Jason Monkdf5459d2016-02-29 10:47:35 -0500332 mQuickQsPanel.setVisibility(View.VISIBLE);
Jason Monk162011e2016-02-19 08:11:55 -0500333 }
334
335 @Override
336 public void onAnimationAtEnd() {
337 mQuickQsPanel.setVisibility(View.INVISIBLE);
Rohan Shaha8401992018-01-25 18:22:44 -0800338 final int N = mQuickQsViews.size();
Jason Monke80654b2016-02-24 14:53:57 -0500339 for (int i = 0; i < N; i++) {
Rohan Shaha8401992018-01-25 18:22:44 -0800340 mQuickQsViews.get(i).setVisibility(View.VISIBLE);
Jason Monke80654b2016-02-24 14:53:57 -0500341 }
Jason Monk162011e2016-02-19 08:11:55 -0500342 }
343
344 @Override
345 public void onAnimationStarted() {
Jason Monk5737ef32016-04-12 14:35:13 -0400346 mQuickQsPanel.setVisibility(mOnKeyguard ? View.INVISIBLE : View.VISIBLE);
Jason Monke80654b2016-02-24 14:53:57 -0500347 if (mOnFirstPage) {
Rohan Shaha8401992018-01-25 18:22:44 -0800348 final int N = mQuickQsViews.size();
Jason Monke80654b2016-02-24 14:53:57 -0500349 for (int i = 0; i < N; i++) {
Rohan Shaha8401992018-01-25 18:22:44 -0800350 mQuickQsViews.get(i).setVisibility(View.INVISIBLE);
Jason Monke80654b2016-02-24 14:53:57 -0500351 }
352 }
Jason Monk162011e2016-02-19 08:11:55 -0500353 }
354
355 private void clearAnimationState() {
356 final int N = mAllViews.size();
357 mQuickQsPanel.setAlpha(0);
358 for (int i = 0; i < N; i++) {
359 View v = mAllViews.get(i);
360 v.setAlpha(1);
Jason Monka2bd0462016-04-12 13:55:16 -0400361 v.setTranslationX(0);
362 v.setTranslationY(0);
Jason Monk162011e2016-02-19 08:11:55 -0500363 }
Rohan Shaha8401992018-01-25 18:22:44 -0800364 final int N2 = mQuickQsViews.size();
Jason Monk8fb77872016-03-03 16:39:42 -0500365 for (int i = 0; i < N2; i++) {
Rohan Shaha8401992018-01-25 18:22:44 -0800366 mQuickQsViews.get(i).setVisibility(View.VISIBLE);
Jason Monk8fb77872016-03-03 16:39:42 -0500367 }
Jason Monk162011e2016-02-19 08:11:55 -0500368 }
369
370 @Override
371 public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft,
372 int oldTop, int oldRight, int oldBottom) {
Jason Monk51fb85a2016-03-28 14:06:04 -0400373 mQsPanel.post(mUpdateAnimators);
Jason Monk162011e2016-02-19 08:11:55 -0500374 }
375
376 @Override
377 public void onTilesChanged() {
378 // Give the QS panels a moment to generate their new tiles, then create all new animators
379 // hooked up to the new views.
380 mQsPanel.post(mUpdateAnimators);
381 }
382
Jason Monk79a9f2f2016-03-10 14:55:22 -0500383 private final TouchAnimator.Listener mNonFirstPageListener =
384 new TouchAnimator.ListenerAdapter() {
385 @Override
dongwan0605.kim03c9afa2017-01-03 15:40:07 +0900386 public void onAnimationAtEnd() {
387 mQuickQsPanel.setVisibility(View.INVISIBLE);
388 }
389
390 @Override
Jason Monk79a9f2f2016-03-10 14:55:22 -0500391 public void onAnimationStarted() {
392 mQuickQsPanel.setVisibility(View.VISIBLE);
393 }
394 };
395
Jason Monk162011e2016-02-19 08:11:55 -0500396 private Runnable mUpdateAnimators = new Runnable() {
397 @Override
398 public void run() {
399 updateAnimators();
Jason Monkbe8612d2016-03-30 16:19:06 -0400400 setPosition(mLastPosition);
Jason Monk162011e2016-02-19 08:11:55 -0500401 }
402 };
403}