alternative text also for fullscreen barcode

This commit is contained in:
ligi 2014-09-15 20:51:39 +02:00
parent 608d334947
commit 02928402de
4 changed files with 45 additions and 13 deletions

View file

@ -75,9 +75,9 @@ public class TheFullscreenBarcodeActivity extends BaseIntegration<FullscreenBarc
pass.setBarCode(new BarCode(format, BARCODE_MESSAGE));
App.getPassStore().setCurrentPass(pass);
getActivity();
onView(withId(R.id.fullscreen_image)).check(matches(isDisplayed()));
onView(withId(R.id.fullscreen_barcode)).check(matches(isDisplayed()));
final ImageView viewById = ButterKnife.findById(getActivity(), R.id.fullscreen_image);
final ImageView viewById = ButterKnife.findById(getActivity(), R.id.fullscreen_barcode);
BitmapDrawable bitmapDrawable = (BitmapDrawable) viewById.getDrawable();
assertThat(BarcodeDecoder.decodeBitmap(bitmapDrawable.getBitmap())).isEqualTo(BARCODE_MESSAGE);
}

View file

@ -93,7 +93,7 @@ public class ThePassViewActivity extends BaseIntegration<PassViewActivity> {
getActivity();
onView(withId(R.id.barcode_img)).perform(click());
onView(withId(R.id.fullscreen_image)).check(matches(isDisplayed()));
onView(withId(R.id.fullscreen_barcode)).check(matches(isDisplayed()));
}

View file

@ -4,31 +4,51 @@ import android.content.pm.ActivityInfo;
import android.content.res.Configuration;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.TextView;
import com.google.zxing.BarcodeFormat;
import org.ligi.axt.AXT;
import org.ligi.passandroid.R;
import static butterknife.ButterKnife.findById;
import butterknife.ButterKnife;
import butterknife.InjectView;
public class FullscreenBarcodeActivity extends PassViewActivityBase {
@InjectView(R.id.fullscreen_barcode)
ImageView barcodeImageView;
@InjectView(R.id.alternativeBarcodeText)
TextView alternativeBarcodeText;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (optionalPass.isPresent()) {
setContentView(R.layout.fullscreen_image);
final ImageView iv = findById(this, R.id.fullscreen_image);
int smallestSize = AXT.at(getWindowManager()).getSmallestSide();
ButterKnife.inject(this);
final int smallestSize = AXT.at(getWindowManager()).getSmallestSide();
setBestFittingOrientationForBarCode();
iv.setImageBitmap(optionalPass.get().getBarCode().get().getBitmap(smallestSize));
barcodeImageView.setImageBitmap(optionalPass.get().getBarCode().get().getBitmap(smallestSize));
if (optionalPass.get().getBarCode().get().getAlternativeText().isPresent()) {
alternativeBarcodeText.setVisibility(View.VISIBLE);
alternativeBarcodeText.setText(optionalPass.get().getBarCode().get().getAlternativeText().get());
} else {
alternativeBarcodeText.setVisibility(View.GONE);
}
} else {
finish(); // this should never happen, but better safe than sorry
}
}

View file

@ -1,9 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<ImageView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/fullscreen_image"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white"
android:src="@drawable/ic_launcher"/>
android:orientation="vertical">
<ImageView
android:id="@+id/fullscreen_barcode"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:background="@android:color/white" />
<TextView
android:id="@+id/alternativeBarcodeText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:background="@android:color/white" />
</LinearLayout>