mirror of
https://github.com/beemdevelopment/Aegis.git
synced 2025-05-15 06:22:49 +00:00
Improve method to notify users on copy
Add minor code improvements
This commit is contained in:
parent
1a7a794dc9
commit
b43bac37db
20 changed files with 164 additions and 25 deletions
|
@ -757,7 +757,6 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
|
|||
ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
ClipData clip = ClipData.newPlainText("text/plain", entry.getInfo().getOtp());
|
||||
clipboard.setPrimaryClip(clip);
|
||||
Toast.makeText(this, getString(R.string.code_copied), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
private class ActionModeCallbacks implements ActionMode.Callback {
|
||||
|
|
|
@ -4,6 +4,8 @@ import android.os.Handler;
|
|||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.AnimationUtils;
|
||||
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
|
@ -340,6 +342,7 @@ public class EntryAdapter extends RecyclerView.Adapter<EntryHolder> implements I
|
|||
|
||||
if (!handled) {
|
||||
_view.onEntryClick(entry);
|
||||
holder.animateCopyText();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,8 +1,12 @@
|
|||
package com.beemdevelopment.aegis.ui.views;
|
||||
|
||||
import android.graphics.PorterDuff;
|
||||
import android.os.Handler;
|
||||
import android.view.View;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.AnimationUtils;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
@ -28,9 +32,11 @@ public class EntryHolder extends RecyclerView.ViewHolder {
|
|||
private TextView _profileName;
|
||||
private TextView _profileCode;
|
||||
private TextView _profileIssuer;
|
||||
private TextView _profileCopied;
|
||||
private ImageView _profileDrawable;
|
||||
private VaultEntry _entry;
|
||||
private ImageView _buttonRefresh;
|
||||
private RelativeLayout _description;
|
||||
|
||||
private boolean _hidden;
|
||||
|
||||
|
@ -38,6 +44,7 @@ public class EntryHolder extends RecyclerView.ViewHolder {
|
|||
private View _view;
|
||||
|
||||
private UiRefresher _refresher;
|
||||
private Handler _animationHandler;
|
||||
|
||||
public EntryHolder(final View view) {
|
||||
super(view);
|
||||
|
@ -47,6 +54,8 @@ public class EntryHolder extends RecyclerView.ViewHolder {
|
|||
_profileName = view.findViewById(R.id.profile_account_name);
|
||||
_profileCode = view.findViewById(R.id.profile_code);
|
||||
_profileIssuer = view.findViewById(R.id.profile_issuer);
|
||||
_profileCopied = view.findViewById(R.id.profile_copied);
|
||||
_description = view.findViewById(R.id.description);
|
||||
_profileDrawable = view.findViewById(R.id.ivTextDrawable);
|
||||
_buttonRefresh = view.findViewById(R.id.buttonRefresh);
|
||||
|
||||
|
@ -200,6 +209,29 @@ public class EntryHolder extends RecyclerView.ViewHolder {
|
|||
animateAlphaTo(DEFAULT_ALPHA);
|
||||
}
|
||||
|
||||
public void animateCopyText() {
|
||||
if (_animationHandler != null) {
|
||||
_animationHandler.removeCallbacksAndMessages(null);
|
||||
}
|
||||
Animation slideDownFadeIn = AnimationUtils.loadAnimation(itemView.getContext(), R.anim.slide_down_fade_in);
|
||||
Animation slideDownFadeOut = AnimationUtils.loadAnimation(itemView.getContext(), R.anim.slide_down_fade_out);
|
||||
Animation fadeOut = AnimationUtils.loadAnimation(itemView.getContext(), R.anim.fade_out);
|
||||
Animation fadeIn = AnimationUtils.loadAnimation(itemView.getContext(), R.anim.fade_in);
|
||||
|
||||
_profileCopied.startAnimation(slideDownFadeIn);
|
||||
_description.startAnimation(slideDownFadeOut);
|
||||
|
||||
|
||||
_animationHandler = new Handler();
|
||||
_animationHandler.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
_profileCopied.startAnimation(fadeOut);
|
||||
_description.startAnimation(fadeIn);
|
||||
}
|
||||
}, 3000);
|
||||
}
|
||||
|
||||
private void animateAlphaTo(float alpha) {
|
||||
itemView.animate().alpha(alpha).setDuration(200).start();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue