Merge "Remove sub-text from the lines of AP list in Wi-Fi Slice"

This commit is contained in:
Fan Zhang
2019-02-12 17:59:05 +00:00
committed by Android (Google) Code Review
5 changed files with 73 additions and 43 deletions

View File

@@ -958,6 +958,22 @@ public final class Utils extends com.android.settingslib.Utils {
return new BitmapDrawable(null, bitmap);
}
/**
* Converts the {@link Drawable} to a {@link Bitmap}.
*/
public static Bitmap drawableToBitmap(Drawable drawable) {
if (drawable instanceof BitmapDrawable) {
return ((BitmapDrawable)drawable).getBitmap();
}
final Bitmap bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(),
drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
final Canvas canvas = new Canvas(bitmap);
drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
drawable.draw(canvas);
return bitmap;
}
/**
* Get the {@link Drawable} that represents the app icon
*/