Skip to content

Commit

Permalink
Fix dark mode rendering glitch (#1355)
Browse files Browse the repository at this point in the history
  • Loading branch information
TheLastProject authored Jun 7, 2023
1 parent 4b6497c commit 03239f0
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
16 changes: 10 additions & 6 deletions app/src/main/java/protect/card_locker/LoyaltyCardViewActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat;
import androidx.core.widget.TextViewCompat;

import com.google.android.material.color.MaterialColors;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.textfield.TextInputEditText;

Expand Down Expand Up @@ -873,18 +874,17 @@ public void onGlobalLayout() {
private void drawMainImage(int index, boolean waitForResize, boolean isFullscreen) {
if (imageTypes.isEmpty()) {
barcodeRenderTarget.setVisibility(View.GONE);
binding.mainCardView.setCardBackgroundColor(Color.TRANSPARENT);
binding.cardIdView.setTextColor(MaterialColors.getColor(binding.cardIdView, com.google.android.material.R.attr.colorOnSurfaceVariant));
return;
}

ImageType wantedImageType = imageTypes.get(index);

if (wantedImageType == ImageType.BARCODE) {
// Use border in non-fullscreen mode
if (!isFullscreen) {
barcodeRenderTarget.setBackground(AppCompatResources.getDrawable(this, R.drawable.round_outline));
} else {
barcodeRenderTarget.setBackgroundColor(Color.WHITE);
}
barcodeRenderTarget.setBackgroundColor(Color.WHITE);
binding.mainCardView.setCardBackgroundColor(Color.WHITE);
binding.cardIdView.setTextColor(getResources().getColor(R.color.md_theme_light_onSurfaceVariant));

if (waitForResize) {
redrawBarcodeAfterResize(!isFullscreen);
Expand All @@ -896,10 +896,14 @@ private void drawMainImage(int index, boolean waitForResize, boolean isFullscree
} else if (wantedImageType == ImageType.IMAGE_FRONT) {
barcodeRenderTarget.setImageBitmap(frontImageBitmap);
barcodeRenderTarget.setBackgroundColor(Color.TRANSPARENT);
binding.mainCardView.setCardBackgroundColor(Color.TRANSPARENT);
binding.cardIdView.setTextColor(MaterialColors.getColor(binding.cardIdView, com.google.android.material.R.attr.colorOnSurfaceVariant));
barcodeRenderTarget.setContentDescription(getString(R.string.frontImageDescription));
} else if (wantedImageType == ImageType.IMAGE_BACK) {
barcodeRenderTarget.setImageBitmap(backImageBitmap);
barcodeRenderTarget.setBackgroundColor(Color.TRANSPARENT);
binding.mainCardView.setCardBackgroundColor(Color.TRANSPARENT);
binding.cardIdView.setTextColor(MaterialColors.getColor(binding.cardIdView, com.google.android.material.R.attr.colorOnSurfaceVariant));
barcodeRenderTarget.setContentDescription(getString(R.string.backImageDescription));
} else {
throw new IllegalArgumentException("Unknown image type: " + wantedImageType);
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/layout/loyalty_card_view_layout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
android:layout_weight="1">

<com.google.android.material.card.MaterialCardView
android:id="@+id/main_card_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:cardCornerRadius="8dp"
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 03239f0

Please sign in to comment.