Added optional background color instead of flag color

This commit is contained in:
M66B
2019-09-27 11:33:07 +02:00
parent ff2a4201c2
commit 0e8860ae1e
6 changed files with 59 additions and 10 deletions

View File

@@ -50,9 +50,9 @@ public class ViewCardOptional extends CardView {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
boolean cards = prefs.getBoolean("cards", true);
boolean compact = prefs.getBoolean("compact", false);
if (cards) {
int dp6 = Helper.dp2pixels(getContext(), 6);
int color = Helper.resolveColor(getContext(), R.attr.colorCardBackground);
FrameLayout.LayoutParams lparam = (FrameLayout.LayoutParams) getLayoutParams();
lparam.setMargins(dp6, compact ? 0 : dp6, dp6, dp6);
@@ -60,13 +60,21 @@ public class ViewCardOptional extends CardView {
setRadius(dp6);
setElevation(compact ? dp6 / 2f : dp6);
setCardBackgroundColor(color);
getChildAt(0).setPadding(dp6, dp6, dp6, dp6);
} else {
setRadius(0);
setElevation(0);
setCardBackgroundColor(Color.TRANSPARENT);
}
}
@Override
public void setCardBackgroundColor(int color) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
boolean cards = prefs.getBoolean("cards", true);
if (cards && color == Color.TRANSPARENT)
color = Helper.resolveColor(getContext(), R.attr.colorCardBackground);
super.setCardBackgroundColor(color);
}
}