mirror of
https://github.com/zxing/zxing.git
synced 2025-01-12 19:57:27 -08:00
Added an option to hide the contents when encoding a barcode via Intent.
git-svn-id: https://zxing.googlecode.com/svn/trunk@1988 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
d7c5cc9b38
commit
deea2105b7
|
@ -142,6 +142,12 @@ public final class Intents {
|
|||
*/
|
||||
public static final String FORMAT = "ENCODE_FORMAT";
|
||||
|
||||
/**
|
||||
* Normally the contents of the barcode are displayed to the user in a TextView. Setting this
|
||||
* boolean to false will hide that TextView, showing only the encode barcode.
|
||||
*/
|
||||
public static final String SHOW_CONTENTS = "ENCODE_SHOW_CONTENTS";
|
||||
|
||||
private Encode() {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -171,8 +171,13 @@ public final class EncodeActivity extends Activity {
|
|||
Bitmap bitmap = qrCodeEncoder.encodeAsBitmap();
|
||||
ImageView view = (ImageView) findViewById(R.id.image_view);
|
||||
view.setImageBitmap(bitmap);
|
||||
|
||||
TextView contents = (TextView) findViewById(R.id.contents_text_view);
|
||||
contents.setText(qrCodeEncoder.getDisplayContents());
|
||||
if (intent.getBooleanExtra(Intents.Encode.SHOW_CONTENTS, true)) {
|
||||
contents.setText(qrCodeEncoder.getDisplayContents());
|
||||
} else {
|
||||
contents.setText("");
|
||||
}
|
||||
} catch (WriterException e) {
|
||||
Log.e(TAG, "Could not encode barcode", e);
|
||||
showErrorMessage(R.string.msg_encode_contents_failed);
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
-->
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.google.zxing.client.androidtest"
|
||||
android:versionName="1.12"
|
||||
android:versionCode="4">
|
||||
android:versionName="1.13"
|
||||
android:versionCode="5">
|
||||
<!-- We require Cupcake (Android 1.5) or later, but are really targeting Donut. -->
|
||||
<uses-sdk android:minSdkVersion="3"
|
||||
android:targetSdkVersion="4"/>
|
||||
|
|
|
@ -80,16 +80,20 @@
|
|||
android:text="@string/encode_location"/>
|
||||
</TableRow>
|
||||
<TableRow>
|
||||
<Button android:id="@+id/encode_hidden_data"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/encode_hidden_data"/>
|
||||
<Button android:id="@+id/encode_bad_data"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/encode_bad_data"/>
|
||||
</TableRow>
|
||||
<TableRow>
|
||||
<Button android:id="@+id/share_via_barcode"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/share_via_barcode"/>
|
||||
</TableRow>
|
||||
<TableRow>
|
||||
<Button android:id="@+id/run_benchmark"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
<string name="encode_bad_data">Encode bad data</string>
|
||||
<string name="encode_contact">Encode contact</string>
|
||||
<string name="encode_email">Encode email</string>
|
||||
<string name="encode_hidden_data">Encode hidden data</string>
|
||||
<string name="encode_location">Encode location</string>
|
||||
<string name="encode_phone">Encode phone</string>
|
||||
<string name="encode_sms">Encode SMS</string>
|
||||
|
|
|
@ -40,7 +40,6 @@ public final class ZXingTestActivity extends Activity {
|
|||
|
||||
findViewById(R.id.take_test_photos).setOnClickListener(takeTestPhotos);
|
||||
findViewById(R.id.get_camera_parameters).setOnClickListener(getCameraParameters);
|
||||
findViewById(R.id.run_benchmark).setOnClickListener(runBenchmark);
|
||||
findViewById(R.id.scan_product).setOnClickListener(scanProduct);
|
||||
findViewById(R.id.scan_qr_code).setOnClickListener(scanQRCode);
|
||||
findViewById(R.id.scan_anything).setOnClickListener(scanAnything);
|
||||
|
@ -51,8 +50,10 @@ public final class ZXingTestActivity extends Activity {
|
|||
findViewById(R.id.encode_sms).setOnClickListener(encodeSMS);
|
||||
findViewById(R.id.encode_contact).setOnClickListener(encodeContact);
|
||||
findViewById(R.id.encode_location).setOnClickListener(encodeLocation);
|
||||
findViewById(R.id.encode_hidden_data).setOnClickListener(encodeHiddenData);
|
||||
findViewById(R.id.encode_bad_data).setOnClickListener(encodeBadData);
|
||||
findViewById(R.id.share_via_barcode).setOnClickListener(shareViaBarcode);
|
||||
findViewById(R.id.run_benchmark).setOnClickListener(runBenchmark);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -202,6 +203,16 @@ public final class ZXingTestActivity extends Activity {
|
|||
}
|
||||
};
|
||||
|
||||
public final Button.OnClickListener encodeHiddenData = new Button.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent("com.google.zxing.client.android.ENCODE");
|
||||
intent.putExtra("ENCODE_TYPE", "TEXT_TYPE");
|
||||
intent.putExtra("ENCODE_DATA", "SURPRISE!");
|
||||
intent.putExtra("ENCODE_SHOW_CONTENTS", false);
|
||||
startActivity(intent);
|
||||
}
|
||||
};
|
||||
|
||||
public final Button.OnClickListener encodeBadData = new Button.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
encodeBarcode(null, "bar");
|
||||
|
|
Loading…
Reference in a new issue