Skip to content

Commit

Permalink
Merge branch 'next-cleanup'
Browse files Browse the repository at this point in the history
  • Loading branch information
rkistner committed Jun 5, 2016
2 parents 3e12faa + 842895f commit 7d47cd3
Show file tree
Hide file tree
Showing 19 changed files with 383 additions and 285 deletions.
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
### 3.3.0 (Pending)

* Rename CompoundBarcodeView to DecoratedBarcodeView.

### 3.2.0 (2016-02-06)

Expand Down
6 changes: 3 additions & 3 deletions EMBEDDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
For more control over the UI or scanning behaviour, some components may be used directly:

* BarcodeView: Handles displaying the preview and decoding of the barcodes.
* CompoundBarcodeView: Combines BarcodeView with a viewfinder for feedback, as well as some status /
* DecoratedBarcodeView: Combines BarcodeView with a viewfinder for feedback, as well as some status /
prompt text.
* CaptureManager: Manages the InactivityTimer, BeepManager, orientation lock, and returning of the
barcode result.
Expand Down Expand Up @@ -31,7 +31,7 @@ SurfaceView and other components, the camera preview may end up displaying outsi
and over other components. This happens especially when:

1. Placing the scanner inside a dialog, or:
2. Other components are placed before the (Compound)BarcodeView, resulting in a lower z-order.
2. Other components are placed before the (Decorated)BarcodeView, resulting in a lower z-order.

For these cases we have two solutions:

Expand All @@ -50,7 +50,7 @@ The default is to:
You can override these options:

