mirror of
https://github.com/beemdevelopment/Aegis.git
synced 2025-05-15 22:42:51 +00:00
Make the behavior of highlighting and revealing entries consistent
I think this makes the highlight/reveal functionality feel a bit more consistent, by not allowing multiple entries to be revealed at the same time, just like you can't have multiple highlighted entries. Here's video of what it looks like: https://alexbakker.me/u/3a9dhplrj2.mp4.
This commit is contained in:
parent
a93ced6e34
commit
a6a5af781e
2 changed files with 41 additions and 47 deletions
|
@ -27,7 +27,7 @@ public class EntryAdapter extends RecyclerView.Adapter<EntryHolder> implements I
|
|||
private List<DatabaseEntry> _entries;
|
||||
private List<DatabaseEntry> _shownEntries;
|
||||
private DatabaseEntry _selectedEntry;
|
||||
private DatabaseEntry _highlightedEntry;
|
||||
private DatabaseEntry _focusedEntry;
|
||||
private boolean _showAccountName;
|
||||
private boolean _searchAccountName;
|
||||
private boolean _highlightEntry;
|
||||
|
@ -304,10 +304,10 @@ public class EntryAdapter extends RecyclerView.Adapter<EntryHolder> implements I
|
|||
DatabaseEntry entry = _shownEntries.get(position);
|
||||
holder.setFocused(entry == _selectedEntry);
|
||||
|
||||
boolean dimmed = _highlightedEntry != null && _highlightedEntry != entry;
|
||||
boolean hidden = _tapToReveal && entry != _focusedEntry;
|
||||
boolean dimmed = _highlightEntry && _focusedEntry != null && _focusedEntry != entry;
|
||||
boolean showProgress = !isPeriodUniform() && entry.getInfo() instanceof TotpInfo;
|
||||
holder.setData(entry, _showAccountName, showProgress, _tapToReveal, dimmed);
|
||||
holder.setTapToRevealTime(_tapToRevealTime);
|
||||
holder.setData(entry, _showAccountName, showProgress, hidden, dimmed);
|
||||
holder.loadIcon(_view);
|
||||
|
||||
holder.itemView.setOnClickListener(new View.OnClickListener() {
|
||||
|
@ -316,16 +316,12 @@ public class EntryAdapter extends RecyclerView.Adapter<EntryHolder> implements I
|
|||
boolean handled = false;
|
||||
|
||||
if (_selectedEntry == null) {
|
||||
if (_tapToReveal && holder.isCodeHidden()) {
|
||||
holder.revealCode();
|
||||
}
|
||||
|
||||
if (_highlightEntry) {
|
||||
if (_highlightedEntry == entry) {
|
||||
resetHighlight();
|
||||
if (_highlightEntry || _tapToReveal) {
|
||||
if (_focusedEntry == entry) {
|
||||
resetFocus();
|
||||
handled = true;
|
||||
} else {
|
||||
highlightEntry(entry);
|
||||
focusEntry(entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -410,34 +406,49 @@ public class EntryAdapter extends RecyclerView.Adapter<EntryHolder> implements I
|
|||
return period;
|
||||
}
|
||||
|
||||
private void highlightEntry(DatabaseEntry entry) {
|
||||
_highlightedEntry = entry;
|
||||
private void focusEntry(DatabaseEntry entry) {
|
||||
_focusedEntry = entry;
|
||||
_dimHandler.removeCallbacksAndMessages(null);
|
||||
|
||||
for (EntryHolder holder : _holders) {
|
||||
if (holder.getEntry() != _highlightedEntry) {
|
||||
if (holder.getEntry() != _focusedEntry) {
|
||||
if (_highlightEntry) {
|
||||
holder.dim();
|
||||
}
|
||||
if (_tapToReveal) {
|
||||
holder.hideCode();
|
||||
}
|
||||
} else {
|
||||
if (_highlightEntry) {
|
||||
holder.highlight();
|
||||
}
|
||||
if (_tapToReveal) {
|
||||
holder.revealCode();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_dimHandler.postDelayed(this::resetHighlight, _tapToRevealTime * 1000);
|
||||
_dimHandler.postDelayed(this::resetFocus, _tapToRevealTime * 1000);
|
||||
}
|
||||
|
||||
private void resetHighlight() {
|
||||
_highlightedEntry = null;
|
||||
|
||||
private void resetFocus() {
|
||||
for (EntryHolder holder : _holders) {
|
||||
if (_highlightEntry) {
|
||||
holder.highlight();
|
||||
}
|
||||
if (_tapToReveal) {
|
||||
holder.hideCode();
|
||||
}
|
||||
}
|
||||
|
||||
_focusedEntry = null;
|
||||
}
|
||||
|
||||
public void setSelectedEntry(DatabaseEntry entry) {
|
||||
if (entry == null) {
|
||||
notifyItemChanged(_shownEntries.indexOf(_selectedEntry));
|
||||
} else if (_highlightEntry) {
|
||||
resetHighlight();
|
||||
resetFocus();
|
||||
}
|
||||
|
||||
_selectedEntry = entry;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package com.beemdevelopment.aegis.ui.views;
|
||||
|
||||
import android.graphics.PorterDuff;
|
||||
import android.os.Handler;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
@ -34,13 +33,11 @@ public class EntryHolder extends RecyclerView.ViewHolder {
|
|||
private ImageView _buttonRefresh;
|
||||
|
||||
private boolean _hidden;
|
||||
private int _tapToRevealTime;
|
||||
|
||||
private PeriodProgressBar _progressBar;
|
||||
private View _view;
|
||||
|
||||
private UiRefresher _refresher;
|
||||
private Handler _hiddenHandler;
|
||||
|
||||
public EntryHolder(final View view) {
|
||||
super(view);
|
||||
|
@ -61,7 +58,7 @@ public class EntryHolder extends RecyclerView.ViewHolder {
|
|||
_refresher = new UiRefresher(new UiRefresher.Listener() {
|
||||
@Override
|
||||
public void onRefresh() {
|
||||
if (!isCodeHidden()) {
|
||||
if (_hidden) {
|
||||
refreshCode();
|
||||
}
|
||||
|
||||
|
@ -73,8 +70,6 @@ public class EntryHolder extends RecyclerView.ViewHolder {
|
|||
return ((TotpInfo)_entry.getInfo()).getMillisTillNextRotation();
|
||||
}
|
||||
});
|
||||
|
||||
_hiddenHandler = new Handler();
|
||||
}
|
||||
|
||||
public void setData(DatabaseEntry entry, boolean showAccountName, boolean showProgress, boolean hidden, boolean dimmed) {
|
||||
|
@ -93,9 +88,6 @@ public class EntryHolder extends RecyclerView.ViewHolder {
|
|||
_profileName.setText(" - " + entry.getName());
|
||||
}
|
||||
|
||||
// cancel any scheduled hideCode calls
|
||||
_hiddenHandler.removeCallbacksAndMessages(null);
|
||||
|
||||
if (_hidden) {
|
||||
hideCode();
|
||||
} else {
|
||||
|
@ -127,10 +119,6 @@ public class EntryHolder extends RecyclerView.ViewHolder {
|
|||
return _profileDrawable;
|
||||
}
|
||||
|
||||
public void setTapToRevealTime(int number) {
|
||||
_tapToRevealTime = number;
|
||||
}
|
||||
|
||||
public void setOnRefreshClickListener(View.OnClickListener listener) {
|
||||
_buttonRefresh.setOnClickListener(listener);
|
||||
}
|
||||
|
@ -171,7 +159,7 @@ public class EntryHolder extends RecyclerView.ViewHolder {
|
|||
}
|
||||
|
||||
public void refreshCode() {
|
||||
if (!isCodeHidden()) {
|
||||
if (!_hidden) {
|
||||
updateCode();
|
||||
}
|
||||
}
|
||||
|
@ -196,10 +184,14 @@ public class EntryHolder extends RecyclerView.ViewHolder {
|
|||
|
||||
public void revealCode() {
|
||||
updateCode();
|
||||
_hiddenHandler.postDelayed(this::hideCode, _tapToRevealTime * 1000);
|
||||
_hidden = false;
|
||||
}
|
||||
|
||||
public void hideCode() {
|
||||
_profileCode.setText(R.string.tap_to_reveal);
|
||||
_hidden = true;
|
||||
}
|
||||
|
||||
public void dim() {
|
||||
animateAlphaTo(DIMMED_ALPHA);
|
||||
}
|
||||
|
@ -211,13 +203,4 @@ public class EntryHolder extends RecyclerView.ViewHolder {
|
|||
private void animateAlphaTo(float alpha) {
|
||||
itemView.animate().alpha(alpha).setDuration(200).start();
|
||||
}
|
||||
|
||||
private void hideCode() {
|
||||
_profileCode.setText(R.string.tap_to_reveal);
|
||||
_hidden = true;
|
||||
}
|
||||
|
||||
public boolean isCodeHidden() {
|
||||
return _hidden;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue