blob: cbf6e2989db2ed7ef8afcb8e2f8ad9967751fc9f [file] [log] [blame]
John Spurlockaf8d6c42014-05-07 17:49:08 -04001/*
2 * Copyright (C) 2014 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.systemui.qs;
18
19import android.animation.Animator;
20import android.animation.Animator.AnimatorListener;
21import android.animation.AnimatorListenerAdapter;
22import android.content.Context;
John Spurlock7f8f22a2014-07-02 18:54:17 -040023import android.content.Intent;
John Spurlock4bf31982014-05-21 13:04:22 -040024import android.content.res.Resources;
John Spurlockaf8d6c42014-05-07 17:49:08 -040025import android.os.Handler;
26import android.os.Message;
27import android.util.AttributeSet;
John Spurlock7f8f22a2014-07-02 18:54:17 -040028import android.view.LayoutInflater;
John Spurlockaf8d6c42014-05-07 17:49:08 -040029import android.view.View;
30import android.view.ViewGroup;
Jorim Jaggi3f48f462014-07-08 16:53:29 +020031import android.widget.ImageView;
John Spurlockaf8d6c42014-05-07 17:49:08 -040032
33import com.android.systemui.R;
John Spurlock7f8f22a2014-07-02 18:54:17 -040034import com.android.systemui.qs.QSTile.DetailAdapter;
Jorim Jaggi3f48f462014-07-08 16:53:29 +020035import com.android.systemui.settings.BrightnessController;
36import com.android.systemui.settings.ToggleSlider;
Adrian Roos1ef80fe2014-07-14 22:53:54 +020037import com.android.systemui.statusbar.phone.QSTileHost;
John Spurlockaf8d6c42014-05-07 17:49:08 -040038
39import java.util.ArrayList;
John Spurlockbceed062014-08-10 18:04:16 -040040import java.util.Collection;
John Spurlockaf8d6c42014-05-07 17:49:08 -040041
42/** View that represents the quick settings tile panel. **/
43public class QSPanel extends ViewGroup {
John Spurlock4bf31982014-05-21 13:04:22 -040044 private static final float TILE_ASPECT = 1.2f;
John Spurlockaf8d6c42014-05-07 17:49:08 -040045
46 private final Context mContext;
47 private final ArrayList<TileRecord> mRecords = new ArrayList<TileRecord>();
John Spurlock7f8f22a2014-07-02 18:54:17 -040048 private final View mDetail;
49 private final ViewGroup mDetailContent;
50 private final View mDetailSettingsButton;
51 private final View mDetailDoneButton;
Jorim Jaggi3f48f462014-07-08 16:53:29 +020052 private final View mBrightnessView;
John Spurlock8af525d2014-08-02 10:56:05 -040053 private final QSDetailClipper mClipper;
John Spurlockaf8d6c42014-05-07 17:49:08 -040054 private final H mHandler = new H();
55
56 private int mColumns;
57 private int mCellWidth;
58 private int mCellHeight;
59 private int mLargeCellWidth;
60 private int mLargeCellHeight;
John Spurlock92d9b192014-06-29 12:54:24 -040061 private int mPanelPaddingBottom;
John Spurlock39076ed2014-06-30 20:47:20 -040062 private int mDualTileUnderlap;
John Spurlock5729d092014-05-29 17:42:51 -040063 private boolean mExpanded;
Jorim Jaggie65e3102014-07-01 22:00:50 +020064 private boolean mListening;
John Spurlockaf8d6c42014-05-07 17:49:08 -040065
Adrian Roos1ef80fe2014-07-14 22:53:54 +020066 private Record mDetailRecord;
John Spurlock5729d092014-05-29 17:42:51 -040067 private Callback mCallback;
Jorim Jaggi3f48f462014-07-08 16:53:29 +020068 private BrightnessController mBrightnessController;
Adrian Roos1ef80fe2014-07-14 22:53:54 +020069 private QSTileHost mHost;
John Spurlockaf8d6c42014-05-07 17:49:08 -040070
Jason Monk3d5f5512014-07-25 11:17:28 -040071 private QSFooter mFooter;
72
John Spurlockaf8d6c42014-05-07 17:49:08 -040073 public QSPanel(Context context) {
74 this(context, null);
75 }
76
77 public QSPanel(Context context, AttributeSet attrs) {
78 super(context, attrs);
79 mContext = context;
80
John Spurlock7f8f22a2014-07-02 18:54:17 -040081 mDetail = LayoutInflater.from(context).inflate(R.layout.qs_detail, this, false);
82 mDetailContent = (ViewGroup) mDetail.findViewById(android.R.id.content);
83 mDetailSettingsButton = mDetail.findViewById(android.R.id.button2);
84 mDetailDoneButton = mDetail.findViewById(android.R.id.button1);
John Spurlockaf8d6c42014-05-07 17:49:08 -040085 mDetail.setVisibility(GONE);
86 mDetail.setClickable(true);
Jorim Jaggi3f48f462014-07-08 16:53:29 +020087 mBrightnessView = LayoutInflater.from(context).inflate(
88 R.layout.quick_settings_brightness_dialog, this, false);
Jason Monk3d5f5512014-07-25 11:17:28 -040089 mFooter = new QSFooter(this, context);
John Spurlockaf8d6c42014-05-07 17:49:08 -040090 addView(mDetail);
Jorim Jaggi3f48f462014-07-08 16:53:29 +020091 addView(mBrightnessView);
Jason Monk3d5f5512014-07-25 11:17:28 -040092 addView(mFooter.getView());
John Spurlock8af525d2014-08-02 10:56:05 -040093 mClipper = new QSDetailClipper(mDetail);
John Spurlockaf8d6c42014-05-07 17:49:08 -040094 updateResources();
Jorim Jaggi3f48f462014-07-08 16:53:29 +020095
96 mBrightnessController = new BrightnessController(getContext(),
97 (ImageView) findViewById(R.id.brightness_icon),
98 (ToggleSlider) findViewById(R.id.brightness_slider));
Adrian Roos1ef80fe2014-07-14 22:53:54 +020099
100 mDetailDoneButton.setOnClickListener(new OnClickListener() {
101 @Override
102 public void onClick(View v) {
John Spurlockf7ae4422014-08-01 12:45:18 -0400103 closeDetail();
Adrian Roos1ef80fe2014-07-14 22:53:54 +0200104 }
105 });
John Spurlockaf8d6c42014-05-07 17:49:08 -0400106 }
107
John Spurlock5729d092014-05-29 17:42:51 -0400108 public void setCallback(Callback callback) {
109 mCallback = callback;
110 }
111
Adrian Roos1ef80fe2014-07-14 22:53:54 +0200112 public void setHost(QSTileHost host) {
113 mHost = host;
Jason Monk3d5f5512014-07-25 11:17:28 -0400114 mFooter.setHost(host);
Adrian Roos1ef80fe2014-07-14 22:53:54 +0200115 }
116
Adrian Roos00a0b1f2014-07-16 16:44:49 +0200117 public QSTileHost getHost() {
118 return mHost;
119 }
Adrian Roos1ef80fe2014-07-14 22:53:54 +0200120
John Spurlockaf8d6c42014-05-07 17:49:08 -0400121 public void updateResources() {
John Spurlock4bf31982014-05-21 13:04:22 -0400122 final Resources res = mContext.getResources();
123 final int columns = Math.max(1, res.getInteger(R.integer.quick_settings_num_columns));
124 mCellHeight = res.getDimensionPixelSize(R.dimen.qs_tile_height);
125 mCellWidth = (int)(mCellHeight * TILE_ASPECT);
126 mLargeCellHeight = res.getDimensionPixelSize(R.dimen.qs_dual_tile_height);
127 mLargeCellWidth = (int)(mLargeCellHeight * TILE_ASPECT);
John Spurlock92d9b192014-06-29 12:54:24 -0400128 mPanelPaddingBottom = res.getDimensionPixelSize(R.dimen.qs_panel_padding_bottom);
John Spurlock39076ed2014-06-30 20:47:20 -0400129 mDualTileUnderlap = res.getDimensionPixelSize(R.dimen.qs_dual_tile_padding_vertical);
John Spurlockaf8d6c42014-05-07 17:49:08 -0400130 if (mColumns != columns) {
131 mColumns = columns;
132 postInvalidate();
133 }
John Spurlock1a462c12014-07-14 10:52:01 -0400134 if (mListening) {
135 refreshAllTiles();
136 }
John Spurlockaf8d6c42014-05-07 17:49:08 -0400137 }
138
139 public void setExpanded(boolean expanded) {
John Spurlock5729d092014-05-29 17:42:51 -0400140 if (mExpanded == expanded) return;
141 mExpanded = expanded;
142 if (!mExpanded) {
John Spurlockf7ae4422014-08-01 12:45:18 -0400143 closeDetail();
John Spurlockaf8d6c42014-05-07 17:49:08 -0400144 }
Jorim Jaggie65e3102014-07-01 22:00:50 +0200145 }
146
147 public void setListening(boolean listening) {
148 if (mListening == listening) return;
149 mListening = listening;
John Spurlockaf8d6c42014-05-07 17:49:08 -0400150 for (TileRecord r : mRecords) {
Jorim Jaggie65e3102014-07-01 22:00:50 +0200151 r.tile.setListening(mListening);
John Spurlock1a462c12014-07-14 10:52:01 -0400152 }
Jason Monk3d5f5512014-07-25 11:17:28 -0400153 mFooter.setListening(mListening);
John Spurlock1a462c12014-07-14 10:52:01 -0400154 if (mListening) {
155 refreshAllTiles();
John Spurlockaf8d6c42014-05-07 17:49:08 -0400156 }
Jorim Jaggi3f48f462014-07-08 16:53:29 +0200157 if (listening) {
158 mBrightnessController.registerCallbacks();
159 } else {
160 mBrightnessController.unregisterCallbacks();
161 }
John Spurlockaf8d6c42014-05-07 17:49:08 -0400162 }
163
John Spurlock1a462c12014-07-14 10:52:01 -0400164 private void refreshAllTiles() {
165 for (TileRecord r : mRecords) {
166 r.tile.refreshState();
167 }
Jason Monk3d5f5512014-07-25 11:17:28 -0400168 mFooter.refreshState();
John Spurlock1a462c12014-07-14 10:52:01 -0400169 }
170
Adrian Roos1ef80fe2014-07-14 22:53:54 +0200171 public void showDetailAdapter(boolean show, DetailAdapter adapter) {
172 Record r = new Record();
173 r.detailAdapter = adapter;
174 showDetail(show, r);
175 }
176
177 private void showDetail(boolean show, Record r) {
John Spurlockaf8d6c42014-05-07 17:49:08 -0400178 mHandler.obtainMessage(H.SHOW_DETAIL, show ? 1 : 0, 0, r).sendToTarget();
179 }
180
181 private void setTileVisibility(View v, boolean visible) {
182 mHandler.obtainMessage(H.SET_TILE_VISIBILITY, visible ? 1 : 0, 0, v).sendToTarget();
183 }
184
185 private void handleSetTileVisibility(View v, boolean visible) {
John Spurlock360e15b2014-07-08 18:45:21 -0400186 if (visible == (v.getVisibility() == VISIBLE)) return;
John Spurlockaf8d6c42014-05-07 17:49:08 -0400187 v.setVisibility(visible ? VISIBLE : GONE);
188 }
189
John Spurlockbceed062014-08-10 18:04:16 -0400190 public void setTiles(Collection<QSTile<?>> tiles) {
191 for (TileRecord record : mRecords) {
192 removeView(record.tileView);
193 }
194 mRecords.clear();
195 for (QSTile<?> tile : tiles) {
196 addTile(tile);
197 }
198 if (isShowingDetail()) {
199 mDetail.bringToFront();
200 }
201 }
202
203 private void addTile(final QSTile<?> tile) {
John Spurlockaf8d6c42014-05-07 17:49:08 -0400204 final TileRecord r = new TileRecord();
205 r.tile = tile;
206 r.tileView = tile.createTileView(mContext);
207 r.tileView.setVisibility(View.GONE);
John Spurlockbceed062014-08-10 18:04:16 -0400208 final QSTile.Callback callback = new QSTile.Callback() {
John Spurlockaf8d6c42014-05-07 17:49:08 -0400209 @Override
210 public void onStateChanged(QSTile.State state) {
211 setTileVisibility(r.tileView, state.visible);
212 r.tileView.onStateChanged(state);
213 }
214 @Override
215 public void onShowDetail(boolean show) {
216 QSPanel.this.showDetail(show, r);
217 }
John Spurlock7f8f22a2014-07-02 18:54:17 -0400218 @Override
219 public void onToggleStateChanged(boolean state) {
220 if (mDetailRecord == r) {
221 fireToggleStateChanged(state);
222 }
223 }
John Spurlock486b78e2014-07-07 08:37:56 -0400224 @Override
225 public void onScanStateChanged(boolean state) {
226 if (mDetailRecord == r) {
227 fireScanStateChanged(state);
228 }
229 }
John Spurlockbceed062014-08-10 18:04:16 -0400230 };
231 r.tile.setCallback(callback);
John Spurlockaf8d6c42014-05-07 17:49:08 -0400232 final View.OnClickListener click = new View.OnClickListener() {
233 @Override
234 public void onClick(View v) {
235 r.tile.click();
236 }
237 };
238 final View.OnClickListener clickSecondary = new View.OnClickListener() {
239 @Override
240 public void onClick(View v) {
241 r.tile.secondaryClick();
242 }
243 };
244 r.tileView.init(click, clickSecondary);
John Spurlockbceed062014-08-10 18:04:16 -0400245 r.tile.setListening(mListening);
246 callback.onStateChanged(r.tile.getState());
John Spurlockccb6b9a2014-05-17 15:54:40 -0400247 r.tile.refreshState();
John Spurlockaf8d6c42014-05-07 17:49:08 -0400248 mRecords.add(r);
249
250 addView(r.tileView);
251 }
252
John Spurlockf7ae4422014-08-01 12:45:18 -0400253 public boolean isShowingDetail() {
254 return mDetailRecord != null;
255 }
256
257 public void closeDetail() {
258 showDetail(false, mDetailRecord);
259 }
260
Adrian Roos1ef80fe2014-07-14 22:53:54 +0200261 private void handleShowDetail(Record r, boolean show) {
262 if (r instanceof TileRecord) {
263 handleShowDetailTile((TileRecord) r, show);
264 } else {
265 handleShowDetailImpl(r, show, getWidth() /* x */, 0/* y */);
266 }
267 }
268
269 private void handleShowDetailTile(TileRecord r, boolean show) {
270 if ((mDetailRecord != null) == show) return;
271
John Spurlockaf8d6c42014-05-07 17:49:08 -0400272 if (show) {
John Spurlock7f8f22a2014-07-02 18:54:17 -0400273 r.detailAdapter = r.tile.getDetailAdapter();
274 if (r.detailAdapter == null) return;
Adrian Roos1ef80fe2014-07-14 22:53:54 +0200275 }
276 int x = r.tileView.getLeft() + r.tileView.getWidth() / 2;
277 int y = r.tileView.getTop() + r.tileView.getHeight() / 2;
278 handleShowDetailImpl(r, show, x, y);
279 }
280
281 private void handleShowDetailImpl(Record r, boolean show, int x, int y) {
282 if ((mDetailRecord != null) == show) return; // already in right state
283 DetailAdapter detailAdapter = null;
284 AnimatorListener listener = null;
285 if (show) {
286 detailAdapter = r.detailAdapter;
287 r.detailView = detailAdapter.createDetailView(mContext, r.detailView, mDetailContent);
John Spurlock7f8f22a2014-07-02 18:54:17 -0400288 if (r.detailView == null) throw new IllegalStateException("Must return detail view");
Adrian Roos1ef80fe2014-07-14 22:53:54 +0200289
290 final Intent settingsIntent = detailAdapter.getSettingsIntent();
John Spurlock7f8f22a2014-07-02 18:54:17 -0400291 mDetailSettingsButton.setVisibility(settingsIntent != null ? VISIBLE : GONE);
292 mDetailSettingsButton.setOnClickListener(new OnClickListener() {
293 @Override
294 public void onClick(View v) {
Adrian Roos1ef80fe2014-07-14 22:53:54 +0200295 mHost.startSettingsActivity(settingsIntent);
John Spurlock7f8f22a2014-07-02 18:54:17 -0400296 }
297 });
Adrian Roos1ef80fe2014-07-14 22:53:54 +0200298
John Spurlock7f8f22a2014-07-02 18:54:17 -0400299 mDetailContent.removeAllViews();
John Spurlockaf8d6c42014-05-07 17:49:08 -0400300 mDetail.bringToFront();
John Spurlock7f8f22a2014-07-02 18:54:17 -0400301 mDetailContent.addView(r.detailView);
Adrian Roos1ef80fe2014-07-14 22:53:54 +0200302 mDetailRecord = r;
John Spurlockaf8d6c42014-05-07 17:49:08 -0400303 } else {
John Spurlockaf8d6c42014-05-07 17:49:08 -0400304 listener = mTeardownDetailWhenDone;
305 }
Adrian Roos1ef80fe2014-07-14 22:53:54 +0200306 fireShowingDetail(show ? detailAdapter : null);
John Spurlockaf8d6c42014-05-07 17:49:08 -0400307 mClipper.animateCircularClip(x, y, show, listener);
308 }
309
310 @Override
311 protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
312 final int width = MeasureSpec.getSize(widthMeasureSpec);
Jorim Jaggi3f48f462014-07-08 16:53:29 +0200313 mBrightnessView.measure(exactly(width), MeasureSpec.UNSPECIFIED);
Jason Monk3d5f5512014-07-25 11:17:28 -0400314 mFooter.getView().measure(exactly(width), MeasureSpec.UNSPECIFIED);
John Spurlockccb6b9a2014-05-17 15:54:40 -0400315 int r = -1;
316 int c = -1;
John Spurlockaf8d6c42014-05-07 17:49:08 -0400317 int rows = 0;
John Spurlockccb6b9a2014-05-17 15:54:40 -0400318 boolean rowIsDual = false;
John Spurlockaf8d6c42014-05-07 17:49:08 -0400319 for (TileRecord record : mRecords) {
320 if (record.tileView.getVisibility() == GONE) continue;
John Spurlockccb6b9a2014-05-17 15:54:40 -0400321 // wrap to next column if we've reached the max # of columns
322 // also don't allow dual + single tiles on the same row
323 if (r == -1 || c == (mColumns - 1) || rowIsDual != record.tile.supportsDualTargets()) {
324 r++;
325 c = 0;
326 rowIsDual = record.tile.supportsDualTargets();
327 } else {
328 c++;
329 }
John Spurlockaf8d6c42014-05-07 17:49:08 -0400330 record.row = r;
331 record.col = c;
332 rows = r + 1;
John Spurlockaf8d6c42014-05-07 17:49:08 -0400333 }
334
335 for (TileRecord record : mRecords) {
336 if (record.tileView.getVisibility() == GONE) continue;
John Spurlockccb6b9a2014-05-17 15:54:40 -0400337 record.tileView.setDual(record.tile.supportsDualTargets());
John Spurlockaf8d6c42014-05-07 17:49:08 -0400338 final int cw = record.row == 0 ? mLargeCellWidth : mCellWidth;
339 final int ch = record.row == 0 ? mLargeCellHeight : mCellHeight;
340 record.tileView.measure(exactly(cw), exactly(ch));
341 }
Jorim Jaggi3f48f462014-07-08 16:53:29 +0200342 int h = rows == 0 ? mBrightnessView.getHeight() : (getRowTop(rows) + mPanelPaddingBottom);
Jason Monk3d5f5512014-07-25 11:17:28 -0400343 if (mFooter.hasFooter()) {
344 h += mFooter.getView().getHeight();
345 }
Adrian Roos19408922014-08-07 20:54:12 +0200346 mDetail.measure(exactly(width), MeasureSpec.UNSPECIFIED);
347 if (mDetail.getMeasuredHeight() < h) {
348 mDetail.measure(exactly(width), exactly(h));
349 }
350 setMeasuredDimension(width, Math.max(h, mDetail.getMeasuredHeight()));
John Spurlockaf8d6c42014-05-07 17:49:08 -0400351 }
352
353 private static int exactly(int size) {
354 return MeasureSpec.makeMeasureSpec(size, MeasureSpec.EXACTLY);
355 }
356
357 @Override
358 protected void onLayout(boolean changed, int l, int t, int r, int b) {
John Spurlock4bf31982014-05-21 13:04:22 -0400359 final int w = getWidth();
Jorim Jaggi3f48f462014-07-08 16:53:29 +0200360 mBrightnessView.layout(0, 0,
361 mBrightnessView.getMeasuredWidth(), mBrightnessView.getMeasuredHeight());
John Spurlockaf8d6c42014-05-07 17:49:08 -0400362 for (TileRecord record : mRecords) {
363 if (record.tileView.getVisibility() == GONE) continue;
364 final int cols = getColumnCount(record.row);
365 final int cw = record.row == 0 ? mLargeCellWidth : mCellWidth;
366 final int extra = (w - cw * cols) / (cols + 1);
367 final int left = record.col * cw + (record.col + 1) * extra;
368 final int top = getRowTop(record.row);
369 record.tileView.layout(left, top,
370 left + record.tileView.getMeasuredWidth(),
371 top + record.tileView.getMeasuredHeight());
372 }
John Spurlock3e04cc82014-05-30 12:34:03 -0400373 final int dh = Math.max(mDetail.getMeasuredHeight(), getMeasuredHeight());
374 mDetail.layout(0, 0, mDetail.getMeasuredWidth(), dh);
Jason Monk3d5f5512014-07-25 11:17:28 -0400375 if (mFooter.hasFooter()) {
376 View footer = mFooter.getView();
377 footer.layout(0, getMeasuredHeight() - footer.getMeasuredHeight(),
378 footer.getMeasuredWidth(), getMeasuredHeight());
379 }
John Spurlockaf8d6c42014-05-07 17:49:08 -0400380 }
381
382 private int getRowTop(int row) {
Jorim Jaggi3f48f462014-07-08 16:53:29 +0200383 if (row <= 0) return mBrightnessView.getHeight();
384 return mBrightnessView.getHeight()
385 + mLargeCellHeight - mDualTileUnderlap + (row - 1) * mCellHeight;
John Spurlockaf8d6c42014-05-07 17:49:08 -0400386 }
387
388 private int getColumnCount(int row) {
389 int cols = 0;
390 for (TileRecord record : mRecords) {
391 if (record.tileView.getVisibility() == GONE) continue;
392 if (record.row == row) cols++;
393 }
394 return cols;
395 }
396
John Spurlock7f8f22a2014-07-02 18:54:17 -0400397 private void fireShowingDetail(QSTile.DetailAdapter detail) {
John Spurlock5729d092014-05-29 17:42:51 -0400398 if (mCallback != null) {
John Spurlock7f8f22a2014-07-02 18:54:17 -0400399 mCallback.onShowingDetail(detail);
400 }
401 }
402
403 private void fireToggleStateChanged(boolean state) {
404 if (mCallback != null) {
405 mCallback.onToggleStateChanged(state);
John Spurlock5729d092014-05-29 17:42:51 -0400406 }
407 }
408
John Spurlock486b78e2014-07-07 08:37:56 -0400409 private void fireScanStateChanged(boolean state) {
410 if (mCallback != null) {
411 mCallback.onScanStateChanged(state);
412 }
413 }
414
John Spurlockaf8d6c42014-05-07 17:49:08 -0400415 private class H extends Handler {
416 private static final int SHOW_DETAIL = 1;
417 private static final int SET_TILE_VISIBILITY = 2;
418 @Override
419 public void handleMessage(Message msg) {
420 if (msg.what == SHOW_DETAIL) {
Adrian Roos1ef80fe2014-07-14 22:53:54 +0200421 handleShowDetail((Record)msg.obj, msg.arg1 != 0);
John Spurlockaf8d6c42014-05-07 17:49:08 -0400422 } else if (msg.what == SET_TILE_VISIBILITY) {
423 handleSetTileVisibility((View)msg.obj, msg.arg1 != 0);
424 }
425 }
426 }
427
Adrian Roos1ef80fe2014-07-14 22:53:54 +0200428 private static class Record {
John Spurlock856edeb2014-06-01 20:36:47 -0400429 View detailView;
John Spurlock7f8f22a2014-07-02 18:54:17 -0400430 DetailAdapter detailAdapter;
Adrian Roos1ef80fe2014-07-14 22:53:54 +0200431 }
432
433 private static final class TileRecord extends Record {
434 QSTile<?> tile;
435 QSTileView tileView;
John Spurlockaf8d6c42014-05-07 17:49:08 -0400436 int row;
437 int col;
438 }
439
440 private final AnimatorListenerAdapter mTeardownDetailWhenDone = new AnimatorListenerAdapter() {
441 public void onAnimationEnd(Animator animation) {
John Spurlock7f8f22a2014-07-02 18:54:17 -0400442 mDetailContent.removeAllViews();
John Spurlockaf8d6c42014-05-07 17:49:08 -0400443 mDetailRecord = null;
444 };
445 };
John Spurlock5729d092014-05-29 17:42:51 -0400446
447 public interface Callback {
John Spurlock7f8f22a2014-07-02 18:54:17 -0400448 void onShowingDetail(QSTile.DetailAdapter detail);
449 void onToggleStateChanged(boolean state);
John Spurlock486b78e2014-07-07 08:37:56 -0400450 void onScanStateChanged(boolean state);
John Spurlock5729d092014-05-29 17:42:51 -0400451 }
John Spurlockaf8d6c42014-05-07 17:49:08 -0400452}