Merge "Fixes and changes to support settings using UsageView" into nyc-dev
This commit is contained in:
@@ -17,10 +17,10 @@
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingEnd="@dimen/usage_graph_padding_end"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/graph_label_group"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/usage_graph_area_height"
|
||||
android:orientation="horizontal"
|
||||
@@ -28,9 +28,9 @@
|
||||
android:clipToPadding="false">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/label_group"
|
||||
android:layout_width="@dimen/usage_graph_labels_width"
|
||||
android:layout_height="match_parent"
|
||||
android:paddingStart="@dimen/usage_graph_labels_padding"
|
||||
android:orientation="vertical">
|
||||
|
||||
<include android:id="@+id/label_top"
|
||||
@@ -65,6 +65,7 @@
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/bottom_label_group"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingStart="@dimen/usage_graph_labels_width"
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
<attr name="sideLabels" format="reference" />
|
||||
<attr name="bottomLabels" format="reference" />
|
||||
<attr name="textColor" format="color" />
|
||||
<attr name="android:gravity" />
|
||||
</declare-styleable>
|
||||
|
||||
</resources>
|
||||
|
||||
@@ -41,8 +41,7 @@
|
||||
<!-- Usage graph dimens -->
|
||||
<dimen name="usage_graph_area_height">122dp</dimen>
|
||||
<dimen name="usage_graph_margin_top_bottom">9dp</dimen>
|
||||
<dimen name="usage_graph_padding_end">24dp</dimen>
|
||||
<dimen name="usage_graph_labels_width">72dp</dimen>
|
||||
<dimen name="usage_graph_labels_width">56dp</dimen>
|
||||
<dimen name="usage_graph_labels_padding">16dp</dimen>
|
||||
|
||||
<dimen name="usage_graph_divider_size">1dp</dimen>
|
||||
|
||||
@@ -733,7 +733,7 @@
|
||||
<string name="daltonizer_type_overridden">Overridden by <xliff:g id="title" example="Simulate color space">%1$s</xliff:g></string>
|
||||
|
||||
<!-- [CHAR_LIMIT=40] Label for estimated remaining duration of battery charging/discharging -->
|
||||
<string name="power_remaining_duration_only">Approx. <xliff:g id="time">%2$s</xliff:g> left</string>
|
||||
<string name="power_remaining_duration_only">Approx. <xliff:g id="time">%1$s</xliff:g> left</string>
|
||||
|
||||
<!-- [CHAR_LIMIT=40] Label for battery level chart when discharging with duration -->
|
||||
<string name="power_discharging_duration"><xliff:g id="level">%1$s</xliff:g>
|
||||
|
||||
@@ -149,7 +149,7 @@ public class BatteryInfo {
|
||||
String remaining = "";
|
||||
if (remainingTimeUs != 0) {
|
||||
remaining = context.getString(R.string.remaining_length_format,
|
||||
Formatter.formatShortElapsedTime(context, remainingTimeUs));
|
||||
Formatter.formatShortElapsedTime(context, remainingTimeUs / 1000));
|
||||
}
|
||||
view.setBottomLabels(new CharSequence[] { timeString, remaining});
|
||||
|
||||
|
||||
@@ -18,8 +18,10 @@ import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.SparseIntArray;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import com.android.settingslib.R;
|
||||
|
||||
@@ -58,6 +60,24 @@ public class UsageView extends FrameLayout {
|
||||
v.setTextColor(color);
|
||||
}
|
||||
}
|
||||
if (a.hasValue(R.styleable.UsageView_android_gravity)) {
|
||||
int gravity = a.getInt(R.styleable.UsageView_android_gravity, 0);
|
||||
if (gravity == Gravity.END) {
|
||||
LinearLayout layout = (LinearLayout) findViewById(R.id.graph_label_group);
|
||||
LinearLayout labels = (LinearLayout) findViewById(R.id.label_group);
|
||||
// Swap the children order.
|
||||
layout.removeView(labels);
|
||||
layout.addView(labels);
|
||||
// Set gravity.
|
||||
labels.setGravity(Gravity.END);
|
||||
// Swap the bottom label padding
|
||||
LinearLayout bottomLabels = (LinearLayout) findViewById(R.id.bottom_label_group);
|
||||
bottomLabels.setPadding(bottomLabels.getPaddingRight(), bottomLabels.getPaddingTop(),
|
||||
bottomLabels.getPaddingLeft(), bottomLabels.getPaddingBottom());
|
||||
} else if (gravity != Gravity.START) {
|
||||
throw new IllegalArgumentException("Unsupported gravity " + gravity);
|
||||
}
|
||||
}
|
||||
mUsageGraph.setAccentColor(a.getColor(R.styleable.UsageView_android_colorAccent, 0));
|
||||
}
|
||||
|
||||
|
||||
@@ -34,6 +34,8 @@
|
||||
android:id="@+id/battery_usage"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginEnd="24dp"
|
||||
systemui:sideLabels="@array/battery_labels"
|
||||
android:colorAccent="?android:attr/colorAccent"
|
||||
systemui:textColor="#66FFFFFF" />
|
||||
|
||||
Reference in New Issue
Block a user