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

Commit 10643893 authored by Jason Monk's avatar Jason Monk Committed by android-build-merger
Browse files

Merge "Add bt battery level to QS icons" into oc-mr1-dev

am: 984b76f6

Change-Id: If156c3f183fa4efa489202ef90b75ce758ff5b16
parents 13a0c859 984b76f6
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -184,7 +184,11 @@ 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);
            } else {
                iv.setImageResource(item.icon);
            }
            iv.getOverlay().clear();
            if (item.overlay != null) {
                item.overlay.setBounds(0, 0, mQsDetailIconOverlaySize, mQsDetailIconOverlaySize);
@@ -254,6 +258,7 @@ public class QSDetailItems extends FrameLayout {

    public static class Item {
        public int icon;
        public Drawable iconDrawable;
        public Drawable overlay;
        public CharSequence line1;
        public CharSequence line2;
+15 −0
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package com.android.systemui.qs.tiles;

import static com.android.settingslib.graph.BluetoothDeviceLayerDrawable.createLayerDrawable;

import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothProfile;
@@ -32,8 +34,10 @@ import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settingslib.Utils;
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
import com.android.settingslib.graph.BluetoothDeviceLayerDrawable;
import com.android.systemui.Dependency;
import com.android.systemui.R;
import com.android.systemui.R.drawable;
import com.android.systemui.plugins.ActivityStarter;
import com.android.systemui.plugins.qs.DetailAdapter;
import com.android.systemui.plugins.qs.QSTile.BooleanState;
@@ -127,6 +131,15 @@ public class BluetoothTile extends QSTileImpl<BooleanState> {
            if (connected) {
                state.icon = ResourceIcon.get(R.drawable.ic_qs_bluetooth_connected);
                state.label = mController.getLastDeviceName();
                CachedBluetoothDevice lastDevice = mController.getLastDevice();
                if (lastDevice != null) {
                    int batteryLevel = lastDevice.getBatteryLevel();
                    if (batteryLevel != BluetoothDevice.BATTERY_LEVEL_UNKNOWN) {
                        BluetoothDeviceLayerDrawable drawable = createLayerDrawable(mContext,
                                R.drawable.ic_qs_bluetooth_connected, batteryLevel);
                        state.icon = new DrawableIcon(drawable);
                    }
                }
                state.contentDescription = mContext.getString(
                        R.string.accessibility_bluetooth_name, state.label);
            } else if (state.isTransient) {
@@ -278,6 +291,8 @@ public class BluetoothTile extends QSTileImpl<BooleanState> {
                        item.icon = R.drawable.ic_qs_bluetooth_connected;
                        int batteryLevel = device.getBatteryLevel();
                        if (batteryLevel != BluetoothDevice.BATTERY_LEVEL_UNKNOWN) {
                            item.iconDrawable = createLayerDrawable(mContext, item.icon,
                                    batteryLevel);
                            item.line2 = mContext.getString(
                                    R.string.quick_settings_connected_battery_level,
                                    Utils.formatPercentage(batteryLevel));
+1 −0
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ public interface BluetoothController extends CallbackController<Callback>, Dumpa

    int getMaxConnectionState(CachedBluetoothDevice device);
    int getBondState(CachedBluetoothDevice device);
    CachedBluetoothDevice getLastDevice();

    public interface Callback {
        void onBluetoothStateChange(boolean enabled);
+5 −0
Original line number Diff line number Diff line
@@ -120,6 +120,11 @@ public class BluetoothControllerImpl implements BluetoothController, BluetoothCa
        return getCachedState(device).mBondState;
    }

    @Override
    public CachedBluetoothDevice getLastDevice() {
        return mLastDevice;
    }

    @Override
    public int getMaxConnectionState(CachedBluetoothDevice device) {
        return getCachedState(device).mMaxConnectionState;
+5 −0
Original line number Diff line number Diff line
@@ -93,4 +93,9 @@ public class FakeBluetoothController extends BaseLeakChecker<Callback> implement
    public int getBondState(CachedBluetoothDevice device) {
        return 0;
    }

    @Override
    public CachedBluetoothDevice getLastDevice() {
        return null;
    }
}