mirror of
https://github.com/zxing/zxing.git
synced 2024-11-10 13:04:05 -08:00
Make sure it's possible un-set custom search URL; sometimes remains as a newline or space
git-svn-id: https://zxing.googlecode.com/svn/trunk@1299 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
10119d1ed0
commit
9cc7f5838c
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue