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.tiles; |
| 18 | |
Jason Monk | d52356a | 2015-01-28 10:40:41 -0500 | [diff] [blame] | 19 | import java.util.List; |
| 20 | |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 21 | import android.content.Context; |
| 22 | import android.content.Intent; |
| 23 | import android.content.res.Resources; |
| 24 | import android.provider.Settings; |
John Spurlock | ccb6b9a | 2014-05-17 15:54:40 -0400 | [diff] [blame] | 25 | import android.util.Log; |
John Spurlock | 7f8f22a | 2014-07-02 18:54:17 -0400 | [diff] [blame] | 26 | import android.view.View; |
John Spurlock | 7f8f22a | 2014-07-02 18:54:17 -0400 | [diff] [blame] | 27 | import android.view.ViewGroup; |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 28 | |
Jason Monk | d52356a | 2015-01-28 10:40:41 -0500 | [diff] [blame] | 29 | import com.android.settingslib.wifi.AccessPoint; |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 30 | import com.android.systemui.R; |
John Spurlock | 486b78e | 2014-07-07 08:37:56 -0400 | [diff] [blame] | 31 | import com.android.systemui.qs.QSDetailItems; |
| 32 | import com.android.systemui.qs.QSDetailItems.Item; |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 33 | import com.android.systemui.qs.QSTile; |
| 34 | import com.android.systemui.qs.QSTileView; |
| 35 | import com.android.systemui.qs.SignalTileView; |
| 36 | import com.android.systemui.statusbar.policy.NetworkController; |
Jason Monk | d2263cd | 2014-11-10 14:22:56 -0500 | [diff] [blame] | 37 | import com.android.systemui.statusbar.policy.NetworkController.AccessPointController; |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 38 | import com.android.systemui.statusbar.policy.NetworkController.NetworkSignalChangedCallback; |
| 39 | |
| 40 | /** Quick settings tile: Wifi **/ |
| 41 | public class WifiTile extends QSTile<QSTile.SignalState> { |
| 42 | private static final Intent WIFI_SETTINGS = new Intent(Settings.ACTION_WIFI_SETTINGS); |
| 43 | |
| 44 | private final NetworkController mController; |
Jason Monk | d2263cd | 2014-11-10 14:22:56 -0500 | [diff] [blame] | 45 | private final AccessPointController mWifiController; |
John Spurlock | 7f8f22a | 2014-07-02 18:54:17 -0400 | [diff] [blame] | 46 | private final WifiDetailAdapter mDetailAdapter; |
Selim Cinek | 4fda7b2 | 2014-08-18 22:07:25 +0200 | [diff] [blame] | 47 | private final QSTile.SignalState mStateBeforeClick = newTileState(); |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 48 | |
| 49 | public WifiTile(Host host) { |
| 50 | super(host); |
| 51 | mController = host.getNetworkController(); |
Jason Monk | d2263cd | 2014-11-10 14:22:56 -0500 | [diff] [blame] | 52 | mWifiController = mController.getAccessPointController(); |
John Spurlock | 7f8f22a | 2014-07-02 18:54:17 -0400 | [diff] [blame] | 53 | mDetailAdapter = new WifiDetailAdapter(); |
John Spurlock | ccb6b9a | 2014-05-17 15:54:40 -0400 | [diff] [blame] | 54 | } |
| 55 | |
| 56 | @Override |
| 57 | public boolean supportsDualTargets() { |
| 58 | return true; |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 59 | } |
| 60 | |
| 61 | @Override |
| 62 | protected SignalState newTileState() { |
| 63 | return new SignalState(); |
| 64 | } |
| 65 | |
| 66 | @Override |
John Spurlock | ccb6b9a | 2014-05-17 15:54:40 -0400 | [diff] [blame] | 67 | public void setListening(boolean listening) { |
| 68 | if (listening) { |
| 69 | mController.addNetworkSignalChangedCallback(mCallback); |
Jason Monk | d2263cd | 2014-11-10 14:22:56 -0500 | [diff] [blame] | 70 | mWifiController.addAccessPointCallback(mDetailAdapter); |
John Spurlock | ccb6b9a | 2014-05-17 15:54:40 -0400 | [diff] [blame] | 71 | } else { |
| 72 | mController.removeNetworkSignalChangedCallback(mCallback); |
Jason Monk | d2263cd | 2014-11-10 14:22:56 -0500 | [diff] [blame] | 73 | mWifiController.removeAccessPointCallback(mDetailAdapter); |
John Spurlock | ccb6b9a | 2014-05-17 15:54:40 -0400 | [diff] [blame] | 74 | } |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 75 | } |
| 76 | |
| 77 | @Override |
John Spurlock | 7f8f22a | 2014-07-02 18:54:17 -0400 | [diff] [blame] | 78 | public DetailAdapter getDetailAdapter() { |
| 79 | return mDetailAdapter; |
| 80 | } |
| 81 | |
| 82 | @Override |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 83 | public QSTileView createTileView(Context context) { |
| 84 | return new SignalTileView(context); |
| 85 | } |
| 86 | |
| 87 | @Override |
| 88 | protected void handleClick() { |
Selim Cinek | 4fda7b2 | 2014-08-18 22:07:25 +0200 | [diff] [blame] | 89 | mState.copyTo(mStateBeforeClick); |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 90 | mController.setWifiEnabled(!mState.enabled); |
| 91 | } |
| 92 | |
| 93 | @Override |
| 94 | protected void handleSecondaryClick() { |
Jason Monk | d2263cd | 2014-11-10 14:22:56 -0500 | [diff] [blame] | 95 | if (!mWifiController.canConfigWifi()) { |
Jason Monk | 5d32507 | 2014-10-27 11:38:47 -0400 | [diff] [blame] | 96 | mHost.startSettingsActivity(new Intent(Settings.ACTION_WIFI_SETTINGS)); |
| 97 | return; |
| 98 | } |
| 99 | if (!mState.enabled) { |
| 100 | mController.setWifiEnabled(true); |
| 101 | mState.enabled = true; |
| 102 | } |
| 103 | showDetail(true); |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 104 | } |
| 105 | |
| 106 | @Override |
| 107 | protected void handleUpdateState(SignalState state, Object arg) { |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 108 | state.visible = true; |
John Spurlock | ccb6b9a | 2014-05-17 15:54:40 -0400 | [diff] [blame] | 109 | if (DEBUG) Log.d(TAG, "handleUpdateState arg=" + arg); |
| 110 | if (arg == null) return; |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 111 | CallbackInfo cb = (CallbackInfo) arg; |
| 112 | |
| 113 | boolean wifiConnected = cb.enabled && (cb.wifiSignalIconId > 0) && (cb.enabledDesc != null); |
| 114 | boolean wifiNotConnected = (cb.wifiSignalIconId > 0) && (cb.enabledDesc == null); |
John Spurlock | 7f8f22a | 2014-07-02 18:54:17 -0400 | [diff] [blame] | 115 | boolean enabledChanging = state.enabled != cb.enabled; |
| 116 | if (enabledChanging) { |
John Spurlock | 486b78e | 2014-07-07 08:37:56 -0400 | [diff] [blame] | 117 | mDetailAdapter.setItemsVisible(cb.enabled); |
John Spurlock | 7f8f22a | 2014-07-02 18:54:17 -0400 | [diff] [blame] | 118 | fireToggleStateChanged(cb.enabled); |
| 119 | } |
John Spurlock | 3d09bbd | 2014-05-22 12:20:16 -0400 | [diff] [blame] | 120 | state.enabled = cb.enabled; |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 121 | state.connected = wifiConnected; |
| 122 | state.activityIn = cb.enabled && cb.activityIn; |
| 123 | state.activityOut = cb.enabled && cb.activityOut; |
John Spurlock | 899f439 | 2014-06-11 10:59:11 -0400 | [diff] [blame] | 124 | state.filter = true; |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 125 | final String signalContentDescription; |
| 126 | final Resources r = mContext.getResources(); |
John Spurlock | c1d48a5 | 2014-08-01 12:12:32 -0400 | [diff] [blame] | 127 | if (!state.enabled) { |
John Spurlock | 2d69581 | 2014-10-30 13:25:21 -0400 | [diff] [blame] | 128 | state.icon = ResourceIcon.get(R.drawable.ic_qs_wifi_disabled); |
John Spurlock | c1d48a5 | 2014-08-01 12:12:32 -0400 | [diff] [blame] | 129 | state.label = r.getString(R.string.quick_settings_wifi_label); |
| 130 | signalContentDescription = r.getString(R.string.accessibility_wifi_off); |
| 131 | } else if (wifiConnected) { |
John Spurlock | 2d69581 | 2014-10-30 13:25:21 -0400 | [diff] [blame] | 132 | state.icon = ResourceIcon.get(cb.wifiSignalIconId); |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 133 | state.label = removeDoubleQuotes(cb.enabledDesc); |
| 134 | signalContentDescription = cb.wifiSignalContentDescription; |
| 135 | } else if (wifiNotConnected) { |
John Spurlock | 2d69581 | 2014-10-30 13:25:21 -0400 | [diff] [blame] | 136 | state.icon = ResourceIcon.get(R.drawable.ic_qs_wifi_0); |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 137 | state.label = r.getString(R.string.quick_settings_wifi_label); |
| 138 | signalContentDescription = r.getString(R.string.accessibility_no_wifi); |
| 139 | } else { |
John Spurlock | 2d69581 | 2014-10-30 13:25:21 -0400 | [diff] [blame] | 140 | state.icon = ResourceIcon.get(R.drawable.ic_qs_wifi_no_network); |
John Spurlock | 012d4a2 | 2014-06-04 00:40:18 -0400 | [diff] [blame] | 141 | state.label = r.getString(R.string.quick_settings_wifi_label); |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 142 | signalContentDescription = r.getString(R.string.accessibility_wifi_off); |
| 143 | } |
| 144 | state.contentDescription = mContext.getString( |
| 145 | R.string.accessibility_quick_settings_wifi, |
Selim Cinek | e5557a9 | 2014-08-15 19:59:23 +0200 | [diff] [blame] | 146 | signalContentDescription); |
| 147 | String wifiName = state.label; |
| 148 | if (state.connected) { |
| 149 | wifiName = r.getString(R.string.accessibility_wifi_name, state.label); |
| 150 | } |
| 151 | state.dualLabelContentDescription = wifiName; |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 152 | } |
| 153 | |
Selim Cinek | 4fda7b2 | 2014-08-18 22:07:25 +0200 | [diff] [blame] | 154 | @Override |
| 155 | protected boolean shouldAnnouncementBeDelayed() { |
| 156 | return mStateBeforeClick.enabled == mState.enabled; |
| 157 | } |
| 158 | |
| 159 | @Override |
| 160 | protected String composeChangeAnnouncement() { |
| 161 | if (mState.enabled) { |
| 162 | return mContext.getString(R.string.accessibility_quick_settings_wifi_changed_on); |
| 163 | } else { |
| 164 | return mContext.getString(R.string.accessibility_quick_settings_wifi_changed_off); |
| 165 | } |
| 166 | } |
| 167 | |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 168 | private static String removeDoubleQuotes(String string) { |
| 169 | if (string == null) return null; |
| 170 | final int length = string.length(); |
| 171 | if ((length > 1) && (string.charAt(0) == '"') && (string.charAt(length - 1) == '"')) { |
| 172 | return string.substring(1, length - 1); |
| 173 | } |
| 174 | return string; |
| 175 | } |
| 176 | |
| 177 | private static final class CallbackInfo { |
| 178 | boolean enabled; |
John Spurlock | d5cd2fd | 2014-07-27 11:36:33 -0400 | [diff] [blame] | 179 | boolean connected; |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 180 | int wifiSignalIconId; |
| 181 | String enabledDesc; |
| 182 | boolean activityIn; |
| 183 | boolean activityOut; |
| 184 | String wifiSignalContentDescription; |
John Spurlock | ccb6b9a | 2014-05-17 15:54:40 -0400 | [diff] [blame] | 185 | |
| 186 | @Override |
| 187 | public String toString() { |
| 188 | return new StringBuilder("CallbackInfo[") |
| 189 | .append("enabled=").append(enabled) |
John Spurlock | d5cd2fd | 2014-07-27 11:36:33 -0400 | [diff] [blame] | 190 | .append(",connected=").append(connected) |
John Spurlock | ccb6b9a | 2014-05-17 15:54:40 -0400 | [diff] [blame] | 191 | .append(",wifiSignalIconId=").append(wifiSignalIconId) |
| 192 | .append(",enabledDesc=").append(enabledDesc) |
| 193 | .append(",activityIn=").append(activityIn) |
| 194 | .append(",activityOut=").append(activityOut) |
| 195 | .append(",wifiSignalContentDescription=").append(wifiSignalContentDescription) |
| 196 | .append(']').toString(); |
| 197 | } |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 198 | } |
| 199 | |
| 200 | private final NetworkSignalChangedCallback mCallback = new NetworkSignalChangedCallback() { |
| 201 | @Override |
John Spurlock | d5cd2fd | 2014-07-27 11:36:33 -0400 | [diff] [blame] | 202 | public void onWifiSignalChanged(boolean enabled, boolean connected, int wifiSignalIconId, |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 203 | boolean activityIn, boolean activityOut, |
| 204 | String wifiSignalContentDescriptionId, String description) { |
John Spurlock | ccb6b9a | 2014-05-17 15:54:40 -0400 | [diff] [blame] | 205 | if (DEBUG) Log.d(TAG, "onWifiSignalChanged enabled=" + enabled); |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 206 | final CallbackInfo info = new CallbackInfo(); |
| 207 | info.enabled = enabled; |
John Spurlock | d5cd2fd | 2014-07-27 11:36:33 -0400 | [diff] [blame] | 208 | info.connected = connected; |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 209 | info.wifiSignalIconId = wifiSignalIconId; |
| 210 | info.enabledDesc = description; |
| 211 | info.activityIn = activityIn; |
| 212 | info.activityOut = activityOut; |
| 213 | info.wifiSignalContentDescription = wifiSignalContentDescriptionId; |
| 214 | refreshState(info); |
| 215 | } |
| 216 | |
| 217 | @Override |
| 218 | public void onMobileDataSignalChanged(boolean enabled, |
| 219 | int mobileSignalIconId, |
| 220 | String mobileSignalContentDescriptionId, int dataTypeIconId, |
| 221 | boolean activityIn, boolean activityOut, |
Jason Monk | b574627 | 2014-11-12 16:50:31 -0500 | [diff] [blame] | 222 | String dataTypeContentDescriptionId, String description, |
Jorim Jaggi | c737b9b | 2014-09-08 23:57:20 +0200 | [diff] [blame] | 223 | boolean isDataTypeIconWide) { |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 224 | // noop |
| 225 | } |
| 226 | |
Jason Monk | b574627 | 2014-11-12 16:50:31 -0500 | [diff] [blame] | 227 | public void onNoSimVisibleChanged(boolean noSims) { |
| 228 | // noop |
| 229 | } |
| 230 | |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 231 | @Override |
| 232 | public void onAirplaneModeChanged(boolean enabled) { |
| 233 | // noop |
| 234 | } |
John Spurlock | b98f747 | 2014-07-08 17:09:42 -0400 | [diff] [blame] | 235 | |
| 236 | @Override |
| 237 | public void onMobileDataEnabled(boolean enabled) { |
| 238 | // noop |
| 239 | } |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 240 | }; |
John Spurlock | 7f8f22a | 2014-07-02 18:54:17 -0400 | [diff] [blame] | 241 | |
| 242 | private final class WifiDetailAdapter implements DetailAdapter, |
Jason Monk | d2263cd | 2014-11-10 14:22:56 -0500 | [diff] [blame] | 243 | NetworkController.AccessPointController.AccessPointCallback, QSDetailItems.Callback { |
John Spurlock | 7f8f22a | 2014-07-02 18:54:17 -0400 | [diff] [blame] | 244 | |
John Spurlock | 486b78e | 2014-07-07 08:37:56 -0400 | [diff] [blame] | 245 | private QSDetailItems mItems; |
John Spurlock | 7f8f22a | 2014-07-02 18:54:17 -0400 | [diff] [blame] | 246 | private AccessPoint[] mAccessPoints; |
| 247 | |
| 248 | @Override |
| 249 | public int getTitle() { |
| 250 | return R.string.quick_settings_wifi_label; |
| 251 | } |
| 252 | |
| 253 | public Intent getSettingsIntent() { |
| 254 | return WIFI_SETTINGS; |
| 255 | } |
| 256 | |
| 257 | @Override |
| 258 | public Boolean getToggleState() { |
| 259 | return mState.enabled; |
| 260 | } |
| 261 | |
| 262 | @Override |
| 263 | public void setToggleState(boolean state) { |
| 264 | if (DEBUG) Log.d(TAG, "setToggleState " + state); |
| 265 | mController.setWifiEnabled(state); |
| 266 | showDetail(false); |
| 267 | } |
| 268 | |
| 269 | @Override |
| 270 | public View createDetailView(Context context, View convertView, ViewGroup parent) { |
John Spurlock | 486b78e | 2014-07-07 08:37:56 -0400 | [diff] [blame] | 271 | if (DEBUG) Log.d(TAG, "createDetailView convertView=" + (convertView != null)); |
| 272 | mAccessPoints = null; |
Jason Monk | d2263cd | 2014-11-10 14:22:56 -0500 | [diff] [blame] | 273 | mWifiController.scanForAccessPoints(); |
John Spurlock | 486b78e | 2014-07-07 08:37:56 -0400 | [diff] [blame] | 274 | fireScanStateChanged(true); |
| 275 | mItems = QSDetailItems.convertOrInflate(context, convertView, parent); |
| 276 | mItems.setTagSuffix("Wifi"); |
| 277 | mItems.setCallback(this); |
| 278 | mItems.setEmptyState(R.drawable.ic_qs_wifi_detail_empty, |
| 279 | R.string.quick_settings_wifi_detail_empty_text); |
John Spurlock | 7f8f22a | 2014-07-02 18:54:17 -0400 | [diff] [blame] | 280 | updateItems(); |
John Spurlock | 486b78e | 2014-07-07 08:37:56 -0400 | [diff] [blame] | 281 | setItemsVisible(mState.enabled); |
John Spurlock | 7f8f22a | 2014-07-02 18:54:17 -0400 | [diff] [blame] | 282 | return mItems; |
| 283 | } |
| 284 | |
| 285 | @Override |
Jason Monk | d52356a | 2015-01-28 10:40:41 -0500 | [diff] [blame] | 286 | public void onAccessPointsChanged(final List<AccessPoint> accessPoints) { |
| 287 | mAccessPoints = accessPoints.toArray(new AccessPoint[accessPoints.size()]); |
John Spurlock | 486b78e | 2014-07-07 08:37:56 -0400 | [diff] [blame] | 288 | updateItems(); |
Jason Monk | d52356a | 2015-01-28 10:40:41 -0500 | [diff] [blame] | 289 | if (accessPoints != null && accessPoints.size() > 0) { |
John Spurlock | 486b78e | 2014-07-07 08:37:56 -0400 | [diff] [blame] | 290 | fireScanStateChanged(false); |
| 291 | } |
John Spurlock | 7f8f22a | 2014-07-02 18:54:17 -0400 | [diff] [blame] | 292 | } |
| 293 | |
John Spurlock | 486b78e | 2014-07-07 08:37:56 -0400 | [diff] [blame] | 294 | @Override |
Jason Monk | 17f3c3f | 2015-01-14 10:13:22 -0500 | [diff] [blame] | 295 | public void onSettingsActivityTriggered(Intent settingsIntent) { |
| 296 | mHost.startSettingsActivity(settingsIntent); |
| 297 | } |
| 298 | |
| 299 | @Override |
John Spurlock | 486b78e | 2014-07-07 08:37:56 -0400 | [diff] [blame] | 300 | public void onDetailItemClick(Item item) { |
| 301 | if (item == null || item.tag == null) return; |
| 302 | final AccessPoint ap = (AccessPoint) item.tag; |
Jason Monk | d52356a | 2015-01-28 10:40:41 -0500 | [diff] [blame] | 303 | if (!ap.isActive()) { |
Jason Monk | d2263cd | 2014-11-10 14:22:56 -0500 | [diff] [blame] | 304 | if (mWifiController.connect(ap)) { |
Jason Monk | 5d32507 | 2014-10-27 11:38:47 -0400 | [diff] [blame] | 305 | mHost.collapsePanels(); |
| 306 | } |
John Spurlock | 486b78e | 2014-07-07 08:37:56 -0400 | [diff] [blame] | 307 | } |
| 308 | showDetail(false); |
| 309 | } |
| 310 | |
| 311 | @Override |
| 312 | public void onDetailItemDisconnect(Item item) { |
| 313 | // noop |
| 314 | } |
| 315 | |
| 316 | public void setItemsVisible(boolean visible) { |
| 317 | if (mItems == null) return; |
| 318 | mItems.setItemsVisible(visible); |
John Spurlock | 7f8f22a | 2014-07-02 18:54:17 -0400 | [diff] [blame] | 319 | } |
| 320 | |
| 321 | private void updateItems() { |
| 322 | if (mItems == null) return; |
John Spurlock | 486b78e | 2014-07-07 08:37:56 -0400 | [diff] [blame] | 323 | Item[] items = null; |
| 324 | if (mAccessPoints != null) { |
| 325 | items = new Item[mAccessPoints.length]; |
| 326 | for (int i = 0; i < mAccessPoints.length; i++) { |
| 327 | final AccessPoint ap = mAccessPoints[i]; |
| 328 | final Item item = new Item(); |
| 329 | item.tag = ap; |
Jason Monk | d52356a | 2015-01-28 10:40:41 -0500 | [diff] [blame] | 330 | item.icon = mWifiController.getIcon(ap); |
| 331 | item.line1 = ap.getSsid(); |
| 332 | item.line2 = ap.getSummary(); |
| 333 | item.overlay = ap.getSecurity() != AccessPoint.SECURITY_NONE |
Jason Monk | b27ec6d3 | 2014-12-01 17:50:16 -0500 | [diff] [blame] | 334 | ? mContext.getDrawable(R.drawable.qs_ic_wifi_lock) |
| 335 | : null; |
John Spurlock | 486b78e | 2014-07-07 08:37:56 -0400 | [diff] [blame] | 336 | items[i] = item; |
| 337 | } |
John Spurlock | 7f8f22a | 2014-07-02 18:54:17 -0400 | [diff] [blame] | 338 | } |
John Spurlock | 486b78e | 2014-07-07 08:37:56 -0400 | [diff] [blame] | 339 | mItems.setItems(items); |
John Spurlock | 7f8f22a | 2014-07-02 18:54:17 -0400 | [diff] [blame] | 340 | } |
| 341 | }; |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 342 | } |