diff --git a/app/src/main/java/protect/card_locker/LoyaltyCardViewActivity.java b/app/src/main/java/protect/card_locker/LoyaltyCardViewActivity.java
index f6e3ecfa6..d91aeb90e 100644
--- a/app/src/main/java/protect/card_locker/LoyaltyCardViewActivity.java
+++ b/app/src/main/java/protect/card_locker/LoyaltyCardViewActivity.java
@@ -23,6 +23,7 @@ import android.view.WindowManager;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
+import android.widget.RelativeLayout;
import android.widget.SeekBar;
import android.widget.TextView;
import android.widget.Toast;
@@ -71,6 +72,10 @@ public class LoyaltyCardViewActivity extends CatimaAppCompatActivity implements
ImageButton minimizeButton;
View collapsingToolbarLayout;
AppBarLayout appBarLayout;
+ ImageView iconImage;
+ RelativeLayout relativeLayout;
+ Toolbar landscapeToolbar;
+
int loyaltyCardId;
LoyaltyCard loyaltyCard;
boolean rotationEnabled;
@@ -101,6 +106,8 @@ public class LoyaltyCardViewActivity extends CatimaAppCompatActivity implements
static final String STATE_IMAGEINDEX = "imageIndex";
static final String STATE_FULLSCREEN = "isFullscreen";
+ private final int HEADER_FILTER_ALPHA = 70;
+
final private TaskHandler mTasks = new TaskHandler();
@Override
@@ -259,6 +266,9 @@ public class LoyaltyCardViewActivity extends CatimaAppCompatActivity implements
minimizeButton = findViewById(R.id.minimizeButton);
collapsingToolbarLayout = findViewById(R.id.collapsingToolbarLayout);
appBarLayout = findViewById(R.id.app_bar_layout);
+ iconImage = findViewById(R.id.icon_image);
+ relativeLayout = findViewById(R.id.relative_layout);
+ landscapeToolbar = findViewById(R.id.toolbar_landscape);
centerGuideline = findViewById(R.id.centerGuideline);
barcodeScaler = findViewById(R.id.barcodeScaler);
@@ -366,6 +376,34 @@ public class LoyaltyCardViewActivity extends CatimaAppCompatActivity implements
}
});
+ // synchronizing iconImage size with it's layer above
+ collapsingToolbarLayout.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
+ @Override
+ public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
+ Log.d("onLayoutChange", "collapsing toolbar change, height: " + v.getHeight());
+ // on android 11, setAdjustViewBounds on the imageView triggers this callback again to my horror, so adding an if to block it
+ if(iconImage.getHeight() != v.getHeight()) {
+ // setAdjustViewBounds and scale type breaks when an image is set, then the following has to be execute in this order
+ iconImage.setAdjustViewBounds(true);
+ iconImage.setScaleType(ImageView.ScaleType.CENTER_CROP);
+ iconImage.setMaxHeight(v.getHeight());
+ iconImage.setMaxWidth(v.getWidth());
+ }
+ }
+ });
+ landscapeToolbar.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
+ @Override
+ public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
+ Log.d("onLayoutChange", "landscape toolbar change, height: " + v.getHeight());
+ if(iconImage.getHeight() != v.getHeight()) {
+ iconImage.setAdjustViewBounds(true);
+ iconImage.setScaleType(ImageView.ScaleType.CENTER_CROP);
+ iconImage.setMaxHeight(v.getHeight());
+ iconImage.setMaxWidth(v.getWidth());
+ }
+ }
+ });
+
mGestureDetector = new GestureDetector(this, this);
View.OnTouchListener gestureTouchListener = (v, event) -> mGestureDetector.onTouchEvent(event);
mainImage.setOnTouchListener(gestureTouchListener);
@@ -501,7 +539,6 @@ public class LoyaltyCardViewActivity extends CatimaAppCompatActivity implements
backgroundHeaderColor = LetterBitmap.getDefaultColor(this, loyaltyCard.store);
}
- collapsingToolbarLayout.setBackgroundColor(backgroundHeaderColor);
appBarLayout.setBackgroundColor(backgroundHeaderColor);
int textColor;
@@ -513,6 +550,24 @@ public class LoyaltyCardViewActivity extends CatimaAppCompatActivity implements
storeName.setTextColor(textColor);
((Toolbar) findViewById(R.id.toolbar_landscape)).setTitleTextColor(textColor);
+ Bitmap icon = Utils.retrieveCardImage(this, loyaltyCard.id, ImageLocationType.icon);
+ if (icon != null){
+ int backgroundAlphaColor = Utils.needsDarkForeground(backgroundHeaderColor) ? Color.WHITE : Color.BLACK;
+ Log.d("onResume", "setting icon image");
+ iconImage.setImageBitmap(icon);
+ int backgroundWithAlpha = Color.argb(HEADER_FILTER_ALPHA, Color.red(backgroundAlphaColor), Color.green(backgroundAlphaColor), Color.blue(backgroundAlphaColor));
+ collapsingToolbarLayout.setBackgroundColor(backgroundWithAlpha);
+ landscapeToolbar.setBackgroundColor(backgroundWithAlpha);
+ // for images that has alpha
+ iconImage.setBackgroundColor(backgroundWithAlpha);
+ }else{
+ Bitmap plain = Bitmap.createBitmap(new int[]{backgroundHeaderColor}, 1, 1, Bitmap.Config.ARGB_8888);
+ iconImage.setImageBitmap(plain);
+ collapsingToolbarLayout.setBackgroundColor(Color.TRANSPARENT);
+ landscapeToolbar.setBackgroundColor(Color.TRANSPARENT);
+ iconImage.setBackgroundColor(Color.TRANSPARENT);
+ }
+
// If the background is very bright, we should use dark icons
backgroundNeedsDarkIcons = Utils.needsDarkForeground(backgroundHeaderColor);
ActionBar actionBar = getSupportActionBar();
@@ -820,6 +875,8 @@ public class LoyaltyCardViewActivity extends CatimaAppCompatActivity implements
actionBar.hide();
}
+ iconImage.setVisibility(View.GONE);
+
// Hide toolbars
//
// Appbar needs to be invisible and have padding removed
@@ -860,6 +917,8 @@ public class LoyaltyCardViewActivity extends CatimaAppCompatActivity implements
actionBar.show();
}
+ iconImage.setVisibility(View.VISIBLE);
+
// Show appropriate toolbar
// And restore 24dp paddingTop for appBarLayout
appBarLayout.setVisibility(View.VISIBLE);
diff --git a/app/src/main/java/protect/card_locker/Utils.java b/app/src/main/java/protect/card_locker/Utils.java
index 6c3d0680f..3e28026e8 100644
--- a/app/src/main/java/protect/card_locker/Utils.java
+++ b/app/src/main/java/protect/card_locker/Utils.java
@@ -61,8 +61,8 @@ public class Utils {
static final double LUMINANCE_MIDPOINT = 0.5;
- static final int BITMAP_SIZE_SMALL = 64;
- static final int BITMAP_SIZE_BIG = 512;
+ static final int BITMAP_SIZE_SMALL = 512;
+ static final int BITMAP_SIZE_BIG = 2045;
static public LetterBitmap generateIcon(Context context, LoyaltyCard loyaltyCard, boolean forShortcut) {
return generateIcon(context, loyaltyCard.store, loyaltyCard.headerColor, forShortcut);
diff --git a/app/src/main/res/layout/loyalty_card_view_layout.xml b/app/src/main/res/layout/loyalty_card_view_layout.xml
index 936a9b750..93a3f10e5 100644
--- a/app/src/main/res/layout/loyalty_card_view_layout.xml
+++ b/app/src/main/res/layout/loyalty_card_view_layout.xml
@@ -244,50 +244,73 @@
android:layout_height="wrap_content"
android:weightSum="1.0"
android:fitsSystemWindows="true">
-
-
+
+
+ android:layout_height="match_parent"
+ android:layout_alignParentTop="true"
+ android:scaleType="centerCrop"
+ app:srcCompat="@drawable/ic_launcher_foreground"
+ tools:ignore="ContentDescription" />
+
-
-
+
+
+
+
+
+
+
+
+
+