Update color bar defaults to use theme attr colors
Previously the values were hardcoded. Now the default value for left and middle are colorAccent. Also updated SummaryPreference to not call LinearColorBar.setColors unless its own setColors is called. BUG: 28760785 Change-Id: Id28e809e6b5f0f6508258c995d5dcfacbc9c8725
This commit is contained in:
@@ -33,6 +33,7 @@ public class SummaryPreference extends Preference {
|
||||
private String mUnits;
|
||||
|
||||
private int mLeft, mMiddle, mRight;
|
||||
private boolean mColorsSet = false;
|
||||
private float mLeftRatio, mMiddleRatio, mRightRatio;
|
||||
private String mStartLabel;
|
||||
private String mEndLabel;
|
||||
@@ -40,8 +41,6 @@ public class SummaryPreference extends Preference {
|
||||
public SummaryPreference(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
setLayoutResource(R.layout.settings_summary_preference);
|
||||
mLeft = context.getColor(R.color.summary_default_start);
|
||||
mRight = context.getColor(R.color.summary_default_end);
|
||||
}
|
||||
|
||||
public void setAmount(String amount) {
|
||||
@@ -77,6 +76,7 @@ public class SummaryPreference extends Preference {
|
||||
mLeft = left;
|
||||
mMiddle = middle;
|
||||
mRight = right;
|
||||
mColorsSet = true;
|
||||
notifyChanged();
|
||||
}
|
||||
|
||||
@@ -86,7 +86,9 @@ public class SummaryPreference extends Preference {
|
||||
|
||||
LinearColorBar colorBar = (LinearColorBar) holder.itemView.findViewById(R.id.color_bar);
|
||||
colorBar.setRatios(mLeftRatio, mMiddleRatio, mRightRatio);
|
||||
colorBar.setColors(mLeft, mMiddle, mRight);
|
||||
if (mColorsSet) {
|
||||
colorBar.setColors(mLeft, mMiddle, mRight);
|
||||
}
|
||||
|
||||
if (!TextUtils.isEmpty(mStartLabel) || !TextUtils.isEmpty(mEndLabel)) {
|
||||
holder.findViewById(R.id.label_bar).setVisibility(View.VISIBLE);
|
||||
|
||||
Reference in New Issue
Block a user