```xml
<com.journeyapps.barcodescanner.CompoundBarcodeView
<com.journeyapps.barcodescanner.DecoratedBarcodeView
android:layout_width="..."
android:layout_height="..."
app:zxing_use_texture_view="false" (defaults to true, only has an effect on Android API 14+)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
package example.zxing;

import android.app.Activity;
import android.content.res.Configuration;
import android.graphics.Color;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.widget.ImageView;

import com.google.zxing.ResultPoint;
import com.journeyapps.barcodescanner.BarcodeCallback;
import com.journeyapps.barcodescanner.BarcodeResult;
import com.journeyapps.barcodescanner.CompoundBarcodeView;
import com.journeyapps.barcodescanner.DecoratedBarcodeView;

import java.util.List;

Expand All @@ -22,7 +20,7 @@
*/
public class ContinuousCaptureActivity extends Activity {
private static final String TAG = ContinuousCaptureActivity.class.getSimpleName();
private CompoundBarcodeView barcodeView;
private DecoratedBarcodeView barcodeView;

private BarcodeCallback callback = new BarcodeCallback() {
@Override
Expand All @@ -46,7 +44,7 @@ protected void onCreate(Bundle savedInstanceState) {

setContentView(R.layout.continuous_scan);

barcodeView = (CompoundBarcodeView) findViewById(R.id.barcode_scanner);
barcodeView = (DecoratedBarcodeView) findViewById(R.id.barcode_scanner);
barcodeView.decodeContinuous(callback);
}

Expand Down
8 changes: 4 additions & 4 deletions sample/src/main/java/example/zxing/CustomScannerActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,24 @@
import android.widget.Button;

import com.journeyapps.barcodescanner.CaptureManager;
import com.journeyapps.barcodescanner.CompoundBarcodeView;
import com.journeyapps.barcodescanner.DecoratedBarcodeView;

/**
* Custom Scannner Activity extending from Activity to display a custom layout form scanner view.
*/
public class CustomScannerActivity extends Activity implements
CompoundBarcodeView.TorchListener {
DecoratedBarcodeView.TorchListener {

private CaptureManager capture;
private CompoundBarcodeView barcodeScannerView;
private DecoratedBarcodeView barcodeScannerView;
private Button switchFlashlightButton;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_custom_scanner);

barcodeScannerView = (CompoundBarcodeView)findViewById(R.id.zxing_barcode_scanner);
barcodeScannerView = (DecoratedBarcodeView)findViewById(R.id.zxing_barcode_scanner);
barcodeScannerView.setTorchListener(this);

switchFlashlightButton = (Button)findViewById(R.id.switch_flashlight);
Expand Down
6 changes: 3 additions & 3 deletions sample/src/main/java/example/zxing/SmallCaptureActivity.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package example.zxing;

import com.journeyapps.barcodescanner.CaptureActivity;
import com.journeyapps.barcodescanner.CompoundBarcodeView;
import com.journeyapps.barcodescanner.DecoratedBarcodeView;

/**
* This activity has a margin.
*/
public class SmallCaptureActivity extends CaptureActivity {
@Override
protected CompoundBarcodeView initializeContent() {
protected DecoratedBarcodeView initializeContent() {
setContentView(R.layout.capture_small);
return (CompoundBarcodeView)findViewById(R.id.zxing_barcode_scanner);
return (DecoratedBarcodeView)findViewById(R.id.zxing_barcode_scanner);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
import android.view.KeyEvent;

import com.journeyapps.barcodescanner.CaptureManager;
import com.journeyapps.barcodescanner.CompoundBarcodeView;
import com.journeyapps.barcodescanner.DecoratedBarcodeView;

/**
* Sample Activity extending from ActionBarActivity to display a Toolbar.
*/
public class ToolbarCaptureActivity extends ActionBarActivity {
private CaptureManager capture;
private CompoundBarcodeView barcodeScannerView;
private DecoratedBarcodeView barcodeScannerView;

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand All @@ -25,7 +25,7 @@ protected void onCreate(Bundle savedInstanceState) {
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);

barcodeScannerView = (CompoundBarcodeView)findViewById(R.id.zxing_barcode_scanner);
barcodeScannerView = (DecoratedBarcodeView)findViewById(R.id.zxing_barcode_scanner);

capture = new CaptureManager(this, barcodeScannerView);
capture.initializeFromIntent(getIntent(), savedInstanceState);
Expand Down
4 changes: 2 additions & 2 deletions sample/src/main/res/layout/activity_custom_scanner.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
android:layout_height="match_parent"
tools:context="example.zxing.CustomScannerActivity">

<com.journeyapps.barcodescanner.CompoundBarcodeView
<com.journeyapps.barcodescanner.DecoratedBarcodeView
android:id="@+id/zxing_barcode_scanner"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:zxing_scanner_layout="@layout/custom_barcode_scanner">
</com.journeyapps.barcodescanner.CompoundBarcodeView>
</com.journeyapps.barcodescanner.DecoratedBarcodeView>

<Button
android:id="@+id/switch_flashlight"
Expand Down
4 changes: 2 additions & 2 deletions sample/src/main/res/layout/capture_appcompat.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
android:layout_alignParentLeft="true"
app:theme="@style/ThemeOverlay.AppCompat.ActionBar"/>

<com.journeyapps.barcodescanner.CompoundBarcodeView
<com.journeyapps.barcodescanner.DecoratedBarcodeView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_below="@+id/my_awesome_toolbar"
Expand All @@ -41,7 +41,7 @@
app:zxing_use_texture_view="true"/>


<!-- Sample for a footer. Also add to CompoundBarcodeView: android:layout_above="@+id/footer" -->
<!-- Sample for a footer. Also add to DecoratedBarcodeView: android:layout_above="@+id/footer" -->
<!-- <TextView
android:id="@+id/footer"
android:layout_width="match_parent"
Expand Down
2 changes: 1 addition & 1 deletion sample/src/main/res/layout/capture_small.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent">

<com.journeyapps.barcodescanner.CompoundBarcodeView
<com.journeyapps.barcodescanner.DecoratedBarcodeView
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
Expand Down
4 changes: 2 additions & 2 deletions sample/src/main/res/layout/continuous_scan.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
android:layout_width="match_parent"
android:layout_height="match_parent">

<com.journeyapps.barcodescanner.CompoundBarcodeView
<com.journeyapps.barcodescanner.DecoratedBarcodeView
android:id="@+id/barcode_scanner"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_above="@+id/buttonsLayout"
android:layout_alignParentTop="true">

</com.journeyapps.barcodescanner.CompoundBarcodeView>
</com.journeyapps.barcodescanner.DecoratedBarcodeView>

<LinearLayout
android:orientation="vertical"
Expand Down
2 changes: 1 addition & 1 deletion zxing-android-embedded/res/layout/zxing_capture.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<!--
This Activity is typically full-screen. Therefore we can safely use centerCrop scaling with
a SurfaceView, without fear of weird artifacts. -->
<com.journeyapps.barcodescanner.CompoundBarcodeView
<com.journeyapps.barcodescanner.DecoratedBarcodeView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/zxing_barcode_scanner"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -697,8 +697,7 @@ private void initCamera() {
return;
}

cameraInstance = new CameraInstance(getContext());
cameraInstance.setCameraSettings(cameraSettings);
cameraInstance = createCameraInstance();

cameraInstance.setReadyHandler(stateHandler);
cameraInstance.open();
Expand All @@ -708,6 +707,19 @@ private void initCamera() {
openedOrientation = getDisplayRotation();
}

/**
* Create a new CameraInstance.
*
* Override to use a custom CameraInstance.
*
* @return a new CameraInstance
*/
protected CameraInstance createCameraInstance() {
CameraInstance cameraInstance = new CameraInstance(getContext());
cameraInstance.setCameraSettings(cameraSettings);
return cameraInstance;
}


private void startCameraPreview(CameraSurface surface) {
if (!previewActive && cameraInstance != null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package com.journeyapps.barcodescanner;

import android.app.Activity;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.support.v4.app.ActivityCompat;
import android.view.KeyEvent;

import com.google.zxing.client.android.R;
Expand All @@ -13,7 +11,7 @@
*/
public class CaptureActivity extends Activity {
private CaptureManager capture;
private CompoundBarcodeView barcodeScannerView;
private DecoratedBarcodeView barcodeScannerView;

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand All @@ -31,9 +29,9 @@ protected void onCreate(Bundle savedInstanceState) {
*
* @return the CompoundBarcodeView
*/
protected CompoundBarcodeView initializeContent() {
protected DecoratedBarcodeView initializeContent() {
setContentView(R.layout.zxing_capture);
return (CompoundBarcodeView)findViewById(R.id.zxing_barcode_scanner);
return (DecoratedBarcodeView)findViewById(R.id.zxing_barcode_scanner);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public class CaptureManager {
private static int cameraPermissionReqCode = 250;

private Activity activity;
private CompoundBarcodeView barcodeView;
private DecoratedBarcodeView barcodeView;
private int orientationLock = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
private static final String SAVED_ORIENTATION_LOCK = "SAVED_ORIENTATION_LOCK";
private boolean returnBarcodeImagePath = false;
Expand Down Expand Up @@ -116,7 +116,7 @@ public void cameraError(Exception error) {
}
};

public CaptureManager(Activity activity, CompoundBarcodeView barcodeView) {
public CaptureManager(Activity activity, DecoratedBarcodeView barcodeView) {
this.activity = activity;
this.barcodeView = barcodeView;
barcodeView.getBarcodeView().addStateListener(stateListener);
Expand Down
Loading

0 comments on commit 7d47cd3

Please sign in to comment.