Use Settings in EntriesCardAdapter
This commit is contained in:
parent
5fb3666dfd
commit
acadf4f369
2 changed files with 20 additions and 12 deletions
|
@ -110,6 +110,10 @@ public class Settings {
|
||||||
return context.getString(resId);
|
return context.getString(resId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int getResInt(int resId) {
|
||||||
|
return context.getResources().getInteger(resId);
|
||||||
|
}
|
||||||
|
|
||||||
private String getString(int keyId, int defaultId) {
|
private String getString(int keyId, int defaultId) {
|
||||||
return settings.getString(getResString(keyId), getResString(defaultId));
|
return settings.getString(getResString(keyId), getResString(defaultId));
|
||||||
}
|
}
|
||||||
|
@ -122,6 +126,10 @@ public class Settings {
|
||||||
return settings.getBoolean(getResString(keyId), defaultValue);
|
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) {
|
private long getLong(int keyId, long defaultValue) {
|
||||||
return settings.getLong(getResString(keyId), 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() {
|
public AuthMethod getAuthMethod() {
|
||||||
String authString = getString(R.string.settings_key_auth, R.string.settings_default_auth);
|
String authString = getString(R.string.settings_key_auth, R.string.settings_default_auth);
|
||||||
return AuthMethod.valueOf(authString.toUpperCase());
|
return AuthMethod.valueOf(authString.toUpperCase());
|
||||||
|
@ -227,6 +239,10 @@ public class Settings {
|
||||||
return getString(R.string.settings_key_theme, R.string.settings_default_theme);
|
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() {
|
public boolean getScrollLabel() {
|
||||||
return getBoolean(R.string.settings_key_label_scroll, false);
|
return getBoolean(R.string.settings_key_label_scroll, false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,8 +27,6 @@ import android.content.ClipData;
|
||||||
import android.content.ClipboardManager;
|
import android.content.ClipboardManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.preference.PreferenceManager;
|
|
||||||
import android.support.v7.widget.PopupMenu;
|
import android.support.v7.widget.PopupMenu;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
|
@ -69,7 +67,6 @@ import static org.shadowice.flocke.andotp.Utilities.Settings.SortMode;
|
||||||
public class EntriesCardAdapter extends RecyclerView.Adapter<EntryViewHolder>
|
public class EntriesCardAdapter extends RecyclerView.Adapter<EntryViewHolder>
|
||||||
implements ItemTouchHelperAdapter, Filterable {
|
implements ItemTouchHelperAdapter, Filterable {
|
||||||
private Context context;
|
private Context context;
|
||||||
private SharedPreferences sharedPrefs;
|
|
||||||
private EntryFilter filter;
|
private EntryFilter filter;
|
||||||
private ArrayList<Entry> entries;
|
private ArrayList<Entry> entries;
|
||||||
private ArrayList<Entry> displayedEntries;
|
private ArrayList<Entry> displayedEntries;
|
||||||
|
@ -82,7 +79,6 @@ public class EntriesCardAdapter extends RecyclerView.Adapter<EntryViewHolder>
|
||||||
|
|
||||||
public EntriesCardAdapter(Context context, TagsAdapter tagsFilterAdapter) {
|
public EntriesCardAdapter(Context context, TagsAdapter tagsFilterAdapter) {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
this.sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
|
|
||||||
this.tagsFilterAdapter = tagsFilterAdapter;
|
this.tagsFilterAdapter = tagsFilterAdapter;
|
||||||
this.settings = new Settings(context);
|
this.settings = new Settings(context);
|
||||||
loadEntries();
|
loadEntries();
|
||||||
|
@ -168,19 +164,15 @@ public class EntriesCardAdapter extends RecyclerView.Adapter<EntryViewHolder>
|
||||||
entryViewHolder.hideCustomPeriod();
|
entryViewHolder.hideCustomPeriod();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sharedPrefs.getBoolean(context.getString(R.string.settings_key_tap_to_reveal), false)) {
|
if (settings.getTapToReveal()) {
|
||||||
entryViewHolder.enableTapToReveal();
|
entryViewHolder.enableTapToReveal();
|
||||||
} else {
|
} else {
|
||||||
entryViewHolder.disableTapToReveal();
|
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(settings.getLabelSize());
|
||||||
entryViewHolder.setLabelSize(fontSize);
|
entryViewHolder.setThumbnailSize(settings.getThumbnailSize());
|
||||||
|
entryViewHolder.setLabelScroll(settings.getScrollLabel());
|
||||||
int thumbnailSize = settings.getThumbnailSize();
|
|
||||||
entryViewHolder.setThumbnailSize(thumbnailSize);
|
|
||||||
|
|
||||||
entryViewHolder.setLabelScroll(sharedPrefs.getBoolean(context.getString(R.string.settings_key_label_scroll), false));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue