Tweak UI of CardPreference and ContextualCard

- CardPreference uses settingslib_preference
  layout to fix title/summary alignment issue.

- Remove stroke for CardPreference and ContextualCard.

- Set colorSurface as default card background color.

Bug: 188599776
Test: manual visual
Change-Id: Id0ee40be60de1f7605849490ee43eae4b9420abb
This commit is contained in:
Arc Wang
2021-06-09 09:23:00 +08:00
parent 7b85f2af24
commit bdb70b1078
8 changed files with 8 additions and 107 deletions

View File

@@ -19,9 +19,7 @@ package com.android.settings.widget;
import android.content.Context;
import android.util.AttributeSet;
import androidx.annotation.ColorInt;
import androidx.preference.Preference;
import androidx.preference.PreferenceViewHolder;
import com.android.settings.R;
@@ -32,10 +30,6 @@ import com.google.android.material.card.MaterialCardView;
*/
public class CardPreference extends Preference {
private static final @ColorInt int INVALID_COLOR = -1;
private @ColorInt int mCardBackgroundColor = INVALID_COLOR;
public CardPreference(Context context) {
this(context, null /* attrs */);
}
@@ -43,23 +37,4 @@ public class CardPreference extends Preference {
public CardPreference(Context context, AttributeSet attrs) {
super(context, attrs, R.attr.cardPreferenceStyle);
}
/** Set card background color of the MaterialCardView in CardPreference. */
public void setCardBackgroundColor(@ColorInt int color) {
if (mCardBackgroundColor == color) {
return;
}
mCardBackgroundColor = color;
notifyChanged();
}
@Override
public void onBindViewHolder(PreferenceViewHolder view) {
super.onBindViewHolder(view);
if (mCardBackgroundColor != INVALID_COLOR) {
final MaterialCardView cardView = (MaterialCardView) view.findViewById(R.id.container);
cardView.setCardBackgroundColor(mCardBackgroundColor);
}
}
}