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 e0709bd5..7250e15e 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 @@ -110,6 +110,10 @@ public class Settings { return context.getString(resId); } + private int getResInt(int resId) { + return context.getResources().getInteger(resId); + } + private String getString(int keyId, int defaultId) { return settings.getString(getResString(keyId), getResString(defaultId)); } @@ -122,6 +126,10 @@ public class Settings { return settings.getBoolean(getResString(keyId), defaultValue); } + private int getInt(int keyId, int defaultId) { + return settings.getInt(getResString(keyId), getResInt(defaultId)); + } + private long getLong(int keyId, long defaultValue) { return settings.getLong(getResString(keyId), defaultValue); } @@ -189,6 +197,10 @@ public class Settings { + public boolean getTapToReveal() { + return getBoolean(R.string.settings_key_tap_to_reveal, false); + } + public AuthMethod getAuthMethod() { String authString = getString(R.string.settings_key_auth, R.string.settings_default_auth); return AuthMethod.valueOf(authString.toUpperCase()); @@ -227,6 +239,10 @@ public class Settings { return getString(R.string.settings_key_theme, R.string.settings_default_theme); } + public int getLabelSize() { + return getInt(R.string.settings_key_label_size, R.integer.settings_default_label_size); + } + public boolean getScrollLabel() { return getBoolean(R.string.settings_key_label_scroll, false); } 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 b67f6fda..e1b6c3bd 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 @@ -27,8 +27,6 @@ import android.content.ClipData; import android.content.ClipboardManager; import android.content.Context; import android.content.DialogInterface; -import android.content.SharedPreferences; -import android.preference.PreferenceManager; import android.support.v7.widget.PopupMenu; import android.support.v7.widget.RecyclerView; import android.text.Editable; @@ -69,7 +67,6 @@ import static org.shadowice.flocke.andotp.Utilities.Settings.SortMode; public class EntriesCardAdapter extends RecyclerView.Adapter implements ItemTouchHelperAdapter, Filterable { private Context context; - private SharedPreferences sharedPrefs; private EntryFilter filter; private ArrayList entries; private ArrayList displayedEntries; @@ -82,7 +79,6 @@ public class EntriesCardAdapter extends RecyclerView.Adapter public EntriesCardAdapter(Context context, TagsAdapter tagsFilterAdapter) { this.context = context; - this.sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context); this.tagsFilterAdapter = tagsFilterAdapter; this.settings = new Settings(context); loadEntries(); @@ -168,19 +164,15 @@ public class EntriesCardAdapter extends RecyclerView.Adapter entryViewHolder.hideCustomPeriod(); } - if (sharedPrefs.getBoolean(context.getString(R.string.settings_key_tap_to_reveal), false)) { + if (settings.getTapToReveal()) { entryViewHolder.enableTapToReveal(); } else { entryViewHolder.disableTapToReveal(); } - 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)); + entryViewHolder.setLabelSize(settings.getLabelSize()); + entryViewHolder.setThumbnailSize(settings.getThumbnailSize()); + entryViewHolder.setLabelScroll(settings.getScrollLabel()); } @Override