Make header colour code more consistent (#1363)

- Ensure a header colour is picked for the main screen
- Simplify all different header colour code pickers into a single code
  path
This commit is contained in:
Sylvia van Os
2023-06-10 18:34:49 +02:00
committed by GitHub
parent e66c5e36fb
commit 6e390717da
6 changed files with 15 additions and 14 deletions

View File

@@ -853,10 +853,9 @@ public class LoyaltyCardEditActivity extends CatimaAppCompatActivity implements
}
}
// Generate random header color
if (tempLoyaltyCard.headerColor == null) {
// Select a random color to start out with.
updateTempState(LoyaltyCardField.headerColor, Utils.getRandomHeaderColor(this));
// If name is set, pick colour relevant for name. Otherwise pick randomly
updateTempState(LoyaltyCardField.headerColor, tempLoyaltyCard.store.isEmpty() ? Utils.getRandomHeaderColor(this) : Utils.getHeaderColor(this, tempLoyaltyCard));
}
// Update from intent
@@ -928,7 +927,7 @@ public class LoyaltyCardEditActivity extends CatimaAppCompatActivity implements
protected void setColorFromIcon() {
Object icon = thumbnail.getTag();
if (icon != null && (icon instanceof Bitmap)) {
int headerColor = Utils.getHeaderColorFromImage((Bitmap) icon, tempLoyaltyCard.headerColor != null ? tempLoyaltyCard.headerColor : androidx.appcompat.R.attr.colorPrimary);
int headerColor = Utils.getHeaderColorFromImage((Bitmap) icon, Utils.getHeaderColor(this, tempLoyaltyCard));
updateTempState(LoyaltyCardField.headerColor, headerColor);