From 1b1c00d6033079f114e3e5f5e6276b8a02cdf64c Mon Sep 17 00:00:00 2001 From: RichyHBM Date: Sat, 25 Nov 2017 13:30:49 +0000 Subject: [PATCH 01/15] Show default thumbnail --- .../shadowice/flocke/andotp/Activities/MainActivity.java | 3 ++- .../org/shadowice/flocke/andotp/Utilities/Settings.java | 5 +++++ app/src/main/res/layout/component_card.xml | 7 +++++++ app/src/main/res/values/dimens.xml | 4 ++++ app/src/main/res/values/settings.xml | 1 + app/src/main/res/values/strings_settings.xml | 1 + app/src/main/res/xml/preferences.xml | 6 ++++++ 7 files changed, 26 insertions(+), 1 deletion(-) 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 30a84126..60f158b4 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 @@ -429,7 +429,8 @@ 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_tap_to_reveal)) || - key.equals(getString(R.string.settings_key_label_scroll))) { + key.equals(getString(R.string.settings_key_label_scroll)) || + key.equals(getString(R.string.settings_key_thumbnail_visible))) { adapter.notifyDataSetChanged(); } else if (key.equals(getString(R.string.settings_key_theme)) || key.equals(getString(R.string.settings_key_lang))) { 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 77e3d4bf..0b90f4ab 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 @@ -330,4 +330,9 @@ public class Settings { toggledTags.add(tag); setStringSet(R.string.settings_key_tags_toggles, toggledTags); } + + public boolean getThumbnailVisible() { + return getBoolean(R.string.settings_key_thumbnail_visible, true); + } + } diff --git a/app/src/main/res/layout/component_card.xml b/app/src/main/res/layout/component_card.xml index 5ef14874..ee9891dc 100644 --- a/app/src/main/res/layout/component_card.xml +++ b/app/src/main/res/layout/component_card.xml @@ -13,6 +13,13 @@ android:gravity="center_vertical" android:baselineAligned="false" > + + 16dp 0dp + 64dp + + + 33sp 200dp 1dp diff --git a/app/src/main/res/values/settings.xml b/app/src/main/res/values/settings.xml index da712e4b..97dc00fa 100644 --- a/app/src/main/res/values/settings.xml +++ b/app/src/main/res/values/settings.xml @@ -15,6 +15,7 @@ pref_theme pref_label_size pref_label_scroll + pref_thumbnail_visible pref_backup_ask pref_backup_directory diff --git a/app/src/main/res/values/strings_settings.xml b/app/src/main/res/values/strings_settings.xml index aebf17e4..7ab3a1bf 100644 --- a/app/src/main/res/values/strings_settings.xml +++ b/app/src/main/res/values/strings_settings.xml @@ -18,6 +18,7 @@ Theme Label font size Scroll label + Show thumbnails Ask for filename Backup directory diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml index 8c32e7ea..6530b829 100644 --- a/app/src/main/res/xml/preferences.xml +++ b/app/src/main/res/xml/preferences.xml @@ -66,6 +66,12 @@ android:summary="@string/settings_desc_label_scroll" android:defaultValue="false" /> + + + Date: Sat, 25 Nov 2017 14:25:13 +0000 Subject: [PATCH 02/15] Change default image to LetterTile, set if no other image is defined --- README.md | 1 + .../andotp/Activities/BackupActivity.java | 4 +- .../andotp/Activities/MainActivity.java | 9 ++ .../flocke/andotp/Database/Entry.java | 17 +++ .../andotp/Utilities/DatabaseHelper.java | 13 +- .../flocke/andotp/Utilities/LetterBitmap.java | 133 ++++++++++++++++++ .../andotp/View/EntriesCardAdapter.java | 10 +- .../flocke/andotp/View/EntryViewHolder.java | 14 +- app/src/main/res/values/settings.xml | 12 ++ 9 files changed, 202 insertions(+), 11 deletions(-) create mode 100644 app/src/main/java/org/shadowice/flocke/andotp/Utilities/LetterBitmap.java diff --git a/README.md b/README.md index b1fa4186..6d3020ee 100644 --- a/README.md +++ b/README.md @@ -120,6 +120,7 @@ So make sure you have a **current backup** before switching! * [Android-ItemTouchHelper-Demo](https://github.com/iPaulPro/Android-ItemTouchHelper-Demo/tree/master/app/src/main/java/co/paulburke/android/itemtouchhelperdemo/helper) * [Code Parts from Google's Android Samples](https://android.googlesource.com/platform/development/+/master/samples/Vault/src/com/example/android/vault) * [FloatingActionMenuAndroid](https://github.com/pmahsky/FloatingActionMenuAndroid) + * [LetterBitmap](http://stackoverflow.com/questions/23122088/colored-boxed-with-letters-a-la-gmail) ## License: ``` diff --git a/app/src/main/java/org/shadowice/flocke/andotp/Activities/BackupActivity.java b/app/src/main/java/org/shadowice/flocke/andotp/Activities/BackupActivity.java index 627127c0..24f23dbe 100644 --- a/app/src/main/java/org/shadowice/flocke/andotp/Activities/BackupActivity.java +++ b/app/src/main/java/org/shadowice/flocke/andotp/Activities/BackupActivity.java @@ -439,7 +439,7 @@ public class BackupActivity extends BaseActivity { SecretKey key = EncryptionHelper.generateSymmetricKeyFromPassword(password); byte[] decrypted = EncryptionHelper.decrypt(key, encrypted); - ArrayList entries = DatabaseHelper.stringToEntries(new String(decrypted, StandardCharsets.UTF_8)); + ArrayList entries = DatabaseHelper.stringToEntries(this, new String(decrypted, StandardCharsets.UTF_8)); if (! replace.isChecked()) { ArrayList currentEntries = DatabaseHelper.loadDatabase(this); @@ -508,7 +508,7 @@ public class BackupActivity extends BaseActivity { private void doRestoreEncrypted(String content) { if (Tools.isExternalStorageReadable()) { - ArrayList entries = DatabaseHelper.stringToEntries(content); + ArrayList entries = DatabaseHelper.stringToEntries(this, content); if (entries.size() > 0) { if (! replace.isChecked()) { 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 60f158b4..eed57491 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 @@ -63,6 +63,7 @@ import com.google.zxing.integration.android.IntentResult; import org.shadowice.flocke.andotp.Database.Entry; import org.shadowice.flocke.andotp.R; import org.shadowice.flocke.andotp.Utilities.DatabaseHelper; +import org.shadowice.flocke.andotp.Utilities.LetterBitmap; import org.shadowice.flocke.andotp.Utilities.Settings; import org.shadowice.flocke.andotp.Utilities.TagDialogHelper; import org.shadowice.flocke.andotp.Utilities.TokenCalculator; @@ -208,6 +209,10 @@ public class MainActivity extends BaseActivity int digits = Integer.parseInt(digitsInput.getText().toString()); Entry e = new Entry(type, secret, period, digits, label, algorithm, tagsAdapter.getActiveTags()); + + int size = getResources().getDimensionPixelSize(R.dimen.card_thumbnail_size); + e.setThumbnailImage(new LetterBitmap(MainActivity.this).getLetterTile(label, label, size, size)); + e.updateOTP(); adapter.addEntry(e); adapter.saveEntries(); @@ -454,6 +459,10 @@ public class MainActivity extends BaseActivity if(result.getContents() != null) { try { Entry e = new Entry(result.getContents()); + + int size = getResources().getDimensionPixelSize(R.dimen.card_thumbnail_size); + e.setThumbnailImage(new LetterBitmap(MainActivity.this).getLetterTile(e.getLabel(), e.getLabel(), size, size)); + e.updateOTP(); adapter.addEntry(e); adapter.saveEntries(); diff --git a/app/src/main/java/org/shadowice/flocke/andotp/Database/Entry.java b/app/src/main/java/org/shadowice/flocke/andotp/Database/Entry.java index b1cda863..16b3c41d 100644 --- a/app/src/main/java/org/shadowice/flocke/andotp/Database/Entry.java +++ b/app/src/main/java/org/shadowice/flocke/andotp/Database/Entry.java @@ -23,6 +23,7 @@ package org.shadowice.flocke.andotp.Database; +import android.graphics.Bitmap; import android.net.Uri; import org.apache.commons.codec.binary.Base32; @@ -52,6 +53,7 @@ public class Entry { private static final String JSON_TYPE = "type"; private static final String JSON_ALGORITHM = "algorithm"; private static final String JSON_TAGS = "tags"; + private static final String JSON_THUMBNAIL = "thumbnail"; private OTPType type = OTPType.TOTP; private int period = TokenCalculator.TOTP_DEFAULT_PERIOD; @@ -62,6 +64,8 @@ public class Entry { private String currentOTP; private long last_update = 0; public List tags = new ArrayList<>(); + private int thumbnail = -1; + private Bitmap thumbnailImage; public Entry(){} @@ -163,6 +167,12 @@ public class Entry { } catch (JSONException e) { e.printStackTrace(); } + + try { + this.thumbnail = jsonObj.getInt(JSON_THUMBNAIL); + } catch(JSONException e) { + this.thumbnail = -1; + } } public JSONObject toJSON() throws JSONException { @@ -173,6 +183,7 @@ public class Entry { jsonObj.put(JSON_DIGITS, getDigits()); jsonObj.put(JSON_TYPE, getType().toString()); jsonObj.put(JSON_ALGORITHM, algorithm.toString()); + jsonObj.put(JSON_THUMBNAIL, getThumbnail()); JSONArray tagsArray = new JSONArray(); for(String tag : tags){ @@ -227,6 +238,12 @@ public class Entry { public void setTags(List tags) { this.tags = tags; } + public Bitmap getThumbnailImage() { return thumbnailImage; } + + public void setThumbnailImage(Bitmap thumbnailImage) { this.thumbnailImage = thumbnailImage; } + + public int getThumbnail() { return thumbnail; } + public TokenCalculator.HashAlgorithm getAlgorithm() { return this.algorithm; } diff --git a/app/src/main/java/org/shadowice/flocke/andotp/Utilities/DatabaseHelper.java b/app/src/main/java/org/shadowice/flocke/andotp/Utilities/DatabaseHelper.java index 477e1c93..9e3face8 100644 --- a/app/src/main/java/org/shadowice/flocke/andotp/Utilities/DatabaseHelper.java +++ b/app/src/main/java/org/shadowice/flocke/andotp/Utilities/DatabaseHelper.java @@ -28,6 +28,7 @@ import android.net.Uri; import org.json.JSONArray; import org.shadowice.flocke.andotp.Database.Entry; +import org.shadowice.flocke.andotp.R; import java.io.File; import java.util.ArrayList; @@ -65,7 +66,7 @@ public class DatabaseHelper { SecretKey key = KeyStoreHelper.loadOrGenerateWrappedKey(context, new File(context.getFilesDir() + "/" + KEY_FILE)); data = EncryptionHelper.decrypt(key, data); - entries = stringToEntries(new String(data)); + entries = stringToEntries(context, new String(data)); } catch (Exception error) { error.printStackTrace(); } @@ -89,14 +90,18 @@ public class DatabaseHelper { return json.toString(); } - public static ArrayList stringToEntries(String data) { + public static ArrayList stringToEntries(Context context, String data) { ArrayList entries = new ArrayList<>(); try { JSONArray json = new JSONArray(data); for (int i = 0; i < json.length(); i++) { - entries.add(new Entry(json.getJSONObject(i))); + Entry entry = new Entry(json.getJSONObject(i)); + + int size = context.getResources().getDimensionPixelSize(R.dimen.card_thumbnail_size); + entry.setThumbnailImage(new LetterBitmap(context).getLetterTile(entry.getLabel(), entry.getLabel(), size, size)); + entries.add(entry); } } catch (Exception error) { error.printStackTrace(); @@ -119,7 +124,7 @@ public class DatabaseHelper { ArrayList entries = null; if (! content.isEmpty()) - entries = stringToEntries(content); + entries = stringToEntries(context, content); return entries; } diff --git a/app/src/main/java/org/shadowice/flocke/andotp/Utilities/LetterBitmap.java b/app/src/main/java/org/shadowice/flocke/andotp/Utilities/LetterBitmap.java new file mode 100644 index 00000000..dadc2c9b --- /dev/null +++ b/app/src/main/java/org/shadowice/flocke/andotp/Utilities/LetterBitmap.java @@ -0,0 +1,133 @@ +package org.shadowice.flocke.andotp.Utilities; + +import android.content.Context; +import android.content.res.Resources; +import android.content.res.TypedArray; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.graphics.Canvas; +import android.graphics.Color; +import android.graphics.Paint; +import android.graphics.Rect; +import android.graphics.Typeface; +import android.text.TextPaint; + +import org.shadowice.flocke.andotp.R; + +/** + * Orginal http://stackoverflow.com/questions/23122088/colored-boxed-with-letters-a-la-gmail + * Used to create a {@link Bitmap} that contains a letter used in the English + * alphabet or digit, if there is no letter or digit available, a default image + * is shown instead. + * + * Only English language supported. + */ +public class LetterBitmap { + + /** + * The number of available tile colors + */ + private static final int NUM_OF_TILE_COLORS = 8; + + /** + * The {@link TextPaint} used to draw the letter onto the tile + */ + private final TextPaint mPaint = new TextPaint(); + /** + * The bounds that enclose the letter + */ + private final Rect mBounds = new Rect(); + /** + * The {@link Canvas} to draw on + */ + private final Canvas mCanvas = new Canvas(); + /** + * The first char of the name being displayed + */ + private final char[] mFirstChar = new char[1]; + + /** + * The background colors of the tile + */ + private final TypedArray mColors; + /** + * The font size used to display the letter + */ + private final int mTileLetterFontSize; + /** + * The default image to display + */ + private final Bitmap mDefaultBitmap; + + /** + * Constructor for LetterTileProvider + * + * @param context The {@link Context} to use + */ + public LetterBitmap(Context context) { + final Resources res = context.getResources(); + + mPaint.setTypeface(Typeface.create("sans-serif-light", Typeface.BOLD)); + mPaint.setColor(Color.WHITE); + mPaint.setTextAlign(Paint.Align.CENTER); + mPaint.setAntiAlias(true); + + mColors = res.obtainTypedArray(R.array.letter_tile_colors); + mTileLetterFontSize = res.getDimensionPixelSize(R.dimen.tile_letter_font_size); + + mDefaultBitmap = BitmapFactory.decodeResource(res, android.R.drawable.sym_def_app_icon); + } + + /** + * @param displayName The name used to create the letter for the tile + * @param key The key used to generate the background color for the tile + * @param width The desired width of the tile + * @param height The desired height of the tile + * @return A {@link Bitmap} that contains a letter used in the English + * alphabet or digit, if there is no letter or digit available, a + * default image is shown instead + */ + public Bitmap getLetterTile(String displayName, String key, int width, int height) { + final Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); + char firstChar = displayName.charAt(0); + + final Canvas c = mCanvas; + c.setBitmap(bitmap); + c.drawColor(pickColor(key)); + + if (!isEnglishLetterOrDigit(firstChar)) { + firstChar = 'A'; + } + mFirstChar[0] = Character.toUpperCase(firstChar); + mPaint.setTextSize(mTileLetterFontSize); + mPaint.getTextBounds(mFirstChar, 0, 1, mBounds); + c.drawText(mFirstChar, 0, 1, width / 2, height / 2 + + (mBounds.bottom - mBounds.top) / 2, mPaint); + return bitmap; + } + + /** + * @param c The char to check + * @return True if c is in the English alphabet or is a digit, + * false otherwise + */ + private static boolean isEnglishLetterOrDigit(char c) { + return 'A' <= c && c <= 'Z' || 'a' <= c && c <= 'z' || '0' <= c && c <= '9'; + } + + /** + * @param key The key used to generate the tile color + * @return A new or previously chosen color for key used as the + * tile background color + */ + private int pickColor(String key) { + // String.hashCode() is not supposed to change across java versions, so + // this should guarantee the same key always maps to the same color + final int color = Math.abs(key.hashCode()) % NUM_OF_TILE_COLORS; + try { + return mColors.getColor(color, Color.BLACK); + } finally { + mColors.recycle(); + } + } +} \ No newline at end of file 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 52b27a96..57cfff7f 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 @@ -44,6 +44,7 @@ import android.widget.Toast; import org.shadowice.flocke.andotp.Database.Entry; import org.shadowice.flocke.andotp.Utilities.DatabaseHelper; +import org.shadowice.flocke.andotp.Utilities.LetterBitmap; import org.shadowice.flocke.andotp.Utilities.Settings; import org.shadowice.flocke.andotp.Utilities.TagDialogHelper; import org.shadowice.flocke.andotp.View.ItemTouchHelper.ItemTouchHelperAdapter; @@ -153,7 +154,7 @@ public class EntriesCardAdapter extends RecyclerView.Adapter public void onBindViewHolder(EntryViewHolder entryViewHolder, int i) { Entry entry = displayedEntries.get(i); - entryViewHolder.updateValues(entry.getLabel(), entry.getCurrentOTP(), entry.getTags()); + entryViewHolder.updateValues(entry.getLabel(), entry.getCurrentOTP(), entry.getTags(), entry.getThumbnailImage()); if (entry.hasNonDefaultPeriod()) { entryViewHolder.showCustomPeriod(entry.getPeriod()); @@ -250,7 +251,12 @@ public class EntriesCardAdapter extends RecyclerView.Adapter notifyItemChanged(pos); } - entries.get(realIndex).setLabel(newLabel); + int size = context.getResources().getDimensionPixelSize(R.dimen.card_thumbnail_size); + + Entry e = entries.get(realIndex); + e.setLabel(newLabel); + e.setThumbnailImage(new LetterBitmap(context).getLetterTile(e.getLabel(), e.getLabel(), size, size)); + DatabaseHelper.saveDatabase(context, entries); } }) 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 9f9f4370..356966f4 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 @@ -23,6 +23,7 @@ package org.shadowice.flocke.andotp.View; import android.content.Context; +import android.graphics.Bitmap; import android.graphics.ColorFilter; import android.support.v7.widget.CardView; import android.support.v7.widget.RecyclerView; @@ -34,9 +35,10 @@ import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; +import org.shadowice.flocke.andotp.R; +import org.shadowice.flocke.andotp.Utilities.Settings; import org.shadowice.flocke.andotp.Utilities.Tools; import org.shadowice.flocke.andotp.View.ItemTouchHelper.ItemTouchHelperViewHolder; -import org.shadowice.flocke.andotp.R; import java.util.List; @@ -52,12 +54,12 @@ public class EntryViewHolder extends RecyclerView.ViewHolder private LinearLayout coverLayout; private LinearLayout customPeriodLayout; private ImageView visibleImg; + private ImageView thumbnailImg; private TextView value; private TextView label; private TextView tags; private TextView customPeriod; - public EntryViewHolder(Context context, final View v) { super(v); @@ -67,6 +69,7 @@ public class EntryViewHolder extends RecyclerView.ViewHolder value = v.findViewById(R.id.valueText); valueLayout = v.findViewById(R.id.valueLayout); visibleImg = v.findViewById(R.id.valueImg); + thumbnailImg = v.findViewById(R.id.thumbnailImg); coverLayout = v.findViewById(R.id.coverLayout); label = v.findViewById(R.id.textViewLabel); tags = v.findViewById(R.id.textViewTags); @@ -103,7 +106,9 @@ public class EntryViewHolder extends RecyclerView.ViewHolder }); } - public void updateValues(String label, String token, List tags) { + public void updateValues(String label, String token, List tags, Bitmap thumbnail) { + Settings settings = new Settings(context); + this.label.setText(label); value.setText(token); @@ -121,6 +126,9 @@ public class EntryViewHolder extends RecyclerView.ViewHolder } else { this.tags.setVisibility(View.GONE); } + + thumbnailImg.setVisibility(settings.getThumbnailVisible() ? View.VISIBLE : View.GONE); + thumbnailImg.setImageBitmap(thumbnail); } public void showCustomPeriod(int period) { diff --git a/app/src/main/res/values/settings.xml b/app/src/main/res/values/settings.xml index 97dc00fa..fc8b250a 100644 --- a/app/src/main/res/values/settings.xml +++ b/app/src/main/res/values/settings.xml @@ -39,6 +39,18 @@ light 8 + + + #f16364 + #f58559 + #f9a43e + #e4c62e + #67bf74 + #59a2be + #2093cd + #ad62a7 + + none From e8c71161bbd16fcf32530304111b6c56f4aa6126 Mon Sep 17 00:00:00 2001 From: RichyHBM Date: Sat, 25 Nov 2017 14:49:12 +0000 Subject: [PATCH 03/15] Create enum for holding images and returning a default image --- .../andotp/Activities/BackupActivity.java | 4 ++-- .../andotp/Activities/MainActivity.java | 6 ++--- .../flocke/andotp/Database/Entry.java | 11 +++++---- .../PasswordEncryptedPreference.java | 2 +- .../andotp/Utilities/DatabaseHelper.java | 3 ++- .../andotp/Utilities/EntryThumbnail.java | 23 +++++++++++++++++++ .../flocke/andotp/Utilities/LetterBitmap.java | 2 +- .../andotp/View/EntriesCardAdapter.java | 10 ++++---- 8 files changed, 43 insertions(+), 18 deletions(-) create mode 100644 app/src/main/java/org/shadowice/flocke/andotp/Utilities/EntryThumbnail.java diff --git a/app/src/main/java/org/shadowice/flocke/andotp/Activities/BackupActivity.java b/app/src/main/java/org/shadowice/flocke/andotp/Activities/BackupActivity.java index 24f23dbe..c4056b5f 100644 --- a/app/src/main/java/org/shadowice/flocke/andotp/Activities/BackupActivity.java +++ b/app/src/main/java/org/shadowice/flocke/andotp/Activities/BackupActivity.java @@ -49,11 +49,11 @@ import org.openintents.openpgp.OpenPgpSignatureResult; import org.openintents.openpgp.util.OpenPgpApi; import org.openintents.openpgp.util.OpenPgpServiceConnection; import org.shadowice.flocke.andotp.Database.Entry; -import org.shadowice.flocke.andotp.Utilities.FileHelper; +import org.shadowice.flocke.andotp.R; import org.shadowice.flocke.andotp.Utilities.DatabaseHelper; import org.shadowice.flocke.andotp.Utilities.EncryptionHelper; +import org.shadowice.flocke.andotp.Utilities.FileHelper; import org.shadowice.flocke.andotp.Utilities.Tools; -import org.shadowice.flocke.andotp.R; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; 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 eed57491..69a0bdc8 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 @@ -63,7 +63,7 @@ import com.google.zxing.integration.android.IntentResult; import org.shadowice.flocke.andotp.Database.Entry; import org.shadowice.flocke.andotp.R; import org.shadowice.flocke.andotp.Utilities.DatabaseHelper; -import org.shadowice.flocke.andotp.Utilities.LetterBitmap; +import org.shadowice.flocke.andotp.Utilities.EntryThumbnail; import org.shadowice.flocke.andotp.Utilities.Settings; import org.shadowice.flocke.andotp.Utilities.TagDialogHelper; import org.shadowice.flocke.andotp.Utilities.TokenCalculator; @@ -211,7 +211,7 @@ public class MainActivity extends BaseActivity Entry e = new Entry(type, secret, period, digits, label, algorithm, tagsAdapter.getActiveTags()); int size = getResources().getDimensionPixelSize(R.dimen.card_thumbnail_size); - e.setThumbnailImage(new LetterBitmap(MainActivity.this).getLetterTile(label, label, size, size)); + e.setThumbnailImage(EntryThumbnail.getThumbnailGraphic(MainActivity.this, label, size, e.getThumbnail())); e.updateOTP(); adapter.addEntry(e); @@ -461,7 +461,7 @@ public class MainActivity extends BaseActivity Entry e = new Entry(result.getContents()); int size = getResources().getDimensionPixelSize(R.dimen.card_thumbnail_size); - e.setThumbnailImage(new LetterBitmap(MainActivity.this).getLetterTile(e.getLabel(), e.getLabel(), size, size)); + e.setThumbnailImage(EntryThumbnail.getThumbnailGraphic(MainActivity.this, e.getLabel(), size, e.getThumbnail())); e.updateOTP(); adapter.addEntry(e); diff --git a/app/src/main/java/org/shadowice/flocke/andotp/Database/Entry.java b/app/src/main/java/org/shadowice/flocke/andotp/Database/Entry.java index 16b3c41d..a70a41b0 100644 --- a/app/src/main/java/org/shadowice/flocke/andotp/Database/Entry.java +++ b/app/src/main/java/org/shadowice/flocke/andotp/Database/Entry.java @@ -30,6 +30,7 @@ import org.apache.commons.codec.binary.Base32; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; +import org.shadowice.flocke.andotp.Utilities.EntryThumbnail; import org.shadowice.flocke.andotp.Utilities.TokenCalculator; import java.net.URL; @@ -64,7 +65,7 @@ public class Entry { private String currentOTP; private long last_update = 0; public List tags = new ArrayList<>(); - private int thumbnail = -1; + private EntryThumbnail.EntryThumbnails thumbnail = EntryThumbnail.EntryThumbnails.Default; private Bitmap thumbnailImage; public Entry(){} @@ -169,9 +170,9 @@ public class Entry { } try { - this.thumbnail = jsonObj.getInt(JSON_THUMBNAIL); + this.thumbnail = EntryThumbnail.EntryThumbnails.values()[jsonObj.getInt(JSON_THUMBNAIL)]; } catch(JSONException e) { - this.thumbnail = -1; + this.thumbnail = EntryThumbnail.EntryThumbnails.Default; } } @@ -183,7 +184,7 @@ public class Entry { jsonObj.put(JSON_DIGITS, getDigits()); jsonObj.put(JSON_TYPE, getType().toString()); jsonObj.put(JSON_ALGORITHM, algorithm.toString()); - jsonObj.put(JSON_THUMBNAIL, getThumbnail()); + jsonObj.put(JSON_THUMBNAIL, getThumbnail().ordinal()); JSONArray tagsArray = new JSONArray(); for(String tag : tags){ @@ -242,7 +243,7 @@ public class Entry { public void setThumbnailImage(Bitmap thumbnailImage) { this.thumbnailImage = thumbnailImage; } - public int getThumbnail() { return thumbnail; } + public EntryThumbnail.EntryThumbnails getThumbnail() { return thumbnail; } public TokenCalculator.HashAlgorithm getAlgorithm() { return this.algorithm; diff --git a/app/src/main/java/org/shadowice/flocke/andotp/Preferences/PasswordEncryptedPreference.java b/app/src/main/java/org/shadowice/flocke/andotp/Preferences/PasswordEncryptedPreference.java index e4a8fe0d..b03e5fe7 100644 --- a/app/src/main/java/org/shadowice/flocke/andotp/Preferences/PasswordEncryptedPreference.java +++ b/app/src/main/java/org/shadowice/flocke/andotp/Preferences/PasswordEncryptedPreference.java @@ -22,11 +22,11 @@ package org.shadowice.flocke.andotp.Preferences; +import android.app.AlertDialog; import android.content.Context; import android.content.res.TypedArray; import android.preference.DialogPreference; import android.support.design.widget.TextInputEditText; -import android.app.AlertDialog; import android.support.design.widget.TextInputLayout; import android.text.Editable; import android.text.InputType; diff --git a/app/src/main/java/org/shadowice/flocke/andotp/Utilities/DatabaseHelper.java b/app/src/main/java/org/shadowice/flocke/andotp/Utilities/DatabaseHelper.java index 9e3face8..f6913a6e 100644 --- a/app/src/main/java/org/shadowice/flocke/andotp/Utilities/DatabaseHelper.java +++ b/app/src/main/java/org/shadowice/flocke/andotp/Utilities/DatabaseHelper.java @@ -100,7 +100,8 @@ public class DatabaseHelper { Entry entry = new Entry(json.getJSONObject(i)); int size = context.getResources().getDimensionPixelSize(R.dimen.card_thumbnail_size); - entry.setThumbnailImage(new LetterBitmap(context).getLetterTile(entry.getLabel(), entry.getLabel(), size, size)); + entry.setThumbnailImage(EntryThumbnail.getThumbnailGraphic(context, entry.getLabel(), size, entry.getThumbnail())); + entries.add(entry); } } catch (Exception error) { 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 new file mode 100644 index 00000000..121d8461 --- /dev/null +++ b/app/src/main/java/org/shadowice/flocke/andotp/Utilities/EntryThumbnail.java @@ -0,0 +1,23 @@ +package org.shadowice.flocke.andotp.Utilities; + +import android.content.Context; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; + +import org.shadowice.flocke.andotp.R; + +public class EntryThumbnail { + public enum EntryThumbnails { + Default + } + + public static Bitmap getThumbnailGraphic(Context context, String label, int size, EntryThumbnails thumbnail) { + switch (thumbnail) { + case Default: + LetterBitmap letterBitmap = new LetterBitmap(context); + return letterBitmap.getLetterTile(label, label, size, size); + default: + return BitmapFactory.decodeResource(context.getResources(), R.mipmap.ic_launcher); + } + } +} diff --git a/app/src/main/java/org/shadowice/flocke/andotp/Utilities/LetterBitmap.java b/app/src/main/java/org/shadowice/flocke/andotp/Utilities/LetterBitmap.java index dadc2c9b..549b9ba9 100644 --- a/app/src/main/java/org/shadowice/flocke/andotp/Utilities/LetterBitmap.java +++ b/app/src/main/java/org/shadowice/flocke/andotp/Utilities/LetterBitmap.java @@ -22,7 +22,7 @@ import org.shadowice.flocke.andotp.R; * * Only English language supported. */ -public class LetterBitmap { +class LetterBitmap { /** * The number of available tile colors 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 57cfff7f..40e1c462 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 @@ -43,14 +43,12 @@ import android.widget.FrameLayout; import android.widget.Toast; import org.shadowice.flocke.andotp.Database.Entry; +import org.shadowice.flocke.andotp.R; import org.shadowice.flocke.andotp.Utilities.DatabaseHelper; -import org.shadowice.flocke.andotp.Utilities.LetterBitmap; +import org.shadowice.flocke.andotp.Utilities.EntryThumbnail; import org.shadowice.flocke.andotp.Utilities.Settings; import org.shadowice.flocke.andotp.Utilities.TagDialogHelper; import org.shadowice.flocke.andotp.View.ItemTouchHelper.ItemTouchHelperAdapter; -import org.shadowice.flocke.andotp.R; - -import static org.shadowice.flocke.andotp.Utilities.Settings.SortMode; import java.util.ArrayList; import java.util.Collections; @@ -60,6 +58,8 @@ import java.util.HashSet; import java.util.List; import java.util.concurrent.Callable; +import static org.shadowice.flocke.andotp.Utilities.Settings.SortMode; + public class EntriesCardAdapter extends RecyclerView.Adapter implements ItemTouchHelperAdapter, Filterable { private Context context; @@ -255,7 +255,7 @@ public class EntriesCardAdapter extends RecyclerView.Adapter Entry e = entries.get(realIndex); e.setLabel(newLabel); - e.setThumbnailImage(new LetterBitmap(context).getLetterTile(e.getLabel(), e.getLabel(), size, size)); + e.setThumbnailImage(EntryThumbnail.getThumbnailGraphic(context, e.getLabel(), size, e.getThumbnail())); DatabaseHelper.saveDatabase(context, entries); } From 8258b972e1bfa52a63a960f645e779165a0c7481 Mon Sep 17 00:00:00 2001 From: RichyHBM Date: Sat, 25 Nov 2017 18:57:06 +0000 Subject: [PATCH 04/15] Allow user to change image from list of images --- .../flocke/andotp/Database/Entry.java | 2 + .../andotp/Utilities/EntryThumbnail.java | 43 ++++++++++++--- .../andotp/View/EntriesCardAdapter.java | 54 +++++++++++++++++++ .../View/ThumbnailSelectionAdapter.java | 50 +++++++++++++++++ app/src/main/res/drawable/ic_github.xml | 4 ++ .../layout/component_thumbnail_selection.xml | 18 +++++++ app/src/main/res/menu/menu_popup.xml | 4 ++ app/src/main/res/values/strings_main.xml | 1 + 8 files changed, 169 insertions(+), 7 deletions(-) create mode 100644 app/src/main/java/org/shadowice/flocke/andotp/View/ThumbnailSelectionAdapter.java create mode 100644 app/src/main/res/drawable/ic_github.xml create mode 100644 app/src/main/res/layout/component_thumbnail_selection.xml diff --git a/app/src/main/java/org/shadowice/flocke/andotp/Database/Entry.java b/app/src/main/java/org/shadowice/flocke/andotp/Database/Entry.java index a70a41b0..0585c97b 100644 --- a/app/src/main/java/org/shadowice/flocke/andotp/Database/Entry.java +++ b/app/src/main/java/org/shadowice/flocke/andotp/Database/Entry.java @@ -245,6 +245,8 @@ public class Entry { public EntryThumbnail.EntryThumbnails getThumbnail() { return thumbnail; } + public void setThumbnail( EntryThumbnail.EntryThumbnails value) { thumbnail = value; } + public TokenCalculator.HashAlgorithm getAlgorithm() { return this.algorithm; } 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 121d8461..7853bc25 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 @@ -3,21 +3,50 @@ package org.shadowice.flocke.andotp.Utilities; import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; +import android.graphics.Canvas; +import android.graphics.drawable.Drawable; +import android.graphics.drawable.PictureDrawable; + +import com.larvalabs.svgandroid.SVG; +import com.larvalabs.svgandroid.SVGBuilder; import org.shadowice.flocke.andotp.R; +import java.io.IOException; + public class EntryThumbnail { public enum EntryThumbnails { - Default + Default(R.mipmap.ic_launcher_round), + Github(R.drawable.ic_github); + + private int resource; + + EntryThumbnails(int resource) { + this.resource = resource; + } + + public int getResource() { + return resource; + } } public static Bitmap getThumbnailGraphic(Context context, String label, int size, EntryThumbnails thumbnail) { - switch (thumbnail) { - case Default: - LetterBitmap letterBitmap = new LetterBitmap(context); - return letterBitmap.getLetterTile(label, label, size, size); - default: - return BitmapFactory.decodeResource(context.getResources(), R.mipmap.ic_launcher); + if(thumbnail == EntryThumbnails.Default) { + LetterBitmap letterBitmap = new LetterBitmap(context); + return letterBitmap.getLetterTile(label, label, size, size); } + + try { + Drawable drawable = context.getResources().getDrawable(thumbnail.getResource()); + Bitmap bitmap = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888); + Canvas canvas = new Canvas(bitmap); + drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight()); + drawable.draw(canvas); + return bitmap; + } 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/View/EntriesCardAdapter.java b/app/src/main/java/org/shadowice/flocke/andotp/View/EntriesCardAdapter.java index 40e1c462..5fa9bed2 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 @@ -28,6 +28,7 @@ import android.content.ClipboardManager; import android.content.Context; import android.content.DialogInterface; import android.content.SharedPreferences; +import android.graphics.Bitmap; import android.preference.PreferenceManager; import android.support.v7.widget.PopupMenu; import android.support.v7.widget.RecyclerView; @@ -36,10 +37,15 @@ import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; +import android.widget.AdapterView; +import android.widget.ArrayAdapter; import android.widget.EditText; import android.widget.Filter; import android.widget.Filterable; import android.widget.FrameLayout; +import android.widget.LinearLayout; +import android.widget.ListView; +import android.widget.TextView; import android.widget.Toast; import org.shadowice.flocke.andotp.Database.Entry; @@ -268,6 +274,51 @@ public class EntriesCardAdapter extends RecyclerView.Adapter .show(); } + public void changeThumbnail(final int pos) { + AlertDialog.Builder builder = new AlertDialog.Builder(context); + + int marginSmall = context.getResources().getDimensionPixelSize(R.dimen.activity_margin_small); + int marginMedium = context.getResources().getDimensionPixelSize(R.dimen.activity_margin_medium); + + ListView list = new ListView(context); + list.setAdapter(new ThumbnailSelectionAdapter(context)); + list.setDividerHeight(0); + + list.setOnItemClickListener(new AdapterView.OnItemClickListener() { + @Override + public void onItemClick(AdapterView parent, View view, int position, long id) { + int realIndex = getRealIndex(pos); + TextView v = (TextView) view.findViewById(R.id.thumbnail_selection_text); + EntryThumbnail.EntryThumbnails thumbnail = EntryThumbnail.EntryThumbnails.Default; + try { + thumbnail = EntryThumbnail.EntryThumbnails.valueOf(v.getText().toString()); + } catch (Exception e) { + e.printStackTrace(); + } + + int size = context.getResources().getDimensionPixelSize(R.dimen.card_thumbnail_size); + Entry e = entries.get(realIndex); + e.setThumbnailImage(EntryThumbnail.getThumbnailGraphic(context, e.getLabel(), size, thumbnail)); + DatabaseHelper.saveDatabase(context, entries); + notifyItemChanged(pos); + } + }); + + FrameLayout container = new FrameLayout(context); + container.setPaddingRelative(marginMedium, marginSmall, marginMedium, 0); + container.addView(list); + + builder.setTitle(R.string.menu_popup_change_image) + .setView(container) + .setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) {} + }) + .create() + .show(); + } + + public void editEntryTags(final int pos) { final int realPos = getRealIndex(pos); final Entry entry = entries.get(realPos); @@ -352,6 +403,9 @@ public class EntriesCardAdapter extends RecyclerView.Adapter if (id == R.id.menu_popup_editLabel) { editEntryLabel(pos); return true; + } else if(id == R.id.menu_popup_changeImage) { + changeThumbnail(pos); + return true; } else if (id == R.id.menu_popup_editTags) { editEntryTags(pos); return true; diff --git a/app/src/main/java/org/shadowice/flocke/andotp/View/ThumbnailSelectionAdapter.java b/app/src/main/java/org/shadowice/flocke/andotp/View/ThumbnailSelectionAdapter.java new file mode 100644 index 00000000..2c975a8b --- /dev/null +++ b/app/src/main/java/org/shadowice/flocke/andotp/View/ThumbnailSelectionAdapter.java @@ -0,0 +1,50 @@ +package org.shadowice.flocke.andotp.View; + +import android.content.Context; +import android.support.annotation.NonNull; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ArrayAdapter; +import android.widget.ImageView; +import android.widget.TextView; + +import org.shadowice.flocke.andotp.R; +import org.shadowice.flocke.andotp.Utilities.EntryThumbnail; + +import java.util.ArrayList; + +public class ThumbnailSelectionAdapter extends ArrayAdapter { + private Context context; + + public ThumbnailSelectionAdapter(Context context) { + super(context, R.layout.component_thumbnail_selection, new ArrayList()); + this.context = context; + + for (EntryThumbnail.EntryThumbnails thumb : EntryThumbnail.EntryThumbnails.values()) { + add(thumb); + } + } + + @NonNull + @Override + public View getView(int i, View view, @NonNull ViewGroup viewGroup) { + View newView; + if (view == null) { + newView = LayoutInflater.from(context).inflate(R.layout.component_thumbnail_selection , viewGroup, false); + } else{ + newView = view; + } + + ImageView imageView = (ImageView) newView.findViewById(R.id.thumbnail_selection_icon); + TextView textView = (TextView) newView.findViewById(R.id.thumbnail_selection_text); + + EntryThumbnail.EntryThumbnails thumb = getItem(i); + + int size = context.getResources().getDimensionPixelSize(R.dimen.card_thumbnail_size); + imageView.setImageBitmap(EntryThumbnail.getThumbnailGraphic(context, thumb.name(), size, thumb)); + textView.setText(thumb.name()); + + return newView; + } +} diff --git a/app/src/main/res/drawable/ic_github.xml b/app/src/main/res/drawable/ic_github.xml new file mode 100644 index 00000000..c409fa1f --- /dev/null +++ b/app/src/main/res/drawable/ic_github.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/layout/component_thumbnail_selection.xml b/app/src/main/res/layout/component_thumbnail_selection.xml new file mode 100644 index 00000000..2ef3faf6 --- /dev/null +++ b/app/src/main/res/layout/component_thumbnail_selection.xml @@ -0,0 +1,18 @@ + + + + + + + + + diff --git a/app/src/main/res/menu/menu_popup.xml b/app/src/main/res/menu/menu_popup.xml index 8191c189..6293c3b6 100644 --- a/app/src/main/res/menu/menu_popup.xml +++ b/app/src/main/res/menu/menu_popup.xml @@ -5,6 +5,10 @@ android:id="@+id/menu_popup_editLabel" android:title="@string/menu_popup_edit_label" /> + + diff --git a/app/src/main/res/values/strings_main.xml b/app/src/main/res/values/strings_main.xml index dd40662c..d7ff70e0 100644 --- a/app/src/main/res/values/strings_main.xml +++ b/app/src/main/res/values/strings_main.xml @@ -44,6 +44,7 @@ Label Edit label + Change image Edit tags Remove From 91db03bc473e92623128a6fe67ee16e711851941 Mon Sep 17 00:00:00 2001 From: RichyHBM Date: Sun, 26 Nov 2017 11:50:44 +0000 Subject: [PATCH 05/15] Remove bitmap from entry class --- .../andotp/Activities/MainActivity.java | 8 --- .../flocke/andotp/Database/Entry.java | 5 -- .../andotp/Utilities/DatabaseHelper.java | 4 -- .../andotp/Utilities/EntryThumbnail.java | 10 +--- .../andotp/View/EntriesCardAdapter.java | 50 +++++++++++-------- .../flocke/andotp/View/EntryViewHolder.java | 7 ++- .../View/ThumbnailSelectionAdapter.java | 47 ++++++++++------- app/src/main/res/drawable/ic_github.xml | 11 ++-- app/src/main/res/layout/component_card.xml | 2 +- .../layout/component_thumbnail_selection.xml | 18 ------- 10 files changed, 74 insertions(+), 88 deletions(-) delete mode 100644 app/src/main/res/layout/component_thumbnail_selection.xml 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 69a0bdc8..08bcc610 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 @@ -209,10 +209,6 @@ public class MainActivity extends BaseActivity int digits = Integer.parseInt(digitsInput.getText().toString()); Entry e = new Entry(type, secret, period, digits, label, algorithm, tagsAdapter.getActiveTags()); - - int size = getResources().getDimensionPixelSize(R.dimen.card_thumbnail_size); - e.setThumbnailImage(EntryThumbnail.getThumbnailGraphic(MainActivity.this, label, size, e.getThumbnail())); - e.updateOTP(); adapter.addEntry(e); adapter.saveEntries(); @@ -459,10 +455,6 @@ public class MainActivity extends BaseActivity if(result.getContents() != null) { try { Entry e = new Entry(result.getContents()); - - int size = getResources().getDimensionPixelSize(R.dimen.card_thumbnail_size); - e.setThumbnailImage(EntryThumbnail.getThumbnailGraphic(MainActivity.this, e.getLabel(), size, e.getThumbnail())); - e.updateOTP(); adapter.addEntry(e); adapter.saveEntries(); diff --git a/app/src/main/java/org/shadowice/flocke/andotp/Database/Entry.java b/app/src/main/java/org/shadowice/flocke/andotp/Database/Entry.java index 0585c97b..e9cea5bc 100644 --- a/app/src/main/java/org/shadowice/flocke/andotp/Database/Entry.java +++ b/app/src/main/java/org/shadowice/flocke/andotp/Database/Entry.java @@ -66,7 +66,6 @@ public class Entry { private long last_update = 0; public List tags = new ArrayList<>(); private EntryThumbnail.EntryThumbnails thumbnail = EntryThumbnail.EntryThumbnails.Default; - private Bitmap thumbnailImage; public Entry(){} @@ -239,10 +238,6 @@ public class Entry { public void setTags(List tags) { this.tags = tags; } - public Bitmap getThumbnailImage() { return thumbnailImage; } - - public void setThumbnailImage(Bitmap thumbnailImage) { this.thumbnailImage = thumbnailImage; } - public EntryThumbnail.EntryThumbnails getThumbnail() { return thumbnail; } public void setThumbnail( EntryThumbnail.EntryThumbnails value) { thumbnail = value; } diff --git a/app/src/main/java/org/shadowice/flocke/andotp/Utilities/DatabaseHelper.java b/app/src/main/java/org/shadowice/flocke/andotp/Utilities/DatabaseHelper.java index f6913a6e..9d14c2c4 100644 --- a/app/src/main/java/org/shadowice/flocke/andotp/Utilities/DatabaseHelper.java +++ b/app/src/main/java/org/shadowice/flocke/andotp/Utilities/DatabaseHelper.java @@ -98,10 +98,6 @@ public class DatabaseHelper { for (int i = 0; i < json.length(); i++) { Entry entry = new Entry(json.getJSONObject(i)); - - int size = context.getResources().getDimensionPixelSize(R.dimen.card_thumbnail_size); - entry.setThumbnailImage(EntryThumbnail.getThumbnailGraphic(context, entry.getLabel(), size, entry.getThumbnail())); - entries.add(entry); } } catch (Exception error) { 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 7853bc25..b650d88a 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 @@ -5,15 +5,9 @@ import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.drawable.Drawable; -import android.graphics.drawable.PictureDrawable; - -import com.larvalabs.svgandroid.SVG; -import com.larvalabs.svgandroid.SVGBuilder; import org.shadowice.flocke.andotp.R; -import java.io.IOException; - public class EntryThumbnail { public enum EntryThumbnails { Default(R.mipmap.ic_launcher_round), @@ -38,9 +32,9 @@ public class EntryThumbnail { try { Drawable drawable = context.getResources().getDrawable(thumbnail.getResource()); - Bitmap bitmap = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888); + Bitmap bitmap = Bitmap.createBitmap(drawable.getMinimumWidth(), drawable.getMinimumHeight(), Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); - drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight()); + drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); drawable.draw(canvas); return bitmap; } catch(Exception e) { 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 5fa9bed2..6abdc6cc 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 @@ -37,12 +37,14 @@ import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; +import android.widget.AbsListView; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.EditText; import android.widget.Filter; import android.widget.Filterable; import android.widget.FrameLayout; +import android.widget.GridView; import android.widget.LinearLayout; import android.widget.ListView; import android.widget.TextView; @@ -160,7 +162,7 @@ public class EntriesCardAdapter extends RecyclerView.Adapter public void onBindViewHolder(EntryViewHolder entryViewHolder, int i) { Entry entry = displayedEntries.get(i); - entryViewHolder.updateValues(entry.getLabel(), entry.getCurrentOTP(), entry.getTags(), entry.getThumbnailImage()); + entryViewHolder.updateValues(entry.getLabel(), entry.getCurrentOTP(), entry.getTags(), entry.getThumbnail()); if (entry.hasNonDefaultPeriod()) { entryViewHolder.showCustomPeriod(entry.getPeriod()); @@ -261,7 +263,6 @@ public class EntriesCardAdapter extends RecyclerView.Adapter Entry e = entries.get(realIndex); e.setLabel(newLabel); - e.setThumbnailImage(EntryThumbnail.getThumbnailGraphic(context, e.getLabel(), size, e.getThumbnail())); DatabaseHelper.saveDatabase(context, entries); } @@ -280,42 +281,49 @@ public class EntriesCardAdapter extends RecyclerView.Adapter int marginSmall = context.getResources().getDimensionPixelSize(R.dimen.activity_margin_small); int marginMedium = context.getResources().getDimensionPixelSize(R.dimen.activity_margin_medium); - ListView list = new ListView(context); - list.setAdapter(new ThumbnailSelectionAdapter(context)); - list.setDividerHeight(0); + GridView grid = new GridView(context); + grid.setAdapter(new ThumbnailSelectionAdapter(context)); + grid.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); + grid.setColumnWidth(context.getResources().getDimensionPixelSize(R.dimen.card_thumbnail_size)); + grid.setNumColumns(GridView.AUTO_FIT); + grid.setVerticalSpacing(context.getResources().getDimensionPixelSize(R.dimen.activity_margin_medium)); + grid.setHorizontalSpacing(context.getResources().getDimensionPixelSize(R.dimen.activity_margin_medium)); + grid.setStretchMode(GridView.STRETCH_COLUMN_WIDTH); - list.setOnItemClickListener(new AdapterView.OnItemClickListener() { + FrameLayout container = new FrameLayout(context); + container.setPaddingRelative(marginMedium, marginSmall, marginMedium, 0); + container.addView(grid); + + final AlertDialog alert = builder.setTitle(R.string.menu_popup_change_image) + .setView(container) + .setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) {} + }) + .create(); + + grid.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView parent, View view, int position, long id) { int realIndex = getRealIndex(pos); - TextView v = (TextView) view.findViewById(R.id.thumbnail_selection_text); EntryThumbnail.EntryThumbnails thumbnail = EntryThumbnail.EntryThumbnails.Default; try { - thumbnail = EntryThumbnail.EntryThumbnails.valueOf(v.getText().toString()); + thumbnail = EntryThumbnail.EntryThumbnails.values()[position]; } catch (Exception e) { e.printStackTrace(); } int size = context.getResources().getDimensionPixelSize(R.dimen.card_thumbnail_size); Entry e = entries.get(realIndex); - e.setThumbnailImage(EntryThumbnail.getThumbnailGraphic(context, e.getLabel(), size, thumbnail)); + e.setThumbnail(thumbnail); + DatabaseHelper.saveDatabase(context, entries); notifyItemChanged(pos); + alert.cancel(); } }); - FrameLayout container = new FrameLayout(context); - container.setPaddingRelative(marginMedium, marginSmall, marginMedium, 0); - container.addView(list); - - builder.setTitle(R.string.menu_popup_change_image) - .setView(container) - .setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialogInterface, int i) {} - }) - .create() - .show(); + alert.show(); } 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 356966f4..40977a34 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 @@ -36,6 +36,7 @@ import android.widget.LinearLayout; import android.widget.TextView; import org.shadowice.flocke.andotp.R; +import org.shadowice.flocke.andotp.Utilities.EntryThumbnail; import org.shadowice.flocke.andotp.Utilities.Settings; import org.shadowice.flocke.andotp.Utilities.Tools; import org.shadowice.flocke.andotp.View.ItemTouchHelper.ItemTouchHelperViewHolder; @@ -106,7 +107,7 @@ public class EntryViewHolder extends RecyclerView.ViewHolder }); } - public void updateValues(String label, String token, List tags, Bitmap thumbnail) { + public void updateValues(String label, String token, List tags, EntryThumbnail.EntryThumbnails thumbnail) { Settings settings = new Settings(context); this.label.setText(label); @@ -128,7 +129,9 @@ public class EntryViewHolder extends RecyclerView.ViewHolder } thumbnailImg.setVisibility(settings.getThumbnailVisible() ? View.VISIBLE : View.GONE); - thumbnailImg.setImageBitmap(thumbnail); + + int size = context.getResources().getDimensionPixelSize(R.dimen.card_thumbnail_size); + thumbnailImg.setImageBitmap(EntryThumbnail.getThumbnailGraphic(context, label, size, thumbnail)); } public void showCustomPeriod(int period) { diff --git a/app/src/main/java/org/shadowice/flocke/andotp/View/ThumbnailSelectionAdapter.java b/app/src/main/java/org/shadowice/flocke/andotp/View/ThumbnailSelectionAdapter.java index 2c975a8b..06bb304c 100644 --- a/app/src/main/java/org/shadowice/flocke/andotp/View/ThumbnailSelectionAdapter.java +++ b/app/src/main/java/org/shadowice/flocke/andotp/View/ThumbnailSelectionAdapter.java @@ -6,6 +6,8 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; +import android.widget.BaseAdapter; +import android.widget.GridView; import android.widget.ImageView; import android.widget.TextView; @@ -14,37 +16,46 @@ import org.shadowice.flocke.andotp.Utilities.EntryThumbnail; import java.util.ArrayList; -public class ThumbnailSelectionAdapter extends ArrayAdapter { +public class ThumbnailSelectionAdapter extends BaseAdapter { private Context context; - public ThumbnailSelectionAdapter(Context context) { - super(context, R.layout.component_thumbnail_selection, new ArrayList()); + ThumbnailSelectionAdapter(Context context) { this.context = context; + } - for (EntryThumbnail.EntryThumbnails thumb : EntryThumbnail.EntryThumbnails.values()) { - add(thumb); - } + @Override + public int getCount() { + return EntryThumbnail.EntryThumbnails.values().length; + } + + @Override + public Object getItem(int i) { + if(i >= EntryThumbnail.EntryThumbnails.values().length) + return EntryThumbnail.EntryThumbnails.Default; + else + return EntryThumbnail.EntryThumbnails.values()[i]; + } + + @Override + public long getItemId(int i) { + return EntryThumbnail.EntryThumbnails.values()[i].ordinal(); } @NonNull @Override public View getView(int i, View view, @NonNull ViewGroup viewGroup) { - View newView; + int size = context.getResources().getDimensionPixelSize(R.dimen.card_thumbnail_size); + ImageView imageView; if (view == null) { - newView = LayoutInflater.from(context).inflate(R.layout.component_thumbnail_selection , viewGroup, false); - } else{ - newView = view; + imageView = new ImageView(context); + imageView.setLayoutParams(new GridView.LayoutParams(size, size)); + } else { + imageView = (ImageView) view; } - ImageView imageView = (ImageView) newView.findViewById(R.id.thumbnail_selection_icon); - TextView textView = (TextView) newView.findViewById(R.id.thumbnail_selection_text); + EntryThumbnail.EntryThumbnails thumb = (EntryThumbnail.EntryThumbnails)getItem(i); - EntryThumbnail.EntryThumbnails thumb = getItem(i); - - int size = context.getResources().getDimensionPixelSize(R.dimen.card_thumbnail_size); imageView.setImageBitmap(EntryThumbnail.getThumbnailGraphic(context, thumb.name(), size, thumb)); - textView.setText(thumb.name()); - - return newView; + return imageView; } } diff --git a/app/src/main/res/drawable/ic_github.xml b/app/src/main/res/drawable/ic_github.xml index c409fa1f..3b739907 100644 --- a/app/src/main/res/drawable/ic_github.xml +++ b/app/src/main/res/drawable/ic_github.xml @@ -1,4 +1,9 @@ - - + + diff --git a/app/src/main/res/layout/component_card.xml b/app/src/main/res/layout/component_card.xml index ee9891dc..7cb8e33e 100644 --- a/app/src/main/res/layout/component_card.xml +++ b/app/src/main/res/layout/component_card.xml @@ -17,7 +17,7 @@ android:id="@+id/thumbnailImg" android:layout_width="@dimen/card_thumbnail_size" android:layout_height="@dimen/card_thumbnail_size" - android:layout_marginEnd="@dimen/activity_margin_small" + android:layout_marginEnd="@dimen/activity_margin" android:src="@mipmap/ic_launcher"/> - - - - - - - - From 85f1a86b5ddf78d3a2a8c8245448c8724355d77c Mon Sep 17 00:00:00 2001 From: RichyHBM Date: Sun, 26 Nov 2017 15:34:54 +0000 Subject: [PATCH 06/15] Let user search for image --- .../andotp/View/EntriesCardAdapter.java | 34 +++++++++++++++++-- .../View/ThumbnailSelectionAdapter.java | 28 +++++++++++---- app/src/main/res/values/dimens.xml | 1 + 3 files changed, 54 insertions(+), 9 deletions(-) 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 6abdc6cc..b894e9c7 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 @@ -32,6 +32,9 @@ import android.graphics.Bitmap; import android.preference.PreferenceManager; import android.support.v7.widget.PopupMenu; import android.support.v7.widget.RecyclerView; +import android.text.Editable; +import android.text.TextWatcher; +import android.util.Log; import android.view.LayoutInflater; import android.view.MenuInflater; import android.view.MenuItem; @@ -281,18 +284,43 @@ public class EntriesCardAdapter extends RecyclerView.Adapter int marginSmall = context.getResources().getDimensionPixelSize(R.dimen.activity_margin_small); int marginMedium = context.getResources().getDimensionPixelSize(R.dimen.activity_margin_medium); + final ThumbnailSelectionAdapter thumbnailAdapter = new ThumbnailSelectionAdapter(context); + + final EditText input = new EditText(context); + input.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); + input.setSingleLine(); + + input.addTextChangedListener(new TextWatcher() { + @Override + public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {} + + @Override + public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {} + + @Override + public void afterTextChanged(Editable editable) { + thumbnailAdapter.filter(editable.toString()); + } + }); + GridView grid = new GridView(context); - grid.setAdapter(new ThumbnailSelectionAdapter(context)); + grid.setAdapter(thumbnailAdapter); grid.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); - grid.setColumnWidth(context.getResources().getDimensionPixelSize(R.dimen.card_thumbnail_size)); + grid.setColumnWidth(context.getResources().getDimensionPixelSize(R.dimen.card_thumbnail_size_small)); grid.setNumColumns(GridView.AUTO_FIT); grid.setVerticalSpacing(context.getResources().getDimensionPixelSize(R.dimen.activity_margin_medium)); grid.setHorizontalSpacing(context.getResources().getDimensionPixelSize(R.dimen.activity_margin_medium)); grid.setStretchMode(GridView.STRETCH_COLUMN_WIDTH); + LinearLayout layout = new LinearLayout(context); + layout.setOrientation(LinearLayout.VERTICAL); + layout.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); + layout.addView(input); + layout.addView(grid); + FrameLayout container = new FrameLayout(context); container.setPaddingRelative(marginMedium, marginSmall, marginMedium, 0); - container.addView(grid); + container.addView(layout); final AlertDialog alert = builder.setTitle(R.string.menu_popup_change_image) .setView(container) diff --git a/app/src/main/java/org/shadowice/flocke/andotp/View/ThumbnailSelectionAdapter.java b/app/src/main/java/org/shadowice/flocke/andotp/View/ThumbnailSelectionAdapter.java index 06bb304c..75f8fc0a 100644 --- a/app/src/main/java/org/shadowice/flocke/andotp/View/ThumbnailSelectionAdapter.java +++ b/app/src/main/java/org/shadowice/flocke/andotp/View/ThumbnailSelectionAdapter.java @@ -15,36 +15,52 @@ import org.shadowice.flocke.andotp.R; import org.shadowice.flocke.andotp.Utilities.EntryThumbnail; import java.util.ArrayList; +import java.util.Collections; +import java.util.List; public class ThumbnailSelectionAdapter extends BaseAdapter { private Context context; + private List items; ThumbnailSelectionAdapter(Context context) { + items = new ArrayList(EntryThumbnail.EntryThumbnails.values().length); + Collections.addAll(items, EntryThumbnail.EntryThumbnails.values()); + this.context = context; } + void filter(String filter) { + items.clear(); + for (EntryThumbnail.EntryThumbnails thumb : EntryThumbnail.EntryThumbnails.values()) { + if(thumb.name().toLowerCase().contains(filter.toLowerCase())) { + items.add(thumb); + } + } + notifyDataSetChanged(); + } + @Override public int getCount() { - return EntryThumbnail.EntryThumbnails.values().length; + return items.size(); } @Override public Object getItem(int i) { - if(i >= EntryThumbnail.EntryThumbnails.values().length) - return EntryThumbnail.EntryThumbnails.Default; + if(i < getCount()) + return items.get(i); else - return EntryThumbnail.EntryThumbnails.values()[i]; + return EntryThumbnail.EntryThumbnails.Default; } @Override public long getItemId(int i) { - return EntryThumbnail.EntryThumbnails.values()[i].ordinal(); + return ((EntryThumbnail.EntryThumbnails) getItem(i)).ordinal(); } @NonNull @Override public View getView(int i, View view, @NonNull ViewGroup viewGroup) { - int size = context.getResources().getDimensionPixelSize(R.dimen.card_thumbnail_size); + int size = context.getResources().getDimensionPixelSize(R.dimen.card_thumbnail_size_small); ImageView imageView; if (view == null) { imageView = new ImageView(context); diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index edcf801c..985951d0 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -10,6 +10,7 @@ 0dp 64dp + 46dp 33sp From df3ff7536c41dc6da2b08139e643b6620c0c1e84 Mon Sep 17 00:00:00 2001 From: RichyHBM Date: Mon, 27 Nov 2017 20:54:08 +0000 Subject: [PATCH 07/15] Allow bitmap thumbnails --- .../flocke/andotp/Database/Entry.java | 14 ++++---- .../andotp/Utilities/EntryThumbnail.java | 33 +++++++++++++++---- .../andotp/View/EntriesCardAdapter.java | 5 +-- .../flocke/andotp/View/EntryViewHolder.java | 6 ++++ .../View/ThumbnailSelectionAdapter.java | 9 ++--- 5 files changed, 47 insertions(+), 20 deletions(-) diff --git a/app/src/main/java/org/shadowice/flocke/andotp/Database/Entry.java b/app/src/main/java/org/shadowice/flocke/andotp/Database/Entry.java index e9cea5bc..16b4f613 100644 --- a/app/src/main/java/org/shadowice/flocke/andotp/Database/Entry.java +++ b/app/src/main/java/org/shadowice/flocke/andotp/Database/Entry.java @@ -142,19 +142,19 @@ public class Entry { try { this.digits = jsonObj.getInt(JSON_DIGITS); - } catch(JSONException e) { + } catch(Exception e) { this.digits = TokenCalculator.TOTP_DEFAULT_DIGITS; } try { this.type = OTPType.valueOf(jsonObj.getString(JSON_TYPE)); - } catch(JSONException e) { + } catch(Exception e) { this.type = DEFAULT_TYPE; } try { this.algorithm = TokenCalculator.HashAlgorithm.valueOf(jsonObj.getString(JSON_ALGORITHM)); - } catch (JSONException e) { + } catch (Exception e) { this.algorithm = TokenCalculator.DEFAULT_ALGORITHM; } @@ -164,13 +164,13 @@ public class Entry { for(int i = 0; i < tagsArray.length(); i++) { this.tags.add(tagsArray.getString(i)); } - } catch (JSONException e) { + } catch (Exception e) { e.printStackTrace(); } try { - this.thumbnail = EntryThumbnail.EntryThumbnails.values()[jsonObj.getInt(JSON_THUMBNAIL)]; - } catch(JSONException e) { + this.thumbnail = EntryThumbnail.EntryThumbnails.valueOf(jsonObj.getString(JSON_THUMBNAIL)); + } catch(Exception e) { this.thumbnail = EntryThumbnail.EntryThumbnails.Default; } } @@ -183,7 +183,7 @@ public class Entry { jsonObj.put(JSON_DIGITS, getDigits()); jsonObj.put(JSON_TYPE, getType().toString()); jsonObj.put(JSON_ALGORITHM, algorithm.toString()); - jsonObj.put(JSON_THUMBNAIL, getThumbnail().ordinal()); + jsonObj.put(JSON_THUMBNAIL, getThumbnail().name()); JSONArray tagsArray = new JSONArray(); for(String tag : tags){ 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 b650d88a..c7ba0965 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 @@ -9,19 +9,34 @@ import android.graphics.drawable.Drawable; import org.shadowice.flocke.andotp.R; public class EntryThumbnail { + private enum AssetType { + Bitmap, + Vector + } + public enum EntryThumbnails { Default(R.mipmap.ic_launcher_round), Github(R.drawable.ic_github); private int resource; + private AssetType assetType; EntryThumbnails(int resource) { this.resource = resource; + this.assetType = AssetType.Vector; + } + + EntryThumbnails(int resource, AssetType assetType) { + this.resource = resource; + this.assetType = assetType; } public int getResource() { return resource; } + public AssetType getAssetType() { + return assetType; + } } public static Bitmap getThumbnailGraphic(Context context, String label, int size, EntryThumbnails thumbnail) { @@ -31,13 +46,17 @@ public class EntryThumbnail { } try { - 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; - } catch(Exception e) { + 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(); } 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 b894e9c7..e5def43c 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 @@ -284,7 +284,8 @@ public class EntriesCardAdapter extends RecyclerView.Adapter int marginSmall = context.getResources().getDimensionPixelSize(R.dimen.activity_margin_small); int marginMedium = context.getResources().getDimensionPixelSize(R.dimen.activity_margin_medium); - final ThumbnailSelectionAdapter thumbnailAdapter = new ThumbnailSelectionAdapter(context); + int realIndex = getRealIndex(pos); + final ThumbnailSelectionAdapter thumbnailAdapter = new ThumbnailSelectionAdapter(context, entries.get(realIndex).getLabel()); final EditText input = new EditText(context); input.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); @@ -306,7 +307,7 @@ public class EntriesCardAdapter extends RecyclerView.Adapter GridView grid = new GridView(context); grid.setAdapter(thumbnailAdapter); grid.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); - grid.setColumnWidth(context.getResources().getDimensionPixelSize(R.dimen.card_thumbnail_size_small)); + grid.setColumnWidth(context.getResources().getDimensionPixelSize(R.dimen.card_thumbnail_size)); grid.setNumColumns(GridView.AUTO_FIT); grid.setVerticalSpacing(context.getResources().getDimensionPixelSize(R.dimen.activity_margin_medium)); grid.setHorizontalSpacing(context.getResources().getDimensionPixelSize(R.dimen.activity_margin_medium)); 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 40977a34..ed83913c 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 @@ -148,6 +148,12 @@ public class EntryViewHolder extends RecyclerView.ViewHolder tags.setTextSize(TypedValue.COMPLEX_UNIT_PT, size - 2); } + public void setThumbnailSize(int size) { + thumbnailImg.getLayoutParams().height = size; + thumbnailImg.getLayoutParams().width = size; + thumbnailImg.requestLayout(); + } + public void setLabelScroll(boolean active) { if (active) { label.setEllipsize(TextUtils.TruncateAt.MARQUEE); diff --git a/app/src/main/java/org/shadowice/flocke/andotp/View/ThumbnailSelectionAdapter.java b/app/src/main/java/org/shadowice/flocke/andotp/View/ThumbnailSelectionAdapter.java index 75f8fc0a..7dc8ee15 100644 --- a/app/src/main/java/org/shadowice/flocke/andotp/View/ThumbnailSelectionAdapter.java +++ b/app/src/main/java/org/shadowice/flocke/andotp/View/ThumbnailSelectionAdapter.java @@ -21,11 +21,12 @@ import java.util.List; public class ThumbnailSelectionAdapter extends BaseAdapter { private Context context; private List items; + private String label = "Example"; - ThumbnailSelectionAdapter(Context context) { + ThumbnailSelectionAdapter(Context context, String label) { items = new ArrayList(EntryThumbnail.EntryThumbnails.values().length); Collections.addAll(items, EntryThumbnail.EntryThumbnails.values()); - + this.label = label; this.context = context; } @@ -60,7 +61,7 @@ public class ThumbnailSelectionAdapter extends BaseAdapter { @NonNull @Override public View getView(int i, View view, @NonNull ViewGroup viewGroup) { - int size = context.getResources().getDimensionPixelSize(R.dimen.card_thumbnail_size_small); + int size = context.getResources().getDimensionPixelSize(R.dimen.card_thumbnail_size); ImageView imageView; if (view == null) { imageView = new ImageView(context); @@ -71,7 +72,7 @@ public class ThumbnailSelectionAdapter extends BaseAdapter { EntryThumbnail.EntryThumbnails thumb = (EntryThumbnail.EntryThumbnails)getItem(i); - imageView.setImageBitmap(EntryThumbnail.getThumbnailGraphic(context, thumb.name(), size, thumb)); + imageView.setImageBitmap(EntryThumbnail.getThumbnailGraphic(context, label, size, thumb)); return imageView; } } From 43ddf62529f880510293d7cd01632605e4e46775 Mon Sep 17 00:00:00 2001 From: RichyHBM Date: Mon, 27 Nov 2017 21:29:02 +0000 Subject: [PATCH 08/15] Let users select thumbnail size --- README.md | 1 + .../andotp/Activities/MainActivity.java | 3 +- .../andotp/Utilities/DimensionConverter.java | 81 +++++++++++++++++++ .../flocke/andotp/Utilities/Settings.java | 11 +++ .../andotp/View/EntriesCardAdapter.java | 11 ++- .../flocke/andotp/View/EntryViewHolder.java | 5 +- .../View/ThumbnailSelectionAdapter.java | 10 ++- app/src/main/res/values/dimens.xml | 3 +- app/src/main/res/values/settings.xml | 9 +++ app/src/main/res/values/strings_settings.xml | 8 ++ app/src/main/res/xml/preferences.xml | 6 ++ 11 files changed, 136 insertions(+), 12 deletions(-) create mode 100644 app/src/main/java/org/shadowice/flocke/andotp/Utilities/DimensionConverter.java diff --git a/README.md b/README.md index 6d3020ee..2f6216a9 100644 --- a/README.md +++ b/README.md @@ -121,6 +121,7 @@ So make sure you have a **current backup** before switching! * [Code Parts from Google's Android Samples](https://android.googlesource.com/platform/development/+/master/samples/Vault/src/com/example/android/vault) * [FloatingActionMenuAndroid](https://github.com/pmahsky/FloatingActionMenuAndroid) * [LetterBitmap](http://stackoverflow.com/questions/23122088/colored-boxed-with-letters-a-la-gmail) + * [DimensionConverter](https://stackoverflow.com/questions/8343971/how-to-parse-a-dimension-string-and-convert-it-to-a-dimension-value) ## License: ``` 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 08bcc610..fb676f65 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 @@ -431,7 +431,8 @@ public class MainActivity extends BaseActivity if (key.equals(getString(R.string.settings_key_label_size)) || key.equals(getString(R.string.settings_key_tap_to_reveal)) || 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_visible)) || + key.equals(getString(R.string.settings_key_thumbnail_size))) { adapter.notifyDataSetChanged(); } else if (key.equals(getString(R.string.settings_key_theme)) || key.equals(getString(R.string.settings_key_lang))) { diff --git a/app/src/main/java/org/shadowice/flocke/andotp/Utilities/DimensionConverter.java b/app/src/main/java/org/shadowice/flocke/andotp/Utilities/DimensionConverter.java new file mode 100644 index 00000000..3a22639f --- /dev/null +++ b/app/src/main/java/org/shadowice/flocke/andotp/Utilities/DimensionConverter.java @@ -0,0 +1,81 @@ +package org.shadowice.flocke.andotp.Utilities; + +import android.util.DisplayMetrics; +import android.util.TypedValue; + +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class DimensionConverter { + + // -- Initialize dimension string to constant lookup. + public static final Map dimensionConstantLookup = initDimensionConstantLookup(); + private static Map initDimensionConstantLookup() { + Map m = new HashMap(); + m.put("px", TypedValue.COMPLEX_UNIT_PX); + m.put("dip", TypedValue.COMPLEX_UNIT_DIP); + m.put("dp", TypedValue.COMPLEX_UNIT_DIP); + m.put("sp", TypedValue.COMPLEX_UNIT_SP); + m.put("pt", TypedValue.COMPLEX_UNIT_PT); + m.put("in", TypedValue.COMPLEX_UNIT_IN); + m.put("mm", TypedValue.COMPLEX_UNIT_MM); + return Collections.unmodifiableMap(m); + } + // -- Initialize pattern for dimension string. + private static final Pattern DIMENSION_PATTERN = Pattern.compile("^\\s*(\\d+(\\.\\d+)*)\\s*([a-zA-Z]+)\\s*$"); + + public static int stringToDimensionPixelSize(String dimension, DisplayMetrics metrics) { + // -- Mimics TypedValue.complexToDimensionPixelSize(int data, DisplayMetrics metrics). + InternalDimension internalDimension = stringToInternalDimension(dimension); + final float value = internalDimension.value; + final float f = TypedValue.applyDimension(internalDimension.unit, value, metrics); + final int res = (int)(f+0.5f); + if (res != 0) return res; + if (value == 0) return 0; + if (value > 0) return 1; + return -1; + } + + public static float stringToDimension(String dimension, DisplayMetrics metrics) { + // -- Mimics TypedValue.complexToDimension(int data, DisplayMetrics metrics). + InternalDimension internalDimension = stringToInternalDimension(dimension); + return TypedValue.applyDimension(internalDimension.unit, internalDimension.value, metrics); + } + + private static InternalDimension stringToInternalDimension(String dimension) { + // -- Match target against pattern. + Matcher matcher = DIMENSION_PATTERN.matcher(dimension); + if (matcher.matches()) { + // -- Match found. + // -- Extract value. + float value = Float.valueOf(matcher.group(1)).floatValue(); + // -- Extract dimension units. + String unit = matcher.group(3).toLowerCase(); + // -- Get Android dimension constant. + Integer dimensionUnit = dimensionConstantLookup.get(unit); + if (dimensionUnit == null) { + // -- Invalid format. + throw new NumberFormatException(); + } else { + // -- Return valid dimension. + return new InternalDimension(value, dimensionUnit); + } + } else { + // -- Invalid format. + throw new NumberFormatException(); + } + } + + private static class InternalDimension { + float value; + int unit; + + public InternalDimension(float value, int unit) { + this.value = value; + this.unit = unit; + } + } +} \ No newline at end of file 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 0b90f4ab..a276c48f 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 @@ -27,6 +27,7 @@ import android.content.SharedPreferences; import android.os.Environment; import android.preference.PreferenceManager; import android.util.Base64; +import android.util.Log; import org.apache.commons.codec.binary.Hex; import org.apache.commons.codec.digest.DigestUtils; @@ -335,4 +336,14 @@ public class Settings { return getBoolean(R.string.settings_key_thumbnail_visible, true); } + public int getThumbnailSize() { + try { + String dimen = getString(R.string.settings_key_thumbnail_size, context.getResources().getString(R.string.settings_default_thumbnail_size)); + Log.d("dimen", dimen); + return DimensionConverter.stringToDimensionPixelSize(dimen, context.getResources().getDisplayMetrics()); + } catch(Exception e) { + e.printStackTrace(); + return context.getResources().getDimensionPixelSize(R.dimen.card_thumbnail_size); + } + } } 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 e5def43c..58a280a0 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 @@ -56,6 +56,7 @@ import android.widget.Toast; import org.shadowice.flocke.andotp.Database.Entry; import org.shadowice.flocke.andotp.R; import org.shadowice.flocke.andotp.Utilities.DatabaseHelper; +import org.shadowice.flocke.andotp.Utilities.DimensionConverter; import org.shadowice.flocke.andotp.Utilities.EntryThumbnail; import org.shadowice.flocke.andotp.Utilities.Settings; import org.shadowice.flocke.andotp.Utilities.TagDialogHelper; @@ -182,6 +183,9 @@ public class EntriesCardAdapter extends RecyclerView.Adapter int fontSize = sharedPrefs.getInt(context.getString(R.string.settings_key_label_size), context.getResources().getInteger(R.integer.settings_default_label_size)); entryViewHolder.setLabelSize(fontSize); + int thumbnailSize = settings.getThumbnailSize(); + entryViewHolder.setThumbnailSize(thumbnailSize); + entryViewHolder.setLabelScroll(sharedPrefs.getBoolean(context.getString(R.string.settings_key_label_scroll), false)); } @@ -262,8 +266,6 @@ public class EntriesCardAdapter extends RecyclerView.Adapter notifyItemChanged(pos); } - int size = context.getResources().getDimensionPixelSize(R.dimen.card_thumbnail_size); - Entry e = entries.get(realIndex); e.setLabel(newLabel); @@ -307,7 +309,9 @@ public class EntriesCardAdapter extends RecyclerView.Adapter GridView grid = new GridView(context); grid.setAdapter(thumbnailAdapter); grid.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); - grid.setColumnWidth(context.getResources().getDimensionPixelSize(R.dimen.card_thumbnail_size)); + + int thumbnailSize = settings.getThumbnailSize(); + grid.setColumnWidth(thumbnailSize); grid.setNumColumns(GridView.AUTO_FIT); grid.setVerticalSpacing(context.getResources().getDimensionPixelSize(R.dimen.activity_margin_medium)); grid.setHorizontalSpacing(context.getResources().getDimensionPixelSize(R.dimen.activity_margin_medium)); @@ -342,7 +346,6 @@ public class EntriesCardAdapter extends RecyclerView.Adapter e.printStackTrace(); } - int size = context.getResources().getDimensionPixelSize(R.dimen.card_thumbnail_size); Entry e = entries.get(realIndex); e.setThumbnail(thumbnail); 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 ed83913c..b6966474 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 @@ -36,6 +36,7 @@ import android.widget.LinearLayout; import android.widget.TextView; import org.shadowice.flocke.andotp.R; +import org.shadowice.flocke.andotp.Utilities.DimensionConverter; import org.shadowice.flocke.andotp.Utilities.EntryThumbnail; import org.shadowice.flocke.andotp.Utilities.Settings; import org.shadowice.flocke.andotp.Utilities.Tools; @@ -130,8 +131,8 @@ public class EntryViewHolder extends RecyclerView.ViewHolder thumbnailImg.setVisibility(settings.getThumbnailVisible() ? View.VISIBLE : View.GONE); - int size = context.getResources().getDimensionPixelSize(R.dimen.card_thumbnail_size); - thumbnailImg.setImageBitmap(EntryThumbnail.getThumbnailGraphic(context, label, size, thumbnail)); + int thumbnailSize = settings.getThumbnailSize(); + thumbnailImg.setImageBitmap(EntryThumbnail.getThumbnailGraphic(context, label, thumbnailSize, thumbnail)); } public void showCustomPeriod(int period) { diff --git a/app/src/main/java/org/shadowice/flocke/andotp/View/ThumbnailSelectionAdapter.java b/app/src/main/java/org/shadowice/flocke/andotp/View/ThumbnailSelectionAdapter.java index 7dc8ee15..6cf27ae9 100644 --- a/app/src/main/java/org/shadowice/flocke/andotp/View/ThumbnailSelectionAdapter.java +++ b/app/src/main/java/org/shadowice/flocke/andotp/View/ThumbnailSelectionAdapter.java @@ -12,7 +12,9 @@ import android.widget.ImageView; import android.widget.TextView; import org.shadowice.flocke.andotp.R; +import org.shadowice.flocke.andotp.Utilities.DimensionConverter; import org.shadowice.flocke.andotp.Utilities.EntryThumbnail; +import org.shadowice.flocke.andotp.Utilities.Settings; import java.util.ArrayList; import java.util.Collections; @@ -22,12 +24,14 @@ public class ThumbnailSelectionAdapter extends BaseAdapter { private Context context; private List items; private String label = "Example"; + private Settings settings; ThumbnailSelectionAdapter(Context context, String label) { items = new ArrayList(EntryThumbnail.EntryThumbnails.values().length); Collections.addAll(items, EntryThumbnail.EntryThumbnails.values()); this.label = label; this.context = context; + settings = new Settings(context); } void filter(String filter) { @@ -61,18 +65,18 @@ public class ThumbnailSelectionAdapter extends BaseAdapter { @NonNull @Override public View getView(int i, View view, @NonNull ViewGroup viewGroup) { - int size = context.getResources().getDimensionPixelSize(R.dimen.card_thumbnail_size); + int thumbnailSize = settings.getThumbnailSize(); ImageView imageView; if (view == null) { imageView = new ImageView(context); - imageView.setLayoutParams(new GridView.LayoutParams(size, size)); + imageView.setLayoutParams(new GridView.LayoutParams(thumbnailSize, thumbnailSize)); } else { imageView = (ImageView) view; } EntryThumbnail.EntryThumbnails thumb = (EntryThumbnail.EntryThumbnails)getItem(i); - imageView.setImageBitmap(EntryThumbnail.getThumbnailGraphic(context, label, size, thumb)); + imageView.setImageBitmap(EntryThumbnail.getThumbnailGraphic(context, label, thumbnailSize, thumb)); return imageView; } } diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index 985951d0..f1075f83 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -9,8 +9,7 @@ 16dp 0dp - 64dp - 46dp + 46dp 33sp diff --git a/app/src/main/res/values/settings.xml b/app/src/main/res/values/settings.xml index fc8b250a..2da59f7f 100644 --- a/app/src/main/res/values/settings.xml +++ b/app/src/main/res/values/settings.xml @@ -16,6 +16,7 @@ pref_label_size pref_label_scroll pref_thumbnail_visible + pref_thumbnail_size pref_backup_ask pref_backup_directory @@ -38,6 +39,7 @@ system light 8 + 46dp @@ -83,6 +85,13 @@ black + + 32dp + 46dp + 64dp + 96dp + + diff --git a/app/src/main/res/values/strings_settings.xml b/app/src/main/res/values/strings_settings.xml index 7ab3a1bf..ca9b2fba 100644 --- a/app/src/main/res/values/strings_settings.xml +++ b/app/src/main/res/values/strings_settings.xml @@ -19,6 +19,7 @@ Label font size Scroll label Show thumbnails + Thumbnail size Ask for filename Backup directory @@ -85,6 +86,13 @@ Black theme + + Small + Default + Medium + Large + + Password PIN diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml index 6530b829..fd4de0e0 100644 --- a/app/src/main/res/xml/preferences.xml +++ b/app/src/main/res/xml/preferences.xml @@ -71,6 +71,12 @@ android:title="@string/settings_title_thumbnail_visible_ask" android:defaultValue="true" /> + From d2eb7350eca9b42f8a93752b8e26aef41b5ea232 Mon Sep 17 00:00:00 2001 From: RichyHBM Date: Tue, 28 Nov 2017 19:34:42 +0000 Subject: [PATCH 09/15] Add thumbnails for amazon, battlenet, bitbucket, bitcoin, bitstamp, bitwarden, coinbase, dropbox, facebook, git, github, gitlab, google, kickstarter, lastpass, microsoft, origin, rss, slack, steam, wordpress --- .../andotp/Utilities/EntryThumbnail.java | 22 ++++++- app/src/main/res/drawable/ic_amazon.xml | 4 ++ app/src/main/res/drawable/ic_battlenet.xml | 12 ++++ app/src/main/res/drawable/ic_bitbucket.xml | 15 +++++ app/src/main/res/drawable/ic_bitcoin.xml | 23 ++++++++ app/src/main/res/drawable/ic_coinbase.xml | 54 ++++++++++++++++++ app/src/main/res/drawable/ic_dropbox.xml | 9 +++ app/src/main/res/drawable/ic_facebook.xml | 12 ++++ app/src/main/res/drawable/ic_git.xml | 9 +++ app/src/main/res/drawable/ic_github.xml | 12 ++-- app/src/main/res/drawable/ic_gitlab.xml | 27 +++++++++ app/src/main/res/drawable/ic_google.xml | 18 ++++++ app/src/main/res/drawable/ic_kickstarter.xml | 12 ++++ app/src/main/res/drawable/ic_lastpass.xml | 42 ++++++++++++++ app/src/main/res/drawable/ic_microsoft.xml | 30 ++++++++++ app/src/main/res/drawable/ic_origin.xml | 20 +++++++ app/src/main/res/drawable/ic_rss.xml | 40 +++++++++++++ app/src/main/res/drawable/ic_slack.xml | 11 ++++ app/src/main/res/drawable/ic_steam.xml | 9 +++ app/src/main/res/drawable/ic_wordpress.xml | 21 +++++++ app/src/main/res/mipmap-xhdpi/bitstamp.png | Bin 0 -> 7570 bytes app/src/main/res/mipmap-xhdpi/bitwarden.png | Bin 0 -> 2443 bytes 22 files changed, 395 insertions(+), 7 deletions(-) create mode 100644 app/src/main/res/drawable/ic_amazon.xml create mode 100644 app/src/main/res/drawable/ic_battlenet.xml create mode 100644 app/src/main/res/drawable/ic_bitbucket.xml create mode 100644 app/src/main/res/drawable/ic_bitcoin.xml create mode 100644 app/src/main/res/drawable/ic_coinbase.xml create mode 100644 app/src/main/res/drawable/ic_dropbox.xml create mode 100644 app/src/main/res/drawable/ic_facebook.xml create mode 100644 app/src/main/res/drawable/ic_git.xml create mode 100644 app/src/main/res/drawable/ic_gitlab.xml create mode 100644 app/src/main/res/drawable/ic_google.xml create mode 100644 app/src/main/res/drawable/ic_kickstarter.xml create mode 100644 app/src/main/res/drawable/ic_lastpass.xml create mode 100644 app/src/main/res/drawable/ic_microsoft.xml create mode 100644 app/src/main/res/drawable/ic_origin.xml create mode 100644 app/src/main/res/drawable/ic_rss.xml create mode 100644 app/src/main/res/drawable/ic_slack.xml create mode 100644 app/src/main/res/drawable/ic_steam.xml create mode 100644 app/src/main/res/drawable/ic_wordpress.xml create mode 100644 app/src/main/res/mipmap-xhdpi/bitstamp.png create mode 100644 app/src/main/res/mipmap-xhdpi/bitwarden.png 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 c7ba0965..d45cc0b6 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 @@ -16,7 +16,27 @@ public class EntryThumbnail { public enum EntryThumbnails { Default(R.mipmap.ic_launcher_round), - Github(R.drawable.ic_github); + Amazon(R.drawable.ic_amazon), + BattleNet(R.drawable.ic_battlenet), + BitBucket(R.drawable.ic_bitbucket), + Bitcoin(R.drawable.ic_bitcoin), + Bitstamp(R.mipmap.bitstamp, AssetType.Bitmap), + Bitwarden(R.mipmap.bitwarden, AssetType.Bitmap), + Coinbase(R.drawable.ic_coinbase), + Dropbox(R.drawable.ic_dropbox), + Facebook(R.drawable.ic_facebook), + Git(R.drawable.ic_git), + Github(R.drawable.ic_github), + Gitlab(R.drawable.ic_gitlab), + Google(R.drawable.ic_google), + Kickstarter(R.drawable.ic_kickstarter), + LastPass(R.drawable.ic_lastpass), + Microsoft(R.drawable.ic_microsoft), + Origin(R.drawable.ic_origin), + RSS(R.drawable.ic_rss), + Slack(R.drawable.ic_slack), + Steam(R.drawable.ic_steam), + Wordpress(R.drawable.ic_wordpress); private int resource; private AssetType assetType; diff --git a/app/src/main/res/drawable/ic_amazon.xml b/app/src/main/res/drawable/ic_amazon.xml new file mode 100644 index 00000000..9ee6eb73 --- /dev/null +++ b/app/src/main/res/drawable/ic_amazon.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_battlenet.xml b/app/src/main/res/drawable/ic_battlenet.xml new file mode 100644 index 00000000..f45f4b7e --- /dev/null +++ b/app/src/main/res/drawable/ic_battlenet.xml @@ -0,0 +1,12 @@ + + + + diff --git a/app/src/main/res/drawable/ic_bitbucket.xml b/app/src/main/res/drawable/ic_bitbucket.xml new file mode 100644 index 00000000..b940249d --- /dev/null +++ b/app/src/main/res/drawable/ic_bitbucket.xml @@ -0,0 +1,15 @@ + + + + + diff --git a/app/src/main/res/drawable/ic_bitcoin.xml b/app/src/main/res/drawable/ic_bitcoin.xml new file mode 100644 index 00000000..7f00dac6 --- /dev/null +++ b/app/src/main/res/drawable/ic_bitcoin.xml @@ -0,0 +1,23 @@ + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_coinbase.xml b/app/src/main/res/drawable/ic_coinbase.xml new file mode 100644 index 00000000..6e924a16 --- /dev/null +++ b/app/src/main/res/drawable/ic_coinbase.xml @@ -0,0 +1,54 @@ + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_dropbox.xml b/app/src/main/res/drawable/ic_dropbox.xml new file mode 100644 index 00000000..12031fa7 --- /dev/null +++ b/app/src/main/res/drawable/ic_dropbox.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_facebook.xml b/app/src/main/res/drawable/ic_facebook.xml new file mode 100644 index 00000000..b906a983 --- /dev/null +++ b/app/src/main/res/drawable/ic_facebook.xml @@ -0,0 +1,12 @@ + + + + diff --git a/app/src/main/res/drawable/ic_git.xml b/app/src/main/res/drawable/ic_git.xml new file mode 100644 index 00000000..0bbce40e --- /dev/null +++ b/app/src/main/res/drawable/ic_git.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_github.xml b/app/src/main/res/drawable/ic_github.xml index 3b739907..93eb5ba0 100644 --- a/app/src/main/res/drawable/ic_github.xml +++ b/app/src/main/res/drawable/ic_github.xml @@ -1,9 +1,9 @@ + android:width="256dp" + android:height="250dp" + android:viewportWidth="256.0" + android:viewportHeight="250.0"> + android:pathData="M128,0C57.32,0 0,57.31 0,128C0,184.56 36.68,232.54 87.53,249.46C93.93,250.65 96.28,246.68 96.28,243.3C96.28,240.25 96.16,230.17 96.11,219.47C60.5,227.22 52.98,204.37 52.98,204.37C47.16,189.57 38.77,185.64 38.77,185.64C27.16,177.7 39.65,177.86 39.65,177.86C52.5,178.76 59.27,191.05 59.27,191.05C70.68,210.62 89.21,204.96 96.52,201.69C97.66,193.42 100.98,187.77 104.64,184.57C76.21,181.34 46.32,170.36 46.32,121.32C46.32,107.34 51.33,95.92 59.51,86.96C58.18,83.73 53.8,70.72 60.75,53.08C60.75,53.08 71.5,49.64 95.96,66.2C106.17,63.37 117.12,61.95 128,61.9C138.88,61.95 149.84,63.37 160.07,66.2C184.5,49.64 195.23,53.08 195.23,53.08C202.2,70.72 197.82,83.73 196.49,86.96C204.69,95.92 209.66,107.34 209.66,121.32C209.66,170.48 179.72,181.3 151.21,184.47C155.8,188.44 159.9,196.23 159.9,208.18C159.9,225.3 159.75,239.09 159.75,243.3C159.75,246.71 162.05,250.7 168.54,249.44C219.37,232.5 256,184.54 256,128C256,57.31 198.69,0 128,0ZM47.94,182.34C47.66,182.98 46.66,183.17 45.75,182.73C44.82,182.31 44.3,181.45 44.6,180.81C44.87,180.15 45.88,179.97 46.8,180.41C47.73,180.83 48.26,181.7 47.94,182.34ZM54.24,187.96C53.63,188.52 52.43,188.26 51.62,187.37C50.79,186.47 50.63,185.28 51.25,184.71C51.88,184.14 53.03,184.41 53.87,185.3C54.71,186.2 54.87,187.39 54.24,187.96ZM58.56,195.15C57.77,195.69 56.49,195.18 55.7,194.04C54.91,192.9 54.91,191.54 55.71,190.99C56.51,190.44 57.77,190.94 58.58,192.07C59.36,193.22 59.36,194.59 58.56,195.15ZM65.86,203.47C65.16,204.24 63.67,204.04 62.57,202.98C61.45,201.95 61.14,200.48 61.84,199.71C62.55,198.94 64.06,199.15 65.16,200.2C66.27,201.23 66.61,202.71 65.86,203.47ZM75.3,206.28C74.99,207.28 73.55,207.74 72.1,207.31C70.66,206.88 69.71,205.7 70,204.69C70.3,203.68 71.75,203.2 73.21,203.66C74.65,204.1 75.6,205.26 75.3,206.28ZM86.05,207.47C86.08,208.53 84.85,209.4 83.33,209.42C81.8,209.46 80.56,208.6 80.55,207.56C80.55,206.5 81.75,205.63 83.28,205.61C84.8,205.58 86.05,206.42 86.05,207.47ZM96.6,207.07C96.78,208.1 95.73,209.16 94.22,209.44C92.73,209.71 91.35,209.07 91.17,208.05C90.98,207 92.06,205.94 93.54,205.67C95.05,205.4 96.41,206.02 96.6,207.07Z" + android:fillColor="#161614"/> diff --git a/app/src/main/res/drawable/ic_gitlab.xml b/app/src/main/res/drawable/ic_gitlab.xml new file mode 100644 index 00000000..6d8833f6 --- /dev/null +++ b/app/src/main/res/drawable/ic_gitlab.xml @@ -0,0 +1,27 @@ + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_google.xml b/app/src/main/res/drawable/ic_google.xml new file mode 100644 index 00000000..b71c47f2 --- /dev/null +++ b/app/src/main/res/drawable/ic_google.xml @@ -0,0 +1,18 @@ + + + + + + diff --git a/app/src/main/res/drawable/ic_kickstarter.xml b/app/src/main/res/drawable/ic_kickstarter.xml new file mode 100644 index 00000000..5dad8673 --- /dev/null +++ b/app/src/main/res/drawable/ic_kickstarter.xml @@ -0,0 +1,12 @@ + + + + diff --git a/app/src/main/res/drawable/ic_lastpass.xml b/app/src/main/res/drawable/ic_lastpass.xml new file mode 100644 index 00000000..616bb17d --- /dev/null +++ b/app/src/main/res/drawable/ic_lastpass.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_microsoft.xml b/app/src/main/res/drawable/ic_microsoft.xml new file mode 100644 index 00000000..637ecedf --- /dev/null +++ b/app/src/main/res/drawable/ic_microsoft.xml @@ -0,0 +1,30 @@ + + + + + + diff --git a/app/src/main/res/drawable/ic_origin.xml b/app/src/main/res/drawable/ic_origin.xml new file mode 100644 index 00000000..1bf8eceb --- /dev/null +++ b/app/src/main/res/drawable/ic_origin.xml @@ -0,0 +1,20 @@ + + + + + + + + diff --git a/app/src/main/res/drawable/ic_rss.xml b/app/src/main/res/drawable/ic_rss.xml new file mode 100644 index 00000000..be5ad629 --- /dev/null +++ b/app/src/main/res/drawable/ic_rss.xml @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_slack.xml b/app/src/main/res/drawable/ic_slack.xml new file mode 100644 index 00000000..d180f52e --- /dev/null +++ b/app/src/main/res/drawable/ic_slack.xml @@ -0,0 +1,11 @@ + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_steam.xml b/app/src/main/res/drawable/ic_steam.xml new file mode 100644 index 00000000..192aaacf --- /dev/null +++ b/app/src/main/res/drawable/ic_steam.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_wordpress.xml b/app/src/main/res/drawable/ic_wordpress.xml new file mode 100644 index 00000000..a702a9cf --- /dev/null +++ b/app/src/main/res/drawable/ic_wordpress.xml @@ -0,0 +1,21 @@ + + + + + + + diff --git a/app/src/main/res/mipmap-xhdpi/bitstamp.png b/app/src/main/res/mipmap-xhdpi/bitstamp.png new file mode 100644 index 0000000000000000000000000000000000000000..cd5e56cedcde19cee1bd3c24908f12f56bc7b039 GIT binary patch literal 7570 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 Date: Tue, 28 Nov 2017 19:35:58 +0000 Subject: [PATCH 10/15] Add thumbnails for angellist, apple, cloudflare, digital ocean, discord, ifttt, mailgun, paypal, protonmail, stripe, twitch, twitter --- .../andotp/Utilities/EntryThumbnail.java | 13 ++++ app/src/main/res/drawable/ic_angellist.xml | 9 +++ app/src/main/res/drawable/ic_apple.xml | 9 +++ app/src/main/res/drawable/ic_cloudflare.xml | 15 +++++ .../main/res/drawable/ic_digital_ocean.xml | 12 ++++ app/src/main/res/drawable/ic_discord.xml | 9 +++ app/src/main/res/drawable/ic_ifttt.xml | 60 +++++++++++++++++++ app/src/main/res/drawable/ic_mailgun.xml | 9 +++ app/src/main/res/drawable/ic_paypal.xml | 18 ++++++ app/src/main/res/drawable/ic_protonmail.xml | 18 ++++++ app/src/main/res/drawable/ic_stripe.xml | 9 +++ app/src/main/res/drawable/ic_twitch.xml | 9 +++ app/src/main/res/drawable/ic_twitter.xml | 9 +++ 13 files changed, 199 insertions(+) create mode 100644 app/src/main/res/drawable/ic_angellist.xml create mode 100644 app/src/main/res/drawable/ic_apple.xml create mode 100644 app/src/main/res/drawable/ic_cloudflare.xml create mode 100644 app/src/main/res/drawable/ic_digital_ocean.xml create mode 100644 app/src/main/res/drawable/ic_discord.xml create mode 100644 app/src/main/res/drawable/ic_ifttt.xml create mode 100644 app/src/main/res/drawable/ic_mailgun.xml create mode 100644 app/src/main/res/drawable/ic_paypal.xml create mode 100644 app/src/main/res/drawable/ic_protonmail.xml create mode 100644 app/src/main/res/drawable/ic_stripe.xml create mode 100644 app/src/main/res/drawable/ic_twitch.xml create mode 100644 app/src/main/res/drawable/ic_twitter.xml 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 d45cc0b6..9e2c7e19 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 @@ -5,6 +5,7 @@ import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.drawable.Drawable; +import android.util.Log; import org.shadowice.flocke.andotp.R; @@ -17,25 +18,37 @@ public class EntryThumbnail { public enum EntryThumbnails { Default(R.mipmap.ic_launcher_round), Amazon(R.drawable.ic_amazon), + AngelList(R.drawable.ic_angellist), + Apple(R.drawable.ic_apple), BattleNet(R.drawable.ic_battlenet), BitBucket(R.drawable.ic_bitbucket), Bitcoin(R.drawable.ic_bitcoin), Bitstamp(R.mipmap.bitstamp, AssetType.Bitmap), Bitwarden(R.mipmap.bitwarden, AssetType.Bitmap), + Cloudflare(R.drawable.ic_cloudflare), Coinbase(R.drawable.ic_coinbase), + DigitalOcean(R.drawable.ic_digital_ocean), + Discord(R.drawable.ic_discord), Dropbox(R.drawable.ic_dropbox), Facebook(R.drawable.ic_facebook), Git(R.drawable.ic_git), Github(R.drawable.ic_github), Gitlab(R.drawable.ic_gitlab), Google(R.drawable.ic_google), + IFTTT(R.drawable.ic_ifttt), Kickstarter(R.drawable.ic_kickstarter), LastPass(R.drawable.ic_lastpass), + Mailgun(R.drawable.ic_mailgun), Microsoft(R.drawable.ic_microsoft), Origin(R.drawable.ic_origin), + PayPal(R.drawable.ic_paypal), + ProtonMail(R.drawable.ic_protonmail), RSS(R.drawable.ic_rss), Slack(R.drawable.ic_slack), Steam(R.drawable.ic_steam), + Stripe(R.drawable.ic_stripe), + Twitch(R.drawable.ic_twitch), + Twitter(R.drawable.ic_twitter), Wordpress(R.drawable.ic_wordpress); private int resource; diff --git a/app/src/main/res/drawable/ic_angellist.xml b/app/src/main/res/drawable/ic_angellist.xml new file mode 100644 index 00000000..e49b9b57 --- /dev/null +++ b/app/src/main/res/drawable/ic_angellist.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_apple.xml b/app/src/main/res/drawable/ic_apple.xml new file mode 100644 index 00000000..a4ff7db1 --- /dev/null +++ b/app/src/main/res/drawable/ic_apple.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_cloudflare.xml b/app/src/main/res/drawable/ic_cloudflare.xml new file mode 100644 index 00000000..270536d0 --- /dev/null +++ b/app/src/main/res/drawable/ic_cloudflare.xml @@ -0,0 +1,15 @@ + + + + + diff --git a/app/src/main/res/drawable/ic_digital_ocean.xml b/app/src/main/res/drawable/ic_digital_ocean.xml new file mode 100644 index 00000000..353bad8b --- /dev/null +++ b/app/src/main/res/drawable/ic_digital_ocean.xml @@ -0,0 +1,12 @@ + + + + diff --git a/app/src/main/res/drawable/ic_discord.xml b/app/src/main/res/drawable/ic_discord.xml new file mode 100644 index 00000000..b26a67d2 --- /dev/null +++ b/app/src/main/res/drawable/ic_discord.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_ifttt.xml b/app/src/main/res/drawable/ic_ifttt.xml new file mode 100644 index 00000000..69f2b6b4 --- /dev/null +++ b/app/src/main/res/drawable/ic_ifttt.xml @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_mailgun.xml b/app/src/main/res/drawable/ic_mailgun.xml new file mode 100644 index 00000000..00e20022 --- /dev/null +++ b/app/src/main/res/drawable/ic_mailgun.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_paypal.xml b/app/src/main/res/drawable/ic_paypal.xml new file mode 100644 index 00000000..f52a669b --- /dev/null +++ b/app/src/main/res/drawable/ic_paypal.xml @@ -0,0 +1,18 @@ + + + + + + diff --git a/app/src/main/res/drawable/ic_protonmail.xml b/app/src/main/res/drawable/ic_protonmail.xml new file mode 100644 index 00000000..cbc2404c --- /dev/null +++ b/app/src/main/res/drawable/ic_protonmail.xml @@ -0,0 +1,18 @@ + + + + diff --git a/app/src/main/res/drawable/ic_stripe.xml b/app/src/main/res/drawable/ic_stripe.xml new file mode 100644 index 00000000..44a6c350 --- /dev/null +++ b/app/src/main/res/drawable/ic_stripe.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_twitch.xml b/app/src/main/res/drawable/ic_twitch.xml new file mode 100644 index 00000000..195c98fb --- /dev/null +++ b/app/src/main/res/drawable/ic_twitch.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_twitter.xml b/app/src/main/res/drawable/ic_twitter.xml new file mode 100644 index 00000000..b75963ed --- /dev/null +++ b/app/src/main/res/drawable/ic_twitter.xml @@ -0,0 +1,9 @@ + + + From 5be1cb8393c51a721be30afd8d6fdd773534b216 Mon Sep 17 00:00:00 2001 From: RichyHBM Date: Tue, 28 Nov 2017 20:10:42 +0000 Subject: [PATCH 11/15] Tidy up imports --- .../shadowice/flocke/andotp/Activities/MainActivity.java | 1 - .../java/org/shadowice/flocke/andotp/Database/Entry.java | 1 - .../shadowice/flocke/andotp/Utilities/DatabaseHelper.java | 1 - .../shadowice/flocke/andotp/Utilities/EntryThumbnail.java | 1 - .../org/shadowice/flocke/andotp/Utilities/Settings.java | 2 -- .../shadowice/flocke/andotp/View/EntriesCardAdapter.java | 7 ------- .../org/shadowice/flocke/andotp/View/EntryViewHolder.java | 2 -- .../flocke/andotp/View/ThumbnailSelectionAdapter.java | 5 ----- 8 files changed, 20 deletions(-) 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 fb676f65..d4a5e5ad 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 @@ -63,7 +63,6 @@ import com.google.zxing.integration.android.IntentResult; import org.shadowice.flocke.andotp.Database.Entry; import org.shadowice.flocke.andotp.R; import org.shadowice.flocke.andotp.Utilities.DatabaseHelper; -import org.shadowice.flocke.andotp.Utilities.EntryThumbnail; import org.shadowice.flocke.andotp.Utilities.Settings; import org.shadowice.flocke.andotp.Utilities.TagDialogHelper; import org.shadowice.flocke.andotp.Utilities.TokenCalculator; diff --git a/app/src/main/java/org/shadowice/flocke/andotp/Database/Entry.java b/app/src/main/java/org/shadowice/flocke/andotp/Database/Entry.java index 16b4f613..d647763b 100644 --- a/app/src/main/java/org/shadowice/flocke/andotp/Database/Entry.java +++ b/app/src/main/java/org/shadowice/flocke/andotp/Database/Entry.java @@ -23,7 +23,6 @@ package org.shadowice.flocke.andotp.Database; -import android.graphics.Bitmap; import android.net.Uri; import org.apache.commons.codec.binary.Base32; diff --git a/app/src/main/java/org/shadowice/flocke/andotp/Utilities/DatabaseHelper.java b/app/src/main/java/org/shadowice/flocke/andotp/Utilities/DatabaseHelper.java index 9d14c2c4..7e66799f 100644 --- a/app/src/main/java/org/shadowice/flocke/andotp/Utilities/DatabaseHelper.java +++ b/app/src/main/java/org/shadowice/flocke/andotp/Utilities/DatabaseHelper.java @@ -28,7 +28,6 @@ import android.net.Uri; import org.json.JSONArray; import org.shadowice.flocke.andotp.Database.Entry; -import org.shadowice.flocke.andotp.R; import java.io.File; import java.util.ArrayList; 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 9e2c7e19..220666f3 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 @@ -5,7 +5,6 @@ import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.drawable.Drawable; -import android.util.Log; import org.shadowice.flocke.andotp.R; 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 a276c48f..e0709bd5 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 @@ -27,7 +27,6 @@ import android.content.SharedPreferences; import android.os.Environment; import android.preference.PreferenceManager; import android.util.Base64; -import android.util.Log; import org.apache.commons.codec.binary.Hex; import org.apache.commons.codec.digest.DigestUtils; @@ -339,7 +338,6 @@ public class Settings { public int getThumbnailSize() { try { String dimen = getString(R.string.settings_key_thumbnail_size, context.getResources().getString(R.string.settings_default_thumbnail_size)); - Log.d("dimen", dimen); return DimensionConverter.stringToDimensionPixelSize(dimen, context.getResources().getDisplayMetrics()); } catch(Exception e) { e.printStackTrace(); 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 58a280a0..88e37f40 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 @@ -28,35 +28,28 @@ import android.content.ClipboardManager; import android.content.Context; import android.content.DialogInterface; import android.content.SharedPreferences; -import android.graphics.Bitmap; import android.preference.PreferenceManager; import android.support.v7.widget.PopupMenu; import android.support.v7.widget.RecyclerView; import android.text.Editable; import android.text.TextWatcher; -import android.util.Log; import android.view.LayoutInflater; import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; -import android.widget.AbsListView; import android.widget.AdapterView; -import android.widget.ArrayAdapter; import android.widget.EditText; import android.widget.Filter; import android.widget.Filterable; import android.widget.FrameLayout; import android.widget.GridView; import android.widget.LinearLayout; -import android.widget.ListView; -import android.widget.TextView; import android.widget.Toast; import org.shadowice.flocke.andotp.Database.Entry; import org.shadowice.flocke.andotp.R; import org.shadowice.flocke.andotp.Utilities.DatabaseHelper; -import org.shadowice.flocke.andotp.Utilities.DimensionConverter; import org.shadowice.flocke.andotp.Utilities.EntryThumbnail; import org.shadowice.flocke.andotp.Utilities.Settings; import org.shadowice.flocke.andotp.Utilities.TagDialogHelper; 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 b6966474..4fe61bd8 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 @@ -23,7 +23,6 @@ package org.shadowice.flocke.andotp.View; import android.content.Context; -import android.graphics.Bitmap; import android.graphics.ColorFilter; import android.support.v7.widget.CardView; import android.support.v7.widget.RecyclerView; @@ -36,7 +35,6 @@ import android.widget.LinearLayout; import android.widget.TextView; import org.shadowice.flocke.andotp.R; -import org.shadowice.flocke.andotp.Utilities.DimensionConverter; import org.shadowice.flocke.andotp.Utilities.EntryThumbnail; import org.shadowice.flocke.andotp.Utilities.Settings; import org.shadowice.flocke.andotp.Utilities.Tools; diff --git a/app/src/main/java/org/shadowice/flocke/andotp/View/ThumbnailSelectionAdapter.java b/app/src/main/java/org/shadowice/flocke/andotp/View/ThumbnailSelectionAdapter.java index 6cf27ae9..04756c92 100644 --- a/app/src/main/java/org/shadowice/flocke/andotp/View/ThumbnailSelectionAdapter.java +++ b/app/src/main/java/org/shadowice/flocke/andotp/View/ThumbnailSelectionAdapter.java @@ -2,17 +2,12 @@ package org.shadowice.flocke.andotp.View; import android.content.Context; import android.support.annotation.NonNull; -import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.widget.ArrayAdapter; import android.widget.BaseAdapter; import android.widget.GridView; import android.widget.ImageView; -import android.widget.TextView; -import org.shadowice.flocke.andotp.R; -import org.shadowice.flocke.andotp.Utilities.DimensionConverter; import org.shadowice.flocke.andotp.Utilities.EntryThumbnail; import org.shadowice.flocke.andotp.Utilities.Settings; From 0f5a121c6bd407ed7ca756db11efd330180c21ac Mon Sep 17 00:00:00 2001 From: RichyHBM Date: Wed, 29 Nov 2017 22:38:57 +0000 Subject: [PATCH 12/15] Add cozy cloud , next clous and mastodon --- .../andotp/Utilities/EntryThumbnail.java | 3 ++ app/src/main/res/drawable/ic_cozycloud.xml | 4 ++ app/src/main/res/drawable/ic_mastodon.xml | 12 +++++ app/src/main/res/drawable/ic_nextcloud.xml | 52 +++++++++++++++++++ 4 files changed, 71 insertions(+) create mode 100644 app/src/main/res/drawable/ic_cozycloud.xml create mode 100644 app/src/main/res/drawable/ic_mastodon.xml create mode 100644 app/src/main/res/drawable/ic_nextcloud.xml 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 220666f3..eb0004a3 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 @@ -26,6 +26,7 @@ public class EntryThumbnail { Bitwarden(R.mipmap.bitwarden, AssetType.Bitmap), Cloudflare(R.drawable.ic_cloudflare), Coinbase(R.drawable.ic_coinbase), + CozyCloud(R.drawable.ic_cozycloud), DigitalOcean(R.drawable.ic_digital_ocean), Discord(R.drawable.ic_discord), Dropbox(R.drawable.ic_dropbox), @@ -38,7 +39,9 @@ public class EntryThumbnail { Kickstarter(R.drawable.ic_kickstarter), LastPass(R.drawable.ic_lastpass), Mailgun(R.drawable.ic_mailgun), + Mastodon(R.drawable.ic_mastodon), Microsoft(R.drawable.ic_microsoft), + NextCloud(R.drawable.ic_nextcloud), Origin(R.drawable.ic_origin), PayPal(R.drawable.ic_paypal), ProtonMail(R.drawable.ic_protonmail), diff --git a/app/src/main/res/drawable/ic_cozycloud.xml b/app/src/main/res/drawable/ic_cozycloud.xml new file mode 100644 index 00000000..f7dcdc16 --- /dev/null +++ b/app/src/main/res/drawable/ic_cozycloud.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_mastodon.xml b/app/src/main/res/drawable/ic_mastodon.xml new file mode 100644 index 00000000..61206cd1 --- /dev/null +++ b/app/src/main/res/drawable/ic_mastodon.xml @@ -0,0 +1,12 @@ + + + + diff --git a/app/src/main/res/drawable/ic_nextcloud.xml b/app/src/main/res/drawable/ic_nextcloud.xml new file mode 100644 index 00000000..04f92681 --- /dev/null +++ b/app/src/main/res/drawable/ic_nextcloud.xml @@ -0,0 +1,52 @@ + + + + + + + + + + + + From a628e7c8866b7a9780e5627b6d64c296d2bff355 Mon Sep 17 00:00:00 2001 From: RichyHBM Date: Wed, 29 Nov 2017 23:34:10 +0000 Subject: [PATCH 13/15] Change amazon and add AWS --- .../andotp/Utilities/EntryThumbnail.java | 1 + app/src/main/res/drawable/ic_amazon.xml | 23 ++++++++++++++++--- .../res/drawable/ic_amazonwebservices.xml | 17 ++++++++++++++ 3 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 app/src/main/res/drawable/ic_amazonwebservices.xml 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 eb0004a3..1a7ba12a 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 @@ -17,6 +17,7 @@ public class EntryThumbnail { public enum EntryThumbnails { Default(R.mipmap.ic_launcher_round), Amazon(R.drawable.ic_amazon), + AmazonWebServices(R.drawable.ic_amazonwebservices), AngelList(R.drawable.ic_angellist), Apple(R.drawable.ic_apple), BattleNet(R.drawable.ic_battlenet), diff --git a/app/src/main/res/drawable/ic_amazon.xml b/app/src/main/res/drawable/ic_amazon.xml index 9ee6eb73..23e1d327 100644 --- a/app/src/main/res/drawable/ic_amazon.xml +++ b/app/src/main/res/drawable/ic_amazon.xml @@ -1,4 +1,21 @@ - - + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_amazonwebservices.xml b/app/src/main/res/drawable/ic_amazonwebservices.xml new file mode 100644 index 00000000..0b096637 --- /dev/null +++ b/app/src/main/res/drawable/ic_amazonwebservices.xml @@ -0,0 +1,17 @@ + + + + + From 9920f87d929e35e6e600a666184f2edf55be995d Mon Sep 17 00:00:00 2001 From: RichyHBM Date: Thu, 30 Nov 2017 07:26:09 +0000 Subject: [PATCH 14/15] Rename from ic_ to thumb_ --- .../andotp/Utilities/EntryThumbnail.java | 74 +++++++++--------- .../{ic_amazon.xml => thumb_amazon.xml} | 0 ...rvices.xml => thumb_amazonwebservices.xml} | 0 .../{ic_angellist.xml => thumb_angellist.xml} | 0 .../{ic_apple.xml => thumb_apple.xml} | 0 .../{ic_battlenet.xml => thumb_battlenet.xml} | 0 .../{ic_bitbucket.xml => thumb_bitbucket.xml} | 0 .../{ic_bitcoin.xml => thumb_bitcoin.xml} | 0 ...ic_cloudflare.xml => thumb_cloudflare.xml} | 0 .../{ic_coinbase.xml => thumb_coinbase.xml} | 0 .../{ic_cozycloud.xml => thumb_cozycloud.xml} | 0 ...ital_ocean.xml => thumb_digital_ocean.xml} | 0 .../{ic_discord.xml => thumb_discord.xml} | 0 .../{ic_dropbox.xml => thumb_dropbox.xml} | 0 .../{ic_facebook.xml => thumb_facebook.xml} | 0 .../drawable/{ic_git.xml => thumb_git.xml} | 0 .../{ic_github.xml => thumb_github.xml} | 0 .../{ic_gitlab.xml => thumb_gitlab.xml} | 0 .../{ic_google.xml => thumb_google.xml} | 0 .../{ic_ifttt.xml => thumb_ifttt.xml} | 0 ..._kickstarter.xml => thumb_kickstarter.xml} | 0 .../{ic_lastpass.xml => thumb_lastpass.xml} | 0 .../{ic_mailgun.xml => thumb_mailgun.xml} | 0 .../{ic_mastodon.xml => thumb_mastodon.xml} | 0 .../{ic_microsoft.xml => thumb_microsoft.xml} | 0 .../{ic_nextcloud.xml => thumb_nextcloud.xml} | 0 .../{ic_origin.xml => thumb_origin.xml} | 0 .../{ic_paypal.xml => thumb_paypal.xml} | 0 ...ic_protonmail.xml => thumb_protonmail.xml} | 0 .../drawable/{ic_rss.xml => thumb_rss.xml} | 0 .../{ic_slack.xml => thumb_slack.xml} | 0 .../{ic_steam.xml => thumb_steam.xml} | 0 .../{ic_stripe.xml => thumb_stripe.xml} | 0 .../{ic_twitch.xml => thumb_twitch.xml} | 0 .../{ic_twitter.xml => thumb_twitter.xml} | 0 .../{ic_wordpress.xml => thumb_wordpress.xml} | 0 .../{bitstamp.png => thumb_bitstamp.png} | Bin .../{bitwarden.png => thumb_bitwarden.png} | Bin 38 files changed, 37 insertions(+), 37 deletions(-) rename app/src/main/res/drawable/{ic_amazon.xml => thumb_amazon.xml} (100%) rename app/src/main/res/drawable/{ic_amazonwebservices.xml => thumb_amazonwebservices.xml} (100%) rename app/src/main/res/drawable/{ic_angellist.xml => thumb_angellist.xml} (100%) rename app/src/main/res/drawable/{ic_apple.xml => thumb_apple.xml} (100%) rename app/src/main/res/drawable/{ic_battlenet.xml => thumb_battlenet.xml} (100%) rename app/src/main/res/drawable/{ic_bitbucket.xml => thumb_bitbucket.xml} (100%) rename app/src/main/res/drawable/{ic_bitcoin.xml => thumb_bitcoin.xml} (100%) rename app/src/main/res/drawable/{ic_cloudflare.xml => thumb_cloudflare.xml} (100%) rename app/src/main/res/drawable/{ic_coinbase.xml => thumb_coinbase.xml} (100%) rename app/src/main/res/drawable/{ic_cozycloud.xml => thumb_cozycloud.xml} (100%) rename app/src/main/res/drawable/{ic_digital_ocean.xml => thumb_digital_ocean.xml} (100%) rename app/src/main/res/drawable/{ic_discord.xml => thumb_discord.xml} (100%) rename app/src/main/res/drawable/{ic_dropbox.xml => thumb_dropbox.xml} (100%) rename app/src/main/res/drawable/{ic_facebook.xml => thumb_facebook.xml} (100%) rename app/src/main/res/drawable/{ic_git.xml => thumb_git.xml} (100%) rename app/src/main/res/drawable/{ic_github.xml => thumb_github.xml} (100%) rename app/src/main/res/drawable/{ic_gitlab.xml => thumb_gitlab.xml} (100%) rename app/src/main/res/drawable/{ic_google.xml => thumb_google.xml} (100%) rename app/src/main/res/drawable/{ic_ifttt.xml => thumb_ifttt.xml} (100%) rename app/src/main/res/drawable/{ic_kickstarter.xml => thumb_kickstarter.xml} (100%) rename app/src/main/res/drawable/{ic_lastpass.xml => thumb_lastpass.xml} (100%) rename app/src/main/res/drawable/{ic_mailgun.xml => thumb_mailgun.xml} (100%) rename app/src/main/res/drawable/{ic_mastodon.xml => thumb_mastodon.xml} (100%) rename app/src/main/res/drawable/{ic_microsoft.xml => thumb_microsoft.xml} (100%) rename app/src/main/res/drawable/{ic_nextcloud.xml => thumb_nextcloud.xml} (100%) rename app/src/main/res/drawable/{ic_origin.xml => thumb_origin.xml} (100%) rename app/src/main/res/drawable/{ic_paypal.xml => thumb_paypal.xml} (100%) rename app/src/main/res/drawable/{ic_protonmail.xml => thumb_protonmail.xml} (100%) rename app/src/main/res/drawable/{ic_rss.xml => thumb_rss.xml} (100%) rename app/src/main/res/drawable/{ic_slack.xml => thumb_slack.xml} (100%) rename app/src/main/res/drawable/{ic_steam.xml => thumb_steam.xml} (100%) rename app/src/main/res/drawable/{ic_stripe.xml => thumb_stripe.xml} (100%) rename app/src/main/res/drawable/{ic_twitch.xml => thumb_twitch.xml} (100%) rename app/src/main/res/drawable/{ic_twitter.xml => thumb_twitter.xml} (100%) rename app/src/main/res/drawable/{ic_wordpress.xml => thumb_wordpress.xml} (100%) rename app/src/main/res/mipmap-xhdpi/{bitstamp.png => thumb_bitstamp.png} (100%) rename app/src/main/res/mipmap-xhdpi/{bitwarden.png => thumb_bitwarden.png} (100%) 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 1a7ba12a..9a39b773 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 @@ -16,43 +16,43 @@ public class EntryThumbnail { public enum EntryThumbnails { Default(R.mipmap.ic_launcher_round), - Amazon(R.drawable.ic_amazon), - AmazonWebServices(R.drawable.ic_amazonwebservices), - AngelList(R.drawable.ic_angellist), - Apple(R.drawable.ic_apple), - BattleNet(R.drawable.ic_battlenet), - BitBucket(R.drawable.ic_bitbucket), - Bitcoin(R.drawable.ic_bitcoin), - Bitstamp(R.mipmap.bitstamp, AssetType.Bitmap), - Bitwarden(R.mipmap.bitwarden, AssetType.Bitmap), - Cloudflare(R.drawable.ic_cloudflare), - Coinbase(R.drawable.ic_coinbase), - CozyCloud(R.drawable.ic_cozycloud), - DigitalOcean(R.drawable.ic_digital_ocean), - Discord(R.drawable.ic_discord), - Dropbox(R.drawable.ic_dropbox), - Facebook(R.drawable.ic_facebook), - Git(R.drawable.ic_git), - Github(R.drawable.ic_github), - Gitlab(R.drawable.ic_gitlab), - Google(R.drawable.ic_google), - IFTTT(R.drawable.ic_ifttt), - Kickstarter(R.drawable.ic_kickstarter), - LastPass(R.drawable.ic_lastpass), - Mailgun(R.drawable.ic_mailgun), - Mastodon(R.drawable.ic_mastodon), - Microsoft(R.drawable.ic_microsoft), - NextCloud(R.drawable.ic_nextcloud), - Origin(R.drawable.ic_origin), - PayPal(R.drawable.ic_paypal), - ProtonMail(R.drawable.ic_protonmail), - RSS(R.drawable.ic_rss), - Slack(R.drawable.ic_slack), - Steam(R.drawable.ic_steam), - Stripe(R.drawable.ic_stripe), - Twitch(R.drawable.ic_twitch), - Twitter(R.drawable.ic_twitter), - Wordpress(R.drawable.ic_wordpress); + Amazon(R.drawable.thumb_amazon), + AmazonWebServices(R.drawable.thumb_amazonwebservices), + AngelList(R.drawable.thumb_angellist), + Apple(R.drawable.thumb_apple), + BattleNet(R.drawable.thumb_battlenet), + BitBucket(R.drawable.thumb_bitbucket), + Bitcoin(R.drawable.thumb_bitcoin), + Bitstamp(R.mipmap.thumb_bitstamp, AssetType.Bitmap), + Bitwarden(R.mipmap.thumb_bitwarden, AssetType.Bitmap), + Cloudflare(R.drawable.thumb_cloudflare), + Coinbase(R.drawable.thumb_coinbase), + CozyCloud(R.drawable.thumb_cozycloud), + DigitalOcean(R.drawable.thumb_digital_ocean), + Discord(R.drawable.thumb_discord), + Dropbox(R.drawable.thumb_dropbox), + Facebook(R.drawable.thumb_facebook), + Git(R.drawable.thumb_git), + Github(R.drawable.thumb_github), + Gitlab(R.drawable.thumb_gitlab), + Google(R.drawable.thumb_google), + IFTTT(R.drawable.thumb_ifttt), + Kickstarter(R.drawable.thumb_kickstarter), + LastPass(R.drawable.thumb_lastpass), + Mailgun(R.drawable.thumb_mailgun), + Mastodon(R.drawable.thumb_mastodon), + Microsoft(R.drawable.thumb_microsoft), + NextCloud(R.drawable.thumb_nextcloud), + Origin(R.drawable.thumb_origin), + PayPal(R.drawable.thumb_paypal), + ProtonMail(R.drawable.thumb_protonmail), + RSS(R.drawable.thumb_rss), + Slack(R.drawable.thumb_slack), + Steam(R.drawable.thumb_steam), + Stripe(R.drawable.thumb_stripe), + Twitch(R.drawable.thumb_twitch), + Twitter(R.drawable.thumb_twitter), + Wordpress(R.drawable.thumb_wordpress); private int resource; private AssetType assetType; diff --git a/app/src/main/res/drawable/ic_amazon.xml b/app/src/main/res/drawable/thumb_amazon.xml similarity index 100% rename from app/src/main/res/drawable/ic_amazon.xml rename to app/src/main/res/drawable/thumb_amazon.xml diff --git a/app/src/main/res/drawable/ic_amazonwebservices.xml b/app/src/main/res/drawable/thumb_amazonwebservices.xml similarity index 100% rename from app/src/main/res/drawable/ic_amazonwebservices.xml rename to app/src/main/res/drawable/thumb_amazonwebservices.xml diff --git a/app/src/main/res/drawable/ic_angellist.xml b/app/src/main/res/drawable/thumb_angellist.xml similarity index 100% rename from app/src/main/res/drawable/ic_angellist.xml rename to app/src/main/res/drawable/thumb_angellist.xml diff --git a/app/src/main/res/drawable/ic_apple.xml b/app/src/main/res/drawable/thumb_apple.xml similarity index 100% rename from app/src/main/res/drawable/ic_apple.xml rename to app/src/main/res/drawable/thumb_apple.xml diff --git a/app/src/main/res/drawable/ic_battlenet.xml b/app/src/main/res/drawable/thumb_battlenet.xml similarity index 100% rename from app/src/main/res/drawable/ic_battlenet.xml rename to app/src/main/res/drawable/thumb_battlenet.xml diff --git a/app/src/main/res/drawable/ic_bitbucket.xml b/app/src/main/res/drawable/thumb_bitbucket.xml similarity index 100% rename from app/src/main/res/drawable/ic_bitbucket.xml rename to app/src/main/res/drawable/thumb_bitbucket.xml diff --git a/app/src/main/res/drawable/ic_bitcoin.xml b/app/src/main/res/drawable/thumb_bitcoin.xml similarity index 100% rename from app/src/main/res/drawable/ic_bitcoin.xml rename to app/src/main/res/drawable/thumb_bitcoin.xml diff --git a/app/src/main/res/drawable/ic_cloudflare.xml b/app/src/main/res/drawable/thumb_cloudflare.xml similarity index 100% rename from app/src/main/res/drawable/ic_cloudflare.xml rename to app/src/main/res/drawable/thumb_cloudflare.xml diff --git a/app/src/main/res/drawable/ic_coinbase.xml b/app/src/main/res/drawable/thumb_coinbase.xml similarity index 100% rename from app/src/main/res/drawable/ic_coinbase.xml rename to app/src/main/res/drawable/thumb_coinbase.xml diff --git a/app/src/main/res/drawable/ic_cozycloud.xml b/app/src/main/res/drawable/thumb_cozycloud.xml similarity index 100% rename from app/src/main/res/drawable/ic_cozycloud.xml rename to app/src/main/res/drawable/thumb_cozycloud.xml diff --git a/app/src/main/res/drawable/ic_digital_ocean.xml b/app/src/main/res/drawable/thumb_digital_ocean.xml similarity index 100% rename from app/src/main/res/drawable/ic_digital_ocean.xml rename to app/src/main/res/drawable/thumb_digital_ocean.xml diff --git a/app/src/main/res/drawable/ic_discord.xml b/app/src/main/res/drawable/thumb_discord.xml similarity index 100% rename from app/src/main/res/drawable/ic_discord.xml rename to app/src/main/res/drawable/thumb_discord.xml diff --git a/app/src/main/res/drawable/ic_dropbox.xml b/app/src/main/res/drawable/thumb_dropbox.xml similarity index 100% rename from app/src/main/res/drawable/ic_dropbox.xml rename to app/src/main/res/drawable/thumb_dropbox.xml diff --git a/app/src/main/res/drawable/ic_facebook.xml b/app/src/main/res/drawable/thumb_facebook.xml similarity index 100% rename from app/src/main/res/drawable/ic_facebook.xml rename to app/src/main/res/drawable/thumb_facebook.xml diff --git a/app/src/main/res/drawable/ic_git.xml b/app/src/main/res/drawable/thumb_git.xml similarity index 100% rename from app/src/main/res/drawable/ic_git.xml rename to app/src/main/res/drawable/thumb_git.xml diff --git a/app/src/main/res/drawable/ic_github.xml b/app/src/main/res/drawable/thumb_github.xml similarity index 100% rename from app/src/main/res/drawable/ic_github.xml rename to app/src/main/res/drawable/thumb_github.xml diff --git a/app/src/main/res/drawable/ic_gitlab.xml b/app/src/main/res/drawable/thumb_gitlab.xml similarity index 100% rename from app/src/main/res/drawable/ic_gitlab.xml rename to app/src/main/res/drawable/thumb_gitlab.xml diff --git a/app/src/main/res/drawable/ic_google.xml b/app/src/main/res/drawable/thumb_google.xml similarity index 100% rename from app/src/main/res/drawable/ic_google.xml rename to app/src/main/res/drawable/thumb_google.xml diff --git a/app/src/main/res/drawable/ic_ifttt.xml b/app/src/main/res/drawable/thumb_ifttt.xml similarity index 100% rename from app/src/main/res/drawable/ic_ifttt.xml rename to app/src/main/res/drawable/thumb_ifttt.xml diff --git a/app/src/main/res/drawable/ic_kickstarter.xml b/app/src/main/res/drawable/thumb_kickstarter.xml similarity index 100% rename from app/src/main/res/drawable/ic_kickstarter.xml rename to app/src/main/res/drawable/thumb_kickstarter.xml diff --git a/app/src/main/res/drawable/ic_lastpass.xml b/app/src/main/res/drawable/thumb_lastpass.xml similarity index 100% rename from app/src/main/res/drawable/ic_lastpass.xml rename to app/src/main/res/drawable/thumb_lastpass.xml diff --git a/app/src/main/res/drawable/ic_mailgun.xml b/app/src/main/res/drawable/thumb_mailgun.xml similarity index 100% rename from app/src/main/res/drawable/ic_mailgun.xml rename to app/src/main/res/drawable/thumb_mailgun.xml diff --git a/app/src/main/res/drawable/ic_mastodon.xml b/app/src/main/res/drawable/thumb_mastodon.xml similarity index 100% rename from app/src/main/res/drawable/ic_mastodon.xml rename to app/src/main/res/drawable/thumb_mastodon.xml diff --git a/app/src/main/res/drawable/ic_microsoft.xml b/app/src/main/res/drawable/thumb_microsoft.xml similarity index 100% rename from app/src/main/res/drawable/ic_microsoft.xml rename to app/src/main/res/drawable/thumb_microsoft.xml diff --git a/app/src/main/res/drawable/ic_nextcloud.xml b/app/src/main/res/drawable/thumb_nextcloud.xml similarity index 100% rename from app/src/main/res/drawable/ic_nextcloud.xml rename to app/src/main/res/drawable/thumb_nextcloud.xml diff --git a/app/src/main/res/drawable/ic_origin.xml b/app/src/main/res/drawable/thumb_origin.xml similarity index 100% rename from app/src/main/res/drawable/ic_origin.xml rename to app/src/main/res/drawable/thumb_origin.xml diff --git a/app/src/main/res/drawable/ic_paypal.xml b/app/src/main/res/drawable/thumb_paypal.xml similarity index 100% rename from app/src/main/res/drawable/ic_paypal.xml rename to app/src/main/res/drawable/thumb_paypal.xml diff --git a/app/src/main/res/drawable/ic_protonmail.xml b/app/src/main/res/drawable/thumb_protonmail.xml similarity index 100% rename from app/src/main/res/drawable/ic_protonmail.xml rename to app/src/main/res/drawable/thumb_protonmail.xml diff --git a/app/src/main/res/drawable/ic_rss.xml b/app/src/main/res/drawable/thumb_rss.xml similarity index 100% rename from app/src/main/res/drawable/ic_rss.xml rename to app/src/main/res/drawable/thumb_rss.xml diff --git a/app/src/main/res/drawable/ic_slack.xml b/app/src/main/res/drawable/thumb_slack.xml similarity index 100% rename from app/src/main/res/drawable/ic_slack.xml rename to app/src/main/res/drawable/thumb_slack.xml diff --git a/app/src/main/res/drawable/ic_steam.xml b/app/src/main/res/drawable/thumb_steam.xml similarity index 100% rename from app/src/main/res/drawable/ic_steam.xml rename to app/src/main/res/drawable/thumb_steam.xml diff --git a/app/src/main/res/drawable/ic_stripe.xml b/app/src/main/res/drawable/thumb_stripe.xml similarity index 100% rename from app/src/main/res/drawable/ic_stripe.xml rename to app/src/main/res/drawable/thumb_stripe.xml diff --git a/app/src/main/res/drawable/ic_twitch.xml b/app/src/main/res/drawable/thumb_twitch.xml similarity index 100% rename from app/src/main/res/drawable/ic_twitch.xml rename to app/src/main/res/drawable/thumb_twitch.xml diff --git a/app/src/main/res/drawable/ic_twitter.xml b/app/src/main/res/drawable/thumb_twitter.xml similarity index 100% rename from app/src/main/res/drawable/ic_twitter.xml rename to app/src/main/res/drawable/thumb_twitter.xml diff --git a/app/src/main/res/drawable/ic_wordpress.xml b/app/src/main/res/drawable/thumb_wordpress.xml similarity index 100% rename from app/src/main/res/drawable/ic_wordpress.xml rename to app/src/main/res/drawable/thumb_wordpress.xml diff --git a/app/src/main/res/mipmap-xhdpi/bitstamp.png b/app/src/main/res/mipmap-xhdpi/thumb_bitstamp.png similarity index 100% rename from app/src/main/res/mipmap-xhdpi/bitstamp.png rename to app/src/main/res/mipmap-xhdpi/thumb_bitstamp.png diff --git a/app/src/main/res/mipmap-xhdpi/bitwarden.png b/app/src/main/res/mipmap-xhdpi/thumb_bitwarden.png similarity index 100% rename from app/src/main/res/mipmap-xhdpi/bitwarden.png rename to app/src/main/res/mipmap-xhdpi/thumb_bitwarden.png From e44ff462292f01257bda885e1bfccb1518188cb6 Mon Sep 17 00:00:00 2001 From: RichyHBM Date: Thu, 30 Nov 2017 07:35:30 +0000 Subject: [PATCH 15/15] Use real index for thumbnail selection --- .../org/shadowice/flocke/andotp/View/EntriesCardAdapter.java | 3 ++- .../flocke/andotp/View/ThumbnailSelectionAdapter.java | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) 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 88e37f40..f0d5499d 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 @@ -334,7 +334,8 @@ public class EntriesCardAdapter extends RecyclerView.Adapter int realIndex = getRealIndex(pos); EntryThumbnail.EntryThumbnails thumbnail = EntryThumbnail.EntryThumbnails.Default; try { - thumbnail = EntryThumbnail.EntryThumbnails.values()[position]; + int realPos = thumbnailAdapter.getRealIndex(position); + thumbnail = EntryThumbnail.EntryThumbnails.values()[realPos]; } catch (Exception e) { e.printStackTrace(); } diff --git a/app/src/main/java/org/shadowice/flocke/andotp/View/ThumbnailSelectionAdapter.java b/app/src/main/java/org/shadowice/flocke/andotp/View/ThumbnailSelectionAdapter.java index 04756c92..f9f9af15 100644 --- a/app/src/main/java/org/shadowice/flocke/andotp/View/ThumbnailSelectionAdapter.java +++ b/app/src/main/java/org/shadowice/flocke/andotp/View/ThumbnailSelectionAdapter.java @@ -52,6 +52,10 @@ public class ThumbnailSelectionAdapter extends BaseAdapter { return EntryThumbnail.EntryThumbnails.Default; } + public int getRealIndex(int displayPosition) { + return ((EntryThumbnail.EntryThumbnails)getItem(displayPosition)).ordinal(); + } + @Override public long getItemId(int i) { return ((EntryThumbnail.EntryThumbnails) getItem(i)).ordinal();