Move thumbnail toggle into the size selector

This commit is contained in:
RichyHBM 2018-01-02 22:08:16 +00:00
parent e9254fca6f
commit ccbe2ef19c
8 changed files with 24 additions and 25 deletions

View file

@ -309,7 +309,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)) ||

View file

@ -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);

View file

@ -352,7 +352,7 @@ public class Settings {
}
public boolean getThumbnailVisible() {
return getBoolean(R.string.settings_key_thumbnail_visible, true);
return getThumbnailSize() > 0;
}
public int getThumbnailSize() {

View file

@ -168,7 +168,9 @@ public class EntriesCardAdapter extends RecyclerView.Adapter<EntryViewHolder>
}
entryViewHolder.setLabelSize(settings.getLabelSize());
entryViewHolder.setThumbnailSize(settings.getThumbnailSize());
if(settings.getThumbnailVisible()) {
entryViewHolder.setThumbnailSize(settings.getThumbnailSize());
}
entryViewHolder.setLabelScroll(settings.getScrollLabel());
}

View file

@ -132,7 +132,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) {

View file

@ -16,7 +16,6 @@
<string name="settings_key_theme" translatable="false">pref_theme</string>
<string name="settings_key_label_size" translatable="false">pref_label_size_sp</string>
<string name="settings_key_label_scroll" translatable="false">pref_label_scroll</string>
<string name="settings_key_thumbnail_visible" translatable="false">pref_thumbnail_visible</string>
<string name="settings_key_thumbnail_size" translatable="false">pref_thumbnail_size</string>
<string name="settings_key_backup_ask" translatable="false">pref_backup_ask</string>
@ -93,6 +92,7 @@
</string-array>
<string-array name="settings_values_thumbnail_size" translatable="false">
<item>0dp</item>
<item>32dp</item>
<item>46dp</item>
<item>64dp</item>

View file

@ -19,7 +19,6 @@
<string name="settings_title_theme">Theme</string>
<string name="settings_title_label_size">Label font size</string>
<string name="settings_title_label_scroll">Scroll label</string>
<string name="settings_title_thumbnail_visible_ask">Show thumbnails</string>
<string name="settings_title_thumbnail_size_ask">Thumbnail size</string>
<string name="settings_title_backup_ask">Ask for filename</string>
@ -84,6 +83,7 @@
</string-array>
<string-array name="settings_entries_thumbnail_size">
<item>Hidden</item>
<item>Small</item>
<item>Default</item>
<item>Medium</item>

View file

@ -76,11 +76,6 @@
android:summary="@string/settings_desc_label_scroll"
android:defaultValue="false" />
<CheckBoxPreference
android:key="@string/settings_key_thumbnail_visible"
android:title="@string/settings_title_thumbnail_visible_ask"
android:defaultValue="true" />
<ListPreference
android:key="@string/settings_key_thumbnail_size"
android:title="@string/settings_title_thumbnail_size_ask"