diff --git a/app/src/main/java/org/shadowice/flocke/andotp/Activities/MainActivity.java b/app/src/main/java/org/shadowice/flocke/andotp/Activities/MainActivity.java index 353b8693..bee08eec 100644 --- a/app/src/main/java/org/shadowice/flocke/andotp/Activities/MainActivity.java +++ b/app/src/main/java/org/shadowice/flocke/andotp/Activities/MainActivity.java @@ -354,7 +354,6 @@ public class MainActivity extends BaseActivity public void onSharedPreferenceChanged(SharedPreferences prefs, String key) { if (key.equals(getString(R.string.settings_key_label_size)) || key.equals(getString(R.string.settings_key_label_scroll)) || - key.equals(getString(R.string.settings_key_thumbnail_visible)) || key.equals(getString(R.string.settings_key_thumbnail_size))) { adapter.notifyDataSetChanged(); } else if (key.equals(getString(R.string.settings_key_tap_to_reveal)) || 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 0dbea350..cdc98922 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 @@ -84,24 +84,25 @@ public class EntryThumbnail { } public static Bitmap getThumbnailGraphic(Context context, String label, int size, EntryThumbnails thumbnail) { - if(thumbnail == EntryThumbnails.Default) { + if (thumbnail == EntryThumbnails.Default && size > 0) { LetterBitmap letterBitmap = new LetterBitmap(context); return letterBitmap.getLetterTile(label, label, size, size); - } + } else if (thumbnail != EntryThumbnails.Default) { - try { - if(thumbnail.getAssetType() == AssetType.Vector) { - Drawable drawable = context.getResources().getDrawable(thumbnail.getResource()); - 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()); - drawable.draw(canvas); - return bitmap; - } else { - return BitmapFactory.decodeResource(context.getResources(), thumbnail.getResource()); + try { + if (thumbnail.getAssetType() == AssetType.Vector) { + Drawable drawable = context.getResources().getDrawable(thumbnail.getResource()); + 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()); + drawable.draw(canvas); + return bitmap; + } else { + return BitmapFactory.decodeResource(context.getResources(), thumbnail.getResource()); + } + } catch (Exception e) { + e.printStackTrace(); } - } catch (Exception e) { - e.printStackTrace(); } return BitmapFactory.decodeResource(context.getResources(), R.mipmap.ic_launcher_round); diff --git a/app/src/main/java/org/shadowice/flocke/andotp/Utilities/Settings.java b/app/src/main/java/org/shadowice/flocke/andotp/Utilities/Settings.java index b1cfe4af..6bda160d 100644 --- a/app/src/main/java/org/shadowice/flocke/andotp/Utilities/Settings.java +++ b/app/src/main/java/org/shadowice/flocke/andotp/Utilities/Settings.java @@ -406,7 +406,7 @@ public class Settings { } public boolean getThumbnailVisible() { - return getBoolean(R.string.settings_key_thumbnail_visible, true); + return getThumbnailSize() > 0; } public int getThumbnailSize() { diff --git a/app/src/main/java/org/shadowice/flocke/andotp/View/EntriesCardAdapter.java b/app/src/main/java/org/shadowice/flocke/andotp/View/EntriesCardAdapter.java index a04c308c..8a530cb4 100644 --- a/app/src/main/java/org/shadowice/flocke/andotp/View/EntriesCardAdapter.java +++ b/app/src/main/java/org/shadowice/flocke/andotp/View/EntriesCardAdapter.java @@ -185,7 +185,9 @@ public class EntriesCardAdapter extends RecyclerView.Adapter } entryViewHolder.setLabelSize(settings.getLabelSize()); - entryViewHolder.setThumbnailSize(settings.getThumbnailSize()); + if(settings.getThumbnailVisible()) { + entryViewHolder.setThumbnailSize(settings.getThumbnailSize()); + } entryViewHolder.setLabelScroll(settings.getScrollLabel()); } 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 1638dc6d..d142c1b9 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 @@ -131,7 +131,9 @@ public class EntryViewHolder extends RecyclerView.ViewHolder thumbnailImg.setVisibility(settings.getThumbnailVisible() ? View.VISIBLE : View.GONE); int thumbnailSize = settings.getThumbnailSize(); - thumbnailImg.setImageBitmap(EntryThumbnail.getThumbnailGraphic(context, label, thumbnailSize, thumbnail)); + if(settings.getThumbnailVisible()) { + thumbnailImg.setImageBitmap(EntryThumbnail.getThumbnailGraphic(context, label, thumbnailSize, thumbnail)); + } if (this.tapToReveal) { if (isVisible) { diff --git a/app/src/main/res/values/settings.xml b/app/src/main/res/values/settings.xml index 9df8aed0..98c33236 100644 --- a/app/src/main/res/values/settings.xml +++ b/app/src/main/res/values/settings.xml @@ -20,7 +20,6 @@ pref_theme pref_label_size_sp pref_label_scroll - pref_thumbnail_visible pref_thumbnail_size pref_backup_ask @@ -96,6 +95,7 @@ + 0dp 32dp 46dp 64dp diff --git a/app/src/main/res/values/strings_settings.xml b/app/src/main/res/values/strings_settings.xml index 4fcd6afd..754b6118 100644 --- a/app/src/main/res/values/strings_settings.xml +++ b/app/src/main/res/values/strings_settings.xml @@ -20,7 +20,6 @@ Theme Label font size Scroll label - Show thumbnails Thumbnail size Ask for filename @@ -130,6 +129,7 @@ + Hidden Small Default Medium diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml index fcd6f485..0a563584 100644 --- a/app/src/main/res/xml/preferences.xml +++ b/app/src/main/res/xml/preferences.xml @@ -76,11 +76,6 @@ android:summary="@string/settings_desc_label_scroll" android:defaultValue="false" /> - -