Add battery indicator to bluetooth icon

This cl change util method in bluetooth package to return
drawable instead of resId.

If the bt device has battery level, then method return customized
layerDrawable, otherwise return a simple drawable created from
resId.

Bug: 63393322
Test: RunSettingsRoboTests

Change-Id: Ib21822eafda0e8570212ce5cb070478e4f4876a2
Merged-In: Ib21822eafda0e8570212ce5cb070478e4f4876a2
This commit is contained in:
jackqdyulei
2017-08-09 09:57:27 -07:00
parent efcc8be05c
commit 7661137981
7 changed files with 84 additions and 29 deletions

View File

@@ -21,6 +21,7 @@ import android.bluetooth.BluetoothDevice;
import android.content.Context;
import android.content.DialogInterface;
import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import android.os.UserManager;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceViewHolder;
@@ -120,9 +121,9 @@ public final class BluetoothDevicePreference extends GearPreference implements
// Null check is done at the framework
setSummary(mCachedDevice.getConnectionSummary());
Pair<Integer, String> pair = Utils.getBtClassDrawableWithDescription(mResources,
final Pair<Drawable, String> pair = Utils.getBtClassDrawableWithDescription(getContext(),
mCachedDevice);
if (pair.first != 0) {
if (pair.first != null) {
setIcon(pair.first);
contentDescription = pair.second;
}