Use the entire card for tap to reveal

Fixes #10
This commit is contained in:
Jakob Nixdorf 2017-07-28 08:15:45 +02:00
parent dc549fa0c2
commit 0ef744d8f8
No known key found for this signature in database
GPG key ID: BE99BF86574A7DBC

View file

@ -29,6 +29,7 @@ import android.content.Context;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.support.v7.widget.CardView;
import android.support.v7.widget.PopupMenu;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
@ -140,7 +141,11 @@ public class EntriesCardAdapter extends RecyclerView.Adapter<EntriesCardAdapter.
}
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(context);
entryViewHolder.setTapToReveal(sharedPref.getBoolean(context.getString(R.string.settings_key_tap_to_reveal), false));
if (sharedPref.getBoolean(context.getString(R.string.settings_key_tap_to_reveal), false)) {
entryViewHolder.enableTapToReveal();
} else {
entryViewHolder.disableTapToReveal();
}
}
@Override
@ -296,8 +301,7 @@ public class EntriesCardAdapter extends RecyclerView.Adapter<EntriesCardAdapter.
private ViewHolderEventCallback eventCallback;
private boolean ttr_enabled = false;
protected CardView card;
protected TextView OTPValue;
protected TextView OTPValueCover;
protected TextView OTPLabel;
@ -309,6 +313,7 @@ public class EntriesCardAdapter extends RecyclerView.Adapter<EntriesCardAdapter.
public EntryViewHolder(final View v) {
super(v);
card = (CardView) v.findViewById(R.id.card_view);
OTPValue = (TextView) v.findViewById(R.id.textViewOTP);
OTPValueCover = (TextView) v.findViewById(R.id.textViewOTPCover);
OTPLabel = (TextView) v.findViewById(R.id.textViewLabel);
@ -332,39 +337,31 @@ public class EntriesCardAdapter extends RecyclerView.Adapter<EntriesCardAdapter.
});
}
public void setTapToReveal(boolean ttr) {
if (ttr) {
public void enableTapToReveal() {
OTPValue.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_visibility_visible, 0, 0, 0);
if (! ttr_enabled || OTPValue.getVisibility() == View.GONE) {
OTPValue.setVisibility(View.GONE);
OTPValueCover.setVisibility(View.VISIBLE);
}
OTPValue.setOnClickListener(new View.OnClickListener() {
card.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
OTPValue.setVisibility(View.GONE);
OTPValueCover.setVisibility(View.VISIBLE);
}
});
OTPValueCover.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
OTPValueCover.setVisibility(View.GONE);
if (OTPValue.getVisibility() == View.GONE && OTPValueCover.getVisibility() == View.VISIBLE) {
OTPValue.setVisibility(View.VISIBLE);
OTPValueCover.setVisibility(View.GONE);
} else {
OTPValue.setVisibility(View.GONE);
OTPValueCover.setVisibility(View.VISIBLE);
}
}
});
} else {
}
public void disableTapToReveal() {
OTPValue.setCompoundDrawables(null, null, null, null);
OTPValue.setVisibility(View.VISIBLE);
OTPValueCover.setVisibility(View.GONE);
OTPValue.setOnClickListener(null);
OTPValueCover.setOnClickListener(null);
}
ttr_enabled = ttr;
card.setOnClickListener(null);
}
@Override