mirror of
https://github.com/zxing/zxing.git
synced 2025-02-02 05:41:08 -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. -->
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.google.zxing.client.android"
|
||||
android:versionName="3.0 beta2"
|
||||
android:versionCode="36">
|
||||
<!-- We require Donut (Android 1.6) or later. -->
|
||||
<uses-sdk android:minSdkVersion="4"/>
|
||||
android:versionName="3.0 beta3"
|
||||
android:versionCode="37">
|
||||
<!-- We require Cupcake (Android 1.5) or later. -->
|
||||
<uses-sdk android:minSdkVersion="3"/>
|
||||
<!-- Donut-specific flags which allow us to run on large and high dpi screens. -->
|
||||
<supports-screens
|
||||
android:largeScreens="true"
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
android:gravity="center"
|
||||
android:textColor="@color/contents_text"
|
||||
android:textSize="20.0sp"
|
||||
android:paddingRight="8px"
|
||||
android:paddingTop="8px"
|
||||
android:paddingBottom="8px"/>
|
||||
android:paddingRight="8dip"
|
||||
android:paddingTop="8dip"
|
||||
android:paddingBottom="8dip"/>
|
||||
</LinearLayout>
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
android:layout_height="fill_parent"
|
||||
android:background="@color/share_view"
|
||||
android:orientation="vertical"
|
||||
android:padding="16px">
|
||||
android:padding="16dip">
|
||||
|
||||
<TextView
|
||||
android:layout_width="fill_parent"
|
||||
|
@ -29,7 +29,7 @@
|
|||
android:textColor="@color/share_text"
|
||||
android:textSize="18.0sp"
|
||||
android:text="@string/msg_share_explanation"
|
||||
android:paddingBottom="32px"/>
|
||||
android:paddingBottom="32dip"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -43,7 +43,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:scaleType="center"
|
||||
android:src="@drawable/share_via_barcode"
|
||||
android:paddingRight="48px"/>
|
||||
android:paddingRight="48dip"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
android:orientation="vertical"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="4px">
|
||||
android:padding="4dip">
|
||||
|
||||
|
||||
<TextView android:id="@+id/bookmark_title"
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
android:layout_height="fill_parent"
|
||||
android:background="@color/result_view"
|
||||
android:visibility="gone"
|
||||
android:padding="4px">
|
||||
android:padding="4dip">
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
|
@ -43,7 +43,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="top"
|
||||
android:padding="12px">
|
||||
android:padding="12dip">
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
|
@ -54,7 +54,7 @@
|
|||
<ImageView android:id="@+id/barcode_image_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="4px"
|
||||
android:layout_marginBottom="4dip"
|
||||
android:adjustViewBounds="true"
|
||||
android:scaleType="centerInside"/>
|
||||
|
||||
|
@ -88,7 +88,7 @@
|
|||
android:text="@string/msg_default_contents"
|
||||
android:textColor="@color/result_text"
|
||||
android:textSize="22sp"
|
||||
android:paddingLeft="12px"
|
||||
android:paddingLeft="12dip"
|
||||
android:autoLink="web"/>
|
||||
|
||||
</ScrollView>
|
||||
|
@ -140,7 +140,7 @@
|
|||
android:layout_weight="0"
|
||||
android:background="@color/status_view"
|
||||
android:baselineAligned="false"
|
||||
android:padding="4px">
|
||||
android:padding="4dip">
|
||||
|
||||
<TextView android:id="@+id/status_text_view"
|
||||
android:layout_width="wrap_content"
|
||||
|
|
|
@ -41,8 +41,8 @@
|
|||
android:gravity="center"
|
||||
android:textColor="@color/contents_text"
|
||||
android:textSize="20.0sp"
|
||||
android:paddingBottom="8px"
|
||||
android:paddingLeft="8px"
|
||||
android:paddingRight="8px"/>
|
||||
android:paddingBottom="8dip"
|
||||
android:paddingLeft="8dip"
|
||||
android:paddingRight="8dip"/>
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
|
@ -25,7 +25,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:fadingEdge="vertical"
|
||||
android:fadingEdgeLength="16dip"/>
|
||||
android:fadingEdgeLength="12dip"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="fill_parent"
|
||||
|
@ -33,7 +33,7 @@
|
|||
android:layout_weight="0"
|
||||
android:orientation="horizontal"
|
||||
android:gravity="center"
|
||||
android:padding="8px"
|
||||
android:padding="6dip"
|
||||
android:weightSum="1"
|
||||
android:background="@color/help_button_view">
|
||||
|
||||
|
|
|
@ -18,7 +18,8 @@
|
|||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/sbc_header_view"
|
||||
android:paddingLeft="8px"
|
||||
android:paddingLeft="8dip"
|
||||
android:paddingBottom="4dip"
|
||||
android:enabled="false"
|
||||
android:textColor="@color/sbc_header_text"
|
||||
android:singleLine="true"
|
||||
|
|
|
@ -20,13 +20,13 @@
|
|||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/sbc_list_item"
|
||||
android:padding="8px">
|
||||
android:padding="6dip">
|
||||
|
||||
<TextView android:id="@+id/page_number_view"
|
||||
android:layout_width="75px"
|
||||
android:layout_width="75dip"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="left|top"
|
||||
android:layout_marginRight="8px"
|
||||
android:layout_marginRight="8dip"
|
||||
android:textColor="@color/sbc_page_number_text"
|
||||
android:singleLine="false"
|
||||
android:textSize="16sp"
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
android:layout_height="fill_parent"
|
||||
android:background="@color/share_view"
|
||||
android:orientation="vertical"
|
||||
android:padding="16px">
|
||||
android:padding="16dip">
|
||||
|
||||
<TextView
|
||||
android:layout_width="fill_parent"
|
||||
|
@ -29,7 +29,7 @@
|
|||
android:textColor="@color/share_text"
|
||||
android:textSize="18.0sp"
|
||||
android:text="@string/msg_share_explanation"
|
||||
android:paddingBottom="32px"/>
|
||||
android:paddingBottom="32dip"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -43,7 +43,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:scaleType="center"
|
||||
android:src="@drawable/share_via_barcode"
|
||||
android:paddingBottom="32px"/>
|
||||
android:paddingBottom="32dip"/>
|
||||
|
||||
<Button android:id="@+id/contact_button"
|
||||
android:layout_width="fill_parent"
|
||||
|
|
|
@ -23,6 +23,7 @@ import android.graphics.PixelFormat;
|
|||
import android.graphics.Point;
|
||||
import android.graphics.Rect;
|
||||
import android.hardware.Camera;
|
||||
import android.os.Build;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.util.Log;
|
||||
|
@ -60,6 +61,7 @@ final class CameraManager {
|
|||
private boolean previewing;
|
||||
private int previewFormat;
|
||||
private String previewFormatString;
|
||||
private boolean useOneShotPreviewCallback;
|
||||
|
||||
/**
|
||||
* 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() {
|
||||
public void onPreviewFrame(byte[] data, Camera camera) {
|
||||
if (!useOneShotPreviewCallback) {
|
||||
camera.setPreviewCallback(null);
|
||||
}
|
||||
if (previewHandler != null) {
|
||||
Message message = previewHandler.obtainMessage(previewMessage, cameraResolution.x,
|
||||
cameraResolution.y, data);
|
||||
|
@ -115,6 +120,16 @@ final class CameraManager {
|
|||
camera = null;
|
||||
initialized = 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() {
|
||||
if (camera != null && previewing) {
|
||||
if (!useOneShotPreviewCallback) {
|
||||
camera.setPreviewCallback(null);
|
||||
}
|
||||
camera.stopPreview();
|
||||
previewHandler = null;
|
||||
autoFocusHandler = null;
|
||||
|
@ -181,7 +199,11 @@ final class CameraManager {
|
|||
if (camera != null && previewing) {
|
||||
previewHandler = handler;
|
||||
previewMessage = message;
|
||||
camera.setOneShotPreviewCallback(previewCallback);
|
||||
if (useOneShotPreviewCallback) {
|
||||
camera.setOneShotPreviewCallback(previewCallback);
|
||||
} else {
|
||||
camera.setPreviewCallback(previewCallback);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue