Make the possibility to set a custom header more visible

This commit is contained in:
Sylvia van Os
2022-07-27 21:22:59 +02:00
parent 0189f13ee6
commit 34bbfffdaf
4 changed files with 30 additions and 1 deletions

View File

@@ -1,5 +1,9 @@
# Changelog
## Unreleased - 112
- Make the possibility to set a custom header more visible
## v2.18.1 - 111
- Arabic language support

View File

@@ -117,6 +117,7 @@ public class LoyaltyCardEditActivity extends CatimaAppCompatActivity {
TabLayout tabs;
ImageView thumbnail;
ImageView thumbnailEditIcon;
EditText storeFieldEdit;
EditText noteFieldEdit;
ChipGroup groupsChips;
@@ -315,6 +316,7 @@ public class LoyaltyCardEditActivity extends CatimaAppCompatActivity {
tabs = findViewById(R.id.tabs);
thumbnail = findViewById(R.id.thumbnail);
thumbnailEditIcon = findViewById(R.id.thumbnailEditIcon);
storeFieldEdit = findViewById(R.id.storeNameEdit);
noteFieldEdit = findViewById(R.id.noteEdit);
groupsChips = findViewById(R.id.groupChips);
@@ -914,13 +916,21 @@ public class LoyaltyCardEditActivity extends CatimaAppCompatActivity {
generateIcon(storeFieldEdit.getText().toString());
thumbnailEditIcon.setBackgroundColor(Utils.needsDarkForeground(tempLoyaltyCard.headerColor) ? Color.BLACK : Color.WHITE);
thumbnailEditIcon.setColorFilter(Utils.needsDarkForeground(tempLoyaltyCard.headerColor) ? Color.WHITE : Color.BLACK);
onResuming = false;
}
protected void setColorFromIcon() {
Object icon = thumbnail.getTag();
if (icon != null && (icon instanceof Bitmap)) {
updateTempState(LoyaltyCardField.headerColor, Utils.getHeaderColorFromImage((Bitmap) icon, tempLoyaltyCard.headerColor != null ? tempLoyaltyCard.headerColor : R.attr.colorPrimary));
int headerColor = Utils.getHeaderColorFromImage((Bitmap) icon, tempLoyaltyCard.headerColor != null ? tempLoyaltyCard.headerColor : R.attr.colorPrimary);
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");
}
@@ -1102,6 +1112,9 @@ public class LoyaltyCardEditActivity extends CatimaAppCompatActivity {
public void onColorSelected(int dialogId, int color) {
updateTempState(LoyaltyCardField.headerColor, color);
thumbnailEditIcon.setBackgroundColor(Utils.needsDarkForeground(color) ? Color.BLACK : Color.WHITE);
thumbnailEditIcon.setColorFilter(Utils.needsDarkForeground(color) ? Color.WHITE : Color.BLACK);
// Unset image if set
thumbnail.setTag(null);

View File

@@ -82,6 +82,17 @@
android:contentDescription="@string/thumbnailDescription"
android:src="@mipmap/ic_launcher"/>
<com.google.android.material.imageview.ShapeableImageView
android:id="@+id/thumbnailEditIcon"
app:shapeAppearanceOverlay="@style/ShapeAppearanceOverlay.Material3.FloatingActionButton"
android:layout_width="@dimen/cardThumbnailEditOverlaySize"
android:layout_height="@dimen/cardThumbnailEditOverlaySize"
android:layout_gravity="bottom|end"
android:layout_margin="4dp"
app:contentPadding="4dp"
android:alpha="0.8"
android:src="@drawable/ic_mode_edit_white_24dp"/>
</com.google.android.material.card.MaterialCardView>
<com.google.android.material.textfield.TextInputLayout

View File

@@ -28,6 +28,7 @@
<dimen name="cardThumbnailSize">46dp</dimen>
<dimen name="cardThumbnailSizeLarge">200dp</dimen>
<dimen name="cardThumbnailEditOverlaySize">21dp</dimen>
<dimen name="activity_margin_small">8dp</dimen>
<dimen name="activity_margin">16dp</dimen>