mirror of
https://github.com/zxing/zxing.git
synced 2025-03-05 20:48:51 -08:00
- Added back support for Cupcake by making the choice of preview callback conditional on the build flavor.
- Fixed a number of non-dpi-aware resource dimensions. - Bumped the version to 3.0 beta 3. git-svn-id: https://zxing.googlecode.com/svn/trunk@1081 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
c36697c812
commit
7f428a3a9b
|
@ -20,10 +20,10 @@ version to be published. The next versionCode will be 7, regardless of whether t
|
||||||
versionName is 2.31, 2.4, or 3.0. -->
|
versionName is 2.31, 2.4, or 3.0. -->
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="com.google.zxing.client.android"
|
package="com.google.zxing.client.android"
|
||||||
android:versionName="3.0 beta2"
|
android:versionName="3.0 beta3"
|
||||||
android:versionCode="36">
|
android:versionCode="37">
|
||||||
<!-- We require Donut (Android 1.6) or later. -->
|
<!-- We require Cupcake (Android 1.5) or later. -->
|
||||||
<uses-sdk android:minSdkVersion="4"/>
|
<uses-sdk android:minSdkVersion="3"/>
|
||||||
<!-- Donut-specific flags which allow us to run on large and high dpi screens. -->
|
<!-- Donut-specific flags which allow us to run on large and high dpi screens. -->
|
||||||
<supports-screens
|
<supports-screens
|
||||||
android:largeScreens="true"
|
android:largeScreens="true"
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:textColor="@color/contents_text"
|
android:textColor="@color/contents_text"
|
||||||
android:textSize="20.0sp"
|
android:textSize="20.0sp"
|
||||||
android:paddingRight="8px"
|
android:paddingRight="8dip"
|
||||||
android:paddingTop="8px"
|
android:paddingTop="8dip"
|
||||||
android:paddingBottom="8px"/>
|
android:paddingBottom="8dip"/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
android:layout_height="fill_parent"
|
android:layout_height="fill_parent"
|
||||||
android:background="@color/share_view"
|
android:background="@color/share_view"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:padding="16px">
|
android:padding="16dip">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
|
@ -29,7 +29,7 @@
|
||||||
android:textColor="@color/share_text"
|
android:textColor="@color/share_text"
|
||||||
android:textSize="18.0sp"
|
android:textSize="18.0sp"
|
||||||
android:text="@string/msg_share_explanation"
|
android:text="@string/msg_share_explanation"
|
||||||
android:paddingBottom="32px"/>
|
android:paddingBottom="32dip"/>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
@ -43,7 +43,7 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:scaleType="center"
|
android:scaleType="center"
|
||||||
android:src="@drawable/share_via_barcode"
|
android:src="@drawable/share_via_barcode"
|
||||||
android:paddingRight="48px"/>
|
android:paddingRight="48dip"/>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:padding="4px">
|
android:padding="4dip">
|
||||||
|
|
||||||
|
|
||||||
<TextView android:id="@+id/bookmark_title"
|
<TextView android:id="@+id/bookmark_title"
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
android:layout_height="fill_parent"
|
android:layout_height="fill_parent"
|
||||||
android:background="@color/result_view"
|
android:background="@color/result_view"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
android:padding="4px">
|
android:padding="4dip">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
|
@ -43,7 +43,7 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:gravity="top"
|
android:gravity="top"
|
||||||
android:padding="12px">
|
android:padding="12dip">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
|
@ -54,7 +54,7 @@
|
||||||
<ImageView android:id="@+id/barcode_image_view"
|
<ImageView android:id="@+id/barcode_image_view"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="4px"
|
android:layout_marginBottom="4dip"
|
||||||
android:adjustViewBounds="true"
|
android:adjustViewBounds="true"
|
||||||
android:scaleType="centerInside"/>
|
android:scaleType="centerInside"/>
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@
|
||||||
android:text="@string/msg_default_contents"
|
android:text="@string/msg_default_contents"
|
||||||
android:textColor="@color/result_text"
|
android:textColor="@color/result_text"
|
||||||
android:textSize="22sp"
|
android:textSize="22sp"
|
||||||
android:paddingLeft="12px"
|
android:paddingLeft="12dip"
|
||||||
android:autoLink="web"/>
|
android:autoLink="web"/>
|
||||||
|
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
@ -140,7 +140,7 @@
|
||||||
android:layout_weight="0"
|
android:layout_weight="0"
|
||||||
android:background="@color/status_view"
|
android:background="@color/status_view"
|
||||||
android:baselineAligned="false"
|
android:baselineAligned="false"
|
||||||
android:padding="4px">
|
android:padding="4dip">
|
||||||
|
|
||||||
<TextView android:id="@+id/status_text_view"
|
<TextView android:id="@+id/status_text_view"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
|
|
@ -41,8 +41,8 @@
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:textColor="@color/contents_text"
|
android:textColor="@color/contents_text"
|
||||||
android:textSize="20.0sp"
|
android:textSize="20.0sp"
|
||||||
android:paddingBottom="8px"
|
android:paddingBottom="8dip"
|
||||||
android:paddingLeft="8px"
|
android:paddingLeft="8dip"
|
||||||
android:paddingRight="8px"/>
|
android:paddingRight="8dip"/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</ScrollView>
|
</ScrollView>
|
|
@ -25,7 +25,7 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:fadingEdge="vertical"
|
android:fadingEdge="vertical"
|
||||||
android:fadingEdgeLength="16dip"/>
|
android:fadingEdgeLength="12dip"/>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
|
@ -33,7 +33,7 @@
|
||||||
android:layout_weight="0"
|
android:layout_weight="0"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:padding="8px"
|
android:padding="6dip"
|
||||||
android:weightSum="1"
|
android:weightSum="1"
|
||||||
android:background="@color/help_button_view">
|
android:background="@color/help_button_view">
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,8 @@
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="@color/sbc_header_view"
|
android:background="@color/sbc_header_view"
|
||||||
android:paddingLeft="8px"
|
android:paddingLeft="8dip"
|
||||||
|
android:paddingBottom="4dip"
|
||||||
android:enabled="false"
|
android:enabled="false"
|
||||||
android:textColor="@color/sbc_header_text"
|
android:textColor="@color/sbc_header_text"
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
|
|
|
@ -20,13 +20,13 @@
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="@color/sbc_list_item"
|
android:background="@color/sbc_list_item"
|
||||||
android:padding="8px">
|
android:padding="6dip">
|
||||||
|
|
||||||
<TextView android:id="@+id/page_number_view"
|
<TextView android:id="@+id/page_number_view"
|
||||||
android:layout_width="75px"
|
android:layout_width="75dip"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="left|top"
|
android:layout_gravity="left|top"
|
||||||
android:layout_marginRight="8px"
|
android:layout_marginRight="8dip"
|
||||||
android:textColor="@color/sbc_page_number_text"
|
android:textColor="@color/sbc_page_number_text"
|
||||||
android:singleLine="false"
|
android:singleLine="false"
|
||||||
android:textSize="16sp"
|
android:textSize="16sp"
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
android:layout_height="fill_parent"
|
android:layout_height="fill_parent"
|
||||||
android:background="@color/share_view"
|
android:background="@color/share_view"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:padding="16px">
|
android:padding="16dip">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
|
@ -29,7 +29,7 @@
|
||||||
android:textColor="@color/share_text"
|
android:textColor="@color/share_text"
|
||||||
android:textSize="18.0sp"
|
android:textSize="18.0sp"
|
||||||
android:text="@string/msg_share_explanation"
|
android:text="@string/msg_share_explanation"
|
||||||
android:paddingBottom="32px"/>
|
android:paddingBottom="32dip"/>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
@ -43,7 +43,7 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:scaleType="center"
|
android:scaleType="center"
|
||||||
android:src="@drawable/share_via_barcode"
|
android:src="@drawable/share_via_barcode"
|
||||||
android:paddingBottom="32px"/>
|
android:paddingBottom="32dip"/>
|
||||||
|
|
||||||
<Button android:id="@+id/contact_button"
|
<Button android:id="@+id/contact_button"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
|
|
|
@ -23,6 +23,7 @@ import android.graphics.PixelFormat;
|
||||||
import android.graphics.Point;
|
import android.graphics.Point;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.hardware.Camera;
|
import android.hardware.Camera;
|
||||||
|
import android.os.Build;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
@ -60,6 +61,7 @@ final class CameraManager {
|
||||||
private boolean previewing;
|
private boolean previewing;
|
||||||
private int previewFormat;
|
private int previewFormat;
|
||||||
private String previewFormatString;
|
private String previewFormatString;
|
||||||
|
private boolean useOneShotPreviewCallback;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Preview frames are delivered here, which we pass on to the registered handler. Make sure to
|
* Preview frames are delivered here, which we pass on to the registered handler. Make sure to
|
||||||
|
@ -67,6 +69,9 @@ final class CameraManager {
|
||||||
*/
|
*/
|
||||||
private final Camera.PreviewCallback previewCallback = new Camera.PreviewCallback() {
|
private final Camera.PreviewCallback previewCallback = new Camera.PreviewCallback() {
|
||||||
public void onPreviewFrame(byte[] data, Camera camera) {
|
public void onPreviewFrame(byte[] data, Camera camera) {
|
||||||
|
if (!useOneShotPreviewCallback) {
|
||||||
|
camera.setPreviewCallback(null);
|
||||||
|
}
|
||||||
if (previewHandler != null) {
|
if (previewHandler != null) {
|
||||||
Message message = previewHandler.obtainMessage(previewMessage, cameraResolution.x,
|
Message message = previewHandler.obtainMessage(previewMessage, cameraResolution.x,
|
||||||
cameraResolution.y, data);
|
cameraResolution.y, data);
|
||||||
|
@ -115,6 +120,16 @@ final class CameraManager {
|
||||||
camera = null;
|
camera = null;
|
||||||
initialized = false;
|
initialized = false;
|
||||||
previewing = false;
|
previewing = false;
|
||||||
|
|
||||||
|
// Camera.setOneShotPreviewCallback() has a race condition in Cupcake, so we use the older
|
||||||
|
// Camera.setPreviewCallback() on 1.5 and earlier. For Donut and later, we need to use
|
||||||
|
// the more efficient one shot callback, as the older one can swamp the system and cause it
|
||||||
|
// to run out of memory.
|
||||||
|
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.CUPCAKE) {
|
||||||
|
useOneShotPreviewCallback = false;
|
||||||
|
} else {
|
||||||
|
useOneShotPreviewCallback = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -162,6 +177,9 @@ final class CameraManager {
|
||||||
*/
|
*/
|
||||||
public void stopPreview() {
|
public void stopPreview() {
|
||||||
if (camera != null && previewing) {
|
if (camera != null && previewing) {
|
||||||
|
if (!useOneShotPreviewCallback) {
|
||||||
|
camera.setPreviewCallback(null);
|
||||||
|
}
|
||||||
camera.stopPreview();
|
camera.stopPreview();
|
||||||
previewHandler = null;
|
previewHandler = null;
|
||||||
autoFocusHandler = null;
|
autoFocusHandler = null;
|
||||||
|
@ -181,7 +199,11 @@ final class CameraManager {
|
||||||
if (camera != null && previewing) {
|
if (camera != null && previewing) {
|
||||||
previewHandler = handler;
|
previewHandler = handler;
|
||||||
previewMessage = message;
|
previewMessage = message;
|
||||||
camera.setOneShotPreviewCallback(previewCallback);
|
if (useOneShotPreviewCallback) {
|
||||||
|
camera.setOneShotPreviewCallback(previewCallback);
|
||||||
|
} else {
|
||||||
|
camera.setPreviewCallback(previewCallback);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue