John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package com.android.systemui.qs; |
| 18 | |
Jason Monk | e5b770e | 2017-03-03 21:49:29 -0500 | [diff] [blame] | 19 | import static com.android.systemui.qs.tileimpl.QSTileImpl.getColorForState; |
| 20 | |
Jason Monk | 7e53f20 | 2016-01-28 10:40:20 -0500 | [diff] [blame] | 21 | import android.content.ComponentName; |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 22 | import android.content.Context; |
Jorim Jaggi | e17c4b4 | 2014-08-26 17:27:31 +0200 | [diff] [blame] | 23 | import android.content.res.Configuration; |
John Spurlock | 4bf3198 | 2014-05-21 13:04:22 -0400 | [diff] [blame] | 24 | import android.content.res.Resources; |
Jason Monk | cb4b31d | 2017-05-03 10:37:34 -0400 | [diff] [blame] | 25 | import android.metrics.LogMaker; |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 26 | import android.os.Handler; |
| 27 | import android.os.Message; |
Jason Monk | e5b770e | 2017-03-03 21:49:29 -0500 | [diff] [blame] | 28 | import android.service.quicksettings.Tile; |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 29 | import android.util.AttributeSet; |
John Spurlock | 7f8f22a | 2014-07-02 18:54:17 -0400 | [diff] [blame] | 30 | import android.view.LayoutInflater; |
Jason Monk | 231b052 | 2018-01-04 10:49:55 -0500 | [diff] [blame] | 31 | import android.view.MotionEvent; |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 32 | import android.view.View; |
Jason Monk | 520ea06 | 2015-08-18 14:53:06 -0400 | [diff] [blame] | 33 | import android.widget.LinearLayout; |
Jason Monk | cb4b31d | 2017-05-03 10:37:34 -0400 | [diff] [blame] | 34 | |
Chris Wren | 457a21c | 2015-05-06 17:50:34 -0400 | [diff] [blame] | 35 | import com.android.internal.logging.MetricsLogger; |
Tamas Berghammer | 383db5eb | 2016-06-22 15:21:38 +0100 | [diff] [blame] | 36 | import com.android.internal.logging.nano.MetricsProto.MetricsEvent; |
Jason Monk | 824ffff | 2017-04-11 15:49:06 -0400 | [diff] [blame] | 37 | import com.android.settingslib.Utils; |
Jason Monk | de850bb | 2017-02-01 19:26:30 -0500 | [diff] [blame] | 38 | import com.android.systemui.Dependency; |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 39 | import com.android.systemui.R; |
Jason Monk | e5b770e | 2017-03-03 21:49:29 -0500 | [diff] [blame] | 40 | import com.android.systemui.plugins.qs.DetailAdapter; |
Jason Monk | 702e2eb | 2017-03-03 16:53:44 -0500 | [diff] [blame] | 41 | import com.android.systemui.plugins.qs.QSTile; |
| 42 | import com.android.systemui.plugins.qs.QSTileView; |
| 43 | import com.android.systemui.qs.QSHost.Callback; |
Jason Monk | bd6dbb0 | 2015-09-03 15:46:25 -0400 | [diff] [blame] | 44 | import com.android.systemui.qs.customize.QSCustomizer; |
Jason Monk | 7e53f20 | 2016-01-28 10:40:20 -0500 | [diff] [blame] | 45 | import com.android.systemui.qs.external.CustomTile; |
Jorim Jaggi | 3f48f46 | 2014-07-08 16:53:29 +0200 | [diff] [blame] | 46 | import com.android.systemui.settings.BrightnessController; |
Muyuan Li | 3b0f892 | 2016-04-18 19:27:29 -0700 | [diff] [blame] | 47 | import com.android.systemui.settings.ToggleSliderView; |
Adrian Roos | 5fd872e | 2014-08-12 17:28:58 +0200 | [diff] [blame] | 48 | import com.android.systemui.statusbar.policy.BrightnessMirrorController; |
Adrian Roos | b01793f | 2017-08-09 14:34:55 +0200 | [diff] [blame] | 49 | import com.android.systemui.statusbar.policy.BrightnessMirrorController.BrightnessMirrorListener; |
Jason Monk | caf3762 | 2015-08-18 12:33:50 -0400 | [diff] [blame] | 50 | import com.android.systemui.tuner.TunerService; |
| 51 | import com.android.systemui.tuner.TunerService.Tunable; |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 52 | |
| 53 | import java.util.ArrayList; |
John Spurlock | bceed06 | 2014-08-10 18:04:16 -0400 | [diff] [blame] | 54 | import java.util.Collection; |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 55 | |
| 56 | /** View that represents the quick settings tile panel. **/ |
Adrian Roos | b01793f | 2017-08-09 14:34:55 +0200 | [diff] [blame] | 57 | public class QSPanel extends LinearLayout implements Tunable, Callback, BrightnessMirrorListener { |
Jason Monk | caf3762 | 2015-08-18 12:33:50 -0400 | [diff] [blame] | 58 | |
| 59 | public static final String QS_SHOW_BRIGHTNESS = "qs_show_brightness"; |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 60 | |
Jason Monk | bd6dbb0 | 2015-09-03 15:46:25 -0400 | [diff] [blame] | 61 | protected final Context mContext; |
Jason Monk | 11a7744 | 2015-05-12 19:29:02 -0400 | [diff] [blame] | 62 | protected final ArrayList<TileRecord> mRecords = new ArrayList<TileRecord>(); |
Jason Monk | 11a7744 | 2015-05-12 19:29:02 -0400 | [diff] [blame] | 63 | protected final View mBrightnessView; |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 64 | private final H mHandler = new H(); |
Amin Shaikh | 15781d6 | 2018-02-16 16:00:13 -0500 | [diff] [blame^] | 65 | private final View mPageIndicator; |
Jason Monk | 8c09ac7 | 2017-03-16 11:53:40 -0400 | [diff] [blame] | 66 | private final MetricsLogger mMetricsLogger = Dependency.get(MetricsLogger.class); |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 67 | |
Muyuan Li | 0e9f538 | 2016-04-27 15:51:15 -0700 | [diff] [blame] | 68 | protected boolean mExpanded; |
Jason Monk | 1bec6af | 2016-05-31 15:40:58 -0400 | [diff] [blame] | 69 | protected boolean mListening; |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 70 | |
Jason Monk | e5b770e | 2017-03-03 21:49:29 -0500 | [diff] [blame] | 71 | private QSDetail.Callback mCallback; |
Jorim Jaggi | 3f48f46 | 2014-07-08 16:53:29 +0200 | [diff] [blame] | 72 | private BrightnessController mBrightnessController; |
Jason Monk | bbadff8 | 2015-11-06 15:47:26 -0500 | [diff] [blame] | 73 | protected QSTileHost mHost; |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 74 | |
Jason Monk | e5b770e | 2017-03-03 21:49:29 -0500 | [diff] [blame] | 75 | protected QSSecurityFooter mFooter; |
Selim Cinek | e32010a | 2014-08-20 23:50:41 +0200 | [diff] [blame] | 76 | private boolean mGridContentVisible = true; |
Jason Monk | 3d5f551 | 2014-07-25 11:17:28 -0400 | [diff] [blame] | 77 | |
Jason Monk | bd6dbb0 | 2015-09-03 15:46:25 -0400 | [diff] [blame] | 78 | protected QSTileLayout mTileLayout; |
| 79 | |
| 80 | private QSCustomizer mCustomizePanel; |
Jason Monk | 377e7ad | 2016-02-16 14:03:21 -0500 | [diff] [blame] | 81 | private Record mDetailRecord; |
Jason Monk | 520ea06 | 2015-08-18 14:53:06 -0400 | [diff] [blame] | 82 | |
Adrian Roos | 429c962 | 2016-06-15 13:02:17 -0700 | [diff] [blame] | 83 | private BrightnessMirrorController mBrightnessMirrorController; |
Jason Monk | e5b770e | 2017-03-03 21:49:29 -0500 | [diff] [blame] | 84 | private View mDivider; |
Adrian Roos | 429c962 | 2016-06-15 13:02:17 -0700 | [diff] [blame] | 85 | |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 86 | public QSPanel(Context context) { |
| 87 | this(context, null); |
| 88 | } |
| 89 | |
| 90 | public QSPanel(Context context, AttributeSet attrs) { |
| 91 | super(context, attrs); |
| 92 | mContext = context; |
| 93 | |
Jason Monk | 162011e | 2016-02-19 08:11:55 -0500 | [diff] [blame] | 94 | setOrientation(VERTICAL); |
Jason Monk | 520ea06 | 2015-08-18 14:53:06 -0400 | [diff] [blame] | 95 | |
Jason Monk | 231b052 | 2018-01-04 10:49:55 -0500 | [diff] [blame] | 96 | mBrightnessView = LayoutInflater.from(mContext).inflate( |
| 97 | R.layout.quick_settings_brightness_dialog, this, false); |
Amin Shaikh | 15781d6 | 2018-02-16 16:00:13 -0500 | [diff] [blame^] | 98 | addView(mBrightnessView); |
| 99 | |
| 100 | mTileLayout = (QSTileLayout) LayoutInflater.from(mContext).inflate( |
| 101 | R.layout.qs_paged_tile_layout, this, false); |
Jason Monk | 231b052 | 2018-01-04 10:49:55 -0500 | [diff] [blame] | 102 | mTileLayout.setListening(mListening); |
Amin Shaikh | 15781d6 | 2018-02-16 16:00:13 -0500 | [diff] [blame^] | 103 | addView((View) mTileLayout); |
| 104 | |
| 105 | mPageIndicator = LayoutInflater.from(context).inflate( |
| 106 | R.layout.qs_page_indicator, this, false); |
| 107 | addView(mPageIndicator); |
| 108 | |
| 109 | ((PagedTileLayout) mTileLayout).setPageIndicator((PageIndicator) mPageIndicator); |
Jason Monk | 3250885 | 2017-01-18 09:17:13 -0500 | [diff] [blame] | 110 | |
Jason Monk | e5b770e | 2017-03-03 21:49:29 -0500 | [diff] [blame] | 111 | addDivider(); |
| 112 | |
phweiss | 4f70f10 | 2017-04-12 19:32:55 +0200 | [diff] [blame] | 113 | mFooter = new QSSecurityFooter(this, context); |
| 114 | addView(mFooter.getView()); |
| 115 | |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 116 | updateResources(); |
Jorim Jaggi | 3f48f46 | 2014-07-08 16:53:29 +0200 | [diff] [blame] | 117 | |
| 118 | mBrightnessController = new BrightnessController(getContext(), |
Jason Monk | e5b770e | 2017-03-03 21:49:29 -0500 | [diff] [blame] | 119 | findViewById(R.id.brightness_icon), |
| 120 | findViewById(R.id.brightness_slider)); |
| 121 | } |
| 122 | |
| 123 | protected void addDivider() { |
| 124 | mDivider = LayoutInflater.from(mContext).inflate(R.layout.qs_divider, this, false); |
Jason Monk | 824ffff | 2017-04-11 15:49:06 -0400 | [diff] [blame] | 125 | mDivider.setBackgroundColor(Utils.applyAlpha(mDivider.getAlpha(), |
| 126 | getColorForState(mContext, Tile.STATE_ACTIVE))); |
Jason Monk | e5b770e | 2017-03-03 21:49:29 -0500 | [diff] [blame] | 127 | addView(mDivider); |
| 128 | } |
| 129 | |
| 130 | public View getDivider() { |
| 131 | return mDivider; |
Jason Monk | 3250885 | 2017-01-18 09:17:13 -0500 | [diff] [blame] | 132 | } |
Adrian Roos | 1ef80fe | 2014-07-14 22:53:54 +0200 | [diff] [blame] | 133 | |
Amin Shaikh | 15781d6 | 2018-02-16 16:00:13 -0500 | [diff] [blame^] | 134 | public View getPageIndicator() { |
| 135 | return mPageIndicator; |
| 136 | } |
| 137 | |
Jason Monk | 377e7ad | 2016-02-16 14:03:21 -0500 | [diff] [blame] | 138 | public boolean isShowingCustomize() { |
| 139 | return mCustomizePanel != null && mCustomizePanel.isCustomizing(); |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 140 | } |
| 141 | |
Jason Monk | caf3762 | 2015-08-18 12:33:50 -0400 | [diff] [blame] | 142 | @Override |
| 143 | protected void onAttachedToWindow() { |
| 144 | super.onAttachedToWindow(); |
Evan Laird | 92fbcb2 | 2018-02-16 15:25:53 +0000 | [diff] [blame] | 145 | Dependency.get(TunerService.class).addTunable(this, QS_SHOW_BRIGHTNESS); |
Jason Monk | f160edca | 2016-03-30 13:48:56 -0400 | [diff] [blame] | 146 | if (mHost != null) { |
| 147 | setTiles(mHost.getTiles()); |
| 148 | } |
Adrian Roos | b01793f | 2017-08-09 14:34:55 +0200 | [diff] [blame] | 149 | if (mBrightnessMirrorController != null) { |
| 150 | mBrightnessMirrorController.addCallback(this); |
| 151 | } |
Jason Monk | caf3762 | 2015-08-18 12:33:50 -0400 | [diff] [blame] | 152 | } |
| 153 | |
| 154 | @Override |
| 155 | protected void onDetachedFromWindow() { |
Jason Monk | de850bb | 2017-02-01 19:26:30 -0500 | [diff] [blame] | 156 | Dependency.get(TunerService.class).removeTunable(this); |
| 157 | if (mHost != null) { |
| 158 | mHost.removeCallback(this); |
| 159 | } |
Jason Monk | f160edca | 2016-03-30 13:48:56 -0400 | [diff] [blame] | 160 | for (TileRecord record : mRecords) { |
| 161 | record.tile.removeCallbacks(); |
| 162 | } |
Adrian Roos | b01793f | 2017-08-09 14:34:55 +0200 | [diff] [blame] | 163 | if (mBrightnessMirrorController != null) { |
| 164 | mBrightnessMirrorController.removeCallback(this); |
| 165 | } |
Jason Monk | caf3762 | 2015-08-18 12:33:50 -0400 | [diff] [blame] | 166 | super.onDetachedFromWindow(); |
| 167 | } |
| 168 | |
| 169 | @Override |
Jason Monk | 46dbfb4 | 2016-02-25 14:59:20 -0500 | [diff] [blame] | 170 | public void onTilesChanged() { |
| 171 | setTiles(mHost.getTiles()); |
| 172 | } |
| 173 | |
| 174 | @Override |
Jason Monk | caf3762 | 2015-08-18 12:33:50 -0400 | [diff] [blame] | 175 | public void onTuningChanged(String key, String newValue) { |
| 176 | if (QS_SHOW_BRIGHTNESS.equals(key)) { |
Evan Laird | 92fbcb2 | 2018-02-16 15:25:53 +0000 | [diff] [blame] | 177 | mBrightnessView.setVisibility(newValue == null || Integer.parseInt(newValue) != 0 |
| 178 | ? VISIBLE : GONE); |
Jason Monk | caf3762 | 2015-08-18 12:33:50 -0400 | [diff] [blame] | 179 | } |
| 180 | } |
| 181 | |
Jason Monk | a992732 | 2015-12-13 16:22:37 -0500 | [diff] [blame] | 182 | public void openDetails(String subPanel) { |
Jason Monk | 702e2eb | 2017-03-03 16:53:44 -0500 | [diff] [blame] | 183 | QSTile tile = getTile(subPanel); |
Jason Monk | cb4b31d | 2017-05-03 10:37:34 -0400 | [diff] [blame] | 184 | showDetailAdapter(true, tile.getDetailAdapter(), new int[]{getWidth() / 2, 0}); |
Jason Monk | a992732 | 2015-12-13 16:22:37 -0500 | [diff] [blame] | 185 | } |
| 186 | |
Jason Monk | 702e2eb | 2017-03-03 16:53:44 -0500 | [diff] [blame] | 187 | private QSTile getTile(String subPanel) { |
Jason Monk | a992732 | 2015-12-13 16:22:37 -0500 | [diff] [blame] | 188 | for (int i = 0; i < mRecords.size(); i++) { |
| 189 | if (subPanel.equals(mRecords.get(i).tile.getTileSpec())) { |
| 190 | return mRecords.get(i).tile; |
| 191 | } |
| 192 | } |
| 193 | return mHost.createTile(subPanel); |
| 194 | } |
| 195 | |
Adrian Roos | 5fd872e | 2014-08-12 17:28:58 +0200 | [diff] [blame] | 196 | public void setBrightnessMirror(BrightnessMirrorController c) { |
Adrian Roos | b01793f | 2017-08-09 14:34:55 +0200 | [diff] [blame] | 197 | if (mBrightnessMirrorController != null) { |
| 198 | mBrightnessMirrorController.removeCallback(this); |
| 199 | } |
Adrian Roos | 429c962 | 2016-06-15 13:02:17 -0700 | [diff] [blame] | 200 | mBrightnessMirrorController = c; |
Adrian Roos | b01793f | 2017-08-09 14:34:55 +0200 | [diff] [blame] | 201 | if (mBrightnessMirrorController != null) { |
| 202 | mBrightnessMirrorController.addCallback(this); |
| 203 | } |
| 204 | updateBrightnessMirror(); |
| 205 | } |
| 206 | |
| 207 | @Override |
| 208 | public void onBrightnessMirrorReinflated(View brightnessMirror) { |
| 209 | updateBrightnessMirror(); |
Adrian Roos | 5fd872e | 2014-08-12 17:28:58 +0200 | [diff] [blame] | 210 | } |
| 211 | |
Jason Monk | b46059a | 2016-06-30 14:22:42 -0400 | [diff] [blame] | 212 | View getBrightnessView() { |
| 213 | return mBrightnessView; |
| 214 | } |
| 215 | |
Jason Monk | e5b770e | 2017-03-03 21:49:29 -0500 | [diff] [blame] | 216 | public void setCallback(QSDetail.Callback callback) { |
John Spurlock | 5729d09 | 2014-05-29 17:42:51 -0400 | [diff] [blame] | 217 | mCallback = callback; |
| 218 | } |
| 219 | |
Jason Monk | 8b9d67f | 2016-03-02 08:59:08 -0500 | [diff] [blame] | 220 | public void setHost(QSTileHost host, QSCustomizer customizer) { |
Adrian Roos | 1ef80fe | 2014-07-14 22:53:54 +0200 | [diff] [blame] | 221 | mHost = host; |
Jason Monk | 46dbfb4 | 2016-02-25 14:59:20 -0500 | [diff] [blame] | 222 | mHost.addCallback(this); |
| 223 | setTiles(mHost.getTiles()); |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 224 | mFooter.setHostEnvironment(host); |
Jason Monk | 8b9d67f | 2016-03-02 08:59:08 -0500 | [diff] [blame] | 225 | mCustomizePanel = customizer; |
| 226 | if (mCustomizePanel != null) { |
| 227 | mCustomizePanel.setHost(mHost); |
| 228 | } |
Adrian Roos | 1ef80fe | 2014-07-14 22:53:54 +0200 | [diff] [blame] | 229 | } |
| 230 | |
Adrian Roos | 00a0b1f | 2014-07-16 16:44:49 +0200 | [diff] [blame] | 231 | public QSTileHost getHost() { |
| 232 | return mHost; |
| 233 | } |
Adrian Roos | 1ef80fe | 2014-07-14 22:53:54 +0200 | [diff] [blame] | 234 | |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 235 | public void updateResources() { |
John Spurlock | 4bf3198 | 2014-05-21 13:04:22 -0400 | [diff] [blame] | 236 | final Resources res = mContext.getResources(); |
Amin Shaikh | 15781d6 | 2018-02-16 16:00:13 -0500 | [diff] [blame^] | 237 | setPadding(0, res.getDimensionPixelSize(R.dimen.qs_brightness_padding_top), |
| 238 | 0, res.getDimensionPixelSize(R.dimen.qs_panel_padding_bottom)); |
Jason Monk | a758ba6 | 2015-07-14 12:29:28 -0400 | [diff] [blame] | 239 | for (TileRecord r : mRecords) { |
| 240 | r.tile.clearState(); |
| 241 | } |
John Spurlock | 1a462c1 | 2014-07-14 10:52:01 -0400 | [diff] [blame] | 242 | if (mListening) { |
| 243 | refreshAllTiles(); |
| 244 | } |
Jason Monk | caf3762 | 2015-08-18 12:33:50 -0400 | [diff] [blame] | 245 | if (mTileLayout != null) { |
| 246 | mTileLayout.updateResources(); |
| 247 | } |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 248 | } |
| 249 | |
Jorim Jaggi | e17c4b4 | 2014-08-26 17:27:31 +0200 | [diff] [blame] | 250 | @Override |
| 251 | protected void onConfigurationChanged(Configuration newConfig) { |
| 252 | super.onConfigurationChanged(newConfig); |
Jorim Jaggi | e17c4b4 | 2014-08-26 17:27:31 +0200 | [diff] [blame] | 253 | mFooter.onConfigurationChanged(); |
Adrian Roos | 429c962 | 2016-06-15 13:02:17 -0700 | [diff] [blame] | 254 | |
Adrian Roos | b01793f | 2017-08-09 14:34:55 +0200 | [diff] [blame] | 255 | updateBrightnessMirror(); |
| 256 | } |
| 257 | |
| 258 | public void updateBrightnessMirror() { |
Adrian Roos | 429c962 | 2016-06-15 13:02:17 -0700 | [diff] [blame] | 259 | if (mBrightnessMirrorController != null) { |
Adrian Roos | b01793f | 2017-08-09 14:34:55 +0200 | [diff] [blame] | 260 | ToggleSliderView brightnessSlider = findViewById(R.id.brightness_slider); |
| 261 | ToggleSliderView mirrorSlider = mBrightnessMirrorController.getMirror() |
| 262 | .findViewById(R.id.brightness_slider); |
| 263 | brightnessSlider.setMirror(mirrorSlider); |
| 264 | brightnessSlider.setMirrorController(mBrightnessMirrorController); |
Adrian Roos | 429c962 | 2016-06-15 13:02:17 -0700 | [diff] [blame] | 265 | } |
Jorim Jaggi | e17c4b4 | 2014-08-26 17:27:31 +0200 | [diff] [blame] | 266 | } |
| 267 | |
Jason Monk | bd6dbb0 | 2015-09-03 15:46:25 -0400 | [diff] [blame] | 268 | public void onCollapse() { |
Yoshinori Hirano | 1dd7d07 | 2016-09-05 16:11:59 +0900 | [diff] [blame] | 269 | if (mCustomizePanel != null && mCustomizePanel.isShown()) { |
Jason Monk | b9c0019 | 2015-10-07 11:45:33 -0400 | [diff] [blame] | 270 | mCustomizePanel.hide(mCustomizePanel.getWidth() / 2, mCustomizePanel.getHeight() / 2); |
Jason Monk | bd6dbb0 | 2015-09-03 15:46:25 -0400 | [diff] [blame] | 271 | } |
| 272 | } |
| 273 | |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 274 | public void setExpanded(boolean expanded) { |
John Spurlock | 5729d09 | 2014-05-29 17:42:51 -0400 | [diff] [blame] | 275 | if (mExpanded == expanded) return; |
| 276 | mExpanded = expanded; |
Amin Shaikh | 15781d6 | 2018-02-16 16:00:13 -0500 | [diff] [blame^] | 277 | if (!mExpanded && mTileLayout instanceof PagedTileLayout) { |
| 278 | ((PagedTileLayout) mTileLayout).setCurrentItem(0, false); |
Jason Monk | 162011e | 2016-02-19 08:11:55 -0500 | [diff] [blame] | 279 | } |
Jason Monk | 8c09ac7 | 2017-03-16 11:53:40 -0400 | [diff] [blame] | 280 | mMetricsLogger.visibility(MetricsEvent.QS_PANEL, mExpanded); |
John Spurlock | 5729d09 | 2014-05-29 17:42:51 -0400 | [diff] [blame] | 281 | if (!mExpanded) { |
John Spurlock | f7ae442 | 2014-08-01 12:45:18 -0400 | [diff] [blame] | 282 | closeDetail(); |
Chris Wren | 457a21c | 2015-05-06 17:50:34 -0400 | [diff] [blame] | 283 | } else { |
| 284 | logTiles(); |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 285 | } |
Jorim Jaggi | e65e310 | 2014-07-01 22:00:50 +0200 | [diff] [blame] | 286 | } |
| 287 | |
Amin Shaikh | 5da602f | 2018-02-02 15:00:25 -0500 | [diff] [blame] | 288 | public void setPageListener(final PagedTileLayout.PageListener pageListener) { |
| 289 | if (mTileLayout instanceof PagedTileLayout) { |
| 290 | ((PagedTileLayout) mTileLayout).setPageListener(pageListener); |
Amin Shaikh | 5da602f | 2018-02-02 15:00:25 -0500 | [diff] [blame] | 291 | } |
| 292 | } |
| 293 | |
Muyuan Li | 0e9f538 | 2016-04-27 15:51:15 -0700 | [diff] [blame] | 294 | public boolean isExpanded() { |
| 295 | return mExpanded; |
| 296 | } |
| 297 | |
Jorim Jaggi | e65e310 | 2014-07-01 22:00:50 +0200 | [diff] [blame] | 298 | public void setListening(boolean listening) { |
| 299 | if (mListening == listening) return; |
| 300 | mListening = listening; |
Jason Monk | 1bec6af | 2016-05-31 15:40:58 -0400 | [diff] [blame] | 301 | if (mTileLayout != null) { |
| 302 | mTileLayout.setListening(listening); |
John Spurlock | 1a462c1 | 2014-07-14 10:52:01 -0400 | [diff] [blame] | 303 | } |
Jason Monk | 3d5f551 | 2014-07-25 11:17:28 -0400 | [diff] [blame] | 304 | mFooter.setListening(mListening); |
John Spurlock | 1a462c1 | 2014-07-14 10:52:01 -0400 | [diff] [blame] | 305 | if (mListening) { |
| 306 | refreshAllTiles(); |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 307 | } |
Jason Monk | b5ece9a | 2016-04-22 11:40:36 -0400 | [diff] [blame] | 308 | if (mBrightnessView.getVisibility() == View.VISIBLE) { |
| 309 | if (listening) { |
| 310 | mBrightnessController.registerCallbacks(); |
| 311 | } else { |
| 312 | mBrightnessController.unregisterCallbacks(); |
| 313 | } |
Jorim Jaggi | 3f48f46 | 2014-07-08 16:53:29 +0200 | [diff] [blame] | 314 | } |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 315 | } |
| 316 | |
Jorim Jaggi | 1ecd7cd | 2014-11-03 16:18:03 +0100 | [diff] [blame] | 317 | public void refreshAllTiles() { |
yuemingw | eb2bf7d18 | 2018-01-23 16:05:08 +0000 | [diff] [blame] | 318 | mBrightnessController.checkRestrictionAndSetEnabled(); |
John Spurlock | 1a462c1 | 2014-07-14 10:52:01 -0400 | [diff] [blame] | 319 | for (TileRecord r : mRecords) { |
| 320 | r.tile.refreshState(); |
| 321 | } |
Jason Monk | 3d5f551 | 2014-07-25 11:17:28 -0400 | [diff] [blame] | 322 | mFooter.refreshState(); |
John Spurlock | 1a462c1 | 2014-07-14 10:52:01 -0400 | [diff] [blame] | 323 | } |
| 324 | |
Adrian Roos | 970be53 | 2014-11-21 15:50:16 +0100 | [diff] [blame] | 325 | public void showDetailAdapter(boolean show, DetailAdapter adapter, int[] locationInWindow) { |
| 326 | int xInWindow = locationInWindow[0]; |
| 327 | int yInWindow = locationInWindow[1]; |
Jason Monk | 377e7ad | 2016-02-16 14:03:21 -0500 | [diff] [blame] | 328 | ((View) getParent()).getLocationInWindow(locationInWindow); |
Adrian Roos | 970be53 | 2014-11-21 15:50:16 +0100 | [diff] [blame] | 329 | |
Adrian Roos | 1ef80fe | 2014-07-14 22:53:54 +0200 | [diff] [blame] | 330 | Record r = new Record(); |
| 331 | r.detailAdapter = adapter; |
Adrian Roos | 970be53 | 2014-11-21 15:50:16 +0100 | [diff] [blame] | 332 | r.x = xInWindow - locationInWindow[0]; |
| 333 | r.y = yInWindow - locationInWindow[1]; |
| 334 | |
| 335 | locationInWindow[0] = xInWindow; |
| 336 | locationInWindow[1] = yInWindow; |
| 337 | |
Adrian Roos | 1ef80fe | 2014-07-14 22:53:54 +0200 | [diff] [blame] | 338 | showDetail(show, r); |
| 339 | } |
| 340 | |
Jason Monk | dc35dcb | 2015-12-04 16:36:15 -0500 | [diff] [blame] | 341 | protected void showDetail(boolean show, Record r) { |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 342 | mHandler.obtainMessage(H.SHOW_DETAIL, show ? 1 : 0, 0, r).sendToTarget(); |
| 343 | } |
| 344 | |
Jason Monk | 702e2eb | 2017-03-03 16:53:44 -0500 | [diff] [blame] | 345 | public void setTiles(Collection<QSTile> tiles) { |
Julia Reynolds | 20aef8a | 2016-05-04 16:44:08 -0400 | [diff] [blame] | 346 | setTiles(tiles, false); |
| 347 | } |
| 348 | |
Jason Monk | 702e2eb | 2017-03-03 16:53:44 -0500 | [diff] [blame] | 349 | public void setTiles(Collection<QSTile> tiles, boolean collapsedView) { |
John Spurlock | bceed06 | 2014-08-10 18:04:16 -0400 | [diff] [blame] | 350 | for (TileRecord record : mRecords) { |
Jason Monk | caf3762 | 2015-08-18 12:33:50 -0400 | [diff] [blame] | 351 | mTileLayout.removeTile(record); |
Xiaohui Chen | 08e266c | 2016-04-18 12:53:28 -0700 | [diff] [blame] | 352 | record.tile.removeCallback(record.callback); |
John Spurlock | bceed06 | 2014-08-10 18:04:16 -0400 | [diff] [blame] | 353 | } |
| 354 | mRecords.clear(); |
Jason Monk | 702e2eb | 2017-03-03 16:53:44 -0500 | [diff] [blame] | 355 | for (QSTile tile : tiles) { |
Julia Reynolds | 20aef8a | 2016-05-04 16:44:08 -0400 | [diff] [blame] | 356 | addTile(tile, collapsedView); |
John Spurlock | bceed06 | 2014-08-10 18:04:16 -0400 | [diff] [blame] | 357 | } |
John Spurlock | bceed06 | 2014-08-10 18:04:16 -0400 | [diff] [blame] | 358 | } |
| 359 | |
Jason Monk | ec87a87 | 2016-03-01 15:00:16 -0500 | [diff] [blame] | 360 | protected void drawTile(TileRecord r, QSTile.State state) { |
John Spurlock | 20c8905 | 2015-05-11 13:11:24 -0400 | [diff] [blame] | 361 | r.tileView.onStateChanged(state); |
| 362 | } |
| 363 | |
Jason Monk | 702e2eb | 2017-03-03 16:53:44 -0500 | [diff] [blame] | 364 | protected QSTileView createTileView(QSTile tile, boolean collapsedView) { |
| 365 | return mHost.createTileView(tile, collapsedView); |
Jason Monk | dc35dcb | 2015-12-04 16:36:15 -0500 | [diff] [blame] | 366 | } |
| 367 | |
Xiaohui Chen | 6644893 | 2016-04-18 12:53:28 -0700 | [diff] [blame] | 368 | protected boolean shouldShowDetail() { |
| 369 | return mExpanded; |
| 370 | } |
| 371 | |
Jason Monk | 702e2eb | 2017-03-03 16:53:44 -0500 | [diff] [blame] | 372 | protected TileRecord addTile(final QSTile tile, boolean collapsedView) { |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 373 | final TileRecord r = new TileRecord(); |
| 374 | r.tile = tile; |
Julia Reynolds | 20aef8a | 2016-05-04 16:44:08 -0400 | [diff] [blame] | 375 | r.tileView = createTileView(tile, collapsedView); |
John Spurlock | bceed06 | 2014-08-10 18:04:16 -0400 | [diff] [blame] | 376 | final QSTile.Callback callback = new QSTile.Callback() { |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 377 | @Override |
| 378 | public void onStateChanged(QSTile.State state) { |
Jason Monk | 377e7ad | 2016-02-16 14:03:21 -0500 | [diff] [blame] | 379 | drawTile(r, state); |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 380 | } |
Jason Monk | ca894a0 | 2016-01-12 15:30:22 -0500 | [diff] [blame] | 381 | |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 382 | @Override |
| 383 | public void onShowDetail(boolean show) { |
Xiaohui Chen | 6644893 | 2016-04-18 12:53:28 -0700 | [diff] [blame] | 384 | // Both the collapsed and full QS panels get this callback, this check determines |
| 385 | // which one should handle showing the detail. |
| 386 | if (shouldShowDetail()) { |
| 387 | QSPanel.this.showDetail(show, r); |
| 388 | } |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 389 | } |
Jason Monk | ca894a0 | 2016-01-12 15:30:22 -0500 | [diff] [blame] | 390 | |
John Spurlock | 7f8f22a | 2014-07-02 18:54:17 -0400 | [diff] [blame] | 391 | @Override |
| 392 | public void onToggleStateChanged(boolean state) { |
| 393 | if (mDetailRecord == r) { |
| 394 | fireToggleStateChanged(state); |
| 395 | } |
| 396 | } |
Jason Monk | ca894a0 | 2016-01-12 15:30:22 -0500 | [diff] [blame] | 397 | |
John Spurlock | 486b78e | 2014-07-07 08:37:56 -0400 | [diff] [blame] | 398 | @Override |
| 399 | public void onScanStateChanged(boolean state) { |
John Spurlock | 465cefa | 2014-08-16 10:39:33 -0400 | [diff] [blame] | 400 | r.scanState = state; |
John Spurlock | 486b78e | 2014-07-07 08:37:56 -0400 | [diff] [blame] | 401 | if (mDetailRecord == r) { |
John Spurlock | 465cefa | 2014-08-16 10:39:33 -0400 | [diff] [blame] | 402 | fireScanStateChanged(r.scanState); |
John Spurlock | 486b78e | 2014-07-07 08:37:56 -0400 | [diff] [blame] | 403 | } |
| 404 | } |
Selim Cinek | 4fda7b2 | 2014-08-18 22:07:25 +0200 | [diff] [blame] | 405 | |
| 406 | @Override |
| 407 | public void onAnnouncementRequested(CharSequence announcement) { |
dooyoung.hwang | 1b00662 | 2016-12-22 20:04:20 +0900 | [diff] [blame] | 408 | if (announcement != null) { |
| 409 | mHandler.obtainMessage(H.ANNOUNCE_FOR_ACCESSIBILITY, announcement) |
| 410 | .sendToTarget(); |
| 411 | } |
Selim Cinek | 4fda7b2 | 2014-08-18 22:07:25 +0200 | [diff] [blame] | 412 | } |
John Spurlock | bceed06 | 2014-08-10 18:04:16 -0400 | [diff] [blame] | 413 | }; |
Jason Monk | ca894a0 | 2016-01-12 15:30:22 -0500 | [diff] [blame] | 414 | r.tile.addCallback(callback); |
Xiaohui Chen | 08e266c | 2016-04-18 12:53:28 -0700 | [diff] [blame] | 415 | r.callback = callback; |
Jason Monk | 702e2eb | 2017-03-03 16:53:44 -0500 | [diff] [blame] | 416 | r.tileView.init(r.tile); |
John Spurlock | ccb6b9a | 2014-05-17 15:54:40 -0400 | [diff] [blame] | 417 | r.tile.refreshState(); |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 418 | mRecords.add(r); |
| 419 | |
Jason Monk | caf3762 | 2015-08-18 12:33:50 -0400 | [diff] [blame] | 420 | if (mTileLayout != null) { |
| 421 | mTileLayout.addTile(r); |
| 422 | } |
Muyuan Li | b40004b | 2016-05-11 14:47:29 -0700 | [diff] [blame] | 423 | |
| 424 | return r; |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 425 | } |
| 426 | |
Jason Monk | 2142843 | 2016-02-10 16:42:38 -0500 | [diff] [blame] | 427 | |
Jason Monk | 4bb7b1a | 2016-05-27 15:19:15 -0400 | [diff] [blame] | 428 | public void showEdit(final View v) { |
Jason Monk | 2142843 | 2016-02-10 16:42:38 -0500 | [diff] [blame] | 429 | v.post(new Runnable() { |
| 430 | @Override |
| 431 | public void run() { |
| 432 | if (mCustomizePanel != null) { |
| 433 | if (!mCustomizePanel.isCustomizing()) { |
| 434 | int[] loc = new int[2]; |
| 435 | v.getLocationInWindow(loc); |
Jason Monk | 4bb7b1a | 2016-05-27 15:19:15 -0400 | [diff] [blame] | 436 | int x = loc[0] + v.getWidth() / 2; |
| 437 | int y = loc[1] + v.getHeight() / 2; |
Jason Monk | 2142843 | 2016-02-10 16:42:38 -0500 | [diff] [blame] | 438 | mCustomizePanel.show(x, y); |
| 439 | } |
| 440 | } |
| 441 | |
| 442 | } |
| 443 | }); |
| 444 | } |
| 445 | |
John Spurlock | f7ae442 | 2014-08-01 12:45:18 -0400 | [diff] [blame] | 446 | public void closeDetail() { |
Yoshinori Hirano | 1dd7d07 | 2016-09-05 16:11:59 +0900 | [diff] [blame] | 447 | if (mCustomizePanel != null && mCustomizePanel.isShown()) { |
Jason Monk | bd6dbb0 | 2015-09-03 15:46:25 -0400 | [diff] [blame] | 448 | // Treat this as a detail panel for now, to make things easy. |
Jason Monk | b9c0019 | 2015-10-07 11:45:33 -0400 | [diff] [blame] | 449 | mCustomizePanel.hide(mCustomizePanel.getWidth() / 2, mCustomizePanel.getHeight() / 2); |
Jason Monk | bd6dbb0 | 2015-09-03 15:46:25 -0400 | [diff] [blame] | 450 | return; |
| 451 | } |
John Spurlock | f7ae442 | 2014-08-01 12:45:18 -0400 | [diff] [blame] | 452 | showDetail(false, mDetailRecord); |
| 453 | } |
| 454 | |
Jorim Jaggi | 8bc983e | 2014-12-10 17:45:50 +0100 | [diff] [blame] | 455 | public int getGridHeight() { |
Jason Monk | 162011e | 2016-02-19 08:11:55 -0500 | [diff] [blame] | 456 | return getMeasuredHeight(); |
Jorim Jaggi | 8bc983e | 2014-12-10 17:45:50 +0100 | [diff] [blame] | 457 | } |
| 458 | |
Jason Monk | dc35dcb | 2015-12-04 16:36:15 -0500 | [diff] [blame] | 459 | protected void handleShowDetail(Record r, boolean show) { |
Adrian Roos | 1ef80fe | 2014-07-14 22:53:54 +0200 | [diff] [blame] | 460 | if (r instanceof TileRecord) { |
| 461 | handleShowDetailTile((TileRecord) r, show); |
| 462 | } else { |
Adrian Roos | 970be53 | 2014-11-21 15:50:16 +0100 | [diff] [blame] | 463 | int x = 0; |
| 464 | int y = 0; |
| 465 | if (r != null) { |
| 466 | x = r.x; |
| 467 | y = r.y; |
| 468 | } |
| 469 | handleShowDetailImpl(r, show, x, y); |
Adrian Roos | 1ef80fe | 2014-07-14 22:53:54 +0200 | [diff] [blame] | 470 | } |
| 471 | } |
| 472 | |
| 473 | private void handleShowDetailTile(TileRecord r, boolean show) { |
Jason Monk | efe3d3f | 2015-06-10 16:48:03 -0400 | [diff] [blame] | 474 | if ((mDetailRecord != null) == show && mDetailRecord == r) return; |
Adrian Roos | 1ef80fe | 2014-07-14 22:53:54 +0200 | [diff] [blame] | 475 | |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 476 | if (show) { |
John Spurlock | 7f8f22a | 2014-07-02 18:54:17 -0400 | [diff] [blame] | 477 | r.detailAdapter = r.tile.getDetailAdapter(); |
| 478 | if (r.detailAdapter == null) return; |
Adrian Roos | 1ef80fe | 2014-07-14 22:53:54 +0200 | [diff] [blame] | 479 | } |
Jason Monk | 0d6a1c4 | 2015-04-20 16:38:51 -0400 | [diff] [blame] | 480 | r.tile.setDetailListening(show); |
Adrian Roos | 1ef80fe | 2014-07-14 22:53:54 +0200 | [diff] [blame] | 481 | int x = r.tileView.getLeft() + r.tileView.getWidth() / 2; |
Jason Monk | 702e2eb | 2017-03-03 16:53:44 -0500 | [diff] [blame] | 482 | int y = r.tileView.getDetailY() + mTileLayout.getOffsetTop(r) + getTop(); |
Adrian Roos | 1ef80fe | 2014-07-14 22:53:54 +0200 | [diff] [blame] | 483 | handleShowDetailImpl(r, show, x, y); |
| 484 | } |
| 485 | |
| 486 | private void handleShowDetailImpl(Record r, boolean show, int x, int y) { |
Jason Monk | 377e7ad | 2016-02-16 14:03:21 -0500 | [diff] [blame] | 487 | setDetailRecord(show ? r : null); |
| 488 | fireShowingDetail(show ? r.detailAdapter : null, x, y); |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 489 | } |
| 490 | |
Muyuan Li | 4074b46 | 2016-05-06 13:40:42 -0700 | [diff] [blame] | 491 | protected void setDetailRecord(Record r) { |
Jason Monk | 377e7ad | 2016-02-16 14:03:21 -0500 | [diff] [blame] | 492 | if (r == mDetailRecord) return; |
| 493 | mDetailRecord = r; |
| 494 | final boolean scanState = mDetailRecord instanceof TileRecord |
| 495 | && ((TileRecord) mDetailRecord).scanState; |
| 496 | fireScanStateChanged(scanState); |
| 497 | } |
| 498 | |
| 499 | void setGridContentVisibility(boolean visible) { |
Selim Cinek | e32010a | 2014-08-20 23:50:41 +0200 | [diff] [blame] | 500 | int newVis = visible ? VISIBLE : INVISIBLE; |
Jason Monk | 162011e | 2016-02-19 08:11:55 -0500 | [diff] [blame] | 501 | setVisibility(newVis); |
Chris Wren | 457a21c | 2015-05-06 17:50:34 -0400 | [diff] [blame] | 502 | if (mGridContentVisible != visible) { |
Jason Monk | 8c09ac7 | 2017-03-16 11:53:40 -0400 | [diff] [blame] | 503 | mMetricsLogger.visibility(MetricsEvent.QS_PANEL, newVis); |
Chris Wren | 457a21c | 2015-05-06 17:50:34 -0400 | [diff] [blame] | 504 | } |
Selim Cinek | e32010a | 2014-08-20 23:50:41 +0200 | [diff] [blame] | 505 | mGridContentVisible = visible; |
| 506 | } |
| 507 | |
Chris Wren | 457a21c | 2015-05-06 17:50:34 -0400 | [diff] [blame] | 508 | private void logTiles() { |
| 509 | for (int i = 0; i < mRecords.size(); i++) { |
Jason Monk | cb4b31d | 2017-05-03 10:37:34 -0400 | [diff] [blame] | 510 | QSTile tile = mRecords.get(i).tile; |
| 511 | mMetricsLogger.write(tile.populate(new LogMaker(tile.getMetricsCategory()) |
| 512 | .setType(MetricsEvent.TYPE_OPEN))); |
Chris Wren | 457a21c | 2015-05-06 17:50:34 -0400 | [diff] [blame] | 513 | } |
| 514 | } |
| 515 | |
Jason Monk | 377e7ad | 2016-02-16 14:03:21 -0500 | [diff] [blame] | 516 | private void fireShowingDetail(DetailAdapter detail, int x, int y) { |
John Spurlock | 5729d09 | 2014-05-29 17:42:51 -0400 | [diff] [blame] | 517 | if (mCallback != null) { |
Jason Monk | 377e7ad | 2016-02-16 14:03:21 -0500 | [diff] [blame] | 518 | mCallback.onShowingDetail(detail, x, y); |
John Spurlock | 7f8f22a | 2014-07-02 18:54:17 -0400 | [diff] [blame] | 519 | } |
| 520 | } |
| 521 | |
| 522 | private void fireToggleStateChanged(boolean state) { |
| 523 | if (mCallback != null) { |
| 524 | mCallback.onToggleStateChanged(state); |
John Spurlock | 5729d09 | 2014-05-29 17:42:51 -0400 | [diff] [blame] | 525 | } |
| 526 | } |
| 527 | |
John Spurlock | 486b78e | 2014-07-07 08:37:56 -0400 | [diff] [blame] | 528 | private void fireScanStateChanged(boolean state) { |
| 529 | if (mCallback != null) { |
| 530 | mCallback.onScanStateChanged(state); |
| 531 | } |
| 532 | } |
| 533 | |
Jason Monk | 7e53f20 | 2016-01-28 10:40:20 -0500 | [diff] [blame] | 534 | public void clickTile(ComponentName tile) { |
| 535 | final String spec = CustomTile.toSpec(tile); |
| 536 | final int N = mRecords.size(); |
| 537 | for (int i = 0; i < N; i++) { |
| 538 | if (mRecords.get(i).tile.getTileSpec().equals(spec)) { |
| 539 | mRecords.get(i).tile.click(); |
| 540 | break; |
| 541 | } |
| 542 | } |
| 543 | } |
| 544 | |
Jason Monk | 162011e | 2016-02-19 08:11:55 -0500 | [diff] [blame] | 545 | QSTileLayout getTileLayout() { |
| 546 | return mTileLayout; |
| 547 | } |
| 548 | |
Jason Monk | 702e2eb | 2017-03-03 16:53:44 -0500 | [diff] [blame] | 549 | QSTileView getTileView(QSTile tile) { |
Jason Monk | 162011e | 2016-02-19 08:11:55 -0500 | [diff] [blame] | 550 | for (TileRecord r : mRecords) { |
| 551 | if (r.tile == tile) { |
| 552 | return r.tileView; |
| 553 | } |
| 554 | } |
| 555 | return null; |
| 556 | } |
| 557 | |
Jason Monk | e5b770e | 2017-03-03 21:49:29 -0500 | [diff] [blame] | 558 | public QSSecurityFooter getFooter() { |
Jason Monk | df36aed | 2016-07-25 11:21:56 -0400 | [diff] [blame] | 559 | return mFooter; |
| 560 | } |
| 561 | |
phweiss | a0cb251 | 2016-12-14 21:37:48 +0100 | [diff] [blame] | 562 | public void showDeviceMonitoringDialog() { |
| 563 | mFooter.showDeviceMonitoringDialog(); |
| 564 | } |
| 565 | |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 566 | private class H extends Handler { |
| 567 | private static final int SHOW_DETAIL = 1; |
| 568 | private static final int SET_TILE_VISIBILITY = 2; |
dooyoung.hwang | 1b00662 | 2016-12-22 20:04:20 +0900 | [diff] [blame] | 569 | private static final int ANNOUNCE_FOR_ACCESSIBILITY = 3; |
Jason Monk | cb4b31d | 2017-05-03 10:37:34 -0400 | [diff] [blame] | 570 | |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 571 | @Override |
| 572 | public void handleMessage(Message msg) { |
| 573 | if (msg.what == SHOW_DETAIL) { |
Jason Monk | cb4b31d | 2017-05-03 10:37:34 -0400 | [diff] [blame] | 574 | handleShowDetail((Record) msg.obj, msg.arg1 != 0); |
dooyoung.hwang | 1b00662 | 2016-12-22 20:04:20 +0900 | [diff] [blame] | 575 | } else if (msg.what == ANNOUNCE_FOR_ACCESSIBILITY) { |
Jason Monk | cb4b31d | 2017-05-03 10:37:34 -0400 | [diff] [blame] | 576 | announceForAccessibility((CharSequence) msg.obj); |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 577 | } |
| 578 | } |
| 579 | } |
| 580 | |
Jason Monk | dc35dcb | 2015-12-04 16:36:15 -0500 | [diff] [blame] | 581 | protected static class Record { |
John Spurlock | 7f8f22a | 2014-07-02 18:54:17 -0400 | [diff] [blame] | 582 | DetailAdapter detailAdapter; |
Adrian Roos | 970be53 | 2014-11-21 15:50:16 +0100 | [diff] [blame] | 583 | int x; |
| 584 | int y; |
Adrian Roos | 1ef80fe | 2014-07-14 22:53:54 +0200 | [diff] [blame] | 585 | } |
| 586 | |
Jason Monk | bd6dbb0 | 2015-09-03 15:46:25 -0400 | [diff] [blame] | 587 | public static final class TileRecord extends Record { |
Jason Monk | 702e2eb | 2017-03-03 16:53:44 -0500 | [diff] [blame] | 588 | public QSTile tile; |
| 589 | public com.android.systemui.plugins.qs.QSTileView tileView; |
Jason Monk | 11a7744 | 2015-05-12 19:29:02 -0400 | [diff] [blame] | 590 | public boolean scanState; |
Xiaohui Chen | 08e266c | 2016-04-18 12:53:28 -0700 | [diff] [blame] | 591 | public QSTile.Callback callback; |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 592 | } |
| 593 | |
Jason Monk | caf3762 | 2015-08-18 12:33:50 -0400 | [diff] [blame] | 594 | public interface QSTileLayout { |
| 595 | void addTile(TileRecord tile); |
Jason Monk | cb4b31d | 2017-05-03 10:37:34 -0400 | [diff] [blame] | 596 | |
Jason Monk | caf3762 | 2015-08-18 12:33:50 -0400 | [diff] [blame] | 597 | void removeTile(TileRecord tile); |
Jason Monk | cb4b31d | 2017-05-03 10:37:34 -0400 | [diff] [blame] | 598 | |
Jason Monk | caf3762 | 2015-08-18 12:33:50 -0400 | [diff] [blame] | 599 | int getOffsetTop(TileRecord tile); |
Jason Monk | cb4b31d | 2017-05-03 10:37:34 -0400 | [diff] [blame] | 600 | |
Jason Monk | 9d02a43 | 2016-01-20 16:33:46 -0500 | [diff] [blame] | 601 | boolean updateResources(); |
Jason Monk | 1bec6af | 2016-05-31 15:40:58 -0400 | [diff] [blame] | 602 | |
| 603 | void setListening(boolean listening); |
Jason Monk | caf3762 | 2015-08-18 12:33:50 -0400 | [diff] [blame] | 604 | } |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 605 | } |