Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4c06596f authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Remove battery from bluetooth tile icon"

parents dd4b4352 43216489
Loading
Loading
Loading
Loading
+20 −12
Original line number Diff line number Diff line
@@ -131,21 +131,10 @@ public class BluetoothTile extends QSTileImpl<BooleanState> {

        if (enabled) {
            if (connected) {
                state.icon = ResourceIcon.get(R.drawable.ic_qs_bluetooth_connected);
                state.icon = new BluetoothConnectedTileIcon();
                state.contentDescription = mContext.getString(
                        R.string.accessibility_bluetooth_name, state.label);

                final CachedBluetoothDevice lastDevice = mController.getLastDevice();
                if (lastDevice != null) {
                    final int batteryLevel = lastDevice.getBatteryLevel();
                    if (batteryLevel != BluetoothDevice.BATTERY_LEVEL_UNKNOWN) {
                        state.icon = new BluetoothBatteryTileIcon(
                                batteryLevel,
                                mContext.getResources().getFraction(
                                        R.fraction.bt_battery_scale_fraction, 1, 1));
                    }
                }

                state.label = mController.getLastDeviceName();
            } else if (state.isTransient) {
                state.icon = ResourceIcon.get(R.drawable.ic_bluetooth_transient_animation);
@@ -281,6 +270,25 @@ public class BluetoothTile extends QSTileImpl<BooleanState> {
        }
    }


    /**
     * Bluetooth icon wrapper (when connected with no battery indicator) for Quick Settings. This is
     * used instead of {@link com.android.systemui.qs.tileimpl.QSTileImpl.DrawableIcon} in order to
     * use a context that reflects dark/light theme attributes.
     */
    private class BluetoothConnectedTileIcon extends Icon {

        BluetoothConnectedTileIcon() {
            // Do nothing. Default constructor to limit visibility.
        }

        @Override
        public Drawable getDrawable(Context context) {
            // This method returns Pair<Drawable, String> - the first value is the drawable.
            return context.getDrawable(R.drawable.ic_qs_bluetooth_connected);
        }
    }

    protected class BluetoothDetailAdapter implements DetailAdapter, QSDetailItems.Callback {
        // We probably won't ever have space in the UI for more than 20 devices, so don't
        // get info for them.