Merge pull request #1013 from orange-elephant/no-icons-view-mode

Add 'No Icons' view mode
This commit is contained in:
Alexander Bakker 2022-11-20 18:36:42 +01:00 committed by GitHub
commit 01e59d79a1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 52 additions and 9 deletions

View file

@ -120,6 +120,10 @@ public class Preferences {
return _prefs.getBoolean("pref_account_name", true); return _prefs.getBoolean("pref_account_name", true);
} }
public boolean isIconVisible() {
return _prefs.getBoolean("pref_show_icons", true);
}
public CodeGrouping getCodeGroupSize() { public CodeGrouping getCodeGroupSize() {
String value = _prefs.getString("pref_code_group_size_string", "GROUPING_THREES"); String value = _prefs.getString("pref_code_group_size_string", "GROUPING_THREES");

View file

@ -129,6 +129,7 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
_entryListView.setListener(this); _entryListView.setListener(this);
_entryListView.setCodeGroupSize(_prefs.getCodeGroupSize()); _entryListView.setCodeGroupSize(_prefs.getCodeGroupSize());
_entryListView.setShowAccountName(_prefs.isAccountNameVisible()); _entryListView.setShowAccountName(_prefs.isAccountNameVisible());
_entryListView.setShowIcon(_prefs.isIconVisible());
_entryListView.setHighlightEntry(_prefs.isEntryHighlightEnabled()); _entryListView.setHighlightEntry(_prefs.isEntryHighlightEnabled());
_entryListView.setPauseFocused(_prefs.isPauseFocusedEnabled()); _entryListView.setPauseFocused(_prefs.isPauseFocusedEnabled());
_entryListView.setTapToReveal(_prefs.isTapToRevealEnabled()); _entryListView.setTapToReveal(_prefs.isTapToRevealEnabled());
@ -266,6 +267,7 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
recreate(); recreate();
} else if (data.getBooleanExtra("needsRefresh", false)) { } else if (data.getBooleanExtra("needsRefresh", false)) {
boolean showAccountName = _prefs.isAccountNameVisible(); boolean showAccountName = _prefs.isAccountNameVisible();
boolean showIcons = _prefs.isIconVisible();
Preferences.CodeGrouping codeGroupSize = _prefs.getCodeGroupSize(); Preferences.CodeGrouping codeGroupSize = _prefs.getCodeGroupSize();
boolean highlightEntry = _prefs.isEntryHighlightEnabled(); boolean highlightEntry = _prefs.isEntryHighlightEnabled();
boolean pauseFocused = _prefs.isPauseFocusedEnabled(); boolean pauseFocused = _prefs.isPauseFocusedEnabled();
@ -274,6 +276,7 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
ViewMode viewMode = _prefs.getCurrentViewMode(); ViewMode viewMode = _prefs.getCurrentViewMode();
boolean copyOnTap = _prefs.isCopyOnTapEnabled(); boolean copyOnTap = _prefs.isCopyOnTapEnabled();
_entryListView.setShowAccountName(showAccountName); _entryListView.setShowAccountName(showAccountName);
_entryListView.setShowIcon(showIcons);
_entryListView.setCodeGroupSize(codeGroupSize); _entryListView.setCodeGroupSize(codeGroupSize);
_entryListView.setHighlightEntry(highlightEntry); _entryListView.setHighlightEntry(highlightEntry);
_entryListView.setPauseFocused(pauseFocused); _entryListView.setPauseFocused(pauseFocused);

View file

@ -109,5 +109,11 @@ public class AppearancePreferencesFragment extends PreferencesFragment {
getResult().putExtra("needsRefresh", true); getResult().putExtra("needsRefresh", true);
return true; return true;
}); });
Preference showIconsPreference = requirePreference("pref_show_icons");
showIconsPreference.setOnPreferenceChangeListener((preference, newValue) -> {
getResult().putExtra("needsRefresh", true);
return true;
});
} }
} }

View file

