blob: f6073671dd60e7a6b6538460ac60d9efe63796b4 [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
Rohan Shahdb2cfa32018-02-20 11:27:22 -080047
Jason Monk162011e2016-02-19 08:11:55 -050048 private final ArrayList<View> mAllViews = new ArrayList<>();
Rohan Shaha8401992018-01-25 18:22:44 -080049 /**
50 * List of {@link View}s representing Quick Settings that are being animated from the quick QS
51 * position to the normal QS panel.
52 */
53 private final ArrayList<View> mQuickQsViews = new ArrayList<>();
Jason Monk162011e2016-02-19 08:11:55 -050054 private final QuickQSPanel mQuickQsPanel;
55 private final QSPanel mQsPanel;
Jason Monk0ceef212016-11-02 14:05:23 -040056 private final QS mQs;
Jason Monk162011e2016-02-19 08:11:55 -050057
Jason Monk8fb77872016-03-03 16:39:42 -050058 private PagedTileLayout mPagedLayout;
59
Jason Monk162011e2016-02-19 08:11:55 -050060 private boolean mOnFirstPage = true;
61 private TouchAnimator mFirstPageAnimator;
62 private TouchAnimator mFirstPageDelayedAnimator;
Jason Monka97776a2016-03-09 15:13:02 -050063 private TouchAnimator mTranslationXAnimator;
64 private TouchAnimator mTranslationYAnimator;
Jason Monk162011e2016-02-19 08:11:55 -050065 private TouchAnimator mNonfirstPageAnimator;
Amin Shaikh5da602f2018-02-02 15:00:25 -050066 private TouchAnimator mNonfirstPageDelayedAnimator;
Jason Monkb46059a2016-06-30 14:22:42 -040067 private TouchAnimator mBrightnessAnimator;
Jason Monk162011e2016-02-19 08:11:55 -050068
Jason Monk8fb77872016-03-03 16:39:42 -050069 private boolean mOnKeyguard;
70
71 private boolean mAllowFancy;
72 private boolean mFullRows;
73 private int mNumQuickTiles;
Jason Monkbe8612d2016-03-30 16:19:06 -040074 private float mLastPosition;
Jason Monk9ffd9f62016-06-07 16:06:59 -040075 private QSTileHost mHost;
Jason Monk8fb77872016-03-03 16:39:42 -050076
Jason Monk0ceef212016-11-02 14:05:23 -040077 public QSAnimator(QS qs, QuickQSPanel quickPanel, QSPanel panel) {
78 mQs = qs;
Jason Monk162011e2016-02-19 08:11:55 -050079 mQuickQsPanel = quickPanel;
80 mQsPanel = panel;
Jason Monk8fb77872016-03-03 16:39:42 -050081 mQsPanel.addOnAttachStateChangeListener(this);
Jason Monk0ceef212016-11-02 14:05:23 -040082 qs.getView().addOnLayoutChangeListener(this);
83 if (mQsPanel.isAttachedToWindow()) {
84 onViewAttachedToWindow(null);
85 }
Jason Monk162011e2016-02-19 08:11:55 -050086 QSTileLayout tileLayout = mQsPanel.getTileLayout();
87 if (tileLayout instanceof PagedTileLayout) {
Jason Monk8fb77872016-03-03 16:39:42 -050088 mPagedLayout = ((PagedTileLayout) tileLayout);
Jason Monk162011e2016-02-19 08:11:55 -050089 } else {
90 Log.w(TAG, "QS Not using page layout");
91 }
Amin Shaikh5da602f2018-02-02 15:00:25 -050092 panel.setPageListener(this);
Jason Monk162011e2016-02-19 08:11:55 -050093 }
94
Jason Monk51fb85a2016-03-28 14:06:04 -040095 public void onRtlChanged() {
96 updateAnimators();
97 }
98
Jason Monk8fb77872016-03-03 16:39:42 -050099 public void setOnKeyguard(boolean onKeyguard) {
100 mOnKeyguard = onKeyguard;
Jason Monk5737ef32016-04-12 14:35:13 -0400101 mQuickQsPanel.setVisibility(mOnKeyguard ? View.INVISIBLE : View.VISIBLE);
Jason Monk8fb77872016-03-03 16:39:42 -0500102 if (mOnKeyguard) {
103 clearAnimationState();
104 }
105 }
106
Jason Monk162011e2016-02-19 08:11:55 -0500107 public void setHost(QSTileHost qsh) {
Jason Monk9ffd9f62016-06-07 16:06:59 -0400108 mHost = qsh;
Jason Monk162011e2016-02-19 08:11:55 -0500109 qsh.addCallback(this);
Jason Monka9df9992016-03-15 12:41:13 -0400110 updateAnimators();
Jason Monk162011e2016-02-19 08:11:55 -0500111 }
112
113 @Override
Jason Monk8fb77872016-03-03 16:39:42 -0500114 public void onViewAttachedToWindow(View v) {
Jason Monkde850bb2017-02-01 19:26:30 -0500115 Dependency.get(TunerService.class).addTunable(this, ALLOW_FANCY_ANIMATION,
Jason Monk8fb77872016-03-03 16:39:42 -0500116 MOVE_FULL_ROWS, QuickQSPanel.NUM_QUICK_TILES);
117 }
118
119 @Override
120 public void onViewDetachedFromWindow(View v) {
Jason Monk9ffd9f62016-06-07 16:06:59 -0400121 if (mHost != null) {
122 mHost.removeCallback(this);
123 }
Jason Monkde850bb2017-02-01 19:26:30 -0500124 Dependency.get(TunerService.class).removeTunable(this);
Jason Monk8fb77872016-03-03 16:39:42 -0500125 }
126
127 @Override
128 public void onTuningChanged(String key, String newValue) {
129 if (ALLOW_FANCY_ANIMATION.equals(key)) {
130 mAllowFancy = newValue == null || Integer.parseInt(newValue) != 0;
131 if (!mAllowFancy) {
132 clearAnimationState();
133 }
134 } else if (MOVE_FULL_ROWS.equals(key)) {
Jason Monk39a2e702016-03-08 16:41:23 -0500135 mFullRows = newValue == null || Integer.parseInt(newValue) != 0;
Jason Monk8fb77872016-03-03 16:39:42 -0500136 } else if (QuickQSPanel.NUM_QUICK_TILES.equals(key)) {
Jason Monk0ceef212016-11-02 14:05:23 -0400137 mNumQuickTiles = mQuickQsPanel.getNumQuickTiles(mQs.getContext());
Jason Monk8fb77872016-03-03 16:39:42 -0500138 clearAnimationState();
139 }
140 updateAnimators();
141 }
142
143 @Override
Jason Monk66eaf312016-02-25 12:29:29 -0500144 public void onPageChanged(boolean isFirst) {
145 if (mOnFirstPage == isFirst) return;
146 if (!isFirst) {
Jason Monk162011e2016-02-19 08:11:55 -0500147 clearAnimationState();
148 }
Jason Monk66eaf312016-02-25 12:29:29 -0500149 mOnFirstPage = isFirst;
Jason Monk162011e2016-02-19 08:11:55 -0500150 }
151
152 private void updateAnimators() {
153 TouchAnimator.Builder firstPageBuilder = new Builder();
Jason Monkfa0f47a2016-03-08 09:17:56 -0500154 TouchAnimator.Builder translationXBuilder = new Builder();
Jason Monk162011e2016-02-19 08:11:55 -0500155 TouchAnimator.Builder translationYBuilder = new Builder();
Jason Monk98196b02016-03-14 10:33:02 -0400156
Jason Monka9df9992016-03-15 12:41:13 -0400157 if (mQsPanel.getHost() == null) return;
Jason Monk702e2eb2017-03-03 16:53:44 -0500158 Collection<QSTile> tiles = mQsPanel.getHost().getTiles();
Jason Monk162011e2016-02-19 08:11:55 -0500159 int count = 0;
160 int[] loc1 = new int[2];
161 int[] loc2 = new int[2];
Jason Monk789e9c02016-03-28 16:00:09 -0400162 int lastXDiff = 0;
Jason Monk789e9c02016-03-28 16:00:09 -0400163 int lastX = 0;
Jason Monk98196b02016-03-14 10:33:02 -0400164
Jason Monkbc8ffc22016-03-09 10:58:49 -0500165 clearAnimationState();
Jason Monk162011e2016-02-19 08:11:55 -0500166 mAllViews.clear();
Rohan Shaha8401992018-01-25 18:22:44 -0800167 mQuickQsViews.clear();
Jason Monk98196b02016-03-14 10:33:02 -0400168
Jason Monkf13413e2017-02-15 15:49:32 -0500169 QSTileLayout tileLayout = mQsPanel.getTileLayout();
170 mAllViews.add((View) tileLayout);
Jason Monkbdefffd2017-06-26 11:22:21 -0400171 int height = mQs.getView() != null ? mQs.getView().getMeasuredHeight() : 0;
Fabian Kozynski802279f2018-09-07 13:44:54 -0400172 int width = mQs.getView() != null ? mQs.getView().getMeasuredWidth() : 0;
Jason Monkbdefffd2017-06-26 11:22:21 -0400173 int heightDiff = height - mQs.getHeader().getBottom()
Jason Monke5b770e2017-03-03 21:49:29 -0500174 + mQs.getHeader().getPaddingBottom();
175 firstPageBuilder.addFloat(tileLayout, "translationY", heightDiff, 0);
Jason Monk98196b02016-03-14 10:33:02 -0400176
Jason Monk702e2eb2017-03-03 16:53:44 -0500177 for (QSTile tile : tiles) {
178 QSTileView tileView = mQsPanel.getTileView(tile);
Jason Monk6e6af2c2016-09-20 14:34:26 -0400179 if (tileView == null) {
180 Log.e(TAG, "tileView is null " + tile.getTileSpec());
181 continue;
182 }
Xiaohui Chen2f3551b2016-04-07 10:37:25 -0700183 final View tileIcon = tileView.getIcon().getIconView();
Jason Monk0ceef212016-11-02 14:05:23 -0400184 View view = mQs.getView();
Fabian Kozynski802279f2018-09-07 13:44:54 -0400185
186 // This case: less tiles to animate in small displays.
187 if (count < mQuickQsPanel.getTileLayout().getNumVisibleTiles() && mAllowFancy) {
Jason Monk162011e2016-02-19 08:11:55 -0500188 // Quick tiles.
Jason Monk9f1422d2017-03-08 09:11:51 -0500189 QSTileView quickTileView = mQuickQsPanel.getTileView(tile);
190 if (quickTileView == null) continue;
Jason Monk162011e2016-02-19 08:11:55 -0500191
Jason Monk789e9c02016-03-28 16:00:09 -0400192 lastX = loc1[0];
Jason Monk0ceef212016-11-02 14:05:23 -0400193 getRelativePosition(loc1, quickTileView.getIcon().getIconView(), view);
194 getRelativePosition(loc2, tileIcon, view);
Jason Monk162011e2016-02-19 08:11:55 -0500195 final int xDiff = loc2[0] - loc1[0];
196 final int yDiff = loc2[1] - loc1[1];
Jason Monk789e9c02016-03-28 16:00:09 -0400197 lastXDiff = loc1[0] - lastX;
Jason Monk162011e2016-02-19 08:11:55 -0500198
Fabian Kozynski802279f2018-09-07 13:44:54 -0400199 if (count < tileLayout.getNumVisibleTiles()) {
200 // Move the quick tile right from its location to the new one.
201 translationXBuilder.addFloat(quickTileView, "translationX", 0, xDiff);
202 translationYBuilder.addFloat(quickTileView, "translationY", 0, yDiff);
Jason Monk162011e2016-02-19 08:11:55 -0500203
Fabian Kozynski802279f2018-09-07 13:44:54 -0400204 // Counteract the parent translation on the tile. So we have a static base to
205 // animate the label position off from.
206 //firstPageBuilder.addFloat(tileView, "translationY", mQsPanel.getHeight(), 0);
207
208 // Move the real tile from the quick tile position to its final
209 // location.
210 translationXBuilder.addFloat(tileView, "translationX", -xDiff, 0);
211 translationYBuilder.addFloat(tileView, "translationY", -yDiff, 0);
212
213 } else { // These tiles disappear when expanding
214 firstPageBuilder.addFloat(quickTileView, "alpha", 1, 0);
215 translationYBuilder.addFloat(quickTileView, "translationY", 0, yDiff);
216 translationXBuilder.addFloat(quickTileView, "translationX", 0, xDiff + width);
217 }
Jason Monk162011e2016-02-19 08:11:55 -0500218
Rohan Shaha8401992018-01-25 18:22:44 -0800219 mQuickQsViews.add(tileView.getIconWithBackground());
Jason Monk0f0de132016-12-19 15:36:13 -0500220 mAllViews.add(tileView.getIcon());
Jason Monk162011e2016-02-19 08:11:55 -0500221 mAllViews.add(quickTileView);
Jason Monk8fb77872016-03-03 16:39:42 -0500222 } else if (mFullRows && isIconInAnimatedRow(count)) {
Jason Monk789e9c02016-03-28 16:00:09 -0400223 // TODO: Refactor some of this, it shares a lot with the above block.
224 // Move the last tile position over by the last difference between quick tiles.
225 // This makes the extra icons seems as if they are coming from positions in the
226 // quick panel.
227 loc1[0] += lastXDiff;
Jason Monk0ceef212016-11-02 14:05:23 -0400228 getRelativePosition(loc2, tileIcon, view);
Jason Monk789e9c02016-03-28 16:00:09 -0400229 final int xDiff = loc2[0] - loc1[0];
230 final int yDiff = loc2[1] - loc1[1];
231
Fabian Kozynski52728302018-09-07 12:45:59 +0000232 firstPageBuilder.addFloat(tileView, "translationY", heightDiff, 0);
Fabian Kozynski40c9f0d2018-08-29 16:21:42 -0400233 translationXBuilder.addFloat(tileView, "translationX", -xDiff, 0);
Fabian Kozynski52728302018-09-07 12:45:59 +0000234 translationYBuilder.addFloat(tileView, "translationY", -yDiff, 0);
235 translationYBuilder.addFloat(tileIcon, "translationY", -yDiff, 0);
Jason Monk789e9c02016-03-28 16:00:09 -0400236
Jason Monk8fb77872016-03-03 16:39:42 -0500237 mAllViews.add(tileIcon);
Jason Monk98196b02016-03-14 10:33:02 -0400238 } else {
Jason Monkb46059a2016-06-30 14:22:42 -0400239 firstPageBuilder.addFloat(tileView, "alpha", 0, 1);
Jason Monke5b770e2017-03-03 21:49:29 -0500240 firstPageBuilder.addFloat(tileView, "translationY", -heightDiff, 0);
Jason Monk162011e2016-02-19 08:11:55 -0500241 }
242 mAllViews.add(tileView);
Jason Monk8fb77872016-03-03 16:39:42 -0500243 count++;
Jason Monk162011e2016-02-19 08:11:55 -0500244 }
Jason Monk8fb77872016-03-03 16:39:42 -0500245 if (mAllowFancy) {
Jason Monkb46059a2016-06-30 14:22:42 -0400246 // Make brightness appear static position and alpha in through second half.
247 View brightness = mQsPanel.getBrightnessView();
248 if (brightness != null) {
Jason Monke5b770e2017-03-03 21:49:29 -0500249 firstPageBuilder.addFloat(brightness, "translationY", heightDiff, 0);
Jason Monkb46059a2016-06-30 14:22:42 -0400250 mBrightnessAnimator = new TouchAnimator.Builder()
251 .addFloat(brightness, "alpha", 0, 1)
252 .setStartDelay(.5f)
253 .build();
254 mAllViews.add(brightness);
255 } else {
256 mBrightnessAnimator = null;
257 }
Jason Monk98196b02016-03-14 10:33:02 -0400258 mFirstPageAnimator = firstPageBuilder
259 .setListener(this)
260 .build();
261 // Fade in the tiles/labels as we reach the final position.
262 mFirstPageDelayedAnimator = new TouchAnimator.Builder()
263 .setStartDelay(EXPANDED_TILE_DELAY)
Amin Shaikh15781d62018-02-16 16:00:13 -0500264 .addFloat(mQsPanel.getPageIndicator(), "alpha", 0, 1)
Jason Monkf13413e2017-02-15 15:49:32 -0500265 .addFloat(tileLayout, "alpha", 0, 1)
Jason Monkce4be852017-03-27 17:09:30 -0400266 .addFloat(mQsPanel.getDivider(), "alpha", 0, 1)
Jason Monkdf36aed2016-07-25 11:21:56 -0400267 .addFloat(mQsPanel.getFooter().getView(), "alpha", 0, 1).build();
Amin Shaikh15781d62018-02-16 16:00:13 -0500268 mAllViews.add(mQsPanel.getPageIndicator());
Jason Monkce4be852017-03-27 17:09:30 -0400269 mAllViews.add(mQsPanel.getDivider());
Jason Monkdf36aed2016-07-25 11:21:56 -0400270 mAllViews.add(mQsPanel.getFooter().getView());
Jason Monk08a79192016-08-02 13:36:52 -0400271 float px = 0;
272 float py = 1;
273 if (tiles.size() <= 3) {
274 px = 1;
275 } else if (tiles.size() <= 6) {
276 px = .4f;
277 }
278 PathInterpolatorBuilder interpolatorBuilder = new PathInterpolatorBuilder(0, 0, px, py);
Jason Monka97776a2016-03-09 15:13:02 -0500279 translationXBuilder.setInterpolator(interpolatorBuilder.getXInterpolator());
280 translationYBuilder.setInterpolator(interpolatorBuilder.getYInterpolator());
281 mTranslationXAnimator = translationXBuilder.build();
282 mTranslationYAnimator = translationYBuilder.build();
Jason Monk8fb77872016-03-03 16:39:42 -0500283 }
Jason Monk162011e2016-02-19 08:11:55 -0500284 mNonfirstPageAnimator = new TouchAnimator.Builder()
285 .addFloat(mQuickQsPanel, "alpha", 1, 0)
Amin Shaikh15781d62018-02-16 16:00:13 -0500286 .addFloat(mQsPanel.getPageIndicator(), "alpha", 0, 1)
Jason Monkce4be852017-03-27 17:09:30 -0400287 .addFloat(mQsPanel.getDivider(), "alpha", 0, 1)
Jason Monk79a9f2f2016-03-10 14:55:22 -0500288 .setListener(mNonFirstPageListener)
Jason Monk162011e2016-02-19 08:11:55 -0500289 .setEndDelay(.5f)
290 .build();
Amin Shaikh5da602f2018-02-02 15:00:25 -0500291 mNonfirstPageDelayedAnimator = new TouchAnimator.Builder()
292 .setStartDelay(.14f)
293 .addFloat(tileLayout, "alpha", 0, 1).build();
Jason Monk162011e2016-02-19 08:11:55 -0500294 }
295
Jason Monk8fb77872016-03-03 16:39:42 -0500296 private boolean isIconInAnimatedRow(int count) {
297 if (mPagedLayout == null) {
298 return false;
299 }
300 final int columnCount = mPagedLayout.getColumnCount();
301 return count < ((mNumQuickTiles + columnCount - 1) / columnCount) * columnCount;
302 }
303
Jason Monk162011e2016-02-19 08:11:55 -0500304 private void getRelativePosition(int[] loc1, View view, View parent) {
305 loc1[0] = 0 + view.getWidth() / 2;
306 loc1[1] = 0;
307 getRelativePositionInt(loc1, view, parent);
308 }
309
310 private void getRelativePositionInt(int[] loc1, View view, View parent) {
311 if(view == parent || view == null) return;
Jason Monk61d118d2016-05-20 14:44:16 -0400312 // Ignore tile pages as they can have some offset we don't want to take into account in
313 // RTL.
314 if (!(view instanceof PagedTileLayout.TilePage)) {
315 loc1[0] += view.getLeft();
316 loc1[1] += view.getTop();
317 }
Jason Monk162011e2016-02-19 08:11:55 -0500318 getRelativePositionInt(loc1, (View) view.getParent(), parent);
319 }
320
321 public void setPosition(float position) {
322 if (mFirstPageAnimator == null) return;
Jason Monk8fb77872016-03-03 16:39:42 -0500323 if (mOnKeyguard) {
324 return;
325 }
Jason Monkbe8612d2016-03-30 16:19:06 -0400326 mLastPosition = position;
Jason Monk8fb77872016-03-03 16:39:42 -0500327 if (mOnFirstPage && mAllowFancy) {
Jason Monk162011e2016-02-19 08:11:55 -0500328 mQuickQsPanel.setAlpha(1);
329 mFirstPageAnimator.setPosition(position);
330 mFirstPageDelayedAnimator.setPosition(position);
Jason Monka97776a2016-03-09 15:13:02 -0500331 mTranslationXAnimator.setPosition(position);
332 mTranslationYAnimator.setPosition(position);
Jason Monkb46059a2016-06-30 14:22:42 -0400333 if (mBrightnessAnimator != null) {
334 mBrightnessAnimator.setPosition(position);
335 }
Jason Monk162011e2016-02-19 08:11:55 -0500336 } else {
337 mNonfirstPageAnimator.setPosition(position);
Amin Shaikh5da602f2018-02-02 15:00:25 -0500338 mNonfirstPageDelayedAnimator.setPosition(position);
Jason Monk162011e2016-02-19 08:11:55 -0500339 }
340 }
341
342 @Override
343 public void onAnimationAtStart() {
Jason Monkdf5459d2016-02-29 10:47:35 -0500344 mQuickQsPanel.setVisibility(View.VISIBLE);
Jason Monk162011e2016-02-19 08:11:55 -0500345 }
346
347 @Override
348 public void onAnimationAtEnd() {
349 mQuickQsPanel.setVisibility(View.INVISIBLE);
Rohan Shaha8401992018-01-25 18:22:44 -0800350 final int N = mQuickQsViews.size();
Jason Monke80654b2016-02-24 14:53:57 -0500351 for (int i = 0; i < N; i++) {
Rohan Shaha8401992018-01-25 18:22:44 -0800352 mQuickQsViews.get(i).setVisibility(View.VISIBLE);
Jason Monke80654b2016-02-24 14:53:57 -0500353 }
Jason Monk162011e2016-02-19 08:11:55 -0500354 }
355
356 @Override
357 public void onAnimationStarted() {
Jason Monk5737ef32016-04-12 14:35:13 -0400358 mQuickQsPanel.setVisibility(mOnKeyguard ? View.INVISIBLE : View.VISIBLE);
Jason Monke80654b2016-02-24 14:53:57 -0500359 if (mOnFirstPage) {
Rohan Shaha8401992018-01-25 18:22:44 -0800360 final int N = mQuickQsViews.size();
Jason Monke80654b2016-02-24 14:53:57 -0500361 for (int i = 0; i < N; i++) {
Rohan Shaha8401992018-01-25 18:22:44 -0800362 mQuickQsViews.get(i).setVisibility(View.INVISIBLE);
Jason Monke80654b2016-02-24 14:53:57 -0500363 }
364 }
Jason Monk162011e2016-02-19 08:11:55 -0500365 }
366
367 private void clearAnimationState() {
368 final int N = mAllViews.size();
369 mQuickQsPanel.setAlpha(0);
370 for (int i = 0; i < N; i++) {
371 View v = mAllViews.get(i);
372 v.setAlpha(1);
Jason Monka2bd0462016-04-12 13:55:16 -0400373 v.setTranslationX(0);
374 v.setTranslationY(0);
Jason Monk162011e2016-02-19 08:11:55 -0500375 }
Rohan Shaha8401992018-01-25 18:22:44 -0800376 final int N2 = mQuickQsViews.size();
Jason Monk8fb77872016-03-03 16:39:42 -0500377 for (int i = 0; i < N2; i++) {
Rohan Shaha8401992018-01-25 18:22:44 -0800378 mQuickQsViews.get(i).setVisibility(View.VISIBLE);
Jason Monk8fb77872016-03-03 16:39:42 -0500379 }
Jason Monk162011e2016-02-19 08:11:55 -0500380 }
381
382 @Override
383 public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft,
384 int oldTop, int oldRight, int oldBottom) {
Jason Monk51fb85a2016-03-28 14:06:04 -0400385 mQsPanel.post(mUpdateAnimators);
Jason Monk162011e2016-02-19 08:11:55 -0500386 }
387
388 @Override
389 public void onTilesChanged() {
390 // Give the QS panels a moment to generate their new tiles, then create all new animators
391 // hooked up to the new views.
392 mQsPanel.post(mUpdateAnimators);
393 }
394
Jason Monk79a9f2f2016-03-10 14:55:22 -0500395 private final TouchAnimator.Listener mNonFirstPageListener =
396 new TouchAnimator.ListenerAdapter() {
397 @Override
dongwan0605.kim03c9afa2017-01-03 15:40:07 +0900398 public void onAnimationAtEnd() {
399 mQuickQsPanel.setVisibility(View.INVISIBLE);
400 }
401
402 @Override
Jason Monk79a9f2f2016-03-10 14:55:22 -0500403 public void onAnimationStarted() {
404 mQuickQsPanel.setVisibility(View.VISIBLE);
405 }
406 };
407
Jason Monk162011e2016-02-19 08:11:55 -0500408 private Runnable mUpdateAnimators = new Runnable() {
409 @Override
410 public void run() {
411 updateAnimators();
Jason Monkbe8612d2016-03-30 16:19:06 -0400412 setPosition(mLastPosition);
Jason Monk162011e2016-02-19 08:11:55 -0500413 }
414 };
415}