summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/SettingsLib/res/values/dimens.xml7
-rwxr-xr-xpackages/SettingsLib/src/com/android/settingslib/graph/BatteryMeterDrawableBase.java5
-rw-r--r--packages/SettingsLib/src/com/android/settingslib/graph/BluetoothDeviceLayerDrawable.java74
-rw-r--r--packages/SettingsLib/tests/robotests/src/com/android/settingslib/graph/BluetoothDeviceLayerDrawableTest.java25
-rw-r--r--packages/SystemUI/res/drawable/ic_qs_bluetooth_connected.xml4
-rw-r--r--packages/SystemUI/res/layout/qs_detail_item.xml2
-rw-r--r--packages/SystemUI/res/values/dimens.xml1
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/tiles/BluetoothTile.java4
8 files changed, 70 insertions, 52 deletions
diff --git a/packages/SettingsLib/res/values/dimens.xml b/packages/SettingsLib/res/values/dimens.xml
index 1e35cbc78343..e2615709cfb7 100644
--- a/packages/SettingsLib/res/values/dimens.xml
+++ b/packages/SettingsLib/res/values/dimens.xml
@@ -61,10 +61,13 @@
<fraction name="battery_button_height_fraction">10.5%</fraction>
<!-- Ratio between height of button part and height of total -->
- <fraction name="bt_battery_button_height_fraction">7.5%</fraction>
+ <fraction name="bt_battery_button_height_fraction">7.8%</fraction>
<!-- Ratio between width and height -->
- <fraction name="bt_battery_ratio_fraction">45%</fraction>
+ <fraction name="bt_battery_ratio_fraction">35%</fraction>
+
+ <!-- Ratio of height between battery icon and bluetooth icon -->
+ <fraction name="bt_battery_scale_fraction">75%</fraction>
<!-- Fraction value to smooth the edges of the battery icon. The path will be inset by this
fraction of a pixel.-->
diff --git a/packages/SettingsLib/src/com/android/settingslib/graph/BatteryMeterDrawableBase.java b/packages/SettingsLib/src/com/android/settingslib/graph/BatteryMeterDrawableBase.java
index d588a6626bd5..817989ab96ae 100755
--- a/packages/SettingsLib/src/com/android/settingslib/graph/BatteryMeterDrawableBase.java
+++ b/packages/SettingsLib/src/com/android/settingslib/graph/BatteryMeterDrawableBase.java
@@ -292,6 +292,7 @@ public class BatteryMeterDrawableBase extends Drawable {
@Override
public void draw(Canvas c) {
final int level = mLevel;
+ final Rect bounds = getBounds();
if (level == -1) return;
@@ -300,8 +301,10 @@ public class BatteryMeterDrawableBase extends Drawable {
final int width = (int) (getAspectRatio() * mHeight);
final int px = (mWidth - width) / 2;
final int buttonHeight = Math.round(height * mButtonHeightFraction);
+ final int left = mPadding.left + bounds.left;
+ final int top = bounds.bottom - mPadding.bottom - height;
- mFrame.set(mPadding.left, mPadding.top, width + mPadding.left, height + mPadding.top);
+ mFrame.set(left, top, width + left, height + top);
mFrame.offset(px, 0);
// button-frame: area above the battery body
diff --git a/packages/SettingsLib/src/com/android/settingslib/graph/BluetoothDeviceLayerDrawable.java b/packages/SettingsLib/src/com/android/settingslib/graph/BluetoothDeviceLayerDrawable.java
index 61790b96099f..b7fd40485e4d 100644
--- a/packages/SettingsLib/src/com/android/settingslib/graph/BluetoothDeviceLayerDrawable.java
+++ b/packages/SettingsLib/src/com/android/settingslib/graph/BluetoothDeviceLayerDrawable.java
@@ -24,6 +24,7 @@ import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
+import android.graphics.Rect;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.LayerDrawable;
@@ -47,7 +48,7 @@ public class BluetoothDeviceLayerDrawable extends LayerDrawable {
/**
* Create the {@link LayerDrawable} that contains bluetooth device icon and battery icon.
- * This is a vertical layout drawable while bluetooth icon at top and battery icon at bottom.
+ * This is a horizontal layout drawable while bluetooth icon at start and battery icon at end.
*
* @param context used to get the spec for icon
* @param resId represents the bluetooth device drawable
@@ -55,55 +56,44 @@ public class BluetoothDeviceLayerDrawable extends LayerDrawable {
*/
public static BluetoothDeviceLayerDrawable createLayerDrawable(Context context, int resId,
int batteryLevel) {
+ return createLayerDrawable(context, resId, batteryLevel, 1 /*iconScale*/);
+ }
+
+ /**
+ * Create the {@link LayerDrawable} that contains bluetooth device icon and battery icon.
+ * This is a horizontal layout drawable while bluetooth icon at start and battery icon at end.
+ *
+ * @param context used to get the spec for icon
+ * @param resId represents the bluetooth device drawable
+ * @param batteryLevel the battery level for bluetooth device
+ * @param iconScale the ratio of height between battery icon and bluetooth icon
+ */
+ public static BluetoothDeviceLayerDrawable createLayerDrawable(Context context, int resId,
+ int batteryLevel, float iconScale) {
final Drawable deviceDrawable = context.getDrawable(resId);
final BatteryMeterDrawable batteryDrawable = new BatteryMeterDrawable(context,
R.color.meter_background_color, batteryLevel);
- final int pad = context.getResources()
- .getDimensionPixelSize(R.dimen.bt_battery_padding);
- batteryDrawable.setPadding(0, pad, 0, pad);
+ final int pad = context.getResources().getDimensionPixelSize(R.dimen.bt_battery_padding);
+ batteryDrawable.setPadding(pad, pad, pad, pad);
final BluetoothDeviceLayerDrawable drawable = new BluetoothDeviceLayerDrawable(
- new Drawable[]{deviceDrawable,
- rotateDrawable(context.getResources(), batteryDrawable)});
- // Set the bluetooth icon at the top
- drawable.setLayerGravity(0 /* index of deviceDrawable */, Gravity.TOP);
- // Set battery icon right below the bluetooth icon
- drawable.setLayerInset(1 /* index of batteryDrawable */, 0,
- deviceDrawable.getIntrinsicHeight(), 0, 0);
+ new Drawable[]{deviceDrawable, batteryDrawable});
+ // Set the bluetooth icon at the left
+ drawable.setLayerGravity(0 /* index of deviceDrawable */, Gravity.START);
+ // Set battery icon to the right of the bluetooth icon
+ drawable.setLayerInsetStart(1 /* index of batteryDrawable */,
+ deviceDrawable.getIntrinsicWidth());
+ drawable.setLayerInsetTop(1 /* index of batteryDrawable */,
+ (int) (deviceDrawable.getIntrinsicHeight() * (1 - iconScale)));
- drawable.setConstantState(context, resId, batteryLevel);
+ drawable.setConstantState(context, resId, batteryLevel, iconScale);
return drawable;
}
- /**
- * Rotate the {@code drawable} by 90 degree clockwise and return rotated {@link Drawable}
- */
- private static Drawable rotateDrawable(Resources res, Drawable drawable) {
- // Get the bitmap from drawable
- 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);
-
- // Create rotate matrix
- final Matrix matrix = new Matrix();
- matrix.postRotate(
- res.getConfiguration().getLayoutDirection() == View.LAYOUT_DIRECTION_LTR
- ? 90 : 270);
-
- // Create new bitmap with rotate matrix
- final Bitmap rotateBitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(),
- bitmap.getHeight(), matrix, true);
- bitmap.recycle();
-
- return new BitmapDrawable(res, rotateBitmap);
- }
-
- public void setConstantState(Context context, int resId, int batteryLevel) {
- mState = new BluetoothDeviceLayerDrawableState(context, resId, batteryLevel);
+ public void setConstantState(Context context, int resId, int batteryLevel, float iconScale) {
+ mState = new BluetoothDeviceLayerDrawableState(context, resId, batteryLevel, iconScale);
}
@Override
@@ -149,17 +139,19 @@ public class BluetoothDeviceLayerDrawable extends LayerDrawable {
Context context;
int resId;
int batteryLevel;
+ float iconScale;
public BluetoothDeviceLayerDrawableState(Context context, int resId,
- int batteryLevel) {
+ int batteryLevel, float iconScale) {
this.context = context;
this.resId = resId;
this.batteryLevel = batteryLevel;
+ this.iconScale = iconScale;
}
@Override
public Drawable newDrawable() {
- return createLayerDrawable(context, resId, batteryLevel);
+ return createLayerDrawable(context, resId, batteryLevel, iconScale);
}
@Override
diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/graph/BluetoothDeviceLayerDrawableTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/graph/BluetoothDeviceLayerDrawableTest.java
index f6fe158691fa..1e65a0af5ba7 100644
--- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/graph/BluetoothDeviceLayerDrawableTest.java
+++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/graph/BluetoothDeviceLayerDrawableTest.java
@@ -39,6 +39,8 @@ import org.robolectric.annotation.Config;
public class BluetoothDeviceLayerDrawableTest {
private static final int RES_ID = R.drawable.ic_bt_cellphone;
private static final int BATTERY_LEVEL = 15;
+ private static final float BATTERY_ICON_SCALE = 0.75f;
+ private static final int BATTERY_ICON_PADDING_TOP = 6;
private static final float TOLERANCE = 0.001f;
private Context mContext;
@@ -54,9 +56,24 @@ public class BluetoothDeviceLayerDrawableTest {
mContext, RES_ID, BATTERY_LEVEL);
assertThat(drawable.getDrawable(0)).isInstanceOf(VectorDrawable.class);
- assertThat(drawable.getDrawable(1)).isInstanceOf(BitmapDrawable.class);
- assertThat(drawable.getLayerInsetTop(1)).isEqualTo(
- drawable.getDrawable(0).getIntrinsicHeight());
+ assertThat(drawable.getDrawable(1)).isInstanceOf(
+ BluetoothDeviceLayerDrawable.BatteryMeterDrawable.class);
+ assertThat(drawable.getLayerInsetStart(1)).isEqualTo(
+ drawable.getDrawable(0).getIntrinsicWidth());
+ assertThat(drawable.getLayerInsetTop(1)).isEqualTo(0);
+ }
+
+ @Test
+ public void testCreateLayerDrawable_withIconScale_configCorrect() {
+ BluetoothDeviceLayerDrawable drawable = BluetoothDeviceLayerDrawable.createLayerDrawable(
+ mContext, RES_ID, BATTERY_LEVEL, BATTERY_ICON_SCALE);
+
+ assertThat(drawable.getDrawable(0)).isInstanceOf(VectorDrawable.class);
+ assertThat(drawable.getDrawable(1)).isInstanceOf(
+ BluetoothDeviceLayerDrawable.BatteryMeterDrawable.class);
+ assertThat(drawable.getLayerInsetStart(1)).isEqualTo(
+ drawable.getDrawable(0).getIntrinsicWidth());
+ assertThat(drawable.getLayerInsetTop(1)).isEqualTo(BATTERY_ICON_PADDING_TOP);
}
@Test
@@ -65,7 +82,7 @@ public class BluetoothDeviceLayerDrawableTest {
new BluetoothDeviceLayerDrawable.BatteryMeterDrawable(mContext,
R.color.meter_background_color, BATTERY_LEVEL);
- assertThat(batteryDrawable.getAspectRatio()).isWithin(TOLERANCE).of(0.45f);
+ assertThat(batteryDrawable.getAspectRatio()).isWithin(TOLERANCE).of(0.35f);
assertThat(batteryDrawable.getRadiusRatio()).isWithin(TOLERANCE).of(0f);
assertThat(batteryDrawable.getBatteryLevel()).isEqualTo(BATTERY_LEVEL);
}
diff --git a/packages/SystemUI/res/drawable/ic_qs_bluetooth_connected.xml b/packages/SystemUI/res/drawable/ic_qs_bluetooth_connected.xml
index 3eb81f84dc2a..b673e4f3b081 100644
--- a/packages/SystemUI/res/drawable/ic_qs_bluetooth_connected.xml
+++ b/packages/SystemUI/res/drawable/ic_qs_bluetooth_connected.xml
@@ -14,8 +14,8 @@ Copyright (C) 2017 The Android Open Source Project
limitations under the License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
- android:width="64dp"
- android:height="64dp"
+ android:width="24dp"
+ android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0"
android:tint="?android:attr/colorControlNormal" >
diff --git a/packages/SystemUI/res/layout/qs_detail_item.xml b/packages/SystemUI/res/layout/qs_detail_item.xml
index 97e82ffb92f4..0844bb46d53f 100644
--- a/packages/SystemUI/res/layout/qs_detail_item.xml
+++ b/packages/SystemUI/res/layout/qs_detail_item.xml
@@ -26,7 +26,7 @@
<ImageView
android:id="@android:id/icon"
- android:layout_width="@dimen/qs_detail_item_icon_size"
+ android:layout_width="@dimen/qs_detail_item_icon_width"
android:layout_height="@dimen/qs_detail_item_icon_size"
android:layout_marginStart="@dimen/qs_detail_item_icon_marginStart"
android:layout_marginEnd="@dimen/qs_detail_item_icon_marginEnd"
diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml
index bcaafccd7acb..9901f6ff8fda 100644
--- a/packages/SystemUI/res/values/dimens.xml
+++ b/packages/SystemUI/res/values/dimens.xml
@@ -298,6 +298,7 @@
<dimen name="qs_detail_padding_start">16dp</dimen>
<dimen name="qs_detail_items_padding_top">4dp</dimen>
<dimen name="qs_detail_item_icon_size">24dp</dimen>
+ <dimen name="qs_detail_item_icon_width">32dp</dimen>
<dimen name="qs_detail_item_icon_marginStart">0dp</dimen>
<dimen name="qs_detail_item_icon_marginEnd">20dp</dimen>
<dimen name="qs_footer_padding_start">16dp</dimen>
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/BluetoothTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/BluetoothTile.java
index 774f0b3dfbb4..8d62f2aa669c 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/BluetoothTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/BluetoothTile.java
@@ -136,7 +136,9 @@ public class BluetoothTile extends QSTileImpl<BooleanState> {
int batteryLevel = lastDevice.getBatteryLevel();
if (batteryLevel != BluetoothDevice.BATTERY_LEVEL_UNKNOWN) {
BluetoothDeviceLayerDrawable drawable = createLayerDrawable(mContext,
- R.drawable.ic_qs_bluetooth_connected, batteryLevel);
+ R.drawable.ic_qs_bluetooth_connected, batteryLevel,
+ mContext.getResources().getFraction(
+ R.fraction.bt_battery_scale_fraction, 1, 1));
state.icon = new DrawableIcon(drawable);
}
}