Merge "Usage graphs support RTL style."

This commit is contained in:
TreeHugger Robot
2018-06-14 02:35:28 +00:00
committed by Android (Google) Code Review
2 changed files with 7 additions and 2 deletions

View File

@@ -80,8 +80,7 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal"
android:layoutDirection="ltr">
android:orientation="horizontal">
<include android:id="@+id/label_start"
layout="@layout/usage_side_label" />

View File

@@ -255,9 +255,15 @@ public class UsageGraph extends View {
return;
}
canvas.save();
if (getLayoutDirection() == LAYOUT_DIRECTION_RTL) {
// Flip the canvas along the y-axis of the center of itself before drawing paths.
canvas.scale(-1, 1, canvas.getWidth() * 0.5f, 0);
}
drawLinePath(canvas, mLocalProjectedPaths, mDottedPaint);
drawFilledPath(canvas, mLocalPaths, mFillPaint);
drawLinePath(canvas, mLocalPaths, mLinePaint);
canvas.restore();
BatteryUtils.logRuntime(LOG_TAG, "onDraw", startTime);
}