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

@@ -16,8 +16,8 @@
package com.android.settings.bluetooth;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.support.v14.preference.PreferenceFragment;
import android.support.v7.preference.PreferenceScreen;
import android.util.Pair;
@@ -51,11 +51,11 @@ public class BluetoothDetailsHeaderController extends BluetoothDetailsController
}
protected void setHeaderProperties() {
Pair<Integer, String> pair = Utils.getBtClassDrawableWithDescription
(mContext.getResources(), mCachedDevice);
final Pair<Drawable, String> pair = Utils.getBtClassDrawableWithDescription
(mContext, mCachedDevice);
String summaryText = mCachedDevice.getConnectionSummary();
mHeaderController.setLabel(mCachedDevice.getName());
mHeaderController.setIcon(mContext.getDrawable(pair.first));
mHeaderController.setIcon(pair.first);
mHeaderController.setIconContentDescription(pair.second);
mHeaderController.setSummary(summaryText);
}