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"
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>
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"
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"
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"
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"
android:layout_height="fill_parent"
android:background="@color/result_view"
android:visibility="gone"
- android:padding="4px">
+ android:padding="4dip">
<LinearLayout
android:orientation="horizontal"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="top"
- android:padding="12px">
+ android:padding="12dip">
<LinearLayout
android:orientation="vertical"
<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"/>
android:text="@string/msg_default_contents"
android:textColor="@color/result_text"
android:textSize="22sp"
- android:paddingLeft="12px"
+ android:paddingLeft="12dip"
android:autoLink="web"/>
</ScrollView>
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"
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>
\ No newline at end of file
android:layout_height="wrap_content"
android:layout_weight="1"
android:fadingEdge="vertical"
- android:fadingEdgeLength="16dip"/>
+ android:fadingEdgeLength="12dip"/>
<LinearLayout
android:layout_width="fill_parent"
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">
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"
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"
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"
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"
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"
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;
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
*/
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);
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;
+ }
}
/**
*/
public void stopPreview() {
if (camera != null && previewing) {
+ if (!useOneShotPreviewCallback) {
+ camera.setPreviewCallback(null);
+ }
camera.stopPreview();
previewHandler = null;
autoFocusHandler = null;
if (camera != null && previewing) {
previewHandler = handler;
previewMessage = message;
- camera.setOneShotPreviewCallback(previewCallback);
+ if (useOneShotPreviewCallback) {
+ camera.setOneShotPreviewCallback(previewCallback);
+ } else {
+ camera.setPreviewCallback(previewCallback);
+ }
}
}