Merge pull request #102 from RichyHBM/hide_thumbnail_in_dropdown
Move thumbnail toggle into the size selector Closes #98
This commit is contained in:
commit
1989a2aa4e
8 changed files with 24 additions and 25 deletions
|
@ -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)) ||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -185,7 +185,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());
|
||||
}
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -20,7 +20,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>
|
||||
|
@ -96,6 +95,7 @@
|
|||
</string-array>
|
||||
|
||||
<string-array name="settings_values_thumbnail_size" translatable="false">
|
||||
<item>0dp</item>
|
||||
<item>32dp</item>
|
||||
<item>46dp</item>
|
||||
<item>64dp</item>
|
||||
|
|
|
@ -20,7 +20,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>
|
||||
|
@ -130,6 +129,7 @@
|
|||
</string-array>
|
||||
|
||||
<string-array name="settings_entries_thumbnail_size">
|
||||
<item>Hidden</item>
|
||||
<item>Small</item>
|
||||
<item>Default</item>
|
||||
<item>Medium</item>
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in a new issue