From fbc38ecb9d7f63b5a080738f0aa3ef9eb96ba388 Mon Sep 17 00:00:00 2001 From: RichyHBM Date: Sun, 12 Nov 2017 13:14:14 +0000 Subject: [PATCH] Show tags on the etnry cards --- .../flocke/andotp/View/EntriesCardAdapter.java | 2 +- .../flocke/andotp/View/EntryViewHolder.java | 17 ++++++++++++++++- app/src/main/res/layout/component_card.xml | 8 ++++++++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/org/shadowice/flocke/andotp/View/EntriesCardAdapter.java b/app/src/main/java/org/shadowice/flocke/andotp/View/EntriesCardAdapter.java index 297a8008..5a6534e8 100644 --- a/app/src/main/java/org/shadowice/flocke/andotp/View/EntriesCardAdapter.java +++ b/app/src/main/java/org/shadowice/flocke/andotp/View/EntriesCardAdapter.java @@ -150,7 +150,7 @@ public class EntriesCardAdapter extends RecyclerView.Adapter 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()); diff --git a/app/src/main/java/org/shadowice/flocke/andotp/View/EntryViewHolder.java b/app/src/main/java/org/shadowice/flocke/andotp/View/EntryViewHolder.java index dc1df524..f0412bcc 100644 --- a/app/src/main/java/org/shadowice/flocke/andotp/View/EntryViewHolder.java +++ b/app/src/main/java/org/shadowice/flocke/andotp/View/EntryViewHolder.java @@ -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 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() { diff --git a/app/src/main/res/layout/component_card.xml b/app/src/main/res/layout/component_card.xml index 568b1611..490d74ec 100644 --- a/app/src/main/res/layout/component_card.xml +++ b/app/src/main/res/layout/component_card.xml @@ -79,6 +79,14 @@ android:ellipsize="end" android:textSize="8pt" /> + +