@ -45,6 +45,7 @@ public class EntryAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
private VaultEntry _focusedEntry; private VaultEntry _focusedEntry;
private Preferences.CodeGrouping _codeGroupSize; private Preferences.CodeGrouping _codeGroupSize;
private boolean _showAccountName; private boolean _showAccountName;
private boolean _showIcon;
private boolean _highlightEntry; private boolean _highlightEntry;
private boolean _tempHighlightEntry; private boolean _tempHighlightEntry;
private boolean _tapToReveal; private boolean _tapToReveal;
@ -88,6 +89,10 @@ public class EntryAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
_showAccountName = showAccountName; _showAccountName = showAccountName;
} }
public void setShowIcon(boolean showIcon) {
_showIcon = showIcon;
}
public void setTapToReveal(boolean tapToReveal) { public void setTapToReveal(boolean tapToReveal) {
_tapToReveal = tapToReveal; _tapToReveal = tapToReveal;
} }
@ -257,6 +262,7 @@ public class EntryAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
} else { } else {
for (EntryHolder holder : _holders) { for (EntryHolder holder : _holders) {
holder.refresh(); holder.refresh();
holder.showIcon(_showIcon);
} }
} }
} }
@ -375,13 +381,11 @@ public class EntryAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
RecyclerView.ViewHolder holder; RecyclerView.ViewHolder holder;
View view = inflater.inflate(viewType, parent, false); View view = inflater.inflate(viewType, parent, false);
if (viewType == R.layout.card_footer) { holder = viewType == R.layout.card_footer ? new FooterView(view) : new EntryHolder(view);
holder = new FooterView(view); if (_showIcon && holder instanceof EntryHolder) {
} else { _view.setPreloadView(((EntryHolder) holder).getIconView());
EntryHolder entryHolder = new EntryHolder(view);
_view.setPreloadView(entryHolder.getIconView());
holder = entryHolder;
} }
return holder; return holder;
} }
@ -403,9 +407,12 @@ public class EntryAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
boolean paused = _pauseFocused && entry == _focusedEntry; boolean paused = _pauseFocused && entry == _focusedEntry;
boolean dimmed = (_highlightEntry || _tempHighlightEntry) && _focusedEntry != null && _focusedEntry != entry; boolean dimmed = (_highlightEntry || _tempHighlightEntry) && _focusedEntry != null && _focusedEntry != entry;
boolean showProgress = entry.getInfo() instanceof TotpInfo && ((TotpInfo) entry.getInfo()).getPeriod() != getMostFrequentPeriod(); boolean showProgress = entry.getInfo() instanceof TotpInfo && ((TotpInfo) entry.getInfo()).getPeriod() != getMostFrequentPeriod();
entryHolder.setData(entry, _codeGroupSize, _showAccountName, showProgress, hidden, paused, dimmed); entryHolder.setData(entry, _codeGroupSize, _showAccountName, _showIcon, showProgress, hidden, paused, dimmed);
entryHolder.setFocused(_selectedEntries.contains(entry)); entryHolder.setFocused(_selectedEntries.contains(entry));
entryHolder.loadIcon(_view);
if (_showIcon) {
entryHolder.loadIcon(_view);
}
entryHolder.itemView.setOnClickListener(new View.OnClickListener() { entryHolder.itemView.setOnClickListener(new View.OnClickListener() {
@Override @Override

View file

@ -105,7 +105,7 @@ public class EntryHolder extends RecyclerView.ViewHolder {
}); });
} }
public void setData(VaultEntry entry, Preferences.CodeGrouping groupSize, boolean showAccountName, boolean showProgress, boolean hidden, boolean paused, boolean dimmed) { public void setData(VaultEntry entry, Preferences.CodeGrouping groupSize, boolean showAccountName, boolean showIcon, boolean showProgress, boolean hidden, boolean paused, boolean dimmed) {
_entry = entry; _entry = entry;
_hidden = hidden; _hidden = hidden;
_paused = paused; _paused = paused;
@ -138,6 +138,8 @@ public class EntryHolder extends RecyclerView.ViewHolder {
refreshCode(); refreshCode();
} }
showIcon(showIcon);
itemView.setAlpha(dimmed ? DIMMED_ALPHA : DEFAULT_ALPHA); itemView.setAlpha(dimmed ? DIMMED_ALPHA : DEFAULT_ALPHA);
} }
@ -298,6 +300,14 @@ public class EntryHolder extends RecyclerView.ViewHolder {
_hidden = true; _hidden = true;
} }
public void showIcon(boolean show) {
if (show) {
_profileDrawable.setVisibility(View.VISIBLE);
} else {
_profileDrawable.setVisibility(View.GONE);
}
}
public void setPaused(boolean paused) { public void setPaused(boolean paused) {
_paused = paused; _paused = paused;

View file

@ -297,6 +297,10 @@ public class EntryListView extends Fragment implements EntryAdapter.Listener {
_adapter.setShowAccountName(showAccountName); _adapter.setShowAccountName(showAccountName);
} }
public void setShowIcon(boolean showIcon) {
_adapter.setShowIcon(showIcon);
}
public void setHighlightEntry(boolean highlightEntry) { public void setHighlightEntry(boolean highlightEntry) {
_adapter.setHighlightEntry(highlightEntry); _adapter.setHighlightEntry(highlightEntry);
} }

View file

@ -38,6 +38,8 @@
<string name="pref_select_theme_title">Theme</string> <string name="pref_select_theme_title">Theme</string>
<string name="pref_view_mode_title">View mode</string> <string name="pref_view_mode_title">View mode</string>
<string name="pref_lang_title">Language</string> <string name="pref_lang_title">Language</string>
<string name="pref_show_icons_title">Show icons</string>
<string name="pref_show_icons_summary">Display icons next to each entry</string>
<string name="pref_code_group_size_title">Code digit grouping</string> <string name="pref_code_group_size_title">Code digit grouping</string>
<string name="pref_code_group_size_summary">Select number of digits to group codes by</string> <string name="pref_code_group_size_summary">Select number of digits to group codes by</string>
<string name="pref_account_name_title">Show the account name</string> <string name="pref_account_name_title">Show the account name</string>

View file

@ -30,6 +30,13 @@
android:title="@string/pref_view_mode_title" android:title="@string/pref_view_mode_title"
app:iconSpaceReserved="false"/> app:iconSpaceReserved="false"/>
<androidx.preference.SwitchPreferenceCompat
android:defaultValue="true"
android:key="pref_show_icons"
android:title="@string/pref_show_icons_title"
android:summary="@string/pref_show_icons_summary"
app:iconSpaceReserved="false"/>
<ListPreference <ListPreference
android:key="pref_code_group_size_string" android:key="pref_code_group_size_string"
android:title="@string/pref_code_group_size_title" android:title="@string/pref_code_group_size_title"