From cd2310f110c7859d4c0a063e3055fad7571944b3 Mon Sep 17 00:00:00 2001 From: Jakob Nixdorf Date: Tue, 4 May 2021 07:18:55 +0200 Subject: [PATCH] Fix NPE when issuer was not set --- .../org/shadowice/flocke/andotp/Utilities/EntryThumbnail.java | 4 +++- .../org/shadowice/flocke/andotp/View/EntryViewHolder.java | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/org/shadowice/flocke/andotp/Utilities/EntryThumbnail.java b/app/src/main/java/org/shadowice/flocke/andotp/Utilities/EntryThumbnail.java index eb55256f..884e1c9b 100644 --- a/app/src/main/java/org/shadowice/flocke/andotp/Utilities/EntryThumbnail.java +++ b/app/src/main/java/org/shadowice/flocke/andotp/Utilities/EntryThumbnail.java @@ -30,6 +30,7 @@ import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.drawable.Drawable; +import android.text.TextUtils; import androidx.appcompat.app.AppCompatDelegate; import androidx.appcompat.content.res.AppCompatResources; @@ -42,13 +43,14 @@ public class EntryThumbnail { if (thumbnail == EntryThumbnails.Default && size > 0) { LetterBitmap letterBitmap = new LetterBitmap(context); - String letterSrc = issuer.isEmpty() ? label : issuer; + String letterSrc = TextUtils.isEmpty(issuer) ? label : issuer; return letterBitmap.getLetterTile(letterSrc, letterSrc, size, size); } else if (thumbnail != EntryThumbnails.Default) { try { if (thumbnail.getAssetType() == AssetType.Vector) { Drawable drawable = AppCompatResources.getDrawable(context, thumbnail.getResource()); + assert drawable != null; // The thumbnail should always have a drawable Bitmap bitmap = Bitmap.createBitmap(drawable.getMinimumWidth(), drawable.getMinimumHeight(), Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); diff --git a/app/src/main/java/org/shadowice/flocke/andotp/View/EntryViewHolder.java b/app/src/main/java/org/shadowice/flocke/andotp/View/EntryViewHolder.java index ec2a262f..14c50da1 100644 --- a/app/src/main/java/org/shadowice/flocke/andotp/View/EntryViewHolder.java +++ b/app/src/main/java/org/shadowice/flocke/andotp/View/EntryViewHolder.java @@ -251,7 +251,7 @@ public class EntryViewHolder extends RecyclerView.ViewHolder int thumbnailSize = settings.getThumbnailSize(); if(settings.getThumbnailVisible()) { - thumbnailImg.setImageBitmap(EntryThumbnail.getThumbnailGraphic(context, entry.getIssuer(), entry.getLabel(), thumbnailSize, entry.getThumbnail())); + thumbnailImg.setImageBitmap(EntryThumbnail.getThumbnailGraphic(context, issuerText, labelText, thumbnailSize, entry.getThumbnail())); } if (entry.isTimeBased() && (entry.hasNonDefaultPeriod() || settings.isShowIndividualTimeoutsEnabled())) {