From 0e858292b5fe64b005316faf9f12441965a007d6 Mon Sep 17 00:00:00 2001 From: ligi Date: Sun, 21 Sep 2014 19:06:54 +0200 Subject: [PATCH] design update --- .../ligi/passandroid/ui/PassViewActivity.java | 28 +++++++++++++------ src/main/res/layout/main_field_item.xml | 28 +++++++++++++++++++ src/main/res/layout/pass_view_extra_data.xml | 17 +++++------ 3 files changed, 54 insertions(+), 19 deletions(-) create mode 100644 src/main/res/layout/main_field_item.xml diff --git a/src/main/java/org/ligi/passandroid/ui/PassViewActivity.java b/src/main/java/org/ligi/passandroid/ui/PassViewActivity.java index 2abc67bc..89036b9d 100644 --- a/src/main/java/org/ligi/passandroid/ui/PassViewActivity.java +++ b/src/main/java/org/ligi/passandroid/ui/PassViewActivity.java @@ -25,6 +25,8 @@ import org.ligi.passandroid.R; import org.ligi.passandroid.helper.PassVisualizer; import org.ligi.passandroid.maps.PassbookMapsFacade; import org.ligi.passandroid.model.Pass; +import org.ligi.passandroid.model.PassField; +import org.ligi.passandroid.model.PassFieldList; import java.io.File; @@ -51,8 +53,8 @@ public class PassViewActivity extends PassViewActivityBase { @InjectView(R.id.back_fields) TextView back_tv; - @InjectView(R.id.main_fields) - TextView front_tv; + @InjectView(R.id.front_field_container) + ViewGroup frontFieldsContainer; @InjectView(R.id.barcode_alt_text) TextView barcodeAlternatvieText; @@ -126,13 +128,10 @@ public class PassViewActivity extends PassViewActivityBase { } if (pass.getType() != null) { - String front_str = ""; - front_str += PassVisualizer.getFieldListAsString(pass.getHeaderFields()); - front_str += PassVisualizer.getFieldListAsString(pass.getPrimaryFields()); - front_str += PassVisualizer.getFieldListAsString(pass.getSecondaryFields()); - front_str += PassVisualizer.getFieldListAsString(pass.getAuxiliaryFields()); - - front_tv.setText(Html.fromHtml(front_str)); + addFrontFields(pass.getHeaderFields()); + addFrontFields(pass.getPrimaryFields()); + addFrontFields(pass.getSecondaryFields()); + addFrontFields(pass.getAuxiliaryFields()); } String back_str = ""; @@ -148,6 +147,17 @@ public class PassViewActivity extends PassViewActivityBase { PassVisualizer.visualize(this, pass, contentView); } + private void addFrontFields(PassFieldList passFields) { + for (PassField field : passFields) { + View v = getLayoutInflater().inflate(R.layout.main_field_item, null); + TextView key = (TextView) v.findViewById(R.id.key); + key.setText(field.label); + TextView value = (TextView) v.findViewById(R.id.value); + value.setText(field.value); + frontFieldsContainer.addView(v); + } + } + private static void setBitmapSafe(ImageView imageView, Optional bitmapOptional) { if (bitmapOptional.isPresent()) { diff --git a/src/main/res/layout/main_field_item.xml b/src/main/res/layout/main_field_item.xml new file mode 100644 index 00000000..4e63459a --- /dev/null +++ b/src/main/res/layout/main_field_item.xml @@ -0,0 +1,28 @@ + + + + + + + \ No newline at end of file diff --git a/src/main/res/layout/pass_view_extra_data.xml b/src/main/res/layout/pass_view_extra_data.xml index 99a4ca26..a6d0c153 100644 --- a/src/main/res/layout/pass_view_extra_data.xml +++ b/src/main/res/layout/pass_view_extra_data.xml @@ -12,12 +12,11 @@ android:contentDescription="@string/logo" android:paddingBottom="10dp" /> - + android:contentDescription="@string/logo" /> + android:layout_gravity="center_horizontal" + android:paddingBottom="10dp" /> + android:padding="20dp" />