Renaming in BluetoothTile and QSDetailItems

Rename the fields so they could disclose the type.

1. Rename icon to iconResId(type: int)
2. Rename iconDrawable to icon(type QSTile.Icon)
3. Rename BluetoothBatteryDrawable to BluetoothBatteryTileIcon

Bug: 68008183
Test: Build

Change-Id: I5edb24c2fcfa114c2d7134898d4e2b2bcedf0758
This commit is contained in:
jackqdyulei
2017-10-24 13:27:53 -07:00
parent 3a3ff7deeb
commit 786a490dd7
4 changed files with 16 additions and 28 deletions

View File

@@ -185,10 +185,10 @@ public class QSDetailItems extends FrameLayout {
}
view.setVisibility(mItemsVisible ? VISIBLE : INVISIBLE);
final ImageView iv = (ImageView) view.findViewById(android.R.id.icon);
if (item.iconDrawable != null) {
iv.setImageDrawable(item.iconDrawable.getDrawable(iv.getContext()));
if (item.icon != null) {
iv.setImageDrawable(item.icon.getDrawable(iv.getContext()));
} else {
iv.setImageResource(item.icon);
iv.setImageResource(item.iconResId);
}
iv.getOverlay().clear();
if (item.overlay != null) {
@@ -258,8 +258,8 @@ public class QSDetailItems extends FrameLayout {
}
public static class Item {
public int icon;
public QSTile.Icon iconDrawable;
public int iconResId;
public QSTile.Icon icon;
public Drawable overlay;
public CharSequence line1;
public CharSequence line2;

View File

@@ -134,7 +134,7 @@ public class BluetoothTile extends QSTileImpl<BooleanState> {
if (lastDevice != null) {
int batteryLevel = lastDevice.getBatteryLevel();
if (batteryLevel != BluetoothDevice.BATTERY_LEVEL_UNKNOWN) {
state.icon = new BluetoothBatteryDrawable(batteryLevel,
state.icon = new BluetoothBatteryTileIcon(batteryLevel,
mContext.getResources().getFraction(
R.fraction.bt_battery_scale_fraction, 1, 1));
}
@@ -212,15 +212,11 @@ public class BluetoothTile extends QSTileImpl<BooleanState> {
return new BluetoothDetailAdapter();
}
private class BluetoothBatteryDrawable extends Icon {
private class BluetoothBatteryTileIcon extends Icon {
private int mLevel;
private float mIconScale;
BluetoothBatteryDrawable(int level) {
this(level, 1 /* iconScale */);
}
BluetoothBatteryDrawable(int level, float iconScale) {
BluetoothBatteryTileIcon(int level, float iconScale) {
mLevel = level;
mIconScale = iconScale;
}
@@ -302,15 +298,16 @@ public class BluetoothTile extends QSTileImpl<BooleanState> {
for (CachedBluetoothDevice device : devices) {
if (mController.getBondState(device) == BluetoothDevice.BOND_NONE) continue;
final Item item = new Item();
item.icon = R.drawable.ic_qs_bluetooth_on;
item.iconResId = R.drawable.ic_qs_bluetooth_on;
item.line1 = device.getName();
item.tag = device;
int state = device.getMaxConnectionState();
if (state == BluetoothProfile.STATE_CONNECTED) {
item.icon = R.drawable.ic_qs_bluetooth_connected;
item.iconResId = R.drawable.ic_qs_bluetooth_connected;
int batteryLevel = device.getBatteryLevel();
if (batteryLevel != BluetoothDevice.BATTERY_LEVEL_UNKNOWN) {
item.iconDrawable = new BluetoothBatteryDrawable(batteryLevel);
item.icon = new BluetoothBatteryTileIcon(batteryLevel,
1 /* iconScale */);
item.line2 = mContext.getString(
R.string.quick_settings_connected_battery_level,
Utils.formatPercentage(batteryLevel));
@@ -321,7 +318,7 @@ public class BluetoothTile extends QSTileImpl<BooleanState> {
items.add(connectedDevices, item);
connectedDevices++;
} else if (state == BluetoothProfile.STATE_CONNECTING) {
item.icon = R.drawable.ic_qs_bluetooth_connecting;
item.iconResId = R.drawable.ic_qs_bluetooth_connecting;
item.line2 = mContext.getString(R.string.quick_settings_connecting);
items.add(connectedDevices, item);
} else {

View File

@@ -19,26 +19,17 @@ package com.android.systemui.qs.tiles;
import static android.media.MediaRouter.ROUTE_TYPE_REMOTE_DISPLAY;
import android.app.Dialog;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.media.MediaRouter;
import android.os.UserHandle;
import android.provider.Settings;
import android.service.quicksettings.Tile;
import android.util.Log;
import android.view.ContextThemeWrapper;
import android.view.View;
import android.view.View.OnAttachStateChangeListener;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.view.WindowManager.LayoutParams;
import android.widget.Button;
import com.android.internal.app.MediaRouteChooserDialog;
import com.android.internal.app.MediaRouteControllerDialog;
import com.android.internal.app.MediaRouteDialogPresenter;
import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
@@ -280,7 +271,7 @@ public class CastTile extends QSTileImpl<BooleanState> {
for (CastDevice device : devices) {
if (device.state == CastDevice.STATE_CONNECTED) {
final Item item = new Item();
item.icon = R.drawable.ic_qs_cast_on;
item.iconResId = R.drawable.ic_qs_cast_on;
item.line1 = getDeviceName(device);
item.line2 = mContext.getString(R.string.quick_settings_connected);
item.tag = device;
@@ -300,7 +291,7 @@ public class CastTile extends QSTileImpl<BooleanState> {
final CastDevice device = mVisibleOrder.get(id);
if (!devices.contains(device)) continue;
final Item item = new Item();
item.icon = R.drawable.ic_qs_cast_off;
item.iconResId = R.drawable.ic_qs_cast_off;
item.line1 = getDeviceName(device);
if (device.state == CastDevice.STATE_CONNECTING) {
item.line2 = mContext.getString(R.string.quick_settings_connecting);

View File

@@ -402,7 +402,7 @@ public class WifiTile extends QSTileImpl<SignalState> {
final AccessPoint ap = mAccessPoints[i];
final Item item = new Item();
item.tag = ap;
item.icon = mWifiController.getIcon(ap);
item.iconResId = mWifiController.getIcon(ap);
item.line1 = ap.getSsid();
item.line2 = ap.isActive() ? ap.getSummary() : null;
item.icon2 = ap.getSecurity() != AccessPoint.SECURITY_NONE