diff --git a/src/main/java/org/ligi/passandroid/model/Pass.java b/src/main/java/org/ligi/passandroid/model/Pass.java index 0c5c0929..5e908fde 100644 --- a/src/main/java/org/ligi/passandroid/model/Pass.java +++ b/src/main/java/org/ligi/passandroid/model/Pass.java @@ -16,12 +16,14 @@ public interface Pass extends Serializable { String BITMAP_THUMBNAIL = "thumbnail"; String BITMAP_STRIP = "strip"; String BITMAP_LOGO = "logo"; + String BITMAP_FOOTER = "footer"; - @StringDef({BITMAP_ICON, BITMAP_THUMBNAIL, BITMAP_STRIP, BITMAP_LOGO}) + @StringDef({BITMAP_ICON, BITMAP_THUMBNAIL, BITMAP_STRIP, BITMAP_LOGO, BITMAP_FOOTER}) @Retention(RetentionPolicy.SOURCE) @interface PassBitmap { } + String[] TYPES = new String[]{"generic", "coupon", "eventTicket", "boardingPass", "storeCard"}; String getDescription(); diff --git a/src/main/java/org/ligi/passandroid/reader/AppleStylePassReader.java b/src/main/java/org/ligi/passandroid/reader/AppleStylePassReader.java index 8343dabc..e3a6d358 100644 --- a/src/main/java/org/ligi/passandroid/reader/AppleStylePassReader.java +++ b/src/main/java/org/ligi/passandroid/reader/AppleStylePassReader.java @@ -54,6 +54,7 @@ public class AppleStylePassReader { copyBitmapFile(path, localized_path, PassImpl.BITMAP_LOGO); copyBitmapFile(path, localized_path, PassImpl.BITMAP_STRIP); copyBitmapFile(path, localized_path, PassImpl.BITMAP_THUMBNAIL); + copyBitmapFile(path, localized_path, PassImpl.BITMAP_FOOTER); final File file = new File(path + "/pass.json"); diff --git a/src/main/java/org/ligi/passandroid/ui/PassViewActivity.java b/src/main/java/org/ligi/passandroid/ui/PassViewActivity.java index f82592e4..2abef02d 100644 --- a/src/main/java/org/ligi/passandroid/ui/PassViewActivity.java +++ b/src/main/java/org/ligi/passandroid/ui/PassViewActivity.java @@ -1,8 +1,10 @@ package org.ligi.passandroid.ui; +import android.content.Context; import android.content.Intent; import android.graphics.Bitmap; import android.os.Bundle; +import android.support.annotation.NonNull; import android.support.v4.app.NavUtils; import android.support.v4.app.TaskStackBuilder; import android.text.Html; @@ -13,6 +15,7 @@ import android.view.View; import android.view.ViewGroup; import android.view.WindowManager; import android.widget.ImageView; +import android.widget.LinearLayout; import android.widget.TextView; import butterknife.ButterKnife; import butterknife.InjectView; @@ -51,6 +54,9 @@ public class PassViewActivity extends PassViewActivityBase { @InjectView(R.id.logo_img) ImageView logo_img; + @InjectView(R.id.footer_img) + ImageView footer_img; + @InjectView(R.id.thumbnail_img) ImageView thumbnail_img; @@ -114,8 +120,7 @@ public class PassViewActivity extends PassViewActivityBase { } setBitmapSafe(logo_img, pass.getBitmap(Pass.BITMAP_LOGO)); - - logo_img.setBackgroundColor(pass.getBackgroundColor()); + setBitmapSafe(footer_img, pass.getBitmap(Pass.BITMAP_FOOTER)); setBitmapSafe(thumbnail_img, pass.getBitmap(Pass.BITMAP_THUMBNAIL)); setBitmapSafe(strip_img, pass.getBitmap(Pass.BITMAP_STRIP)); @@ -179,14 +184,31 @@ public class PassViewActivity extends PassViewActivityBase { private static void setBitmapSafe(ImageView imageView, Bitmap bitmap) { if (bitmap != null) { + imageView.setLayoutParams(getLayoutParamsSoThatWeHaveAtLeasHalfAFinger(imageView, bitmap)); + imageView.setImageBitmap(bitmap); imageView.setVisibility(View.VISIBLE); + imageView.requestLayout(); } else { imageView.setVisibility(View.GONE); } } + @NonNull + private static ViewGroup.LayoutParams getLayoutParamsSoThatWeHaveAtLeasHalfAFinger(final ImageView imageView, final Bitmap bitmap) { + final Context context = imageView.getContext(); + final int halfAFingerInPixels = context.getResources().getDimensionPixelSize(R.dimen.finger)/2 ; + final ViewGroup.LayoutParams params=imageView.getLayoutParams(); + if (bitmap.getHeight()< halfAFingerInPixels) { + params.height= halfAFingerInPixels; + + } else { + params.height= LinearLayout.LayoutParams.WRAP_CONTENT; + } + return params; + } + @Override public boolean onPrepareOptionsMenu(Menu menu) { diff --git a/src/main/res/layout/pass_view_extra_data.xml b/src/main/res/layout/pass_view_extra_data.xml index b0263891..eaa6db3f 100644 --- a/src/main/res/layout/pass_view_extra_data.xml +++ b/src/main/res/layout/pass_view_extra_data.xml @@ -1,78 +1,91 @@ + xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical"> + android:id="@+id/thumbnail_img" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center_horizontal" + android:contentDescription="@string/logo" + android:paddingBottom="10dp"/> + android:id="@+id/strip_img" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center_horizontal" + android:paddingBottom="10dp" + tools:ignore="ContentDescription"/> - - - - - - - - - - - - android:visibility="gone" /> + + + + + + + + + + + android:id="@+id/logo_img" + android:scaleType="fitXY" + tools:src="@drawable/ic_launcher" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center_horizontal" + android:adjustViewBounds="true" + android:contentDescription="@string/logo" + android:padding="8dp"/> + + + \ No newline at end of file