Skip to content

Commit

Permalink
Merge pull request #2205 from CatimaLoyalty/fix/transparentThumbnails2
Browse files Browse the repository at this point in the history
Make thumbnails in edit view consistent with card view
  • Loading branch information
TheLastProject authored Dec 3, 2024
2 parents 208b1a2 + e6345bc commit d1b8051
Showing 1 changed file with 11 additions and 19 deletions.
30 changes: 11 additions & 19 deletions app/src/main/java/protect/card_locker/LoyaltyCardEditActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -1005,33 +1005,25 @@ protected void onResume() {
}
}

protected void setColorFromIcon() {
Object icon = thumbnail.getTag();
if (icon != null && (icon instanceof Bitmap)) {
int headerColor = Utils.getHeaderColorFromImage((Bitmap) icon, Utils.getHeaderColor(this, tempLoyaltyCard));
protected void setThumbnailImage(@Nullable Bitmap bitmap) {
setCardImage(thumbnail, bitmap, false);

if (bitmap != null) {
int headerColor = Utils.getHeaderColorFromImage(bitmap, Utils.getHeaderColor(this, tempLoyaltyCard));

setLoyaltyCardHeaderColor(headerColor);

thumbnail.setBackgroundColor(Utils.needsDarkForeground(headerColor) ? Color.BLACK : Color.WHITE);

thumbnailEditIcon.setBackgroundColor(Utils.needsDarkForeground(headerColor) ? Color.BLACK : Color.WHITE);
thumbnailEditIcon.setColorFilter(Utils.needsDarkForeground(headerColor) ? Color.WHITE : Color.BLACK);
} else {
Log.d("setColorFromIcon", "attempting header color change from icon but icon does not exist");
}
}

protected void setThumbnailImage(@Nullable Bitmap bitmap) {
setCardImage(thumbnail, bitmap, false);

if (bitmap == null) {
generateIcon(storeFieldEdit.getText().toString().trim());
} else {
thumbnail.setBackgroundColor(Color.TRANSPARENT);
setColorFromIcon();
}

if (tempLoyaltyCard.headerColor != null) {
thumbnailEditIcon.setBackgroundColor(Utils.needsDarkForeground(tempLoyaltyCard.headerColor) ? Color.BLACK : Color.WHITE);
thumbnailEditIcon.setColorFilter(Utils.needsDarkForeground(tempLoyaltyCard.headerColor) ? Color.WHITE : Color.BLACK);
if (tempLoyaltyCard.headerColor != null) {
thumbnailEditIcon.setBackgroundColor(Utils.needsDarkForeground(tempLoyaltyCard.headerColor) ? Color.BLACK : Color.WHITE);
thumbnailEditIcon.setColorFilter(Utils.needsDarkForeground(tempLoyaltyCard.headerColor) ? Color.WHITE : Color.BLACK);
}
}
}

Expand Down

0 comments on commit d1b8051

Please sign in to comment.