Skip to content

Commit

Permalink
Don't cache image header colour
Browse files Browse the repository at this point in the history
Simplifies the logic for the icon -> front -> back fallback
  • Loading branch information
TheLastProject committed Jun 15, 2024
1 parent 630a096 commit 31836a2
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 16 deletions.
15 changes: 0 additions & 15 deletions app/src/main/java/protect/card_locker/LoyaltyCardEditActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,6 @@ public void onUserDismissedSelector() {
mIconUnsaved = true;
setCardImage(thumbnail, Utils.resizeBitmap(bitmap, Utils.BITMAP_SIZE_SMALL), false);
thumbnail.setBackgroundColor(Color.TRANSPARENT);
setColorFromIcon();
}
Log.d("cropper", "mRequestedImage: " + mRequestedImage);
mCropperFinishedType = mRequestedImage;
Expand Down Expand Up @@ -984,20 +983,6 @@ 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));

updateTempState(LoyaltyCardField.headerColor, headerColor);

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 setCardImage(ImageView imageView, Bitmap bitmap, boolean applyFallback) {
imageView.setTag(bitmap);

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/protect/card_locker/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -935,7 +935,7 @@ public static String linkify(final String input) {
* @return background colour
*/
public static int setIconOrTextWithBackground(Context context, LoyaltyCard loyaltyCard, Bitmap icon, ImageView backgroundOrIcon, TextView textWhenNoImage) {
int headerColor = getHeaderColor(context, loyaltyCard);
int headerColor = getHeaderColorFromImage(icon, getHeaderColor(context, loyaltyCard));
backgroundOrIcon.setImageBitmap(icon);
backgroundOrIcon.setBackgroundColor(headerColor);

Expand Down

0 comments on commit 31836a2

Please sign in to comment.