Show tags on the etnry cards

This commit is contained in:
RichyHBM 2017-11-12 13:14:14 +00:00
parent 11b9d0164a
commit fbc38ecb9d
3 changed files with 25 additions and 2 deletions

View file

@ -150,7 +150,7 @@ public class EntriesCardAdapter extends RecyclerView.Adapter<EntryViewHolder>
public void onBindViewHolder(EntryViewHolder entryViewHolder, int i) {
Entry entry = displayedEntries.get(i);
entryViewHolder.updateValues(entry.getLabel(), entry.getCurrentOTP());
entryViewHolder.updateValues(entry.getLabel(), entry.getCurrentOTP(), entry.getTags());
if (entry.hasNonDefaultPeriod()) {
entryViewHolder.showCustomPeriod(entry.getPeriod());

View file

@ -37,6 +37,8 @@ import org.shadowice.flocke.andotp.Utilities.Tools;
import org.shadowice.flocke.andotp.View.ItemTouchHelper.ItemTouchHelperViewHolder;
import org.shadowice.flocke.andotp.R;
import java.util.List;
public class EntryViewHolder extends RecyclerView.ViewHolder
implements ItemTouchHelperViewHolder {
@ -51,6 +53,7 @@ public class EntryViewHolder extends RecyclerView.ViewHolder
private ImageView visibleImg;
private TextView value;
private TextView label;
private TextView tags;
private TextView customPeriod;
@ -65,6 +68,7 @@ public class EntryViewHolder extends RecyclerView.ViewHolder
visibleImg = v.findViewById(R.id.valueImg);
coverLayout = v.findViewById(R.id.coverLayout);
label = v.findViewById(R.id.textViewLabel);
tags = v.findViewById(R.id.textViewTags);
customPeriodLayout = v.findViewById(R.id.customPeriodLayout);
customPeriod = v.findViewById(R.id.customPeriod);
@ -98,9 +102,19 @@ public class EntryViewHolder extends RecyclerView.ViewHolder
});
}
public void updateValues(String label, String token) {
public void updateValues(String label, String token, List<String> tags) {
this.label.setText(label);
value.setText(token);
StringBuilder stringBuilder = new StringBuilder();
for(int i = 0; i < tags.size(); i++) {
stringBuilder.append(tags.get(i));
if(i < tags.size() - 1) {
stringBuilder.append(", ");
}
}
this.tags.setText(stringBuilder.toString());
}
public void showCustomPeriod(int period) {
@ -114,6 +128,7 @@ public class EntryViewHolder extends RecyclerView.ViewHolder
public void setLabelSize(int size) {
label.setTextSize(TypedValue.COMPLEX_UNIT_PT, size);
tags.setTextSize(TypedValue.COMPLEX_UNIT_PT, size - 2);
}
public void enableTapToReveal() {

View file

@ -79,6 +79,14 @@
android:ellipsize="end"
android:textSize="8pt" />
<TextView
android:id="@+id/textViewTags"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="1"
android:ellipsize="end"
android:textSize="6pt" />
</LinearLayout>
<LinearLayout