Added selection indicator in icon slot (#344)

Changed selection color for black theme


Changed indicator color to black secondary


Fix indicator flickering when scrolling


Applied patch


Fix unsharp selection icon


Add selection indicators to small and compact view
pull/368/head
orangenbaumblatt 5 years ago committed by GitHub
parent 8c0ba2dd1b
commit 7ce74d378f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -306,12 +306,12 @@ public class EntryAdapter extends RecyclerView.Adapter<EntryHolder> implements I
@Override @Override
public void onBindViewHolder(final EntryHolder holder, int position) { public void onBindViewHolder(final EntryHolder holder, int position) {
VaultEntry entry = _shownEntries.get(position); VaultEntry entry = _shownEntries.get(position);
holder.setFocused(_selectedEntries.contains(entry));
boolean hidden = _tapToReveal && entry != _focusedEntry; boolean hidden = _tapToReveal && entry != _focusedEntry;
boolean dimmed = _highlightEntry && _focusedEntry != null && _focusedEntry != entry; boolean dimmed = _highlightEntry && _focusedEntry != null && _focusedEntry != entry;
boolean showProgress = !isPeriodUniform() && entry.getInfo() instanceof TotpInfo; boolean showProgress = !isPeriodUniform() && entry.getInfo() instanceof TotpInfo;
holder.setData(entry, _showAccountName, showProgress, hidden, dimmed); holder.setData(entry, _showAccountName, showProgress, hidden, dimmed);
holder.setFocused(_selectedEntries.contains(entry));
holder.loadIcon(_view); holder.loadIcon(_view);
holder.itemView.setOnClickListener(new View.OnClickListener() { holder.itemView.setOnClickListener(new View.OnClickListener() {
@ -332,9 +332,9 @@ public class EntryAdapter extends RecyclerView.Adapter<EntryHolder> implements I
if (_selectedEntries.contains(entry)) { if (_selectedEntries.contains(entry)) {
_view.onDeselect(entry); _view.onDeselect(entry);
removeSelectedEntry(entry); removeSelectedEntry(entry);
holder.setFocused(false); holder.setFocusedAndAnimate(false);
} else { } else {
holder.setFocused(true); holder.setFocusedAndAnimate(true);
addSelectedEntry(entry); addSelectedEntry(entry);
_view.onSelect(entry); _view.onSelect(entry);
} }
@ -351,7 +351,7 @@ public class EntryAdapter extends RecyclerView.Adapter<EntryHolder> implements I
public boolean onLongClick(View v) { public boolean onLongClick(View v) {
int position = holder.getAdapterPosition(); int position = holder.getAdapterPosition();
if (_selectedEntries.isEmpty()) { if (_selectedEntries.isEmpty()) {
holder.setFocused(true); holder.setFocusedAndAnimate(true);
} }
return _view.onLongEntryClick(_shownEntries.get(position)); return _view.onLongEntryClick(_shownEntries.get(position));
@ -465,20 +465,26 @@ public class EntryAdapter extends RecyclerView.Adapter<EntryHolder> implements I
} }
public void addSelectedEntry(VaultEntry entry) { public void addSelectedEntry(VaultEntry entry) {
if (entry == null) { if (_highlightEntry) {
for (VaultEntry vaultEntry: _selectedEntries) {
notifyItemChanged(_shownEntries.indexOf(vaultEntry));
}
_selectedEntries.clear();
return;
} else if (_highlightEntry) {
resetFocus(); resetFocus();
} }
_selectedEntries.add(entry); _selectedEntries.add(entry);
} }
public void deselectAllEntries() {
for (VaultEntry entry: _selectedEntries) {
for (EntryHolder holder : _holders) {
if (holder.getEntry() == entry) {
holder.setFocusedAndAnimate(false);
break;
}
}
}
_selectedEntries.clear();
}
public boolean isDragAndDropAllowed() { public boolean isDragAndDropAllowed() {
return _sortCategory == SortCategory.CUSTOM && _groupFilter == null && _searchFilter == null; return _sortCategory == SortCategory.CUSTOM && _groupFilter == null && _searchFilter == null;
} }

@ -14,7 +14,6 @@ import androidx.recyclerview.widget.RecyclerView;
import com.amulyakhare.textdrawable.TextDrawable; import com.amulyakhare.textdrawable.TextDrawable;
import com.beemdevelopment.aegis.R; import com.beemdevelopment.aegis.R;
import com.beemdevelopment.aegis.vault.VaultEntry;
import com.beemdevelopment.aegis.helpers.TextDrawableHelper; import com.beemdevelopment.aegis.helpers.TextDrawableHelper;
import com.beemdevelopment.aegis.helpers.ThemeHelper; import com.beemdevelopment.aegis.helpers.ThemeHelper;
import com.beemdevelopment.aegis.helpers.UiRefresher; import com.beemdevelopment.aegis.helpers.UiRefresher;
@ -22,6 +21,7 @@ import com.beemdevelopment.aegis.otp.HotpInfo;
import com.beemdevelopment.aegis.otp.OtpInfo; import com.beemdevelopment.aegis.otp.OtpInfo;
import com.beemdevelopment.aegis.otp.SteamInfo; import com.beemdevelopment.aegis.otp.SteamInfo;
import com.beemdevelopment.aegis.otp.TotpInfo; import com.beemdevelopment.aegis.otp.TotpInfo;
import com.beemdevelopment.aegis.vault.VaultEntry;
import com.bumptech.glide.Glide; import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy; import com.bumptech.glide.load.engine.DiskCacheStrategy;
@ -37,6 +37,9 @@ public class EntryHolder extends RecyclerView.ViewHolder {
private VaultEntry _entry; private VaultEntry _entry;
private ImageView _buttonRefresh; private ImageView _buttonRefresh;
private RelativeLayout _description; private RelativeLayout _description;
private final ImageView _selected;
private final Handler _selectedHandler;
private boolean _hidden; private boolean _hidden;
@ -46,6 +49,9 @@ public class EntryHolder extends RecyclerView.ViewHolder {
private UiRefresher _refresher; private UiRefresher _refresher;
private Handler _animationHandler; private Handler _animationHandler;
private Animation _scaleIn;
private Animation _scaleOut;
public EntryHolder(final View view) { public EntryHolder(final View view) {
super(view); super(view);
@ -58,12 +64,17 @@ public class EntryHolder extends RecyclerView.ViewHolder {
_description = view.findViewById(R.id.description); _description = view.findViewById(R.id.description);
_profileDrawable = view.findViewById(R.id.ivTextDrawable); _profileDrawable = view.findViewById(R.id.ivTextDrawable);
_buttonRefresh = view.findViewById(R.id.buttonRefresh); _buttonRefresh = view.findViewById(R.id.buttonRefresh);
_selected = view.findViewById(R.id.ivSelected);
_selectedHandler = new Handler();
_progressBar = view.findViewById(R.id.progressBar); _progressBar = view.findViewById(R.id.progressBar);
int primaryColorId = view.getContext().getResources().getColor(R.color.colorPrimary); int primaryColorId = view.getContext().getResources().getColor(R.color.colorPrimary);
_progressBar.getProgressDrawable().setColorFilter(primaryColorId, PorterDuff.Mode.SRC_IN); _progressBar.getProgressDrawable().setColorFilter(primaryColorId, PorterDuff.Mode.SRC_IN);
_view.setBackground(_view.getContext().getResources().getDrawable(R.color.card_background)); _view.setBackground(_view.getContext().getResources().getDrawable(R.color.card_background));
_scaleIn = AnimationUtils.loadAnimation(view.getContext(), R.anim.item_scale_in);
_scaleOut = AnimationUtils.loadAnimation(view.getContext(), R.anim.item_scale_out);
_refresher = new UiRefresher(new UiRefresher.Listener() { _refresher = new UiRefresher(new UiRefresher.Listener() {
@Override @Override
public void onRefresh() { public void onRefresh() {
@ -76,7 +87,7 @@ public class EntryHolder extends RecyclerView.ViewHolder {
@Override @Override
public long getMillisTillNextRefresh() { public long getMillisTillNextRefresh() {
return ((TotpInfo)_entry.getInfo()).getMillisTillNextRotation(); return ((TotpInfo) _entry.getInfo()).getMillisTillNextRotation();
} }
}); });
} }
@ -85,6 +96,10 @@ public class EntryHolder extends RecyclerView.ViewHolder {
_entry = entry; _entry = entry;
_hidden = hidden; _hidden = hidden;
_selected.clearAnimation();
_selected.setVisibility(View.GONE);
_selectedHandler.removeCallbacksAndMessages(null);
// only show the progress bar if there is no uniform period and the entry type is TotpInfo // only show the progress bar if there is no uniform period and the entry type is TotpInfo
setShowProgress(showProgress); setShowProgress(showProgress);
@ -148,6 +163,7 @@ public class EntryHolder extends RecyclerView.ViewHolder {
public void setFocused(boolean focused) { public void setFocused(boolean focused) {
if (focused) { if (focused) {
_selected.setVisibility(View.VISIBLE);
_view.setBackgroundColor(ThemeHelper.getThemeColor(R.attr.cardBackgroundFocused, _view.getContext().getTheme())); _view.setBackgroundColor(ThemeHelper.getThemeColor(R.attr.cardBackgroundFocused, _view.getContext().getTheme()));
} else { } else {
_view.setBackgroundColor(ThemeHelper.getThemeColor(R.attr.cardBackground, _view.getContext().getTheme())); _view.setBackgroundColor(ThemeHelper.getThemeColor(R.attr.cardBackground, _view.getContext().getTheme()));
@ -155,6 +171,17 @@ public class EntryHolder extends RecyclerView.ViewHolder {
_view.setSelected(focused); _view.setSelected(focused);
} }
public void setFocusedAndAnimate(boolean focused) {
setFocused(focused);
if (focused) {
_selected.startAnimation(_scaleIn);
} else {
_selected.startAnimation(_scaleOut);
_selectedHandler.postDelayed(() -> _selected.setVisibility(View.GONE), 150);
}
}
public void destroy() { public void destroy() {
_refresher.destroy(); _refresher.destroy();
} }

@ -139,7 +139,12 @@ public class EntryListView extends Fragment implements EntryAdapter.Listener {
public void setActionModeState(boolean enabled, VaultEntry entry) { public void setActionModeState(boolean enabled, VaultEntry entry) {
_touchCallback.setSelectedEntry(entry); _touchCallback.setSelectedEntry(entry);
_touchCallback.setIsLongPressDragEnabled(enabled && _adapter.isDragAndDropAllowed()); _touchCallback.setIsLongPressDragEnabled(enabled && _adapter.isDragAndDropAllowed());
_adapter.addSelectedEntry(entry);
if (enabled) {
_adapter.addSelectedEntry(entry);
} else {
_adapter.deselectAllEntries();
}
} }
public void setSortCategory(SortCategory sortCategory, boolean apply) { public void setSortCategory(SortCategory sortCategory, boolean apply) {

@ -0,0 +1,11 @@
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="150">
<scale
android:fromXScale="0"
android:fromYScale="0"
android:pivotX="50%"
android:pivotY="50%"
android:toXScale="100%"
android:toYScale="100%" />
</set>

@ -0,0 +1,11 @@
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="150">
<scale
android:fromXScale="100%"
android:fromYScale="100%"
android:pivotX="50%"
android:pivotY="50%"
android:toXScale="0"
android:toYScale="0" />
</set>

@ -0,0 +1,12 @@
<vector android:height="60dp" android:tint="#F7F7F7"
android:viewportHeight="24.0" android:viewportWidth="24.0"
android:width="60dp" xmlns:android="http://schemas.android.com/apk/res/android">
<group
android:scaleX="0.5"
android:scaleY="0.5"
android:pivotX="12"
android:pivotY="12"
>
<path android:fillColor="#FF000000" android:pathData="M9,16.17L4.83,12l-1.42,1.41L9,19 21,7l-1.41,-1.41z"/>
</group>
</vector>

@ -2,11 +2,12 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:foreground="?android:attr/selectableItemBackground" xmlns:app="http://schemas.android.com/apk/res-auto"
android:clickable="true" android:foreground="?android:attr/selectableItemBackground"
android:focusable="true" android:clickable="true"
android:layout_height="wrap_content" android:focusable="true"
android:orientation="vertical"> android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout <LinearLayout
android:orientation="horizontal" android:orientation="horizontal"
@ -30,6 +31,17 @@
android:layout_alignParentLeft="true" android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" android:layout_alignParentStart="true"
/> />
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/ivSelected"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:src="@drawable/item_selected"
android:visibility="gone"
app:civ_circle_background_color="@color/colorSecondary" />
</RelativeLayout> </RelativeLayout>
<RelativeLayout <RelativeLayout

@ -2,6 +2,7 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:foreground="?android:attr/selectableItemBackground" android:foreground="?android:attr/selectableItemBackground"
android:clickable="true" android:clickable="true"
android:focusable="true" android:focusable="true"
@ -30,6 +31,17 @@
android:layout_alignParentLeft="true" android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" android:layout_alignParentStart="true"
/> />
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/ivSelected"
android:layout_width="45dp"
android:layout_height="45dp"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:src="@drawable/item_selected"
android:visibility="gone"
app:civ_circle_background_color="@color/colorSecondary" />
</RelativeLayout> </RelativeLayout>
<RelativeLayout <RelativeLayout

@ -2,6 +2,7 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:foreground="?android:attr/selectableItemBackground" android:foreground="?android:attr/selectableItemBackground"
android:clickable="true" android:clickable="true"
android:focusable="true" android:focusable="true"
@ -30,6 +31,17 @@
android:layout_alignParentLeft="true" android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" android:layout_alignParentStart="true"
/> />
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/ivSelected"
android:layout_width="45dp"
android:layout_height="45dp"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:src="@drawable/item_selected"
android:visibility="gone"
app:civ_circle_background_color="@color/colorSecondary" />
</RelativeLayout> </RelativeLayout>
<RelativeLayout <RelativeLayout

@ -29,7 +29,7 @@
<color name="card_background_dark">#363636</color> <color name="card_background_dark">#363636</color>
<color name="card_background_focused_dark">#6B6B6B</color> <color name="card_background_focused_dark">#6B6B6B</color>
<color name="card_background_focused_true_dark">#1B1B1B</color> <color name="card_background_focused_true_dark">#363636</color>
<color name="primary_text_dark">#ffffff</color> <color name="primary_text_dark">#ffffff</color>
<color name="hint_text_dark">#a7a7a7</color> <color name="hint_text_dark">#a7a7a7</color>
<color name="secondary_text_dark">#FF5252</color> <color name="secondary_text_dark">#FF5252</color>

Loading…
Cancel
Save