[SCM] Multi-format 1D/2D barcode image processing library branch, upstream, updated. 24d4480bc48cf9eabf7b2bd2f528248b0e458809
srowen
srowen at 59b500cc-1b3d-0410-9834-0bbf25fbcc57
Wed Aug 4 01:30:59 UTC 2010
The following commit has been merged in the upstream branch:
commit 1d9b741ec11e1c364a9663807d407e8b9b7394b6
Author: srowen <srowen at 59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Date: Sun Apr 11 10:03:27 2010 +0000
Make sure it's possible un-set custom search URL; sometimes remains as a newline or space
git-svn-id: http://zxing.googlecode.com/svn/trunk@1299 59b500cc-1b3d-0410-9834-0bbf25fbcc57
diff --git a/android/src/com/google/zxing/client/android/result/ISBNResultHandler.java b/android/src/com/google/zxing/client/android/result/ISBNResultHandler.java
index 11f3092..bf3ec78 100644
--- a/android/src/com/google/zxing/client/android/result/ISBNResultHandler.java
+++ b/android/src/com/google/zxing/client/android/result/ISBNResultHandler.java
@@ -16,7 +16,6 @@
package com.google.zxing.client.android.result;
-import com.google.zxing.client.android.PreferencesActivity;
import com.google.zxing.client.android.R;
import com.google.zxing.client.result.ISBNParsedResult;
import com.google.zxing.client.result.ParsedResult;
@@ -24,8 +23,6 @@ import com.google.zxing.client.result.ParsedResult;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
-import android.content.SharedPreferences;
-import android.preference.PreferenceManager;
/**
* Handles books encoded by their ISBN values.
@@ -40,15 +37,11 @@ public final class ISBNResultHandler extends ResultHandler {
R.string.button_google_shopper
};
- private String customProductSearch;
+ private final String customProductSearch;
public ISBNResultHandler(Activity activity, ParsedResult result) {
super(activity, result);
- SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity);
- customProductSearch = prefs.getString(PreferencesActivity.KEY_CUSTOM_PRODUCT_SEARCH, null);
- if (customProductSearch != null && customProductSearch.length() == 0) {
- customProductSearch = null;
- }
+ customProductSearch = parseCustomSearchURL();
}
@Override
diff --git a/android/src/com/google/zxing/client/android/result/ProductResultHandler.java b/android/src/com/google/zxing/client/android/result/ProductResultHandler.java
index 916d8d9..7ad14d3 100644
--- a/android/src/com/google/zxing/client/android/result/ProductResultHandler.java
+++ b/android/src/com/google/zxing/client/android/result/ProductResultHandler.java
@@ -16,7 +16,6 @@
package com.google.zxing.client.android.result;
-import com.google.zxing.client.android.PreferencesActivity;
import com.google.zxing.client.android.R;
import com.google.zxing.client.result.ParsedResult;
import com.google.zxing.client.result.ProductParsedResult;
@@ -24,8 +23,6 @@ import com.google.zxing.client.result.ProductParsedResult;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
-import android.content.SharedPreferences;
-import android.preference.PreferenceManager;
/**
* Handles generic products which are not books.
@@ -40,15 +37,11 @@ public final class ProductResultHandler extends ResultHandler {
R.string.button_custom_product_search,
};
- private String customProductSearch;
+ private final String customProductSearch;
public ProductResultHandler(Activity activity, ParsedResult result) {
super(activity, result);
- SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity);
- customProductSearch = prefs.getString(PreferencesActivity.KEY_CUSTOM_PRODUCT_SEARCH, null);
- if (customProductSearch != null && customProductSearch.length() == 0) {
- customProductSearch = null;
- }
+ customProductSearch = parseCustomSearchURL();
}
@Override
diff --git a/android/src/com/google/zxing/client/android/result/ResultHandler.java b/android/src/com/google/zxing/client/android/result/ResultHandler.java
index e7fc5a1..a93dfd4 100644
--- a/android/src/com/google/zxing/client/android/result/ResultHandler.java
+++ b/android/src/com/google/zxing/client/android/result/ResultHandler.java
@@ -376,4 +376,13 @@ public abstract class ResultHandler {
}
}
+ protected String parseCustomSearchURL() {
+ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity);
+ String customProductSearch = prefs.getString(PreferencesActivity.KEY_CUSTOM_PRODUCT_SEARCH, null);
+ if (customProductSearch != null && customProductSearch.trim().length() == 0) {
+ return null;
+ }
+ return customProductSearch;
+ }
+
}
diff --git a/android/src/com/google/zxing/client/android/result/TextResultHandler.java b/android/src/com/google/zxing/client/android/result/TextResultHandler.java
index c60bd02..0a47730 100644
--- a/android/src/com/google/zxing/client/android/result/TextResultHandler.java
+++ b/android/src/com/google/zxing/client/android/result/TextResultHandler.java
@@ -17,12 +17,9 @@
package com.google.zxing.client.android.result;
import com.google.zxing.client.android.R;
-import com.google.zxing.client.android.PreferencesActivity;
import com.google.zxing.client.result.ParsedResult;
import android.app.Activity;
-import android.content.SharedPreferences;
-import android.preference.PreferenceManager;
/**
* This class handles TextParsedResult as well as unknown formats. It's the fallback handler.
@@ -42,14 +39,12 @@ public final class TextResultHandler extends ResultHandler {
public TextResultHandler(Activity activity, ParsedResult result) {
super(activity, result);
- SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity);
- customProductSearch = prefs.getString(PreferencesActivity.KEY_CUSTOM_PRODUCT_SEARCH, null);
+ customProductSearch = parseCustomSearchURL();
}
@Override
public int getButtonCount() {
- return customProductSearch != null && customProductSearch.length() > 0 ?
- buttons.length : buttons.length - 1;
+ return customProductSearch != null ? buttons.length : buttons.length - 1;
}
@Override
--
Multi-format 1D/2D barcode image processing library
More information about the Pkg-google-commits
mailing list